:root {
  color-scheme: light;
  --canvas: #efeee7;
  --paper: #faf9f3;
  --paper-deep: #e8e8dd;
  --ink: #252e28;
  --ink-soft: #56645a;
  --ink-muted: #6b786e;
  --line: #d4d9cf;
  --green: #385641;
  --green-deep: #263d30;
  --green-pale: #e5ebe1;
  --brass: #b1834d;
  --red: #9d5144;
  --board-light: #ece9d7;
  --board-dark: #7d9878;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--canvas); }
button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid #bc8a4f; outline-offset: 3px; }
button:disabled { cursor: not-allowed; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 224px minmax(0, 1fr); }

/* The navigation is a quiet, permanent rail. */
.sidebar {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  padding: 25px 15px 18px;
  color: #f2f0e6;
  background: #243a30;
  border-right: 1px solid #344a3d;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 35px; color: inherit; text-decoration: none; }
.brand-mark, .dialog-mark {
  display: grid;
  flex: none;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff8e9;
  background: var(--brass);
  border-radius: 4px;
  font: 27px/1 Georgia, "Times New Roman", serif;
}
.brand-copy { display: flex; flex-direction: column; gap: 4px; }
.brand-copy strong { color: #fffaf0; font: 600 22px/1 Georgia, "Times New Roman", serif; letter-spacing: -.35px; }
.brand-copy small { color: #b9c4b7; font-size: 8px; font-weight: 700; letter-spacing: 1.25px; }
.nav-label, .section-kicker, .choice-label, .move-heading, .page-footer {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.1px;
}
.nav-label { padding: 0 12px 9px; color: #aebbad; }
.nav-list { display: grid; gap: 3px; }
.nav-link {
  position: relative;
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border-left: 2px solid transparent;
  color: #c5d0c4;
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
  transition: color .15s, background-color .15s;
}
.nav-link svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-link:hover { color: #fffaf0; background: rgba(255, 255, 255, .055); }
.nav-link.is-active { border-left-color: #c69a62; color: #fff8e7; background: #30493a; }
.nav-link-muted { color: #bdcabb; }
.sidebar-spacer { flex: 1; min-height: 80px; }
.engine-card { padding: 15px 10px 2px; border-top: 1px solid rgba(223, 231, 215, .2); }
.engine-card-top { display: flex; align-items: center; gap: 9px; color: #c5d0c1; font-size: 11px; font-weight: 600; }
.engine-dot, .online-indicator, .local-badge span { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #c39255; }
.engine-dot.is-online, .online-indicator.is-online, .local-badge.is-online span { background: #9dbc83; }
.engine-dot.is-offline, .online-indicator.is-offline { background: #d28773; }
.engine-name { margin-top: 13px; color: #fffaf0; font: 600 15px/1.3 Georgia, "Times New Roman", serif; }
.engine-name span { margin-left: 7px; color: #d7bd91; font: 700 9px/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: 1px; }
.engine-card p { margin: 5px 0 12px; color: #b7c3b5; font-size: 11px; line-height: 1.5; }
.text-button { padding: 0; border: 0; color: #e3c795; background: none; font-size: 11px; font-weight: 650; cursor: pointer; }
.text-button:hover { color: #fff3d9; }
.text-button span { padding-left: 3px; font-size: 13px; }

/* Main workspace */
.main-area { width: 100%; max-width: 1600px; min-width: 0; margin: 0 auto; padding: 0 40px 20px; }
.topbar { display: flex; height: 64px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.breadcrumbs { display: flex; align-items: center; gap: 10px; color: var(--ink-muted); font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.breadcrumbs i { color: #99a096; font-style: normal; }
.breadcrumbs strong { color: var(--green-deep); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.local-badge { display: inline-flex; min-height: 34px; align-items: center; gap: 8px; padding: 0; border: 0; color: var(--ink-soft); background: transparent; font-size: 12px; cursor: pointer; }
.local-badge:hover { color: var(--green-deep); }
.local-badge span { width: 7px; height: 7px; }
.icon-button { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid transparent; border-radius: 3px; color: var(--ink-soft); background: transparent; cursor: pointer; transition: color .15s, background-color .15s, border-color .15s; }
.icon-button:hover { border-color: var(--line); color: var(--green-deep); background: var(--paper); }
.theme-button[aria-pressed="true"] { border-color: #bfcabb; color: var(--green-deep); background: var(--green-pale); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.theme-button .theme-icon-moon { display: none; }
.theme-button[aria-pressed="true"] .theme-icon-sun { display: none; }
.theme-button[aria-pressed="true"] .theme-icon-moon { display: block; }
.page-intro { padding: 25px 0 21px; }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 9px; color: var(--ink-muted); font-size: 10px; font-weight: 700; letter-spacing: 1.25px; }
.eyebrow-line { width: 20px; height: 1px; background: var(--brass); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; color: #26362d; font: 500 clamp(27px, 2.25vw, 34px)/1.12 Georgia, "Times New Roman", serif; letter-spacing: -.5px; }
.intro-copy { max-width: 620px; margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }

/* Time and side controls form one compact setup strip. */
.pace-card { padding: 15px 0 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: transparent; }
.pace-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 10px; }
.section-kicker { color: var(--ink-muted); font-size: 10px; }
.pace-heading h2, .game-panel-head h2 { margin: 4px 0 0; color: #2d3a31; font: 600 17px/1.2 Georgia, "Times New Roman", serif; }
.pace-controls { display: grid; grid-template-columns: minmax(310px, 1fr) 1px auto auto; align-items: center; gap: 21px; }
.mode-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.mode-tab {
  display: flex;
  min-width: 0;
  min-height: 47px;
  align-items: center;
  padding: 4px 7px 5px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-soft);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.mode-tab:hover:not(:disabled) { color: var(--green-deep); }
.mode-tab.is-selected { border-bottom-color: var(--green); color: var(--green-deep); }
.mode-tab:disabled { color: #667268; cursor: not-allowed; }
.mode-text { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.mode-text strong { font-size: 13px; font-weight: 700; }
.mode-text small { color: var(--ink-muted); font-size: 11px; line-height: 1.2; white-space: nowrap; }
.settings-divider { width: 1px; height: 40px; background: var(--line); }
.control-picks { display: flex; align-items: center; justify-content: flex-start; gap: 19px; }
.choice-group { display: grid; gap: 7px; }
.choice-label { color: var(--ink-muted); font-size: 10px; }
.choice-options, .side-options { display: flex; align-items: center; gap: 5px; }
.time-option { min-width: 48px; height: 33px; padding: 0 9px; border: 1px solid #cbd2c7; border-radius: 2px; color: var(--ink-soft); background: var(--paper); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 600; cursor: pointer; transition: border-color .15s, color .15s, background-color .15s; }
.time-option:hover:not(:disabled) { border-color: var(--green); }
.time-option.is-selected { border-color: var(--green); color: #fffdf5; background: var(--green); }
.time-option:disabled:not(.is-selected) { border-color: #c9cec5; color: #59665b; background: #e7e8e1; }
.side-options { gap: 4px; }
.side-option { display: flex; min-height: 33px; align-items: center; gap: 6px; padding: 0 7px; border: 1px solid transparent; border-radius: 2px; color: var(--ink-soft); background: transparent; font-size: 12px; cursor: pointer; transition: border-color .15s, background-color .15s; }
.side-option:hover:not(:disabled) { border-color: var(--line); }
.side-option.is-selected { border-color: #bfcabb; color: var(--green-deep); background: var(--green-pale); }
.side-option:disabled { color: var(--ink-muted); cursor: not-allowed; }
.random-side-option span { color: var(--brass); font-size: 15px; line-height: 1; }
.side-disc { width: 11px; height: 11px; border: 1px solid #737e75; border-radius: 50%; }
.side-disc-white { background: #fffefa; }
.side-disc-black { border-color: #26332b; background: #26332b; }
.new-game-button { display: flex; min-width: 126px; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 1px solid var(--green); border-radius: 2px; color: #fffdf5; background: var(--green); font-size: 13px; font-weight: 700; cursor: pointer; transition: background-color .15s, border-color .15s; }
.new-game-button:hover:not(:disabled) { border-color: var(--green-deep); background: var(--green-deep); }
.new-game-button:disabled { border-color: #bcc5b9; color: #4e5c51; background: #dce1d8; }
.new-game-button.is-loading { cursor: progress; }
.new-game-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Board first; supporting game information sits alongside it. */
.play-layout { display: grid; max-width: 1250px; grid-template-columns: minmax(0, 1fr) 292px; align-items: start; gap: 31px; margin: 24px auto 0; }
.board-column { width: 100%; max-width: 760px; min-width: 0; margin: 0 auto; }
.player-strip { display: flex; min-height: 53px; align-items: center; justify-content: space-between; gap: 10px; padding: 0 2px; }
.person-block { display: flex; min-width: 0; align-items: center; gap: 10px; }
.opponent-avatar, .self-avatar { display: grid; width: 32px; height: 32px; flex: none; place-items: center; color: #fff9e9; background: var(--green); border-radius: 3px; font: 22px/1 Georgia, "Times New Roman", serif; }
.self-avatar { color: #fff9e9; background: var(--brass); font: 700 12px/1 ui-sans-serif, system-ui, sans-serif; }
.person-name { display: flex; align-items: center; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 700; }
.person-caption { margin-top: 3px; color: var(--ink-muted); font-size: 11px; }
.online-indicator { width: 7px; height: 7px; }
.player-badges { display: flex; align-items: center; gap: 7px; }
.badge { display: inline-flex; min-height: 22px; align-items: center; padding: 0 6px; border-left: 2px solid #afbdab; color: var(--ink-muted); font-size: 9px; font-weight: 700; letter-spacing: .55px; }
.badge-model { border-left-color: var(--brass); color: #6a5b47; }
.badge-turn { border-left-color: #a7afa5; color: var(--ink-muted); }
.badge-turn.is-live { border-left-color: var(--green); color: var(--green-deep); }
.clock-box { display: flex; width: 108px; min-height: 40px; flex: none; align-items: center; justify-content: center; gap: 8px; border: 1px solid #cfd5ca; border-radius: 2px; color: #28352c; background: var(--paper); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .3px; }
.clock-icon { color: var(--ink-muted); font: 16px/1 Georgia, "Times New Roman", serif; }
.clock-box.is-running { border-color: var(--green-deep); color: #fffdf3; background: var(--green-deep); }
.clock-box.is-running .clock-icon { color: #d5e0d0; }
.clock-box.is-low { border-color: var(--red); color: #fffaf4; background: var(--red); }
.board-frame { position: relative; margin: 2px 0 3px; padding: 8px 8px 22px 22px; border: 1px solid #263a2d; background: #304839; }
.board { position: relative; display: grid; width: 100%; aspect-ratio: 1; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 0; overflow: hidden; border: 1px solid rgba(31, 45, 34, .55); background: var(--board-light); touch-action: none; }
.square { position: relative; display: grid; width: 100%; height: 100%; min-width: 0; min-height: 0; place-items: center; appearance: none; margin: 0; padding: 0; border: 0; outline: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.square.light { background: var(--board-light); }
.square.dark { background: var(--board-dark); }
.square.last-move.light { background: #e4d994; }
.square.last-move.dark { background: #a7ae62; }
.square.selected::after { position: absolute; z-index: 1; border: 3px solid #e4b451; background: rgba(232, 194, 87, .24); content: ""; inset: 0; pointer-events: none; }
.square.in-check::after { position: absolute; z-index: 1; background: rgba(165, 72, 56, .55); box-shadow: inset 0 0 0 3px rgba(255, 248, 235, .55); content: ""; inset: 0; pointer-events: none; }
.square.legal-empty::before { position: absolute; z-index: 2; width: 22%; height: 22%; border-radius: 50%; background: rgba(34, 49, 37, .35); content: ""; pointer-events: none; }
.square.legal-capture::before { position: absolute; z-index: 2; border: 4px solid rgba(34, 49, 37, .32); border-radius: 50%; content: ""; inset: 5%; pointer-events: none; }
.square.premove-target::before { position: absolute; z-index: 2; width: 25%; height: 25%; border: 2px dashed rgba(37, 55, 39, .62); border-radius: 50%; background: rgba(255, 255, 255, .14); content: ""; pointer-events: none; }
.square.premove-target.premove-destination::before { width: auto; height: auto; border: 3px dashed rgba(200, 148, 60, .92); border-radius: 50%; background: rgba(224, 186, 95, .22); inset: 6%; }
.square.premove-source::after { position: absolute; z-index: 1; border: 3px dashed #c8943c; background: rgba(224, 186, 95, .2); content: ""; inset: 0; pointer-events: none; }
.square.premove-destination::after { position: absolute; z-index: 1; border: 3px dashed #c8943c; background: rgba(224, 186, 95, .18); content: ""; inset: 0; pointer-events: none; }
.square:hover::before { filter: brightness(.72); }
.piece-svg { position: relative; z-index: 3; display: block; width: 82%; height: 82%; object-fit: contain; user-select: none; pointer-events: none; }
.piece-svg.is-drag-source { opacity: .22; }
.piece-drag-ghost { position: fixed !important; z-index: 20 !important; top: 0; left: 0; margin: 0; opacity: .96; pointer-events: none; will-change: transform; filter: drop-shadow(0 7px 6px rgba(20, 30, 22, .28)); }
.piece-pending-ghost { transition: transform 120ms cubic-bezier(.2, .75, .25, 1); }
.piece-move-ghost { position: fixed !important; z-index: 20 !important; top: 0; left: 0; margin: 0; opacity: 1; pointer-events: none; will-change: transform; }
.board.is-dragging, .board.is-dragging .square { cursor: grabbing; }
.opponent-avatar img, .self-avatar img { display: block; width: 82%; height: 82%; object-fit: contain; }
.board-coordinates { position: absolute; color: #dfd0a8; font: 700 9px/1 ui-sans-serif, system-ui, sans-serif; }
.board-coordinates-left { top: 8px; bottom: 22px; left: 4px; display: grid; width: 13px; grid-template-rows: repeat(8, 1fr); align-items: center; justify-items: center; }
.board-coordinates-bottom { right: 8px; bottom: 4px; left: 22px; display: grid; grid-template-columns: repeat(8, 1fr); justify-items: center; }
.board-sheen { position: absolute; border: 1px solid rgba(27, 43, 32, .38); inset: 8px 8px 22px 22px; pointer-events: none; }
.square:disabled { cursor: default; }
.is-disabled-game .square { cursor: default; }

.game-panel { display: flex; min-height: 515px; flex-direction: column; padding: 4px 0 0 23px; border-left: 1px solid var(--line); }
.game-panel-head { display: flex; min-height: 50px; align-items: center; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.game-panel-head h2 { font-size: 19px; }
.panel-menu-button { width: 36px; height: 36px; }
.panel-menu-button svg { width: 18px; height: 18px; }
.turn-card { display: flex; min-height: 62px; align-items: center; gap: 11px; margin: 16px 0 20px; padding: 9px 10px; border-left: 3px solid #a7b29f; color: var(--ink); background: #e8eae1; }
.turn-card.is-live { border-left-color: var(--green); background: #e6ebe1; }
.turn-card.is-over { border-left-color: var(--brass); background: #eee9dc; }
.turn-icon { display: grid; width: 22px; flex: none; place-items: center; color: var(--green); font: 600 15px/1 Georgia, "Times New Roman", serif; }
.turn-card.is-over .turn-icon { color: #81613d; }
.turn-card strong, .turn-card small { display: block; }
.turn-card strong { color: var(--ink); font-size: 13px; font-weight: 700; }
.turn-card small { margin-top: 4px; color: var(--ink-soft); font-size: 11px; line-height: 1.35; }
.move-section { display: flex; min-height: 215px; flex: 1; flex-direction: column; }
.move-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 0 9px; border-bottom: 1px solid var(--line); color: var(--ink-muted); font-size: 10px; }
.move-count { color: var(--ink-muted); font-size: 11px; font-weight: 500; letter-spacing: 0; }
.move-list { max-height: 270px; overflow-y: auto; padding: 4px 0; scrollbar-color: #aeb8aa transparent; scrollbar-width: thin; }
.empty-moves { display: flex; min-height: 150px; align-items: center; color: var(--ink-soft); }
.empty-moves p { margin: 0; font-size: 13px; font-weight: 600; line-height: 1.65; }
.empty-moves small { color: var(--ink-muted); font-size: 11px; font-weight: 400; }
.move-row { display: grid; min-height: 34px; grid-template-columns: 34px 1fr 1fr; align-items: center; border-bottom: 1px solid #e4e6dd; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.move-number { color: var(--ink-muted); font-size: 11px; }
.move-san { color: #344139; font-weight: 550; }
.move-san.latest { color: var(--green-deep); font-weight: 750; }
.panel-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding-top: 13px; border-top: 1px solid var(--line); }
.panel-action { display: flex; min-width: 0; min-height: 38px; align-items: center; justify-content: center; gap: 6px; padding: 0 5px; border: 1px solid #cfd6cc; border-radius: 2px; color: var(--ink-soft); background: var(--paper); font-size: 11px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: color .15s, border-color .15s, background-color .15s; }
.panel-action:hover:not(:disabled) { border-color: var(--green); color: var(--green-deep); background: #f0f2eb; }
.panel-action:disabled { color: #58655c; background: #eeeee8; }
.panel-action svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sound-action[aria-pressed="true"] { color: var(--green-deep); }
.sound-action.is-muted { color: var(--ink-muted); background: #eeeee8; }
.resign-action { color: #814a3e; }
.game-footnote { margin-top: auto; padding: 12px 1px 0; color: var(--ink-muted); font-size: 11px; line-height: 1.4; }
.page-footer { display: flex; max-width: 1250px; justify-content: space-between; margin: 24px auto 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink-muted); font-size: 9px; letter-spacing: .8px; }
.page-footer i { padding: 0 4px; color: #959d91; font-style: normal; }
.page-footer span:last-child { color: var(--ink-soft); font-size: 11px; font-weight: 500; letter-spacing: 0; }

/* Feedback and dialogs stay plain and easy to dismiss. */
.toast { position: fixed; z-index: 10; right: 20px; bottom: 20px; max-width: min(390px, calc(100vw - 40px)); padding: 12px 15px; transform: translateY(8px); border: 1px solid #bfc9bc; color: #29392e; background: var(--paper); font-size: 13px; line-height: 1.45; opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
.setup-dialog, .pgn-dialog { color: var(--ink); background: var(--paper); box-shadow: 0 18px 55px rgba(25, 38, 29, .24); }
.setup-dialog { position: relative; width: min(460px, calc(100% - 32px)); padding: 27px; border: 1px solid #cbd2c7; }
.setup-dialog::backdrop, .pgn-dialog::backdrop { background: rgba(22, 35, 27, .58); }
.setup-dialog form { position: relative; }
.dialog-close { position: absolute; top: -15px; right: -15px; font-size: 23px; }
.dialog-mark { width: 42px; height: 42px; margin-bottom: 17px; }
.setup-dialog h2 { margin: 6px 0 10px; color: #28392e; font: 600 23px/1.2 Georgia, "Times New Roman", serif; }
.setup-dialog p { margin-bottom: 13px; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.setup-dialog pre { overflow-x: auto; margin: 15px 0; padding: 13px; border: 1px solid var(--line); color: #344b39; background: #eff0e9; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.setup-dialog .dialog-foot { margin-bottom: 18px; color: var(--ink-muted); font-size: 12px; }
.dialog-done { width: 100%; min-height: 42px; border: 1px solid var(--green); color: #fffdf5; background: var(--green); font-size: 13px; font-weight: 700; cursor: pointer; }
.dialog-done:hover { background: var(--green-deep); }
.pgn-dialog { width: min(760px, calc(100vw - 32px)); max-width: none; padding: 22px; border: 1px solid #cbd2c7; }
.pgn-dialog-shell { display: flex; flex-direction: column; gap: 12px; }
.pgn-dialog-head { display: flex; align-items: center; justify-content: space-between; }
.pgn-dialog-head h2 { margin: 4px 0 0; color: #28392e; font: 600 22px/1.2 Georgia, "Times New Roman", serif; }
.pgn-hint { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.pgn-hint code { color: var(--green-deep); font: 600 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
#pgn-text { width: 100%; min-height: 240px; resize: vertical; padding: 13px; border: 1px solid #cbd2c7; border-radius: 2px; color: #344139; background: #fbfbf6; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; tab-size: 2; }
#pgn-text:focus { outline: 2px solid rgba(77, 112, 76, .34); border-color: var(--green); }
.pgn-dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink-muted); font-size: 11px; }
.pgn-dialog-foot > div { display: flex; flex: none; gap: 8px; }
.pgn-file-button, .pgn-submit-button { min-height: 38px; padding: 0 12px; border: 1px solid #9eac9d; color: var(--green-deep); background: var(--paper); font-size: 12px; font-weight: 650; cursor: pointer; }
.pgn-file-button:hover { border-color: var(--green); background: var(--green-pale); }
.pgn-submit-button { border-color: var(--green); color: #fffdf5; background: var(--green); }
.pgn-submit-button:hover:not(:disabled) { background: var(--green-deep); }
.pgn-submit-button:disabled { opacity: .55; cursor: progress; }
.review-controls { display: grid; gap: 9px; margin: -5px 0 14px; padding: 11px 0 13px; border-bottom: 1px solid var(--line); }
.review-controls[hidden], .resign-action[hidden] { display: none; }
.review-navigation { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.review-navigation button { min-height: 34px; border: 1px solid #cfd6cc; border-radius: 2px; color: var(--green-deep); background: var(--paper); font-size: 14px; font-weight: 700; cursor: pointer; }
.review-navigation button:hover:not(:disabled) { border-color: var(--green); background: var(--green-pale); }
.review-navigation button:disabled { color: #a4ada2; background: #f0f1ec; cursor: default; }
#review-play { color: #fffdf5; border-color: var(--green); background: var(--green); }
#review-range { width: 100%; accent-color: var(--green); cursor: pointer; }
.review-readout { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink-soft); font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
#exit-review-button { padding: 3px 0; border: 0; color: var(--green-deep); background: transparent; font: 600 10px ui-sans-serif, system-ui, sans-serif; cursor: pointer; }
#exit-review-button:hover { text-decoration: underline; }
.move-jump { width: 100%; padding: 3px 4px; border: 0; border-radius: 2px; color: inherit; background: transparent; text-align: left; font: inherit; cursor: pointer; }
.move-jump:hover, .move-jump.is-active { color: #fffdf5; background: var(--green); }
body.is-reviewing .clock-box, body.is-reviewing .player-badges { display: none; }
body.is-reviewing .person-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 1500px) {
  .main-area { padding-right: 54px; padding-left: 54px; }
  .play-layout { gap: 38px; }
}
@media (max-width: 1220px) {
  .main-area { padding-right: 27px; padding-left: 27px; }
  .pace-controls { grid-template-columns: minmax(0, 1fr) 140px; gap: 8px 20px; }
  .settings-divider { display: none; }
  .mode-tabs { grid-column: 1; grid-row: 1; }
  .control-picks { grid-column: 1; grid-row: 2; justify-content: flex-start; gap: 23px; }
  .new-game-button { grid-column: 2; grid-row: 1 / 3; align-self: center; }
  .play-layout { grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; }
}
@media (max-width: 940px) {
  .app-shell { grid-template-columns: 70px minmax(0, 1fr); }
  .sidebar { align-items: center; padding: 22px 8px 16px; }
  .brand { padding: 0 0 35px; }
  .brand-copy, .nav-label, .engine-card { display: none; }
  .nav-list { width: 100%; }
  .nav-link { justify-content: center; padding: 0; }
  .nav-link > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .nav-link svg { width: 20px; height: 20px; }
  .play-layout { grid-template-columns: minmax(0, 1fr); gap: 17px; }
  .board-column { max-width: 690px; }
  .game-panel { min-height: auto; padding: 18px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .move-section { min-height: 130px; }
  .move-list { max-height: 190px; }
  .empty-moves { min-height: 95px; }
  .game-footnote { margin-top: 0; }
  .page-footer { margin-top: 18px; }
}
@media (max-width: 740px) {
  .app-shell { display: block; padding-bottom: 70px; }
  .sidebar { position: fixed; z-index: 8; right: 0; bottom: 0; left: 0; display: flex; min-height: 62px; height: 62px; flex-direction: row; justify-content: center; padding: 5px 12px; border-top: 1px solid #405748; border-right: 0; background: #243a30; }
  .brand, .sidebar-spacer { display: none; }
  .nav-label { display: none; }
  .nav-list { display: flex; width: min(100%, 300px); justify-content: center; gap: 35px; }
  .nav-link { width: 92px; min-height: 49px; flex-direction: column; justify-content: center; gap: 3px; padding: 3px 4px; border: 0; color: #c5d0c4; font-size: 10px; }
  .nav-link.is-active { color: #fff8e7; background: transparent; }
  .nav-link.is-active::after { position: absolute; right: 28px; bottom: 0; left: 28px; height: 2px; background: #c69a62; content: ""; }
  .nav-link > span { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
  .nav-link svg { width: 18px; height: 18px; }
  .main-area { padding: 0 19px 16px; }
  .topbar { height: 55px; }
  .topbar-right { gap: 7px; }
  .local-badge { min-height: 32px; font-size: 11px; }
  .theme-button { width: 32px; height: 32px; }
  .page-intro { padding: 21px 0 17px; }
  h1 { max-width: 540px; font-size: clamp(25px, 6vw, 31px); }
  .intro-copy { font-size: 13px; }
  .pace-card { padding: 12px 0 14px; }
  .pace-heading { display: block; margin-bottom: 11px; }
  .pace-heading h2 { font-size: 16px; }
  .pace-controls { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mode-tabs, .control-picks, .new-game-button { grid-column: auto; grid-row: auto; }
  .mode-tabs { gap: 8px; }
  .mode-tab { min-height: 48px; padding: 3px 5px 5px; }
  .mode-text strong { font-size: 12px; }
  .mode-text small { font-size: 10px; }
  .control-picks { justify-content: space-between; gap: 10px 18px; flex-wrap: wrap; }
  .new-game-button { width: 100%; min-height: 44px; }
  .play-layout { gap: 13px; margin-top: 15px; }
  .player-strip { min-height: 48px; }
  .board-frame { padding: 7px 7px 20px 20px; }
  .board-coordinates-left { top: 7px; bottom: 20px; }
  .board-coordinates-bottom { right: 7px; left: 20px; }
  .board-sheen { inset: 7px 7px 20px 20px; }
  .piece-svg { width: 84%; height: 84%; }
  .game-panel { padding-top: 15px; }
  .panel-actions { max-width: 420px; }
  .game-footnote { display: none; }
  .page-footer { gap: 10px; margin-top: 14px; font-size: 8px; }
  .page-footer span:last-child { text-align: right; font-size: 10px; }
  .toast { right: 12px; bottom: 73px; }
}
@media (max-width: 440px) {
  .main-area { padding-right: 13px; padding-left: 13px; }
  .breadcrumbs { gap: 7px; font-size: 9px; }
  .local-badge { gap: 6px; font-size: 10px; }
  .topbar-right { gap: 3px; }
  .page-intro { padding-top: 18px; }
  .eyebrow { font-size: 9px; letter-spacing: .9px; }
  h1 { font-size: 26px; }
  .intro-copy { font-size: 12px; }
  .mode-tabs { gap: 4px; }
  .mode-tab { min-height: 45px; }
  .mode-text small { font-size: 9px; }
  .control-picks { justify-content: flex-start; gap: 14px; }
  .choice-group { gap: 6px; }
  .choice-options, .side-options { gap: 3px; }
  .time-option { min-width: 42px; height: 32px; padding: 0 6px; font-size: 11px; }
  .side-option { gap: 5px; padding: 0 5px; font-size: 11px; }
  .board-frame { padding: 6px 6px 18px 18px; }
  .board-coordinates-left { top: 6px; bottom: 18px; left: 3px; width: 12px; }
  .board-coordinates-bottom { right: 6px; bottom: 3px; left: 18px; }
  .board-sheen { inset: 6px 6px 18px 18px; }
  .piece-svg { width: 84%; height: 84%; }
  .opponent-avatar, .self-avatar { width: 28px; height: 28px; }
  .person-block { gap: 7px; }
  .person-name { font-size: 11px; }
  .person-caption { font-size: 10px; }
  .badge-model { display: none; }
  .badge-turn { font-size: 8px; }
  .clock-box { width: 88px; min-height: 36px; gap: 5px; font-size: 15px; }
  .clock-icon { font-size: 14px; }
  .game-panel-head h2 { font-size: 18px; }
  .panel-actions { gap: 4px; }
  .panel-action { min-height: 36px; gap: 4px; padding: 0 3px; font-size: 10px; }
}
@media (max-width: 560px) {
  .pgn-dialog { width: calc(100vw - 22px); padding: 16px; }
  #pgn-text { min-height: 190px; padding: 10px; font-size: 11px; }
  .pgn-dialog-foot { align-items: flex-start; flex-direction: column; }
  .pgn-dialog-foot > div { width: 100%; }
  .pgn-dialog-foot button { flex: 1; padding: 0 8px; }
  .review-readout { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Focused play layout: board, clocks, and game setup share one screen. */
@media (min-width: 941px) {
  :root {
    --canvas: #e9e5d9;
    --paper: #fbfaf5;
    --paper-deep: #e4e0d4;
    --ink: #202b24;
    --ink-soft: #59645b;
    --ink-muted: #778077;
    --line: #d3d1c5;
    --green: #527a42;
    --green-deep: #294633;
    --green-pale: #e7eee1;
    --brass: #bc8a43;
    --board-light: #eee8d3;
    --board-dark: #82917d;
  }
  body { background: radial-gradient(ellipse at 12% 0%, #f4f0e5 0, transparent 42%), var(--canvas); }
  .app-shell { display: block; min-height: 100vh; }
  .sidebar { display: none; }
  .main-area {
    display: grid;
    width: min(100%, 1600px);
    max-width: none;
    min-height: 100vh;
    grid-template-columns: minmax(0, 1fr) minmax(315px, 365px);
    grid-template-rows: 58px auto 1fr;
    align-content: start;
    column-gap: clamp(24px, 3vw, 48px);
    padding: 0 clamp(28px, 4vw, 64px) 22px;
  }
  .topbar { grid-column: 1 / -1; grid-row: 1; height: 58px; }
  .breadcrumbs { font-size: 10px; }
  .page-intro { grid-column: 1 / -1; grid-row: 2; padding: 22px 0 15px; }
  .page-intro h1 { font-size: clamp(26px, 2.2vw, 34px); }
  .intro-copy { font-size: 13px; }
  .pace-card {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    padding: 18px;
    border: 1px solid rgba(87, 100, 83, .16);
    border-radius: 10px;
    background: rgba(251, 250, 245, .88);
    box-shadow: 0 10px 30px rgba(52, 57, 43, .06);
  }
  .pace-heading { margin-bottom: 13px; }
  .pace-heading h2 { font-size: 19px; }
  .pace-controls { display: flex; flex-direction: column; align-items: stretch; gap: 17px; }
  .mode-tabs { gap: 5px; }
  .mode-tab { min-height: 40px; justify-content: center; padding: 3px; }
  .mode-text { gap: 0; }
  .mode-text small { display: none; }
  .control-picks { justify-content: space-between; gap: 13px; }
  .choice-options { flex-wrap: wrap; }
  .time-option { min-width: 48px; }
  .side-choice { flex: none; }
  .side-options { flex-wrap: wrap; }
  .side-option { min-height: 30px; }
  .new-game-button { width: 100%; min-height: 48px; border-radius: 5px; background: #6f9f4b; border-color: #6f9f4b; font-size: 14px; }
  .new-game-button:hover:not(:disabled) { background: #59823d; border-color: #59823d; }
  .play-layout { display: contents; }
  .board-column {
    grid-column: 1;
    grid-row: 2 / 4;
    width: min(100%, calc(100vh - 250px));
    max-width: 790px;
    align-self: start;
  }
  .player-strip { min-height: 48px; }
  .board-frame { padding: 8px 8px 22px 22px; border-radius: 5px; box-shadow: 0 12px 28px rgba(38, 49, 37, .17); }
  .board { border-radius: 2px; }
  .piece-svg { width: 88%; height: 88%; }
  .game-panel {
    grid-column: 2;
    grid-row: 3;
    align-self: stretch;
    min-height: 0;
    padding: 17px 18px;
    border: 1px solid rgba(87, 100, 83, .16);
    border-radius: 10px;
    background: rgba(251, 250, 245, .88);
  }
  .game-panel-head { min-height: 45px; }
  .turn-card { margin: 12px 0 17px; }
  .move-section { min-height: 120px; }
  .move-list { max-height: 220px; }
  .panel-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .game-footnote { padding-top: 10px; }
}
@media (max-width: 940px) {
  .main-area { background: radial-gradient(ellipse at 12% 0%, #f4f0e5 0, transparent 42%), var(--canvas); }
  .pace-card { border-radius: 8px; background: rgba(251, 250, 245, .75); }
  .new-game-button { border-radius: 4px; }
  .board-frame { border-radius: 5px; }
}

/* Keep the play surface inside the available viewport height. */
@media (min-width: 941px) and (min-height: 620px) {
  body { height: 100vh; overflow: hidden; }
  .main-area {
    height: 100vh;
    min-height: 0;
    grid-template-rows: 54px minmax(0, auto) minmax(0, 1fr);
    row-gap: 0;
    padding-top: 0;
    padding-bottom: 12px;
  }
  .page-intro { padding: 12px 0 8px; }
  .page-intro .eyebrow { margin-bottom: 5px; }
  .page-intro h1 { margin-bottom: 4px; }
  .pace-card { padding: 14px 16px; }
  .pace-controls { gap: 12px; }
  .control-picks { gap: 9px; }
  .time-option { height: 31px; min-width: 45px; padding-right: 7px; padding-left: 7px; }
  .board-column {
    width: min(100%, calc(100vh - 180px));
    max-width: min(790px, calc(100vh - 180px));
    align-self: center;
  }
  .player-strip { min-height: 42px; }
  .board-frame { margin: 0; padding: 6px 6px 18px 18px; }
  .board-coordinates-left { top: 6px; bottom: 18px; }
  .board-coordinates-bottom { right: 6px; left: 18px; }
  .board-sheen { inset: 6px 6px 18px 18px; }
  .game-panel { overflow: hidden; padding: 12px 14px; }
  .turn-card { min-height: 52px; margin: 8px 0 12px; padding: 7px 9px; }
  .move-section { min-height: 0; }
  .move-list { max-height: none; min-height: 0; }
  .empty-moves { min-height: 72px; }
  .panel-actions { padding-top: 8px; }
}

@media (min-width: 941px) and (max-height: 619px) {
  .main-area { grid-template-rows: 48px auto 1fr; }
  .pace-card { padding: 10px 14px; }
  .pace-heading { margin-bottom: 7px; }
  .pace-controls { gap: 8px; }
  .board-column { width: min(100%, calc(100vh - 150px)); max-width: min(790px, calc(100vh - 150px)); }
  .player-strip { min-height: 36px; }
  .board-frame { padding: 5px 5px 15px 15px; }
  .board-coordinates-left { top: 5px; bottom: 15px; }
  .board-coordinates-bottom { right: 5px; left: 15px; }
  .board-sheen { inset: 5px 5px 15px 15px; }
  .game-panel { overflow: auto; padding: 10px 12px; }
  .turn-card { min-height: 45px; margin: 6px 0 9px; }
  .panel-actions { padding-top: 6px; }
}

body.dark-theme {
  color-scheme: dark;
  --canvas: #171d19;
  --paper: #232c26;
  --paper-deep: #303a32;
  --ink: #edf0e7;
  --ink-soft: #c0c9bc;
  --ink-muted: #9aa69a;
  --line: #3c4940;
  --green: #85ad62;
  --green-deep: #314b38;
  --green-pale: #303d31;
  --brass: #d0a35f;
  --board-light: #c3c7ae;
  --board-dark: #536d59;
  background: var(--canvas);
}
body.dark-theme .main-area { background: var(--canvas); }
body.dark-theme h1,
body.dark-theme .pace-heading h2,
body.dark-theme .game-panel-head h2,
body.dark-theme .move-san,
body.dark-theme .setup-dialog h2,
body.dark-theme .pgn-dialog-head h2 { color: var(--ink); }
body.dark-theme .pace-card,
body.dark-theme .game-panel { border-color: var(--line); background: var(--paper); }
body.dark-theme .board-frame { border: 0; background: transparent; }
body.dark-theme .square.last-move.light { background: #c7b873; }
body.dark-theme .square.last-move.dark { background: #8c945c; }
body.dark-theme .square.selected::after { border-color: #f0c55d; background: rgba(240, 197, 93, .2); }
body.dark-theme .square.premove-target::before { border-color: rgba(233, 239, 224, .72); background: rgba(255, 255, 255, .08); }
body.dark-theme .square.premove-target.premove-destination::before { border-color: #e4b85c; background: rgba(224, 186, 95, .2); }
body.dark-theme .legal-empty::before { background: rgba(20, 30, 22, .48); }
body.dark-theme .legal-capture::before { border-color: rgba(20, 30, 22, .48); }
body.dark-theme .clock-box { border-color: var(--line); color: var(--ink); background: #2b352e; }
body.dark-theme .clock-box.is-running { border-color: #85ad62; color: #f8faef; background: #405b40; }
body.dark-theme .clock-box.is-low { border-color: #b76555; background: #743f38; }
body.dark-theme .turn-card { border-left-color: #75866e; color: var(--ink); background: #2c372f; }
body.dark-theme .turn-card.is-live { border-left-color: #85ad62; background: #303e32; }
body.dark-theme .turn-card.is-over { background: #40382b; }
body.dark-theme .turn-card strong,
body.dark-theme .move-san,
body.dark-theme .move-san.latest { color: var(--ink); }
body.dark-theme .move-row { border-bottom-color: var(--line); }
body.dark-theme .time-option,
body.dark-theme .panel-action,
body.dark-theme .review-navigation button,
body.dark-theme .pgn-file-button { border-color: var(--line); color: var(--ink-soft); background: #2a342d; }
body.dark-theme .time-option:hover:not(:disabled),
body.dark-theme .panel-action:hover:not(:disabled),
body.dark-theme .review-navigation button:hover:not(:disabled) { background: #354338; }
body.dark-theme .time-option.is-selected { border-color: #85ad62; color: #172018; background: #9bc175; }
body.dark-theme .side-option { color: var(--ink-soft); }
body.dark-theme .side-option.is-selected { border-color: #60765d; color: #eff4e9; background: #354538; }
body.dark-theme .settings-divider { background: var(--line); }
body.dark-theme .badge-model { color: #e0c38f; }
body.dark-theme .new-game-button { color: #f9f9f2; background: #638d49; border-color: #638d49; }
body.dark-theme .new-game-button:disabled { color: #abb7a8; background: #3a453b; border-color: #4d5a4d; }
body.dark-theme .setup-dialog,
body.dark-theme .pgn-dialog { border-color: var(--line); color: var(--ink); background: var(--paper); }
body.dark-theme .setup-dialog p,
body.dark-theme .pgn-hint { color: var(--ink-soft); }
body.dark-theme .setup-dialog pre,
body.dark-theme #pgn-text { border-color: var(--line); color: var(--ink); background: #18211b; }
body.dark-theme .dialog-done,
body.dark-theme .pgn-submit-button { color: #f9f9f2; background: #638d49; }
body.dark-theme .toast { border-color: var(--line); color: var(--ink); background: var(--paper); }
body.dark-theme .page-footer { border-color: var(--line); }
body.dark-theme .theme-button[aria-pressed="true"] { border-color: #5c7059; color: #eff4e9; background: #354538; }

/* Coordinates sit lightly over the board, with no surrounding frame. */
.board-frame { margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; }
.board { border: 0; }
.board-coordinates { z-index: 4; color: inherit; font-size: clamp(9px, 1vw, 13px); opacity: .72; text-shadow: 0 1px 2px rgba(0, 0, 0, .16); pointer-events: none; }
.board-coordinates-left { top: 0; bottom: 0; left: 0; width: 19px; }
.board-coordinates-bottom { right: 0; bottom: 0; left: 0; height: 19px; align-items: end; }
.board-coordinates .coordinate-light { color: rgba(38, 48, 39, .68); }
.board-coordinates .coordinate-dark { color: rgba(255, 255, 246, .76); }
.board-sheen { display: none; }
body.dark-theme .board-coordinates .coordinate-light { color: rgba(26, 34, 27, .72); }
body.dark-theme .board-coordinates .coordinate-dark { color: rgba(255, 255, 242, .78); }
