/* ══════════════════════════════════════════════════════
   Fighting Serpents — Artisan / Handcrafted Bead Board
   Walnut wood · jute twine · lapis & tiger's-eye beads · brass
   ══════════════════════════════════════════════════════ */
:root {
  /* ── Workshop surfaces (dirt → wood → deep grain) ── */
  --wood-bg:        #1c130b;
  --wood-1:         #2a1c10;
  --wood-2:         #3a2614;
  --wood-3:         #4d3318;
  --wood-4:         #6b4a24;
  --wood-edge:      #120b05;

  /* ── Brass / hardware ── */
  --brass:          #b88a3e;
  --brass-bright:   #e9c777;
  --brass-dark:     #6e4f1d;

  /* ── Twine / jute ── */
  --twine:          #b59a6a;
  --twine-light:    #d8c193;
  --twine-dark:     #6f5a34;

  /* ── Text (carved / ink) ── */
  --ink:            #ecd9b4;
  --ink-dim:        #b39a6e;
  --ink-faint:      #7c6845;

  /* ── Player beads ── */
  --p1-color:       #c08a2e;   /* Tiger's eye (You) */
  --p1-bright:      #ecca7c;
  --p1-dark:        #5d3a10;
  --p2-color:       #3a5aa6;   /* Lapis lazuli (AI) */
  --p2-bright:      #8fb0ef;
  --p2-dark:        #131f50;

  /* ── Interaction highlights ── */
  --sel:            #ffe7a0;
  --sel-glow:       rgba(255,231,160,.6);
  --capture:        #e8794a;
  --capture-glow:   rgba(232,121,74,.34);
  --move:           #cdb87f;
  --move-glow:      rgba(205,184,127,.30);
  --chain:          #e6a23c;

  /* ── Shadows ── */
  --shadow-1: 0 1px 4px rgba(0,0,0,.6);
  --shadow-2: 0 4px 14px rgba(0,0,0,.7);
  --shadow-3: 0 14px 40px rgba(0,0,0,.82);

  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   24px;
  --radius-full: 9999px;
}

/* ── FX disabled overrides ── */
body.fx-off .piece-arriving  { animation: none !important; }
body.fx-off .piece-capturing { animation: none !important; }
body.fx-off .hint-capture,
body.fx-off .hint-move       { animation: none !important; }
body.fx-off #bg-canvas       { opacity: 0 !important; }

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

html, body {
  height: 100%;
  background: var(--wood-bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', 'Segoe UI', Roboto, system-ui, Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ── Screens ── */
.screen {
  position: fixed; inset: 0;
  display: none; flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; }

/* Shared workshop / dirt backdrop */
.home-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 30%, rgba(120,84,40,.30) 0%, transparent 70%),
    radial-gradient(ellipse 80% 60% at 20% 90%, rgba(40,26,14,.6) 0%, transparent 70%),
    radial-gradient(ellipse 70% 50% at 85% 75%, rgba(60,40,20,.4) 0%, transparent 70%),
    linear-gradient(160deg, #20160c 0%, #140d06 55%, #0d0804 100%);
}
.home-bg::after {
  content: '';
  position: absolute; inset: 0;
  opacity: .5;
  background-image:
    radial-gradient(circle at 20% 35%, rgba(0,0,0,.5) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,.4) 0 1px, transparent 2px),
    radial-gradient(circle at 45% 80%, rgba(160,120,70,.18) 0 1px, transparent 2px),
    radial-gradient(circle at 85% 22%, rgba(160,120,70,.14) 0 1px, transparent 2px);
  background-size: 140px 140px, 90px 90px, 110px 110px, 70px 70px;
}

