/* Snakes & Ladders — pairs with ../../shared.css */
:root {
  --c-red: #c0392b;
  --c-green: #2d8a4f;
  --c-yellow: #d4a017;
  --c-blue: #1f3a5f;
  --c-red-soft: #f1c6c1;
  --c-green-soft: #c6e0cf;
  --c-yellow-soft: #f1dfae;
  --c-blue-soft: #c4cfdb;

  --sl-board-light: #fbf6ea;
  --sl-board-dark: #f0e6cf;
  --sl-board-line: #b8a97a;
  --sl-square-num: #7a6a3f;
  --sl-snake: #2d8a4f;
  --sl-snake-belly: #a8d8b8;
  --sl-ladder: #a06a2b;
  --sl-ladder-light: #d09858;
}

[data-theme='dark'] {
  --sl-board-light: #263042;
  --sl-board-dark: #2f3a52;
  --sl-board-line: #4a5470;
  --sl-square-num: #b8c0d4;
  --sl-snake: #4fbc72;
  --sl-snake-belly: #2d5a3d;
  --sl-ladder: #d09858;
  --sl-ladder-light: #f0b878;
}

.game-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.game-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 32px;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
  line-height: 1;
}
.game-sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

/* Setup screen (matches Ludo) */
.setup {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  box-shadow: var(--shadow);
}
.setup h2 {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 22px;
  margin: 0 0 4px;
}
.setup-help { color: var(--muted); margin: 0 0 18px; font-size: 13px; }

.seat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 620px) { .seat-grid { grid-template-columns: 1fr; } }

.seat {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.seat strong {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 700;
  min-width: 60px;
}
.dot {
  width: 18px; height: 18px; border-radius: 50%;
  box-shadow: 0 1px 0 rgba(0,0,0,0.08), inset 0 -2px 0 rgba(0,0,0,0.15);
}
.seat-opts {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  margin-left: auto;
}
.seat-opts .opt {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 600 12px 'Inter', sans-serif;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.seat-opts .opt:hover { color: var(--ink); }
.seat-opts .opt.is-active {
  background: var(--accent);
  color: var(--paper);
}

.setup-actions { display: flex; justify-content: flex-end; }

/* Play layout */
.play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: start;
}
.play[hidden] { display: none; }
.setup[hidden] { display: none; }
@media (max-width: 900px) {
  .play { grid-template-columns: 1fr; }
}

.board-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

/* Board itself — a square viewport we scale into */
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 640px;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: var(--sl-board-light);
  border: 2px solid var(--sl-board-line);
}
.board-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.tokens-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Grid squares are drawn inside board-svg. Numbers use text elements. */
.sq {
  stroke: var(--sl-board-line);
  stroke-width: 1;
}
.sq-light { fill: var(--sl-board-light); }
.sq-dark  { fill: var(--sl-board-dark); }
.sq-num {
  font: 500 22px 'Inter', sans-serif;
  fill: var(--sl-square-num);
  text-anchor: end;
  dominant-baseline: hanging;
  pointer-events: none;
}
.sq-100 { fill: var(--c-yellow); opacity: 0.35; }
.sq-100-label {
  font: 700 30px 'Fraunces', Georgia, serif;
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: middle;
}

