/* ============================================================
   Letter Lagoon - styles
   Tropical lagoon theme: turquoise water, sand, coral, palm.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --ink: #123c46;
  --ink-soft: #3d6470;
  --ink-faint: #6f95a0;

  --lagoon-deep: #0b4f5e;
  --lagoon: #0f8fa3;
  --lagoon-bright: #19b3c2;
  --turquoise: #2ec4b6;
  --foam: #d9f6f4;

  --sand: #f2e3c1;
  --sand-deep: #e3c98f;
  --cream: #fff8ea;
  --cream-2: #fdf1d8;
  --shell-line: #ecdcb8;

  --coral: #ff6b6b;
  --coral-deep: #e8536a;
  --coral-soft: #ffd9d3;

  --palm: #2a9d8f;
  --palm-deep: #1d7a70;

  --gold: #ffd166;

  --ocean: #2b6fd6; /* uncommon rarity, kept distinct from the common teal */

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow-card: 0 10px 30px rgba(7, 58, 70, 0.16), 0 2px 6px rgba(7, 58, 70, 0.10);
  --shadow-lift: 0 16px 44px rgba(7, 58, 70, 0.22), 0 4px 10px rgba(7, 58, 70, 0.12);

  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system,
    "Helvetica Neue", Arial, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% -10%, #fff3d6 0%, rgba(255, 243, 214, 0) 55%),
    linear-gradient(180deg, #ffe9bd 0%, #bfe9e4 24%, #5ecbc4 42%, #2ba8b8 62%, #12758c 100%);
  background-attachment: fixed;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  touch-action: manipulation;
}

/* Visible, on-brand keyboard focus everywhere */
:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Decorative environment (never interactive) ---------- */
.sky-glow,
.water-lines {
  position: fixed;
  pointer-events: none;
  z-index: 0;
}

.sky-glow {
  inset: 0 0 auto 0;
  height: 45dvh;
  background: radial-gradient(55% 80% at 50% 0%, rgba(255, 241, 196, 0.85), rgba(255, 241, 196, 0) 70%);
  transition: opacity 1.1s ease;
}

/* The open-sea setting: cooler, deeper water with light from above.
   Invisible at the shore; it rises as you dive in and stays while you play. */
.deep-water {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.1s ease;
  background:
    radial-gradient(90% 42% at 50% -6%, rgba(255, 243, 214, 0.38), rgba(255, 243, 214, 0) 62%),
    linear-gradient(180deg, #8fe0d8 0%, #2ba8b8 30%, #12758c 58%, #0b4f5e 82%, #073d4d 100%);
}

body[data-screen="game-screen"] .deep-water,
body[data-screen="result-screen"] .deep-water { opacity: 1; }

/* Out at sea the shore sun is behind you. */
body[data-screen="game-screen"] .sky-glow,
body[data-screen="result-screen"] .sky-glow { opacity: 0; }

/* ---------- Voyage ---------- */
/* Full-screen mood tint per stage - sky, then dusk, night, abyss.
   The scenery itself lives in the voyage scene, not the backdrop. */
.voyage-tint {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: rgba(2, 10, 20, 0);
  transition: background-color 1.8s ease;
}

body[data-stage="3"] .voyage-tint { background-color: rgba(9, 55, 70, 0.10); }
body[data-stage="4"] .voyage-tint { background-color: rgba(255, 141, 84, 0.18); }
body[data-stage="5"] .voyage-tint { background-color: rgba(56, 30, 66, 0.32); }
body[data-stage="6"] .voyage-tint { background-color: rgba(10, 22, 44, 0.48); }
body[data-stage="7"] .voyage-tint { background-color: rgba(3, 12, 24, 0.62); }

.water-lines {
  inset: 0;
  background:
    repeating-linear-gradient(
      175deg,
      rgba(255, 255, 255, 0.05) 0 2px,
      rgba(255, 255, 255, 0) 2px 90px
    ),
    repeating-linear-gradient(
      185deg,
      rgba(6, 60, 74, 0.05) 0 2px,
      rgba(6, 60, 74, 0) 2px 130px
    );
}

/* ---------- Layout scaffolding ---------- */
main {
  position: relative;
  z-index: 1;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 6px calc(14px + var(--safe-right)) calc(28px + var(--safe-bottom)) calc(14px + var(--safe-left));
}

.screen {
  display: none;
  flex-direction: column;
  gap: 18px;
  animation: screen-in 0.45s ease both;
}

.screen.active { display: flex; }

/* The game surfaces gently as the dive water recedes. */
.game-screen.active { animation: game-surface 0.9s cubic-bezier(0.3, 0.7, 0.2, 1) both; }

@keyframes game-surface {
  from { opacity: 0; transform: translateY(26px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* The shore: a quiet, centered departure point. */
.start-screen {
  justify-content: center;
  min-height: calc(100dvh - 80px);
  gap: 30px;
}

.start-screen .hero { padding-top: 0; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Shared surfaces ---------- */
.shell-card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0) 40%),
    var(--cream);
  border: 1px solid var(--shell-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--coral-deep);
  text-transform: uppercase;
}

.eyebrow > span {
  height: 1px;
  width: 34px;
  background: linear-gradient(90deg, transparent, var(--coral-soft));
}
.eyebrow > span:last-child {
  background: linear-gradient(90deg, var(--coral-soft), transparent);
}

/* ---------- Ambient sea: the little boat out on the swell ---------- */
.ambience {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

@media (max-width: 559px) {
  .ambience-boat { top: 23dvh; right: 6vw; }

  /* The instrument dash squeezes: focal countdown first, tiny dots. */
  .vp-dash { gap: 10px; padding: 8px 10px; }
  .dash-stage { font-size: 0.58rem; letter-spacing: 0.06em; }
  .dash-next { gap: 4px; }
  .dash-next-label { font-size: 0.78rem; letter-spacing: 0.08em; }
  .dash-next-track { gap: 3px; }
  .dash-next-track i { width: 12px; }
  .day-strip { gap: 3px; }
  .day-strip i { width: 7px; height: 7px; }
  .dash-day { gap: 3px; }
  .dash-dist { display: none; }
}

/* The primary boat - the same coral-sail skiff you sail on the chart,
   riding the horizon in the distance. */
.ambience-boat {
  position: absolute;
  top: 27dvh;
  right: 13vw;
  width: clamp(58px, 8.5vw, 92px);
  opacity: 0.96;
  filter: drop-shadow(0 6px 10px rgba(4, 42, 52, 0.35));
  animation: ambience-bob 6s ease-in-out infinite;
}

.ambience-boat svg { width: 100%; height: auto; display: block; }

@keyframes ambience-bob {
  0%, 100% { transform: translateY(0) rotate(-1.2deg); }
  50%      { transform: translateY(-9px) rotate(1.4deg); }
}

/* The primary swell rolling along the horizon, drifting like the tide. */
.ambience-wave {
  position: absolute;
  left: -25%;
  right: -25%;
  top: 42dvh;
  height: 22px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 22' preserveAspectRatio='none'%3E%3Cpath d='M0 11 Q 15 3 30 11 T 60 11 T 90 11 T 120 11 V 22 H 0 Z' fill='%23ffffff'/%3E/svg%3E") repeat-x;
  background-size: 120px 22px;
  opacity: 0.22;
  animation: wave-drift 11s linear infinite;
}

/* ---------- Shared controls ---------- */
.shore-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding-top: 6px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255, 248, 234, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 3px 12px rgba(7, 58, 70, 0.12);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.icon-button:hover { transform: translateY(-1px); box-shadow: var(--shadow-card); }
.icon-button:active { transform: translateY(1px) scale(0.96); }

/* Sound button: two icon states, toggled by body.muted OR aria-pressed */
.sound-button svg {
  width: 22px;
  height: 22px;
  display: none;
}
body:not(.muted) .sound-button[aria-pressed="false"] .sound-on,
body.muted .sound-button .sound-off,
.sound-button[aria-pressed="true"] .sound-off { display: block; }
.sound-button[aria-pressed="true"] .sound-on { display: none; }

/* ---------- Buttons ---------- */
.primary-button,
.secondary-button,
.text-button,
.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 13px 22px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

/* The same cream face the hero's CAST OFF wears, scaled for in-game use. */
.primary-button,
.submit-button {
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--lagoon-deep);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 55%),
    var(--cream);
  border: 1px solid var(--shell-line);
  border-bottom: 4px solid var(--lagoon);
  box-shadow: 0 6px 14px rgba(4, 42, 52, 0.35), inset 0 -3px 0 rgba(7, 58, 70, 0.08);
}

.primary-button:hover,
.submit-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(4, 42, 52, 0.40), inset 0 -3px 0 rgba(7, 58, 70, 0.08);
}
.primary-button:active,
.submit-button:active { transform: translateY(1px) scale(0.98); }
.primary-button:disabled,
.submit-button:disabled {
  opacity: 0.45;
  transform: none;
  box-shadow: none;
  cursor: not-allowed;
}

