/* ============ BackgammonWorld ============ */

:root {
  --bg-1: #1a1410;
  --bg-2: #2b201a;
  --gold: #d4a24e;
  --gold-soft: #e8c98a;
  --frame-1: #4a2c15;
  --frame-2: #2e1a0b;
  /* the two checker colors: ivory ("red" seat) and ebony */
  --ivory-1: #fffef7;
  --ivory-2: #e9dcc0;
  --ivory-3: #c0a476;
  --dark-1: #7e858f;
  --dark-2: #363b43;
  --dark-3: #16191e;
  --ink: #f3ead9;
  --ink-dim: #b7a98c;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* fast taps everywhere: no double-tap-zoom hold-off on the board or the
   buttons (rapid capture chains felt laggy / zoomed on phones) */
button, input, .zone { touch-action: manipulation; }

/* generic hide utility — many elements are toggled with .hidden, and
   without this rule a plain element (e.g. the New Game button) stays
   visible online despite classList.add("hidden") */
.hidden { display: none !important; }

body {
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 20% -10%, #3a2a1e 0%, transparent 60%),
    radial-gradient(1000px 600px at 110% 110%, #33241b 0%, transparent 55%),
    linear-gradient(160deg, var(--bg-2), var(--bg-1) 70%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px 40px;
}

/* ---------- Header ---------- */

.site-header { text-align: center; margin-bottom: 12px; }

.logo {
  font-size: clamp(1.25rem, 2.4vw, 1.6rem);
  font-weight: 800;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.logo-accent { color: var(--gold); }

/* the logo doubles as a home link on the legal pages — keep it looking
   like the wordmark, not a default blue underlined anchor */
a.logo, a.logo-link { color: var(--ink); text-decoration: none; }

.logo-disc {
  width: 0.85em; height: 0.85em;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 -3px 5px rgba(0,0,0,.45), inset 0 2px 3px rgba(255,255,255,.35), 0 3px 6px rgba(0,0,0,.5);
}
.logo-disc-ivory { background: radial-gradient(circle at 35% 30%, var(--ivory-1), var(--ivory-2) 55%, var(--ivory-3)); }
.logo-disc-dark  { background: radial-gradient(circle at 35% 30%, var(--dark-1), var(--dark-2) 55%, var(--dark-3)); }

.tagline {
  color: var(--ink-dim);
  font-size: 0.78rem;
  margin-top: 3px;
  font-style: italic;
  opacity: 0.85;
}

/* sound on/off — floats top-right so it costs no sidebar height */
.sound-toggle {
  position: absolute;
  top: 12px; right: 14px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.05);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, opacity .15s ease;
}
.sound-toggle:hover { border-color: rgba(212,162,78,.6); background: rgba(212,162,78,.12); }
.sound-toggle.muted { opacity: .55; }

/* ---------- Layout ---------- */

.arena {
  display: flex;
  gap: 24px;
  align-items: stretch;      /* board & sidebar share the row height */
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  max-width: 1340px; /* room for board + panel + affiliate column on wide screens */
}

/* ---------- Backgammon board ----------
 * The playing field (points, bar, off trays) is one SVG built by main.js;
 * checkers, dice, hints and click zones are absolutely-positioned layers
 * above it, placed in % of the field's 1400 x 920 coordinate space. */

.board-wrap { flex: 0 1 auto; display: flex; }

.board-frame {
  position: relative;
  /* bind to the available viewport height (minus header/margins) so the
     board never pushes the sidebar's online buttons below the fold */
  width: min(94vw, calc((100vh - 150px) * 1.44), 880px);
  /* dynamic viewport unit where supported: classic 100vh includes the
     mobile browser's retracted address bar and oversizes the board */
  width: min(94vw, calc((100dvh - 150px) * 1.44), 880px);
  aspect-ratio: 1400 / 920;
  align-self: flex-start;
  padding: clamp(7px, 1.4vw, 14px); /* slimmer wooden border */
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.10), rgba(0,0,0,.25)),
    repeating-linear-gradient(100deg, var(--frame-1) 0 14px, #57351b 14px 22px, var(--frame-1) 22px 40px),
    var(--frame-1);
  box-shadow:
    0 24px 60px rgba(0,0,0,.6),
    0 6px 18px rgba(0,0,0,.4),
    inset 0 2px 3px rgba(255,255,255,.15),
    inset 0 -3px 6px rgba(0,0,0,.5);
}

.board, .pieces, .hints, .dice-layer, .zones, .cube-layer, .trail-layer {
  position: absolute;
  inset: clamp(7px, 1.4vw, 14px);
  border-radius: 6px;
}

.board { overflow: hidden; box-shadow: inset 0 0 0 2px rgba(0,0,0,.5), inset 0 6px 18px rgba(0,0,0,.35); }
.board svg { display: block; width: 100%; height: 100%; }

.pieces, .hints, .dice-layer { pointer-events: none; }

/* ---------- click zones (invisible hit areas) ---------- */

.zone {
  position: absolute;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none; /* a drag must never start a text selection */
}

/* ---------- checkers ---------- */

.bg-checker {
  position: absolute;
  width: 6%;                 /* 84 of 1400 */
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  transition: top 0.38s cubic-bezier(.4, 1.2, .4, 1), left 0.38s cubic-bezier(.4, 1.2, .4, 1);
  z-index: 2;
}

.bg-checker.red {
  background: radial-gradient(circle at 35% 28%, #fffef7 0%, #f2e7cd 40%, #dcc7a0 75%, #bfa376 100%);
  box-shadow:
    inset 0 3px 5px rgba(255,255,255,.9),
    inset 0 -4px 7px rgba(112, 84, 45, .45),
    0 4px 8px rgba(0,0,0,.5),
    0 1px 2px rgba(0,0,0,.55);
}

.bg-checker.black {
  background: radial-gradient(circle at 35% 28%, #7e858f 0%, #454b54 42%, #262a31 78%, #15181d 100%);
  box-shadow:
    inset 0 3px 5px rgba(255,255,255,.28),
    inset 0 -4px 7px rgba(0,0,0,.7),
    0 4px 8px rgba(0,0,0,.5),
    0 1px 2px rgba(0,0,0,.55);
}

/* turned groove rings, like real wooden checkers */
.bg-checker::before {
  content: "";
  position: absolute; inset: 14%;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.22);
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.06), inset 0 1px 2px rgba(255,255,255,.25);
}
.bg-checker.red::before { border-color: rgba(146, 111, 62, .5); }
.bg-checker.black::before { border-color: rgba(0,0,0,.55); box-shadow: inset 0 0 0 5px rgba(255,255,255,.05), inset 0 1px 2px rgba(255,255,255,.12); }

.bg-checker.selected {
  z-index: 4;
  box-shadow:
    0 0 0 3px var(--gold),
    0 0 20px rgba(212, 162, 78, .9),
    0 4px 8px rgba(0,0,0,.5);
}

.bg-checker.movable { animation: canMove 1.6s ease-in-out infinite; }

@keyframes canMove {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.18) drop-shadow(0 0 6px rgba(212,162,78,.55)); }
}

