/*
 * styles.css — all styling for Hit, Stay.
 * Set dressing follows C:\Repo\Dev\DevilsEquationWordle (itself after
 * DevilsHeavy13, DevilsRoulette and MemoryPoker): a lit concrete cell wall,
 * dark slabs with a gold hairline, purple game furniture, gold for anything
 * you act on, engraved Cinzel caps and Zilla Slab. The cards are
 * MemoryPoker's, to the pixel where it matters: white stock, a hairline inset
 * rule, a slab numeral, and a purple filigree back.
 *
 * used_by: index.html
 * related: offline.html (carries its own minimal copy of the palette);
 *          ui.js (builds the felt, your hand, the action bar and the
 *          announcement)
 * rules:
 *   - Mobile-first at ~380px. Every tappable control is at least 44px.
 *   - Colour has one meaning each: gold = you / act now, purple = game
 *     furniture and the back of a card, green = within the limit, red = over
 *     it. A minus-one card carries the card-stock rouge, because on a real
 *     deck that is what the red ink is for.
 *   - Controls are NOT purple. Every button is the near-black slab with a gold
 *     hairline and a gold light bleeding off its bottom edge, after
 *     C:\Repo\Dev\DevilsRoulette. Purple is left to the furniture that is
 *     only looked at: the masthead ribbon, and card backs.
 *   - Text straight on the wall is dark ink; text on a slab is cream or gold.
 *   - Every number on a game piece — a card face, a chip count — is set in the
 *     display face. The body face is for prose only.
 *   - Fonts are local files in fonts/. No url() to another origin, ever.
 *   - Anything not needed right now is display:none, not greyed out. The one
 *     exception is a seat that has folded, which stays on the felt at reduced
 *     opacity because who folded is information.
 *   - The page is exactly one screen tall (.shell is 100dvh) and never
 *     scrolls. The felt takes whatever height is left over.
 *   - A round ends with .announce over the middle of the felt, which clears
 *     itself. Nothing slides over your hand and there is no result screen
 *     between rounds: the hands stay face up on the felt behind it.
 * message: --card-w is the only card dimension; height comes from the 5/7
 *   aspect ratio and every glyph inside is sized in cqw off the card itself.
 * wiki: README.md
 */
@font-face { font-family: "Cinzel"; font-weight: 400 700; font-style: normal; font-display: swap; src: url("fonts/cinzel-latin.woff2") format("woff2"); }
@font-face { font-family: "Zilla Slab"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/zilla-slab-400.woff2") format("woff2"); }
@font-face { font-family: "Zilla Slab"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/zilla-slab-600.woff2") format("woff2"); }
@font-face { font-family: "Zilla Slab"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/zilla-slab-700.woff2") format("woff2"); }

:root {
  /* Concrete */
  --wall-lit: #a5a39e;
  --wall-mid: #7e7c78;
  --wall-dark: #5a5855;
  --wall-deep: #3e3d3b;

  /* Ink on the wall */
  --ink: #221e1b;
  --ink-soft: #3d3732;
  --ink-faint: #524c46;

  /* Slabs laid on the wall */
  --slab: #25211e;
  --slab-deep: #1a1816;
  --slab-bg: linear-gradient(180deg, rgba(48, 44, 41, 0.94), rgba(26, 24, 22, 0.96));
  --line: rgba(240, 220, 164, 0.2);
  --line-soft: rgba(240, 220, 164, 0.1);
  --cream: #d6cec2;
  --mute: #9c948a;

  /* Purple: the game furniture, and the back of every card */
  --purple-900: #2d1245;
  --purple-700: #4a1d73;
  --purple-600: #5f2a94;
  --purple-500: #7634b4;
  --purple-400: #8a46c9;
  --purple-300: #ad7ae0;
  --purple-100: #e4d4f5;

  /* Gold: you, and anything you act on */
  --gold-600: #9c7628;
  --gold-500: #c6992f;
  --gold-400: #d9b254;
  --gold-200: #f0dca4;

  /* Card stock, from MemoryPoker */
  --stock: #fbf9f4;
  --stock-edge: #ddd6c9;
  --rouge: #b63028;

  /* Within the limit, over the limit */
  --red: #e5594a;
  --red-deep: #9c2a21;
  --amber: #e6c24d;
  --amber-deep: #a8761a;
  --green: #5cc487;
  --green-deep: #1f6a43;

  --display: "Cinzel", "Trajan Pro", Georgia, serif;
  --body: "Zilla Slab", Rockwell, Georgia, serif;
  --ease: cubic-bezier(0.22, 0.61, 0.24, 1);
  --ease-snap: cubic-bezier(0.34, 1.46, 0.5, 1);
  --radius: 6px;
  --shadow-slab: 0 10px 24px -14px rgba(0, 0, 0, 0.9);
  --shadow-card: 0 10px 20px -8px rgba(18, 14, 12, 0.75), 0 2px 4px -2px rgba(18, 14, 12, 0.6);

  /* The one card dimension. ui.js leaves these alone; the media queries at the
     bottom of this file shrink them on a short screen. */
  --card-w: 46px;
  --card-rail: 26px;
}

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

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

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.4;
  color: var(--cream);
  background-color: var(--wall-dark);
  /* One overhead light on a concrete wall. */
  background-image: radial-gradient(120% 88% at 50% 12%, var(--wall-lit) 0%, var(--wall-mid) 42%, var(--wall-dark) 74%, var(--wall-deep) 100%);
  background-attachment: fixed;
  touch-action: manipulation;
  overflow-x: hidden;
  /* House rule: the sites are played, not read. Dragging across the table must
     never paint a text selection. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

input, textarea, select, [contenteditable], .selectable {
  -webkit-user-select: text;
  user-select: text;
}

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

/* Concrete grain */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 8s steps(6) infinite;
}
@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 1%); }
  50% { transform: translate(1%, -2%); }
  75% { transform: translate(2%, 1%); }
}