.secondary-button {
  color: var(--lagoon-deep);
  background: var(--foam);
  border: 1px solid rgba(15, 143, 163, 0.35);
  border-bottom: 3px solid var(--lagoon);
}

.secondary-button:hover { transform: translateY(-2px); background: #cff1ee; box-shadow: 0 8px 18px rgba(7, 58, 70, 0.16); }
.secondary-button:active { transform: translateY(1px); }

.text-button {
  min-height: 48px;
  color: var(--ink-faint);
  font-weight: 700;
  padding: 10px 16px;
}
.text-button:hover { color: var(--ink); background: rgba(255, 255, 255, 0.5); }

/* ---------- Start screen ---------- */
/* The shore, built from the game's own pieces: alphabet tiles, a paper
   chart, and a button pressed like a tile. No marketing-card scaffolding. */
.hero { text-align: center; padding: 0 8px; }

/* The game's name spelled in its own tiles - same cream faces, 3 life
   pips, rarity bars and waterline bob as the in-game keyboard. */
.title-tiles {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.title-row { display: flex; justify-content: center; gap: 8px; }

.tile {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: clamp(42px, 11vw, 60px);
  min-height: clamp(50px, 13.5vw, 70px);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 55%),
    var(--cream);
  border: 1px solid var(--shell-line);
  box-shadow: 0 4px 10px rgba(4, 42, 52, 0.30), inset 0 -3px 0 rgba(7, 58, 70, 0.08);
  animation: bob 3.4s ease-in-out infinite;
}

.tile b {
  line-height: 1;
  font-size: clamp(1.3rem, 4.6vw, 1.9rem);
  font-weight: 900;
  color: var(--lagoon-deep);
}

.tile .pips i { background: var(--turquoise); }

.tile.common   { border-bottom: 3px solid var(--turquoise); }
.tile.uncommon { border-bottom: 3px solid var(--ocean); }
.tile.epic     { border-bottom: 3px solid var(--gold); }

/* Out-of-step bobbing, like the lagoon at rest. */
.title-row .tile:nth-child(2n)   { animation-duration: 3.9s; animation-delay: -1.4s; }
.title-row .tile:nth-child(3n)   { animation-duration: 3.1s; animation-delay: -0.7s; }
.title-row .tile:nth-child(5n)   { animation-duration: 4.3s; animation-delay: -2.1s; }

.hero-copy {
  margin: 20px 0 0;
  font-size: clamp(1rem, 3.8vw, 1.18rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* The embark block: a route chart and tile-pressed buttons, no card shell. */
.embark {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.embark-meta {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 2px rgba(4, 42, 52, 0.45);
}

.embark-meta #day-badge { color: var(--gold); }

.embark-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.07em;
  color: var(--lagoon-deep);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 55%),
    var(--cream);
  border: 1px solid var(--shell-line);
  border-bottom: 4px solid var(--lagoon);
  box-shadow: 0 6px 14px rgba(4, 42, 52, 0.35), inset 0 -3px 0 rgba(7, 58, 70, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.embark-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(4, 42, 52, 0.40), inset 0 -3px 0 rgba(7, 58, 70, 0.08);
}

.embark-button:active { transform: translateY(1px) scale(0.98); }
.embark-button:disabled { opacity: 0.55; }

.embark-secondary {
  min-height: 48px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink-soft);
  background: rgba(255, 248, 234, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 3px 8px rgba(4, 42, 52, 0.18);
  transition: transform 0.15s ease, background 0.15s ease;
}

.embark-secondary:hover { transform: translateY(-2px); background: rgba(255, 248, 234, 0.8); }
.embark-secondary:active { transform: translateY(1px); }
.embark-secondary:disabled { opacity: 0.55; }

.start-best {
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(4, 42, 52, 0.45);
  padding-top: 2px;
}

/* The sailed shore at home: the tide's clock instead of a note. */
.home-sail-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding-top: 4px;
}

.home-sail-clock span {
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 2px rgba(4, 42, 52, 0.45);
}

.home-sail-clock strong {
  line-height: 1;
  font-size: clamp(1.7rem, 7.5vw, 2.3rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(4, 42, 52, 0.35), 0 6px 16px rgba(4, 42, 52, 0.4);
  font-variant-numeric: tabular-nums;
}

/* The shore after the day is sailed: results and the tide's return. */
/* ---------- Game screen: run bar ---------- */
.run-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
}

.run-mode {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.run-mode span,
#run-mode-label {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255, 248, 234, 0.85);
  box-shadow: 0 3px 12px rgba(7, 58, 70, 0.12);
  transition: transform 0.15s ease, background 0.15s ease;
}
.back-button:hover { transform: translateX(-2px); background: var(--cream); }
.back-button:active { transform: scale(0.94); }

.run-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 14px;
  border-radius: 14px;
  background: rgba(255, 248, 234, 0.85);
  border: 1px solid var(--shell-line);
  box-shadow: 0 3px 12px rgba(7, 58, 70, 0.10);
  min-width: 64px;
}

.run-stat span {
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.run-stat strong { font-size: 1.15rem; font-weight: 900; line-height: 1.15; color: var(--ink); }

.score-stat strong { color: var(--coral-deep); }

.time-stat strong { color: var(--lagoon-deep); }
.time-stat.warn strong { color: #9a6a12; }
.time-stat.danger strong { color: var(--coral-deep); }

/* ---------- The voyage viewport: sky scene + water letters + dash ---------- */
.viewport {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: var(--shadow-card);
}

/* The water panel continues the viewport, edge to edge */
.viewport .lagoon {
  border-radius: 0;
  border: none;
  box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.35), inset 0 -14px 30px rgba(4, 42, 52, 0.45);
}

.vp-sky {
  --sky-h: clamp(140px, 24dvh, 220px);
  position: relative;
  height: var(--sky-h);
  background: linear-gradient(180deg, #9fdcec 0%, #c8eef0 68%, #f2e3c1 100%);
  transition: background 1.6s ease;
}

body[data-stage="3"] .vp-sky { background: linear-gradient(180deg, #8fd0e0 0%, #c2e6df 58%, #f6dcae 100%); }
body[data-stage="4"] .vp-sky { background: linear-gradient(180deg, #ffcf9e 0%, #ffb98a 55%, #ff9d5c 100%); }
body[data-stage="5"] .vp-sky { background: linear-gradient(180deg, #5b3a63 0%, #8a5468 58%, #c96b4f 100%); }
body[data-stage="6"] .vp-sky { background: linear-gradient(180deg, #0d2440 0%, #143a56 68%, #1d506b 100%); }
body[data-stage="7"] .vp-sky { background: linear-gradient(180deg, #04101e 0%, #082033 68%, #0d3145 100%); }
/* Brighter night - the moonlit part of the cycle, stars still out */
body[data-stage="8"] .vp-sky { background: linear-gradient(180deg, #2c4a6e 0%, #40708f 68%, #6b93a6 100%); }

/* Only the sun is clipped, so it can sink below the horizon. */
.vp-clip { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }

.vp-sun {
  position: absolute;
  left: 68%;
  top: 12%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3c4, #ffd166 60%, #ffb347);
  box-shadow: 0 0 24px 6px rgba(255, 209, 102, 0.55);
  transition: left 1.6s ease, top 1.6s ease, width 1.6s ease, height 1.6s ease,
    background 1.6s ease, box-shadow 1.6s ease, opacity 1.6s ease;
}

body[data-stage="3"] .vp-sun { top: 26%; left: 74%; }
body[data-stage="4"] .vp-sun {
  top: 54%; left: 48%;
  width: 54px; height: 54px;
  background: radial-gradient(circle at 35% 35%, #ffdcae, #ff9d5c 65%, #ff7e4d);
  box-shadow: 0 0 34px 10px rgba(255, 157, 92, 0.55);
}
body[data-stage="5"] .vp-sun { top: 88%; left: 26%; width: 44px; height: 44px; opacity: 0.6; }
body[data-stage="6"] .vp-sun,
body[data-stage="7"] .vp-sun,
body[data-stage="8"] .vp-sun {
  left: 70%; top: 10%;
  width: 30px; height: 30px;
  background: radial-gradient(circle at 35% 35%, #ffffff, #e8e4c8 70%, #cfc9a8);
  box-shadow: 0 0 18px 4px rgba(232, 228, 200, 0.4);
}

.vp-clouds i {
  position: absolute;
  width: 64px;
  height: 15px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  top: 18px;
  left: 12%;
  opacity: 0.9;
  transition: opacity 1.6s ease;
  animation: cloud-sway 11s ease-in-out infinite alternate;
}

.vp-clouds i:nth-child(2) { top: 34px; left: 44%; width: 46px; animation-duration: 14s; animation-delay: -4s; }
.vp-clouds i:nth-child(3) { top: 52px; left: 68%; width: 54px; animation-duration: 17s; animation-delay: -9s; }

body[data-stage="5"] .vp-clouds i,
body[data-stage="6"] .vp-clouds i,
body[data-stage="7"] .vp-clouds i,
body[data-stage="8"] .vp-clouds i { opacity: 0; }

@keyframes cloud-sway {
  from { transform: translateX(-26px); }
  to   { transform: translateX(26px); }
}

.vp-stars i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transition: opacity 1.6s ease;
}

body[data-stage="6"] .vp-stars i,
body[data-stage="7"] .vp-stars i,
body[data-stage="8"] .vp-stars i { opacity: 0.9; animation: star-twinkle 2.6s ease-in-out infinite; }

@keyframes star-twinkle {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 1; }
}

.vp-stars i:nth-child(1) { left: 8%; top: 12%; }
.vp-stars i:nth-child(2) { left: 22%; top: 30%; animation-delay: .4s; }
.vp-stars i:nth-child(3) { left: 35%; top: 10%; animation-delay: 1.2s; }
.vp-stars i:nth-child(4) { left: 48%; top: 26%; animation-delay: .8s; }
.vp-stars i:nth-child(5) { left: 58%; top: 44%; animation-delay: 1.8s; }
.vp-stars i:nth-child(6) { left: 12%; top: 46%; animation-delay: 2.2s; }
.vp-stars i:nth-child(7) { left: 30%; top: 52%; animation-delay: .2s; }
.vp-stars i:nth-child(8) { left: 64%; top: 14%; animation-delay: 1.5s; }
.vp-stars i:nth-child(9) { left: 78%; top: 32%; animation-delay: .6s; }
.vp-stars i:nth-child(10) { left: 86%; top: 10%; animation-delay: 2s; }

/* Your boat - hull sits in the lagoon water, not hovering above it */
.vp-boat {
  position: absolute;
  bottom: -4px;
  left: 5%;
  width: 46px;
  height: 44px;
  margin-left: -23px;
  z-index: 3;
  filter: drop-shadow(0 3px 4px rgba(4, 42, 52, 0.3));
  animation: boat-sway 3.2s ease-in-out infinite;
  transition: left 30s linear, transform 0.13s linear;
}

.vp-boat svg { width: 100%; height: 100%; display: block; }

/* The wake trailing behind the boat - proof it's moving */
.vp-wake {
  position: absolute;
  right: 100%;
  bottom: 9px;
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.75));
}

.vp-wake::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -6px;
  width: 60%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.5));
}

.vp-boat.celebrate { animation: boat-arrive 0.8s cubic-bezier(0.2, 1.4, 0.4, 1); }

@keyframes boat-sway {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50%      { transform: translateY(-4px) rotate(2deg); }
}

@keyframes boat-arrive {
  0%   { transform: translateY(0) rotate(0deg); }
  35%  { transform: translateY(-6px) rotate(5deg); }
  70%  { transform: translateY(-2px) rotate(-3deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

/* The timer shark - a fin slicing through the sea behind you. It closes in
   as the clock drains, and at time-up it's right on the boat's stern.
   Answer in time and it falls back into the deep. */
.vp-shark {
  position: absolute;
  bottom: -6px;
  left: -20%;
  width: 58px;
  z-index: 4;
  pointer-events: none;
  transition: left 0.13s linear;
  animation: shark-swim 1.6s ease-in-out infinite;
}

.vp-shark svg { width: 100%; height: auto; display: block; }

.vp-shark.danger {
  animation: shark-swim 1.6s ease-in-out infinite,
    shark-flash 0.5s ease-in-out infinite alternate;
}
.vp-shark.recede { transition: left 0.95s ease; }
.vp-shark.bite { animation: shark-bite 0.7s ease-in; }

@keyframes shark-swim {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(1.5px) rotate(2deg); }
}

@keyframes shark-flash {
  from { filter: none; }
  to   { filter: brightness(1.2) saturate(1.35) drop-shadow(0 0 10px rgba(255, 107, 107, 0.55)); }
}

/* Time-up: the shark lunges at the stern as the boat goes over */
@keyframes shark-bite {
  0%   { transform: translateX(0) rotate(0); }
  35%  { transform: translateX(16px) translateY(-4px) rotate(-10deg); }
  100% { transform: translateX(10px) translateY(0) rotate(-4deg); }
}

/* Barely escaped: the boat wobbles with relief as the shark falls back,
   then rocks back upright */
.vp-boat.recover { animation: boat-recover 0.95s ease; }

@keyframes boat-recover {
  0%   { transform: translateX(4px) translateY(-8px) rotate(18deg); }
  35%  { transform: translateX(2px) translateY(-4px) rotate(-6deg); }
  70%  { transform: translateY(-2px) rotate(3deg); }
  100% { transform: translateY(0) rotate(0deg); }
}

/* Banked seconds rising off the TIME stat */
.time-pop {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 50%;
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--palm-deep);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
  pointer-events: none;
  animation: score-rise 1.1s ease-out forwards;
}

/* ---------- Answer launch FX ---------- */
.game-screen { position: relative; }

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

/* The word chip: black box, rarity-colored perimeter and text */
.word-chip {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 12px;
  background: #061821;
  border: 2px solid var(--turquoise);
  color: var(--turquoise);
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(4, 42, 52, 0.5);
  z-index: 3;
}

.word-chip.uncommon { border-color: var(--ocean); color: var(--ocean); }
.word-chip.rare { border-color: var(--coral); color: var(--coral); }
.word-chip.epic { border-color: var(--gold); color: var(--gold); }

/* Rare answers keep their own spotlight while the world dims */
.word-chip::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 300px;
  height: 300px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
  display: none;
}

.word-chip.rare::before {
  display: block;
  background: radial-gradient(circle,
    rgba(255, 107, 107, 0.32) 0%,
    rgba(255, 107, 107, 0.13) 34%,
    transparent 62%);
}

.word-chip.epic::before {
  display: block;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle,
    rgba(255, 209, 102, 0.38) 0%,
    rgba(255, 209, 102, 0.16) 36%,
    transparent 64%);
}

/* The dimmed world behind a rare sink */
.spot-dim {
  position: absolute;
  inset: 0;
  background: rgba(3, 16, 26, 0.55);
  opacity: 0;
  z-index: 2;
}

.spot-dim.epic { background: rgba(3, 16, 26, 0.66); }

/* The answer's jet: tier-colored churn bursting from the stern */
.splash-ring {
  position: absolute;
  width: 46px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  z-index: 2;
}

.splash-ring.common { border-color: rgba(46, 196, 182, 0.9); }
.splash-ring.uncommon { border-color: rgba(43, 111, 214, 0.9); }
.splash-ring.rare { border-color: rgba(255, 107, 107, 0.95); }
.splash-ring.epic { border-color: rgba(255, 209, 102, 0.95); }

.splash-drop {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  z-index: 2;
}

.splash-drop.common { background: var(--turquoise); }
.splash-drop.uncommon { background: var(--ocean); }
.splash-drop.rare { background: var(--coral); }
.splash-drop.epic { background: var(--gold); }

/* Fuel delivered: the boat surges forward */
.vp-boat.nudge { animation: boat-nudge 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.2); }

@keyframes boat-nudge {
  0%   { transform: translateX(0) rotate(0deg); }
  40%  { transform: translateX(16px) rotate(2deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

/* ---------- The instrument dash: the next sky, the day's progress ---------- */
.vp-dash {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #063645, #042a36);
  border-top: 1px solid rgba(46, 196, 182, 0.25);
}

.dash-stage {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #9fe8ff;
  white-space: nowrap;
}

/* The focal countdown: the next sky, and the legs until it arrives */
.dash-next {
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.dash-next-label {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--gold);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.dash-next-track { display: flex; gap: 5px; }

.dash-next-track i {
  width: 18px;
  height: 5px;
  border-radius: 999px;
  background: rgba(46, 196, 182, 0.15);
  border: 1px solid rgba(46, 196, 182, 0.35);
}

.dash-next-track i.done { background: var(--gold); border-color: var(--gold); }

/* The day itself: one dot per question, filling toward the far shore */
.dash-day {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

.day-strip { display: flex; gap: 4px; }

.day-strip i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(46, 196, 182, 0.12);
  border: 1px solid rgba(46, 196, 182, 0.4);
}

.day-strip i.done { background: var(--lagoon-bright); border-color: var(--lagoon-bright); }

.day-strip i.now {
  background: var(--gold);
  border-color: var(--gold);
  animation: blip-pulse 1.4s ease-in-out infinite;
}

.dash-dist {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #9fe8ff;
}

@keyframes blip-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* Result screen: the day's twelve, filled by how each leg went */
.day-strip-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--cream-2);
  border: 1px solid var(--shell-line);
}

.strip-label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  white-space: nowrap;
}

.day-strip.result { gap: 7px; justify-content: center; }

.day-strip.result i {
  width: 13px;
  height: 13px;
  background: var(--cream);
  border: 2px solid rgba(15, 143, 163, 0.35);
}

.day-strip.result i.done { background: var(--lagoon); border-color: var(--lagoon-deep); }

.day-strip i.lost { background: var(--coral); border-color: var(--coral-deep); }

/* ---------- Game screen: prompt card ---------- */
.prompt-card {
  padding: 18px 20px 16px;
  text-align: center;
}

/* (The round timer lives in the scene: a wave rolling toward the boat.) */

.category-label {
  display: inline-block;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: #fff;
  background: linear-gradient(180deg, var(--turquoise), var(--lagoon));
  box-shadow: 0 3px 10px rgba(15, 143, 163, 0.35);
}

.prompt-card h2 {
  margin: 12px 0 4px;
  font-size: clamp(1.35rem, 5.4vw, 1.8rem);
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.next-prompt {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--shell-line);
}

.next-prompt span {
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.next-prompt strong {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--palm-deep);
}

/* JS-applied shake on wrong/rejected input */
.shake { animation: shake-x 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

@keyframes shake-x {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* ---------- Answer form ---------- */
.answer-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-wrap { position: relative; }

#answer-input {
  width: 100%;
  min-height: 56px;
  padding: 14px 52px 14px 18px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--shell-line);
  border-radius: var(--radius-md);
  box-shadow: inset 0 2px 6px rgba(7, 58, 70, 0.07), var(--shadow-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#answer-input::placeholder { color: var(--ink-faint); font-weight: 500; }

#answer-input:focus {
  outline: none;
  border-color: var(--turquoise);
  box-shadow: inset 0 2px 6px rgba(7, 58, 70, 0.07), 0 0 0 4px rgba(46, 196, 182, 0.25), var(--shadow-card);
}

.clear-button {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink-faint);
  transition: background 0.15s ease, color 0.15s ease;
}

.clear-button:hover { background: var(--coral-soft); color: var(--coral-deep); }
.input-wrap.has-text .clear-button { display: inline-flex; }

.submit-button { width: 100%; }

.feedback {
  min-height: 1.4em;
  margin: -6px 0 0;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.feedback.success { color: var(--palm-deep); }
.feedback.error { color: var(--coral-deep); }

/* ---------- Lagoon / letter grid ---------- */
.lagoon {
  position: relative;
  padding: 14px 14px 26px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(90% 55% at 50% 0%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, var(--lagoon-bright) 0%, var(--lagoon) 45%, var(--lagoon-deep) 100%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.35), inset 0 -14px 30px rgba(4, 42, 52, 0.45), var(--shadow-card);
  overflow: hidden;
}

.lagoon-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 0 4px 10px;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(4, 42, 52, 0.4);
}

#letters-left { color: var(--gold); }

.letter-grid {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Wordle-style keyboard rows: QWERTYUIOP / ASDFGHJKL / ZXCVBNM */
.letter-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.letter-row .letter {
  flex: 1 1 auto;
  max-width: 64px;
}

.lagoon-floor {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 22px;
  background:
    radial-gradient(60% 100% at 20% 100%, var(--sand) 0 60%, transparent 61%),
    radial-gradient(70% 100% at 75% 100%, var(--sand-deep) 0 60%, transparent 61%),
    linear-gradient(180deg, transparent, rgba(227, 201, 143, 0.85));
  opacity: 0.85;
}

/* The alphabet tiles - the health bar */
.letter {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  border-radius: 12px;
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--lagoon-deep);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 55%),
    var(--cream);
  border: 1px solid var(--shell-line);
  box-shadow: 0 4px 10px rgba(4, 42, 52, 0.30), inset 0 -3px 0 rgba(7, 58, 70, 0.08);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  animation: bob 3.4s ease-in-out infinite;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.3s ease;
}

.letter-face { line-height: 1; }

/* Life pips - every letter carries 3 lives */
.pips {
  display: flex;
  gap: 3px;
  line-height: 0;
}

.pips i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(18, 60, 70, 0.14);
  box-shadow: inset 0 1px 1px rgba(4, 42, 52, 0.2);
}

.letter[data-lives="3"] .pips i { background: var(--turquoise); }
.letter[data-lives="2"] .pips i:nth-child(-n+2) { background: var(--gold); }
.letter[data-lives="1"] .pips i:nth-child(1) { background: var(--coral); }

.letter.used .pips { display: none; }

.letter:hover { transform: translateY(-3px); box-shadow: 0 8px 16px rgba(4, 42, 52, 0.35), inset 0 -3px 0 rgba(7, 58, 70, 0.08); }
.letter:active { transform: translateY(0) scale(0.93); }

/* Varied bob delays/durations so the lagoon never moves in lockstep */
.letter:nth-child(7n+1) { animation-duration: 3.1s; animation-delay: -0.4s; }
.letter:nth-child(7n+2) { animation-duration: 3.9s; animation-delay: -1.3s; }
.letter:nth-child(7n+3) { animation-duration: 2.9s; animation-delay: -2.1s; }
.letter:nth-child(7n+4) { animation-duration: 3.6s; animation-delay: -0.9s; }
.letter:nth-child(7n+5) { animation-duration: 4.2s; animation-delay: -1.8s; }
.letter:nth-child(7n+6) { animation-duration: 3.3s; animation-delay: -2.6s; }
.letter:nth-child(7n)   { animation-duration: 3.7s; animation-delay: -0.2s; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-0.8deg); }
  50%      { transform: translateY(-4px) rotate(0.8deg); }
}

/* Rarity tints on tiles */
.letter.rarity-common,
.letter.common { border-bottom: 3px solid var(--turquoise); }
.letter.rarity-uncommon,
.letter.uncommon { border-bottom: 3px solid var(--ocean); }
.letter.rarity-rare,
.letter.rare { border-bottom: 3px solid var(--coral); }
.letter.rarity-epic,
.letter.epic {
  border-bottom: 3px solid var(--gold);
  color: #9a6a12;
}
.letter[data-rarity="common"]    { border-bottom: 3px solid var(--turquoise); }
.letter[data-rarity="uncommon"]  { border-bottom: 3px solid var(--ocean); }
.letter[data-rarity="rare"]      { border-bottom: 3px solid var(--coral); }
.letter[data-rarity="epic"]      { border-bottom: 3px solid var(--gold); }

/* Flash when a letter is part of a correct answer */
.letter.correct {
  animation: correct-flash 0.6s ease both;
}

@keyframes correct-flash {
  0%   { background-color: var(--cream); }
  35%  { background-color: #c9f7d4; transform: translateY(-6px) scale(1.08); box-shadow: 0 0 18px rgba(61, 220, 132, 0.8); }
  100% { background-color: var(--cream); }
}

/* Spent letters sink, then rest dimmed on the lagoon floor - always visible */
.letter.used {
  animation: sink 1.15s cubic-bezier(0.5, 0.05, 0.8, 0.4) forwards;
  pointer-events: none;
}

@keyframes sink {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; filter: none; }
  30%  { transform: translateY(3px) rotate(5deg); opacity: 0.95; }
  65%  { transform: translateY(13px) rotate(-6deg); opacity: 0.5; filter: blur(0.5px) saturate(0.6); }
  100% { transform: translateY(9px) rotate(5deg); opacity: 0.3; filter: blur(0.4px) saturate(0.35); }
}

/* Returned letters rise back to the surface */
.letter.returned {
  animation: return-up 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

@keyframes return-up {
  0%   { transform: translateY(26px) rotate(-8deg); opacity: 0; filter: blur(2px); }
  60%  { transform: translateY(-5px) rotate(3deg); opacity: 1; filter: none; }
  100% { transform: translateY(0) rotate(0); opacity: 1; }
}

/* Bubbles spawned by JS inside the lagoon */
.bubble {
  position: absolute;
  bottom: 8px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.65);
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.12) 45%, rgba(255, 255, 255, 0.05));
  pointer-events: none;
  z-index: 2;
  animation: bubble-rise 1.6s ease-in forwards;
}

@keyframes bubble-rise {
  0%   { transform: translateY(0) scale(0.6); opacity: 0; }
  15%  { opacity: 0.9; }
  100% { transform: translateY(-150px) scale(1.1); opacity: 0; }
}

/* Floating score text spawned by JS */
.score-pop {
  position: absolute;
  z-index: 3;
  font-weight: 900;
  font-size: 1.05rem;
  color: var(--gold);
  text-shadow: 0 1px 0 rgba(4, 42, 52, 0.5), 0 0 10px rgba(255, 209, 102, 0.6);
  pointer-events: none;
  animation: score-rise 1.1s ease-out forwards;
}

@keyframes score-rise {
  0%   { transform: translateY(0) scale(0.8); opacity: 0; }
  20%  { opacity: 1; transform: translateY(-10px) scale(1.1); }
  100% { transform: translateY(-46px) scale(1); opacity: 0; }
}

/* Rarity legend */
.game-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 0 6px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.game-footer span { display: inline-flex; align-items: center; gap: 6px; }

.rarity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.rarity-dot.common   { background: var(--turquoise); }
.rarity-dot.uncommon { background: var(--ocean); }
.rarity-dot.rare     { background: var(--coral); }
.rarity-dot.epic     { background: var(--gold); }

/* ---------- Result screen ---------- */
.result-screen { position: relative; z-index: 50; }

.result-card {
  padding: 26px 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.72)),
    var(--cream);
}

.result-flamingo {
  font-size: 2.6rem;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(7, 58, 70, 0.25));
  animation: bob 3.2s ease-in-out infinite;
}

