/* ---------- Colours (change these to restyle the whole page) ---------- */
:root {
  --plum: #1d1230;
  --plum-light: #2b1a47;
  --mint: #7ff0c8;
  --sun: #ffd84d;
  --pink: #ff8fb7;
  --sky: #7cc0ff;
  --lilac: #c1a8ff;
  --ink: #1d1230;
  --paper: #f6f3ff;
  color-scheme: dark;
}

/* ---------- Basics ---------- */
* { box-sizing: border-box; margin: 0; }

body {
  background: var(--plum);
  background-image: radial-gradient(90% 60% at 10% -10%, var(--plum-light), transparent);
  color: var(--paper);
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1.05rem;
  line-height: 1.5;
  padding: clamp(1rem, 4vw, 3rem);
}

a { color: inherit; }

/* ---------- Header ---------- */
header { max-width: 1200px; margin: 0 auto 2.5rem; }

.clock { color: #cbbfe6; font-size: .95rem; margin-bottom: 1rem; }

h1 {
  font-family: "Unbounded", "Arial Black", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(2.4rem, 8vw, 5.5rem);
  line-height: 1;
  letter-spacing: -.03em;
}

header p:last-child { margin-top: 1rem; max-width: 36rem; color: #cbbfe6; }

/* ---------- The grid of toys ---------- */
.grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
}

.tile {
  color: var(--ink);
  border-radius: 24px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  min-height: 340px;
}

.tile h2 {
  font-family: "Unbounded", system-ui, sans-serif;
  font-weight: 500;
  font-size: 1.15rem;
}

.hint { font-size: .95rem; opacity: .8; margin-top: -.5rem; }
.small { font-size: .9rem; opacity: .85; }
.wide { grid-column: 1 / -1; }

/* tile colours */
.mint { background: var(--mint); }
.sun { background: var(--sun); }
.pink { background: var(--pink); }
.sky { background: var(--sky); }
.lilac { background: var(--lilac); }

/* ---------- Buttons and inputs ---------- */
button {
  font: inherit;
  font-weight: 600;
  color: var(--paper);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: .55rem 1.1rem;
  cursor: pointer;
}
button:hover { filter: brightness(1.3); }
button:active { transform: translateY(1px); }

button:focus-visible, input:focus-visible, textarea:focus-visible, [role=button]:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

input[type=text], textarea {
  font: inherit;
  width: 100%;
  border: 3px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  border-radius: 14px;
  padding: .6rem .8rem;
}
textarea { resize: vertical; min-height: 84px; }

.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

.stat {
  font-family: "Unbounded", system-ui, sans-serif;
  font-weight: 800;
  font-size: 2.2rem;
  line-height: 1;
}
.stat.big { font-size: 3.4rem; }

/* ---------- Doodle pad ---------- */
canvas {
  width: 100%;
  display: block;
  background: var(--paper);
  border-radius: 16px;
  touch-action: none;   /* lets you draw on a phone without the page scrolling */
  cursor: crosshair;
}

.swatch { width: 28px; height: 28px; padding: 0; border: 3px solid transparent; border-radius: 50%; }
.swatch[aria-pressed=true] { border-color: var(--paper); box-shadow: 0 0 0 2px var(--ink); }

/* ---------- Reaction test ---------- */
#pad {
  flex: 1;
  min-height: 160px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1rem;
  border-radius: 16px;
  font-weight: 600;
  font-size: 1.15rem;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  user-select: none;
}
#pad.wait { background: #b3261e; }   /* red: wait */
#pad.go { background: #0f9d58; }     /* green: click now */

/* ---------- Typing sprint ---------- */
#target {
  background: var(--paper);
  border-radius: 16px;
  padding: .9rem 1rem;
  font-size: 1.1rem;
  line-height: 1.7;
}
#target .ok { color: #0a7a45; }                         /* typed right */
#target .bad { background: #ffb3b3; color: #7a0a0a; }   /* typed wrong */
#target .rest { opacity: .55; }                         /* not typed yet */

/* ---------- Decider ---------- */
#result {
  font-family: "Unbounded", system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.8rem;
  min-height: 2.6rem;
  overflow-wrap: anywhere;
}

