/* Exploding Kittens — mobile-first, no build step.
 *
 * The entire UI is drawn from five values and nothing else:
 *
 *   crimson  #820a12   gold  #fbc240   paper  #fdfeff   grey  #5f5d5c
 *   gradient #e72834 → #ffc942
 *
 * Depth comes from alpha compositing those over each other, never from new
 * hues — every literal below is annotated with the mix it stands for. The one
 * exception is black at low alpha for drop shadows and modal scrims, which are
 * shading rather than colour.
 *
 * Two surface families, each shipping its own --ink/--muted/--line so that the
 * component rules further down never need to know which one they are sitting
 * on. Crimson is the default (the app ground); .panel and friends switch to
 * paper. The palette forces this split: grey is unreadable on crimson (1.9:1)
 * but sits at 6.5:1 on paper.
 */

:root {
  --crimson: #820a12;
  --gold: #fbc240;
  --paper: #fdfeff;
  --grey: #5f5d5c;
  --grad: linear-gradient(135deg, #e72834, #ffc942);

  /* Crimson family — the app ground, topbar, handbar, seats. */
  --bg: var(--crimson);
  --bg-soft: #8b1b23;          /* paper 7% over crimson */
  --panel: #90252c;            /* paper 11% over crimson */
  --line: #9d4046;             /* paper 22% over crimson */
  --ink: var(--paper);         /* 10.5:1 on crimson */
  --muted: #dbbabd;            /* paper 72% over crimson — 5.9:1 */

  /* Gold carries every highlight: whose turn it is, the room code, selection. */
  --accent: var(--gold);
  --accent-ink: var(--crimson); /* 6.4:1 on gold */
  --good: var(--gold);
  --warn: var(--gold);

  --radius: 14px;
  /* Cards are 3:4, matching the printed deck and the art we cut for the back.
     Sized to show off the scans: every card carries a different one, so the face
     is worth looking at rather than just identifying. The vw term still governs
     on a phone, where the hand has to fit across the screen. */
  --card-w: clamp(112px, 31vw, 164px);
  --card-h: calc(var(--card-w) * 4 / 3);
}

/* Paper family. Declaring the tokens on the container flips every descendant
   that reads --ink/--muted/--line/--bg-soft, so the rules below stay generic. */
.panel,
.modal-box,
.log-panel,
.rules-panel,
.toast,
.nope-bar,
.card {
  --bg-soft: #f7f2f3;          /* crimson 5% over paper */
  --panel: var(--paper);
  --line: #e7d2d4;             /* crimson 18% over paper */
  --ink: var(--crimson);       /* 10.5:1 on paper */
  --muted: var(--grey);        /* 6.5:1 on paper */
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

.screen { min-height: 100dvh; }
[hidden] { display: none !important; }

/* ───────────────────────────── buttons ───────────────────────────── */

.btn {
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
/* Solid gold, not the gradient: paper text over the gradient's gold end is
   1.6:1, so anything carrying a label gets a flat fill it can be read on. */
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--crimson); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; }
.btn.nope {
  background: var(--crimson); border-color: var(--crimson); color: var(--paper);
  font-size: 18px; letter-spacing: .06em; padding: 12px 26px;
}

/* ───────────────────────── home & lobby ───────────────────────── */

/* The gradient gets the two screens with no body text of their own — every
   readable thing on them lives inside the paper panel. */
#menu, #home, #lobby, #browser { display: grid; place-items: center; padding: 24px; background: var(--grad); }

.panel {
  position: relative;   /* anchors .sound-corner */
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  display: grid;
  gap: 16px;
  text-align: center;
}

.logo { margin: 0; font-size: 34px; line-height: 1.1; letter-spacing: -.02em; color: var(--crimson); }
.tagline { margin: 0; color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }
/* Gold cannot carry text on paper (1.7:1), so errors lean on weight instead. */
.error { color: var(--crimson); font-weight: 600; font-size: 14px; margin: 0; }

.field { display: grid; gap: 6px; text-align: left; font-size: 13px; color: var(--muted); }
input {
  font: inherit; color: var(--ink);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px; width: 100%;
}
input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

.or { position: relative; color: var(--muted); font-size: 13px; }
.or::before { content: ""; position: absolute; inset: 50% 0 auto; border-top: 1px solid var(--line); }
.or span { position: relative; background: var(--panel); padding: 0 10px; }

/* ───────────────────────── sound toggle ───────────────────────── */

.sound-corner { position: absolute; top: 12px; right: 12px; }

.mute { padding: 7px; line-height: 0; border-radius: 999px; }
.mute .ico { width: 20px; height: 20px; display: block; }
/* One icon, two states: the waves and the cross swap places. */
.mute .slash { display: none; }
.mute.off .wave { display: none; }
.mute.off .slash { display: inline; }
.mute.off { color: var(--muted); }

/* ─────────────── visibility toggle & public lobby browser ─────────────── */

/* Two buttons acting as radios: the chosen one takes the gold band the room code
   uses, so "selected" reads the same way everywhere in the app. */
.segmented { display: flex; gap: 8px; }
.seg {
  flex: 1; font: inherit; font-weight: 600; font-size: 14px;
  color: var(--ink); background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 8px; cursor: pointer;
  display: grid; gap: 2px; justify-items: center;
  transition: border-color .12s ease, background .12s ease;
}
.seg small { font-size: 10px; font-weight: 500; color: var(--muted); line-height: 1.25; }
.seg.on { border-color: var(--gold); background: linear-gradient(var(--gold), var(--gold)) bottom / 100% 4px no-repeat, var(--bg-soft); }
.seg.on small { color: var(--ink); }
.seg:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.browser-title { font-size: 26px; }

/* ───────────────────────────── game menu ───────────────────────────── */

.game-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.game-tile {
  width: 100%; display: flex; align-items: center; gap: 12px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 14px; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
}
.game-tile:hover { border-color: var(--gold); }
.game-tile:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.game-emoji { font-size: 28px; line-height: 1; }
.game-text { flex: 1; display: grid; gap: 3px; min-width: 0; }
.game-text b { font-size: 17px; }
.game-text small { font-size: 12px; color: var(--muted); line-height: 1.35; }

/* The one tile you can press is the one with a coloured edge and a chevron. */
.game-tile:not(.locked) { border-left: 3px solid var(--gold); }
.game-go { flex: none; font-size: 22px; color: var(--muted); line-height: 1; }

/* Locked tiles stay legible rather than being greyed into unreadability: the
   point is to advertise what is coming, not to hide it. */
.game-tile.locked { cursor: default; opacity: .7; }
.game-tile.locked:hover { border-color: var(--line); }
.soon {
  flex: none; font-size: 10px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px;
}

.room-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.room-list li {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; text-align: left;
}
.room-info { flex: 1; display: grid; gap: 2px; min-width: 0; }
.room-tag { font-size: 17px; font-weight: 800; letter-spacing: .14em; }
/* Names can be long; the row must not stretch the panel. */
.room-who {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.join-row { display: flex; gap: 8px; }
.code-input {
  text-transform: uppercase; letter-spacing: .35em;
  text-align: center; font-weight: 700; font-size: 20px;
}

/* Gold as a highlighter band behind the digits rather than as the ink: crimson
   reads 6.4:1 over the band and 10.5:1 over the paper either side of it. */
.room-code {
  margin: 0; font-size: 52px; font-weight: 800;
  letter-spacing: .18em; color: var(--crimson);
  background: linear-gradient(var(--gold), var(--gold)) bottom / 100% 34% no-repeat;
}

/* ───────────────────────── avatar picker ─────────────────────────
   External art, like the card scans, so the palette only frames it: --line for
   a portrait going spare, gold for the one that is yours. */

.picker { display: grid; gap: 8px; }
.avatar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.avatar-pick {
  font: inherit; color: var(--ink);
  background: none; border: 0; padding: 0;
  display: grid; gap: 5px; justify-items: center;
  cursor: pointer;
}
.avatar-pick:disabled { cursor: default; }
.avatar-pick:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 12px; }

.avatar-art {
  width: 100%; aspect-ratio: 1; display: block; border-radius: 50%;
  box-shadow: 0 0 0 2px var(--line), 0 4px 10px rgba(0,0,0,.25);
  transition: transform .12s ease, box-shadow .12s ease, filter .15s ease;
}
.avatar-pick:hover:not(:disabled) .avatar-art { transform: translateY(-3px); }
.avatar-cap {
  font-size: 11px; font-weight: 700; color: var(--muted);
  line-height: 1.2; overflow-wrap: anywhere;
}

.avatar-pick.mine .avatar-art { box-shadow: 0 0 0 3px var(--gold), 0 4px 10px rgba(0,0,0,.25); }
.avatar-pick.mine .avatar-cap { color: var(--ink); }

/* Taken: drained of colour, matching the button already being disabled. */
.avatar-pick.taken .avatar-art { filter: grayscale(1); opacity: .3; }

.avatar-chip {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%; overflow: hidden;
  background: var(--bg-soft); box-shadow: 0 0 0 1px var(--line);
  display: grid; place-items: center; font-size: 15px; line-height: 1;
}
.avatar-chip img { width: 100%; height: 100%; display: block; }
.seat .avatar-chip { width: 24px; height: 24px; font-size: 12px; }

.lobby-actions { display: flex; gap: 8px; justify-content: center; }

.lobby-players { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lobby-players li {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; text-align: left;
}
/* The ring keeps a gold dot legible on paper, where hue does the work but
   luminance does not. */
.dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--gold); box-shadow: 0 0 0 1px var(--crimson);
}
.dot.off { background: var(--grey); box-shadow: none; }
.tag { margin-left: auto; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ───────────────────────────── table ───────────────────────────── */

.table { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.pill {
  font-weight: 700; letter-spacing: .16em; font-size: 13px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px;
}
.turn-banner { flex: 1; text-align: center; font-weight: 600; font-size: 14px; }
.turn-banner.mine { color: var(--warn); }

.seats {
  display: flex; gap: 8px; padding: 12px 14px;
  overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.seat {
  flex: none; min-width: 104px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 11px; font-size: 13px;
}
.seat.current { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn) inset; }
.seat.dead { opacity: .4; }
.seat.selectable { border-color: var(--accent); cursor: pointer; }
.seat-name { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.seat-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }

.center {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: clamp(16px, 6vw, 48px); padding: 8px 14px; min-height: 0;
}

/* Face-down back: the box art, cropped to the card ratio. The label rides on a
   scrim along the bottom rather than over the logo, the same trick the scanned
   card faces use. */
.deck {
  position: relative; overflow: hidden;
  width: var(--card-w); aspect-ratio: 3 / 4;
  border-radius: var(--radius); cursor: pointer;
  color: var(--paper); font: inherit; padding: 0;
  background: url("/cards/background.jpeg") center / cover, var(--crimson);
  border: 2px solid var(--line);
  display: grid; align-content: end;
  transition: transform .1s ease, border-color .15s ease;
}
.deck:disabled { cursor: default; opacity: .55; }
.deck:not(:disabled) { border-color: var(--warn); }
.deck:not(:disabled):hover { transform: translateY(-4px); }
/* Tight stops so the scrim sits under the wordmark rather than over it. */
.deck-strip {
  display: grid; gap: 1px; padding: 14px 4px 5px;
  background: linear-gradient(to top, rgba(0,0,0,.9) 26%, rgba(0,0,0,.55) 60%, transparent);
}
.deck-label { font-weight: 800; font-size: 14px; }
.deck-count { font-size: 11px; color: rgba(253,254,255,.78); } /* paper 78% on the scrim */

.discard {
  width: var(--card-w); aspect-ratio: 3 / 4;
  border-radius: var(--radius); border: 2px dashed var(--line);
  display: grid; place-items: center;
}

.deck-stack { display: grid; gap: 8px; justify-items: center; }
/* Gold only once the odds are worth flinching at. */
.deck-risk {
  margin: 0; font-size: 13px; font-weight: 700;
  color: var(--muted); letter-spacing: .02em;
}
.deck-risk.hot { color: var(--warn); }

/* ───────────────────────────── cards ───────────────────────────── */

.card {
  width: var(--card-w); aspect-ratio: 3 / 4; flex: none;
  border-radius: var(--radius);
  border: 2px solid var(--line);
  background: var(--paper);
  cursor: pointer; padding: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center;
  box-shadow: 0 6px 14px rgba(0,0,0,.3);
  transition: transform .14s ease, box-shadow .14s ease;
  font: inherit;
}
.card .glyph { font-size: clamp(30px, 10vw, 44px); line-height: 1; }
.card .label { font-size: 11px; font-weight: 700; line-height: 1.15; }

/* Cards with scanned art: the photo fills the face and the label rides on a
   scrim along the bottom, so the two never fight for the same pixels. */
.card.has-art {
  position: relative; overflow: hidden;
  padding: 0; justify-content: flex-end; gap: 0;
}
.card.has-art .art {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  /* The scans keep a white paper border; nudging past it hides the edge. */
  transform: scale(1.04);
}
.card.has-art .label {
  position: relative; align-self: stretch;
  padding: 10px 3px 3px;
  color: var(--paper);
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
  background: linear-gradient(to top, rgba(0,0,0,.88) 40%, transparent);
}
.card.static { cursor: default; box-shadow: none; }
.card.selected { transform: translateY(-16px); box-shadow: 0 0 0 3px var(--warn), 0 12px 24px rgba(0,0,0,.5); }
.hand .card:hover:not(.selected):not(.blocked) { transform: translateY(-8px) rotate(-1deg); }
.hand .card:active:not(.blocked) { transform: translateY(-4px) scale(.98); }

/* Can't join the current selection: still tappable, so the hint can say why. */
.card.blocked { opacity: .34; cursor: not-allowed; }

/* Cards dealt or drawn slide up into the hand instead of appearing. */
.hand .card { animation: deal-in .22s ease both; }
@keyframes deal-in { from { opacity: 0; transform: translateY(14px) scale(.94); } }

/* Face-down in your own hand, for playing next to somebody nosy. The flip is
   the reveal, so it only runs on the card you actually turned over. */
.card.hidden-face {
  padding: 0;
  background: url("/cards/background.jpeg") center / cover, var(--crimson);
}
.card.flipping { animation: flip-face .26s ease both; }
@keyframes flip-face {
  from { transform: rotateY(78deg) scale(.96); }
  to { transform: rotateY(0) scale(1); }
}

/* Thirteen per-type hues cannot survive a five-colour palette, so type coding
   collapses into three families, matching how the printed cards work: a gold
   band for the powerless cat cards, the brand gradient for cards that actually
   do something, and solid crimson for the one that kills you. Cards with a
   scan show it instead and ignore all of this. */
.card:not(.has-art):not(.hidden-face) {
  background: var(--grad) top / 100% 9px no-repeat, var(--paper);
}
.card[data-slug^="cat-"]:not(.has-art) {
  background: linear-gradient(var(--gold), var(--gold)) top / 100% 9px no-repeat, var(--paper);
}
.card[data-slug="exploding"]:not(.has-art) {
  background: var(--crimson); color: var(--paper); border-color: var(--crimson);
}

/* ─────────────────────── hand & actions ─────────────────────── */

/* --nope-h is set from JS to the live height of the Nope bar so the hand is
   never hidden behind it while you are deciding whether to Nope. */
.handbar {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 10px 0 calc(12px + var(--nope-h, 0px));
  transition: padding-bottom .15s ease;
}
.hand {
  display: flex; gap: 7px; padding: 18px 14px 6px;
  overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  align-items: flex-end; min-height: calc(var(--card-h) + 24px);
}
.actions { display: flex; align-items: center; gap: 12px; padding: 4px 14px 0; }
.hint { color: var(--muted); font-size: 13px; }
.hint.warn { color: var(--gold); font-weight: 600; }

.target-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--bg-soft); border-top: 1px solid var(--line);
}
.target-label { font-size: 13px; color: var(--muted); }
.target-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* ───────────────────────────── nope ───────────────────────────── */

