/* MovieCat Online: web-native client.
   Scene: friends on a couch or a call, at night, in low light. Dark theater surfaces,
   one warm marquee-gold accent, the 2011 cat art as the cast. */

:root {
  color-scheme: dark;

  /* Neutrals tinted toward plum velvet (hue 330). */
  --bg: oklch(0.16 0.03 330);
  --bg-2: oklch(0.2 0.035 330);
  --surface: oklch(0.245 0.04 330);
  --surface-2: oklch(0.29 0.045 330);
  --surface-3: oklch(0.34 0.05 330);
  --line: oklch(0.37 0.045 330);
  --line-strong: oklch(0.5 0.05 330);
  --ink: oklch(0.97 0.008 330);
  --ink-2: oklch(0.84 0.025 330);
  --ink-3: oklch(0.7 0.03 330);

  /* Marquee gold: primary actions, current turn, focus, your own name. */
  --gold: oklch(0.84 0.15 82);
  --gold-2: oklch(0.89 0.13 86);
  --gold-ink: oklch(0.24 0.05 60);
  --gold-soft: oklch(0.84 0.15 82 / 0.16);

  --good: oklch(0.8 0.18 150);
  --good-ink: oklch(0.22 0.06 150);
  --good-soft: oklch(0.8 0.18 150 / 0.18);
  --bad: oklch(0.72 0.17 25);
  --bad-ink: oklch(0.22 0.06 25);
  --bad-soft: oklch(0.72 0.17 25 / 0.2);
  --select: oklch(0.82 0.13 230);
  --select-soft: oklch(0.82 0.13 230 / 0.2);

  /* Per-puzzle glow, from the original game's background colors. */
  --tone: oklch(0.55 0.15 315);

  --font: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.875rem;
  --fs-3xl: 2.375rem;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  --ease: cubic-bezier(0.25, 1, 0.5, 1); /* ease-out-quart */
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 160ms;
  --med: 240ms;

  --z-sticky: 10;
  --z-overlay: 20;
  --z-dialog: 30;
  --z-toast: 40;

  --hud-h: 60px;
  --gutter: clamp(12px, 3vw, 28px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -10%, oklch(0.84 0.15 82 / 0.08), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; font-weight: 900; }
p { margin: 0; text-wrap: pretty; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

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

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.65rem 1.25rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  font-size: var(--fs-md);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease), opacity var(--fast);
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn svg { width: 1.15em; height: 1.15em; flex: none; }

.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--gold-ink);
}
.btn-primary:hover { background: var(--gold-2); border-color: var(--gold-2); }
.btn-lg { min-height: 56px; font-size: var(--fs-lg); padding: 0.75rem 1.75rem; }
.btn-block { width: 100%; }
.btn-ghost { border-color: transparent; }
.btn-icon { width: 44px; min-height: 44px; padding: 0; border-color: transparent; }

.link-btn {
  background: none;
  border: 0;
  padding: 0.25rem;
  color: var(--ink-2);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--ink); }

/* ---------- form fields ---------- */

.field { display: grid; gap: 0.4rem; }
.field label { font-weight: 800; font-size: var(--fs-sm); color: var(--ink-2); }
.input {
  min-height: 52px;
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--bg-2);
  color: var(--ink);
  font-size: var(--fs-lg);
  font-weight: 700;
  transition: border-color var(--fast), background var(--fast);
}
.input::placeholder { color: var(--ink-3); font-weight: 600; }
.input:hover { border-color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--gold); background: var(--surface); }
.input-code { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 900; }
.input-code::placeholder { letter-spacing: 0.05em; text-transform: none; }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding: 4px;
  gap: 4px;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.segmented button {
  min-height: 44px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
  color: var(--ink-2);
  transition: background var(--fast), color var(--fast);
}
.segmented button:hover:not(:disabled) { color: var(--ink); background: var(--surface); }
.segmented button[aria-pressed="true"] { background: var(--gold); color: var(--gold-ink); }
.segmented button:disabled { cursor: default; }

/* ---------- page frame (outside a game) ---------- */

.page {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  padding: calc(var(--gutter) * 1.5) var(--gutter);
}
.page-inner { width: min(100%, 1040px); margin: 0 auto; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 900;
  font-size: var(--fs-lg);
  color: var(--ink);
  text-decoration: none;
}
.brand img { width: 36px; height: 36px; border-radius: 9px; }

