/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fff7ec;
  --surface: #ffffff;
  --ink: #1f2a44;
  --ink-soft: #3b4768;
  --muted: #7c849b;
  --dim: #c2c8d6;
  --border: #ece7df;
  --border-subtle: #f4efe7;
  --accent: #ff7a3d;
  --accent-soft: #fff0e6;
  --accent-glow: rgba(255, 122, 61, 0.18);
  --red: #ef4d5a;
  --red-soft: #fff0f1;
  --gold: #f5b430;
  --gold-soft: #fff7e0;
  --blue: #3d8bff;
  --purple: #8b5cf6;
  --teal: #18c2a8;
  --pink: #ff5fa2;
  --wait-bg: #fff3d6;
  --wait-ink: #9a7212;
  /* Theme-scoped surfaces (overridden per data-theme below) */
  --cell-bg: #ffffff;
  --cell-alt-bg: #fff3e2;
  --cell-ladder-bg: #e8fbf2;
  --cell-snake-bg: #ffeef0;
  --cell-start-bg: #e6fbf5;
  --dice-face-bg: #ffffff;
  --dice-face-bg2: #fff1e2;
  --on-accent: #ffffff;
  --bar-bg: var(--ink);
  --bar-ink: #ffffff;
  --modal-scrim: rgba(0,0,0,0.4);
  --shadow-xs: 0 1px 2px rgba(31,42,68,0.04);
  --shadow-sm: 0 1px 3px rgba(31,42,68,0.06), 0 1px 1px rgba(31,42,68,0.03);
  --shadow: 0 2px 10px rgba(31,42,68,0.07), 0 1px 3px rgba(31,42,68,0.04);
  --shadow-md: 0 6px 20px rgba(31,42,68,0.10), 0 2px 6px rgba(31,42,68,0.05);
  --shadow-lg: 0 16px 48px rgba(31,42,68,0.16), 0 6px 16px rgba(31,42,68,0.06);
  --shadow-pop: 0 5px 0 rgba(31,42,68,0.16);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 22px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Trebuchet MS", "Segoe UI", system-ui, var(--font);
  --mono: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-premium: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ═══════════════════ THEMES ═══════════════════ */

[data-theme="dark"] {
  --bg: #141824;
  --surface: #1e2330;
  --ink: #e9edf6;
  --ink-soft: #b9c2d6;
  --muted: #8a93a8;
  --dim: #4a5266;
  --border: #2a3142;
  --border-subtle: #232a39;
  --accent-soft: #2a2233;
  --red-soft: #2c1f24;
  --gold-soft: #2c2716;
  --wait-bg: #2a2716;
  --wait-ink: #e6c878;
  --cell-bg: #232a39;
  --cell-alt-bg: #1f2533;
  --cell-ladder-bg: #1e3330;
  --cell-snake-bg: #33232a;
  --cell-start-bg: #1e3330;
  --dice-face-bg: #2a3142;
  --dice-face-bg2: #232a39;
  --on-accent: #141824;
  --bar-bg: #0e1119;
  --bar-ink: #e9edf6;
  --modal-scrim: rgba(0,0,0,0.62);
}

[data-theme="neon"] {
  --bg: #0a0e1a;
  --surface: #121a2e;
  --ink: #eafff9;
  --ink-soft: #a9c7d6;
  --muted: #6f8aa0;
  --dim: #2f4358;
  --border: #1d3050;
  --border-subtle: #16263f;
  --accent: #00ffd1;
  --accent-soft: #07242c;
  --accent-glow: rgba(0, 255, 209, 0.28);
  --red: #ff2bd6;
  --red-soft: #2a0f29;
  --gold: #ffe83d;
  --gold-soft: #2c2a0f;
  --blue: #2b6bff;
  --purple: #b14dff;
  --teal: #00ffd1;
  --pink: #ff2bd6;
  --wait-bg: #122436;
  --wait-ink: #67e8f9;
  --cell-bg: #101a30;
  --cell-alt-bg: #0d1628;
  --cell-ladder-bg: #0d2630;
  --cell-snake-bg: #2a0f29;
  --cell-start-bg: #0d2630;
  --dice-face-bg: #16233f;
  --dice-face-bg2: #101a30;
  --on-accent: #04121a;
  --bar-bg: #060a14;
  --bar-ink: #eafff9;
  --modal-scrim: rgba(2, 6, 16, 0.7);
}