.result-eyebrow { color: var(--coral-deep); }

.result-card h2 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--coral-deep);
}

/* The verdict label flips palm-green when you made the far shore. */
.result-card h2.win { color: var(--palm-deep); }

#result-reason { margin: 0; color: var(--ink-soft); max-width: 30em; }

/* Recap stats — the game's own tile language, not dashboard boxes. */
.recap-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.stat-chip {
  flex: 1 1 120px;
  max-width: 172px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 11px 8px 9px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 55%),
    var(--cream);
  border: 1px solid var(--shell-line);
  border-bottom: 3px solid var(--lagoon);
  box-shadow: 0 4px 10px rgba(4, 42, 52, 0.30), inset 0 -3px 0 rgba(7, 58, 70, 0.08);
}

.stat-chip.gold { border-bottom-color: var(--gold); }
.stat-chip.palm { border-bottom-color: var(--palm); }

.stat-chip span {
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.stat-chip strong {
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1;
  color: var(--lagoon-deep);
  font-variant-numeric: tabular-nums;
}

/* The tide's clock, under the recap: when the next voyage unlocks. */
.next-sail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding-top: 6px;
}

.next-sail span {
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.next-sail strong {
  line-height: 1;
  font-size: 1.7rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--lagoon-deep);
  font-variant-numeric: tabular-nums;
}