/* ── HOME ── */
.home-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; padding: 32px 24px; gap: 22px;
}
.home-plaque {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 26px 30px 30px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(150deg, var(--wood-3) 0%, var(--wood-2) 45%, var(--wood-1) 100%);
  border: 1px solid var(--brass-dark);
  box-shadow:
    inset 0 1px 0 rgba(255,220,150,.14),
    inset 0 0 36px rgba(0,0,0,.45),
    var(--shadow-3);
}
.home-emblem {
  line-height: 0;
  filter: drop-shadow(0 5px 12px rgba(0,0,0,.6));
}
.home-title {
  font-size: 40px; font-weight: 700;
  text-align: center; line-height: 1.08;
  color: var(--brass-bright);
  letter-spacing: .5px;
  text-shadow: 0 1px 0 #2a1c10, 0 2px 5px rgba(0,0,0,.7), 0 0 22px rgba(180,138,62,.28);
}
.home-subtitle {
  font-size: 13px;
  color: var(--ink-dim);
  text-align: center; line-height: 1.5;
  font-style: italic;
}
.home-foot {
  margin-top: 4px;
  font-size: 12px; color: var(--ink-faint);
  display: flex; align-items: center; gap: 7px;
}
.net-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #5aa15a; box-shadow: 0 0 6px rgba(90,161,90,.6);
}
.net-dot.offline { background: var(--brass); box-shadow: 0 0 6px rgba(184,138,62,.6); }
.home-buttons {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  gap: 12px; width: 100%; max-width: 320px;
}

/* ── Buttons (brass plates) ── */
.btn-primary {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; width: 100%; padding: 15px 24px;
  background: linear-gradient(180deg, var(--brass-bright) 0%, var(--brass) 52%, var(--brass-dark) 100%);
  color: #2a1a06; border: 1px solid #4d3614;
  border-radius: var(--radius-full);
  font-size: 16px; font-weight: 700; font-family: inherit;
  cursor: pointer; letter-spacing: .3px;
  box-shadow: inset 0 1px 0 rgba(255,247,220,.6), inset 0 -2px 4px rgba(80,52,16,.5), var(--shadow-2);
  transition: transform 80ms, filter 80ms;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(0.97); filter: brightness(0.9); }
.btn-primary .btn-icon { font-size: 19px; }

.btn-secondary {
  display: flex; align-items: center; justify-content: center;
  padding: 11px 32px;
  background: linear-gradient(180deg, var(--wood-4), var(--wood-2));
  color: var(--ink);
  border: 1px solid var(--brass-dark);
  border-radius: var(--radius-full);
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,220,150,.12), var(--shadow-1);
  transition: filter 80ms, transform 80ms;
}
.btn-secondary:hover { filter: brightness(1.08); }
.btn-secondary:active { transform: scale(.97); }

.btn-text {
  background: none; border: none;
  color: var(--brass-bright);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; padding: 8px 16px;
  text-align: center; letter-spacing: .3px;
  text-decoration: underline; text-underline-offset: 4px;
  text-decoration-color: var(--brass-dark);
}

/* ── Shared top bar ── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--wood-3), var(--wood-1));
  border-bottom: 2px solid var(--wood-edge);
  box-shadow: inset 0 1px 0 rgba(255,220,150,.1), var(--shadow-1);
  flex-shrink: 0;
}
.topbar-title {
  font-size: 20px; font-weight: 700;
  color: var(--brass-bright);
  text-shadow: 0 1px 0 #1c130b;
}
.btn-icon-back {
  background: none; border: none;
  color: var(--ink); font-size: 22px;
  padding: 8px; cursor: pointer;
  border-radius: var(--radius-full); line-height: 1;
}
.btn-icon-back:active { background: rgba(0,0,0,.25); }

/* ── Rules ── */
.rules-content {
  overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  -webkit-overflow-scrolling: touch;
  background: var(--wood-bg);
}

/* Animated rules demo */
.rules-demo {
  background:
    radial-gradient(ellipse 70% 60% at 50% 38%, rgba(90,62,30,.4), transparent 75%),
    linear-gradient(155deg, var(--wood-3), var(--wood-1));
  border-radius: var(--radius-md);
  border: 1px solid var(--brass-dark);
  box-shadow: inset 0 1px 0 rgba(255,220,150,.1), var(--shadow-1);
  padding: 14px 14px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#rules-demo-svg {
  width: 100%; max-width: 232px; height: auto; display: block;
  overflow: visible;
}
#rules-demo-caption {
  font-size: 13.5px; font-weight: 600; font-style: italic;
  color: var(--brass-bright); text-align: center; min-height: 34px;
  display: flex; align-items: center; justify-content: center;
  text-shadow: 0 1px 0 rgba(0,0,0,.5);
  transition: opacity 200ms;
}
.demo-bead { transform-box: fill-box; transform-origin: center; }
.rule-card {
  background: linear-gradient(155deg, var(--wood-2), var(--wood-1));
  border-radius: var(--radius-md); padding: 16px;
  border: 1px solid var(--brass-dark);
  box-shadow: inset 0 1px 0 rgba(255,220,150,.08), var(--shadow-1);
}
.rule-card h3 {
  color: var(--brass-bright); font-size: 14px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px; margin-bottom: 8px;
}
.rule-card p { font-size: 14px; color: var(--ink-dim); line-height: 1.6; }
.rule-card strong { color: var(--ink); }

