:root {
  --bg: #12141c; --panel: #1c1f2b; --line: #2c3042; --text: #eceaf2; --muted: #8f93a8;
  --a: #f0a53c; --a-dim: #5a4220; --b: #9277f2; --b-dim: #3a3166; --n: #b9b3a3; --n-dim: #4a483f; --x: #e5484d;
  --card: #262a3a; --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
button.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
button.quiet { color: var(--muted); }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; margin-top: 14px; }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; min-width: 0; }
.error { color: var(--x); min-height: 1.4em; margin: 4px 0 0; }
.muted { color: var(--muted); }

.brand { font-size: 44px; font-weight: 800; letter-spacing: -1.5px; margin: 0; color: var(--a); }
.brand span { color: var(--b); }
.brand.small { font-size: 22px; letter-spacing: -0.5px; }
.gate { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.sub { color: var(--muted); max-width: 380px; margin: 8px 0 24px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.panel label { font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; text-transform: uppercase; letter-spacing: 3px; }
.or { text-align: center; color: var(--muted); font-size: 13px; margin-top: 6px; }

header { display: flex; align-items: center; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
#status { flex: 1; text-align: center; font-size: 19px; font-weight: 700; }
#status.a { color: var(--a); } #status.b { color: var(--b); }
.tools { display: flex; gap: 8px; }
.tools button { padding: 6px 10px; font-size: 13px; }
#toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: #fff; color: #111; padding: 10px 16px; border-radius: 8px; z-index: 5; max-width: 90vw; box-shadow: 0 6px 24px #0008; }

.table { display: grid; grid-template-columns: 220px minmax(0, 1fr) 240px; gap: 18px; padding: 18px; max-width: 1400px; margin: 0 auto; }
.team { background: var(--panel); border: 1px solid var(--line); border-top: 4px solid; border-radius: var(--radius); padding: 14px; align-self: start; }
.team.a { border-top-color: var(--a); } .team.b { border-top-color: var(--b); }
.team.turn.a { box-shadow: 0 0 0 2px var(--a); } .team.turn.b { box-shadow: 0 0 0 2px var(--b); }
.score { display: flex; justify-content: space-between; align-items: baseline; }
.score .name { font-weight: 800; font-size: 18px; }
.a .score .name, .a .score .left { color: var(--a); } .b .score .name, .b .score .left { color: var(--b); }
.score .left { font-size: 34px; font-weight: 800; line-height: 1; }
.team h3, .log h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 14px 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 8px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 13px; }
.chip.me { border-color: var(--text); font-weight: 700; }
.chip.off { opacity: .45; font-style: italic; }
.chip.moving { background: var(--text); color: var(--bg); }
.seat { display: block; width: 100%; margin-top: 8px; font-size: 13px; border-style: dashed; color: var(--muted); }
.seat.inline { display: inline-block; width: auto; margin: 0; padding: 3px 10px; }
.seat.danger { color: var(--x); }
.right { display: flex; flex-direction: column; gap: 18px; }
.right .team { align-self: stretch; }

.board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.board.empty { display: flex; align-items: center; justify-content: center; min-height: 320px; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); padding: 30px; text-align: center; }
.card { aspect-ratio: 8 / 5; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius); padding: 4px; font-weight: 800; font-size: clamp(11px, 1.45vw, 20px); letter-spacing: .5px; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: default; color: var(--text); }
.card:disabled { opacity: 1; }
.card.long { font-size: clamp(9px, 1.1vw, 15px); }
.card span { overflow-wrap: anywhere; }
.board.guessing .card:not(.shown) { cursor: pointer; }
.board.guessing .card:not(.shown):hover { transform: translateY(-2px); border-color: var(--text); }
/* Key colours as the cluegiver sees them (unrevealed): an inset edge plus tinted text. */
.card.k-a:not(.shown) { background: var(--a-dim); border-color: var(--a); }
.card.k-b:not(.shown) { background: var(--b-dim); border-color: var(--b); }
.card.k-n:not(.shown) { background: var(--n-dim); border-color: #6b6858; }
.card.k-x:not(.shown) { background: #000; border-color: var(--x); color: var(--x); }
/* Revealed cards: solid colour, word struck through. */
.card.shown { color: #14161f; text-decoration: line-through; text-decoration-thickness: 2px; }
.card.shown.k-a { background: var(--a); border-color: var(--a); }
.card.shown.k-b { background: var(--b); border-color: var(--b); }
.card.shown.k-n { background: var(--n); border-color: var(--n); opacity: .55; }
.card.shown.k-x { background: var(--x); border-color: var(--x); color: #fff; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 16px; min-height: 44px; }
.clue { display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 8px; border: 2px solid; font-size: 20px; }
.clue.a { border-color: var(--a); color: var(--a); } .clue.b { border-color: var(--b); color: var(--b); }
.clue i { font-style: normal; font-weight: 800; background: currentColor; border-radius: 6px; padding: 0 8px; }
.clue.a i, .clue.b i { -webkit-text-fill-color: var(--bg); }
.clue small { font-size: 12px; color: var(--muted); }
.clue-form { display: flex; gap: 8px; }
.clue-form input { width: 200px; text-transform: uppercase; }
.bench { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin-top: 14px; font-size: 13px; }
.bench .label { color: var(--muted); }

.log { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 14px 12px; }
#log { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.l-clue { display: flex; gap: 8px; align-items: center; margin-top: 6px; padding: 4px 8px; border-radius: 6px; }
.l-clue.a { background: var(--a-dim); } .l-clue.b { background: var(--b-dim); }
.l-clue b { flex: 1; text-align: right; }
.l-clue i { font-style: normal; font-weight: 800; }
.l-guess { padding-left: 10px; }
.l-guess .a { color: var(--a); } .l-guess .b { color: var(--b); }
.l-guess b.k-a { color: var(--a); } .l-guess b.k-b { color: var(--b); } .l-guess b.k-n { color: var(--n); } .l-guess b.k-x { color: var(--x); }
.l-pass { padding-left: 10px; color: var(--muted); }
.l-end { font-weight: 800; margin-top: 6px; } .l-end.a { color: var(--a); } .l-end.b { color: var(--b); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; max-width: 480px; padding: 24px; }
dialog::backdrop { background: #000a; }
dialog h2 { margin-top: 0; }

@media (max-width: 900px) {
  .table { grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px; }
  .middle { grid-column: 1 / -1; grid-row: 1; }
  .right { display: contents; }
  .log { grid-column: 1 / -1; }
  header { flex-wrap: wrap; gap: 8px; }
  #status { order: 3; flex-basis: 100%; font-size: 16px; }
  .board { gap: 6px; }
  .card { font-size: clamp(8px, 2.3vw, 16px); letter-spacing: 0; border-width: 1.5px; padding: 2px; border-radius: 7px; aspect-ratio: 4 / 3; }
  .card.long { font-size: clamp(6px, 1.7vw, 13px); }
}