.result-voyage {
  margin: 0;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-soft);
  max-width: 34em;
}

/* ---------- Round-by-round answer review (post-run) ---------- */
.review {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.review-hint {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--palm-deep);
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 46dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px;
}

.review-item { display: flex; flex-direction: column; }

.review-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--cream-2);
  border: 1px solid var(--shell-line);
  transition: background 0.15s ease, transform 0.15s ease;
}

.review-row:hover { background: #fdf6e3; transform: translateY(-1px); }
.review-item.open .review-row { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.review-round {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(180deg, var(--turquoise), var(--lagoon));
  box-shadow: 0 2px 6px rgba(15, 143, 163, 0.35);
}

.review-q {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink);
}

.review-a {
  flex-shrink: 0;
  max-width: 40%;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-a b { color: var(--coral-deep); font-weight: 900; }
.review-a.missed { color: var(--coral-deep); font-style: italic; }

.review-caret {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--ink-faint);
  transition: transform 0.2s ease;
}

.review-item.open .review-caret { transform: rotate(180deg); }

.review-detail {
  display: none;
  padding: 10px 12px 12px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--foam);
  border: 1px solid var(--shell-line);
  border-top: 1px dashed var(--shell-line);
}

.review-item.open .review-detail { display: block; animation: screen-in 0.3s ease both; }