/* A paper slab, so it reads as an interruption against the crimson table. */
.nope-bar {
  position: fixed; inset: auto 0 0; z-index: 40;
  background: var(--panel);
  border-top: 3px solid var(--gold);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}
.nope-inner { max-width: 560px; margin: 0 auto; display: grid; gap: 10px; text-align: center; }
.nope-text { margin: 0; font-size: 15px; font-weight: 600; }
.nope-timer { height: 5px; background: var(--line); border-radius: 999px; overflow: hidden; }
/* Draining bar: decorative, so it can take the gradient unscrimmed. */
.nope-timer i { display: block; height: 100%; background: var(--grad); width: 100%; }
.nope-actions { display: flex; gap: 10px; justify-content: center; }

/* ───────────────────────────── log ───────────────────────────── */

/* Always on, like a chat window: a short strip beneath the table on a phone, a
   column beside it once there is width to spare. */
.table-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.log-panel {
  flex: none; height: 104px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column;
}
/* The whole header is the collapse control, so the hit area is generous on a
   phone rather than a lone caret glyph. */
.log-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 6px 14px; border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel); color: var(--muted);
  font: inherit; font-size: 11px;
  text-transform: uppercase; letter-spacing: .1em;
  cursor: pointer; text-align: left;
}
.log-head:hover { color: var(--ink); }
.log-head strong { font: inherit; }
.caret { font-size: 13px; line-height: 1; transition: transform .15s ease; }