[data-theme="retro"] {
  --bg: #f4ecd8;
  --surface: #fbf6e9;
  --ink: #3a2e1e;
  --ink-soft: #5b4a32;
  --muted: #8a7656;
  --dim: #c4b393;
  --border: #ddccab;
  --border-subtle: #e8dcc1;
  --accent: #d2691e;
  --accent-soft: #f6e6d2;
  --accent-glow: rgba(210, 105, 30, 0.2);
  --red: #b5402f;
  --red-soft: #f3e0d6;
  --gold: #c79a1e;
  --gold-soft: #f6ebcc;
  --blue: #3f6d8c;
  --purple: #8a5a8f;
  --teal: #2e7d5b;
  --pink: #c45d7c;
  --wait-bg: #f1e3c4;
  --wait-ink: #8a6a1f;
  --cell-bg: #fbf6e9;
  --cell-alt-bg: #f1e6cd;
  --cell-ladder-bg: #e6f0dc;
  --cell-snake-bg: #f3e0d6;
  --cell-start-bg: #e6f0dc;
  --dice-face-bg: #fbf6e9;
  --dice-face-bg2: #f1e6cd;
  --on-accent: #fbf6e9;
  --bar-bg: #3a2e1e;
  --bar-ink: #f4ecd8;
  --modal-scrim: rgba(58, 46, 30, 0.5);
}

html { height: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(45, 138, 94, 0.15);
  color: var(--ink);
}

.hidden { display: none !important; }

/* ── Focus ── */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ═══════════════════ LOBBY ═══════════════════ */

.lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

.lobby-inner {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

/* ── [TITLE REDESIGN] Branded game typography ── */

.lobby-title {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 14px;
  text-align: center;
}

.title-word {
  display: block;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(120deg, var(--accent), var(--pink), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 2px 1px rgba(31,42,68,0.12));
}

.title-word:last-of-type {
  background: linear-gradient(120deg, var(--blue), var(--teal), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
}

.title-amp {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
  font-style: normal;
  color: var(--gold);
  letter-spacing: 0.04em;
  margin: 6px 0 4px;
}

.lobby-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 28px;
  letter-spacing: 0.005em;
}

.lobby-sub.error {
  color: var(--red);
  font-weight: 600;
}

/* ── [FOOTNOTE] Quiet brand attribution ── */

.lobby-footnote {
  margin-top: 32px;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  opacity: 0.55;
  text-align: center;
}

.lobby-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  text-align: left;
}

label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 6px;
}

input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--surface);
  margin-bottom: 16px;
  min-height: 44px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input::placeholder {
  color: var(--dim);
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#roomCodeInput {
  text-transform: uppercase;
  font-family: var(--mono);
  font-size: 0.88rem;
  letter-spacing: 0.12em;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  min-height: 44px;
  letter-spacing: 0.005em;
  transition: background 0.18s var(--ease), opacity 0.18s var(--ease), transform 0.1s var(--ease), box-shadow 0.18s var(--ease);
}

.btn-block { width: 100%; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-pop);
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.05); }
.btn-primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 rgba(31,42,68,0.16); }

.btn-outline {
  background: var(--surface);
  color: var(--ink);
}

.btn-outline:hover:not(:disabled) { background: var(--bg); }
.btn-outline:active:not(:disabled) { transform: scale(0.985); }

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.divider {
  text-align: center;
  margin: 22px 0;
  position: relative;
}

.divider::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: var(--border);
}

.divider span {
  background: var(--surface);
  padding: 0 14px;
  font-size: 0.75rem;
  color: var(--dim);
  position: relative;
  letter-spacing: 0.02em;
}

/* ═══════════════════ GAME SCREEN ═══════════════════ */

.game-screen {
  max-width: 820px;
  margin: 0 auto;
  padding-bottom: 24px;
}

/* ── Room bar ── */

.room-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bar-bg);
  color: var(--bar-ink);
  padding: 10px 18px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.room-tag {
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.4;
}

.room-code {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  flex: 1;
  opacity: 0.9;
}

.bar-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px;
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.65);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 5px 10px;
  min-height: 28px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.bar-btn:hover {
  background: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.9);
}

/* ── Player strip ── */

.player-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.p-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease), box-shadow 0.3s var(--ease);
  min-width: 0;
  background: var(--surface);
}