button, input { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

/* One screen, no scrolling. Below 540px tall it gives up and scrolls rather
   than crush the table. */
.shell {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  height: 100vh;
  height: 100dvh;
  min-height: 540px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 14px env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.shell > * { flex: none; }

/* ---------------- masthead ---------------- */

.masthead { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }

/* The purple ribbon with notched ends that every title hangs from. */
.eyebrow {
  display: inline-block;
  padding: 3px 12px;
  font-family: var(--display);
  font-size: 0.44rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--gold-200);
  background: linear-gradient(180deg, var(--purple-700), var(--purple-900));
  box-shadow: inset 0 0 0 1px var(--gold-600), inset 0 1px 0 rgba(240, 220, 164, 0.3);
  clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 50%, 100% 100%, 0 100%, 9px 50%);
}

/* Engraved into the wall. */
.wordmark {
  font-family: var(--display);
  font-size: clamp(1.15rem, 6.6vw, 1.6rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #171412;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.16), 0 -1px 1px rgba(0, 0, 0, 0.5);
}

/* Hamburger menu. Dark slab, gold hairline, gold display labels. Opaque, so
   nothing bleeds through. */
.menu { position: relative; flex: none; }
.menu-btn { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 0; background: var(--slab-bg); box-shadow: var(--shadow-slab); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 0.2s ease; }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: linear-gradient(180deg, #3a3228, #1c1916); border-color: var(--gold-400); }
.menu-btn:focus-visible, .menu-item:focus-visible { outline: 2px solid var(--gold-200); outline-offset: -3px; }
.menu-bars { position: relative; width: 16px; height: 12px; }
.menu-bars i { position: absolute; left: 0; width: 16px; height: 2px; background: var(--gold-200); border-radius: 1px; transition: transform 0.22s var(--ease), opacity 0.15s ease, top 0.22s var(--ease); }
.menu-bars i:nth-child(1) { top: 0; }
.menu-bars i:nth-child(2) { top: 5px; }
.menu-bars i:nth-child(3) { top: 10px; }
.menu-btn[aria-expanded="true"] .menu-bars i:nth-child(1) { top: 5px; transform: rotate(45deg); }
.menu-btn[aria-expanded="true"] .menu-bars i:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] .menu-bars i:nth-child(3) { top: 5px; transform: rotate(-45deg); }
.menu-panel { position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; width: 216px; display: flex; flex-direction: column; border: 1px solid var(--line); border-top: 2px solid var(--gold-400); background: var(--slab); box-shadow: 0 18px 34px -10px rgba(0, 0, 0, 0.9); animation: sheet-in 0.2s var(--ease) both; }
.menu-panel[hidden] { display: none; }
.menu-item { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 36px; padding: 0 12px 0 26px; border: 0; background: none; font-family: var(--display); font-size: 0.58rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; text-decoration: none; color: var(--gold-200); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background 0.18s ease, color 0.18s ease; }
.menu-item::before { content: ''; position: absolute; left: 11px; top: 50%; width: 5px; height: 5px; margin-top: -3px; background: var(--gold-400); transform: rotate(45deg); opacity: 0.55; transition: opacity 0.18s ease; }
.menu-item + .menu-item { border-top: 1px solid var(--line-soft); }
.menu-item:hover, .menu-item:active { background: rgba(240, 220, 164, 0.07); color: var(--stock); }
.menu-item:hover::before, .menu-item:active::before { opacity: 1; }
.menu-more { border-top: 1px solid var(--line); background: rgba(240, 220, 164, 0.04); }
.menu-more::after { content: '\2197'; font-size: 0.8rem; letter-spacing: 0; }

/* The state-pill groups in the menu (Odds, Pace). */
.opt-pills { display: flex; gap: 4px; font-family: var(--body); font-size: 0.7rem; letter-spacing: 0; line-height: 1; text-transform: none; }
.opt-pills i { padding: 2px 5px; border: 1px solid var(--line); font-style: normal; font-weight: 600; color: var(--mute); }
.opt-pills i.on { color: var(--slab-deep); background: var(--gold-200); border-color: var(--gold-200); }

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

.btn {
  appearance: none;
  min-height: 46px;
  min-width: 46px;
  padding: 8px 12px;
  border: 1px solid rgba(240, 220, 164, 0.26);
  border-radius: 2px;
  background: linear-gradient(180deg, #332e2a, #191715);
  /* Near-black, with a gold light bleeding up off the bottom edge. */
  box-shadow: inset 0 1px 0 rgba(240, 220, 164, 0.1), inset 0 -14px 20px -16px var(--gold-400), 0 8px 18px -10px rgba(0, 0, 0, 0.95);
  font-family: var(--display);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold-200);
  cursor: pointer;
  transition: transform 0.16s var(--ease-snap), filter 0.2s ease, box-shadow 0.25s ease, border-color 0.2s;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); transform: translateY(-2px); border-color: rgba(240, 220, 164, 0.5); }