/* Home */
.home {
  display: grid;
  gap: clamp(24px, 5vw, 56px);
  align-items: center;
}
@media (min-width: 860px) {
  .home { grid-template-columns: 1.05fr 1fr; }
}
.home-art {
  position: relative;
  justify-self: center;
  width: min(60%, 260px);
}
@media (min-width: 860px) {
  .home-art { width: min(100%, 460px); }
}
.home-art::before {
  content: "";
  position: absolute;
  inset: 8% 4% 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, oklch(0.84 0.15 82 / 0.28), transparent);
  filter: blur(12px);
}
.home-art img { position: relative; width: 100%; }
.home h1 { font-size: clamp(2.25rem, 6vw, 3.5rem); letter-spacing: -0.02em; }
.home .lede { color: var(--ink-2); font-size: var(--fs-lg); margin-top: 0.6rem; max-width: 34ch; }
.home-form { display: grid; gap: 1.1rem; margin-top: 1.75rem; max-width: 440px; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 0.6rem; }
.or {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink-3);
  font-weight: 800;
  font-size: var(--fs-sm);
}
.or::before, .or::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.home-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-top: 1.5rem; }
.form-error {
  color: var(--bad);
  font-weight: 800;
  font-size: var(--fs-sm);
  min-height: 1.4em;
}

.how {
  margin-top: 1.25rem;
  max-width: 60ch;
  color: var(--ink-2);
}
.how summary { cursor: pointer; font-weight: 800; color: var(--ink); width: fit-content; }
.how ol { padding-left: 1.2rem; margin: 0.6rem 0 0; display: grid; gap: 0.35rem; }

/* ---------- in-game shell ---------- */

.shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
}

.hud {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--hud-h);
  padding: 0.4rem var(--gutter);
  background: oklch(0.16 0.03 330 / 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.hud .brand span { display: none; }
@media (min-width: 720px) { .hud .brand span { display: inline; } }
.hud-room {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-weight: 900;
  letter-spacing: 0.12em;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.hud-room:hover { border-color: var(--ink-3); }
.hud-room svg { width: 15px; height: 15px; }
.hud-spacer { flex: 1; }

.lives { display: inline-flex; align-items: center; gap: 1px; }
.lives .count { display: none; font-weight: 900; font-variant-numeric: tabular-nums; margin-left: 3px; }
@media (max-width: 559px) {
  .hud { gap: 0.4rem; padding-inline: 10px; }
  .hud .brand img { width: 30px; height: 30px; }
  .lives img:not(:first-child) { display: none; }
  .lives img { opacity: 1 !important; transform: none !important; }
  .lives .count { display: inline; }
  .hud .btn-icon { width: 38px; min-height: 38px; }
  .timer { width: 40px; height: 40px; }
  .score { font-size: var(--fs-lg); min-width: 3.5ch; }
  .hud .score small { display: none; }
  .hud-room { letter-spacing: 0.06em; padding: 0.25rem 0.55rem; }
  .hud-room svg { display: none; }
}
.lives img { width: 15px; height: 20px; transition: opacity var(--med), transform var(--med) var(--ease); }
.lives img.dead { opacity: 0.28; transform: translateY(2px) scale(0.9); }
@media (min-width: 560px) { .lives img { width: 18px; height: 24px; } }

.score {
  font-weight: 900;
  font-size: var(--fs-xl);
  font-variant-numeric: tabular-nums;
  min-width: 4.5ch;
  text-align: right;
}
.score small { display: block; font-size: 0.6875rem; letter-spacing: 0.08em; color: var(--ink-3); line-height: 1; text-align: right; }

.timer { position: relative; width: 44px; height: 44px; flex: none; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer .track { stroke: var(--surface-3); }
.timer .fill { stroke: var(--ink-2); transition: stroke var(--med); }
.timer.late .fill { stroke: var(--bad); }
.timer span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.timer.idle { opacity: 0.35; }

/* Players: a scrolling strip on small screens, a side column on wide ones. */
.body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  min-width: 0;
}
.players {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.6rem var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  scrollbar-width: none;
}
.players::-webkit-scrollbar { display: none; }
.player {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
  padding: 0.25rem 0.7rem 0.25rem 0.25rem;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1.5px solid transparent;
  font-weight: 800;
  font-size: var(--fs-sm);
  transition: border-color var(--med), opacity var(--med);
}
.player.me { border-color: var(--gold-soft); }
.player.turn { border-color: var(--gold); }
.player.away, .player.out { opacity: 0.5; }
.player .name { max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .pts { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.avatar {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-3) center / cover no-repeat;
}
.status {
  position: absolute;
  left: 20px;
  bottom: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--bg-2);
  background: var(--surface-3);
}
.status svg { width: 11px; height: 11px; }
.status.playing { background: var(--surface-3); }
.status.playing::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-2);
  animation: pulse 1.2s var(--ease) infinite;
}
.status.solved { background: var(--good); color: var(--good-ink); }
.status.failed { background: var(--bad); color: var(--bad-ink); }
.status.ready { background: var(--gold); color: var(--gold-ink); }
@keyframes pulse { 50% { opacity: 0.25; } }

