@font-face {
  font-family: DM Sans;
  src: url('/fonts/dm-sans.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: Instrument Serif;
  src: url('/fonts/instrument-serif.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: "DM Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --paper: #f5f4ee;
  --panel: #fcfbf7;
  --ink: #262b24;
  --muted: #64695d;
  --line: #e2e2d8;
  --green: #264a3b;
  --green-hover: #315a49;
  --green-pale: #e7eee4;
  --gold: #e5bd73;
  --shadow: 0 1px 2px #252f2210;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid #447c62; outline-offset: 3px; }

.skip-link {
  position: fixed;
  inset: 8px auto auto 8px;
  z-index: 5;
  padding: 10px 16px;
  border-radius: 6px;
  color: white;
  background: var(--green);
  transform: translateY(-150%);
}

.skip-link:focus { transform: none; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.shell { width: min(1140px, calc(100% - 64px)); margin-inline: auto; }

.site-header {
  border-bottom: 1px solid var(--line);
  background: #faf9f4;
}

.header-inner {
  display: grid;
  min-height: 70px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
}

.wordmark {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  font: 33px/.95 var(--serif);
  letter-spacing: -.45px;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: inline-grid;
  flex: none;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  color: #f2d396;
  background: var(--green);
}

.brand-mark::before, .brand-mark::after, .brand-mark i {
  position: absolute;
  width: 19px;
  height: 19px;
  border: 1px solid currentColor;
  content: "";
}

.brand-mark::after { width: 13px; height: 13px; }
.brand-mark i { width: 7px; height: 7px; }

.site-nav { display: flex; align-items: center; gap: 5px; }

.site-nav a, .rule-button {
  display: inline-flex;
  min-height: 39px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #545b50;
  background: transparent;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover, .rule-button:hover { background: #eeeee5; }
.site-nav [aria-current] { color: #294d3d; background: var(--green-pale); }
.rule-button { justify-self: end; border-color: #e5e4dc; }

.icon { position: relative; display: inline-grid; width: 15px; height: 15px; flex: none; place-items: center; }
.icon-board { border: 1.4px solid currentColor; border-radius: 3px; }
.icon-board::after { width: 7px; height: 7px; border: 1px solid currentColor; border-radius: 1px; content: ""; }
.icon-history, .icon-info { border: 1.4px solid currentColor; border-radius: 50%; }
.icon-history::after { position: absolute; top: 2px; left: 5px; width: 4px; height: 5px; border-bottom: 1px solid; border-left: 1px solid; content: ""; }
.icon-info { font-size: 10px; line-height: 1; font-weight: 700; }

main.shell { padding-block: 31px 42px; }
.page-intro { margin-bottom: 26px; }
.page-intro h1 { margin-left: -1px; font: 400 clamp(49px, 5.1vw, 75px)/.94 var(--serif); letter-spacing: -.035em; }
.page-intro p { margin-top: 12px; color: var(--muted); font-size: 15px; }

.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) 348px; align-items: start; gap: 20px; }
.sidebar { display: grid; align-content: start; gap: 16px; }

.board-card, .panel, .stat-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.board-heading {
  display: flex;
  min-height: 81px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}

.turn-display { display: flex; min-width: 0; align-items: center; gap: 12px; }
.turn-display > .disc { width: 32px; height: 32px; }
.turn-display h2 { font: 400 31px/.95 var(--serif); letter-spacing: -.015em; }
.turn-display p { margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.35; }

.phase-label {
  display: flex;
  flex: none;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 20px;
  color: #345343;
  background: var(--green-pale);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.phase-label > span:first-child { width: 6px; height: 6px; border-radius: 50%; background: #62866b; }
.phase-label[data-phase="capture"] { color: #684415; background: #f2e5c9; }
.phase-label[data-phase="capture"] > span:first-child { background: #9d6c29; }

.board-stage {
  display: grid;
  padding: 18px;
  place-items: center;
  background: radial-gradient(ellipse at 50% 35%, #f2efe3, transparent 80%), #eeece2;
}

.board-frame {
  position: relative;
  width: min(100%, 498px);
  padding: 12px;
  aspect-ratio: 1;
  border: 1px solid #96734f;
  border-radius: 17px;
  background:
    repeating-linear-gradient(3deg, #784f2c0a 0 1px, #fff5db12 2px 4px, transparent 5px 8px),
    linear-gradient(145deg, #d0aa76 4%, #ac8054 32%, #cba373 52%, #b38b61 81%, #8e6948);
  box-shadow: inset 0 0 0 2px #ead0a675, inset 0 0 0 4px #7856376e, 0 3px 0 #8b6847, 0 10px 15px #462c2029;
}

.board {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
  border: 1px solid #17362b;
  border-radius: 8px;
  color: #d1b47f;
  background:
    repeating-linear-gradient(8deg, #ffedce03 0 1px, #0e2c210d 1px 3px, transparent 3px 5px),
    radial-gradient(ellipse at 23% 15%, #3a6650, #2d5141 61%, #244537);
  box-shadow: inset 0 0 0 2px #ebcb982e, inset 0 0 22px #102b21a0;
}

.board-grid { position: absolute; inset: 12%; }
.board-square, .board-bridge { position: absolute; color: inherit; pointer-events: none; }
.board-square { border: 1px solid currentColor; box-shadow: 0 1px 0 #17372c4a; }
.board-square.outer { inset: 0; }
.board-square.middle { inset: calc(100% / 6); }
.board-square.inner { inset: calc(100% / 3); }
.board-bridge.north, .board-bridge.south { left: 50%; height: calc(100% / 3); border-left: 1px solid currentColor; transform: translateX(-50%); }
.board-bridge.north { top: 0; }
.board-bridge.south { bottom: 0; }
.board-bridge.east, .board-bridge.west { top: 50%; width: calc(100% / 3); border-top: 1px solid currentColor; transform: translateY(-50%); }
.board-bridge.east { right: 0; }
.board-bridge.west { left: 0; }

.coordinate {
  position: absolute;
  color: #f3dcb0;
  font-size: clamp(8px, 2vw, 10px);
  font-weight: 600;
  line-height: 1;
  transform: translate(-50%, -50%);
}

.coordinate.top, .coordinate.bottom { left: calc(12% + .76 * var(--position)); }
.coordinate.top { top: 5.5%; }
.coordinate.bottom { top: 94.5%; }
.coordinate.left, .coordinate.right { top: calc(12% + .76 * var(--position)); }
.coordinate.left { left: 5.5%; }
.coordinate.right { left: 94.5%; }

.point {
  position: absolute;
  z-index: 1;
  top: var(--y);
  left: var(--x);
  display: grid;
  width: min(44px, 16.5%);
  height: auto;
  padding: 0;
  aspect-ratio: 1;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #edd39b;
  background: transparent;
  touch-action: manipulation;
  transform: translate(-50%, -50%);
}

.point[aria-disabled="true"] { cursor: default; }
.point:focus-visible { outline: 2px solid #fff1c4; outline-offset: 1px; z-index: 3; }
.point[aria-disabled="false"]:hover { z-index: 2; }
.point .intersection {
  display: grid;
  width: 16px;
  height: 16px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: #325743;
  box-shadow: 0 0 0 2px #294d3f5c;
  transition: color .16s, background .16s, box-shadow .16s;
}
.point .intersection::after { width: 4px; height: 4px; border-radius: 50%; background: currentColor; content: ""; }
.point[aria-disabled="false"]:hover .intersection, .point[data-legal] .intersection {
  color: #fff0c4;
  background: #a48243;
  box-shadow: 0 0 0 4px #f9d58529;
}

.disc {
  display: inline-block;
  flex: none;
  width: 17px;
  height: 17px;
  border: 1px solid;
  border-radius: 50%;
}

.disc-white {
  border-color: #b6a684;
  background: radial-gradient(circle at 35% 23%, #fff9e5, #f1e4c6 62%, #ceba90);
  box-shadow: inset 0 0 0 2px #fff4dbaa, 0 1px 2px #15171428;
}

.disc-black {
  border-color: #707568;
  background: radial-gradient(circle at 33% 28%, #545b4b, #31372e 57%, #1e251e 88%);
  box-shadow: inset 0 0 0 2px #dde6be21, 0 1px 2px #15171440;
}

.disc-neutral { border-color: #c5c0ae; background: #e9e7dc; }

.point .disc {
  width: 85%;
  height: auto;
  aspect-ratio: 1;
  box-shadow: inset 0 0 0 3px #fbefd24d, 0 2px 1px #15251b80, 0 4px 5px #142a2370;
}

.point .disc-black { border-color: #939784; box-shadow: inset 0 0 0 3px #cad2b024, 0 2px 1px #15251b95, 0 4px 5px #142a2390; }
.point .disc-white { border-color: #e3c895; }
.point[data-last] .disc { outline: 1px dashed #f2dc9a; outline-offset: 2px; }
.point[data-selected] .disc, .point[aria-disabled="false"]:hover .disc { outline: 2px solid #f9deb0; outline-offset: 2px; }
.point[data-target] .disc { outline: 2px solid var(--gold); outline-offset: 3px; }
.point[data-target]:hover .disc { outline-color: #fff3c7; }

.board-footer {
  display: grid;
  min-height: 48px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

#move-count { color: #40493e; font-weight: 700; white-space: nowrap; }
.board-feedback { color: #8a432c; font-weight: 650; text-align: center; }
.last-move { text-align: right; }
.setup-shortcut { display: none; }

.setup-panel, .players-panel { padding: 19px; }
.panel h2 { font: 400 32px/1 var(--serif); letter-spacing: -.015em; }
#game-setup { display: grid; gap: 14px; margin-top: 16px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 6px; padding: 0; color: #555c51; font-size: 12px; font-weight: 700; }
.segmented { display: flex; gap: 3px; padding: 3px; border: 1px solid #e9e8de; border-radius: 8px; background: #efefe8; }
.segmented label { position: relative; min-width: 0; flex: 1; cursor: pointer; }
.segmented input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.segmented label > span { display: flex; min-height: 34px; align-items: center; justify-content: center; gap: 7px; padding: 4px; border: 1px solid transparent; border-radius: 6px; color: #555c51; font-size: 12px; font-weight: 650; text-align: center; }
.segmented label:hover > span { color: var(--green); background: #f5f5ed; }
.segmented input:checked + span { border-color: #dfe3d9; color: #244635; background: #fffefa; box-shadow: 0 1px 2px #252f2211; }
.segmented input:focus-visible + span { outline: 2px solid #447c62; outline-offset: 0; }
.side-choices .disc { width: 13px; height: 13px; }

.button {
  display: inline-flex;
  min-height: 42px;
  width: fit-content;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}

.button.primary { color: #fffdf4; background: var(--green); }
.button.primary:hover { background: var(--green-hover); }
.button.secondary { border-color: #dedfd5; color: var(--green); background: #f9f9f2; }
.button.secondary:hover { background: var(--green-pale); }
.start-button { width: 100%; justify-content: space-between; min-height: 46px; margin-top: 2px; }
.start-button > span:last-child { font-size: 20px; font-weight: 500; line-height: 1; }
.settings-note { color: var(--muted); font-size: 12px; text-align: center; }

.players-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.players-heading p { color: var(--muted); font-size: 11px; font-weight: 600; }
.player-card { display: flex; min-height: 61px; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid #ebeae1; border-radius: 9px; background: #f7f6ef; }
.player-card + .player-card { margin-top: 7px; }
.player-card[data-current] { border-color: #cddcd0; background: #eef3ea; }
.player-disc { width: 27px; height: 27px; }
.player-identity { display: grid; min-width: 0; gap: 2px; }
.player-identity strong { font-size: 13px; font-weight: 700; }
.player-role, .piece-count { color: var(--muted); font-size: 11px; line-height: 1.2; }
.reserve { display: grid; justify-items: end; gap: 5px; margin-left: auto; white-space: nowrap; }
.reserve-pieces { display: flex; gap: clamp(2px, .34vw, 4px); }
.reserve-pieces .disc { width: 9px; height: 9px; box-shadow: none; }
.reserve-pieces .disc.is-spent { border-color: #c2c6b8; background: transparent; }

.history-intro { display: flex; align-items: end; justify-content: space-between; gap: 14px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.stat-card { display: grid; gap: 13px; padding: 18px; }
.stat-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.stat-heading h2 { font: 400 30px/1 var(--serif); }
.stat-heading p { color: var(--muted); font-size: 12px; }
.stat-score { display: flex; align-items: baseline; gap: 8px; }
.stat-score strong { color: var(--green); font: 400 46px/.8 var(--serif); }
.stat-score span { color: var(--muted); font-size: 12px; }
.stat-bar { display: flex; min-height: 5px; overflow: hidden; border-radius: 8px; background: #eaeae1; }
.stat-bar span:nth-child(1) { background: #51765a; }
.stat-bar span:nth-child(2) { background: #b68b56; }
.stat-bar span:nth-child(3) { background: #999d8b; }
.stat-breakdown { display: flex; flex-wrap: wrap; gap: 5px 13px; margin: 0; color: var(--muted); font-size: 12px; }
.stat-breakdown div { display: flex; gap: 4px; }
.stat-breakdown dd { order: -1; margin: 0; color: var(--ink); font-weight: 700; }

#history-feedback { margin-bottom: 12px; color: var(--muted); }
.matches-panel { margin-top: 17px; }
.matches-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px; }
.matches-heading p { margin-top: 6px; color: var(--muted); font-size: 13px; }
.history-empty { display: grid; justify-items: center; gap: 9px; padding: 36px 16px 44px; border-top: 1px solid var(--line); text-align: center; }
.history-empty h3 { font: 400 33px/1 var(--serif); }
.history-empty p { color: var(--muted); }
.history-empty a { margin-top: 4px; color: var(--green); font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 18px; border-top: 1px solid var(--line); text-align: left; }
th { color: #555c51; background: #f2f2ea; font-size: 12px; }
td { min-width: 0; font-size: 13px; }
td:last-child { width: 1%; text-align: center; }
td > small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.result-tag { display: inline-block; padding: 4px 8px; border-radius: 5px; color: #4d5549; background: #edece3; font-size: 11px; font-weight: 700; }
.result-tag[data-status="finished"] { color: var(--green); background: var(--green-pale); }
.load-more { margin: 12px 18px 18px; }

dialog {
  width: min(100% - 28px, 520px);
  max-height: calc(100% - 28px);
  padding: 22px;
  border: 1px solid #dedfd4;
  border-radius: 15px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 18px 54px #142c2452;
}

dialog::backdrop { background: #162c256b; backdrop-filter: blur(2px); }
.dialog-title { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.dialog-title h2 { font: 400 42px/1 var(--serif); }
.dialog-close { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: #f5f5ef; font-size: 22px; line-height: 1; }
.dialog-close:hover { background: var(--green-pale); }
dialog > p { margin-bottom: 16px; color: #545b50; line-height: 1.55; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.rule-steps { display: grid; gap: 5px; padding-left: 25px; color: var(--green); }
.rule-steps li { padding: 5px 0 5px 3px; }
.rule-steps li span { display: block; margin-top: 2px; color: #545b50; }

@media (max-width: 900px) {
  .play-layout { grid-template-columns: minmax(0, 1fr) 285px; gap: 14px; }
  .setup-panel, .players-panel { padding: 14px; }
  .board-heading { padding-inline: 14px; }
  .board-footer { padding-inline: 12px; }
  .board-stage { padding: 12px; }
  .board-frame { padding: 9px; }
}

@media (max-width: 700px) {
  .shell { width: calc(100% - 24px); }
  .header-inner { grid-template-columns: 1fr auto; gap: 6px; padding-block: 9px; }
  .site-nav { grid-column: 1 / -1; grid-row: 2; }
  .wordmark { font-size: 29px; }
  .brand-mark { width: 29px; height: 29px; border-radius: 7px; }
  .rule-button { grid-column: 2; grid-row: 1; }
  main.shell { padding-top: 21px; }
  .page-intro { margin-bottom: 17px; }
  .page-intro p { margin-top: 8px; font-size: 13px; }
  .play-layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 12px; }
  .board-stage { padding: 12px; }
  .board-frame { width: min(100%, 480px); }
  .setup-shortcut { display: block; color: var(--green); font-weight: 700; text-align: right; }
  .setup-shortcut:not([hidden]) + .last-move { display: none; }
  .stats-grid { gap: 7px; }
  .stat-card { padding: 10px; }
  .stat-score { display: grid; gap: 3px; }
  .stat-score strong { font-size: 38px; }
  .stat-heading { display: grid; gap: 2px; }
}

@media (max-width: 480px) {
  .board-heading { min-height: 69px; }
  .turn-display h2 { font-size: 26px; }
  .turn-display p { font-size: 11px; }
  .turn-display { gap: 8px; }
  .turn-display > .disc { width: 23px; height: 23px; }
  .phase-label { padding: 6px 7px; font-size: 9px; }
  .board-stage { padding: 9px; }
  .board-frame { padding: 7px; border-radius: 12px; }
  .point .intersection { width: 13px; height: 13px; }
  .point .disc { width: 78%; }
  .sidebar { grid-template-columns: 1fr; }
  .board-footer { min-height: 42px; padding: 7px 8px; font-size: 11px; }
  .history-intro { display: block; }
  .history-play { margin-top: 12px; }
  .stat-heading h2 { font-size: 25px; }
  .stat-heading p, .stat-score span, .stat-breakdown { font-size: 10px; }
  .stat-breakdown { display: grid; gap: 2px; }
  th, td { padding: 8px; }
  td { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
