/* Suit symbols come from a proper symbol font: some interface fonts draw a tiny
   spade or club that looks like a diamond. Only the four suit characters use it. */
@font-face {
  font-family: "Card Suits";
  src: local("Segoe UI Symbol"), local("Apple Symbols"), local("Arial Unicode MS"), local("DejaVu Sans"), local("Arial");
  unicode-range: U+2660-2667;
}

:root {
  --felt: #145a3c;
  --felt-dark: #0e4430;
  --felt-light: #1b6e4b;
  --ink: #f4f1e8;
  --muted: #b9cfc3;
  --gold: #f2c14e;
  --red: #c0392b;
  --card: #fbf8f1;
  --card-ink: #1d2330;
  --back-1: #8e2c2c;
  --back-2: #6d1f1f;
  --panel: rgba(0, 0, 0, 0.22);
  --panel-strong: rgba(0, 0, 0, 0.35);
  --card-w: 64px;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Card Suits", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 30%, var(--felt-light), var(--felt) 55%, var(--felt-dark));
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
}
.brand { color: var(--ink); text-decoration: none; font-family: Georgia, serif; font-size: 22px; font-weight: bold; margin-right: auto; }
.brand-mark { color: var(--gold); }
.room-badge { font-size: 14px; color: var(--muted); }
.room-badge b { color: var(--ink); letter-spacing: 2px; }

