:root {
  color-scheme: light;
  font: 100%/1.4 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #262925; background: #faf9f6;
  --ink: #262925; --muted: #676961; --edge: #cfcec7;
  --red: #c4443b; --blue: #3e66b4;
}
* { box-sizing: border-box; }
body, h1, h2, p { margin: 0; }
main {
  width: min(760px, 100%); margin-inline: auto; height: 100svh; min-height: min-content;
  padding: max(18px, env(safe-area-inset-top)) clamp(12px, 4vw, 32px) max(16px, env(safe-area-inset-bottom));
  display: grid; grid-template-rows: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  justify-items: center; gap: 12px;
}
header, footer { width: 100%; }
header, .turn, .dialog-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
header { align-self: start; align-items: center; }
.game-screen {
  height: 100dvh; min-height: 0; padding-block: 0;
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
}
.game-screen header { padding-top: max(12px, env(safe-area-inset-top)); }
.game-screen #board { width: min(100%, 506px, 58dvh); }
.game-screen footer {
  align-self: stretch; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; gap: 10px;
  min-height: 0; padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.game-controls { overflow-y: auto; }
@media (orientation: portrait) and (max-height: 650px) {
  .game-screen #board { max-width: max(220px, calc(100dvh - 320px)); }
}
@media (orientation: landscape) and (max-height: 540px) and (min-width: 560px) {
  .game-screen { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: 24px; }
  .game-screen #board { grid-area: 1 / 1 / 3 / 2; width: min(100%, 94dvh); align-self: center; }
  .game-screen header, .game-screen footer { grid-column: 2; }
  .game-screen header { grid-row: 1; }
  .game-screen footer { grid-row: 2; }
}
h1 { font: 500 clamp(2.5rem, 7vw, 3.8rem)/1 Baskerville, "Baskerville Old Face", Georgia, serif; letter-spacing: -.065em; }
button {
  font: inherit; font-weight: 580; color: var(--ink); background: transparent;
  border: 1px solid var(--edge); border-radius: 999px; min-height: 46px; padding: 8px 16px;
  touch-action: manipulation; cursor: pointer;
}
button:disabled { color: #83857d; border-color: #deded7; cursor: default; }
button.primary { color: #fff; background: var(--ink); border-color: var(--ink); }
button:focus-visible, label:focus-within { outline: 3px solid var(--blue); outline-offset: 3px; }
.icon-button { display: inline-grid; place-items: center; min-width: 46px; padding: 0 10px; }
.icon-button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#settings { border-color: transparent; }
#board { width: min(100%, 506px, max(64svh, 280px)); height: auto; display: block; overflow: visible;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.tile { fill: #f1f0e9; stroke: #aaa99d; stroke-width: 1.15; stroke-linejoin: round; }
.hex[aria-disabled=false] { cursor: pointer; }
.hex:focus { outline: none; }
.hex:focus-visible .tile { stroke: var(--blue); stroke-width: 3; }
.hex.deciding .tile { fill: #e2e1d4; stroke: #838778; }
.hex[data-policy] .tile { fill: color-mix(in srgb, #446555 var(--heat), #f1f0e9); }
.policy-percent { text-anchor: middle; dominant-baseline: central; fill: var(--ink); font-size: 13px; font-weight: 600; pointer-events: none; }
.policy-percent.light { fill: white; }
.stone-svg.red, .stone.red { fill: var(--red); background-color: var(--red); }
.stone-svg.blue, .stone.blue { fill: var(--blue); background-color: var(--blue); }
.disc-edge.red { fill: #97342d; } .disc-edge.blue { fill: #2e4c84; }
.last-mark, .result-line { pointer-events: none; }
.last-mark { fill: #fff; } .result-line { stroke: white; stroke-width: 3; stroke-linecap: round; }
footer { align-self: end; max-width: 480px; padding: 0 clamp(0px, 1vw, 7px); }
h2 { font-size: 1.24rem; line-height: 1.25; font-weight: 630; letter-spacing: -.035em; }
#detail, #policy-note, .caption, dialog p, legend, small { color: var(--muted); }
#detail, #policy-note, .caption, small { font-size: .875rem; }
#policy-note { margin-top: 3px; }
#detail { margin-top: 3px; }
.odds-labels { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-bottom: 7px;
  font-size: .925rem; font-variant-numeric: tabular-nums; }
.red-label, .blue-label { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.red-label .dot { background: var(--red); } .blue-label .dot { background: var(--blue); }
#odds-bar { overflow: hidden; height: 8px; border-radius: 9px; background: var(--blue); }
#red-bar { position: relative; display: block; height: 100%; background: var(--red); width: 50%; transition: width .48s cubic-bezier(.22,.7,.25,1); }
#red-bar::after {
  content: ''; position: absolute; inset: 0 -36px 0 auto; width: 72px; opacity: 0;
  background: linear-gradient(90deg, var(--red), #946484 50%, var(--blue));
  transition: opacity .28s ease;
}
#odds-bar.pending #red-bar::after { opacity: 1; transition-delay: .12s; animation: blend 1.6s ease-in-out infinite alternate; }
@keyframes blend { from { transform: scaleX(.7); } to { transform: scaleX(1.3); } }
.actions { display: flex; gap: 8px; }
.actions button { flex: 1; padding-inline: 8px; }
.actions .icon-button { flex: 0 0 48px; }
.menu-actions { margin-bottom: 20px; }
.policy-option { margin-top: 18px; justify-content: space-between; }
.policy-option small { display: block; margin-top: 2px; }
#view-policy {
  appearance: none; flex: 0 0 40px; height: 24px; margin: 0; border: 1px solid var(--edge);
  border-radius: 20px; background: #dadbd4; cursor: pointer;
}
#view-policy::before { content: ''; display: block; width: 16px; height: 16px; margin: 3px; border-radius: 100%; background: white; }
#view-policy:checked { background: #446555; border-color: #446555; }
#view-policy:checked::before { transform: translateX(16px); }
#swap { color: #264c91; border-color: #92a8ce; background: #edf1f8; }
@media (hover:hover) { .hex[aria-disabled=false]:hover .tile { fill: #e1e2d8; } button:enabled:hover { filter: brightness(.92); } }
@media (max-width: 300px) {
  .odds-labels { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
  .caption { grid-column: 1/-1; grid-row: 1; }
  .blue-label { justify-self: end; }
}
@media (prefers-reduced-motion: reduce) {
  #red-bar, #red-bar::after { transition: none; }
  #odds-bar.pending #red-bar::after { animation: none; }
}
[hidden] { display: none !important; }
dialog { width: min(370px, calc(100% - 28px)); padding: 23px; color: inherit; background: #faf9f6;
  border: 1px solid var(--edge); border-radius: 17px; box-shadow: 0 14px 60px #161b182b; }
dialog::backdrop { background: #20261f59; }
.dialog-head { align-items: center; margin-bottom: 12px; }
.dialog-head h2 { font-size: 1.65rem; }
.dialog-head .close { min-width: 44px; padding: 4px; font-size: 1.45rem; }
dialog .primary { width: 100%; margin-top: 19px; }
.rules-list > div { padding: 12px 0; border-top: 1px solid var(--edge); }
.example { letter-spacing: 3px; line-height: 1; } .win { color: var(--blue); } .lose { color: var(--red); }
fieldset { padding: 0; margin: 0; border: 0; }
label { display: flex; align-items: center; gap: 10px; border: 1px solid var(--edge); border-radius: 10px; margin-top: 8px; padding: 12px; cursor: pointer; }
label small { margin-left: auto; }
.stone { width: 18px; height: 18px; border-radius: 50%; }
input { accent-color: var(--ink); }
#winner-form { margin-top: 10px; }
#winner-form label { display: block; margin: 0 0 4px; padding: 0; border: 0; font-size: .9rem; cursor: text; }
#winner-form div { display: flex; gap: 8px; }
#winner-name { flex: 1; min-width: 0; border: 1px solid var(--edge); border-radius: 8px; padding: 8px; font: inherit; }
#name-status:not(:empty) { margin-top: 6px; font-size: .9rem; }
textarea { width: 100%; resize: vertical; border: 1px solid var(--edge); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 12px; font: 1rem/1.45 ui-monospace, monospace; }
#copy-status:not(:empty) { margin-top: 10px; }
.verify-page { display: block; max-width: 560px; height: auto; }
.verify-page header { margin-bottom: 32px; }
.verify-page a { color: var(--ink); }
.verify-page p { margin: 8px 0 14px; }
.verify-page form button { width: 100%; margin-top: 8px; }
.verify-page #replay { margin-top: 24px; }
.verify-page #board { margin: 12px auto; }