/* ── Waiting / QR ── */
.waiting-content {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; gap: 20px; background: var(--wood-bg);
}
.waiting-label { font-size: 15px; color: var(--ink-dim); text-align: center; }
.qr-container {
  background: #f3e7cd; border-radius: var(--radius-md);
  padding: 16px; box-shadow: var(--shadow-3);
  border: 2px solid var(--brass-dark);
}
.qr-container canvas { display: block; }
.game-id-label { font-size: 15px; color: var(--ink-dim); }
.game-id-label strong {
  color: var(--brass-bright); font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 18px; letter-spacing: 1px;
}
.waiting-spinner { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.waiting-spinner p { font-size: 14px; color: var(--ink-dim); }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--wood-3);
  border-top-color: var(--brass-bright);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Game screen — carved scoreboard header ── */
.game-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background:
    linear-gradient(180deg, var(--wood-4) 0%, var(--wood-2) 60%, var(--wood-1) 100%);
  border-bottom: 2px solid var(--wood-edge);
  box-shadow: inset 0 1px 0 rgba(255,220,150,.12), 0 2px 6px rgba(0,0,0,.5);
  flex-shrink: 0; gap: 6px;
  position: relative; z-index: 5;
}
.game-topbar > #btn-game-menu { justify-self: start; }
.game-topbar > .topbar-tools  { justify-self: end; }
/* Centred turn colour + status text */
.turn-center {
  justify-self: center;
  display: flex; align-items: center; gap: 9px;
  min-width: 0;
}
.btn-icon-small {
  background: none; border: none;
  color: var(--brass-bright); font-size: 20px;
  padding: 6px 8px; cursor: pointer;
  border-radius: var(--radius-sm); flex-shrink: 0;
  min-width: 34px; min-height: 34px;
  text-shadow: 0 1px 0 #1c130b;
}
.btn-icon-small:disabled { color: var(--ink-faint); cursor: default; opacity: .55; }

.topbar-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#btn-fx {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,.22);
  border: 1px solid var(--brass-dark);
  border-radius: var(--radius-full);
  color: var(--ink-dim);
  font-weight: 700;
  height: 28px; padding: 0 9px; cursor: pointer;
  flex-shrink: 0;
  transition: color 150ms, border-color 150ms;
}
#btn-fx .fx-star  { font-size: 13px; line-height: 1; }
#btn-fx .fx-label { font-size: 11px; letter-spacing: .6px; }
#btn-fx.fx-on { border-color: var(--brass); color: var(--brass-bright); }
#btn-audio-profile {
  width: 64px; min-height: 28px;
  background: rgba(0,0,0,.22);
  border: 1px solid var(--brass-dark);
  border-radius: var(--radius-full);
  color: var(--ink-dim);
  font-size: 11px; font-weight: 700; font-family: inherit;
  padding: 4px 6px; cursor: pointer; flex-shrink: 0;
}
#btn-audio-profile.profile-calm   { border-color: var(--p2-color); color: var(--p2-bright); }
#btn-audio-profile.profile-punchy { border-color: var(--brass); color: var(--brass-bright); }
#btn-audio-profile.profile-silent { border-color: var(--ink-faint); color: var(--ink-faint); }