/* Collapsed: the header alone, so the table gets the room back. */
.log-panel.collapsed { height: auto; }
.log-panel.collapsed .log { display: none; }
.log {
  flex: 1; margin: 0; padding: 8px 14px; list-style: none;
  overflow-y: auto; font-size: 13px;
  display: grid; gap: 6px; align-content: start;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.log li { color: var(--muted); }
.log li b { color: var(--ink); }
.log li.big { color: var(--ink); font-weight: 600; }
/* Things that happened to you personally, and are otherwise only a toast. */
.log li.mine { color: var(--ink); }
.log li.fresh { animation: log-in .22s ease both; }
@keyframes log-in { from { opacity: 0; transform: translateY(5px); } }

/* ─────────────────────── demand a card (three of a kind) ─────────────────── */

.demand-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px; width: 100%;
}
.demand-pick {
  font: inherit; font-size: 12px; font-weight: 600; color: var(--ink);
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 6px; cursor: pointer;
  display: grid; gap: 5px; justify-items: center; text-align: center;
  transition: border-color .12s ease, transform .08s ease;
}
.demand-pick:hover { border-color: var(--accent); }
.demand-pick:active { transform: translateY(1px); }
.demand-glyph { font-size: 22px; line-height: 1; }

/* ───────────────────────────── rules ───────────────────────────── */