.p-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.p-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(31,42,68,0.55);
  flex-shrink: 0;
  transition: transform 0.3s var(--ease-bounce);
  box-shadow: var(--shadow-xs);
}

.p-card.active .p-dot {
  transform: scale(1.18) rotate(-8deg);
}

.p-dot {
  --tok: var(--blue);
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--tok) 42%, #fff), var(--tok) 72%);
}
.p-dot.black { --tok: var(--blue); }
.p-dot.white { --tok: var(--pink); }
.p-dot.token-emoji {
  background: none;
  border: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.p-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.p-name {
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.p-pos {
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.vs-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--dim);
  text-transform: lowercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* ── Presence indicator ── */

.p-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
  margin-left: auto;
  transition: background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.p-online.online {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ── Turn banner ── */

.turn-banner {
  padding: 10px 18px;
  text-align: center;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  transition: background 0.35s var(--ease), color 0.35s var(--ease);
}

.turn-banner.state-go {
  background: var(--accent);
  color: #fff;
  animation: banner-pop 0.45s var(--ease-bounce);
}

@keyframes banner-pop {
  0%   { transform: scale(0.96); }
  55%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.turn-banner.state-wait {
  background: var(--wait-bg);
  color: var(--wait-ink);
}

.turn-banner.state-win {
  background: var(--gold-soft);
  color: #6d5a13;
}

/* ── Game layout ── */

.game-layout {
  display: grid;
  grid-template-columns: 1fr 148px;
  gap: 18px;
  padding: 18px;
}

/* [HOP ANIMATION] position: relative creates positioning context for ghost token */
.board-frame {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--ink-soft);
  border-radius: var(--radius);
  padding: 3px;
  box-shadow: var(--shadow);
}

/* ── Board ── */

.board {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  background: linear-gradient(135deg, var(--blue), var(--purple), var(--pink), var(--accent));
  aspect-ratio: 1;
  position: relative;
  border-radius: calc(var(--radius) - 5px);
  overflow: hidden;
}

.board-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cell {
  position: relative;
  background: var(--cell-bg);
  padding: 2px 3px;
  min-width: 0;
  overflow: hidden;
}

.cell.cell-alt {
  background: var(--cell-alt-bg);
}

.cell-num {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.cell.has-ladder { background: var(--cell-ladder-bg); }
.cell.has-snake  { background: var(--cell-snake-bg); }
.cell.cell-start { background: var(--cell-start-bg); }
.cell.cell-end   { background: var(--gold-soft); box-shadow: inset 0 0 14px rgba(245,180,48,0.45); }

.cell-tag {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 0.42rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--on-accent);
  padding: 1px 4px;
  border-radius: 99px;
  line-height: 1.2;
}

.cell.cell-start .cell-tag { background: var(--teal); }
.cell.cell-end .cell-tag   { background: var(--gold); }

.jump-lbl {
  position: absolute;
  right: 2px;
  top: 1px;
  font-size: 0.46rem;
  font-weight: 600;
  line-height: 1;
  opacity: 0.65;
}

.jump-lbl { font-weight: 700; }
.jump-lbl.ladder { color: var(--teal); }
.jump-lbl.snake  { color: var(--red); }

.ls-you {
  font-size: 0.72rem;
  color: var(--muted);
  flex-shrink: 0;
}

/* ── Tokens ── */

.tokens {
  position: absolute;
  bottom: 2px;
  right: 2px;
  display: flex;
  gap: 2px;
}

.token {
  --tok: var(--blue);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(31,42,68,0.55);
  box-shadow: 0 2px 4px rgba(31,42,68,0.28), inset 0 1px 2px rgba(255,255,255,0.5);
  transition: opacity 0.08s var(--ease);
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--tok) 42%, #fff), var(--tok) 72%);
}

.token.token-emoji {
  background: none;
  border: none;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
}

/* [PIECE HOP] Bouncier landing for playful arrival */
.token.bounce {
  animation: tk-land 0.36s var(--ease-bounce);
}

@keyframes tk-land {
  0%   { transform: scale(0.7); }
  60%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* ── [PIECE HOP] Ghost token for movement animation ── */

.ghost-token {
  --tok: var(--blue);
  position: absolute;
  z-index: 10;
  pointer-events: none;
  border-radius: 50%;
  border: 2px solid rgba(31,42,68,0.55);
  box-shadow: 0 2px 6px rgba(31,42,68,0.28), inset 0 1px 2px rgba(255,255,255,0.5);
  will-change: left, top, transform;
  width: 16px;
  height: 16px;
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--tok) 42%, #fff), var(--tok) 72%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.ghost-token.token-emoji {
  background: none;
  border: none;
}

/* [LADDER TRAVERSAL] Bright teal glow during climb */
.ghost-token.climb-glow {
  box-shadow: 0 0 14px rgba(24, 194, 168, 0.7), 0 2px 6px rgba(31,42,68,0.2);
}

/* [SNAKE DESCENT] Bright red glow during descent */
.ghost-token.descend-glow {
  box-shadow: 0 0 14px rgba(239, 77, 90, 0.6), 0 2px 6px rgba(31,42,68,0.2);
}

/* ── Side column ── */

.side-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 4px;
}

.dice {
  --die-size: 62px;
  --die-half: 31px;
  width: 66px;
  height: 66px;
  background: linear-gradient(150deg, var(--dice-face-bg), var(--dice-face-bg2));
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-pop);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
  perspective: 340px;
  position: relative;
}