/* Carved score plates */
.score {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: rgba(0,0,0,.22);
  box-shadow: inset 0 2px 5px rgba(0,0,0,.55), inset 0 -1px 0 rgba(255,220,150,.08);
}
.score-label {
  font-size: 13px; font-weight: 600; letter-spacing: 1px;
  color: var(--ink-dim); text-transform: uppercase;
}
.player-dot {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(255,255,255,.4), 0 1px 2px rgba(0,0,0,.6);
}
.dot-p1 { background: radial-gradient(circle at 35% 28%, var(--p1-bright) 0%, var(--p1-color) 55%, var(--p1-dark) 100%); }
.dot-p2 { background: radial-gradient(circle at 35% 28%, var(--p2-bright) 0%, var(--p2-color) 55%, var(--p2-dark) 100%); }
.piece-count {
  font-size: 19px; font-weight: 700;
  color: var(--brass-bright);
  min-width: 22px; text-align: center;
  text-shadow: 0 1px 0 #1c130b;
  font-variant-numeric: tabular-nums;
}
.turn-indicator {
  width: 30px; height: 30px; border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, var(--wood-4), var(--wood-1));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 2px 5px rgba(0,0,0,.6), 0 1px 0 rgba(255,220,150,.1);
}
.turn-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--p1-color);
  box-shadow: 0 0 7px var(--p1-color);
  transition: background 300ms, transform 300ms, box-shadow 300ms;
}
.turn-dot.p2 {
  background: var(--p2-color);
  box-shadow: 0 0 7px var(--p2-color);
  transform: scale(1.2);
}

/* Status text ("Your turn"), sits inline beside the turn colour */
.status-bar {
  font-size: 15px; font-weight: 600; font-style: italic;
  color: var(--ink-dim);
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 0 rgba(0,0,0,.55);
}
.status-bar.highlight { color: var(--brass-bright); }
.status-bar.alert     { color: var(--capture); text-shadow: 0 0 12px rgba(232,121,74,.35), 0 1px 0 rgba(0,0,0,.55); }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--wood-edge);
  border-bottom: 1px solid var(--wood-edge);
  flex-shrink: 0; position: relative; z-index: 5;
}
.stats-strip span {
  min-width: 0;
  background: linear-gradient(180deg, var(--wood-2), var(--wood-1));
  color: var(--ink-dim);
  font-size: 11px; line-height: 1.2;
  padding: 6px 4px; text-align: center; white-space: nowrap;
}
.stats-strip strong { color: var(--brass-bright); font-size: 12px; }

/* ── Board container ── */
.board-wrapper {
  flex: 1; overflow: hidden;
  background:
    radial-gradient(ellipse 70% 50% at 50% 35%, rgba(90,62,30,.35), transparent 75%),
    linear-gradient(160deg, #1a1109 0%, #120c06 100%);
  display: flex; align-items: center; justify-content: center;
  gap: clamp(8px, 3vw, 22px);
  position: relative;
}
#bg-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  transition: opacity 400ms;
}
.board-scroll {
  overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 0; min-width: 0; height: 100%;
  display: flex; align-items: flex-start; justify-content: center;
  position: relative; z-index: 1;
}