.rules-panel {
  position: fixed; inset: 0; z-index: 55;
  background: var(--panel);
  display: flex; flex-direction: column;
}
.rules-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px; border-bottom: 1px solid var(--line);
}
.rules-body {
  flex: 1; overflow-y: auto;
  padding: 16px 18px calc(24px + env(safe-area-inset-bottom));
  max-width: 620px; margin: 0 auto; width: 100%;
  font-size: 14px; color: var(--muted);
}
.rules-body p { margin: 0 0 12px; }
.rules-body b { color: var(--ink); }
.rules-body h3 {
  margin: 22px 0 8px; font-size: 13px; color: var(--ink);
  text-transform: uppercase; letter-spacing: .1em;
}
.rules-cards { margin: 0; display: grid; gap: 4px 12px; }
.rules-cards dt { color: var(--ink); font-weight: 700; margin-top: 8px; }
.rules-cards dd { margin: 0; }

@media (min-width: 560px) {
  .rules-cards { grid-template-columns: 11rem 1fr; align-items: baseline; }
  .rules-cards dt { margin-top: 0; }
}

/* ─────────────────────── explosions & defuses ─────────────────────── */

/* Never swallows a tap, so a Nope stays reachable through the bang. */
.cinema {
  position: fixed; inset: 0; z-index: 75;
  display: grid; place-items: center;
  pointer-events: none;
}
.flash {
  position: relative;   /* anchors the blast ring */
  display: grid; gap: 10px; justify-items: center; text-align: center;
  padding: 24px 30px;
  animation: flash-in .4s ease both, flash-out .4s ease both;
}
.flash-glyph {
  font-size: clamp(80px, 30vw, 150px); line-height: 1;
  filter: drop-shadow(0 8px 22px rgba(0,0,0,.6));
}
.flash-text {
  margin: 0; font-size: 19px; font-weight: 800; color: var(--paper);
  text-shadow: 0 2px 10px rgba(0,0,0,.85);
}