/* ---------- buttons ---------- */
button { cursor: pointer; border-radius: 999px; border: 0; padding: 10px 18px; font-weight: 600; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--gold); color: #2a1f00; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.secondary { background: rgba(255,255,255,.14); color: var(--ink); }
.secondary:hover:not(:disabled) { background: rgba(255,255,255,.22); }
.danger { background: var(--red); color: #fff; }
.ghost { background: transparent; color: var(--ink); border: 1px solid rgba(255,255,255,.3); }
.small { padding: 6px 12px; font-size: 14px; }
.active-mode { outline: 3px solid var(--gold); }

/* ---------- home ---------- */
.home { max-width: 440px; margin: 40px auto; padding: 0 16px; }
.hero { text-align: center; margin-bottom: 24px; }
.hero h1 { font-family: Georgia, serif; font-size: 44px; margin: 8px 0 4px; }
.hero p { color: var(--muted); margin: 0; }
.hero-cards { display: flex; justify-content: center; gap: 6px; }
.hero-cards .card { --card-w: 52px; transform: rotate(var(--r)); }
.box { background: var(--panel); border-radius: 16px; padding: 20px; display: grid; gap: 14px; }
.box label { font-size: 14px; color: var(--muted); display: grid; gap: 6px; }
.box input {
  padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.25); color: var(--ink); width: 100%;
}
.box input:focus { outline: 2px solid var(--gold); }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: 3px; }
.divider { text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- lobby ---------- */
.lobby { max-width: 520px; margin: 32px auto; padding: 0 16px; display: grid; gap: 16px; }
.code-box { text-align: center; }
.code-box .code { font-family: ui-monospace, Menlo, monospace; font-size: 48px; letter-spacing: 8px; color: var(--gold); margin: 4px 0; }
.code-box .hint { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.share-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.option-row { display: flex; align-items: center; gap: 8px; justify-content: center; }
.option-row .small { min-width: 48px; }
.option-row select { padding: 6px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.25); color: var(--ink); font-weight: 600; }
.player-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.player-list li { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.18); padding: 10px 12px; border-radius: 10px; }
.player-list .meta { margin-left: auto; color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #4cd187; flex: none; }
.dot.off { background: #777; }
.tag { font-size: 11px; background: var(--gold); color: #2a1f00; border-radius: 999px; padding: 2px 8px; font-weight: 700; }
.center { text-align: center; }
.muted { color: var(--muted); }

/* ---------- table ---------- */
.table { display: grid; grid-template-columns: 1fr 260px; gap: 16px; padding: 16px; max-width: 1320px; margin: 0 auto; }
.play-area { display: grid; gap: 14px; align-content: start; }
.opponents { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.seat { background: var(--panel); border-radius: 14px; padding: 10px 12px 12px; border: 2px solid transparent; transition: border-color .2s; }
.seat.turn { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(242,193,78,.18); }
.seat.away { opacity: .55; }
.seat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 600; font-size: 15px; }
.seat-head .tag { margin-left: auto; }
.hand { display: grid; grid-template-columns: repeat(2, var(--card-w)); gap: 8px; justify-content: center; }
.hand.wide { grid-template-columns: repeat(3, var(--card-w)); }
.me .hand { --card-w: 68px; }
.opponents .hand { --card-w: 48px; }
.mine { display: flex; justify-content: center; }
.mine .seat { min-width: 260px; }

.center-row { display: flex; align-items: center; justify-content: center; gap: 22px; flex-wrap: wrap; }
.pile { display: grid; justify-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.pile .card { --card-w: 68px; }
.drawn-slot { display: grid; justify-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 90px; }
.drawn-slot .card { --card-w: 76px; }

.prompt {
  background: var(--panel-strong); border-radius: 14px; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; text-align: center;
  min-height: 60px;
}
.prompt .msg { font-size: 16px; }
.prompt .msg b { color: var(--gold); }
.prompt .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.side { display: grid; gap: 12px; align-content: start; }
.log { background: var(--panel); border-radius: 14px; padding: 12px; max-height: 420px; overflow-y: auto; font-size: 14px; }
.log h3, .scores h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.log p { margin: 0 0 6px; line-height: 1.35; }
.log p:last-child { color: var(--ink); font-weight: 600; }
.log p { color: var(--muted); }
.scores { background: var(--panel); border-radius: 14px; padding: 12px; font-size: 14px; }
.scores table { width: 100%; border-collapse: collapse; }
.scores td { padding: 3px 0; }
.scores td:last-child { text-align: right; }

/* ---------- cards ---------- */
.card {
  width: var(--card-w); aspect-ratio: 5 / 7; border-radius: calc(var(--card-w) * .1);
  position: relative; user-select: none; flex: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  transition: transform .15s, box-shadow .15s, outline-color .15s;
  outline: 3px solid transparent; outline-offset: 2px;
}
.card.face { background: var(--card); color: var(--card-ink); }
.card.face.red { color: var(--red); }
.card .rank { position: absolute; top: 6%; left: 9%; font-weight: 700; font-size: calc(var(--card-w) * .26); line-height: 1; font-family: Georgia, serif; }
.card .suit-sm { position: absolute; top: 30%; left: 10%; font-size: calc(var(--card-w) * .2); line-height: 1; }
.card .pip { position: absolute; right: 10%; bottom: 6%; font-size: calc(var(--card-w) * .48); line-height: 1; }
.card.joker .pip { font-size: calc(var(--card-w) * .42); }
.card.joker .rank { font-size: calc(var(--card-w) * .16); letter-spacing: 1px; writing-mode: vertical-rl; top: 8%; }
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 4px, transparent 4px 10px),
    linear-gradient(135deg, var(--back-1), var(--back-2));
  border: calc(var(--card-w) * .06) solid var(--card);
}
.card.back::after {
  content: "C"; position: absolute; inset: 0; display: grid; place-items: center;
  font-family: Georgia, serif; font-weight: bold; color: rgba(255,255,255,.35); font-size: calc(var(--card-w) * .4);
}
.card.empty { background: transparent; box-shadow: none; border: 2px dashed rgba(255,255,255,.18); }
.card.ghost { background: rgba(255,255,255,.06); box-shadow: none; border: 2px dashed rgba(255,255,255,.25); }
.card.clickable, .card.stickable { cursor: pointer; }
.card { touch-action: manipulation; }
.card.in-flight { visibility: hidden; }
.flying { position: fixed; z-index: 50; pointer-events: none; will-change: transform; }
.flying .card { box-shadow: 0 10px 24px rgba(0,0,0,.45); }
.flying.stick-ok .card { outline: 3px solid #4cd187; outline-offset: 2px; }
.flying.stick-bad .card { outline: 3px solid #ff6b5b; outline-offset: 2px; }
.discard-stack { position: relative; }
.discard-stack .stack-top { position: absolute; inset: 0; }
@keyframes flipIn { from { transform: perspective(600px) rotateY(90deg); } to { transform: perspective(600px) rotateY(0); } }
.flip-in { animation: flipIn .35s ease-out; }
.card { transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s, outline-color .15s; }
@media (prefers-reduced-motion: reduce) { .flip-in, .pop { animation: none; } .card { transition: none; } }
.card.clickable:hover { transform: translateY(-4px); outline-color: rgba(242,193,78,.7); }
.card.selected { outline-color: var(--gold); transform: translateY(-4px); }
.card.revealed { outline-color: #6ad1ff; box-shadow: 0 0 18px rgba(106,209,255,.7); }
.card.locked::before { content: "🔒"; position: absolute; top: -10px; right: -8px; font-size: 14px; z-index: 1; }
.card-tag { font-size: 11px; color: var(--muted); text-align: center; margin-top: 2px; }
.slot { display: grid; justify-items: center; }

@keyframes pop { from { transform: scale(.85); opacity: .3; } to { transform: scale(1); opacity: 1; } }
.pop { animation: pop .25s ease-out; }

/* ---------- turn timer ---------- */
.seat { position: relative; }
.turn-secs { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 13px; background: rgba(0,0,0,.3); border-radius: 999px; padding: 2px 8px; }
.seat-head .tag + .turn-secs { margin-left: 6px; }
.turn-secs.low { background: var(--red); color: #fff; }
.turn-bar { height: 5px; border-radius: 999px; background: rgba(0,0,0,.3); margin-top: 10px; overflow: hidden; }
.turn-fill { height: 100%; background: var(--gold); border-radius: 999px; transition: width .2s linear, background .3s; }
.turn-fill.low { background: #ff6b5b; }
.small-note { font-size: 13px; margin: 0; }

/* ---------- action panel (left of the discard pile) ---------- */
.action-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 190px; }
.action-panel .act { padding: 7px 6px; font-size: 13px; border-radius: 10px; white-space: nowrap; }
.action-panel .wide { grid-column: span 2; }
.action-panel .act:disabled { opacity: 1; background: rgba(255,255,255,.07); color: rgba(244,241,232,.35); box-shadow: none; }
.action-panel .act:not(:disabled):active { transform: translateY(1px); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,.7); } 50% { box-shadow: 0 0 0 6px rgba(192,57,43,0); } }
.pulse { animation: pulse 1s infinite; }
.card.selected { outline: 3px solid var(--gold); outline-offset: 2px; transform: translateY(-6px); box-shadow: 0 0 0 6px rgba(242,193,78,.25), 0 8px 16px rgba(0,0,0,.4); }

/* ---------- results ---------- */
.results { background: var(--panel-strong); border-radius: 14px; padding: 16px; text-align: center; display: grid; gap: 10px; }
.results h2 { margin: 0; font-family: Georgia, serif; }
.results table { margin: 0 auto; border-collapse: collapse; }
.results td { padding: 4px 12px; }
.results tr.win td { color: var(--gold); font-weight: 700; }

/* ---------- toast & dialog ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #1d2330; color: #fff; padding: 10px 18px; border-radius: 999px; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center; z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
dialog { border: 0; border-radius: 16px; padding: 0; max-width: 520px; width: calc(100% - 32px); background: #f7f4ec; color: #1d2330; }
dialog::backdrop { background: rgba(0,0,0,.5); }
.rules { padding: 20px 24px; max-height: 80vh; overflow-y: auto; }
.rules h2 { margin-top: 0; font-family: Georgia, serif; }
.rules h3 { margin-bottom: 4px; }
.rules form { text-align: right; margin-top: 16px; }

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  .table { grid-template-columns: 1fr; padding: 12px; }
  .side { grid-template-columns: 1fr 1fr; }
  .log { max-height: 200px; }
}
@media (max-width: 520px) {
  /* Phones: the action buttons sit in a bar at the bottom of the screen, within thumb reach. */
  .table.playing { padding-bottom: 150px; }
  .table.playing .action-panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; width: auto;
    grid-template-columns: repeat(4, 1fr); gap: 5px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(8, 34, 23, .97); border-top: 1px solid rgba(255,255,255,.12); box-shadow: 0 -6px 20px rgba(0,0,0,.35); }
  .table.playing .action-panel .act { font-size: 13px; padding: 10px 2px; }
  .table.playing .action-panel > :last-child { grid-column: span 4; }
  .center-row { gap: 6px; flex-wrap: nowrap; }
  .action-panel { width: 136px; gap: 4px; flex: none; }
  .action-panel .act { font-size: 11.5px; padding: 6px 2px; }
  .center-row .pile .card { --card-w: 52px; }
  .center-row .drawn-slot { min-width: 0; }
  .center-row .drawn-slot .card { --card-w: 58px; }
  .pile span, .drawn-slot span { font-size: 11px; }
  .me .hand { --card-w: 64px; }
  .opponents .hand { --card-w: 40px; }
  .pile .card { --card-w: 60px; }
  .drawn-slot .card { --card-w: 70px; }
  .side { grid-template-columns: 1fr; }
  .code-box .code { font-size: 38px; letter-spacing: 5px; }
  .hero h1 { font-size: 36px; }
}

/* ---------- easy mode: cards you remember ---------- */
.card.face.known { box-shadow: 0 0 0 2px rgba(120, 190, 255, .85), 0 2px 6px rgba(0,0,0,.35); }

/* ---------- hard mode: notes and cards left ---------- */
.card .note {
  position: absolute; left: 3%; right: 3%; bottom: 4%; z-index: 1;
  display: flex; flex-wrap: wrap; gap: 2px; justify-content: center;
  font-style: normal; font-size: calc(var(--card-w) * .17); line-height: 1.1; font-weight: 700;
}
.card .note i { font-style: normal; padding: 0 3px; border-radius: 4px; }
.card .note i.is { background: #4cd187; color: #0b2a1c; }
.card .note i.not { background: rgba(255,255,255,.88); color: var(--red); text-decoration: line-through; }
.note-bar { background: var(--panel); border-radius: 12px; padding: 8px 10px; display: grid; gap: 6px; text-align: center; font-size: 14px; }
.note-bar b.is { color: #4cd187; }
.note-bar b.not { color: #ff8a7a; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.chip { min-width: 36px; padding: 6px 7px; border-radius: 8px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.25); color: var(--ink); font-weight: 700; cursor: pointer; }
.chip.is { background: #4cd187; color: #0b2a1c; border-color: #4cd187; }
.chip.not { background: #fff; color: var(--red); text-decoration: line-through; border-color: #fff; }
.chip.clear { font-weight: 500; }
.cards-left { display: grid; gap: 8px; }
.left-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.left-cell { background: var(--panel); border-radius: 8px; padding: 5px 6px; display: flex; justify-content: space-between; gap: 4px; font-size: 13px; }
.left-cell.gone { opacity: .4; }

/* No box around your own hand or the note picker. */
.mine .seat, .mine .seat.turn { background: transparent; border-color: transparent; box-shadow: none; }
.note-bar { background: transparent; padding: 4px 0; }

/* Notes: who knows a card, and cards picked for a note */
.card .knows-row { position: absolute; top: 3%; left: 3%; right: 3%; z-index: 1; display: flex; flex-wrap: wrap; gap: 2px; justify-content: center;
  font-size: calc(var(--card-w) * .15); line-height: 1.1; font-weight: 700; }
.card .knows-row i { font-style: normal; background: #7cc4ff; color: #0b2233; padding: 0 3px; border-radius: 4px; }
.card.note-pick { outline: 3px dashed #7cc4ff; outline-offset: 3px; }
.note-bar.open { gap: 8px; }
.chip.who.on { background: #7cc4ff; color: #0b2233; border-color: #7cc4ff; }
.note-bar .chips .small { min-width: 0; }

/* Flash a card someone looked at (blue) or that was swapped (orange) */
@keyframes flashLook { 0%, 100% { box-shadow: 0 0 0 3px rgba(124,196,255,.95), 0 0 18px 6px rgba(124,196,255,.7); } 50% { box-shadow: 0 0 0 3px rgba(124,196,255,.3), 0 0 4px 1px rgba(124,196,255,.2); } }
@keyframes flashSwap { 0%, 100% { box-shadow: 0 0 0 3px rgba(255,159,67,.95), 0 0 18px 6px rgba(255,159,67,.7); } 50% { box-shadow: 0 0 0 3px rgba(255,159,67,.3), 0 0 4px 1px rgba(255,159,67,.2); } }
.card.flash-look { animation: flashLook .8s ease-in-out infinite; }
.card.flash-swap { animation: flashSwap .8s ease-in-out infinite; }
.card .flash-badge { position: absolute; top: -9px; right: -9px; z-index: 2; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; background: #fff; color: #222; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.card.flash-swap .flash-badge { background: #ff9f43; color: #fff; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .card.flash-look, .card.flash-swap { animation: none; box-shadow: 0 0 0 3px #7cc4ff; } .card.flash-swap { box-shadow: 0 0 0 3px #ff9f43; } }

/* Game options in the lobby */
.game-options { display: grid; gap: 6px; justify-items: start; max-width: 360px; margin: 0 auto; width: 100%; }
.toggle { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; text-align: left; }
.toggle input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--gold); }
.toggle small { display: block; color: var(--muted); font-size: 12px; }

/* The note maker floats over the middle of the table so cards and buttons stay put */
.mid { position: relative; display: grid; gap: 14px; }
.note-maker { position: absolute; inset: 0; z-index: 20; overflow-y: auto; display: grid; gap: 6px; align-content: start; justify-items: center;
  background: rgba(10, 40, 28, .97); border: 1px solid rgba(255,255,255,.15); border-radius: 14px; padding: 10px; text-align: center; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.note-maker .note-title { color: var(--gold); }
.note-maker b.is { color: #4cd187; } .note-maker b.not { color: #ff8a7a; }
.action-panel .note-btn { color: #7cc4ff; }
/* Dragging across cards to select them shouldn't scroll the page or pick text */
.table .card.clickable { touch-action: none; -webkit-user-select: none; }
.game-options label.toggle { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; margin: 0; }
.game-options label.toggle input { flex: none; }
.game-options label.toggle span { display: block; }

/* The timer bar keeps its space so nothing jumps */
.turn-bar.off { visibility: hidden; }

/* King suit symbols in notes, chips and the counter */
.ks { font-size: 1.3em; line-height: 0; vertical-align: -0.08em; margin-left: 1px; }
.left-cell b { font-size: 14px; }

/* "CAMBRIO!" pop-up when someone calls it */
.cambio-pop { position: fixed; left: 50%; top: 45%; z-index: 100; pointer-events: none; transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: 4px; padding: 18px 34px; border-radius: 22px;
  background: linear-gradient(135deg, #e74c3c, #b0281a); color: #fff; box-shadow: 0 18px 50px rgba(0,0,0,.5), 0 0 0 4px var(--gold); }
.cambio-pop b { font-family: Georgia, serif; font-size: clamp(40px, 9vw, 84px); letter-spacing: 3px; line-height: 1; text-shadow: 0 3px 0 rgba(0,0,0,.25); }
.cambio-pop span { font-size: clamp(14px, 2.5vw, 20px); font-weight: 600; opacity: .95; }
.tag.cambio-tag { background: #e74c3c; color: #fff; }

/* ---------- card backs and table colours (chosen on the home screen) ---------- */
body[data-table="blue"] { --felt: #1d4f7a; --felt-dark: #123553; --felt-light: #2a6597; }
body[data-table="purple"] { --felt: #4b2a6b; --felt-dark: #321b49; --felt-light: #613a88; }
body[data-table="charcoal"] { --felt: #2c3036; --felt-dark: #1b1e22; --felt-light: #3b4048; }
.card.back[data-back="navy"], body[data-back="navy"] .card.back { --back-1: #22346b; --back-2: #141f45; }
.card.back[data-back="teal"], body[data-back="teal"] .card.back { --back-1: #138a8a; --back-2: #0b5c63; }
.card.back[data-back="red"] { --back-1: #8e2c2c; --back-2: #6d1f1f; }
.card.back[data-back="gold"], body[data-back="gold"] .card.back {
  background: repeating-linear-gradient(45deg, rgba(242,193,78,.18) 0 3px, transparent 3px 9px), linear-gradient(135deg, #222, #0d0d0d);
}
body[data-back="gold"] .card.back::after, .card.back[data-back="gold"]::after { color: rgba(242,193,78,.7); }
/* swatches don't follow the player's own choice, they show each option */
.swatch .card.back[data-back="red"] { background: repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 4px, transparent 4px 10px), linear-gradient(135deg, #8e2c2c, #6d1f1f); }
.swatch .card.back[data-back="navy"] { background: repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 4px, transparent 4px 10px), linear-gradient(135deg, #22346b, #141f45); }
.swatch .card.back[data-back="teal"] { background: repeating-linear-gradient(45deg, rgba(255,255,255,.08) 0 4px, transparent 4px 10px), linear-gradient(135deg, #138a8a, #0b5c63); }
.swatch .card.back[data-back="red"]::after, .swatch .card.back[data-back="navy"]::after, .swatch .card.back[data-back="teal"]::after { color: rgba(255,255,255,.35); }
.customise { gap: 8px; }
.customise h3 { margin: 0; }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch { display: grid; justify-items: center; gap: 4px; background: rgba(0,0,0,.2); border: 2px solid transparent; border-radius: 12px; padding: 8px 4px; color: var(--ink); cursor: pointer; }
.swatch.on { border-color: var(--gold); }
.swatch small { font-size: 11px; color: var(--muted); }
.swatch .card { --card-w: 34px; }
.felt { width: 44px; height: 30px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.felt[data-table="green"] { background: radial-gradient(#1b6e4b, #0e4430); }
.felt[data-table="blue"] { background: radial-gradient(#2a6597, #123553); }
.felt[data-table="purple"] { background: radial-gradient(#613a88, #321b49); }
.felt[data-table="charcoal"] { background: radial-gradient(#3b4048, #1b1e22); }
.home-links { display: flex; justify-content: center; margin: 14px 0; }
.home .box + .box, .home .box.rejoin { margin-top: 14px; }
.rejoin { display: flex !important; align-items: center; justify-content: space-between; gap: 10px; }
/* tutorial */
.tutorial .tut-step { font-size: 12px; color: #6b6b6b; text-transform: uppercase; letter-spacing: 1px; }
.tut-cards { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
.tut-cards .card { --card-w: 52px; }
.tut-buttons { display: flex; gap: 8px; justify-content: center; margin: 10px 0; }
.tut-buttons span { background: #1d2330; color: #f4f1e8; padding: 6px 14px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.tut-nav { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ---------- bots, target score, match ---------- */
.tag.bot-tag { background: #8fa3c2; }
button.tiny { padding: 2px 8px; font-size: 12px; min-height: 0; }
.add-bot { display: block; margin: 0 auto 10px; }
.match-over { background: #ffd35c; color: #2a2100; font-weight: 800; font-size: 18px; border-radius: 12px; padding: 10px 14px; text-align: center; }
.match-over small { display: block; font-weight: 500; font-size: 13px; }

/* ---------- emoji reactions (fixed, so nothing on the table moves) ---------- */
.react-box { position: fixed; right: 16px; bottom: 16px; z-index: 35; display: flex; align-items: center; gap: 6px; }
.react-btn { width: 46px; height: 46px; border-radius: 50%; font-size: 22px; padding: 0; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.25); }
.react-pick { display: flex; gap: 2px; background: rgba(15,20,30,.85); border-radius: 999px; padding: 4px 6px; }
.react-pick button { background: none; border: 0; font-size: 24px; padding: 4px 6px; min-height: 0; }
.react-pick button:hover { transform: scale(1.2); }
.reaction-float { position: fixed; z-index: 60; font-size: 34px; pointer-events: none; }
.stick-time { position: fixed; z-index: 60; pointer-events: none; background: #ffd35c; color: #2a2100; font-weight: 800; font-size: 13px;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
@media (max-width: 520px) {
  .table.playing ~ .react-box, .table.playing .react-box { bottom: 128px; right: 10px; }
  .react-btn { width: 40px; height: 40px; font-size: 19px; }
  .react-pick button { font-size: 21px; padding: 3px 4px; }
}

/* ---------- round replay ---------- */
dialog.replay { max-width: 720px; padding: 16px; }
.replay-head { display: flex; justify-content: space-between; align-items: center; }
.replay-head h2 { margin: 0; }
.replay-step { min-height: 3.2em; margin: 8px 0; }
.replay-table { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; background: var(--felt); border-radius: 12px; padding: 12px; }
.replay-seat { display: flex; flex-direction: column; align-items: center; gap: 6px; color: #fff; }
.replay-hand { display: grid; grid-template-columns: repeat(2, auto); gap: 4px; align-items: center; --card-w: 40px; }
.replay-hand.wide { grid-template-columns: repeat(3, auto); }
.replay-pile { --card-w: 40px; }
dialog .secondary { background: #e2dccd; color: #1d2330; }
dialog .secondary:hover:not(:disabled) { background: #d6cfbd; }
dialog .ghost { color: #1d2330; border: 1px solid rgba(29,35,48,.35); }
dialog .muted { color: #5d6472; }
.replay input[type=range] { width: 100%; margin: 12px 0 6px; }
.replay-controls { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

/* ---------- achievements ---------- */
.ach-pop { position: fixed; top: 12px; left: 50%; transform: translate(-50%, 0); z-index: 80; display: flex; gap: 12px; align-items: center;
  background: #1d2330; color: #f4f1e8; border: 2px solid #ffd35c; border-radius: 14px; padding: 10px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.45);
  max-width: calc(100% - 32px); pointer-events: none; }
.ach-pop .ach-icon { font-size: 30px; }
.ach-pop small { display: block; color: #ffd35c; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.ach-pop b { display: block; font-size: 16px; }
.ach-pop em { display: block; font-style: normal; font-size: 13px; opacity: .8; }
.ach-list ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.ach-list li { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: #ebe6d8; }
.ach-list li.locked { opacity: .55; }
.ach-list li.got { background: #fff3c4; box-shadow: inset 0 0 0 2px #e8b923; }
.ach-list .ach-icon { font-size: 24px; flex: none; width: 30px; text-align: center; }
.ach-list b { display: block; font-size: 14px; }
.ach-list small { display: block; font-size: 12px; color: #5d6472; }
.ach-list h2 small { font-size: 14px; font-weight: 500; }
#achDialog { max-width: 720px; }
.home-links { flex-wrap: wrap; gap: 8px; }

/* ---------- poker-style table: seats around an oval ---------- */
.ring { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto 1fr auto; grid-template-areas: "left top right" "left mid right" "me me me"; gap: 12px 18px; padding: 6px 0 0; }
.ring::before { content: ''; position: absolute; z-index: 0; inset: 70px 56px 120px; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, var(--felt-light), var(--felt) 60%, var(--felt-dark));
  border: 14px solid #4a2f1b; box-shadow: inset 0 0 0 3px rgba(255,255,255,.08), inset 0 10px 40px rgba(0,0,0,.35), 0 18px 40px rgba(0,0,0,.45); }
.ring.no-top::before { top: 10px; }
.ring.no-sides::before { left: 10px; right: 10px; }
.ring > * { position: relative; } /* no z-index: the phone action bar inside .mid must stay on top */
.ring-left, .ring-right { display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.ring-left { grid-area: left; flex-direction: column-reverse; }
.ring-right { grid-area: right; }
.ring-top { grid-area: top; display: flex; justify-content: center; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.ring .mid { grid-area: mid; align-self: center; padding: 18px 0; }
.ring .mine { grid-area: me; }
.ring-left:empty, .ring-right:empty, .ring-top:empty { display: none; }
.ring .seat:not(.me) { background: rgba(10, 22, 16, .82); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.ring .seat.turn:not(.me) { box-shadow: 0 0 0 4px rgba(242,193,78,.25), 0 6px 18px rgba(0,0,0,.35); }
.ring.seats-5 .opponents .hand, .ring.seats-6 .opponents .hand, .ring.seats-7 .opponents .hand { --card-w: 42px; }
.ring .prompt { background: rgba(0,0,0,.28); }
@media (max-width: 520px) {
  /* Phones: everyone else sits across the top in clockwise order, the table sits below them. */
  .ring { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .ring-left, .ring-top, .ring-right { display: contents; }
  .ring-left .seat { order: 0; }
  .ring .mid, .ring .mine { flex-basis: 100%; }
  .ring::before { display: none; }
  .ring .mid { border-radius: 40% / 30%; padding: 16px 6px; border: 8px solid #4a2f1b;
    background: radial-gradient(ellipse at 50% 40%, var(--felt-light), var(--felt) 60%, var(--felt-dark)); }
  .ring.seats-5 .opponents .hand, .ring.seats-6 .opponents .hand, .ring.seats-7 .opponents .hand { --card-w: 34px; }
}
body.ingame { background: #14181e radial-gradient(ellipse at 50% 30%, #2a313b, #14181e 70%) no-repeat; min-height: 100vh; }
body.ingame .topbar, body.ingame header { background: rgba(0,0,0,.35); }
.ring.no-sides .mid { padding: 18px 70px; }
@media (max-width: 520px) { .ring.no-sides .mid { padding: 16px 6px; } }

/* Wide screens: seats spread evenly round the oval, positioned by angle (see seatRing in app.js). */
@media (min-width: 1180px) {
  .ring { display: block; height: 800px; }
  .ring-left, .ring-top, .ring-right { display: contents; }
  .ring::before, .ring.no-top::before, .ring.no-sides::before { inset: 11% 9%; }
  .ring .spot { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); }
  .ring .mid { position: absolute; left: 50%; top: 47%; transform: translate(-50%, -50%); width: min(520px, 52%); padding: 0; }
  .ring .center-row { gap: 12px; }
  .ring .drawn-slot { min-width: 76px; }
  .ring.seats-6 .opponents .hand, .ring.seats-7 .opponents .hand { --card-w: 38px; }
  .ring.no-sides .mid { padding: 0; }
  .ring .mine { position: absolute; left: 50%; top: 89%; transform: translate(-50%, -50%); }
  .ring .me .hand { --card-w: 60px; }
  .ring .opponents .hand { --card-w: 42px; }
  .ring .seat:not(.me) { padding: 8px 10px 10px; }
  .ring .mid:has(.results) { z-index: 5; }
}

/* Centre the table on wide screens. The log sits to the right only when there is room for it
   on both sides (very wide screens); otherwise it goes under the table. */
@media (min-width: 1180px) {
  .table { grid-template-columns: minmax(0, 1fr); max-width: none; justify-items: center; }
  .play-area { width: min(1060px, 100%); }
  /* Seats stick out past the oval, so leave room above and below it. */
  .ring { height: 760px; margin: 44px 0 110px; } /* scaled to fit short screens by fitTable() in app.js */
  .side { width: min(1060px, 100%); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
  .side .log { max-height: 260px; }
}
@media (min-width: 1640px) {
  .table { grid-template-columns: 1fr minmax(0, 1060px) 1fr; justify-items: stretch; }
  .play-area { grid-column: 2; width: auto; }
  .side { grid-column: 3; width: auto; max-width: 300px; grid-template-columns: 1fr; }
  .side .log { max-height: 420px; }
}
