/* Floodgate — calm, glassy, mobile first. */

:root {
  --bg: #f3efe7;
  --bg-2: #ebe5d9;
  --surface: #fffdf8;
  --ink: #1b2330;
  --muted: #5f6873;
  --line: #d9d1c2;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --coral: #d9573f;
  --gold: #b7862c;
  --water-top: #63b6e8;
  --water-deep: #1d68ad;
  --glass-edge: #7f99b0;
  --glass-body: #cfe1ee;
  --metal-hi: #f6e1a6;
  --metal-mid: #c99945;
  --metal-lo: #7a561f;
  --tile-hi: #f4efe5;
  --tile-lo: #ded5c4;
  --tile-ink: #1b2330;
  --tile-lock-hi: #d7ccb7;
  --tile-lock-lo: #c3b59b;
  --key: #e3dccf;
  --key-ink: #1b2330;
  --submit-bg: #1f5f8b; /* white text on this passes WCAG AA */
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.12), 0 6px 20px rgba(40, 30, 10, 0.07);
  --serif: 'Fraunces', 'DM Serif Display', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e1620;
    --bg-2: #142030;
    --surface: #17222f;
    --ink: #e7edf3;
    --muted: #9aa8b6;
    --line: #2a3a4b;
    --accent: #6cb6e6;
    --accent-ink: #0b1620;
    --coral: #f07a62;
    --gold: #e0b25a;
    --water-top: #4fa6de;
    --water-deep: #134f8a;
    --glass-edge: #9fbcd6;
    --glass-body: #6f93b3;
    --metal-hi: #f1dba0;
    --metal-mid: #b8893b;
    --metal-lo: #5f4316;
    --tile-hi: #2b3a4b;
    --tile-lo: #223040;
    --tile-ink: #eef3f8;
    --tile-lock-hi: #3a4d63;
    --tile-lock-lo: #304256;
    --key: #263546;
    --key-ink: #e7edf3;
  --submit-bg: #2a6f9f; /* darker than the dark-theme accent, so white text stays readable */
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0e1620;
  --bg-2: #142030;
  --surface: #17222f;
  --ink: #e7edf3;
  --muted: #9aa8b6;
  --line: #2a3a4b;
  --accent: #6cb6e6;
  --accent-ink: #0b1620;
  --coral: #f07a62;
  --gold: #e0b25a;
  --water-top: #4fa6de;
  --water-deep: #134f8a;
  --glass-edge: #9fbcd6;
  --glass-body: #6f93b3;
  --metal-hi: #f1dba0;
  --metal-mid: #b8893b;
  --metal-lo: #5f4316;
  --tile-hi: #2b3a4b;
  --tile-lo: #223040;
  --tile-ink: #eef3f8;
  --tile-lock-hi: #3a4d63;
  --tile-lock-lo: #304256;
  --key: #263546;
  --key-ink: #e7edf3;
  --submit-bg: #2a6f9f; /* darker than the dark-theme accent, so white text stays readable */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, var(--surface) 0%, var(--bg) 55%, var(--bg-2) 100%) fixed;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; margin: -1px;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.screen { height: 100%; display: flex; flex-direction: column; }

/* ——— Buttons ——— */
.btn {
  min-height: 48px;
  padding: 0 28px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, .key:focus-visible, .lifeline:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 12px; cursor: pointer;
  color: var(--ink);
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { background: var(--bg-2); }

.bar {
  display: grid;
  grid-template-columns: 44px 1fr 44px 44px;
  align-items: center;
  padding: 6px 8px 0;
}
#home .bar { grid-template-columns: 44px 1fr 44px 44px 44px; } /* help · · flag · sound · settings */
.flag-btn .flag { width: 26px; height: 17px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }
.flag-btn[data-locale='uk'] .flag-us, .flag-btn[data-locale='us'] .flag-uk { display: none; }
.update-banner {
  margin: 6px 12px 0;
  min-height: 44px;
  padding: 8px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--submit-bg);
  color: #fff;
  font: 600 0.9rem var(--sans);
  cursor: pointer;
}