/* Anchored over the seat that exploded: no caption, because the name is right
   underneath it. JS sets left/top/width/height from the seat's own box. */
.flash.at-seat {
  position: absolute; padding: 0;
  display: grid; place-content: center; overflow: visible;
}
.flash.at-seat .flash-glyph { font-size: clamp(52px, 17vw, 76px); }
.flash.at-seat .flash-text { display: none; }
.flash.at-seat::before { width: min(52vw, 240px); }

/* Real footage of a blast, laid over the whole table and under the glyph. The
   plate was shot on black, so screen blending throws the black away and leaves
   only the fire — no rectangle, no edges, and the table still reads through it.
   Fades out just before the flash does; JS drops the element after that.

   Mounted on <body> rather than inside .cinema, and that is load-bearing:
   mix-blend-mode only blends against the backdrop within its own stacking
   context, and .cinema is one (fixed + z-index). Nested there, the plate has
   nothing to blend with and paints its black over the whole table. */
.flash-vfx {
  position: fixed; inset: 0; z-index: 74;   /* just under .cinema's glyph */
  width: 100%; height: 100%;
  object-fit: cover;
  mix-blend-mode: screen;
  pointer-events: none;
  animation: vfx-out .4s ease 1.8s both;
}
@keyframes vfx-out { to { opacity: 0; } }