.review-detail-heading {
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--palm-deep);
  margin-bottom: 7px;
}

.review-best {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid var(--shell-line);
}

.review-best + .review-best { margin-top: 5px; }

.review-best.top {
  background: linear-gradient(180deg, #ffe9a8, var(--gold));
  border-color: #e0b95a;
  box-shadow: 0 3px 10px rgba(190, 140, 30, 0.28);
}

.review-best-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-best b { color: var(--coral-deep); font-weight: 900; flex-shrink: 0; }

.review-best-tag {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #7a5410;
  background: rgba(255, 255, 255, 0.7);
}

.review-note {
  margin: 8px 0 0;
  font-size: 0.76rem;
  font-style: italic;
  color: var(--ink-soft);
}

/* Underwater alphabet - letters you leave behind */
.result-lagoon-wrap {
  position: relative;
  width: 100%;
  padding: 12px 12px 26px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(80% 40% at 50% 0%, rgba(255, 255, 255, 0.25), transparent 60%),
    linear-gradient(180deg, var(--lagoon-bright), var(--lagoon) 40%, var(--lagoon-deep) 90%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  overflow: hidden;
  box-shadow: inset 0 -16px 34px rgba(4, 42, 52, 0.5);
}

.result-lagoon-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 10px;
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(4, 42, 52, 0.4);
}

#result-remaining-count { color: var(--gold); }

.result-lagoon {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-lagoon .letter-row { gap: 6px; }

.result-lagoon .letter,
.result-lagoon .result-letter {
  min-height: 42px;
  border-radius: 9px;
  font-size: 0.9rem;
  cursor: default;
  animation-duration: 4.6s;
  flex: 1 1 auto;
  max-width: 46px;
  gap: 2px;
}

.result-lagoon .pips i { width: 3px; height: 3px; box-shadow: none; }

/* Sunk letters rest dim on the lagoon floor; survivors float bright */
.result-lagoon .letter.used,
.result-lagoon .result-letter.used,
.result-lagoon .sunk {
  opacity: 0.4;
  filter: blur(0.4px) saturate(0.6);
  transform: translateY(10px) rotate(6deg);
  box-shadow: none;
}

.sand-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 24px;
  background:
    radial-gradient(60% 100% at 30% 100%, var(--sand) 0 60%, transparent 61%),
    linear-gradient(180deg, transparent, rgba(227, 201, 143, 0.9));
}

.remaining-sentence {
  margin: 0;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-soft);
  max-width: 32em;
}