.dice.your-turn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow-pop);
}

.dice.rolling {
  animation: dice-pulse 0.5s var(--ease-bounce);
}

@keyframes dice-pulse {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* [3D DICE] CSS cube with pip faces */
.dice-cube {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--die-size);
  height: var(--die-size);
  transform-style: preserve-3d;
  transform: rotateX(0) rotateY(0);
}

.die-face {
  position: absolute;
  width: var(--die-size);
  height: var(--die-size);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 8px;
  gap: 1px;
  border-radius: var(--radius-sm);
  background: linear-gradient(150deg, var(--dice-face-bg), var(--dice-face-bg2));
  border: 2px solid var(--border);
  backface-visibility: hidden;
}

.die-pip-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.die-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 -1px 1px rgba(0,0,0,0.18);
}

/* Numeric glyph: screen-reader fallback by default; visible under reduced motion */
.dice-val {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.side-hint {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.board-label {
  margin-top: auto;
  font-size: 0.66rem;
  opacity: 0.7;
}

/* ── Roll button ── */

.roll-btn {
  width: 100%;
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  padding: 13px 12px;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  min-height: 48px;
  box-shadow: var(--shadow-pop);
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.1s var(--ease), box-shadow 0.18s var(--ease);
}

.roll-btn:hover:not(:disabled) { filter: brightness(1.06); }
.roll-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 rgba(31,42,68,0.16); }

.roll-btn:disabled {
  background: var(--bg);
  border-color: var(--border);
  color: var(--dim);
  cursor: not-allowed;
  box-shadow: none;
}

.roll-btn.pulse {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
  animation: roll-glow 1.8s ease-in-out infinite;
}

@keyframes roll-glow {
  0%, 100% { box-shadow: var(--shadow-pop), 0 0 0 0 rgba(255, 122, 61, 0.45); }
  50%      { box-shadow: var(--shadow-pop), 0 0 0 8px rgba(255, 122, 61, 0); }
}

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 22px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 100;
  animation: toast-up 0.25s var(--ease-premium);
  max-width: 88vw;
  text-align: center;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  letter-spacing: 0.005em;
}

@keyframes toast-up {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Log panel ── */

.log-panel {
  margin: 0 18px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.log-panel summary {
  padding: 12px 18px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.18s var(--ease);
}

.log-panel summary:hover {
  color: var(--ink-soft);
}

.log {
  padding: 0 18px 14px;
  max-height: 200px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.log::-webkit-scrollbar { width: 4px; }
.log::-webkit-scrollbar-track { background: transparent; }
.log::-webkit-scrollbar-thumb { background: var(--dim); border-radius: 2px; }

.log-entry {
  padding: 6px 0;
  font-size: 0.76rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--ink-soft);
  line-height: 1.4;
}

.log-entry:last-child { border-bottom: none; }

/* ═══════════════════ WIN OVERLAY ═══════════════════ */

.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fade-in 0.3s var(--ease);
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.win-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  text-align: center;
  max-width: 300px;
  width: 88%;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.35s var(--ease-premium);
}

@keyframes pop-in {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.win-crown {
  font-size: 2.9rem;
  margin-bottom: 6px;
  display: inline-block;
  animation: crown-bounce 0.9s var(--ease-bounce) 0.15s both;
}

@keyframes crown-bounce {
  0%   { transform: scale(0) rotate(-30deg); }
  60%  { transform: scale(1.25) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}

/* [CONFETTI] Full-screen overlay canvas for win burst + ladder sparkle */
.fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 300;
}
.win-box h2 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 8px; }
.win-box p  { color: var(--muted); margin-bottom: 28px; font-size: 0.88rem; line-height: 1.45; }

.win-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ═══════════════════ NEW UI: lobby controls, modals, themes, power-ups ═══════════════════ */

.lobby-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 18px;
}