.main {
  min-width: 0;
  padding: clamp(14px, 3vw, 32px) var(--gutter) calc(24px + env(safe-area-inset-bottom));
  container-type: inline-size;
  container-name: main;
}

@media (min-width: 1100px) {
  .shell { grid-template-rows: auto 1fr; }
  .body { grid-template-columns: minmax(0, 1fr) 280px; grid-template-rows: minmax(0, 1fr); }
  .players {
    order: 2;
    flex-direction: column;
    overflow: visible;
    border-bottom: 0;
    border-left: 1px solid var(--line);
    padding: 1.25rem 1rem;
    gap: 0.4rem;
    align-self: stretch;
  }
  .players::before {
    content: "Players";
    font-weight: 900;
    color: var(--ink-3);
    font-size: var(--fs-sm);
    padding: 0 0.25rem 0.35rem;
  }
  .player { border-radius: var(--r-md); padding: 0.4rem 0.75rem 0.4rem 0.4rem; }
  .player .name { max-width: none; flex: 1; }
  .avatar { width: 38px; height: 38px; }
  .status { left: 30px; }
}

/* ---------- shared panel pieces ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: clamp(16px, 3cqi, 28px);
}
.section-title { font-size: var(--fs-sm); font-weight: 900; color: var(--ink-3); margin-bottom: 0.6rem; }
.muted { color: var(--ink-2); }
.center { text-align: center; }
.stack { display: grid; gap: 1rem; }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 800;
}
.banner.yours { background: var(--gold-soft); border-color: var(--gold); }
.banner .count { color: var(--gold); font-variant-numeric: tabular-nums; font-weight: 900; white-space: nowrap; }

/* ---------- lobby ---------- */

.lobby {
  display: grid;
  gap: 1.25rem;
  width: min(100%, 980px);
  margin: 0 auto;
}
@container main (min-width: 760px) {
  .lobby { grid-template-columns: 1fr 1.1fr; align-items: start; }
}
.room-code {
  font-size: clamp(2.5rem, 12cqi, 4.25rem);
  font-weight: 900;
  letter-spacing: 0.14em;
  line-height: 1;
  margin: 0.25rem 0 1rem;
}
.share-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.share-url { margin-top: 0.75rem; font-size: var(--fs-sm); color: var(--ink-3); word-break: break-all; }
.qr {
  display: none;
  margin-top: 1rem;
  width: 148px;
  padding: 10px;
  border-radius: var(--r-md);
  background: oklch(0.97 0.008 330);
}
.qr svg { width: 100%; height: auto; display: block; }
@media (pointer: fine) { .qr.ready { display: block; } }
.roster { display: grid; gap: 0.5rem; }
.roster-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--r-md);
  background: var(--bg-2);
  font-weight: 800;
}
.roster-row .avatar { width: 44px; height: 44px; }
.roster-row .tag {
  margin-left: auto;
  font-size: var(--fs-xs);
  font-weight: 900;
  padding: 0.15rem 0.55rem;
  border-radius: var(--r-pill);
  background: var(--gold-soft);
  color: var(--gold);
}
.roster-row.away { opacity: 0.5; }
.diff-help { color: var(--ink-2); font-size: var(--fs-sm); margin-top: 0.6rem; min-height: 2.9em; }

/* ---------- board ---------- */