/* ── Tug-of-war score meter ── */
.tug {
  flex-shrink: 0;
  padding: 10px 16px 4px;
  padding-top: 10px;
  background: linear-gradient(180deg, var(--wood-1), var(--wood-bg));
  position: relative; z-index: 5;
}
.tug-track {
  display: flex; align-items: stretch;
  height: 38px;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 2px solid var(--brass-dark);
  background: var(--wood-3);
  box-shadow:
    inset 0 2px 6px rgba(0,0,0,.55),
    inset 0 -1px 0 rgba(255,220,150,.12),
    0 2px 5px rgba(0,0,0,.5);
}
.tug-fill {
  display: flex; align-items: center;
  min-width: 68px;
  overflow: hidden; white-space: nowrap;
  transition: flex-grow 450ms cubic-bezier(.2,.8,.2,1);
}
.tug-fill-ai {
  justify-content: flex-start; padding-left: 15px;
  background: linear-gradient(180deg, #4a6ec4 0%, var(--p2-color) 55%, #2c4488 100%);
  color: #eaf1ff;
  border-right: 3px solid var(--brass-bright);
  text-shadow: 0 1px 2px rgba(0,0,20,.6);
}
.tug-fill-you {
  justify-content: flex-end; padding-right: 15px;
  background: linear-gradient(180deg, var(--p1-bright) 0%, var(--p1-color) 60%, #8a5e1f 100%);
  color: #3a2407;
  text-shadow: 0 1px 1px rgba(255,235,190,.5);
}
.tug-text { font-size: 16px; font-weight: 800; letter-spacing: .3px; }
.tug-text span { font-variant-numeric: tabular-nums; }
.tug-fill-ai .tug-text strong { font-weight: 800; letter-spacing: 1px; }
.tug-fill-you .tug-text strong { font-weight: 800; letter-spacing: 1px; }
.board-scroll::-webkit-scrollbar { width: 4px; }
.board-scroll::-webkit-scrollbar-track { background: transparent; }
.board-scroll::-webkit-scrollbar-thumb { background: var(--brass-dark); border-radius: 2px; }
#board-svg {
  display: block; flex-shrink: 0;
  touch-action: pan-y;
  overflow: visible;   /* let hint/capture rings expand past the board edge */
  filter: drop-shadow(0 12px 34px rgba(0,0,0,.7));
}

/* ── SVG board elements ── */
.board-surface { filter: none; }
.board-line { stroke-linecap: round; }      /* twine styled inline */
.board-arc  { fill: none; stroke-linecap: round; }
.board-node {
  fill: #1a1109;
  stroke: rgba(0,0,0,.5);
  stroke-width: 1;
}

/* ── Pieces (gemstone beads — gradients in SVG <defs>) ── */
.piece-p1 {
  stroke: rgba(50,30,8,.92); stroke-width: 1.4;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,.6));
}
.piece-p2 {
  stroke: rgba(10,18,52,.92); stroke-width: 1.4;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,.6));
}
.piece-p1, .piece-p2 { transform-box: fill-box; transform-origin: center; }
.piece-selected {
  stroke: var(--sel) !important;
  stroke-width: 2.6 !important;
  filter: drop-shadow(0 0 10px var(--sel-glow)) !important;
}
.piece-chain {
  stroke: var(--chain) !important;
  stroke-width: 2.4 !important;
  filter: drop-shadow(0 0 10px rgba(230,162,60,.7)) !important;
}
.piece-can-capture {
  stroke: var(--capture) !important;
  stroke-width: 2.5 !important;
  filter: drop-shadow(0 0 12px rgba(232,121,74,.55)) !important;
  animation: capture-ready 1.25s ease-in-out infinite;
}
.piece-travel {
  pointer-events: none;
  filter: drop-shadow(0 0 12px rgba(255,231,160,.45)) drop-shadow(0 3px 7px rgba(0,0,0,.7));
}
.bead-shine { pointer-events: none; }

/* ── Hint markers ── */
.hint-capture {
  fill: var(--capture-glow);
  stroke: var(--capture);
  stroke-width: 2.2; cursor: pointer;
  filter: drop-shadow(0 0 9px rgba(232,121,74,.45));
}
.hint-move {
  fill: var(--move-glow);
  stroke: var(--move);
  stroke-width: 1.7; cursor: pointer;
  filter: drop-shadow(0 0 7px rgba(205,184,127,.3));
}
.hitarea { fill: transparent; cursor: pointer; }
.node-tap { fill: transparent; cursor: pointer; }

/* ── Animations ── */
@keyframes piece-arrive {
  0%   { transform: scale(0.6); opacity: 0.5; }
  60%  { transform: scale(1.18); }
  80%  { transform: scale(0.94); }
  100% { transform: scale(1);   opacity: 1; }
}
@keyframes hint-pulse {
  0%, 100% { opacity: 0.74; transform: scale(.92); }
  50%       { opacity: 1; transform: scale(1.08); }
}
@keyframes capture-ready {
  0%, 100% { opacity: 1; }
  50%      { opacity: .72; }
}
.piece-arriving { animation: piece-arrive 280ms cubic-bezier(.34,1.56,.64,1) forwards; }
.hint-capture, .hint-move {
  animation: hint-pulse 1.55s ease-in-out infinite;
  transform-box: fill-box;
  transform-origin: center;
}

/* ── Game actions bar ── */
.game-actions {
  display: flex; justify-content: center;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--wood-2), var(--wood-1));
  border-top: 2px solid var(--wood-edge);
  position: relative; z-index: 5;
}

