:root {
  color-scheme: light dark;
  --forest-950: #102b21;
  --forest-900: #17392c;
  --forest-800: #234c3b;
  --forest-700: #2f604a;
  --forest-100: #dfeae2;
  --gold-500: #c89538;
  --gold-300: #e4c276;
  --cream-50: #fffaf0;
  --cream-100: #f7efdf;
  --ink: #203028;
  --muted: #66746c;
  --surface: rgba(255, 253, 247, .9);
  --surface-solid: #fffdf7;
  --page: #f1ecdf;
  --line: rgba(31, 59, 44, .16);
  --wood-1: #c99355;
  --wood-2: #ad713b;
  --wood-3: #8a542d;
  --hole: #58331e;
  --hen: #f8e7bd;
  --fox: #c85b2c;
  --shadow: 0 18px 48px rgba(35, 48, 37, .16);
  --radius-lg: 28px;
  --radius-md: 18px;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; background: var(--page); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 15%, rgba(255,255,255,.82), transparent 28rem),
    radial-gradient(circle at 87% 90%, rgba(47,96,74,.1), transparent 32rem),
    var(--page);
}

button { font: inherit; }
button:focus-visible, .board-node:focus-visible {
  outline: 3px solid var(--gold-500);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  left: 1rem;
  top: -5rem;
  padding: .8rem 1rem;
  color: white;
  background: var(--forest-900);
  border-radius: .6rem;
}
.skip-link:focus { top: 1rem; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.site-header {
  width: min(1180px, calc(100% - 2rem));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .25rem;
  color: inherit;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: var(--fox);
  background: var(--forest-900);
  border: 2px solid var(--gold-300);
  border-radius: 50%;
  box-shadow: 0 5px 16px rgba(21,52,40,.2);
}
.brand-mark svg { width: 38px; height: 38px; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; letter-spacing: .01em; }
.brand small { margin-top: .1rem; color: var(--muted); font-size: .69rem; letter-spacing: .08em; text-transform: uppercase; }

.icon-button, .secondary-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  color: var(--forest-800);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 5px 16px rgba(30,48,39,.06);
}
.icon-button { padding: .55rem 1rem; }
.icon-button svg, .secondary-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button:hover, .secondary-button:hover:not(:disabled) { border-color: rgba(47,96,74,.35); transform: translateY(-1px); }
.icon-button:active, .secondary-button:active:not(:disabled) { transform: translateY(1px); }

main { width: 100%; }