/* stack-count badge on the top checker of tall stacks */
.bg-checker .cnt {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: clamp(10px, 1.6vw, 17px);
  color: rgba(0,0,0,.62);
  text-shadow: 0 1px 0 rgba(255,255,255,.4);
}
.bg-checker.black .cnt { color: rgba(255,255,255,.82); text-shadow: 0 1px 1px rgba(0,0,0,.6); }

/* borne-off checkers rest flat in the tray (seen edge-on) */
.bg-chip {
  position: absolute;
  width: 5.3%;
  aspect-ratio: 3 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 2;
  transition: top 0.38s cubic-bezier(.4, 1.2, .4, 1), left 0.38s cubic-bezier(.4, 1.2, .4, 1);
}
.bg-chip.red {
  background: linear-gradient(180deg, #fbf3dd 0%, #e4d0aa 55%, #c3a778 100%);
  box-shadow: 0 2px 3px rgba(0,0,0,.5), inset 0 1px 1px rgba(255,255,255,.8);
}
.bg-chip.black {
  background: linear-gradient(180deg, #565d68 0%, #2c313a 55%, #171a20 100%);
  box-shadow: 0 2px 3px rgba(0,0,0,.5), inset 0 1px 1px rgba(255,255,255,.25);
}

/* ---------- move hints ---------- */

.bg-hint {
  position: absolute;
  width: 6.4%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px dashed rgba(255, 244, 214, .85);
  background: radial-gradient(circle, rgba(255,244,214,.28), rgba(255,244,214,.08) 70%);
  box-shadow: 0 0 14px rgba(240, 225, 180, .5);
  animation: pulse 1.3s ease-in-out infinite;
  z-index: 3;
}

.bg-hint.capture {
  border-color: rgba(255, 122, 89, .95);
  background: radial-gradient(circle, rgba(255,110,70,.3), rgba(255,110,70,.08) 70%);
  box-shadow: 0 0 16px rgba(255, 120, 70, .75);
}

/* ---------- drag & drop ---------- */

/* the lifted checker rides the pointer: no transition, above everything,
   slightly grown with a deep shadow */
.bg-checker.dragging {
  transition: none;
  animation: none;
  z-index: 10;
  transform: translate(-50%, -50%) scale(1.15);
  filter: brightness(1.08);
  box-shadow:
    0 0 0 3px var(--gold),
    0 16px 30px rgba(0,0,0,.6),
    0 5px 10px rgba(0,0,0,.5);
}

/* !important: zones carry an inline cursor:grab while draggable, which
   would otherwise beat this rule for the whole drag */
.board-frame.grabbing, .board-frame.grabbing .zone { cursor: grabbing !important; }

/* the lifted checker must not parade a stale stack total around */
.bg-checker.dragging .cnt { display: none; }

/* the landing spot under the pointer answers back */
.bg-hint.drop-ok {
  animation: none;
  transform: translate(-50%, -50%) scale(1.28);
  border-style: solid;
  background: radial-gradient(circle, rgba(255,244,214,.45), rgba(255,244,214,.15) 70%);
  box-shadow: 0 0 22px rgba(240, 225, 180, .85);
}
.bg-hint.capture.drop-ok {
  background: radial-gradient(circle, rgba(255,110,70,.45), rgba(255,110,70,.15) 70%);
  box-shadow: 0 0 22px rgba(255, 120, 70, .9);
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.9; }
  50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
}

/* ---------- dice ---------- */

.die {
  position: absolute;
  width: 6.1%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 22%;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: 1%;
  z-index: 5;
  transition: opacity 0.25s ease;
}

.die.red {
  background: linear-gradient(145deg, #fffdf4 0%, #efe3c6 60%, #d8c298 100%);
  box-shadow: 0 4px 10px rgba(0,0,0,.55), inset 0 2px 2px rgba(255,255,255,.9), inset 0 -2px 4px rgba(120, 90, 45, .4);
}
.die.black {
  background: linear-gradient(145deg, #4d545e 0%, #262b33 60%, #14171c 100%);
  box-shadow: 0 4px 10px rgba(0,0,0,.55), inset 0 2px 2px rgba(255,255,255,.25), inset 0 -2px 4px rgba(0,0,0,.7);
}

.die .pip {
  border-radius: 50%;
  margin: 16%;
  visibility: hidden;
}
.die .pip.on { visibility: visible; }
.die.red .pip { background: radial-gradient(circle at 38% 32%, #4a3524, #241708); box-shadow: inset 0 1px 1px rgba(0,0,0,.7); }
.die.black .pip { background: radial-gradient(circle at 38% 32%, #ffffff, #cfd6de); box-shadow: inset 0 -1px 1px rgba(0,0,0,.35); }

.die.used { opacity: 0.32; filter: saturate(.5); }

.die.rolling { animation: dieRoll 0.5s ease; }

@keyframes dieRoll {
  0% { transform: translate(-50%, -140%) rotate(-160deg) scale(.7); opacity: 0; }
  60% { transform: translate(-50%, -46%) rotate(18deg) scale(1.08); opacity: 1; }
  80% { transform: translate(-50%, -52%) rotate(-8deg) scale(.98); }
  100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); }
}

/* pip-count values in the sidebar card */
.pips-value { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

/* ---------- doubling cube & match play ---------- */

.cube-layer, .trail-layer { pointer-events: none; }

.cube {
  position: absolute;
  width: 6.4%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 18%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: clamp(11px, 2vw, 22px);
  color: #2b1a06;
  background: linear-gradient(145deg, #fdf6e0 0%, #ecd9ac 60%, #d3b57e 100%);
  box-shadow: 0 4px 10px rgba(0,0,0,.55), inset 0 2px 2px rgba(255,255,255,.85), inset 0 -2px 4px rgba(120,90,45,.4);
  border: 2px solid rgba(120, 90, 45, .45);
  transition: top .5s cubic-bezier(.4,.9,.4,1);
  z-index: 4;
}
.cube.centered { opacity: .55; }

.match-score-card { text-align: center; font-size: .9rem; color: var(--gold-soft); font-weight: 700; }

.modes-hint { text-transform: none; letter-spacing: 0; font-size: .68rem; opacity: .8; }

/* the opponent's last turn: a ring where each move started, a dot where
 * it landed (#6) */
.trail {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 1;
}
.trail-from {
  width: 2.6%; aspect-ratio: 1;
  /* border scales down on narrow boards so the ring keeps a visible hole */
  border: clamp(2px, 0.25vw, 3px) solid rgba(255, 216, 130, .75);
  background: transparent;
  box-shadow: 0 0 8px rgba(255, 216, 130, .4);
}
.trail-to {
  width: 2%; aspect-ratio: 1;
  background: rgba(255, 216, 130, .85);
  box-shadow: 0 0 10px rgba(255, 216, 130, .55);
}

/* ---------- Side panel ---------- */

.panel {
  display: flex;
  flex-direction: column;
  /* pack the cards from the top with a fixed gap — space-between used to
     stretch the gaps to whatever the tallest row neighbour was (the
     affiliate column), blowing the sidebar far past the board */
  justify-content: flex-start;
  gap: 7px;
  width: min(340px, 92vw);
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 9px 13px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}

.turn-card {
  display: flex; align-items: center; gap: 12px;
  transition: box-shadow .3s ease, border-color .3s ease;
}

.turn-card.red-turn  { border-color: rgba(240, 228, 196, .5); box-shadow: 0 0 18px rgba(233, 220, 192, .22), 0 8px 24px rgba(0,0,0,.35); }
.turn-card.black-turn { border-color: rgba(150, 158, 172, .45); box-shadow: 0 0 18px rgba(120, 130, 148, .2), 0 8px 24px rgba(0,0,0,.35); }

.turn-disc {
  width: 34px; height: 34px;
  border-radius: 50%;
  box-shadow: inset 0 4px 6px rgba(255,255,255,.3), inset 0 -5px 8px rgba(0,0,0,.5), 0 4px 8px rgba(0,0,0,.5);
  transition: background .3s ease;
}
.turn-disc.red  { background: radial-gradient(circle at 35% 28%, #fffef7, #e9dcc0 55%, #c0a476); }
.turn-disc.black { background: radial-gradient(circle at 35% 28%, #7e858f, #363b43 55%, #16191e); }

.turn-label { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-dim); }
.turn-player { font-size: 1.15rem; font-weight: 700; }

.turn-timer {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gold-soft);
  background: rgba(0,0,0,.3);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 4px 10px;
}
.turn-timer.hidden { display: none; }
.turn-timer.warn {
  color: #ff8a70;
  border-color: rgba(255,110,90,.55);
  animation: timerBlink 1s steps(2) infinite;
}
@keyframes timerBlink { 50% { background: rgba(255, 80, 60, .22); } }

.online-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.online-actions .hidden { display: none; }

/* ---------- Match (duel) card — who you're playing, online ---------- */

.match-card { display: flex; flex-direction: column; gap: 4px; }
.match-card.hidden { display: none; }

.match-side {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.match-side.active {
  border-color: rgba(212, 162, 78, .55);
  background: rgba(212, 162, 78, .12);
  box-shadow: 0 0 14px rgba(212, 162, 78, .22);
}

.match-disc {
  width: 26px; height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 3px 5px rgba(255,255,255,.3), inset 0 -4px 6px rgba(0,0,0,.5), 0 2px 5px rgba(0,0,0,.5);
}
.match-disc.red  { background: radial-gradient(circle at 35% 28%, #fffef7, #e9dcc0 55%, #c0a476); }
.match-disc.black { background: radial-gradient(circle at 35% 28%, #7e858f, #363b43 55%, #16191e); }

.match-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.match-name { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-elo { font-size: .74rem; color: var(--ink-dim); }

.match-badge {
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold-soft);
  border: 1px solid rgba(212,162,78,.4);
  border-radius: 6px;
  padding: 1px 5px;
  flex-shrink: 0;
}

.match-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--gold-soft);
  flex-shrink: 0;
}
.match-clock.hidden { display: none; }
.match-clock.warn { color: #ff8a70; animation: timerBlink 1s steps(2) infinite; }

.match-vs {
  text-align: center;
  font-size: .68rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.message-card { min-height: 44px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.message-card p { font-size: .92rem; flex: 1 1 100%; }

/* undo / confirm while a turn is staged */
.turn-actions { display: flex; gap: 8px; width: 100%; }
.turn-actions .btn-small { flex: 1; }
.btn-small.confirm {
  background: linear-gradient(160deg, var(--gold-soft), var(--gold));
  color: #2b1a06;
  font-weight: 800;
  border-color: transparent;
}
.btn-small.confirm:hover { filter: brightness(1.06); }
.btn-small:disabled { opacity: .45; cursor: default; }
#message { font-size: .95rem; line-height: 1.4; color: var(--gold-soft); }
#message.alert { color: #ff9d78; font-weight: 600; }

.captures-card { display: flex; flex-direction: column; gap: 6px; }
.capture-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.capture-label { font-size: .75rem; color: var(--ink-dim); white-space: nowrap; }

/* ---------- Buttons ---------- */

.btn {
  font: inherit;
  font-weight: 700;
  font-size: .95rem;
  padding: 10px 18px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, filter .2s ease;
}

.btn-primary {
  color: #2b1a06;
  background: linear-gradient(160deg, var(--gold-soft), var(--gold) 60%, #b07f30);
  box-shadow: 0 6px 16px rgba(212, 162, 78, .3), inset 0 1px 2px rgba(255,255,255,.5);
}

.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }

/* ---------- Modes ---------- */

.modes-card { display: flex; flex-direction: column; gap: 6px; }
.modes-label { font-size: .68rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-dim); }

.mode-btns { display: flex; gap: 8px; }

.mode-btn, .diff-btn {
  flex: 1;
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-dim);
  padding: 7px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.04);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}

.mode-btn:hover, .diff-btn:hover { border-color: rgba(212,162,78,.5); color: var(--ink); }

.mode-btn.active, .diff-btn.active {
  color: #2b1a06;
  background: linear-gradient(160deg, var(--gold-soft), var(--gold));
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(212,162,78,.3);
}

.diff-row { display: flex; flex-direction: column; gap: 4px; margin-top: 0; }
.diff-row.hidden { display: none; }

.online-sep { height: 1px; background: rgba(255,255,255,.1); margin: 2px 0; }

/* ---------- Online card ---------- */

.online-card { display: flex; flex-direction: column; gap: 10px; border-color: rgba(212,162,78,.35); }
.online-card.hidden { display: none; }
#onlineStatus { font-size: .92rem; color: var(--gold-soft); line-height: 1.4; }

.invite-row { display: flex; gap: 8px; }
.invite-row.hidden { display: none; }

#inviteLink {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: .8rem;
  color: var(--ink);
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  padding: 8px 10px;
}

.btn-small {
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: #2b1a06;
  background: linear-gradient(160deg, var(--gold-soft), var(--gold));
  transition: filter .15s ease;
}
.btn-small:hover { filter: brightness(1.1); }

.btn-small.danger {
  color: var(--ink);
  background: rgba(255, 90, 70, .16);
  border: 1px solid rgba(255, 110, 90, .4);
}
.btn-small.danger:hover { background: rgba(255, 90, 70, .28); }

.overlay-btns { display: flex; gap: 10px; justify-content: center; }
.overlay-btns .hidden { display: none; }

.btn-ghost {
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid rgba(255,255,255,.25);
}
.btn-ghost:hover { color: var(--ink); border-color: rgba(255,255,255,.5); }

/* pulsing dot while searching for an opponent */
.searching::before {
  content: "";
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.2s ease-in-out infinite;
}

/* thinking dots */
.thinking-dots::after {
  content: "";
  animation: dots 1.2s steps(4) infinite;
}
@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.mode-chip {
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  border: 1px dashed rgba(255,255,255,.14);
  color: var(--ink-dim);
  font-size: .88rem;
}

/* ---------- Winner overlay ---------- */

.overlay {
  position: fixed; inset: 0;
  background: rgba(10, 6, 3, .78);
  backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  animation: fadeIn .35s ease;
}

.overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.overlay-card {
  text-align: center;
  background: linear-gradient(165deg, #382718, #241709);
  border: 1px solid rgba(212, 162, 78, .4);
  border-radius: 20px;
  padding: 40px 56px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7), 0 0 40px rgba(212,162,78,.15);
  animation: cardUp .45s cubic-bezier(.3, 1.4, .5, 1);
}

@keyframes cardUp {
  from { transform: translateY(30px) scale(.92); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.overlay-trophy { font-size: 3.2rem; margin-bottom: 8px; }
.overlay-card h2 { font-size: 2rem; margin-bottom: 6px; color: var(--gold-soft); }
.overlay-card p { color: var(--ink-dim); margin-bottom: 22px; }

/* ---------- Player card ---------- */

.player-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.player-info { display: flex; flex-direction: column; min-width: 0; }
.player-name {
  font-weight: 700;
  font-size: .98rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-elo { color: var(--gold-soft); font-weight: 800; font-size: .98rem; }
.player-sub { color: var(--ink-dim); font-size: .72rem; margin-top: 2px; }

.player-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
/* the stacked account/friends/top-25 buttons are the tallest part of the
 * card — keep them slim so the sidebar fits next to the board unscrolled */
.player-actions .btn-small { padding: 5px 10px; font-size: .76rem; }

.btn-small.ghosted {
  color: var(--ink-dim);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.18);
}
.btn-small.ghosted:hover { color: var(--ink); border-color: rgba(212,162,78,.6); }

.overlay-rating {
  color: var(--gold-soft);
  font-weight: 700;
  font-size: 1.05rem;
  margin: -12px 0 20px;
}
.overlay-rating.hidden { display: none; }

/* ---------- Modals ---------- */

.modal {
  position: fixed; inset: 0;
  background: rgba(10, 6, 3, .72);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
  padding: 16px;
  animation: fadeIn .25s ease;
}
.modal.hidden { display: none; }

.modal-card {
  position: relative;
  width: min(400px, 94vw);
  background: linear-gradient(165deg, #382718, #241709);
  border: 1px solid rgba(212, 162, 78, .35);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
  animation: cardUp .35s cubic-bezier(.3, 1.4, .5, 1);
}
.modal-card.modal-wide { width: min(560px, 94vw); max-height: 88vh; overflow-y: auto; }
.modal-card h3 { color: var(--gold-soft); margin-bottom: 6px; }

.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: none; border: none;
  color: var(--ink-dim); font-size: 1.1rem;
  cursor: pointer;
}
.modal-close:hover { color: var(--ink); }

.modal-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.modal-tab {
  flex: 1; font: inherit; font-weight: 600; font-size: .9rem;
  padding: 9px; border-radius: 10px; cursor: pointer;
  color: var(--ink-dim);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.15);
}
.modal-tab.active {
  color: #2b1a06;
  background: linear-gradient(160deg, var(--gold-soft), var(--gold));
  border-color: transparent;
}

.modal-hint { color: var(--ink-dim); font-size: .85rem; line-height: 1.5; margin-bottom: 14px; }
.modal-hint strong { color: #ff9d78; }

#accountForm { display: flex; flex-direction: column; gap: 10px; }
#accountForm input {
  font: inherit;
  color: var(--ink);
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  padding: 11px 12px;
}
#accountForm input:focus { outline: none; border-color: var(--gold); }

.modal-error { color: #ff9d78; font-size: .85rem; }
.modal-error.hidden { display: none; }
.modal-submit { margin-top: 4px; }

/* ---------- Lobby / open challenges ---------- */

.lobby-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.lobby-actions .btn { flex: 1; }

.lobby-list { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }

.lobby-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
}
.lobby-row .lobby-name { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lobby-row .lobby-elo { color: var(--gold-soft); font-weight: 700; font-size: .9rem; }
.lobby-empty { color: var(--ink-dim); padding: 18px 4px; text-align: center; }

/* ---------- Friends ---------- */

.friends-sub {
  margin: 16px 0 8px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink-dim);
}
#friendsModal .friends-sub:first-of-type { margin-top: 8px; }

/* green/gray presence dot in front of a friend's name */
.friend-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255,255,255,.22);
}
.friend-dot.online {
  background: #4cd964;
  box-shadow: 0 0 8px rgba(76, 217, 100, .7);
}

.friend-search {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 10px;
}
.friend-search:focus { outline: none; border-color: var(--gold); }

/* unread-requests count on the Friends button */
#friendsBtn { position: relative; }
.friends-badge {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #e74c3c;
  color: #fff;
  font-size: .68rem;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}
.friends-badge.hidden { display: none; }

/* small round add-friend button in the duel card */
.match-add {
  width: 24px; height: 24px;
  flex-shrink: 0;
  border: 1px solid rgba(212,162,78,.5);
  border-radius: 50%;
  background: rgba(212,162,78,.12);
  color: var(--gold-soft);
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
  transition: background .15s ease;
}
.match-add:hover { background: rgba(212,162,78,.28); }
.match-add:disabled { cursor: default; opacity: .8; }
.match-add.hidden { display: none; }

/* in-game chat (floating box bottom-right; the challenge toast sits above) */
.chat-box {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: min(300px, calc(100vw - 36px));
  border-radius: 14px;
  background: linear-gradient(165deg, #382718, #241709);
  border: 1px solid rgba(212, 162, 78, .4);
  box-shadow: 0 16px 40px rgba(0,0,0,.6);
}
.chat-box.hidden { display: none; }
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.chat-head .modal-close { position: static; }
.chat-head-btns { display: flex; align-items: center; gap: 2px; }
.chat-mute {
  border: none; background: transparent; cursor: pointer;
  font-size: .95rem; line-height: 1; padding: 4px;
  opacity: .85; transition: opacity .15s ease;
}
.chat-mute:hover { opacity: 1; }
.chat-mute.muted { opacity: .45; }

/* unread count on the duel-card chat button */
#matchChatBtn { position: relative; }
.chat-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 15px; height: 15px;
  padding: 0 3px;
  border-radius: 8px;
  background: #e74c3c;
  color: #fff;
  font-size: .6rem;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
}
.chat-badge.hidden { display: none; }
.chat-msgs {
  height: 180px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px;
  font-size: .88rem;
}
.chat-line { max-width: 85%; padding: 4px 9px; border-radius: 9px; line-height: 1.4; overflow-wrap: break-word; }
.chat-line.mine { align-self: flex-end; background: rgba(212,162,78,.18); color: var(--ink); }
.chat-line.theirs { align-self: flex-start; background: rgba(255,255,255,.07); color: var(--ink); }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid rgba(255,255,255,.1); }
.chat-form input {
  flex: 1; min-width: 0;
  font: inherit; font-size: .85rem;
  color: var(--ink);
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  padding: 7px 10px;
}
.chat-form input:focus { outline: none; border-color: var(--gold); }

/* incoming friend-challenge toast (floats above everything) */
.challenge-toast {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(320px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(165deg, #382718, #241709);
  border: 1px solid rgba(212, 162, 78, .5);
  box-shadow: 0 16px 40px rgba(0,0,0,.6), 0 0 24px rgba(212,162,78,.18);
  animation: cardUp .35s cubic-bezier(.3, 1.4, .5, 1);
}
.challenge-toast.hidden { display: none; }
/* if the chat box is open, the toast moves up instead of covering it */
.chat-box:not(.hidden) ~ .challenge-toast { bottom: 306px; }
.challenge-toast span { font-weight: 700; }
.challenge-btns { display: flex; gap: 8px; }
.challenge-btns .btn-small { flex: 1; }

/* ---------- Leaderboard ---------- */

.lb-table-wrap { overflow-x: auto; }
.lb-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.lb-table th {
  text-align: left; color: var(--ink-dim); font-size: .75rem;
  text-transform: uppercase; letter-spacing: 1px;
  padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.12);
}
.lb-table td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.06); }
.lb-table tr:nth-child(1) td:first-child { color: #f2c14e; font-weight: 800; }
.lb-table tr:nth-child(2) td:first-child { color: #c8c8d0; font-weight: 800; }
.lb-table tr:nth-child(3) td:first-child { color: #c9804a; font-weight: 800; }
.lb-table .lb-elo { color: var(--gold-soft); font-weight: 700; }
.lb-empty { color: var(--ink-dim); padding: 14px 4px; }

.lb-history-title { margin-top: 20px; }
.history-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.history-row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: .88rem;
  padding: 8px 10px;
  background: rgba(255,255,255,.04);
  border-radius: 8px;
}
.history-row .win { color: #8fd18a; font-weight: 700; }
.history-row .loss { color: #ff9d78; font-weight: 700; }
.history-row .delta { color: var(--ink-dim); }

/* ---------- Affiliate column ---------- */

/* base = the "below the game" look (mobile + medium widths): a wide block
   with two cards side by side. It becomes a slim right column only on very
   wide screens (see the min-width rule below), so the board is never shrunk. */
.affiliate {
  width: min(620px, 92vw);
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.affiliate-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ink-dim);
}

/* minmax(0,1fr): columns may shrink below the image's intrinsic 240px —
   plain 1fr let the cards force horizontal scrolling on narrow phones */
.affiliate-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.affiliate-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  text-decoration: none;
  color: var(--ink);
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}
.affiliate-card:hover {
  transform: translateY(-2px);
  border-color: rgba(212, 162, 78, .55);
  box-shadow: 0 10px 24px rgba(0,0,0,.35);
}

.affiliate-img {
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.affiliate-img img { max-width: 100%; max-height: 100%; object-fit: contain; }

.affiliate-name { font-weight: 600; font-size: .92rem; }

.affiliate-cta {
  align-self: flex-start;
  font-size: .8rem;
  font-weight: 700;
  color: #2b1a06;
  background: linear-gradient(160deg, var(--gold-soft), var(--gold));
  padding: 6px 12px;
  border-radius: 8px;
}

.affiliate-disclosure { font-size: .68rem; line-height: 1.45; color: var(--ink-dim); }

/* wide screens: a fixed three-column layout — affiliate LEFT of the board,
   board in the middle, panel on the right. Explicit grid-column placement
   puts the affiliate first regardless of its DOM order (it stays last in
   the markup so it falls BELOW the board on narrower screens). Cards stack
   vertically with a fixed small image height so the column stays compact. */
@media (min-width: 1160px) {
  .arena {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr) 322px;
    gap: 20px;
    align-items: start;
    max-width: 1480px;
  }
  /* pin all three to row 1 — the affiliate is last in the DOM, so without
     an explicit row the auto-placement drops it into a new row below */
  .affiliate  { grid-column: 1; grid-row: 1; width: auto; align-self: start; margin: 0; gap: 10px; }
  .board-wrap { grid-column: 2; grid-row: 1; justify-content: center; }
  .panel      { grid-column: 3; grid-row: 1; width: auto; }
  /* fill the middle column on big screens; the height term still caps the
     board so the panel's online buttons never drop below the fold */
  .board-frame {
    width: min(100%, 900px, (100vh - 150px) * 1.6);
    width: min(100%, 900px, (100dvh - 150px) * 1.6);
  }
  .affiliate-cards { grid-template-columns: 1fr; gap: 10px; }
  .affiliate-img { aspect-ratio: auto; height: 104px; padding: 8px; }
  .affiliate-card { padding: 10px; gap: 6px; }
  .affiliate-name { font-size: .86rem; }
}

/* ---------- Content / SEO section ---------- */

.content {
  width: 100%;
  margin-top: 56px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.18);
}

.content-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 48px 22px 30px;
}

.content h2 {
  color: var(--gold-soft);
  font-size: 1.45rem;
  margin: 34px 0 12px;
}
.content h2:first-child { margin-top: 0; }

.content p {
  color: var(--ink-dim);
  line-height: 1.65;
  max-width: 75ch;
  margin: 0 0 14px; /* the global reset removes paragraph spacing */
}

.content strong { color: var(--ink); font-weight: 600; }

/* intro: text left, featured image right (stacks on small screens) */
.content-intro { display: flex; gap: 26px; align-items: flex-start; }
.content-intro-text { flex: 1; min-width: 0; }
.content-hero {
  width: min(300px, 34vw);
  height: auto;
  flex-shrink: 0;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  box-shadow: 0 10px 28px rgba(0,0,0,.4);
}
@media (max-width: 720px) {
  .content-intro { flex-direction: column; align-items: center; }
  .content-hero { width: min(340px, 86vw); }
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 20px 0 8px;
}

.content-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 18px;
}

.content-card h3 { color: var(--ink); font-size: 1.05rem; margin-bottom: 8px; }
.content-card p { font-size: .92rem; margin-bottom: 0; }

.faq dt {
  color: var(--ink);
  font-weight: 600;
  margin-top: 14px;
}
.faq dd {
  color: var(--ink-dim);
  line-height: 1.55;
  margin: 4px 0 0;
}

.site-footer {
  width: 100%;
  padding: 22px 16px 6px;
  text-align: center;
  color: var(--ink-dim);
  font-size: .85rem;
  border-top: 1px solid rgba(255,255,255,.06);
}
.site-footer a { color: var(--gold-soft); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-links { margin-top: 6px; }
.footer-links a { margin: 0 6px; white-space: nowrap; }

/* ---------- Discord button ---------- */
.discord-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px;
  font-weight: 700; font-size: .9rem; text-decoration: none;
  color: #fff; background: #5865f2;
  transition: filter .15s ease, transform .15s ease;
}
.discord-btn:hover { filter: brightness(1.08); text-decoration: none; }
.discord-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.footer-discord { margin: 10px 0 4px; }
/* full-width variant inside the game panel's "Play Online" section */
.discord-panel { width: 100%; margin-top: 8px; }

/* ---------- Legal pages (privacy, cookies, legal notice) ---------- */

.legal-page { max-width: 860px; margin: 0 auto; padding: 40px 22px 20px; }
.legal-page h1 { color: var(--gold-soft); font-size: clamp(1.5rem, 4vw, 1.9rem); margin: 18px 0 4px; }
.legal-page .updated { color: var(--ink-dim); font-size: .82rem; margin-bottom: 26px; }
.legal-page h2 { color: var(--gold-soft); font-size: 1.2rem; margin: 30px 0 10px; }
.legal-page h3 { color: var(--ink); font-size: 1.02rem; margin: 20px 0 8px; }
.legal-page p { color: var(--ink-dim); line-height: 1.7; margin: 0 0 14px; }
.legal-page ul { color: var(--ink-dim); line-height: 1.7; margin: 0 0 14px; padding-left: 22px; }
.legal-page li { margin-bottom: 7px; }
.legal-page strong { color: var(--ink); font-weight: 600; }
.legal-page a { color: var(--gold-soft); }
.legal-page address { font-style: normal; color: var(--ink-dim); line-height: 1.8; margin-bottom: 14px; }
.legal-page .lead { color: var(--ink); background: var(--card); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 22px; }

.legal-table-wrap { overflow-x: auto; margin: 6px 0 20px; }
.legal-table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 520px; }
.legal-table th, .legal-table td { text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--card-border); color: var(--ink-dim); vertical-align: top; }
.legal-table th { color: var(--ink); font-weight: 600; background: rgba(255,255,255,.03); }
.legal-table code { color: var(--gold-soft); font-size: .85em; }

.back-home { display: inline-block; margin: 26px 0 0; color: var(--gold-soft); text-decoration: none; }
.back-home:hover { text-decoration: underline; }

/* ---------- How-to-play guide ---------- */
.guide-toc { background: var(--card); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 16px 20px; margin: 0 0 30px; }
.guide-toc-title { margin: 0 0 10px; font-size: .95rem; color: var(--ink);
  text-transform: uppercase; letter-spacing: 1px; }
.guide-toc ol { margin: 0; padding-left: 20px; color: var(--ink-dim);
  columns: 2; column-gap: 30px; }
.guide-toc li { margin-bottom: 6px; }
.guide-toc a { color: var(--gold-soft); text-decoration: none; }
.guide-toc a:hover { text-decoration: underline; }

.legal-page h2[id] { scroll-margin-top: 16px; }

.guide-tip { border-left: 3px solid var(--gold); background: rgba(212,162,78,.10);
  border-radius: 0 10px 10px 0; padding: 12px 16px; margin: 4px 0 20px; color: var(--ink); }
.guide-tip strong { color: var(--gold-soft); }

.guide-cta { display: inline-block; margin: 4px 0 8px; padding: 12px 22px;
  font-weight: 800; font-size: 1.02rem; text-decoration: none;
  background: linear-gradient(160deg, var(--gold-soft), var(--gold)); border-radius: 10px;
  box-shadow: 0 4px 14px rgba(212,162,78,.3); }
/* higher specificity than ".legal-page a" (gold-soft), which otherwise
   tinted the label almost the same colour as the gold button */
.legal-page a.guide-cta { color: #2b1a06; }
.guide-cta:hover { filter: brightness(1.05); text-decoration: none; }

.guide-figure { margin: 6px 0 22px; }
.guide-figure img { display: block; width: 100%; height: auto; border-radius: 12px;
  border: 1px solid var(--card-border); box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.guide-figure figcaption { margin-top: 8px; font-size: .82rem; color: var(--ink-dim);
  text-align: center; font-style: italic; }

@media (max-width: 640px) { .guide-toc ol { columns: 1; } }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .arena { flex-direction: column; align-items: center; }
  .panel { width: min(620px, 92vw); }
}

/* touch devices: comfortable targets + no iOS focus-zoom.
   (The sidebar sits BELOW the board here, so taller buttons cost nothing.) */
@media (pointer: coarse) {
  /* iOS zooms the whole page into any focused input below 16px */
  #accountForm input, .friend-search, .chat-form input, #inviteLink {
    font-size: 16px;
  }
  .btn-small { padding: 9px 12px; font-size: .85rem; }
  .player-actions .btn-small { padding: 9px 12px; font-size: .85rem; }
  .mode-btn, .diff-btn { padding: 10px 6px; font-size: .88rem; }
  .match-add { width: 34px; height: 34px; font-size: 1.05rem; }
  .sound-toggle { width: 42px; height: 42px; }
  .modal-close { font-size: 1.15rem; padding: 4px 8px; }
}

/* small screens: reclaim a little vertical room above the board */
@media (max-width: 640px) {
  body { padding: 12px 10px 32px; }
  /* keep the centered logo clear of the sound toggle in the corner —
     "BackgammonWorld" plus its two discs otherwise runs under the button */
  .site-header { margin-bottom: 8px; padding: 0 46px; }
  .logo { font-size: clamp(1.15rem, 4.5vw, 1.7rem); gap: 7px; }
  .sound-toggle { top: 8px; right: 10px; }
  .board-frame {
    width: min(96vw, calc((100vh - 120px) * 1.44), 700px);
    width: min(96vw, calc((100dvh - 120px) * 1.44), 700px);
  }
  /* one affiliate card is enough on a phone — two forced sideways scrolling */
  .affiliate-cards { grid-template-columns: 1fr; }
  .affiliate-card:nth-child(2) { display: none; }
}