/* ── Overlays ── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.62);
  z-index: 100; display: flex;
  align-items: flex-end;
  backdrop-filter: blur(8px) saturate(0.7);
}
.overlay.hidden { display: none; }
.overlay.center { align-items: center; justify-content: center; }

/* ── Coin-flip ── */
.flip-sheet {
  display: flex; flex-direction: column; align-items: center;
  gap: 22px; padding: 30px 34px;
  border-radius: var(--radius-lg);
  background: linear-gradient(155deg, var(--wood-3), var(--wood-1));
  border: 2px solid var(--brass-dark);
  box-shadow: inset 0 1px 0 rgba(255,220,150,.14), var(--shadow-3);
  animation: sheet-rise 200ms cubic-bezier(.2,.8,.2,1);
}
.flip-title {
  font-size: 18px; font-weight: 700; letter-spacing: .4px;
  color: var(--brass-bright); text-shadow: 0 1px 0 #1c130b;
}
.coin-stage { perspective: 700px; }
.coin {
  position: relative;
  width: 132px; height: 132px;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
}
.coin-face {
  position: absolute; inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center;
  border: 4px solid var(--brass);
  box-shadow:
    inset 0 4px 10px rgba(255,255,255,.35),
    inset 0 -8px 16px rgba(0,0,0,.5),
    0 8px 22px rgba(0,0,0,.6);
}
.coin-p1 {
  transform: rotateY(0deg);
  background: radial-gradient(circle at 35% 28%, #fbe6a8 0%, var(--p1-color) 52%, #4a2c0b 100%);
  color: #3a2407; text-shadow: 0 1px 1px rgba(255,235,190,.5);
}
.coin-p2 {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 35% 28%, #bcd2f6 0%, var(--p2-color) 52%, #0c163e 100%);
  color: #eaf1ff; text-shadow: 0 1px 2px rgba(0,0,20,.6);
}
.coin-name { font-size: 22px; font-weight: 800; letter-spacing: .5px; }
.flip-result {
  font-size: 17px; font-weight: 700; min-height: 22px;
  color: var(--ink-dim); letter-spacing: .3px;
}
.flip-result.win { color: var(--brass-bright); text-shadow: 0 0 14px rgba(232,196,120,.5); }

.menu-sheet, .win-sheet {
  background: linear-gradient(180deg, var(--wood-3) 0%, var(--wood-1) 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  width: 100%; display: flex; flex-direction: column;
  gap: 8px; box-shadow: var(--shadow-3);
  border-top: 2px solid var(--brass-dark);
  animation: sheet-rise 180ms cubic-bezier(.2,.8,.2,1);
}
.menu-sheet h3 {
  text-align: center; font-size: 20px; font-weight: 700;
  color: var(--brass-bright); margin-bottom: 8px;
}
.menu-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.menu-stats span, .move-history {
  background: rgba(0,0,0,.25);
  border: 1px solid var(--brass-dark);
  border-radius: var(--radius-sm);
}
.menu-stats span { color: var(--ink-dim); font-size: 12px; padding: 9px 6px; text-align: center; }
.menu-stats strong { display: block; color: var(--brass-bright); font-size: 18px; }
.move-history {
  max-height: 138px; overflow-y: auto; padding: 8px;
  color: var(--ink-dim); font-size: 12px; line-height: 1.45;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.move-history:empty::before { content: 'No moves yet'; color: var(--ink-faint); }
.history-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.history-row strong { color: var(--brass-bright); font-weight: 700; }
.menu-item {
  width: 100%; padding: 15px;
  background: linear-gradient(180deg, var(--wood-4), var(--wood-2));
  border: 1px solid var(--brass-dark);
  border-radius: var(--radius-md);
  color: var(--ink); font-size: 16px; font-family: inherit; font-weight: 600;
  cursor: pointer; text-align: center;
  box-shadow: inset 0 1px 0 rgba(255,220,150,.1);
  transition: filter 80ms;
}
.menu-item:active { filter: brightness(.9); }
.menu-close { color: var(--ink-dim); background: rgba(0,0,0,.2); }

.win-sheet { align-items: center; }
.win-sheet h2 {
  text-align: center; font-size: 22px; font-weight: 700;
  color: var(--brass-bright); margin-bottom: 4px;
}
.win-emoji { font-size: 64px; line-height: 1; margin-bottom: 8px; }
.win-sheet p { font-size: 14px; color: var(--ink-dim); text-align: center; margin-bottom: 12px; }
.win-sheet .btn-primary { max-width: 280px; }

@keyframes sheet-rise {
  from { transform: translateY(18px); opacity: .65; }
  to   { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .hint-capture, .hint-move, .piece-arriving, .piece-can-capture, .spinner, .menu-sheet, .win-sheet {
    animation: none !important;
  }
  *, *::before, *::after { scroll-behavior: auto !important; }
}
