:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #5f6670;
  --line: #e2ded5;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --weak: #b4232a;
  --strong: #1f7a47;
  --bar: #2f6f4f;
  --bar-faced: #8a8f98;
  --light-square: #ecdcc0;
  --dark-square: #b08862;
  --last-move: rgba(244, 208, 63, 0.55);
  --arrow-player: rgba(31, 122, 71, 0.85);
  --arrow-faced: rgba(70, 76, 86, 0.6);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --panel: #1e2227;
    --text: #e6e8eb;
    --muted: #9aa3ad;
    --line: #2f343b;
    --accent: #4aa476;
    --accent-text: #0e1512;
    --weak: #f0757a;
    --strong: #5fd394;
    --bar: #4aa476;
    --bar-faced: #6c7480;
    --light-square: #c9b597;
    --dark-square: #86654a;
    --arrow-player: rgba(95, 211, 148, 0.85);
    --arrow-faced: rgba(210, 215, 222, 0.55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.top, main, footer { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 24px;
  padding-bottom: 16px;
}

.top { position: relative; }
.top-links { position: absolute; top: 8px; right: 16px; display: flex; gap: 16px; font-size: 0.9rem; }
.top-links a { text-decoration: underline; }
.brand h1 { margin: 0; font-size: 1.75rem; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.logo { width: 2.5rem; height: 2.5rem; flex: none; }
.logo .pawn { fill: var(--text); }
.logo .glass circle { fill: color-mix(in srgb, var(--muted) 22%, transparent); stroke: var(--muted); stroke-width: 4.5; }
.logo .glass line { stroke: var(--muted); stroke-width: 7; stroke-linecap: round; }
.brand p { margin: 4px 0 0; color: var(--muted); }
.spot-note { font-size: 0.85rem; margin: 0 0 6px; }
.spot-list .leaning button { border-left-style: dashed; opacity: 0.85; }

.ask { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.field input, .field select {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
.field input { width: 14rem; max-width: 60vw; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
}
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#go { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; padding: 9px 18px; }
#go:disabled { opacity: 0.6; cursor: progress; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 16px 0;
}
.panel h2 { margin-top: 0; font-size: 1.15rem; }
.intro ol { padding-left: 1.25rem; }
.about { line-height: 1.55; }
.modal {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 48px);
  padding: 20px 24px 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.modal::backdrop { background: rgba(15, 18, 22, 0.55); }
.modal h2 { margin: 0 40px 10px 0; font-size: 1.2rem; }
.modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin: -6px -10px 0 0;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
  border-radius: 50%;
}
.intro { width: min(600px, calc(100vw - 24px)); }
.about { width: min(1040px, calc(100vw - 24px)); }
.about-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 32px; align-items: start; }
.about-body { grid-column: 1; grid-row: 1; }
.about-body > h3:first-child { margin-top: 4px; }
.about h3 { font-size: 1.05rem; margin: 26px 0 6px; scroll-margin-top: 12px; }
.about-toc { grid-column: 2; grid-row: 1; position: sticky; top: 44px; font-size: 0.88rem; border-left: 1px solid var(--line); padding-left: 16px; }
.about-toc .toc-title { margin: 0 0 6px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.about-toc ol { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.about-toc a { color: var(--text); text-decoration: none; }
.about-toc a:hover { text-decoration: underline; }
@media (max-width: 760px) {
  .about-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .about-toc { grid-column: 1; position: static; border-left: 0; padding: 0 0 12px; border-bottom: 1px solid var(--line); }
  .about-body { grid-row: 2; }
}
.about ul, .about ol { padding-left: 1.25rem; }
.about li { margin: 4px 0; }
.about code { font-size: 0.9em; }
.about-table { overflow-x: auto; margin: 10px 0; }
.about-table table { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.about-table th, .about-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.about-table th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.about-table td + td, .about-table th + th { text-align: right; white-space: nowrap; }
.problem { border-color: var(--weak); color: var(--weak); }
.demo p { margin: 0.25rem 0; }
.demo-players { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0.5rem 0; }
.demo-players button { font: inherit; }

.steps { list-style: none; padding: 0; margin: 0 0 8px; }
.steps li { padding: 6px 0 6px 28px; position: relative; color: var(--muted); }
.steps li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 12px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--line);
}
.steps li.current { color: var(--text); font-weight: 600; }
.steps li.current::before { border-color: var(--accent); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.steps li.done { color: var(--text); }
.steps li.done::before { background: var(--accent); border-color: var(--accent); }
.steps .detail { font-weight: 400; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .steps li.current::before { animation: none; } }

.report-head h2 { margin: 16px 0 0; font-size: 1.5rem; }
.report-head p { margin: 4px 0 12px; }

.tabs { display: flex; gap: 8px; }
.tabs button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.summary { margin: 12px 0 16px; }

.layout { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 820px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.board-wrap { position: relative; width: 100%; max-width: 440px; aspect-ratio: 1; }
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.square { position: relative; display: flex; align-items: center; justify-content: center; user-select: none; }
.square.light { background: var(--light-square); }
.square.dark { background: var(--dark-square); }
.square.target { cursor: pointer; }
.square.target:hover { box-shadow: inset 0 0 0 3px var(--accent); }
.square.last::after { content: ""; position: absolute; inset: 0; background: var(--last-move); }
.square .coord { position: absolute; font-size: 0.62rem; font-weight: 600; line-height: 1; opacity: 0.75; }
.square .coord.file { right: 3px; bottom: 2px; }
.square .coord.rank { left: 3px; top: 3px; }
.square.light .coord { color: var(--dark-square); }
.square.dark .coord { color: var(--light-square); }
.piece {
  position: relative;
  z-index: 1;
  font-size: clamp(22px, 7.6vw, 44px);
  line-height: 1;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", serif;
}
.piece.w { color: #fbfbf8; text-shadow: 0 0 1px #000, 0 0 1px #000, 0 1px 1px #000, 0 -1px 1px #000; }
.piece.b { color: #191919; text-shadow: 0 0 1px rgba(255, 255, 255, 0.35); }
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }

.line-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.line-bar button { padding: 4px 10px; }
.line { list-style: none; display: flex; flex-wrap: wrap; gap: 2px 6px; padding: 0; margin: 0; font-variant-numeric: tabular-nums; }
.line button { border: none; background: none; padding: 2px 4px; color: var(--accent); }
.line button[aria-current="step"] { color: var(--text); font-weight: 700; }

.explore-column h3 { margin: 0; font-size: 1.05rem; }
.opening { margin: 2px 0 10px; color: var(--muted); min-height: 1.5em; }

.options { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.options th { text-align: left; font-size: 0.8rem; font-weight: 600; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.options td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.options tr.pick { cursor: pointer; }
.options tr.pick .move { color: var(--accent); }
.options tr.pick:hover .move { text-decoration: underline; }
.hint { font-size: 0.85rem; margin: 0 0 8px; }
.line-bar button:disabled { opacity: 0.4; cursor: default; }
.line .empty { color: var(--muted); font-size: 0.85rem; padding: 2px 4px; }
.options tr.pick:hover, .options tr.pick:focus-visible { background: color-mix(in srgb, var(--accent) 10%, transparent); outline: none; }
.options .move { font-weight: 700; white-space: nowrap; }
.options .chance { width: 32%; }
.options .range { display: block; font-size: 0.75rem; font-weight: 400; color: var(--muted); white-space: nowrap; }
.bar { display: flex; align-items: center; gap: 8px; }
.bar span { display: block; height: 8px; border-radius: 4px; background: var(--bar); min-width: 2px; }
.bar.faced span { background: var(--bar-faced); }
.bar b { font-weight: 500; min-width: 2.8em; }
.vs.weak { color: var(--weak); font-weight: 600; }
.options.no-positions .after { display: none; }
.vs.strong { color: var(--strong); font-weight: 600; }

.spots { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
@media (max-width: 560px) { .spots { grid-template-columns: 1fr; } }
.spots h3 { font-size: 0.95rem; margin-bottom: 6px; }
.spot-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.spot-list button {
  width: 100%;
  text-align: left;
  border-left: 4px solid var(--line);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.spot-list.weak-list button { border-left-color: var(--weak); }
.spot-list.strong-list button { border-left-color: var(--strong); }
.spot-list .spot-line { font-weight: 600; }
.spot-list .spot-name, .spot-list .spot-stats, .spot-list .spot-cause { font-size: 0.85rem; color: var(--muted); }
.spot-list .spot-cause b { color: var(--text, inherit); font-weight: 600; }
.spot-list .none { color: var(--muted); font-size: 0.9rem; }

.phases { margin: 4px 0 18px; }
.phases h3 { font-size: 0.95rem; margin: 0 0 2px; }
.phases-note { font-size: 0.85rem; margin: 0 0 8px; }
.phase-cells { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 560px) { .phase-cells { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.phase { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.phase .label { display: block; font-size: 0.8rem; color: var(--muted); }
.phase .num { display: block; font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.phase .range { display: block; font-size: 0.75rem; color: var(--muted); }
.phase.total { border-style: dashed; }
.phase .vs.weak, .phase .num.weak { color: var(--weak); }
.phase .num.strong { color: var(--strong); }
.phase-facts { margin: 10px 0 0; padding-left: 18px; font-size: 0.9rem; }

.reading summary { cursor: pointer; font-weight: 600; }
.reading ul { margin-bottom: 0; }

footer { padding-top: 8px; padding-bottom: 32px; font-size: 0.85rem; }