.btn:active:not(:disabled) { transform: translateY(0); filter: brightness(0.95); }
.btn:focus-visible { outline: 2px solid var(--gold-200); outline-offset: 2px; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; box-shadow: none; }

.btn-ghost { background: rgba(24, 20, 18, 0.62); border-color: rgba(240, 220, 164, 0.28); box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: rgba(58, 50, 40, 0.75); border-color: rgba(240, 220, 164, 0.45); filter: none; }
.btn-danger { border-color: var(--red) !important; color: var(--red) !important; }
/* Gold: the one button that moves the game on. */
.btn-primary { background: linear-gradient(180deg, var(--gold-200), var(--gold-500)); border-color: var(--gold-600); color: #1d1608; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 8px 18px -10px rgba(0, 0, 0, 0.95); }
.btn-wide { width: 100%; min-height: 52px; font-size: 0.76rem; letter-spacing: 0.2em; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }
.btn-sub { display: block; margin-top: 2px; font-family: var(--body); font-size: 0.74rem; font-weight: 600; letter-spacing: 0; text-transform: none; opacity: 0.85; }

/* ---------------- status strip ---------------- */

.status { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); background: var(--slab-bg); box-shadow: var(--shadow-slab); }
.stat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 6px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line-soft); }
.stat-label { display: block; font-family: var(--display); font-size: 0.44rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-200); white-space: nowrap; }
.stat-value { font-size: 1.3rem; font-weight: 700; line-height: 1.05; color: var(--stock); font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7); }
#round-no { color: var(--gold-400); }
/* The limit is the one number the whole round is measured against. */
.stat-limit { background: linear-gradient(180deg, rgba(90, 42, 148, 0.4), rgba(45, 18, 69, 0.5)); }
.stat-limit .stat-value { font-family: var(--display); color: var(--gold-200); }
#pot-value { color: var(--gold-200); }

/* ---------------- the felt: the table, seen from above ---------------- */

/* An oval table with you at the bottom of it and the other four around the
   rail, which is how every card game anyone has played is laid out. The limit
   and the pot sit in the middle, where a dealer would put them. */
.felt {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

/* The table fills the whole felt, because every seat is on it and your cards
   have to land inside the rail rather than on a panel below it. A phone is
   portrait, so the table is the long way up — a round end nearest you, a
   round end furthest away — and the straighter middle is what gives the four
   side seats and your own hand room to sit on the cloth. */
.felt-oval {
  position: absolute;
  inset: 0;
  left: 50%;
  width: min(100%, 430px);
  transform: translateX(-50%);
  border-radius: 50% / 34%;
  background:
    radial-gradient(68% 58% at 50% 42%, rgba(173, 122, 224, 0.26), transparent 70%),
    linear-gradient(168deg, #40206a 0%, #24123a 100%);
  box-shadow:
    inset 0 0 0 2px rgba(240, 220, 164, 0.32),
    inset 0 0 0 10px rgba(45, 18, 69, 0.55),
    inset 0 0 44px -10px rgba(0, 0, 0, 0.85),
    0 18px 40px -22px rgba(0, 0, 0, 0.9);
}

/* The dealer's spot: the one number the whole round is measured against, and
   the pot it is being played for. */
.felt-centre {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  text-align: center;
  pointer-events: none;
}
.centre-label { font-family: var(--display); font-size: 0.46rem; font-weight: 700; letter-spacing: 0.26em; text-transform: uppercase; color: var(--purple-100); opacity: 0.75; }
.centre-limit {
  font-family: var(--display);
  font-size: clamp(1.6rem, 9vw, 2.5rem);
  font-weight: 700;
  line-height: 0.95;
  color: var(--gold-200);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8), 0 0 26px rgba(240, 220, 164, 0.25);
}
.centre-pot { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; background: rgba(16, 10, 24, 0.6); font-family: var(--display); font-size: 0.5rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--purple-100); }
.centre-pot b { font-size: 0.86rem; color: var(--gold-200); letter-spacing: 0; }
/* A chip, edge on. */
.centre-pot i { width: 9px; height: 9px; border-radius: 50%; background: linear-gradient(170deg, var(--gold-200), var(--gold-600)); box-shadow: 0 0 0 1px rgba(45, 18, 69, 0.8); }

