:root {
  --bg: #1d1520;
  --panel: #2b1d2e;
  --panel-2: #38263b;
  --ink: #f3e6d3;
  --muted: #b9a7a0;
  --accent: #e0526e;
  --accent-ink: #fff;
  --paper: #f6ecd9;
  --paper-ink: #2b1d2e;
  --gold: #e6b84a;
  --safe: #6cc48a;
  --danger: #ff7b7b;
  --line: rgba(255,255,255,.12);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 900px; margin: 0 auto; padding: 8px 10px 40px; }
a { color: var(--gold); }
h1 { font-size: 1.15rem; margin: 0; letter-spacing: .02em; }
h2 { margin: 0 0 8px; font-size: 1.3rem; }
button { font: inherit; cursor: pointer; }
kbd { display: inline-block; padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; font-size: .8em; background: var(--panel-2); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hints { color: var(--muted); font-size: .8rem; text-align: center; margin-top: 6px; }
.error { color: var(--danger); }

.top { display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line); }
.top-right { display: flex; gap: 12px; align-items: center; }
.chip { background: var(--panel-2); padding: 2px 10px; border-radius: 999px; font-weight: 600;
  letter-spacing: .12em; }
.link { background: none; border: none; color: var(--gold); padding: 0; text-decoration: underline; }

.card-panel { background: var(--panel); border-radius: 14px; padding: 18px; margin: 14px auto; max-width: 520px; }
.lede { color: var(--muted); margin: 0 0 14px; }
.field { display: block; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
.field input, .code-input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; }
.code-input { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; }
.row { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.row > input { flex: 1; }
.or { text-align: center; color: var(--muted); margin: 14px 0 6px; font-size: .9rem; }
button.primary { background: var(--accent); color: var(--accent-ink); border: none; padding: 10px 18px;
  border-radius: 10px; font-weight: 600; }
button.big { padding: 14px 22px; font-size: 1.05rem; flex: 1; }
button:not(.primary):not(.link):not(.gval) { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; }
.code-display { font-size: 2.4rem; font-weight: 800; letter-spacing: .4em; text-align: center; margin: 6px 0 0; }
.room-link { text-align: center; color: var(--muted); font-size: .8rem; word-break: break-all; }
.roster { list-style: none; padding: 0; margin: 14px 0; }
.roster li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--line); }
.roster li.me .name { color: var(--gold); }
.roster .name { flex: 1; font-weight: 600; }
.roster .host, .roster .tag { font-size: .75rem; color: var(--muted); border: 1px solid var(--line); padding: 0 6px; border-radius: 999px; }
.roster .drop { background: none; border: none; color: var(--muted); font-size: 1.1rem; }
.botbar { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }

/* --- the table ---------------------------------------------------------- */
/* Fixed rows and columns: nothing on the table may change size when a card
 * is played, or the whole board shifts under the animations. */
.table { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); grid-template-rows: 150px 200px 96px;
  grid-template-areas: ". n ." "w c e" ". s ."; gap: 8px; margin-top: 8px; }