.lobby-controls .bar-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--ink-soft);
  min-height: 34px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
}

.lobby-controls .bar-btn:hover {
  background: var(--bg);
  color: var(--ink);
}

/* Avatar / token picker */
.avatar-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.avatar-opt {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding: 0;
  transition: transform 0.12s var(--ease-bounce), border-color 0.15s var(--ease);
}

.avatar-opt.swatch {
  background: radial-gradient(circle at 32% 28%, color-mix(in srgb, var(--tok) 42%, #fff), var(--tok) 72%);
}

.avatar-opt.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  transform: scale(1.1);
}

/* Modal overlays (local setup, stats) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 220;
  padding: 20px;
  animation: fade-in 0.25s var(--ease);
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 26px;
  width: 100%;
  max-width: 360px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.3s var(--ease-premium);
  text-align: left;
}

.modal-box h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}

.modal-box select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--surface);
  margin-bottom: 14px;
  min-height: 44px;
}

.ls-seats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.ls-seat {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ls-seat input[type="text"] {
  flex: 1;
  margin-bottom: 0;
}

.ls-seat select {
  width: auto;
  margin-bottom: 0;
  flex-shrink: 0;
}

.ls-check {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 14px;
  cursor: pointer;
}

.ls-check input { width: auto; margin: 0; min-height: 0; }

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

/* Stats */
.stats-body { margin-bottom: 18px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stat-lbl {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stats-recent {
  font-size: 0.78rem;
  color: var(--ink-soft);
  max-height: 160px;
  overflow-y: auto;
}

.stats-recent-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.stats-recent-row .res-win { color: var(--teal); font-weight: 700; }
.stats-recent-row .res-loss { color: var(--red); font-weight: 700; }

/* Local multi-player strip */
.local-strip { flex-wrap: wrap; }
.local-strip .p-card { flex: 1 1 40%; }

/* Turn timer */
.turn-timer {
  height: 4px;
  background: var(--border-subtle);
  overflow: hidden;
}

.turn-timer-bar {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left center;
  transition: transform 0.25s linear;
}

.turn-timer-bar.low { background: var(--red); }

/* Emote bar + floating bubbles */
.emote-bar {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 8px 14px 0;
  flex-wrap: wrap;
}

.emote-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  border-radius: 99px;
  font-size: 1.05rem;
  line-height: 1;
  padding: 5px 9px;
  cursor: pointer;
  min-height: 34px;
  transition: transform 0.12s var(--ease-bounce), background 0.15s var(--ease);
}

.emote-btn:hover { background: var(--bg); transform: translateY(-2px); }

.emote-bubble {
  position: fixed;
  z-index: 60;
  font-size: 1.6rem;
  pointer-events: none;
  animation: emote-float 1.6s var(--ease-premium) forwards;
}

@keyframes emote-float {
  0%   { opacity: 0; transform: translateY(6px) scale(0.6); }
  20%  { opacity: 1; transform: translateY(-4px) scale(1.15); }
  70%  { opacity: 1; transform: translateY(-22px) scale(1); }
  100% { opacity: 0; transform: translateY(-44px) scale(0.9); }
}

/* [SCREEN SHAKE] snake bite */
.board-frame.shake {
  animation: screen-shake 0.42s var(--ease);
}

@keyframes screen-shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-5px, 3px) rotate(-0.6deg); }
  30% { transform: translate(5px, -2px) rotate(0.5deg); }
  45% { transform: translate(-4px, 2px) rotate(-0.4deg); }
  60% { transform: translate(4px, -3px) rotate(0.3deg); }
  80% { transform: translate(-2px, 1px); }
}

/* [BOARD DRIFT] subtle animated gradient behind the cells */
.board {
  background-size: 220% 220%;
  animation: board-drift 22s ease-in-out infinite;
}