/* ---------------- the four seats around it ---------------- */

.pods { position: absolute; inset: 0; }

.pod {
  position: absolute;
  width: 132px;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 6px 5px;
  border: 1px solid var(--line-soft);
  background: linear-gradient(180deg, rgba(40, 36, 33, 0.92), rgba(20, 18, 17, 0.94));
  box-shadow: var(--shadow-slab);
  transition: border-color 0.2s ease, opacity 0.3s ease, box-shadow 0.2s ease;
}
/* Clockwise from you at the bottom: left, up and over, down the right. */
.pod[data-spot="0"] { left: 17%; top: 60%; }
.pod[data-spot="1"] { left: 27%; top: 12%; }
.pod[data-spot="2"] { left: 73%; top: 12%; }
.pod[data-spot="3"] { left: 83%; top: 60%; }

.pod[data-turn="true"] { border-color: var(--gold-400); box-shadow: var(--shadow-slab), 0 0 20px -6px rgba(217, 178, 84, 0.8); }
.pod[data-folded="true"] { opacity: 0.4; }
.pod[data-out="true"] { opacity: 0.24; }
.pod[data-win="true"] { border-color: var(--green); box-shadow: var(--shadow-slab), 0 0 22px -6px rgba(92, 196, 135, 0.75); }

.pod-head { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.pod-name { display: flex; align-items: center; gap: 4px; min-width: 0; font-family: var(--display); font-size: 0.56rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--stock); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The first player of the round, §3. */
.pod-first::before { content: ''; flex: none; width: 5px; height: 5px; background: var(--gold-400); transform: rotate(45deg); }
/* The chip pill, shared with your own seat (see "your seat" below): a chip
   and a number, enclosed, so every stack on the table reads alike. */
.pod-chips, .you-chips { display: inline-flex; align-items: center; gap: 4px; flex: none; padding: 1px 6px 1px 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(16, 10, 24, 0.7); }
.pod-chips i, .you-chips i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(170deg, var(--gold-200), var(--gold-600)); box-shadow: 0 0 0 1px rgba(45, 18, 69, 0.8); }
.pod-chips b, .you-chips b { font-family: var(--display); font-size: 0.74rem; font-weight: 700; color: var(--gold-200); font-variant-numeric: tabular-nums; }
.pod-chips.is-broke b, .you-chips.is-broke b { color: var(--red); }

/* A seat that keeps hitting runs out of pod: the row wraps rather than
   spilling over the edges of the panel. */
.pod-cards { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px; width: 100%; min-height: calc(var(--card-rail) * 1.4); }
.pod-state { max-width: 100%; font-size: 0.62rem; line-height: 1.2; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pod-state[data-tone="in"] { color: var(--gold-200); }
.pod-state[data-tone="out"] { color: var(--red); }
.pod-state[data-tone="safe"] { color: var(--green); }

/* What this seat has pushed into the middle, shown as a chip on the felt side
   of the pod rather than as a number in the row. */
.pod-bet {
  position: absolute;
  left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px 1px 4px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: rgba(16, 10, 24, 0.85);
  box-shadow: 0 0 0 1px var(--line);
  font-family: var(--display);
  font-size: 0.56rem;
  font-weight: 700;
  color: var(--gold-200);
  font-variant-numeric: tabular-nums;
}
.pod-bet::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(170deg, var(--gold-200), var(--gold-600)); box-shadow: 0 0 0 1px rgba(45, 18, 69, 0.8); }
/* Every seat pushes its chips towards the middle: the top two down, the side
   two down and in, you up off the bottom edge. */
.pod[data-spot="1"] .pod-bet, .pod[data-spot="2"] .pod-bet,
.pod[data-spot="0"] .pod-bet, .pod[data-spot="3"] .pod-bet { bottom: -10px; }
.you-bet { top: -11px; }

/* ---------------- the announcement ---------------- */

/* How a round ends: a card dealt over the middle of the table that clears
   itself. The hands stay face up underneath it, which is where the showdown
   is actually read. */
.announce {
  position: absolute;
  left: 50%;
  top: 44%;
  z-index: 18;
  width: min(92%, 320px);
  padding: 11px 14px 12px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-top: 2px solid var(--gold-400);
  background: linear-gradient(180deg, rgba(48, 44, 41, 0.97), rgba(20, 18, 16, 0.98));
  box-shadow: 0 22px 50px -18px #000;
  text-align: center;
  cursor: pointer;
  animation: announce-in 0.3s var(--ease-snap) both;
}
.announce[data-going="true"] { animation: announce-out 0.3s var(--ease) both; }
@keyframes announce-in { from { transform: translate(-50%, -50%) scale(0.86); opacity: 0; } }
@keyframes announce-out { to { transform: translate(-50%, -62%) scale(0.96); opacity: 0; } }