.board { width: min(100%, 1000px); margin: 0 auto; display: grid; gap: 1.1rem; }
.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.board-head h2 { font-size: var(--fs-2xl); }
.rounds { display: flex; gap: 6px; }
.rounds i {
  width: 28px;
  height: 6px;
  border-radius: 3px;
  background: var(--surface-3);
}
.rounds i.done { background: var(--ink-3); }
.rounds i.now { background: var(--gold); }
.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 2cqi, 18px);
}
@container main (min-width: 600px) {
  .tiles { grid-template-columns: repeat(5, 1fr); }
}
.tile {
  position: relative;
  aspect-ratio: 136 / 182;
  border: 0;
  padding: 0;
  border-radius: 14px;
  background: transparent center / contain no-repeat;
  cursor: default;
  transition: transform var(--fast) var(--ease), filter var(--fast), opacity var(--med);
}
.tile.pickable { cursor: pointer; }
.tile.pickable:hover { transform: translateY(-4px) rotate(-1deg); filter: drop-shadow(0 10px 18px oklch(0.84 0.15 82 / 0.3)); }
.tile.pickable:active { transform: scale(0.96); }
.tile.played { opacity: 0.45; filter: saturate(0.6); }
.tile.dealing { animation: deal var(--med) var(--ease-expo) both; }
@keyframes deal { from { transform: scale(1.35); opacity: 0; } }
.board-foot { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; }

.standings { display: grid; gap: 0.35rem; }
.standing {
  display: grid;
  grid-template-columns: 1.6rem 34px 1fr auto auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--r-sm);
  font-weight: 800;
}
.standing:nth-child(odd) { background: var(--bg-2); }
.standing .rank { color: var(--ink-3); text-align: center; }
.standing .avatar { width: 34px; height: 34px; }
.standing .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standing .who.me { color: var(--gold); }
.standing .lv { color: var(--ink-3); font-size: var(--fs-sm); }
.standing .pts { font-variant-numeric: tabular-nums; text-align: right; min-width: 5ch; }
.standing.out { opacity: 0.55; }

/* ---------- puzzle ---------- */