@keyframes board-drift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ═══════════════════ VICTORY RUN + SPLASH ═══════════════════ */

/* Slow-mo vignette: darkens the periphery while the board (centre) stays bright,
   spotlighting the dash to 100. pointer-events:none keeps the emote bar tappable. */
body.victory-slowmo::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(0,0,0,0) 45%, rgba(0,0,0,0.5) 100%);
  pointer-events: none;
  z-index: 150;
  animation: fade-in 0.4s var(--ease);
}

.victory-ring {
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 4px solid var(--ring, var(--gold));
  pointer-events: none;
  z-index: 290;
  transform: translate(-50%, -50%) scale(0.2);
  animation: victory-ring-expand 0.9s var(--ease-premium) forwards;
}

@keyframes victory-ring-expand {
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 0.95; }
  100% { transform: translate(-50%, -50%) scale(6);   opacity: 0; }
}

.victory-flash {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.85), rgba(255,255,255,0));
  pointer-events: none;
  z-index: 285;
  animation: victory-flash-fade 0.5s ease forwards;
}

@keyframes victory-flash-fade {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ═══════════════════ TURN SPOTLIGHT + POWER-UP FX ═══════════════════ */

/* Pulsing ring on the active player's board token. */
.token.turn-glow {
  animation: turn-pulse 1.6s ease-in-out infinite;
}

@keyframes turn-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255,122,61,0.30), 0 2px 4px rgba(31,42,68,0.28), inset 0 1px 2px rgba(255,255,255,0.5); }
  50%      { box-shadow: 0 0 0 4px rgba(255,122,61,0.45), 0 0 10px 2px var(--accent-glow), 0 2px 4px rgba(31,42,68,0.28), inset 0 1px 2px rgba(255,255,255,0.5); }
}

/* Shield bubble around a protected token. */
.token.shielded { position: relative; }
.token.shielded::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--teal);
  box-shadow: 0 0 8px rgba(24,194,168,0.7);
  animation: shield-pulse 1.4s ease-in-out infinite;
}

@keyframes shield-pulse {
  0%, 100% { transform: scale(1);    opacity: 0.8; }
  50%      { transform: scale(1.12); opacity: 1; }
}

/* Active-card sweep on a turn change. */
.p-card.spotlight { position: relative; overflow: hidden; }
.p-card.spotlight::before {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 50%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.5), transparent);
  transform: skewX(-18deg);
  pointer-events: none;
  animation: card-sweep 1.1s var(--ease);
}

@keyframes card-sweep {
  0%   { left: -60%; }
  100% { left: 120%; }
}

.p-card.waiting {
  opacity: 0.6;
  border-style: dashed;
}

/* Double-roll dice glow. */
.dice.power-glow {
  border-color: var(--purple);
  animation: dice-power 0.9s var(--ease);
}

@keyframes dice-power {
  0%, 100% { box-shadow: var(--shadow-pop); }
  50%      { box-shadow: 0 0 0 4px rgba(139,92,246,0.4), 0 0 16px 4px rgba(139,92,246,0.5), var(--shadow-pop); }
}

/* Snake-bite chomp flash at the head square. */
.snake-chomp {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background: radial-gradient(circle at 50% 50%, rgba(239,77,90,0.55), rgba(239,77,90,0));
  animation: chomp 0.46s var(--ease-bounce);
}

@keyframes chomp {
  0%   { transform: scale(0.4); opacity: 0; }
  35%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Hidden power/mystery tile reveal — a slow reveal once a token lands: the cell
   glows and a labelled badge (icon + name) rises, holds, then fades, so the player
   sees WHAT it is before the effect takes hold. Duration mirrors TILE_REVEAL_MS. */
.tile-reveal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 12;
  border-radius: inherit;
  animation: tile-reveal-glow 1.5s var(--ease-premium) forwards;
}
.tile-reveal-power   { background: radial-gradient(circle at 50% 50%, rgba(255,122,61,0.6), rgba(255,122,61,0)); }
.tile-reveal-mystery { background: radial-gradient(circle at 50% 50%, rgba(139,92,246,0.6), rgba(139,92,246,0)); }

.tile-reveal-icon {
  font-size: 1.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(31,42,68,0.45));
  transform-origin: center bottom;
  animation: tile-reveal-icon 1.5s var(--ease-bounce) forwards;
}