.start-screen {
  width: min(760px, calc(100% - 2rem));
  margin: clamp(1rem, 5vh, 4rem) auto 2rem;
  text-align: center;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: clamp(1.5rem, 5vw, 3.3rem);
  border: 1px solid rgba(86, 70, 42, .13);
  background:
    linear-gradient(135deg, rgba(255,255,255,.58), transparent 45%),
    var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.hero-card::before, .hero-card::after {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  border: 1px solid rgba(200,149,56,.17);
  border-radius: 50%;
  pointer-events: none;
}
.hero-card::before { left: -130px; top: -130px; }
.hero-card::after { right: -120px; bottom: -150px; }

.hero-art { display: flex; justify-content: center; align-items: center; gap: .65rem; margin: 0 auto 1.2rem; }
.hero-token {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border: 4px solid rgba(255,255,255,.65);
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(31,52,40,.18);
}
.hero-token svg { width: 62px; height: 62px; }
.hero-token--fox { color: var(--fox); background: var(--forest-900); transform: rotate(-7deg); }
.hero-token--hen { color: var(--hen); background: #7b5935; transform: rotate(7deg); }
.hero-vs { color: var(--muted); font-family: Georgia, serif; font-size: .8rem; font-style: italic; }

.eyebrow { margin: 0 0 .55rem; color: var(--forest-700); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; color: var(--forest-950); line-height: 1.08; }
h1 { max-width: 600px; margin-inline: auto; font-size: clamp(2rem, 7vw, 3.35rem); }
h2 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
.hero-copy { max-width: 570px; margin: 1rem auto 1.6rem; color: var(--muted); line-height: 1.65; }

.mode-list { display: grid; gap: .75rem; max-width: 590px; margin: 0 auto; text-align: left; }
.mode-card {
  width: 100%;
  min-height: 72px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: .85rem;
  padding: .7rem .9rem;
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.44);
  border-radius: 16px;
  text-align: left;
}
.mode-card--active { color: white; border-color: var(--forest-700); background: linear-gradient(135deg, var(--forest-700), var(--forest-900)); cursor: pointer; box-shadow: 0 10px 24px rgba(28,67,51,.22); }
.mode-card--active:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(28,67,51,.26); }
.mode-card--active:active { transform: translateY(1px); }
.mode-card:disabled { color: var(--muted); cursor: not-allowed; opacity: .72; }
.mode-card strong, .mode-card small { display: block; }
.mode-card strong { font-size: .96rem; }
.mode-card small { margin-top: .18rem; color: inherit; opacity: .72; font-size: .76rem; }
.mode-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: rgba(32,48,40,.07); }
.mode-card--active .mode-icon { background: rgba(255,255,255,.12); }
.mode-icon svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mode-arrow { padding: 0 .25rem; color: var(--gold-300); font-size: 2rem; font-weight: 300; }
.soon-badge { padding: .3rem .5rem; color: var(--forest-700); background: var(--forest-100); border-radius: 999px; font-size: .65rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.offline-note { color: var(--muted); font-size: .76rem; }
.offline-note span { margin-right: .35rem; color: var(--forest-700); font-size: .55rem; }

.game-screen { width: min(1180px, calc(100% - 1.25rem)); margin: .8rem auto 2rem; }
.game-layout { display: grid; gap: 1.2rem; }
.board-column { min-width: 0; }
.mobile-status { min-height: 40px; display: flex; align-items: center; justify-content: center; color: var(--forest-800); font-family: Georgia, serif; font-weight: 700; }

.board-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: clamp(7px, 2vw, 18px);
  border: 1px solid #7a4828;
  background:
    repeating-linear-gradient(4deg, transparent 0 13px, rgba(77,39,17,.10) 14px, transparent 16px 26px),
    repeating-radial-gradient(ellipse at 20% 30%, transparent 0 28px, rgba(77,39,17,.08) 30px, transparent 34px 55px),
    linear-gradient(115deg, var(--wood-1), #d8a765 38%, var(--wood-2) 72%, #9b6034);
  border-radius: clamp(18px, 4vw, 34px);
  box-shadow: inset 0 2px 2px rgba(255,255,255,.38), inset 0 -5px 9px rgba(75,38,17,.24), 0 22px 50px rgba(55,35,19,.24);
}
.board-shell::after {
  content: "";
  position: absolute;
  inset: clamp(9px, 2.1vw, 21px);
  pointer-events: none;
  border: 1px solid rgba(255,236,194,.24);
  border-radius: clamp(13px, 3vw, 25px);
}
.board-corner { position: absolute; z-index: 4; width: 11px; height: 11px; background: #50301e; border-radius: 50%; box-shadow: inset 1px 1px 2px #1f120b, 0 1px 1px rgba(255,255,255,.3); }
.board-corner--tl { left: 12px; top: 12px; }
.board-corner--tr { right: 12px; top: 12px; }
.board-corner--bl { left: 12px; bottom: 12px; }
.board-corner--br { right: 12px; bottom: 12px; }

.board-stage { position: relative; width: 100%; height: 100%; border-radius: 22px; }
.board-stage::before {
  content: "STALL";
  position: absolute;
  z-index: 0;
  left: 29%;
  top: 56%;
  width: 42%;
  height: 40%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 1.2%;
  color: rgba(69,45,22,.54);
  border: 2px solid rgba(58,91,55,.45);
  background: rgba(47,96,74,.13);
  border-radius: 12px;
  font-family: Georgia, serif;
  font-size: clamp(.52rem, 2vw, .9rem);
  font-weight: 700;
  letter-spacing: .18em;
}
.board-lines, .board-nodes { position: absolute; inset: 0; width: 100%; height: 100%; }
.board-lines { z-index: 1; overflow: visible; }
.engraved-line { stroke: rgba(71,40,19,.62); stroke-width: .76; stroke-linecap: round; filter: drop-shadow(0 .2px .12px rgba(255,235,190,.8)); }
.last-move-line { stroke: var(--gold-300); stroke-width: 1.15; stroke-linecap: round; opacity: .95; }
.board-nodes { z-index: 2; }

.board-node {
  position: absolute;
  width: clamp(44px, 9.4%, 68px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  color: inherit;
  border: 0;
  background: transparent;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.board-node::before {
  content: "";
  position: absolute;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 60% 65%, #7d4b2b 0, var(--hole) 50%, #321c10 100%);
  box-shadow: inset 2px 2px 4px rgba(23,11,4,.72), 0 1px 1px rgba(255,224,169,.5);
}
.board-node.has-piece { cursor: pointer; }
.board-node.can-select .piece { filter: drop-shadow(0 6px 4px rgba(49,27,12,.27)); }
.board-node.can-select:hover .piece { transform: translateY(-3px) scale(1.04); }
.board-node.selected::after {
  content: "";
  position: absolute;
  inset: 2%;
  border: 3px solid var(--gold-300);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(72,52,24,.28), 0 0 16px rgba(255,210,109,.66);
}
.board-node.legal-target { cursor: pointer; }
.board-node.legal-target::before {
  width: 38%;
  background: radial-gradient(circle, #f6d98b 0 22%, var(--gold-500) 25% 47%, rgba(255,235,174,.66) 50% 70%, transparent 72%);
  box-shadow: 0 0 0 3px rgba(56,95,70,.5), 0 0 14px rgba(245,204,103,.66);
  animation: target-pulse 1.45s ease-in-out infinite;
}
.board-node.last-from::before, .board-node.last-to::before { box-shadow: inset 2px 2px 4px rgba(23,11,4,.72), 0 0 0 3px rgba(244,205,112,.72); }
.piece {
  position: relative;
  z-index: 2;
  width: 88%;
  height: 88%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.36);
  border-radius: 50%;
  box-shadow: inset 0 -4px 8px rgba(58,35,15,.22), inset 0 3px 5px rgba(255,255,255,.32), 0 7px 8px rgba(54,29,13,.28);
  transition: transform .16s ease, filter .16s ease;
}
.piece svg { width: 83%; height: 83%; overflow: visible; }
.piece--hen { color: var(--hen); background: radial-gradient(circle at 35% 28%, #9e7a46, #6d4b2d 70%); --piece-line: #76592f; }
.piece--fox { color: var(--fox); background: radial-gradient(circle at 35% 28%, #365e49, var(--forest-950) 72%); }
.piece.just-moved { animation: piece-arrive .28s cubic-bezier(.2,.9,.3,1.28); }
.board-node:active .piece { transform: scale(.95); }

.board-hint { min-height: 1.4em; margin: .8rem .5rem 0; color: var(--muted); font-size: .8rem; line-height: 1.45; text-align: center; }
.game-panel { display: grid; align-content: start; gap: .85rem; }
.turn-card, .score-card, .captured-card, .goal-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 22px rgba(30,48,39,.07);
}
.turn-card { display: flex; align-items: center; gap: .9rem; padding: .8rem 1rem; }
.turn-piece { width: 50px; height: 50px; display: grid; place-items: center; color: var(--hen); background: #76522f; border-radius: 50%; box-shadow: inset 0 2px 3px rgba(255,255,255,.24); }
.turn-piece--fox { color: var(--fox); background: var(--forest-950); }
.turn-piece svg { width: 43px; height: 43px; }
.panel-label { display: block; margin-bottom: .12rem; color: var(--muted); font-size: .65rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.turn-card strong { color: var(--forest-900); font-family: Georgia, serif; font-size: 1.32rem; }
.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.score-card { padding: .9rem; }
.score-card > span { display: block; color: var(--muted); font-size: .7rem; }
.score-card strong { display: block; margin-top: .15rem; color: var(--forest-900); font-family: Georgia, serif; font-size: 1.75rem; }
.score-card small { color: var(--muted); font-size: .8rem; }
.captured-card { display: flex; align-items: center; justify-content: space-between; gap: .8rem; min-height: 78px; padding: .75rem 1rem; }
.captured-card strong { font-size: .9rem; }
.capture-tray { width: 116px; min-height: 50px; display: flex; flex-wrap: wrap; align-content: center; gap: 2px; padding: 6px 8px; border: 2px solid rgba(78,47,24,.28); background: radial-gradient(ellipse, rgba(89,51,26,.24), rgba(115,71,35,.08)); border-radius: 50%; box-shadow: inset 0 3px 7px rgba(62,37,18,.18); }
.captured-hen { width: 13px; height: 13px; background: var(--hen); border: 1px solid #947141; border-radius: 50%; box-shadow: 0 1px 2px rgba(43,27,12,.25); }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.secondary-button { padding: .6rem .7rem; border-radius: 13px; font-size: .79rem; font-weight: 700; }
.secondary-button:disabled { cursor: not-allowed; opacity: .42; }
.goal-card { display: flex; align-items: center; gap: .75rem; padding: .8rem; }
.goal-icon { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; color: var(--gold-300); border: 2px solid var(--gold-500); background: var(--forest-900); border-radius: 50%; font-family: Georgia, serif; font-weight: 700; }
.goal-card p { margin: 0; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.goal-card strong { display: block; color: var(--forest-800); }

.modal {
  width: min(540px, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: clamp(1.35rem, 5vw, 2.4rem);
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--surface-solid);
  border-radius: var(--radius-lg);
  box-shadow: 0 28px 80px rgba(10,26,20,.38);
}
.modal::backdrop { background: rgba(12,29,23,.72); backdrop-filter: blur(5px); }
.modal form { margin: 0; }
.modal-close { position: absolute; right: 1rem; top: 1rem; width: 44px; height: 44px; color: var(--muted); border: 0; background: transparent; border-radius: 50%; font-size: 1.8rem; cursor: pointer; }
.modal-close:hover { background: var(--forest-100); }
.rule-list { display: grid; gap: 1rem; margin: 1.5rem 0; }
.rule-list > div { display: grid; grid-template-columns: 38px 1fr; gap: .7rem; align-items: start; }
.rule-number { width: 34px; height: 34px; display: grid; place-items: center; color: var(--gold-300); background: var(--forest-900); border-radius: 50%; font-family: Georgia, serif; font-weight: 700; }
.rule-list p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.rule-list strong { display: block; color: var(--ink); }
.primary-button {
  min-height: 48px;
  padding: .75rem 1.2rem;
  color: white;
  border: 1px solid var(--forest-700);
  background: linear-gradient(135deg, var(--forest-700), var(--forest-900));
  border-radius: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(28,67,51,.2);
}
.primary-button:hover { transform: translateY(-1px); }
.modal-action { width: 100%; }
.winner-modal { text-align: center; }
.winner-emblem { width: 90px; height: 90px; display: grid; place-items: center; margin: 0 auto 1rem; color: var(--hen); background: var(--forest-900); border: 4px solid var(--gold-300); border-radius: 50%; box-shadow: 0 10px 28px rgba(23,57,44,.22); }
.winner-emblem svg { width: 76px; height: 76px; }
.winner-modal > p:not(.eyebrow) { color: var(--muted); line-height: 1.5; }
.winner-actions { display: grid; gap: .55rem; margin-top: 1.3rem; }
.text-button { min-height: 44px; color: var(--forest-700); border: 0; background: transparent; font-weight: 700; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes target-pulse { 0%, 100% { transform: scale(.88); opacity: .78; } 50% { transform: scale(1.08); opacity: 1; } }
@keyframes piece-arrive { from { transform: scale(.68) translateY(-14px); opacity: .4; } to { transform: scale(1) translateY(0); opacity: 1; } }

@media (min-width: 760px) {
  .site-header { min-height: 88px; }
  .game-screen { margin-top: 1.2rem; }
  .game-layout { grid-template-columns: minmax(0, 760px) minmax(240px, 300px); align-items: start; justify-content: center; gap: clamp(1.2rem, 3vw, 2.2rem); }
  .mobile-status { display: none; }
  .board-hint { font-size: .87rem; }
  .game-panel { position: sticky; top: 1rem; }
}

@media (max-width: 759px) {
  .game-panel { grid-template-columns: 1fr 1fr; }
  .turn-card, .captured-card, .action-row, .goal-card { grid-column: 1 / -1; }
  .score-grid { display: contents; }
  .goal-card { display: none; }
  .site-header { min-height: 66px; }
  .brand small { display: none; }
  .brand-mark { width: 40px; height: 40px; }
  .brand-mark svg { width: 34px; height: 34px; }
  .icon-button span { display: none; }
  .icon-button { width: 44px; padding: .5rem; }
}

@media (max-width: 420px) {
  .start-screen { width: min(100% - 1rem, 760px); margin-top: .4rem; }
  .hero-card { padding: 1.25rem .85rem; border-radius: 22px; }
  .hero-art { margin-bottom: .9rem; }
  .hero-token { width: 62px; height: 62px; }
  .hero-token svg { width: 52px; height: 52px; }
  .hero-copy { font-size: .88rem; }
  .mode-card { grid-template-columns: 44px 1fr auto; gap: .65rem; padding-inline: .65rem; }
  .mode-icon { width: 42px; height: 42px; }
  .game-screen { width: calc(100% - .5rem); margin-top: 0; }
  .board-hint { margin-inline: .8rem; }
  .game-panel { padding: 0 .3rem; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eaf0eb;
    --muted: #a7b3ab;
    --surface: rgba(27, 43, 35, .9);
    --surface-solid: #1b2b23;
    --page: #0f1d17;
    --line: rgba(222, 235, 225, .13);
    --forest-100: #294638;
    --forest-950: #f2ead7;
    --forest-900: #dfe9e1;
    --forest-800: #bcd4c4;
    --forest-700: #8fb69d;
    --shadow: 0 18px 48px rgba(0, 0, 0, .3);
  }
  body { background: radial-gradient(circle at 50% -20%, #294438, transparent 44rem), var(--page); }
  .brand-mark, .hero-token--fox, .turn-piece--fox, .goal-icon, .rule-number, .winner-emblem { background: #12261e; }
  .mode-card--active, .primary-button { color: #fff; background: linear-gradient(135deg, #386e55, #163c2d); }
  .mode-card--active .mode-icon { background: rgba(255,255,255,.11); }
  .mode-card:not(.mode-card--active) { background: rgba(255,255,255,.025); }
  .soon-badge { color: #bad8c5; }
  .board-stage::before { color: rgba(37,57,40,.72); background: rgba(28,68,47,.24); }
  .turn-card strong, .score-card strong { color: #e8eee9; }
  .goal-card strong { color: #c7d9cd; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