.table > * { min-height: 0; overflow: hidden; }
.seat-n { grid-area: n; } .seat-w { grid-area: w; } .seat-e { grid-area: e; } .seat-s { grid-area: s; }
.centre { grid-area: c; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 8px; border-radius: 14px;
  background: radial-gradient(ellipse at center, #4a2f46 0%, #34223a 70%, transparent 100%); }
.round-label { font-size: .8rem; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }
.piles { display: flex; gap: 14px; align-items: flex-end; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .75rem; color: var(--muted); }
.minis { display: flex; gap: 3px; }

.seat { background: var(--panel); border-radius: 12px; padding: 8px; position: relative;
  border: 2px solid transparent; transition: border-color .15s, box-shadow .15s; }
.seat .who { display: flex; gap: 6px; align-items: center; font-weight: 600; flex-wrap: wrap; }
.seat .tokens { color: var(--accent); letter-spacing: .05em; font-size: .85rem; }
.seat .badge { font-size: .7rem; padding: 0 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.seat .badge.safe { color: var(--safe); border-color: var(--safe); }
.seat .badge.out { color: var(--danger); border-color: var(--danger); }
.seat .badge.turn { color: var(--gold); border-color: var(--gold); }
.seat .badge.bot { font-style: italic; }
/* Fixed height: when a player is knocked out the hand slot stays where it
 * was, empty, and the pile below does not move up into it. */
.seat .cards { display: flex; gap: 6px; margin-top: 6px; align-items: flex-end; flex-wrap: wrap; min-height: 56px; }
.seat .discards { display: flex; gap: 3px; margin-top: 6px; flex-wrap: wrap; }
.seat .known { font-size: .75rem; color: var(--gold); margin-top: 4px; }
.seat.turn { border-color: var(--gold); }
.seat.out { opacity: .55; }
.seat.away .who { opacity: .6; }
.seat .arrow { position: absolute; top: 6px; right: 8px; display: none; }
.seat.targetable { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224,82,110,.25); cursor: pointer; }
.seat.targetable .arrow { display: inline-block; }
.seat.not-target { opacity: .45; }
.seat.me .who .name { color: var(--gold); }

/* --- cards -------------------------------------------------------------- */
.card { background: var(--paper); color: var(--paper-ink); border-radius: 8px; width: 104px; height: 138px;
  padding: 8px; display: flex; flex-direction: column; box-shadow: 0 2px 6px rgba(0,0,0,.4);
  border: 2px solid transparent; position: relative; }
.card .val { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.card .nm { font-weight: 700; font-size: .95rem; margin-top: 2px; }
.card .fx { font-size: .68rem; color: #5b4a55; margin-top: 6px; line-height: 1.25; }
.card.mini { width: 28px; height: 40px; padding: 2px 0; align-items: center; justify-content: center; border-radius: 4px; gap: 1px; }
.card.mini .val { font-size: .95rem; }
.card.mini .card-ico { position: static; width: 13px; height: 13px; color: #8b5a6b; }
.card.small { width: 40px; height: 56px; padding: 4px; border-radius: 5px; }
.card.small .val { font-size: 1.15rem; } .card.small .nm { font-size: .55rem; }
.card.back { background: repeating-linear-gradient(45deg, #7a3550 0 6px, #66283f 6px 12px); border-color: #b0324a; }
.card.back.burned { opacity: .6; }
.card.dim { opacity: .35; filter: grayscale(.6); }
.card.chosen { border-color: var(--gold); transform: translateY(-4px); }
.hand .card { cursor: pointer; }
.hand .card.dim { cursor: not-allowed; }
.card .hint { position: absolute; bottom: 6px; right: 8px; font-size: .75rem; color: #7d6a76; }

.card.fly { position: fixed; top: 0; left: 0; z-index: 20; pointer-events: none; will-change: transform;
  transform: translate(-1000px, -1000px);   /* off screen until its animation places it */
  box-shadow: 0 12px 30px rgba(0,0,0,.6); border-color: var(--gold); transform-origin: center; }
.xmark { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.xmark i { position: absolute; left: -12%; right: -12%; top: 50%; height: 9px; margin-top: -4px; background: #d8202f;
  border-radius: 4px; box-shadow: 0 0 6px rgba(0,0,0,.4); transform-origin: center; animation: stroke .28s ease-out forwards; }
.xmark i.a { transform: rotate(45deg); }
.xmark i.b { transform: rotate(-45deg); animation-delay: .22s; }
.card.exposed { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224,82,110,.35), 0 2px 6px rgba(0,0,0,.4); }
@keyframes stroke { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.fly-cap { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 8px;
  white-space: nowrap; color: var(--ink); font-weight: 600; font-size: .8rem;
  background: rgba(29,21,32,.85); padding: 2px 10px; border-radius: 999px; }
.hand-area { margin-top: 8px; text-align: center; min-height: 330px; }
.hand { min-height: 190px; }
.prompt { font-weight: 600; min-height: 1.5em; margin-bottom: 6px; }
.hand { display: flex; gap: 22px; justify-content: center; padding-bottom: 52px; }
.guess { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.gval { background: var(--panel-2); color: var(--ink); border: 2px solid var(--line); padding: 6px 10px;
  border-radius: 8px; font-weight: 600; min-width: 58px; font-size: .85rem; }
.gval b { display: block; font-size: 1.1rem; }
.gval.sel { border-color: var(--gold); background: #4a3448; }
.card .tags { position: absolute; top: 100%; left: -6px; right: -6px; margin-top: 6px; display: flex; flex-direction: column; gap: 3px; align-items: center; }
.card .tags span { font-size: .68rem; font-weight: 600; line-height: 1.2; padding: 1px 8px; border-radius: 999px; }
.card .tag-fizzle { color: #ffb4a8; background: rgba(163,66,58,.35); border: 1px solid #a3423a; }
.card .tag-seen { color: #ffc2cf; background: rgba(224,82,110,.25); border: 1px solid var(--accent); }
.card.fizzles { border-color: #a3423a; border-style: dashed; }
.last-event { display: none; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.last-event div:first-child { color: var(--ink); }
.notes { list-style: none; padding: 0; margin: 10px 0 0; color: var(--gold); font-size: .85rem; }
.log { list-style: none; padding: 0; margin: 4px 0 0; font-size: .78rem; color: var(--muted); max-width: 100%; max-height: 92px; overflow: hidden; }
.log li { padding: 1px 0; } .log li:first-child { color: var(--ink); }

/* --- overlay ------------------------------------------------------------ */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center;
  justify-content: center; padding: 12px; z-index: 5; }
.overlay-inner { width: 100%; max-width: 460px; }
.reveal, .standings { list-style: none; padding: 0; margin: 8px 0 12px; }
.reveal li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.reveal li.win { color: var(--gold); font-weight: 700; }
.reveal .name { flex: 1; }
.standings li { display: flex; justify-content: space-between; padding: 4px 0; }
.standings .tokens { color: var(--accent); }
.cardlist li { margin-bottom: 8px; }

@media (max-width: 600px) {
  .card { width: 96px; height: 134px; }
  .table { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: 118px 150px 76px; gap: 5px; }
  .seat { padding: 6px; }
  .hand-area { min-height: 270px; }
  .hand { min-height: 186px; }
  .log { display: none; }
  .last-event { display: block; }
}

/* --- options, tracker, language ------------------------------------------ */
.option { display: flex; gap: 8px; align-items: center; font-size: .9rem; color: var(--muted); margin: 6px 0 10px; cursor: pointer; }
.option input { width: 18px; height: 18px; }
.table.with-tracker { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr) 215px; grid-template-areas: ". n . k" "w c e k" ". s . k"; }
.tracker { grid-area: k; background: var(--panel); border-radius: 12px; padding: 8px 10px; align-self: start; }
.tracker-head { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.tracker ol { list-style: none; padding: 0; margin: 0; }
.tracker li { display: grid; grid-template-columns: 1.2em minmax(0, 1fr) auto auto; gap: 6px; align-items: center; font-size: .82rem; padding: 2px 0; white-space: nowrap; }
.tracker .tn { overflow: hidden; text-overflow: ellipsis; }
.tracker .td { flex-shrink: 0; }
.tracker li.gone { opacity: .35; }
.tracker .tv { font-weight: 800; color: var(--gold); }
.tracker .td i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--line); margin-right: 2px; }
.tracker .td i.on { background: var(--accent); }
.tracker .tc { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .table.with-tracker { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: 118px 150px 76px auto; grid-template-areas: ". n ." "w c e" ". s ." "k k k"; }
  .tracker { min-width: 0; }
  .tracker ol { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
  .tracker .td { display: none; }
}
.duel-cap { position: fixed; z-index: 21; transform: translateX(-50%); white-space: nowrap; color: var(--ink);
  font-weight: 600; font-size: .85rem; background: rgba(29,21,32,.85); padding: 3px 12px; border-radius: 999px; pointer-events: none; }
.gval.gone { text-decoration: line-through; opacity: .45; }
.gval.gone.sel { opacity: .8; }
.ico { width: 1em; height: 1em; vertical-align: -0.15em; }
.card .card-ico { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; color: #8b5a6b; }
.card.small .card-ico { top: 4px; right: 4px; width: 14px; height: 14px; }
.card.fly .card-ico { width: 30px; height: 30px; }
.tracker .tn .ico { color: var(--muted); margin-right: 2px; }
.gval .ico { width: 1.1em; height: 1.1em; display: block; margin: 2px auto 0; color: var(--gold); }
.preview { position: fixed; z-index: 30; pointer-events: none; padding: 8px; background: var(--panel); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6); }
.gval .gleft { display: block; font-size: .7rem; color: var(--muted); font-weight: 500; }
.call { position: fixed; z-index: 22; pointer-events: none; display: flex; align-items: center; gap: 12px;
  padding: 10px 18px; border-radius: 14px; background: rgba(29,21,32,.92); border: 2px solid var(--line);
  box-shadow: 0 12px 30px rgba(0,0,0,.6); color: var(--ink); font-weight: 700; }
.call-arrow { font-size: 2rem; color: var(--gold); }
.call-who { font-size: 1rem; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-mark { font-size: 2.4rem; line-height: 1; }
.call.hit { border-color: #d8202f; } .call.hit .call-mark { color: #ff5c5c; }
.call.miss .call-mark { color: var(--safe); }
.card.mini.dead { overflow: visible; }
.card.mini.dead .xmark i { height: 3px; margin-top: -1.5px; left: -8%; right: -8%; animation: none; clip-path: none; box-shadow: none; }