/* The explosion flares gold behind the glyph; the other two are the same beat
   without the noise. Delays must match CINEMA_MS in app.js. */
.flash.exploded { animation-delay: 0s, 1.8s; }
.flash.exploded .flash-glyph { animation: boom .5s ease-out both; }
.flash.exploded::before {
  content: ""; position: absolute; width: min(90vw, 460px); aspect-ratio: 1;
  border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, rgba(251,194,64,.55), rgba(231,40,52,.35) 45%, transparent 70%);
  animation: blast .9s ease-out both;
}
.flash.defused { animation-delay: 0s, .9s; }
.flash.eliminated { animation-delay: 0s, 1s; }
.flash.eliminated .flash-glyph { opacity: .85; }

@keyframes flash-in { from { opacity: 0; transform: scale(.7); } }
@keyframes flash-out { to { opacity: 0; transform: scale(1.06); } }
@keyframes boom {
  0% { transform: scale(.2) rotate(-12deg); }
  55% { transform: scale(1.3) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes blast {
  0% { opacity: 0; transform: scale(.2); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.35); }
}

/* Eliminated seats fade rather than blink out. */
.seat { transition: opacity .45s ease; }

@media (prefers-reduced-motion: reduce) {
  .flash, .flash-glyph, .flash::before { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  .flash { animation: none; }
  .flash.exploded::before { animation: none; opacity: .8; }
  /* A full-screen fireball is exactly what this preference is asking us not to
     do. The bang still sounds; the glyph still says what happened. */
  .flash-vfx { display: none; }
  .log li.fresh { animation: none; }
}

/* ───────────────────────── modal & toasts ───────────────────────── */

.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.6); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
}
.modal-box {
  width: min(480px, 100%); background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 24px; display: grid; gap: 14px; text-align: center;
}
.modal-box h2 { margin: 0; font-size: 22px; }
.modal-cards { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.modal-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 auto; }
.modal-actions .btn[hidden] { display: none; }

.place { display: grid; gap: 12px; }
.place-quick { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.place-slider { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
/* accent-color keeps the native thumb and track inside the palette too. */
.place-slider input { padding: 0; accent-color: var(--crimson); }

/* Sat in the empty band between the seats and the deck, so a burst of toasts
   never buries the turn banner or the other players' card counts. */
/* Below the modal layer (60) on purpose: a prompt you have to answer must not be
   covered by a passing notice, and every toast is now also written to the log, so
   nothing is lost by letting it hide behind one. */
.toasts {
  position: fixed; top: 120px; left: 50%; transform: translateX(-50%);
  z-index: 58; display: grid; gap: 8px; pointer-events: none;
  max-width: min(92vw, 420px);
}
.toast {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 18px; font-size: 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,.45);
  animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-8px); } }

.conn-warning {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
  background: var(--gold); color: var(--crimson); text-align: center;
  font-size: 13px; font-weight: 600; padding: 7px;
}

@media (min-width: 720px) {
  .seats { justify-content: center; }
  .hand { justify-content: center; }
  .actions { justify-content: center; }

  /* Enough room to sit the log alongside the table instead of under it, where
     it can be tall enough to read a whole exchange at a glance. */
  .table-body { flex-direction: row; }
  .log-panel {
    width: 300px; height: auto;
    border-top: 0; border-left: 1px solid var(--line);
  }
  /* Collapsed sideways, the header would be a 300px empty bar, so shrink to a
     narrow spine instead and stand the label on its end. */
  .log-panel.collapsed { width: auto; }
  .log-panel.collapsed .log-head {
    height: 100%; flex-direction: column; justify-content: flex-start;
    gap: 12px; padding: 12px 8px; border-bottom: 0;
  }
  .log-panel.collapsed .log-head strong { writing-mode: vertical-rl; }
}