/* The name badge floats just above the cell so it's legible over the token. */
.tile-reveal-label {
  position: absolute;
  bottom: 100%;
  margin-bottom: 2px;
  white-space: nowrap;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(31, 42, 68, 0.92);
  padding: 2px 7px;
  border-radius: 99px;
  box-shadow: 0 2px 6px rgba(31, 42, 68, 0.35);
  animation: tile-reveal-label 1.5s var(--ease-premium) forwards;
}
.tile-reveal-mystery .tile-reveal-label { background: rgba(91, 33, 182, 0.95); }

@keyframes tile-reveal-glow {
  0%   { transform: scale(0.6); opacity: 0; }
  16%  { transform: scale(1.15); opacity: 1; }
  80%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}
@keyframes tile-reveal-icon {
  0%   { transform: scale(0) translateY(4px) rotate(-12deg); }
  20%  { transform: scale(1.6) translateY(-4px) rotate(6deg); }
  34%  { transform: scale(1.3) translateY(-6px) rotate(0deg); }
  80%  { transform: scale(1.3) translateY(-6px); opacity: 1; }
  100% { transform: scale(1.0) translateY(-10px); opacity: 0; }
}
@keyframes tile-reveal-label {
  0%   { transform: translateY(6px) scale(0.6); opacity: 0; }
  22%  { transform: translateY(0) scale(1); opacity: 1; }
  80%  { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-6px) scale(0.95); opacity: 0; }
}

/* ═══════════════════ DICE SKINS ═══════════════════ */