.announce-word { font-family: var(--display); font-size: clamp(0.95rem, 6.4vw, 1.4rem); font-weight: 700; letter-spacing: 0.1em; line-height: 1.05; text-transform: uppercase; color: var(--gold-200); }
.announce[data-tone="safe"] .announce-word { color: var(--green); text-shadow: 0 0 22px rgba(92, 196, 135, 0.35); }
.announce[data-tone="dead"] .announce-word { color: var(--red); text-shadow: 0 0 22px rgba(229, 89, 74, 0.35); }
.announce-line { margin-top: 5px; font-size: 0.86rem; line-height: 1.35; color: var(--cream); }
.announce-gone { margin-top: 7px; font-size: 0.68rem; color: var(--mute); }
/* The dwell, drawn as a line that runs out. */
.announce-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--gold-400); animation: announce-bar linear both; }
@keyframes announce-bar { from { width: 100%; } to { width: 0; } }

/* ---------------- cards ---------------- */
/* MemoryPoker's card, with a number where the rank was. */

.card {
  position: relative;
  flex: none;
  width: var(--card-w);
  aspect-ratio: 5 / 7;
  padding: 0;
  border: 0;
  background: none;
  perspective: 900px;
  container-type: inline-size;
  -webkit-tap-highlight-color: transparent;
}
.card-rail { width: var(--card-rail); }
.card:not(:disabled) { cursor: pointer; }

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s var(--ease), filter 0.3s ease;
  transition-delay: calc(var(--stagger, 0) * 48ms);
}
.card[data-face="down"] .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

/* Front: white stock, a slab numeral, a hairline rule inset from the edge. */
.card-front {
  display: grid;
  place-items: center;
  background: linear-gradient(168deg, #ffffff 0%, var(--stock) 48%, #efeade 100%);
  color: var(--ink);
  border: 1px solid var(--stock-edge);
}
.card-front::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(34, 30, 27, 0.16);
  border-radius: 3px;
  pointer-events: none;
}
.card-value {
  font-family: var(--display);
  font-size: clamp(0.6rem, 34cqw, 1.5rem);
  font-weight: 700;
  line-height: 0.95;
}
/* A minus-one is the red ink on a real deck: the card that takes away. */
.card-front.is-low { color: var(--rouge); }

