:root {
  --bg: #0f2a1d;
  --felt: #17402b;
  --felt-2: #1d4d34;
  --panel: #0b2016;
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef3ee;
  --muted: #a9bcae;
  --accent: #f2b33d;
  --accent-ink: #2a1c00;
  --primary: #2f8f5b;
  --primary-2: #37a86a;
  --danger: #c0392b;
  --tile: #f6efdd;
  --tile-edge: #d9ceb3;
  --t-red: #c62828;
  --t-blue: #1a5fb4;
  --t-orange: #e07800;
  --t-black: #1c1c1c;
  --sel: #4fc3f7;
  --tw: 38px;
  --th: 52px;
  --tf: 22px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.2; }
h2 { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { display: grid; place-items: center; min-height: 60vh; text-align: center; padding: 16px; }

button, .button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
button:hover:not(:disabled), .button:hover { background: rgba(255, 255, 255, 0.14); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary, .button.primary { background: var(--primary); border-color: var(--primary-2); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--primary-2); }
button.gold { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { background: transparent; border-color: var(--danger); color: #ff8a80; }
button.ghost { background: transparent; }
button.sm { padding: 4px 10px; font-size: 13px; }
button.icon { padding: 2px 8px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }

input, select {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.chk { display: flex; align-items: center; gap: 8px; }
label.chk input { width: auto; }
.form { display: grid; gap: 12px; }
.form.row { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }

.card {
  background: var(--felt);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.gold { background: var(--accent); color: var(--accent-ink); }
.badge.s { background: #3d5afe; }
.badge.type { background: rgba(255, 255, 255, 0.12); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #666; display: inline-block; flex: none; }
.dot.on { background: #4caf50; }

/* ---------- top nav / pages ---------- */
nav.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 800; font-size: 20px; color: var(--text); letter-spacing: 0.02em; }
.brand span { color: var(--accent); }
.nav-r { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
main.page { max-width: 980px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.lobby { display: grid; gap: 16px; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
@media (max-width: 760px) { .lobby { grid-template-columns: minmax(0, 1fr); } }

.login { max-width: 360px; margin: 10vh auto; padding: 0 16px; }
.login h1 { font-size: 36px; text-align: center; }
.login h1 span { color: var(--accent); }

.glist { display: grid; gap: 10px; }
.gitem {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px; border-radius: 10px; background: var(--felt-2); border: 1px solid var(--line);
}
.gitem .meta { min-width: 0; }
.gitem .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

table.users, table.results, table.scores { width: 100%; border-collapse: collapse; }
table.users td, table.users th, table.results td, table.results th, table.scores td, table.scores th {
  padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle;
}
th { color: var(--muted); font-weight: 500; font-size: 13px; }
.table-scroll { overflow-x: auto; }

.rules-page p, .rules-page li { color: #d7e2d9; }
.rules-page li { margin: 4px 0; }

/* ---------- tiles ---------- */
.tile {
  width: var(--tw); height: var(--th);
  background: linear-gradient(180deg, #fffaf0 0%, var(--tile) 70%, var(--tile-edge) 100%);
  border-radius: 6px;
  box-shadow: 0 2px 0 #b8ad92, 0 3px 6px rgba(0, 0, 0, 0.35);
  display: inline-flex; align-items: flex-start; justify-content: center;
  padding-top: calc(var(--th) * 0.12);
  font-weight: 800; font-size: var(--tf); font-family: Georgia, "Times New Roman", serif;
  user-select: none; flex: none; position: relative;
  transition: transform 0.08s ease;
}
.tile::after {
  content: ""; position: absolute; bottom: calc(var(--th) * 0.12); left: 50%;
  width: 22%; height: 4px; transform: translateX(-50%); border-radius: 3px; background: currentColor; opacity: 0.25;
}
.tile.c-red { color: var(--t-red); }
.tile.c-blue { color: var(--t-blue); }
.tile.c-orange { color: var(--t-orange); }
.tile.c-black { color: var(--t-black); }
.tile.joker { color: var(--t-red); font-size: calc(var(--tf) * 1.05); }
.tile.joker.j1 { color: var(--t-black); }
.tile.joker::after { display: none; }
.tile.sm { --tw: 28px; --th: 38px; --tf: 16px; }
.tile.xs { --tw: 22px; --th: 30px; --tf: 13px; border-radius: 4px; }
.tile.xs::after, .tile.sm::after { height: 2px; }
.tile.big { --tw: 48px; --th: 66px; --tf: 28px; }
.tile.empty { background: rgba(255, 255, 255, 0.06); box-shadow: inset 0 0 0 1px var(--line); }
.tile.sel { transform: translateY(-8px); box-shadow: 0 0 0 3px var(--sel), 0 8px 12px rgba(0, 0, 0, 0.4); }
.tile.recent { box-shadow: 0 0 0 2px var(--accent), 0 3px 6px rgba(0, 0, 0, 0.35); }
.tile.recent.sel { box-shadow: 0 0 0 3px var(--sel), 0 8px 12px rgba(0, 0, 0, 0.4); }
.tile.new { box-shadow: 0 0 0 2px var(--sel), 0 3px 6px rgba(0, 0, 0, 0.35); }
.tile.freed { outline: 2px dashed var(--accent); outline-offset: 2px; }
.tile.bonus-tile { outline: 2px solid var(--accent); outline-offset: 2px; }
.rack .tile { cursor: pointer; }
@media (min-width: 900px) {
  :root { --tw: 44px; --th: 60px; --tf: 26px; }
}

/* ---------- game ---------- */
.game { min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(ellipse at top, var(--felt-2), var(--bg) 70%); }
.gbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.gbar .ginfo { display: grid; min-width: 0; flex: 1; }
.gbar .ginfo b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gbar .ginfo span { font-size: 13px; color: var(--muted); }
.gbar .ginfo .req { color: var(--accent); font-weight: 700; }
.gstats { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.stat b { color: var(--text); font-size: 15px; }
.stat button { margin-left: 2px; }

.players { display: flex; gap: 8px; padding: 8px 12px; overflow-x: auto; }
.pchip {
  display: flex; align-items: center; gap: 6px; flex: none;
  padding: 6px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line);
  font-size: 13px;
}
.pchip.me { border-color: rgba(79, 195, 247, 0.5); }
.pchip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pchip.active .badge { background: rgba(0, 0, 0, 0.18); color: var(--accent-ink); }
.pchip .cnt { opacity: 0.8; }
.pchip .score { font-weight: 700; }
.arrow { color: var(--muted); align-self: center; flex: none; }

.banner {
  margin: 0 12px; padding: 10px 12px; border-radius: 12px;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 4; backdrop-filter: blur(6px);
}
.banner.me { background: rgba(242, 179, 61, 0.16); border-color: var(--accent); }
.banner.endvote { background: rgba(192, 57, 43, 0.18); border-color: var(--danger); margin-bottom: 8px; }
.banner .msg { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.countdown { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }
.countdown.low { color: #ff6e6e; }

.tablearea { flex: 1; padding: 12px; display: grid; gap: 12px; align-content: start; }
.owner { display: grid; gap: 6px; }
.oname { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.sets { display: flex; flex-wrap: wrap; gap: 10px; }
.set {
  display: flex; gap: 3px; padding: 6px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.18); border: 1px solid transparent;
}
.set.target { cursor: pointer; border-color: rgba(79, 195, 247, 0.45); }
.set.target:hover { background: rgba(79, 195, 247, 0.12); }
.set.staged { border-color: var(--sel); border-style: dashed; }
.set [data-joker] { cursor: pointer; }
.empty-table { color: var(--muted); text-align: center; padding: 28px 0; border: 1px dashed var(--line); border-radius: 12px; }

/* classic Rummikub table */
.rk-table { display: flex; flex-wrap: wrap; gap: 12px; align-content: flex-start; }
.set.rk { position: relative; padding: 10px 8px 6px; background: rgba(0, 0, 0, 0.22); cursor: pointer; }
.set.rk .setinfo { position: absolute; top: 2px; right: 6px; font-size: 11px; color: var(--muted); }
.set.rk.bad { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger) inset; }
.set.rk.bad .setinfo { color: #ff8a80; }
.set.rk.staged { border-color: var(--sel); border-style: dashed; }
.set.dropnew {
  min-width: 96px; display: flex; align-items: center; justify-content: center; padding: 18px 12px;
  border: 2px dashed var(--sel); color: var(--sel); font-size: 13px; border-radius: 10px; cursor: pointer;
}
.meld { font-size: 13px; color: #ffab91; }
.meld.ok { color: #a5d6a7; }

.stage { margin: 0 12px 12px; padding: 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--sel); display: grid; gap: 8px; }
.stage-h { font-weight: 700; }
.op { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.oplbl { font-size: 13px; color: var(--muted); min-width: 90px; }
.optiles { display: flex; gap: 2px; flex-wrap: wrap; }
.reqline { font-size: 13px; color: #ffab91; }
.reqline.ok { color: #a5d6a7; }
.warn { color: var(--accent); font-size: 13px; }

.rack-wrap {
  position: sticky; bottom: 0; z-index: 3;
  background: rgba(8, 24, 16, 0.96); border-top: 1px solid var(--line);
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
}
.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar .count { font-size: 13px; color: var(--muted); margin-right: auto; }
.toolbar button { padding: 6px 10px; font-size: 13px; }
.rack {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 4px 4px; min-height: calc(var(--th) + 16px);
  background: linear-gradient(180deg, #6b4a2b, #4e3520); border-radius: 10px; box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
  padding-left: 8px; padding-right: 8px;
}
.rack.spectate { color: var(--muted); align-items: center; justify-content: center; }

/* the board: tiles sit in slots, positioned by transform so they can glide */
.rack.board { display: block; position: relative; padding: 0; min-height: 0; overflow: hidden; }
.rack.board .ledge {
  position: absolute; left: 4px; right: 4px; height: 5px; border-radius: 3px;
  background: #3a2715; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 1px 2px rgba(0, 0, 0, 0.6);
}
.rack.board .tile {
  position: absolute; left: 0; top: 0;
  transition: transform 0.18s cubic-bezier(.25, .8, .3, 1), top 0.1s ease, box-shadow 0.1s;
  touch-action: none; will-change: transform;
}
.rack.board .tile.sel { top: -7px; }
.rack.board .tile.dragging {
  transition: none; z-index: 20; cursor: grabbing;
  box-shadow: 0 0 0 2px var(--sel), 0 14px 22px rgba(0, 0, 0, 0.55);
}

/* bank piles */
.bankstrip { display: flex; align-items: flex-end; gap: 10px; padding: 0 12px 8px; overflow-x: auto; }
.bankstrip .lbl { font-size: 13px; color: var(--muted); flex: none; align-self: center; }
.bpiles { display: flex; gap: 6px; align-items: flex-end; flex: 1; }
.bpile { display: grid; justify-items: center; gap: 2px; flex: none; }
.bstack { width: 22px; height: 64px; display: flex; flex-direction: column-reverse; align-items: center; }
.bstack i {
  display: block; flex: none; width: 20px; height: 26px; border-radius: 4px;
  background: linear-gradient(135deg, #2e7d5b, #1b5e40); border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 1px 0 #0b2b1c;
}
.bstack i + i { margin-bottom: -22px; }
.bstack .bonus-top { flex: none; transform: rotate(-8deg); outline: 2px solid var(--accent); outline-offset: 1px; }
.bstack i + .bonus-top { margin-bottom: -18px; }
.bcnt { font-size: 11px; color: var(--muted); }

/* deal animation */
.deal-overlay {
  position: fixed; inset: 0; z-index: 40; overflow: auto; padding: 12px;
  background: radial-gradient(ellipse at top, #1d4d34, #0b2016 75%);
  display: flex; flex-direction: column; align-items: center;
}
.deal-head { width: min(980px, 100%); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.deal-caption { flex: 1; min-width: 200px; color: #d7e2d9; font-size: 14px; }
.deal-stage { position: relative; flex: none; }
.deal-stage .tile { position: absolute; left: 0; top: 0; will-change: transform; }
.tile.back {
  background: linear-gradient(135deg, #2e7d5b, #1b5e40); border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 0 #0b2b1c, 0 3px 6px rgba(0, 0, 0, 0.35);
}
.tile.back::after { display: none; }
.tile.back.old { background: linear-gradient(135deg, #4a7fa6, #2b5577); box-shadow: 0 2px 0 #1a3550, 0 3px 6px rgba(0, 0, 0, 0.35); }
.deal-colnum { position: absolute; text-align: center; font-size: 11px; color: var(--muted); transition: opacity 0.3s; }
.deal-stage.banked .deal-colnum { opacity: 0; }
.deal-seat { position: absolute; text-align: center; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-seat.me { color: var(--accent); font-weight: 700; }

.logbox { margin: 0 12px 12px; }
.logbox summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.logbox ol { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 2px; max-height: 220px; overflow: auto; font-size: 13px; color: #cfdcd2; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); z-index: 20;
  display: grid; place-items: center; padding: 16px; overflow: auto;
}
.modal {
  background: var(--felt); border: 1px solid var(--line); border-radius: 16px; padding: 20px;
  width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; display: grid; gap: 14px;
}
.wsets { display: flex; flex-wrap: wrap; gap: 8px; }
.results td.tiles { display: flex; flex-wrap: wrap; gap: 2px; }
.results tr.win td { color: var(--accent); font-weight: 700; }
.standings { margin: 0; padding-left: 22px; font-size: 18px; }
.vote-opts { display: grid; gap: 8px; }
.vote-opt { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line); text-align: left; white-space: normal; }
.vote-opt.mine { border-color: var(--accent); }

/* ---------- Touch ---------- */
/* every card, pile and slot on the board is the same size */
.game.touch { --tw-sm: 30px; --th-sm: 40px; gap: 8px; }
@media (min-width: 900px) { .game.touch { --tw-sm: 40px; --th-sm: 54px; } }
.game.touch .tile.sm, .game.touch .tile.back.sm {
  --tw: var(--tw-sm); --th: var(--th-sm); --tf: calc(var(--tw-sm) * 0.6);
}
.tslot {
  display: block; width: var(--tw-sm); height: var(--th-sm); border-radius: 6px;
  background: rgba(255, 255, 255, 0.05); box-shadow: inset 0 0 0 1px var(--line);
}

.tplayer { margin: 0 12px; padding: 8px 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); }
.tplayer.me { border-color: rgba(79, 195, 247, 0.4); }
.tplayer.speaking { box-shadow: 0 0 0 2px #4caf50; }
.tname { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.tpiles { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.tgroup { display: grid; justify-items: center; gap: 2px; }
.tlabel { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tleft { display: flex; gap: 6px; }
.tpile { display: grid; justify-items: center; gap: 2px; }
/* the face-up cards on a right pile, fanned so every colour and number stays readable */
.tstack { display: flex; align-items: flex-start; }
.tstack > * + * { margin-left: calc(var(--tw-sm) * -0.35); }
.tstack.tight > * + * { margin-left: calc(var(--tw-sm) * -0.6); }
.tpile.next .tile.back { box-shadow: 0 0 0 2px var(--accent), 0 3px 6px rgba(0, 0, 0, 0.35); }
.tpile.clickable, .tleft.clickable, .tspace, .tfound { cursor: pointer; }
.tcount { font-size: 11px; color: var(--muted); }

/* the board: four columns, the two in the middle are the discard */
.tboard {
  display: grid; grid-template-columns: 1fr auto auto 1fr; gap: 10px 16px;
  align-items: center; padding: 10px 12px; margin: 0 auto; width: 100%;
  max-width: 820px; overflow-x: auto; /* tall stacks scroll rather than squash out of sight */
}
.tcell { position: relative; width: var(--tw-sm); height: var(--th-sm); border-radius: 8px; }
.tspace { background: rgba(0, 0, 0, 0.25); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.tspace.left { justify-self: end; }
.tspace.right { justify-self: start; }
.tspace-card { position: absolute; top: 0; }
/* the edge that stays visible in a stack carries the card's colour */
.tile.edge-right { box-shadow: inset -5px 0 0 currentColor, 0 2px 0 #b8ad92, 0 3px 6px rgba(0, 0, 0, 0.35); }
.tile.edge-left { box-shadow: inset 5px 0 0 currentColor, 0 2px 0 #b8ad92, 0 3px 6px rgba(0, 0, 0, 0.35); }
/* the discard keeps a gold ring even when a card is sitting on it */
.tfound {
  display: grid; place-items: center; background: rgba(242, 179, 61, 0.1);
  outline: 2px solid rgba(242, 179, 61, 0.55); outline-offset: 2px;
}
.tfound.done { background: rgba(47, 143, 91, 0.2); outline-color: var(--primary-2); }
/* a discard pile is one colour for the whole game – a row of the board each */
.tfound[class*="fc"] { position: relative; background: none; outline-color: var(--fc); }
.tfound.fc0 { --fc: #e04a4a; }
.tfound.fc1 { --fc: #5b8ff0; }
.tfound.fc2 { --fc: #f0a13a; }
.tfound.fc3 { --fc: #d8d8d8; }
.tfound[class*="fc"]::before {
  content: ''; position: absolute; inset: 0; border-radius: 8px;
  background: var(--fc); opacity: 0.16;
}
.tfound[class*="fc"].done::before { opacity: 0.32; }
.tfound > * { position: relative; z-index: 1; }

/* a called touch: the announcement and the working */
.touch-call {
  position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.6); animation: touch-in 0.25s ease;
}
.banner.demo { background: rgba(192, 57, 43, 0.14); border-color: var(--danger); }
/* the result of a touch: beside the board, never over it, and it can be folded away */
.touch-panel {
  position: fixed; right: 12px; top: 76px; z-index: 60;
  width: min(360px, calc(100vw - 32px)); max-height: 72vh; overflow: auto;
  background: var(--panel); border: 2px solid var(--danger); border-radius: 12px;
  padding: 10px 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.touch-panel.failed { border-color: var(--primary-2); }
.touch-panel.mini .touch-body { display: none; }
.touch-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.touch-panel .touch-word { font-size: 22px; font-weight: 800; color: var(--danger); letter-spacing: 1px; }
.touch-panel.failed .touch-word { color: #a5d6a7; }
.touch-panel h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.touch-steps { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.touch-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.touch-list li {
  display: flex; align-items: center; gap: 6px; padding: 3px 6px;
  border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.touch-list li:hover { background: rgba(255, 255, 255, 0.05); }
.touch-list li.on { background: rgba(192, 57, 43, 0.22); border-color: var(--danger); }
/* the two ends of the move being looked at */
.tflash-from { box-shadow: 0 0 0 3px var(--accent), 0 0 12px rgba(255, 200, 80, 0.6) !important; border-radius: 8px; }
.tflash-to { box-shadow: 0 0 0 3px var(--danger), 0 0 12px rgba(192, 57, 43, 0.6) !important; border-radius: 8px; }
/* while a touch is shown, the row whose cards are being played */
.tplayer.acting { box-shadow: inset 0 0 0 2px var(--danger); }
.tcounter { font-weight: 800; margin-left: 6px; padding: 1px 7px; border-radius: 999px; }
.tcounter.good { background: rgba(76, 175, 80, 0.25); color: #a5d6a7; }
.tcounter.bad { background: rgba(192, 57, 43, 0.25); color: #ff8a80; }
.touch-card.failed { border-color: var(--primary-2); }
.touch-card.failed .touch-word { color: #a5d6a7; font-size: 34px; }
.touch-card {
  background: var(--felt); border: 2px solid var(--danger); border-radius: 16px; padding: 20px;
  width: min(560px, 100%); display: grid; gap: 12px; justify-items: center; text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}
.touch-word {
  font-size: 44px; font-weight: 900; letter-spacing: 0.08em; color: #ff8a80;
  animation: touch-pop 0.45s cubic-bezier(.2, 1.4, .4, 1);
}
.touch-proof { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; text-align: left; }
.touch-proof h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.touch-proof ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.touch-proof li { display: flex; align-items: center; gap: 6px; font-size: 13px; }
@keyframes touch-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes touch-pop { 0% { transform: scale(0.3) rotate(-8deg); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* chat & voice */
#chat { position: fixed; right: 12px; bottom: 12px; z-index: 30; width: min(340px, calc(100vw - 24px)); }
.chat-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; height: min(460px, 60vh);
}
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-head .muted { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list { list-style: none; margin: 0; padding: 10px 12px; flex: 1; overflow-y: auto; display: grid; gap: 8px; align-content: start; }
.chat-list li { background: rgba(255, 255, 255, 0.07); border-radius: 10px; padding: 6px 10px; max-width: 85%; justify-self: start; }
.chat-list li.mine { justify-self: end; background: rgba(47, 143, 91, 0.4); }
.chat-list li.hint { background: none; color: var(--muted); font-size: 13px; }
.chat-list .who { font-weight: 700; font-size: 12px; margin-right: 6px; }
.chat-list .when { font-size: 11px; color: var(--muted); }
.chat-list .txt { overflow-wrap: anywhere; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.chat-note { padding: 10px; margin: 0; }
.comms { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.unread { background: #e53935; color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; font-weight: 700; }
button.on { border-color: var(--primary-2); background: rgba(47, 143, 91, 0.25); }
.vicon { font-size: 12px; margin-left: 2px; }
.pchip.speaking, .plist li.speaking { box-shadow: 0 0 0 2px #4caf50, 0 0 10px rgba(76, 175, 80, 0.6); }
.plist li { border-radius: 8px; padding: 0 4px; }
@media (min-width: 1000px) {
  body.chat-open .game { margin-right: 356px; }
  body.chat-open #chat { top: 12px; bottom: 12px; width: 332px; }
  body.chat-open .chat-panel { height: 100%; }
}
@media (max-width: 600px) {
  #chat { left: 8px; right: 8px; bottom: 8px; width: auto; }
  .chat-panel { height: 55vh; }
}

#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 50; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { background: #263238; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); }
.toast.error { background: #8e2323; }
.toast.ok { background: #1f6b43; }

.wait ul.plist { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.wait ul.plist li { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.wait .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-btns { display: flex; gap: 4px; flex: none; }
.icon-space { display: inline-block; width: 34px; }
.lvl-select { width: auto; padding: 4px 8px; font-size: 13px; flex: none; }
.addbot { display: inline-flex; gap: 6px; align-items: center; }
.badge.lvl { margin-left: 4px; text-transform: none; letter-spacing: 0; }
.badge.lvl-easy { background: #2e7d32; }
.badge.lvl-medium { background: #b26a00; }
.badge.lvl-hard { background: #b71c1c; }

@media (max-width: 600px) {
  .gstats { gap: 10px; width: 100%; justify-content: space-between; }
  .oplbl { min-width: 0; }
}

/* ---------- Ligent */
.lg-centre { justify-items: center; }
.lg-claim {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px;
  padding: 10px 16px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line);
}
.lg-claim.fresh { animation: lg-in 0.45s cubic-bezier(.25, .8, .3, 1); }
@keyframes lg-in { from { transform: translateY(40px) scale(0.9); opacity: 0.2; } to { transform: none; opacity: 1; } }
.lg-says { font-size: 15px; }
.lg-stack { position: relative; display: inline-grid; place-items: center; }
.lg-stack b { position: absolute; font-size: 18px; color: #fff; text-shadow: 0 1px 3px #000; }
.lg-say { padding: 4px 12px 8px; display: grid; justify-items: center; gap: 4px; }
.lg-grid { display: grid; gap: 4px; max-width: 100%; overflow-x: auto; padding: 10px 4px 4px; }
.lg-row { display: flex; gap: 3px; }
.lg-row .tile { flex: none; cursor: pointer; }
.tile.off { opacity: 0.22; cursor: default; }
/* the result of a challenge, and the centre you took: beside the game, never over it */
.lg-panel {
  position: fixed; right: 12px; top: 176px; z-index: 60; display: grid; gap: 8px;
  width: min(340px, calc(100vw - 32px)); max-height: 72vh; overflow: auto;
  background: var(--panel); border: 2px solid var(--primary-2); border-radius: 12px;
  padding: 10px 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.lg-panel p { margin: 0; }
.lg-panel.lie { border-color: var(--danger); }
.lg-word { font-size: 22px; font-weight: 800; letter-spacing: 1px; color: #a5d6a7; }
.lg-panel.lie .lg-word { color: var(--danger); }
.lg-vs { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.lg-vs span { display: inline-flex; align-items: center; gap: 6px; }
/* all thirteen fit across a phone */
@media (max-width: 560px) {
  .lg-row { gap: 2px; }
  .lg-row .tile.sm { --tw: 23px; --th: 32px; --tf: 14px; }
}
