:root {
  --bg: #fff4e6;
  --ink: #1b1b3a;
  --muted: #1b1b3a99;
  --pink: #ff4f8b;
  --yellow: #ffc93c;
  --teal: #2ec4b6;
  --blue: #3a86ff;
  --orange: #ff7a1a;
  --shadow: #1b1b3a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14142b;
    --ink: #fff4e6;
    --muted: #fff4e699;
    --shadow: #000000;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Fredoka", ui-rounded, system-ui, sans-serif;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  min-height: 100dvh;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Static layout (no JS / reduced motion) ---------- */

#stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.word {
  margin: 0;
  line-height: 1;
  font-weight: 700;
  font-size: clamp(64px, 17vw, 200px);
  letter-spacing: 0.02em;
}

.letter {
  display: inline-block;
  /* Trim the box to cap height and baseline so things rest on the glyphs
     instead of on empty line space. Fredoka caps are ~0.69em tall, so the
     line-height gets within a few px where text-box isn't supported. */
  line-height: 0.7;
  text-box: trim-both cap alphabetic;
  padding: 0 0.04em;
  color: var(--c, var(--ink));
  text-shadow: 0.04em 0.05em 0 var(--shadow);
  user-select: none;
  -webkit-user-select: none;
}
.letter:nth-of-type(5n+2) { --c: var(--pink); }
.letter:nth-of-type(5n+3) { --c: var(--yellow); }
.letter:nth-of-type(5n+4) { --c: var(--teal); }
.letter:nth-of-type(5n+5) { --c: var(--blue); }
.letter:nth-of-type(5n+6) { --c: var(--orange); }

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 2.4vw, 22px);
}

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 560px;
}

.pill {
  display: inline-block;
  padding: 0.55em 1.1em;
  border-radius: 999px;
  border: 3px solid var(--shadow);
  background: var(--c, var(--yellow));
  color: #1b1b3a;
  font-weight: 700;
  font-size: clamp(15px, 2vw, 19px);
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 0 var(--shadow);
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.pill:nth-child(5n+1) { --c: var(--yellow); }
.pill:nth-child(5n+2) { --c: var(--teal); }
.pill:nth-child(5n+3) { --c: var(--pink); }
.pill:nth-child(5n+4) { --c: var(--blue); color: #fff; }
.pill:nth-child(5n+5) { --c: var(--orange); }
.pill:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

#balls, .hint, #sound { display: none; }

/* ---------- Physics mode (set by main.js) ---------- */

.physics body {
  overflow: hidden;
  touch-action: none;
  padding: 0;
  cursor: crosshair;
}

.physics #balls {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.physics #stage {
  position: fixed;
  inset: 0;
  display: block;
}

.physics .word,
.physics .links { display: contents; }

.physics .letter,
.physics .pill {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 50% 100%;
  will-change: transform;
  visibility: hidden;
  cursor: grab;
}
.physics .placed { visibility: visible; }
.physics .held { cursor: grabbing; }

.physics .tagline {
  position: absolute;
  left: 0; right: 0;
  top: 22%;
  pointer-events: none;
}

.physics .hint {
  display: block;
  position: fixed;
  top: 18px; left: 16px;
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  pointer-events: none;
}

.physics #sound {
  display: grid;
  place-items: center;
  position: fixed;
  top: 10px; right: 12px;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
#sound:hover, #sound:focus-visible { color: var(--ink); }
#sound:focus-visible { outline: 3px solid var(--ink); }
#sound .waves { display: none; }
#sound[aria-pressed="true"] .waves { display: inline; }
#sound[aria-pressed="true"] .mute { display: none; }