footer { max-width: 1200px; margin: 2.5rem auto 0; color: #cbbfe6; display: grid; gap: 1.25rem; }

/* Big button that leads to the arcade */
.arcade-btn {
  display: block;
  text-align: center;
  font-family: "Unbounded", system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(1.2rem, 4vw, 2rem);
  color: var(--ink);
  background: var(--mint);
  text-decoration: none;
  border-radius: 24px;
  padding: 1.5rem 1rem;
  transition: transform .15s ease, background .15s ease;
}
.arcade-btn:hover { background: var(--sun); transform: translateY(-3px); }
.arcade-btn:focus-visible { outline: 3px solid var(--paper); outline-offset: 4px; }

/* ---------- Magic 8-ball ---------- */
.peach { background: #ffb38a; }

.ball {
  width: 190px;
  height: 190px;
  margin: .25rem auto;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4b4b63, #0d0d14 62%);
  display: grid;
  place-items: center;
}

.ball-window {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #1b2a6b;
  color: var(--paper);
  display: grid;
  place-items: center;
  text-align: center;
  padding: .5rem;
  font-family: "Unbounded", system-ui, sans-serif;
  font-weight: 800;
  font-size: 2.6rem;
  line-height: 1.15;
}

/* when the ball is giving an answer, the text needs to be smaller */
.ball-window.talking {
  font-size: .78rem;
  font-weight: 500;
}

.ball.shake { animation: shake .7s ease-in-out; }

@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  15%      { transform: translate(-12px, 4px) rotate(-8deg); }
  30%      { transform: translate(12px, -4px) rotate(8deg); }
  45%      { transform: translate(-10px, 6px) rotate(-6deg); }
  60%      { transform: translate(10px, -6px) rotate(6deg); }
  80%      { transform: translate(-4px, 2px) rotate(-2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ball.shake { animation: none; }
}

/* ---------- Scratchpad ---------- */
.notes {
  min-height: 220px;
  font-size: 1.05rem;
  line-height: 1.6;
}

/* ---------- Jukebox ---------- */
.lime { background: #b8f26b; }

.row input[type=text] { flex: 1; min-width: 200px; width: auto; }

.chip {
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: .3rem .85rem;
  font-size: .95rem;
}
.chip:hover { background: var(--ink); color: var(--paper); filter: none; }

.tracks {
  list-style: none;
  padding: 0;
  display: grid;
  gap: .5rem;
  max-height: 320px;      /* scrolls if there are many results */
  overflow-y: auto;
}

.track {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  text-align: left;
  background: var(--paper);
  color: var(--ink);
  border-radius: 14px;
  padding: .5rem .75rem;
}
.track img { border-radius: 8px; flex: none; }
.track[aria-current=true] { outline: 3px solid var(--ink); }

.now {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  background: var(--paper);
  border-radius: 16px;
  padding: .75rem;
}
.now[hidden] { display: none; }   /* needed because .now sets display:flex */
.now img { border-radius: 10px; }
.now-text { display: flex; flex-direction: column; min-width: 140px; flex: 1; }
.now input[type=range] { flex: 2; min-width: 140px; accent-color: var(--ink); }

/* ---------- Jukebox dock (fixed to the right edge) ---------- */
.dock {
  position: fixed;
  right: env(safe-area-inset-right, 0px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  display: flex;
  align-items: flex-start;
  max-height: 90vh;
}

/* the little tab you click to open and close */
.dock-tab {
  writing-mode: vertical-rl;
  background: #b8f26b;
  color: var(--ink);
  border-radius: 16px 0 0 16px;
  padding: 1rem .6rem;
}

/* the panel itself */
.dock-body {
  width: min(320px, calc(100vw - 3.5rem));
  max-height: 90vh;
  overflow-y: auto;
  background: #b8f26b;
  color: var(--ink);
  padding: 1rem;
  border-radius: 0 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: .8rem;
}
.dock:not(.open) .dock-body { display: none; }   /* collapsed: only the tab shows */

.dock-body h2 {
  font-family: "Unbounded", system-ui, sans-serif;
  font-weight: 500;
  font-size: 1.1rem;
}
.dock-body .row input[type=text] { min-width: 0; }
.dock .tracks { max-height: 180px; }

/* ---------- Full-Height Results Inside Search Dock ---------- */
.dock .tracks {
  max-height: 45vh;
  min-height: 180px;
}

/* ---------- Floating Bottom-Right Mini-Player ---------- */
.mini-player {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 30;
  width: 224px;
  background: #b8f26b;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 20px;
  padding: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.mini-player[hidden] {
  display: none;
}

.yt-box {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: var(--ink);
  margin: 0 auto;
}
.yt-box iframe {
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}

.mini-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.mini-info b,
.mini-info small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}
.mini-controls button {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.mini-player input[type=range] {
  width: 100%;
  accent-color: var(--ink);
  cursor: pointer;
}

.mini-player.dragging {
  cursor: grabbing;
}
.mini-close {
  position: absolute;
  top: -10px;
  right: -10px;
  z-index: 2;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #ff5c5c;
  color: var(--ink);
  display: grid;
  place-items: center;
  line-height: 1;
}