/* Back: purple filigree lattice inside a printed white margin. */
.card-back {
  transform: rotateY(180deg);
  display: grid;
  place-items: center;
  border: 1px solid var(--stock-edge);
  background-color: #2b1646;
  background-image:
    repeating-linear-gradient(45deg, rgba(228, 212, 245, 0.2) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(-45deg, rgba(228, 212, 245, 0.2) 0 1px, transparent 1px 6px),
    radial-gradient(70% 55% at 50% 50%, rgba(173, 122, 224, 0.32), transparent 72%),
    linear-gradient(168deg, #40206a 0%, #24123a 100%);
}
.card-back::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid var(--stock);
  border-radius: 3px;
}
.card-crest {
  position: relative;
  width: 36%;
  aspect-ratio: 1;
  transform: rotate(45deg);
  background: linear-gradient(170deg, var(--gold-200), var(--gold-600));
  box-shadow: 0 0 0 1px rgba(45, 18, 69, 0.6);
}

/* A card that was dealt in the hit phase, so the whole table watched it land. */
.card[data-hit="true"] .card-front { border-color: var(--gold-400); box-shadow: inset 0 0 0 1px rgba(217, 178, 84, 0.6); }
/* The one of your three that the table can see. */
.card[data-shown="true"] .card-face { box-shadow: var(--shadow-card), 0 0 0 2px var(--gold-400); }
.card[data-dim="true"] .card-inner { filter: brightness(0.52) saturate(0.5); }

.card:not(:disabled):hover .card-inner { transform: translateY(-4px) scale(1.04); }
.card[data-face="down"]:not(:disabled):hover .card-inner { transform: translateY(-4px) scale(1.04) rotateY(180deg); }
.card:focus-visible { outline: none; }
.card:focus-visible .card-face { box-shadow: var(--shadow-card), 0 0 0 2px var(--gold-200); }
.card[data-pick="true"] .card-inner { transform: translateY(-7px) scale(1.05); }
.card[data-pick="true"] .card-face { box-shadow: var(--shadow-card), 0 0 0 2px var(--gold-400), 0 0 24px -4px rgba(217, 178, 84, 0.75); }
/* Part of the hand that just won. */
.card[data-win="true"] .card-front::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(102deg, transparent 38%, rgba(240, 220, 164, 0.72) 50%, transparent 62%);
  animation: shimmer 2.3s var(--ease) infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* A tag under a card: SHOWN, or the card that busted a hand. */
.card-tag {
  position: absolute;
  bottom: -7px;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  padding: 0 4px;
  font-family: var(--display);
  font-size: 0.42rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #17120d;
  background: var(--gold-400);
}

/* ---------------- your seat, at the bottom edge of the felt ----------------

   You are a seat at the same table, not a separate panel underneath it: your
   cards sit on the felt like everyone else's, and your chip count sits beside
   them the way theirs sits beside theirs. Yours is the only hand drawn at
   full card size, because it is the only one you have to read. */

.seat-you {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 6;
  width: min(100%, 360px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 10px 7px;
  border: 1px solid var(--line);
  border-top: 2px solid var(--gold-400);
  background: linear-gradient(180deg, rgba(44, 39, 35, 0.95), rgba(20, 18, 17, 0.97));
  box-shadow: var(--shadow-slab);
}
.you-head { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.you-name { display: flex; align-items: center; gap: 4px; flex: none; font-family: var(--display); font-size: 0.56rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-200); }
/* Your chips sit next to your cards in the same pill as everyone else's,
   one size up because it is the stack you are playing. */
.you-chips { padding: 1px 7px 1px 5px; }
.you-chips i { width: 9px; height: 9px; }
.you-chips b { font-size: 0.86rem; }
.you-read { flex: 1 1 auto; min-width: 0; font-size: 0.78rem; text-align: right; color: var(--cream); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The only things said about your hand: whether it has gone past the limit,
   and the odds if you asked for them. Never the total — that is yours to
   count, off the cards in front of you. */
.you-note { font-family: var(--display); font-size: 0.56rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cream); }
.you-read .is-bust { color: var(--red); }
.you-read .is-safe { color: var(--green); }
.you-read .odds.is-after::before { content: ' · '; opacity: 0.6; }
/* Light enough to read on the slab; --mute is for dark grounds only. */
.you-read .odds { color: var(--cream); opacity: 0.72; }

.you-cards { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px; width: 100%; min-height: calc(var(--card-w) * 1.4); }
/* The rule between the three you were dealt and the ones you hit for. */
.you-split { flex: none; width: 1px; align-self: stretch; margin: 2px 3px; background: var(--line); }

/* ---------------- the action bar ---------------- */

.actions { display: flex; flex-direction: column; gap: 6px; min-height: 52px; }
.action-row { display: flex; gap: 6px; }
.action-row > .btn { flex: 1 1 0; min-width: 0; padding: 6px 8px; }

/* The wall behind this is a lit mid-grey, so dark grey type on it is
   unreadable. Anything the player has to read gets a dark ground of its own
   and cream type on it — the same deal as every other panel in the house. */
.action-hint,
.action-wait {
  padding: 5px 10px;
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--gold-600);
  background: rgba(22, 19, 17, 0.86);
  box-shadow: 0 6px 16px -12px rgba(0, 0, 0, 0.9);
}
.action-hint { font-size: 0.78rem; line-height: 1.3; color: var(--cream); text-align: center; }
.action-wait { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; font-family: var(--display); font-size: 0.56rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-200); }
.action-wait i { width: 6px; height: 6px; background: var(--gold-600); border-radius: 50%; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

/* The raise stepper, which only exists while you are deciding how much. */
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper .btn { flex: none; width: 46px; padding: 0; font-size: 1.1rem; letter-spacing: 0; }
.stepper-value { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 46px; border: 1px solid var(--line); background: var(--slab-deep); }
.stepper-value b { font-family: var(--display); font-size: 1.2rem; font-weight: 700; color: var(--gold-200); font-variant-numeric: tabular-nums; }
.stepper-value span { font-size: 0.62rem; color: var(--mute); }

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

/* Across the top of the felt, where it covers cloth rather than cards — and
   not the middle, which belongs to the announcement that ends a round. */
.toast {
  position: absolute;
  top: 2px;
  left: 50%;
  z-index: 15;
  max-width: 92%;
  padding: 7px 13px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold-400);
  background: linear-gradient(180deg, #302c29, #1a1816);
  box-shadow: 0 14px 28px -12px rgba(0, 0, 0, 0.95);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--stock);
  text-align: center;
  animation: toast-in 0.2s var(--ease) both;
}
.toast-good { border-left-color: var(--green); }
.toast-bad { border-left-color: var(--red); }
@keyframes toast-in { from { transform: translate(-50%, -10px); opacity: 0; } }

/* ---------------- the verdict, on the final standings ---------------- */

.verdict { padding: 9px 10px 8px; text-align: center; border: 1px solid; background: var(--slab-deep); animation: slam 0.45s var(--ease) both; }
.verdict-word { font-family: var(--display); font-size: clamp(1.05rem, 7.2vw, 1.9rem); font-weight: 700; letter-spacing: 0.1em; line-height: 1.05; }
.verdict-sub { margin-top: 5px; font-size: 0.86rem; color: var(--cream); }
.verdict-safe { border-color: var(--green); }
.verdict-safe .verdict-word { color: var(--green); text-shadow: 0 0 24px rgba(92, 196, 135, 0.35); }
.verdict-dead { border-color: var(--red); }
.verdict-dead .verdict-word { color: var(--red); text-shadow: 0 0 24px rgba(229, 89, 74, 0.35); }
.verdict-flat { border-color: var(--line); }
.verdict-flat .verdict-word { color: var(--gold-200); }
@keyframes slam { from { transform: scale(1.25); opacity: 0; } }