/* While a puzzle is live: no page scroll, every answer on screen at once (fairness). */
html:has(.shell.fit), body:has(.shell.fit) { overflow: hidden; }
.shell.fit { height: 100dvh; min-height: 0; overflow: hidden; }
.shell.fit .body { min-height: 0; grid-template-rows: auto minmax(0, 1fr); }
@media (min-width: 1100px) {
  .shell.fit .body { grid-template-rows: minmax(0, 1fr); }
}
.shell.fit .main {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  padding-top: clamp(10px, 2vh, 24px);
}
.shell.fit .main > div { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.shell.fit .puzzle {
  flex: 1;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
}
.shell.fit .clue { display: flex; flex-direction: column; min-height: 0; overflow: hidden auto; overscroll-behavior: contain; }
.shell.fit .clue-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.shell.fit .clue-body > .media-img,
.shell.fit .clue-body > .screen-frame,
.shell.fit .clue-body > .scene { flex: 1; min-height: 0; display: flex; justify-content: center; }
.shell.fit .clue-body .media-img { width: auto; max-width: 100%; height: 100%; max-height: 100%; object-fit: contain; margin: 0 auto; background: none; }
.shell.fit .screen-frame .media-img { height: 100%; }
.shell.fit .scene img { width: auto; height: 100%; max-width: 100%; object-fit: contain; margin: 0 auto; }
.shell.fit .outfits { flex: 1; min-height: 0; }
.shell.fit .outfit { aspect-ratio: auto; min-height: 0; }
.shell.fit .cards { flex: 1; min-height: 0; grid-template-rows: 1fr 1fr; }
.shell.fit .card { aspect-ratio: auto; min-height: 64px; }
@media (max-width: 1099px) {
  .shell.fit .players { padding-block: 0.4rem; }
  .shell.fit .player { font-size: var(--fs-xs); }
  .shell.fit .player .avatar { width: 26px; height: 26px; }
  .shell.fit .status { left: 14px; width: 15px; height: 15px; }
}
@media (max-height: 760px) {
  .shell.fit .kind { margin-bottom: 0.35rem; }
  .shell.fit .prompt { font-size: clamp(1.05rem, 2.6cqi, 1.5rem); }
  .shell.fit .chapter { min-height: 46px; font-size: var(--fs-md); gap: 0.6rem; }
  .shell.fit .chapter .disc { width: 38px; height: 38px; }
  .shell.fit .chapters { gap: 0.45rem; }
}
/* Short landscape screens (phones on their side): slimmer HUD, players fold into it. */
.hud-players { display: none; }
@media (max-height: 500px) {
  .hud { min-height: 46px; padding-block: 0.15rem; }
  .hud .brand span { display: none; }
  .shell.fit .players { display: none; }
  .shell.fit .body { grid-template-rows: minmax(0, 1fr); }
  .shell.fit .hud-players { display: flex; gap: 4px; margin-right: 0.25rem; }
  .hud-players .player { padding: 0; background: none; border-width: 2px; border-radius: 50%; }
  .hud-players .avatar { width: 26px; height: 26px; }
  .hud-players .status { left: auto; right: -4px; bottom: -3px; width: 14px; height: 14px; }
  .shell.fit .main { padding-top: 8px; }
  .shell.fit .answers > .muted { display: none; }
  .shell.fit .answer-grid, .shell.fit .match-cols, .shell.fit .match-cols .col { gap: 0.35rem; }
  .shell.fit .match-cols .answer { min-height: 40px; }
  .shell.fit .clue { padding: 10px 14px; }
}
/* Small phones: the type label already says what to do for fixed-prompt puzzles. */
@media (max-height: 760px) and (max-width: 559px) {
  .shell.fit .prompt.fixed { display: none; }
  .shell.fit .clue-body { margin-top: 0 !important; }
}


.puzzle {
  width: min(100%, 1100px);
  margin: 0 auto;
  display: grid;
  gap: clamp(14px, 2.5cqi, 28px);
  grid-template-areas: "clue" "answers";
}
@media (orientation: landscape) and (min-width: 640px) {
  @container main (min-width: 600px) {
    .puzzle { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "clue answers"; align-items: start; }
    .shell.fit .puzzle { grid-template-rows: minmax(0, 1fr); align-items: stretch; }
    .shell.fit .answers { overflow: auto; }
  }
}
/* After the reveal, small screens lead with the verdict. */
.puzzle.revealed { grid-template-areas: "answers" "clue"; }
@container main (min-width: 820px) {
  .puzzle.revealed:not(.media) { grid-template-areas: "clue" "answers"; }
  .puzzle.media { grid-template-columns: minmax(0, 1.25fr) minmax(300px, 1fr); grid-template-areas: "clue answers"; align-items: start; }
  .puzzle.media.revealed { grid-template-areas: "clue answers"; }
}
.clue {
  grid-area: clue;
  position: relative;
  border-radius: var(--r-lg);
  padding: clamp(14px, 3cqi, 28px);
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in oklch, var(--tone) 45%, transparent), transparent 70%),
    var(--surface);
  border: 1px solid color-mix(in oklch, var(--tone) 40%, var(--line));
  min-width: 0;
}
.kind {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-sm);
  font-weight: 900;
  color: var(--ink-2);
  margin-bottom: 0.75rem;
}
.kind img { width: 26px; height: 35px; object-fit: contain; }
.kind .pos { margin-left: auto; color: var(--ink-3); }
.prompt { font-size: clamp(1.25rem, 3.4cqi, 1.875rem); font-weight: 900; line-height: 1.22; }
.answers { grid-area: answers; display: grid; gap: 0.6rem; align-content: start; min-width: 0; }
.answer-grid { display: grid; gap: 0.5rem; grid-template-columns: 1fr 1fr; }
/* Side-by-side media layouts on tall screens have room for one tidy column. */
@container main (min-width: 820px) {
  .puzzle.media .answer-grid.short { grid-template-columns: 1fr; }
}
@media (max-height: 700px) {
  @container main (min-width: 820px) {
    .puzzle.media .answer-grid.short { grid-template-columns: 1fr 1fr; }
  }
}
@container main (max-width: 559px) {
  .answer-grid.long .answer { font-size: var(--fs-xs); min-height: 44px; }
  .answer { min-height: 48px; padding: 0.45rem 0.6rem; font-size: var(--fs-sm); gap: 0.4rem; }
  .match-cols .answer { min-height: 52px; }
}
@media (max-height: 560px) {
  .answer { min-height: 40px; padding: 0.35rem 0.6rem; font-size: var(--fs-sm); }
}
.answer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 54px;
  padding: 0.6rem 0.9rem;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line-strong);
  background: var(--bg-2);
  text-align: left;
  font-weight: 800;
  font-size: var(--fs-md);
  line-height: 1.2;
  cursor: pointer;
  transition: background var(--fast) var(--ease), border-color var(--fast), transform var(--fast) var(--ease), opacity var(--med);
}
.answer:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-3); }
.answer:active:not(:disabled) { transform: scale(0.98); }
.answer:disabled { cursor: default; }
.answer .key {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: none;
  place-items: center;
  font-size: var(--fs-xs);
  font-weight: 900;
  color: var(--ink-3);
  border: 1px solid var(--line);
}
@media (pointer: fine) { .answer .key { display: grid; } }
.answer .mark { margin-left: auto; flex: none; width: 22px; height: 22px; }
.answer.pending { border-color: var(--ink-2); opacity: 0.85; }
.answer.selected { border-color: var(--select); background: var(--select-soft); }
.answer.right { border-color: var(--good); background: var(--good-soft); color: var(--ink); }
.answer.right .key { color: var(--good); border-color: var(--good); }
.answer.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--ink-2); }
.answer.wrong .label { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--bad); }
.answer.dim { opacity: 0.4; }
.answer.gone { opacity: 0.25; }
.answer.shake { animation: shake 320ms var(--ease); }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.answer.pop { animation: pop 260ms var(--ease-expo); }
@keyframes pop { 40% { transform: scale(1.04); } }