.dice.dice-skin-gold { --dice-face-bg: #fff3cf; --dice-face-bg2: #f3c95a; }
.dice.dice-skin-gold .die-face { border-color: #e0b341; }
.dice.dice-skin-gold .die-pip  { background: #6e4f0e; box-shadow: inset 0 -1px 1px rgba(0,0,0,0.25); }

.dice.dice-skin-neon { --dice-face-bg: #161a2b; --dice-face-bg2: #232a45; }
.dice.dice-skin-neon .die-face { border-color: #00e5ff; }
.dice.dice-skin-neon .die-pip  { background: #00e5ff; box-shadow: 0 0 6px #00e5ff; }

.dice.dice-skin-wood { --dice-face-bg: #d8a566; --dice-face-bg2: #a9763f; }
.dice.dice-skin-wood .die-face { border-color: #7c4f25; }
.dice.dice-skin-wood .die-pip  { background: #fff3df; box-shadow: inset 0 -1px 1px rgba(0,0,0,0.3); }

/* Dice skin picker (lobby). */
.dice-skin-pick {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.dice-skin-opt {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s var(--ease-bounce), border-color 0.15s var(--ease);
}

.dice-skin-opt .dsp-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dice-skin-opt.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  transform: scale(1.1);
}

.dice-skin-opt.dice-skin-classic { background: linear-gradient(150deg, var(--dice-face-bg), var(--dice-face-bg2)); }
.dice-skin-opt.dice-skin-classic .dsp-pip { background: var(--accent); }
.dice-skin-opt.dice-skin-gold { background: linear-gradient(150deg, #fff3cf, #f3c95a); }
.dice-skin-opt.dice-skin-gold .dsp-pip { background: #6e4f0e; }
.dice-skin-opt.dice-skin-neon { background: linear-gradient(150deg, #161a2b, #232a45); }
.dice-skin-opt.dice-skin-neon .dsp-pip { background: #00e5ff; box-shadow: 0 0 5px #00e5ff; }
.dice-skin-opt.dice-skin-wood { background: linear-gradient(150deg, #d8a566, #a9763f); }
.dice-skin-opt.dice-skin-wood .dsp-pip { background: #fff3df; }

/* ═══════════════════ STRIP / FORFEIT / START PEN / STANDINGS ═══════════════════ */

/* Wrap 3-4 cards onto two rows (online strip; local already wraps). */
.player-strip.wrap { flex-wrap: wrap; }
.player-strip.wrap .p-card { flex: 1 1 40%; }

/* A player who left the game. */
.p-card.forfeited {
  opacity: 0.5;
  border-style: dashed;
}
.p-card.forfeited .p-name { text-decoration: line-through; }

/* Start pen — shows pieces that haven't moved yet, on the board frame. */
.start-pen {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 92%;
  padding: 5px 10px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  box-shadow: var(--shadow-sm);
  z-index: 14;
  pointer-events: none;
}
.start-pen-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.start-chip {
  display: flex;
  align-items: center;
  gap: 4px;
}
.start-chip .token { position: static; }
.token-label {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* Final standings in the win overlay. */
.win-standings {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 2px 0 22px;
  text-align: left;
}
.standing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 0.8rem;
}
.standing-row.winner {
  background: var(--gold-soft);
  font-weight: 700;
}
.standing-rank {
  font-weight: 700;
  color: var(--muted);
  min-width: 22px;
}
.standing-dot {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.standing-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.standing-pos {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.74rem;
}

/* ═══════════════════ ACCESSIBILITY ═══════════════════ */

/* [REDUCED MOTION] Gracefully degrade all animations */
@media (prefers-reduced-motion: reduce) {
  .token.bounce { animation: none; }
  .dice.rolling { animation: none; }
  .roll-btn.pulse { animation: none; }
  .ghost-token { display: none !important; }
  .toast { animation: none; }
  .win-overlay { animation: none; }
  .win-box { animation: none; }
  .win-crown { animation: none; }
  .turn-banner.state-go { animation: none; }
  .fx-canvas { display: none !important; }
  .board { animation: none; }
  .board-frame.shake { animation: none; }
  .emote-bubble { animation: none; }
  .victory-ring, .victory-flash, .snake-chomp, .tile-reveal { display: none !important; }
  body.victory-slowmo::after { display: none !important; }
  .token.turn-glow { animation: none; }
  .token.shielded::after { animation: none; }
  .p-card.spotlight::before { display: none; }
  .dice.power-glow { animation: none; }
  .modal-overlay { animation: none; }
  .modal-box { animation: none; }
  /* Hide the 3D cube, show the numeric glyph instead */
  .dice-cube { display: none !important; }
  .dice-val {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    clip-path: none;
    font-size: 2.1rem;
    line-height: 1;
    color: var(--accent);
  }
}

/* ═══════════════════ RESPONSIVE ═══════════════════ */

@media (max-width: 600px) {
  .game-layout {
    grid-template-columns: 1fr;
    padding: 10px;
    gap: 12px;
  }

  .board-frame { padding: 2px; }

  .side-col {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    align-items: center;
    padding: 0;
  }

  .side-col > .dice {
    grid-row: 1;
    grid-column: 1;
    width: 56px;
    height: 56px;
    --die-size: 52px;
    --die-half: 26px;
  }

  .dice-val { font-size: 1.8rem; }

  .side-col > .roll-btn {
    grid-row: 1;
    grid-column: 2;
    max-width: none;
  }

  .side-col > .side-hint:not(.board-label) {
    grid-row: 2;
    grid-column: 1 / -1;
    text-align: left;
  }

  .side-col > .board-label {
    grid-row: 3;
    grid-column: 1 / -1;
    margin-top: 0;
    text-align: left;
  }

  .player-strip {
    padding: 12px 14px;
    gap: 6px;
  }

  .p-card { padding: 8px 10px; gap: 8px; }
  .p-name { font-size: 0.78rem; }
  .cell-num { font-size: 0.55rem; }
  .jump-lbl { font-size: 0.42rem; }
  .token { width: 14px; height: 14px; }
  .ghost-token { width: 14px; height: 14px; }
  .room-bar { padding: 10px 14px; }
  .turn-banner { padding: 10px 14px; }
  .log-panel { margin: 0 14px 14px; }
  .toast { bottom: 16px; }

  /* Mute toggle gets a comfortable tap target on touch screens */
  #muteBtn { min-width: 44px; min-height: 36px; font-size: 0.95rem; }
}

/* Portrait phones: reclaim vertical space so the board sits higher and larger */
@media (max-width: 600px) and (orientation: portrait) {
  .room-bar { padding: 8px 14px; }
  .player-strip { padding: 10px 14px; }
  .turn-banner { padding: 8px 14px; }
  .game-layout { padding-top: 8px; }
}

@media (max-width: 380px) {
  .title-word { font-size: 2rem; }
  .lobby-card { padding: 22px 18px; }
  .side-col > .dice { width: 48px; height: 48px; --die-size: 44px; --die-half: 22px; }
  .dice-val { font-size: 1.6rem; }
  .roll-btn { min-height: 46px; font-size: 0.92rem; }
}