.streak-summary {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.streak-summary strong { color: var(--ink); }
.streak-summary span[aria-hidden], .streak-summary span:first-child { color: var(--gold); }

.share-button { width: 100%; }

.result-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.result-actions .secondary-button { flex: 1 1 auto; }

.share-status {
  min-height: 1.2em;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--palm-deep);
}

/* ---------- Flood (game over) ---------- */.flood {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 0;
  z-index: 40;
  pointer-events: none;
  background:
    radial-gradient(100% 40% at 50% 0%, rgba(255, 255, 255, 0.22), transparent 60%),
    linear-gradient(180deg, var(--lagoon) 0%, var(--lagoon-deep) 45%, #063645 100%);
  transition: height 1.8s cubic-bezier(0.4, 0, 0.3, 1);
  overflow: visible;
}

.flood.rising,
body.game-over .flood { height: 100%; }

.flood-wave {
  position: absolute;
  left: -25%;
  right: -25%;
  top: -26px;
  height: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 40' preserveAspectRatio='none'%3E%3Cpath d='M0 26 Q 15 8 30 26 T 60 26 T 90 26 T 120 26 V 40 H 0 Z' fill='%230f8fa3'/%3E%3C/svg%3E") repeat-x;
  background-size: 120px 40px;
  animation: wave-drift 5s linear infinite;
}

@keyframes wave-drift {
  from { transform: translateX(0); }
  to   { transform: translateX(-120px); }
}

/* ---------- Dive (embarking) ---------- */
.dive {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  transform: translateY(101%);
  background:
    radial-gradient(100% 40% at 50% 100%, rgba(255, 255, 255, 0.22), transparent 60%),
    linear-gradient(180deg, var(--lagoon-bright) 0%, var(--lagoon) 34%, var(--lagoon-deep) 66%, #063645 100%);
  box-shadow: 0 -70px 140px rgba(4, 42, 52, 0.45);
}

.dive-wave {
  position: absolute;
  left: -25%;
  right: -25%;
  top: -26px;
  height: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 40' preserveAspectRatio='none'%3E%3Cpath d='M0 26 Q 15 8 30 26 T 60 26 T 90 26 T 120 26 V 40 H 0 Z' fill='%230f8fa3'/%3E/svg%3E") repeat-x;
  background-size: 120px 40px;
  animation: wave-drift 5s linear infinite;
}

/* The surface rises over you, holds for a beat while the world swaps,
   then sweeps past overhead - you're out at sea. */
body.diving .dive { animation: dive-sweep 1.25s cubic-bezier(0.45, 0, 0.25, 1) both; }

@keyframes dive-sweep {
  0%   { transform: translateY(101%); }
  38%  { transform: translateY(0); }
  54%  { transform: translateY(-3%); }
  100% { transform: translateY(-101%); }
}

/* ---------- Dialogs ---------- */
dialog {
  position: fixed;
  margin: auto;
  padding: 0;
  border: 0;
  background: none;
  max-width: min(92vw, 460px);
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 32px);
  width: calc(100vw - 32px - var(--safe-left) - var(--safe-right));
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(6, 45, 56, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

dialog[open] {
  animation: dialog-in 0.35s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(26px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Help dialog */
.help-dialog {
  padding: 26px 22px 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.help-dialog .eyebrow { justify-content: flex-start; }
.help-dialog .eyebrow > span:last-child { display: none; }

.help-dialog h2 {
  margin: 8px 0 10px;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.01em;
}

.help-dialog ol {
  margin: 0 0 14px;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-dialog li { font-size: 0.92rem; color: var(--ink-soft); }
.help-dialog li strong { color: var(--ink); }
.help-dialog li::marker { font-weight: 900; color: var(--coral-deep); }

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  font-size: 1.3rem;
}

.help-dialog .primary-button { width: 100%; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  z-index: 90;
  max-width: min(88vw, 420px);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid var(--shell-line);
  box-shadow: var(--shadow-lift);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive tuning ---------- */
@media (min-width: 560px) {
  .answer-form { flex-direction: row; }
  .input-wrap { flex: 1; }
  .submit-button { width: auto; padding-left: 28px; padding-right: 28px; }
  .letter-row .letter { max-width: 56px; }
  .letter { min-height: 48px; }
}

@media (max-width: 374px) {
  .run-stat { min-width: 56px; padding: 4px 10px; }
  .letter-row { gap: 5px; }
  .letter-row .letter { font-size: 1rem; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .letter,
  .letter:nth-child(7n+1), .letter:nth-child(7n+2), .letter:nth-child(7n+3),
  .letter:nth-child(7n+4), .letter:nth-child(7n+5), .letter:nth-child(7n+6),
  .letter:nth-child(7n) { animation: none; }

  .letter.used {
    animation: none;
    opacity: 0.3;
    transform: translateY(9px) rotate(4deg);
  }

  .flood { transition: none; }
  .letter.correct { animation: none; background: #c9f7d4; }
  .voyage-tint { transition: none; }
  .day-strip i.now { animation: none; }

  /* Voyage scene: keep positions, drop the motion */
  .vp-boat { transition: none !important; animation: none; }
  .vp-boat.celebrate,
  .vp-boat.recover,
  .vp-shark,
  .vp-shark.danger,
  .vp-shark.recede,
  .vp-shark.bite { transition: none !important; animation: none; }
  .vp-clouds i,
  .vp-stars i { animation: none; }
}