.feedback {
  min-height: 1.6em;
  font-weight: 900;
  text-align: center;
}
.feedback.bad { color: var(--bad); }
.feedback.good { color: var(--good); }

/* Clue media */
.media-img { width: 100%; border-radius: var(--r-md); background: var(--bg); }
.screen-frame {
  padding: clamp(6px, 1.5cqi, 12px);
  border-radius: var(--r-md);
  background: oklch(0.1 0.02 330);
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px -20px oklch(0.9 0.05 230 / 0.35);
}
.outfits {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(6px, 1.5cqi, 14px);
  padding-bottom: 6px;
  background: linear-gradient(transparent 68%, oklch(0.42 0.08 50 / 0.5) 68%);
  border-radius: var(--r-md);
}
.outfit {
  aspect-ratio: 318 / 496;
  border-radius: var(--r-sm);
  background: oklch(0.3 0.06 50 / 0.35);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.outfit img { width: 100%; height: 100%; object-fit: contain; }
.outfit .soon { color: var(--ink-3); font-weight: 900; font-size: var(--fs-sm); }
.outfit img.in { animation: slide-in 420ms var(--ease-expo) both; }
@keyframes slide-in { from { transform: translateX(40%); opacity: 0; } }

.chat { display: grid; gap: 0.6rem; }
.line { display: flex; align-items: flex-end; gap: 0.5rem; max-width: 92%; }
.line.right { margin-left: auto; flex-direction: row-reverse; }
.line .who { width: 46px; height: 30px; flex: none; object-fit: contain; }
.bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 18px;
  font-weight: 800;
  line-height: 1.3;
  color: oklch(0.2 0.04 260);
}
.bubble.m { background: oklch(0.78 0.09 255); border-bottom-left-radius: 6px; }
.bubble.f { background: oklch(0.8 0.1 350); color: oklch(0.22 0.05 350); border-bottom-left-radius: 6px; }
.line.right .bubble { border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
@container main (max-width: 559px) {
  .bubble { font-size: var(--fs-sm); padding: 0.45rem 0.7rem; }
  .line .who { width: 36px; height: 24px; }
  .chat { gap: 0.45rem; }
}
.bubble.typing { display: flex; gap: 4px; padding: 0.85rem 1rem; }
.bubble.typing i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.55; animation: pulse 1s var(--ease) infinite; }
.bubble.typing i:nth-child(2) { animation-delay: 0.15s; }
.bubble.typing i:nth-child(3) { animation-delay: 0.3s; }
.bubble.in { animation: rise 260ms var(--ease-expo) both; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(8px, 2cqi, 14px); }
@container main (min-width: 380px) and (max-width: 819px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
}
.card {
  position: relative;
  aspect-ratio: 1 / 1.08;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
}
.card:disabled { cursor: default; }
.card-inner {
  position: absolute;
  inset: 0;
  transition: transform 460ms var(--ease-expo);
  transform-style: preserve-3d;
}
.card.flipped .card-inner { transform: rotateY(180deg); }
.card.instant .card-inner { transition: none; }
.card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--r-md);
  backface-visibility: hidden;
  display: grid;
  place-items: end center;
  padding: 0.5rem;
  overflow: hidden;
}
.card-front { background: var(--bg-2) 50% 22% / auto 74% no-repeat; border: 1.5px solid var(--line); } /* height-based so the sign stays at 43% when cards stretch */
.card:hover:not(:disabled) .card-front { border-color: var(--ink-3); }
.card-front span {
  /* Sits on the blank sign the cat is holding (sign center ≈ 43% down the card). */
  position: absolute;
  left: 51%;
  top: 43%;
  transform: translate(-50%, -50%);
  width: 68%;
  font-weight: 900;
  font-size: clamp(0.625rem, 2.1cqi, 0.875rem);
  line-height: 1.1;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px oklch(0 0 0 / 0.45);
}
.card-back {
  transform: rotateY(180deg);
  place-items: center;
  text-align: center;
  background: oklch(0.95 0.03 90);
  color: oklch(0.22 0.03 60);
  font-weight: 800;
  font-size: clamp(0.75rem, 2.6cqi, 1rem);
  line-height: 1.2;
  border: 1.5px solid oklch(0.84 0.15 82);
}
.card-back small { display: block; font-size: 0.7em; font-weight: 900; opacity: 0.6; margin-bottom: 0.2rem; }
.clue-cost { margin-top: 0.75rem; font-size: var(--fs-sm); color: var(--ink-2); font-weight: 700; }