/* Snakes and ladders on the SVG */
.ladder-rail {
  stroke: var(--sl-ladder);
  stroke-width: 6;
  stroke-linecap: round;
  fill: none;
}
.ladder-rung {
  stroke: var(--sl-ladder-light);
  stroke-width: 4;
  stroke-linecap: round;
}
.snake-body {
  stroke: var(--sl-snake);
  stroke-width: 12;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.snake-belly {
  stroke: var(--sl-snake-belly);
  stroke-width: 5;
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 4 4;
  opacity: 0.7;
}
.snake-head {
  fill: var(--sl-snake);
  stroke: var(--ink);
  stroke-width: 1;
}
.snake-eye { fill: #fff; }
.snake-pupil { fill: #000; }

/* Tokens */
.token {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.3);
  box-shadow:
    0 3px 6px rgba(0,0,0,0.22),
    0 2px 0 rgba(0,0,0,0.18),
    inset 0 -3px 0 rgba(0,0,0,0.22),
    inset 0 2px 0 rgba(255,255,255,0.4);
  transform: translate(-50%, -50%);
  /* Smooth hop — slight overshoot on landing (cubic-bezier back-out). */
  transition:
    left 210ms cubic-bezier(0.34, 1.5, 0.6, 1),
    top 210ms cubic-bezier(0.34, 1.5, 0.6, 1);
  z-index: 5;
}
.token[data-color='red']    { background: radial-gradient(circle at 35% 30%, #e05545, var(--c-red)); }
.token[data-color='green']  { background: radial-gradient(circle at 35% 30%, #4bb075, var(--c-green)); }
.token[data-color='yellow'] { background: radial-gradient(circle at 35% 30%, #ecc040, var(--c-yellow)); }
.token[data-color='blue']   { background: radial-gradient(circle at 35% 30%, #4a6a95, var(--c-blue)); }
.token.is-active {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  z-index: 10;
}
/* Snake slide — smooth curved ease-in-out, longer duration */
.token.is-sliding {
  transition:
    left 800ms cubic-bezier(0.55, 0.05, 0.35, 1),
    top 800ms cubic-bezier(0.55, 0.05, 0.35, 1);
}
/* Ladder climb — gentle ease-out */
.token.is-climbing {
  transition:
    left 750ms cubic-bezier(0.25, 0.8, 0.35, 1),
    top 750ms cubic-bezier(0.25, 0.8, 0.35, 1);
}

/* Aside: reuse Ludo's aside styling patterns */
.aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 16px;
}

.turn-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.turn-label {
  display: block;
  font: 600 11px 'Inter', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.turn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}
.turn-dot {
  width: 16px; height: 16px; border-radius: 50%;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.18);
}
.turn-dot[data-color='red']    { background: var(--c-red); }
.turn-dot[data-color='green']  { background: var(--c-green); }
.turn-dot[data-color='yellow'] { background: var(--c-yellow); }
.turn-dot[data-color='blue']   { background: var(--c-blue); }
.turn-name {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}
.turn-sub {
  display: block;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

/* Dice (matches Ludo dice visuals) */
.dice-btn {
  appearance: none;
  border: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease;
  color: var(--ink);
}
.dice-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(0,0,0,0.10); }
.dice-btn:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: var(--shadow); }
.dice-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.dice-face {
  position: relative;
  width: 60px;
  height: 60px;
  background: var(--paper);
  border-radius: 10px;
  border: 2px solid var(--ink);
  flex-shrink: 0;
}
.dice-face .pip {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--ink);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 100ms ease;
}
.dice-face .p1 { left: 30%; top: 30%; }
.dice-face .p2 { left: 70%; top: 30%; }
.dice-face .p3 { left: 30%; top: 50%; }
.dice-face .p4 { left: 70%; top: 50%; }
.dice-face .p5 { left: 30%; top: 70%; }
.dice-face .p6 { left: 70%; top: 70%; }
.dice-face .p7 { left: 50%; top: 50%; }
.dice-face[data-face='1'] .p7 { opacity: 1; }
.dice-face[data-face='2'] .p1, .dice-face[data-face='2'] .p6 { opacity: 1; }
.dice-face[data-face='3'] .p1, .dice-face[data-face='3'] .p7, .dice-face[data-face='3'] .p6 { opacity: 1; }
.dice-face[data-face='4'] .p1, .dice-face[data-face='4'] .p2, .dice-face[data-face='4'] .p5, .dice-face[data-face='4'] .p6 { opacity: 1; }
.dice-face[data-face='5'] .p1, .dice-face[data-face='5'] .p2, .dice-face[data-face='5'] .p5, .dice-face[data-face='5'] .p6, .dice-face[data-face='5'] .p7 { opacity: 1; }
.dice-face[data-face='6'] .p1, .dice-face[data-face='6'] .p2, .dice-face[data-face='6'] .p3, .dice-face[data-face='6'] .p4, .dice-face[data-face='6'] .p5, .dice-face[data-face='6'] .p6 { opacity: 1; }
.dice-face.is-rolling { animation: dice-roll 380ms ease-in-out; }
@keyframes dice-roll {
  0%   { transform: rotate(0deg) scale(1); }
  30%  { transform: rotate(160deg) scale(1.08); }
  60%  { transform: rotate(320deg) scale(0.96); }
  100% { transform: rotate(360deg) scale(1); }
}
.dice-label {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

/* Players list — each row shows colour, square number, medal if finished */
.players-list {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-radius: 8px;
  transition: background 140ms ease;
}
.player-row.is-turn { background: var(--bg-2); }
.player-row .p-dot {
  width: 14px; height: 14px; border-radius: 50%;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.18);
}
.player-row .p-dot[data-color='red']    { background: var(--c-red); }
.player-row .p-dot[data-color='green']  { background: var(--c-green); }
.player-row .p-dot[data-color='yellow'] { background: var(--c-yellow); }
.player-row .p-dot[data-color='blue']   { background: var(--c-blue); }
.player-row .p-name {
  flex: 1;
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.player-row .p-kind {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.player-row .p-sq {
  font: 700 15px 'Inter', sans-serif;
  color: var(--ink);
  min-width: 34px;
  text-align: right;
}
.player-row .p-medal { font-size: 16px; }

/* How to play (matches Ludo) */
.howto {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.howto summary {
  cursor: pointer;
  font-family: 'Fraunces', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  padding: 4px 0;
}
.howto ul {
  margin: 10px 0 2px;
  padding-left: 18px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}
.howto li + li { margin-top: 6px; }

/* Overlay (win) — matches shared overlay conventions */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 40, 0.55);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
  animation: overlay-in 220ms ease;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
.overlay-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  text-align: center;
}
.overlay-card h2 {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--ink);
}
.overlay-card p {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 14px;
}
.overlay-standings {
  text-align: left;
  background: var(--bg-2);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--ink);
}
.overlay-standings ol {
  margin: 0;
  padding-left: 22px;
  line-height: 1.7;
}
.overlay-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Foot link */
.foot {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.foot a {
  color: var(--muted);
  text-decoration: none;
}
.foot a:hover { color: var(--ink); }

/* Responsive */
@media (max-width: 900px) {
  .aside { position: static; }
  .board { max-width: 560px; }
  .players-list { order: 3; }

  /* Non-fullscreen mobile: put Turn card + Roll button on the same row,
     matching the fullscreen layout. Other aside children (players list,
     New game, How to play) fall onto their own rows below. */
  body:not([data-fullscreen="true"]) .aside {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 12px;
    align-items: center;
  }
  body:not([data-fullscreen="true"]) .aside .turn-card {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
  }
  body:not([data-fullscreen="true"]) .aside .dice-btn {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
  }
  /* Everything after row 1 stacks full-width. */
  body:not([data-fullscreen="true"]) .aside .players-list,
  body:not([data-fullscreen="true"]) .aside #btnNew,
  body:not([data-fullscreen="true"]) .aside .howto {
    grid-column: 1 / -1;
  }
}

/* Fullscreen: no-scroll viewport with just board + minimal controls.
   Hides the players list and How-to-play so the visible area is
   only board + turn card + dice + New game. */
body[data-fullscreen="true"] .play {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 24px;
  align-items: start;
  justify-content: center;
  padding: clamp(8px, 2vw, 24px);
  height: 100vh;
  height: 100dvh;
  max-width: 1100px;
  margin: 0 auto;
  box-sizing: border-box;
  overflow: hidden;
}
body[data-fullscreen="true"] .players-list,
body[data-fullscreen="true"] .howto {
  display: none !important;
}
body[data-fullscreen="true"] .board-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  max-height: 100%;
}
body[data-fullscreen="true"] .board-wrap .board {
  max-height: 100%;
  max-width: min(100%, calc(100dvh - 32px));
}
@media (max-width: 900px) {
  /* On mobile fullscreen: board on top, aside row (Turn + Roll) below it.
     Both rows shrink-wrap so there's no dead space; the whole grid is
     pinned to the top of the viewport. */
  body[data-fullscreen="true"] .play {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    align-items: start;
    align-content: start;
    justify-items: center;
    padding: 8px;
    gap: 8px;
  }
  body[data-fullscreen="true"] .board-wrap {
    order: 1;
    padding: 6px;
    min-height: 0;
    min-width: 0;
    /* Shrink-wrap to the board size. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  body[data-fullscreen="true"] .aside {
    order: 2;
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
    min-height: 0;
  }
  body[data-fullscreen="true"] .board-wrap .board {
    /* Board is a square. Size to fit within remaining viewport height
       after aside row (~100px) and outer padding (~32px). */
    width: min(100vw - 32px, 100dvh - 132px);
    height: min(100vw - 32px, 100dvh - 132px);
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
  }
  body[data-fullscreen="true"] .aside .turn-card {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 12px;
  }
  body[data-fullscreen="true"] .aside .dice-btn {
    flex: 0 0 auto;
    padding: 8px 12px;
  }
}

/* Hide New game button in ALL fullscreen views — exit fullscreen to start
   a new game from the normal view. */
body[data-fullscreen="true"] .aside #btnNew {
  display: none !important;
}
@media (max-width: 640px) {
  .game-title { font-size: 26px; }
  .sq-num { font-size: 26px; }
}
@media (max-width: 400px) {
  .game-title { font-size: 24px; }
  .setup { padding: 16px 14px 14px; }
  .seat { padding: 10px 12px; }
  .seat strong { min-width: 52px; font-size: 16px; }
  .seat-opts .opt { padding: 5px 9px; font-size: 11px; }
  .board-wrap { padding: 10px; }
  .token { width: 22px; height: 22px; }
}