/* The showdown: one row per hand, in finishing order. */
.showdown { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); background: var(--slab-deep); }
.showdown li { display: grid; grid-template-columns: 74px 1fr auto; gap: 8px; align-items: center; padding: 6px 9px; }
.showdown li + li { border-top: 1px solid var(--line-soft); }
.showdown li[data-win="true"] { background: linear-gradient(168deg, #3a332b, #1f1c19); box-shadow: inset 3px 0 0 var(--gold-400); }
.sd-name { font-family: var(--display); font-size: 0.58rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--stock); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-cards { display: flex; gap: 2px; flex-wrap: wrap; }
.sd-card { display: grid; place-items: center; min-width: 17px; height: 22px; padding: 0 3px; border: 1px solid var(--stock-edge); border-radius: 2px; background: linear-gradient(168deg, #ffffff, var(--stock)); font-family: var(--display); font-size: 0.66rem; font-weight: 700; color: var(--ink); }
.sd-card.is-low { color: var(--rouge); }
.sd-card.is-hit { border-color: var(--gold-500); }
.sd-total { font-family: var(--display); font-size: 0.92rem; font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
.sd-total.is-bust { color: var(--red); }
.sd-total small { display: block; font-size: 0.5rem; letter-spacing: 0.1em; color: var(--mute); }

/* The chip ledger: what each seat walked away with. */
.ledger { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border: 1px solid var(--line); background: var(--slab-deep); }
.ledger div { padding: 6px 9px; min-width: 0; border-bottom: 1px solid var(--line-soft); }
.ledger div:nth-child(odd) { border-right: 1px solid var(--line-soft); }
.ledger dt { font-family: var(--display); font-size: 0.46rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-200); }
.ledger dd { margin: 2px 0 0; font-size: 0.92rem; font-weight: 600; color: var(--stock); font-variant-numeric: tabular-nums; }
.ledger .up { color: var(--green); }
.ledger .down { color: var(--red); }

/* ---------------- sheets: stats, rules, log ---------------- */

.sheet-overlay { place-items: center; padding: 10px; }
.sheet { display: flex; flex-direction: column; width: min(100%, 440px); max-height: min(92svh, 760px); padding: 0; animation: sheet-in 0.28s var(--ease) both; }
@keyframes sheet-in { from { transform: translateY(14px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); }
.sheet-head .modal-title { margin: 0; }
.sheet-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; overflow-y: auto; overscroll-behavior: contain; }
.stats-empty { padding: 28px 8px; text-align: center; color: var(--cream); }
.stats-note { font-size: 0.74rem; color: var(--mute); }

.section-title { margin-bottom: 5px; font-family: var(--display); font-size: 0.6rem; font-weight: 700; letter-spacing: 0.26em; text-transform: uppercase; color: var(--gold-200); }

.stats-hero { padding: 12px; border: 1px solid var(--line); border-left: 5px solid var(--gold-400); background: var(--slab-deep); }
.stats-hero-rate { font-size: 2.5rem; font-weight: 700; line-height: 1; color: var(--stock); font-variant-numeric: tabular-nums; }
.stats-hero-sub { margin-top: 4px; font-size: 0.92rem; }

.facts { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border: 1px solid var(--line); background: var(--slab-deep); }
.fact { padding: 7px 10px; min-width: 0; border-bottom: 1px solid var(--line-soft); }
.fact:nth-child(odd) { border-right: 1px solid var(--line-soft); }
.fact dt { font-family: var(--display); font-size: 0.46rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold-200); }
.fact dd { margin: 2px 0 0; font-size: 0.94rem; font-weight: 600; color: var(--stock); }

/* Where you finished, one bar per place. */
.dist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.dist li { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: center; font-size: 0.86rem; }
.dist-n { font-family: var(--display); font-size: 0.62rem; font-weight: 700; color: var(--gold-200); text-align: right; }
.dist-bar { position: relative; height: 20px; background: rgba(240, 220, 164, 0.1); }
.dist-bar i { display: block; height: 100%; min-width: 20px; background: linear-gradient(90deg, var(--green-deep), var(--green)); }
.dist-bar b { position: absolute; top: 0; left: 6px; height: 20px; display: flex; align-items: center; font-size: 0.78rem; font-weight: 700; color: var(--stock); }
.dist-first .dist-bar i { background: linear-gradient(90deg, var(--gold-600), var(--gold-200)); }
.dist-first .dist-bar b { color: #1d1608; }

/* The table log: what happened, newest last. */
.log { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); background: var(--slab-deep); font-size: 0.84rem; }
.log li { display: grid; grid-template-columns: 30px 1fr; gap: 8px; padding: 4px 9px; color: var(--cream); }
.log li + li { border-top: 1px solid var(--line-soft); }
.log-round { font-family: var(--display); font-size: 0.56rem; font-weight: 700; color: var(--gold-400); text-align: right; padding-top: 3px; }

/* ---------------- rules ---------------- */

.rules-body { display: flex; flex-direction: column; gap: 10px; font-size: 0.88rem; line-height: 1.45; color: var(--cream); }
.rules-body p { margin: 0; }
.rules-body b, .rules-body strong { color: var(--gold-200); }
.rules-body em { color: var(--stock); font-style: italic; }
.rules-head { margin: 4px 0 -2px; font-family: var(--display); font-size: 0.54rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold-200); }
.rules-note { font-size: 0.78rem; color: var(--mute); }

.rules-legend { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); background: var(--slab-deep); }
.rules-legend li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; }
.rules-legend li + li { border-top: 1px solid var(--line-soft); }
.swatch { flex: none; width: 22px; height: 22px; border: 1px solid rgba(0, 0, 0, 0.5); }
.swatch-red { background: linear-gradient(180deg, #b8463a, var(--red-deep)); }
.swatch-yellow { background: linear-gradient(180deg, var(--amber), var(--amber-deep)); }
.swatch-green { background: linear-gradient(180deg, var(--green), var(--green-deep)); }

.rules-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; border: 1px solid var(--line); background: var(--slab-deep); }
.rules-table th, .rules-table td { padding: 6px 9px; text-align: left; vertical-align: top; }
.rules-table tr + tr th, .rules-table tr + tr td { border-top: 1px solid var(--line-soft); }
.rules-table td:first-child { width: 24px; font-family: var(--display); font-weight: 700; color: var(--gold-400); }

/* The deck, laid out as cards. */
.rules-deal { display: flex; flex-direction: column; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); background: var(--slab-deep); }
.rules-deal-row { display: flex; align-items: center; gap: 10px; }
.rules-deal-label { flex: none; width: 54px; font-family: var(--display); font-size: 0.48rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-200); }
.rules-cards { display: flex; flex-wrap: wrap; gap: 4px; }
.rules-cards i { display: grid; place-items: center; width: 24px; height: 30px; border: 1px solid var(--stock-edge); border-radius: 3px; background: linear-gradient(170deg, #ffffff, var(--stock)); font-family: var(--display); font-size: 0.8rem; font-weight: 700; font-style: normal; color: var(--ink); }
.rules-cards i.is-low { color: var(--rouge); }

/* One line per bot: name, then what it does. */
.rules-bots { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); background: var(--slab-deep); }
.rules-bots li { display: grid; grid-template-columns: 76px 1fr; gap: 10px; padding: 6px 10px; align-items: baseline; }
.rules-bots li + li { border-top: 1px solid var(--line-soft); }
.rules-bots b { font-family: var(--display); font-size: 0.58rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold-200); }
.rules-bots span { font-size: 0.82rem; color: var(--cream); }