.chapters { display: grid; gap: 0.7rem; }
.chapter {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 62px;
  padding: 0.4rem 1rem 0.4rem 0.4rem;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, oklch(0.88 0.1 135), oklch(0.88 0.1 135 / 0.15));
  color: oklch(0.22 0.06 140);
  font-weight: 900;
  font-size: var(--fs-lg);
}
.chapter .disc {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  background: url(/art/ui/dvdchapters_chaptermarker_2x.png) 0 50% / auto 100% no-repeat;
}
.chapter .num { font-size: var(--fs-xs); opacity: 0.7; display: block; }
.chapter.waiting { background: oklch(0.88 0.1 135 / 0.12); color: var(--ink-3); }
.chapter.in { animation: slide-in 600ms var(--ease-expo) both; }

.scene { border-radius: var(--r-md); overflow: hidden; position: relative; }
.scene img { width: 100%; }
.curtain {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  pointer-events: none;
}
.curtain i { background: url(/art/ui/catscene_curtain_left.png) right / cover; animation: open-l 900ms var(--ease-expo) 300ms both; }
.curtain i + i { background-image: url(/art/ui/catscene_curtain_right.png); background-position: left; animation-name: open-r; }
@keyframes open-l { to { transform: translateX(-100%); } }
@keyframes open-r { to { transform: translateX(100%); } }

.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
.match-cols .col { display: grid; gap: 0.55rem; align-content: start; }
.match-cols .answer { justify-content: center; text-align: center; min-height: 64px; }
.match-done { display: grid; gap: 0.4rem; margin-top: 0.5rem; }
.match-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: var(--r-sm);
  background: var(--good-soft);
  font-weight: 800;
  font-size: var(--fs-sm);
}
.match-pair svg { width: 16px; color: var(--good); }
.match-pair span:last-child { text-align: right; }

.picks { font-weight: 900; color: var(--ink-2); font-size: var(--fs-sm); }

/* Lead-in before the clock starts */
.lead {
  display: grid;
  place-items: center;
  gap: 1rem;
  padding: 3rem 1rem;
  text-align: center;
}
.lead img { width: min(36vw, 150px); animation: deal 500ms var(--ease-expo) both; }
.lead h2 { font-size: clamp(1.5rem, 6cqi, 2.5rem); }

/* ---------- reveal ---------- */

.verdict {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.1rem;
  border-radius: var(--r-md);
  font-weight: 900;
  font-size: var(--fs-lg);
}
.verdict svg { width: 26px; height: 26px; flex: none; }
.verdict.good { background: var(--good-soft); color: var(--good); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.verdict.neutral { background: var(--surface-2); color: var(--ink-2); }
.verdict .pts { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink); }

.answer-card {
  border-radius: var(--r-md);
  padding: 1rem 1.1rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.answer-card .label { font-size: var(--fs-sm); font-weight: 900; color: var(--ink-3); }
.answer-card .big { font-size: var(--fs-xl); font-weight: 900; color: var(--good); line-height: 1.2; margin-top: 0.15rem; }
.answer-card .extra { color: var(--ink-2); font-weight: 700; margin-top: 0.2rem; }
.answer-card ul { list-style: none; margin: 0.35rem 0 0; padding: 0; display: grid; gap: 0.2rem; }
.answer-card li { color: var(--good); font-weight: 900; font-size: var(--fs-lg); }
.answer-card li.pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.5rem; font-size: var(--fs-md); }
.answer-card li.pair span:last-child { text-align: right; }