/* ——— Home ——— */
.home-main {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 0 24px;
  gap: 14px;
}
.logo { width: 64px; height: 64px; }
.title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.6rem, 12vw, 3.4rem);
  letter-spacing: -0.02em;
  margin: 0;
  font-variation-settings: 'opsz' 144;
}
.tagline { margin: -6px 0 6px; color: var(--muted); }
.pair-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 34px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 6px;
}
.pair {
  font-family: var(--serif);
  font-size: 3rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.season { color: var(--muted); font-size: 0.9rem; margin-top: 4px; font-variant-numeric: tabular-nums; }
.status { color: var(--muted); font-size: 0.92rem; max-width: 30ch; margin: 4px 0 0; min-height: 1.3em; }
.rematch {
  margin: 0;
  padding: 10px 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  font-size: 0.95rem;
}
#play-btn { min-width: 200px; font-size: 1.1rem; }
.load-error {
  min-height: 44px;
  max-width: 32ch;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--coral) 45%, transparent);
  background: color-mix(in srgb, var(--coral) 10%, var(--surface));
  color: var(--ink);
  font: 500 0.92rem/1.35 var(--sans);
  cursor: pointer;
}
.day-nav { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.home-done-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.home-done-row:not(:has(:not([hidden]))) { display: none; }
.btn.compact { min-height: 44px; padding: 0 12px; font-size: 0.9rem; }
.btn.small { min-height: 44px; padding: 0 16px; font-size: 0.88rem; font-weight: 500; }
.btn.loading { cursor: progress; }
.btn:disabled.loading { opacity: 0.85; }
.pair-card { transition: opacity 0.15s ease; }
.pair-card.loading { opacity: 0.45; }
.site-footer {
  padding: 12px 24px calc(14px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 0.68rem;
  color: var(--muted);
  opacity: 0.8;
  line-height: 1.4;
}
.site-footer.in-sheet { padding: 2px 0 0; }
.about-text { border-top: 1px solid var(--line); padding-top: 10px; }
.about-text h3 { margin: 0 0 4px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
.about-text p { margin: 0; font-size: 0.8rem; color: var(--muted); line-height: 1.45; }

/* ——— Game ——— */
.game-bar { grid-template-columns: 44px 1fr 44px 60px; }

/* Mute toggle: speaker with waves, or a cross when muted. */
.mute-btn .cross { display: none; }
.mute-btn.muted .wave { display: none; }
.mute-btn.muted .cross { display: inline; }
.mute-btn.muted { color: var(--muted); }
.audio-playing .mute-btn:not(.muted) .wave { animation: speaker 1.2s ease-in-out infinite; }
.audio-playing .mute-btn:not(.muted) .w2 { animation-delay: 0.3s; }
@keyframes speaker { 50% { opacity: 0.35; } }
.game-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 2px 8px; text-align: center; }
.g-pair { font-family: var(--serif); font-weight: 600; font-size: 1.25rem; }
.g-season { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.practice-badge {
  display: inline-block;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}
.total { text-align: right; font-family: var(--serif); font-weight: 600; font-size: 1.25rem; padding-right: 6px; font-variant-numeric: tabular-nums; }
.total small { font-family: var(--sans); font-size: 0.65rem; color: var(--muted); margin-left: 2px; font-weight: 500; }

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 2px;
}
.lifeline {
  min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.85rem; font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
}
.lifeline svg { width: 18px; height: 18px; flex: none; }
.lifeline small { color: var(--muted); font-weight: 500; }
.lifeline:disabled { opacity: 0.45; cursor: default; }
.lifeline.used { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 40%, transparent); opacity: 0.8; }
#clue-btn { justify-self: start; }
#reveal-btn { justify-self: end; }
.progress { text-align: center; }
.dots { display: flex; gap: 5px; justify-content: center; }
.dot {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.62rem; font-weight: 600; color: var(--muted);
  border: 1.5px solid var(--line);
  transition: all 0.25s ease;
}
.dot.current { border-color: var(--accent); color: var(--accent); transform: scale(1.12); }
.dot.done { background: var(--water-deep); border-color: var(--water-deep); color: #fff; }
.dot.done.band-2 { background: var(--accent); border-color: var(--accent); }
.dot.done.band-3 { background: var(--gold); border-color: var(--gold); }
.dot.flooded { background: var(--coral); border-color: var(--coral); color: #fff; }
.slot-length { font-size: 0.72rem; color: var(--muted); margin-top: 3px; letter-spacing: 0.04em; }

.clue {
  margin: 6px 12px 0;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 1.02rem;
  text-align: center;
  animation: fade-in 0.25s ease;
}
.clue-label { display: block; font-family: var(--sans); font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 2px; }
.clue-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; text-align: left; }
.clue-list li { display: grid; grid-template-columns: 5.6em 1fr; gap: 8px; align-items: baseline; line-height: 1.25; font-size: 0.92rem; }
/* One Reveal button per tier, side by side under the clues. */
.reveal-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin-top: 6px; }
.reveal-tier {
  min-height: 44px;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font: 600 0.78rem/1.15 var(--sans);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.reveal-tier small { font-weight: 600; font-size: 0.62rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.reveal-tier .x { color: var(--muted); font-weight: 500; }
.reveal-tier.tier-rare small { color: var(--gold); }
.reveal-tier.tier-uncommon small { color: var(--accent); }
.reveal-tier:disabled { opacity: 0.4; cursor: default; }
/* Once this slot's reveal is used, the Reveal row goes and the panel shrinks back. */
.clue.revealed .reveal-row { display: none; }
.clue-tier { font-family: var(--sans); font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tier-rare .clue-tier { color: var(--gold); }
.tier-uncommon .clue-tier { color: var(--accent); }
.answer-count { margin: 2px 0 0; text-align: center; font-size: 0.75rem; color: var(--muted); letter-spacing: 0.02em; min-height: 1.1em; }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 4px 8px 0;
  overflow: hidden;
}
.vessel-box { position: absolute; inset: 0; }
.vessel-svg { position: absolute; inset: 0; display: block; overflow: visible; }

.glass-front { stroke: var(--glass-edge); stroke-width: 2.2; stroke-linejoin: round; opacity: 0.9; }
.glass-highlight { stroke: #fff; stroke-width: 5; stroke-linecap: round; opacity: 0.38; }
.glass-highlight.thin { stroke-width: 2; opacity: 0.3; }
.water-surface { stroke: #fff; stroke-width: 1.6; opacity: 0.4; }
.bubbles circle { fill: rgba(255, 255, 255, 0.6); stroke: rgba(255, 255, 255, 0.85); stroke-width: 0.6; }
.swirl ellipse { stroke: rgba(255, 255, 255, 0.75); stroke-width: 1.6; }
.splash .ripple { stroke: rgba(255, 255, 255, 0.65); stroke-width: 1.2; }
.splash circle { fill: var(--water-top); }
.stream { opacity: 0.92; }
.metal { stroke: var(--metal-lo); stroke-width: 0.6; }
.tap-lever { transition: transform 0.25s ease; }

.overflow-line line { stroke: var(--coral); stroke-width: 1.6; stroke-dasharray: 6 5; }
.overflow-line text { fill: var(--coral); font: 600 9px var(--sans); letter-spacing: 0.16em; }
.overflow-line.warning { animation: pulse 0.8s ease-in-out infinite; }
.overflow-line.warning line { stroke-width: 2.6; }
@keyframes pulse { 50% { opacity: 0.35; } }

.gauge {
  position: absolute; left: 8px; top: 6px; z-index: 2;
  display: flex; align-items: baseline; gap: 4px;
  font-family: var(--serif); font-weight: 600; font-size: 1.25rem; line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.gauge small { font-family: var(--sans); font-weight: 500; font-size: 0.8rem; color: var(--muted); }
.gauge.warning { color: var(--coral); }

/* Bridge tiles */
.bridge {
  position: absolute;
  display: flex;
  gap: 3px;
  z-index: 1;
}
.tile {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 600;
  font-size: var(--tile-font, 24px);
  color: var(--tile-ink);
  background: linear-gradient(180deg, var(--tile-hi), var(--tile-lo));
  border-radius: 5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -2px 0 rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) calc(var(--i) * 30ms), opacity 0.45s ease calc(var(--i) * 30ms);
}
/* Tile letters: trimmed to the capital height so every capital is centred on the
   tile, then nudged up by JS (--glyph-nudge) if the letter hangs below the baseline. */
.tile .glyph {
  display: block;
  line-height: 1;
  text-box: trim-both cap alphabetic;
  transform: translateY(var(--glyph-nudge, 0));
}
.tile.locked {
  background: linear-gradient(180deg, var(--tile-lock-hi), var(--tile-lock-lo));
  color: var(--accent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 35%, transparent), inset 0 -2px 0 rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.2);
}
.tile.revealed { color: var(--gold); font-style: italic; }
.tile.pop { animation: pop 0.12s ease-out; }
@keyframes pop { 50% { transform: scale(1.08); } }
.bridge.rising .tile { transform: translateY(80%); opacity: 0; transition: none; }
.bridge.shake { animation: shake 0.4s ease; }
@keyframes shake {
  20% { transform: translateX(-7px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(2px); }
}
.bridge.cracking .tile::after {
  content: '';
  position: absolute; inset: 0;
  background:
    linear-gradient(112deg, transparent 44%, rgba(0, 0, 0, 0.45) 45.5%, transparent 47.5%),
    linear-gradient(64deg, transparent 58%, rgba(0, 0, 0, 0.35) 59.5%, transparent 61.5%),
    linear-gradient(155deg, transparent 30%, rgba(255, 255, 255, 0.35) 31%, transparent 33%);
  animation: fade-in 0.12s ease;
}
.bridge.cracking .tile { animation: jitter 0.26s linear; }
@keyframes jitter { 25% { transform: translate(1px, 1px); } 50% { transform: translate(-1px, 0); } 75% { transform: translate(1px, -1px); } }
.bridge.falling .tile {
  transform: translate(var(--dx), 260%) rotate(var(--rot));
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.5, 0, 0.9, 0.6) calc(var(--i) * 35ms), opacity 0.5s ease-in calc(var(--i) * 35ms + 100ms);
}
.bridge.fade-out .tile { opacity: 0; transition: opacity 0.3s ease; }

.toast {
  position: absolute; left: 50%; top: 42%; z-index: 3;
  transform: translate(-50%, -50%) scale(0.9);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  font-size: 0.95rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast.error { border-color: color-mix(in srgb, var(--coral) 50%, transparent); }
.toast .badge { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); margin-left: 4px; }
.toast.band-3 .badge { background: var(--gold); color: #fff; }
.toast.band-3 { border-color: var(--gold); }
.toast .pts { color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }

.burst { position: absolute; left: 50%; top: 42%; z-index: 3; pointer-events: none; }
.burst i {
  position: absolute; width: 7px; height: 7px; margin: -3.5px;
  background: var(--gold);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: burst 1s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.burst i:nth-child(3n) { background: var(--water-top); }
@keyframes burst {
  from { transform: rotate(var(--a)) translateY(0) scale(0.4); opacity: 1; }
  to { transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) scale(1.1); opacity: 0; }
}

/* Keyboard */
.keyboard {
  padding: 8px 4px 10px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.kb-row {
  display: grid;
  grid-template-columns: repeat(20, minmax(0, 1fr)); /* a letter key spans 2 columns */
  gap: 0 5px;
  margin-bottom: 6px;
}
.kb-row .key { grid-column: span 2; }
.kb-row:nth-child(2) .key:first-child { grid-column: 2 / span 2; } /* half-key indent */
.kb-row .key.submit { grid-column: 1 / span 3; }   /* bottom left, 1.5 keys wide */
.kb-row .key.delete { grid-column: 18 / span 3; }  /* bottom right, 1.5 keys wide */
.key {
  min-width: 0;
  height: 54px;
  border: 0;
  border-radius: 7px;
  background: var(--key);
  color: var(--key-ink);
  font-weight: 600;
  font-size: 1.05rem;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.08s ease, background 0.12s;
}
/* Submit: bottom-left key in the accent colour with white text; dimmed until the word is complete. */
.key.submit {
  background: var(--submit-bg);
  color: #fff;
  padding: 0 2px; /* the default button padding clipped the label */
  font-size: 0.8rem;
  letter-spacing: 0;
  white-space: nowrap;
  opacity: 0.4;
  transition: opacity 0.2s ease, transform 0.08s ease, background 0.12s;
}
.key.submit.ready { opacity: 1; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 2px 10px color-mix(in srgb, var(--submit-bg) 40%, transparent); }
.key.submit:active, .key.submit.pressed { transform: scale(0.94); background: color-mix(in srgb, var(--submit-bg) 82%, #000); }
.key.submit.pulse { animation: submit-pulse 0.5s ease-out; }
@keyframes submit-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--submit-bg) 55%, transparent); }
  40% { transform: scale(1.07); }
  100% { transform: scale(1); box-shadow: 0 0 0 8px transparent; }
}
.keyboard.disabled .key.submit { opacity: 0.3; }
.key:active, .key.pressed { transform: scale(0.94); background: color-mix(in srgb, var(--key) 70%, var(--accent)); }
.keyboard.disabled .key { opacity: 0.6; }

/* ——— Results ——— */
.results-main {
  flex: 1;
  overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 16px 24px;
  gap: 12px;
  text-align: center;
}
.results-sub { margin: 0; color: var(--muted); font-size: 0.9rem; }
.results-rank { margin: 4px 0 0; font-family: var(--serif); font-weight: 600; font-size: 2.6rem; line-height: 1.05; letter-spacing: -0.01em; color: var(--accent); }
.results-rank.flooded { color: var(--coral); }
.results-message { margin: -4px 0 0; font-size: 0.9rem; color: var(--muted); }
.results-score { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; justify-content: center; }
.results-score .pts-label { color: var(--muted); font-size: 1rem; margin-left: 6px; }
.results-score .big { font-family: var(--serif); font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.results-score .max { color: var(--muted); font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.results-score .pct {
  margin-left: 10px; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
  font-weight: 600; font-size: 0.9rem; align-self: center;
}
.flooded-note { color: var(--ink); font-size: 1rem; font-weight: 500; max-width: 30ch; }
.rank-next { margin: -6px 0 0; font-size: 0.82rem; color: var(--muted); }
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}
.results-table th { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; padding: 10px 6px 6px; text-align: left; }
.results-table td { padding: 10px 6px; border-top: 1px solid var(--line); text-align: left; }
.results-table .len { color: var(--muted); padding-left: 12px; }
.results-table th:first-child { padding-left: 12px; }
.results-table .word { font-family: var(--serif); font-weight: 600; letter-spacing: 0.04em; }
.results-table .rarity.band-2 { color: var(--accent); }
.results-table .rarity.band-3 { color: var(--gold); font-weight: 600; }
.results-table .pts { font-weight: 600; }
.results-table .ll { white-space: nowrap; padding-right: 10px; }
.ll-icon { font-size: 0.95rem; line-height: 1; }
#share-btn { min-width: 180px; margin-top: 6px; }
.share-status { margin: -4px 0 0; min-height: 1.2em; font-size: 0.85rem; color: var(--muted); }
.share-practice-note { margin: 6px 0 0; font-size: 0.88rem; color: var(--muted); max-width: 32ch; }
#examples-btn { min-width: 180px; }

/* Example answers dialog */
/* Browsers cap dialogs at the screen width minus ~2em; let this grid use nearly all of it. */
#examples { width: min(calc(100vw - 12px), 440px); max-width: calc(100vw - 12px); }
.examples-sheet { padding-left: 10px; padding-right: 10px; }
.examples-sheet h2, .examples-sheet .fine { padding: 0 6px; }
.examples-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-variant-numeric: tabular-nums; }
.examples-table th { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 4px 2px; text-align: left; }
.examples-table th:first-child, .examples-table td.len { width: 1.8em; text-align: center; color: var(--muted); }
.examples-table th { padding-left: 3px; }
.examples-table td { padding: 1px 2px; border-top: 1px solid var(--line); vertical-align: middle; }
.ex-word {
  display: block; width: 100%;
  min-height: 44px;
  padding: 2px 3px;
  border: 0; border-radius: 6px;
  background: none;
  text-align: left;
  font: 600 0.74rem/1.15 var(--sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  cursor: pointer;
}
.ex-word.selected, .ex-word:active { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ex-word.tier-uncommon { color: var(--accent); }
.ex-word.tier-rare { color: var(--gold); }
td.yours .ex-word { min-height: 32px; padding-bottom: 0; }
.ex-tag { display: block; padding: 0 3px 4px; font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.ex-tag.tier-uncommon { color: var(--accent); }
.ex-tag.tier-rare { color: var(--gold); }
.example-clue { margin: 4px 6px 0; min-height: 2.6em; font-size: 0.9rem; line-height: 1.3; }
.example-clue strong { font-family: var(--serif); letter-spacing: 0.03em; }
@media (max-width: 360px) {
  .ex-word { font-size: 0.68rem; padding-left: 2px; padding-right: 1px; }
  .examples-table th { font-size: 0.5rem; letter-spacing: 0; }
}
.countdown { margin: 0; color: var(--muted); }
.countdown strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ——— Dialogs ——— */
dialog {
  border: 0;
  padding: 0;
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  width: min(92vw, 440px);
  max-height: 88dvh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(10, 20, 30, 0.45); backdrop-filter: blur(2px); }
.sheet { padding: 22px 22px 20px; display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { font-family: var(--serif); font-weight: 600; margin: 0; font-size: 1.6rem; }
.sheet .btn { align-self: center; min-width: 140px; }
.steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.steps li { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; font-size: 0.9rem; line-height: 1.38; }
.sheet h2:focus { outline: none; }
.locale-sheet { gap: 14px; }
.locale-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.locale-opt {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  min-height: 88px; padding: 14px 8px; border-radius: 16px; cursor: pointer;
  border: 1.5px solid var(--line); background: transparent; color: inherit; font: inherit; font-weight: 600;
}
.locale-opt .flag { width: 44px; height: 29px; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15); }
.locale-opt[aria-pressed='true'] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.locale-opt:active { background: var(--bg-2); }
#locale-picker { width: min(92vw, 320px); }
.mini-bridge { display: flex; gap: 2px; }
.mini-bridge b, .mini-bridge i {
  width: 17px; height: 22px; border-radius: 3px; display: grid; place-items: center;
  font-family: var(--serif); font-style: normal; font-size: 0.8rem;
  background: linear-gradient(180deg, var(--tile-hi), var(--tile-lo));
}
.mini-bridge b { background: linear-gradient(180deg, var(--tile-lock-hi), var(--tile-lock-lo)); color: var(--accent); }
.mini-icon {
  width: 44px; height: 44px; border-radius: 50%; justify-self: center;
  display: grid; place-items: center; font-size: 1.2rem; font-weight: 700;
  background: var(--bg-2); color: var(--accent); font-family: var(--serif);
}
.fine { font-size: 0.82rem; color: var(--muted); margin: 0; line-height: 1.45; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px 8px; margin: 0; }
legend { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); padding: 0 6px; }
.opt { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.opt input { width: 20px; height: 20px; accent-color: var(--accent); }

@keyframes fade-in { from { opacity: 0; } }

/* Narrow screens: keep the lifeline row inside the screen. */
@media (max-width: 360px) {
  .kb-row { gap: 0 3px; } /* keeps Delete and Submit at least 44px wide at 320px */
  .key.submit { font-size: 0.66rem; padding: 0; }
  .controls { gap: 4px; padding-left: 6px; padding-right: 6px; }
  .lifeline { padding: 0 9px; gap: 4px; font-size: 0.8rem; }
  .lifeline svg { width: 16px; height: 16px; }
  .dots { gap: 3px; }
  .dot { width: 18px; height: 18px; }
}

/* Short screens: tighten the chrome so the vessel keeps its room. */
@media (max-height: 640px) {
  .clue { margin-top: 4px; padding: 4px 10px; }
  .clue-label { display: none; }
  .clue-list li { font-size: 0.86rem; }
  .key { height: 44px; }
  .kb-row { margin-bottom: 5px; }
  .controls { padding-top: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .overflow-line.warning { animation: none; }
  .audio-playing .mute-btn .wave { animation: none !important; }
  .bridge.falling .tile, .bridge.rising .tile { transform: none; }
  .tile { transition: opacity 0.25s ease; }
}