/* ---------------- footer, modals ---------------- */

.site-footer { display: flex; align-items: center; justify-content: space-between; height: 38px; font-size: 0.72rem; color: #2b2622; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.12); }
.site-footer a { color: inherit; text-underline-offset: 3px; }
.site-footer a:hover { color: var(--purple-900); }

.modal-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: end center; padding: 16px; background: rgba(12, 10, 9, 0.72); }
.modal { width: min(100%, 420px); padding: 18px; border: 1px solid rgba(240, 220, 164, 0.4); background: linear-gradient(180deg, #302c29, #1a1816); box-shadow: 0 36px 70px -20px #000; outline: none; }
.modal-title { margin: 0 0 8px; font-family: var(--display); font-size: 0.86rem; font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-200); }
.modal-body { margin: 0 0 16px; font-size: 0.92rem; color: var(--cream); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------------- short screens ---------------- */

/* The table has to fit without scrolling, and the cards are the only thing
   with any give in them. */
@media (max-height: 720px) {
  :root { --card-w: 40px; --card-rail: 22px; }
  .wordmark { font-size: 1.1rem; }
  .stat-value { font-size: 1.15rem; }
  .pod { width: 122px; }
}
@media (max-height: 640px) {
  :root { --card-w: 35px; --card-rail: 19px; }
  .pod { width: 112px; padding: 2px 5px 3px; }
  .pod-state { font-size: 0.58rem; }
  .pod[data-spot="0"], .pod[data-spot="3"] { top: 58%; }
  .felt-centre { top: 32%; }
  .btn-wide { min-height: 46px; }
}
/* Narrow phones: the pods have to come in off the rail or they hang over the
   edge of the screen. */
@media (max-width: 380px) {
  .pod { width: 112px; }
  .pod[data-spot="0"] { left: 20%; }
  .pod[data-spot="3"] { left: 80%; }
  .pod[data-spot="1"] { left: 29%; }
  .pod[data-spot="2"] { left: 71%; }
}

/* ---------------- reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .card-inner { transition-delay: 0ms !important; }
  .card[data-win="true"] .card-front::before { animation: none; }
  .verdict, .sheet, .menu-panel, .toast { animation: none; }
  .announce, .announce[data-going="true"] { animation: none; }
  .announce-bar { display: none; }
  .action-wait i { animation: none; opacity: 0.7; }
}