.breakdown { display: grid; gap: 0.2rem; font-weight: 800; }
.breakdown div { display: flex; justify-content: space-between; gap: 1rem; color: var(--ink-2); }
.breakdown div span:last-child { font-variant-numeric: tabular-nums; color: var(--ink); }
.breakdown .total { margin-top: 0.4rem; padding-top: 0.5rem; border-top: 1px solid var(--line); font-size: var(--fs-xl); color: var(--ink); }
.breakdown .total span:last-child { color: var(--gold); }

.results { display: grid; gap: 0.3rem; }
.result {
  display: grid;
  grid-template-columns: 22px 30px 1fr auto auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--r-sm);
  font-weight: 800;
}
.result:nth-child(odd) { background: var(--bg-2); }
.result .ok { color: var(--good); }
.result .no { color: var(--bad); }
.result svg { width: 18px; height: 18px; }
.result .avatar { width: 30px; height: 30px; }
.result .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .who.me { color: var(--gold); }
.result .lost { color: var(--bad); font-size: var(--fs-xs); font-weight: 900; }
.result .pts { font-variant-numeric: tabular-nums; min-width: 4.5ch; text-align: right; }

.continue-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0 calc(0.25rem + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
  margin-top: 0.25rem;
}
.continue-bar .note { color: var(--ink-2); font-weight: 800; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.continue-bar .btn { margin-left: auto; }

/* ---------- round end / final ---------- */

.finale { width: min(100%, 880px); margin: 0 auto; display: grid; gap: 1.25rem; }
.finale h2 { font-size: clamp(1.75rem, 6cqi, 2.75rem); text-align: center; }
.bonus-cats { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; min-height: 54px; }
.bonus-cats img { width: 38px; height: 44px; animation: deal 300ms var(--ease-expo) both; }
.bonus-total { text-align: center; font-size: var(--fs-2xl); font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }

.podium {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  align-items: end;
  gap: clamp(8px, 2cqi, 20px);
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}
.step {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  text-align: center;
  font-weight: 900;
}
.step .avatar { width: clamp(52px, 14cqi, 84px); height: clamp(52px, 14cqi, 84px); }
.step .who { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .pts { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.step .block {
  width: 100%;
  display: grid;
  place-items: center;
  border-radius: var(--r-md) var(--r-md) 6px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.step .block img { width: 34px; }
.step.first .block { height: 120px; background: var(--gold-soft); border-color: var(--gold); }
.step.second .block { height: 88px; }
.step.third .block { height: 64px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.5rem; }
.stat { padding: 0.7rem 0.9rem; border-radius: var(--r-md); background: var(--bg-2); }
.stat b { display: block; font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--fs-sm); color: var(--ink-2); font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }

/* ---------- gallery ---------- */

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; margin-top: 1.25rem; }
.thumb {
  aspect-ratio: 3 / 2;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--bg-2) center / cover no-repeat;
  padding: 0;
  cursor: pointer;
  transition: transform var(--fast) var(--ease), border-color var(--fast);
}
.thumb:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--gold); }
.thumb:disabled { cursor: default; background-size: 70%; opacity: 0.6; }

dialog.viewer {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(96vw, 1100px);
  width: 100%;
}
dialog.viewer::backdrop { background: oklch(0.1 0.02 330 / 0.92); }
dialog.viewer img { width: 100%; border-radius: var(--r-md); }
dialog.viewer .row { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 0.75rem; }

/* ---------- toast / connection ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  padding: 0.7rem 1.1rem;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--bg);
  font-weight: 800;
  box-shadow: 0 10px 30px -10px oklch(0 0 0 / 0.6);
  animation: rise 220ms var(--ease-expo);
  max-width: calc(100vw - 32px);
  text-align: center;
}
.conn {
  font-size: var(--fs-xs);
  font-weight: 900;
  padding: 0.2rem 0.6rem;
  border-radius: var(--r-pill);
  background: var(--bad-soft);
  color: var(--bad);
}

.splash { min-height: 60dvh; display: grid; place-items: center; color: var(--ink-2); font-weight: 800; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
  .card-inner { transition: none; }
}
