:root {
  --bg: #0d1117;
  --panel: rgba(255,255,255,.08);
  --panel-strong: rgba(255,255,255,.12);
  --text: #f5f7fb;
  --muted: #aab4c4;
  --line: rgba(255,255,255,.28);
  --accent: #f3c969;
  --accent2: #65e4a3;
  --danger: #ff6b6b;
  --wood: #b98245;
  --wood2: #805022;
  --white-piece: #f7efe0;
  --black-piece: #14171d;
  --shadow: 0 22px 60px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(243,201,105,.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(101,228,163,.13), transparent 30%),
    linear-gradient(135deg, #07090d 0%, #111827 100%);
}
button, select, input { font: inherit; }
.app-shell { width: min(1440px, calc(100% - 28px)); margin: 0 auto; padding: 28px 0; }
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 20px;
}
.eyebrow { margin: 0 0 8px; color: var(--accent); text-transform: uppercase; letter-spacing: .16em; font-size: .78rem; font-weight: 800; }
h1 { margin: 0; font-size: clamp(2.4rem, 7vw, 5.6rem); line-height: .88; letter-spacing: -.06em; }
.subtitle { max-width: 720px; margin: 16px 0 0; color: var(--muted); font-size: 1.05rem; line-height: 1.55; }
.hero-card, .panel, .board-card {
  border: 1px solid rgba(255,255,255,.13);
  background: linear-gradient(180deg, var(--panel), rgba(255,255,255,.04));
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.hero-card { min-width: 290px; padding: 18px; display: grid; gap: 8px; }
.badge { width: max-content; padding: 7px 11px; border-radius: 999px; font-size: .82rem; font-weight: 800; }
.badge.white { background: rgba(255,255,255,.9); color: #121212; }
.badge.black { background: #06080c; color: white; border: 1px solid rgba(255,255,255,.22); }
.hero-card small { color: var(--muted); }
.layout { display: grid; grid-template-columns: 280px 1fr 310px; gap: 18px; align-items: start; }
.panel { padding: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 1rem; }
.field { display: grid; gap: 8px; margin-bottom: 13px; color: var(--muted); }
select {
  width: 100%;
  color: var(--text);
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  padding: 11px 12px;
  outline: none;
}
.checkline { display: flex; align-items: flex-start; gap: 10px; color: var(--muted); font-size: .92rem; line-height: 1.35; margin: 12px 0 16px; }
.checkline input { margin-top: 3px; }
.actions { display: grid; gap: 10px; }
button {
  cursor: pointer;
  border: none;
  border-radius: 15px;
  padding: 12px 14px;
  font-weight: 800;
  color: #16120a;
  background: linear-gradient(135deg, #f8d985, #f0b842);
  box-shadow: 0 12px 30px rgba(243,201,105,.2);
}
button.secondary { color: var(--text); background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.16); box-shadow: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.score-grid div { background: rgba(255,255,255,.08); border-radius: 18px; padding: 14px; display: grid; gap: 5px; }
.score-grid span { color: var(--muted); font-size: .82rem; }
.score-grid strong { font-size: 1.7rem; }
.legend { display: grid; gap: 10px; color: var(--muted); font-size: .9rem; }
.dot, .ring { display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px; border-radius: 50%; }
.white-dot { background: var(--white-piece); }
.black-dot { background: var(--black-piece); border: 1px solid rgba(255,255,255,.25); }
.ring { background: transparent; border: 3px solid var(--accent2); }
.ring.selected { border-color: var(--accent); }
.board-card { padding: clamp(12px, 2vw, 26px); }
.board-wrap {
  position: relative;
  aspect-ratio: 9 / 5;
  width: 100%;
  min-height: 310px;
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255,255,255,.05), transparent 22%, rgba(0,0,0,.08) 55%, transparent),
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 8px, rgba(0,0,0,.04) 8px 16px),
    linear-gradient(135deg, var(--wood), var(--wood2));
  border: 1px solid rgba(255,255,255,.2);
}
#lineLayer, .board { position: absolute; inset: 0; width: 100%; height: 100%; }
#lineLayer line { stroke: rgba(47, 24, 8, .58); stroke-width: 4; stroke-linecap: round; }
#lineLayer line.diagonal { stroke: rgba(47, 24, 8, .42); stroke-width: 3; }
.point {
  position: absolute;
  width: clamp(30px, 5.2vw, 58px);
  height: clamp(30px, 5.2vw, 58px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.08);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.point::after { content: ""; width: 28%; height: 28%; border-radius: 50%; background: rgba(36,19,8,.55); }
.point.legal { background: rgba(101,228,163,.22); box-shadow: 0 0 0 5px rgba(101,228,163,.18); }
.point.selected { box-shadow: 0 0 0 6px rgba(243,201,105,.24), 0 16px 28px rgba(0,0,0,.28); }
.point.must-capture { box-shadow: 0 0 0 5px rgba(255,107,107,.22); }
.piece {
  width: 84%; height: 84%; border-radius: 50%; position: relative; z-index: 2;
  box-shadow: inset 0 -7px 12px rgba(0,0,0,.18), 0 12px 18px rgba(0,0,0,.28);
  transition: transform .15s ease;
}
.point:hover .piece { transform: scale(1.04); }
.piece.white { background: radial-gradient(circle at 35% 25%, #fff, var(--white-piece) 48%, #cfbd9d); border: 1px solid rgba(0,0,0,.14); }
.piece.black { background: radial-gradient(circle at 35% 25%, #525966, var(--black-piece) 52%, #06070a); border: 1px solid rgba(255,255,255,.14); }
.info-panel ol { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.55; font-size: .93rem; }
.history { max-height: 220px; overflow: auto; background: rgba(0,0,0,.16); border-radius: 16px; padding: 12px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.history p { margin: 0 0 7px; }
.choice-dialog { border: 1px solid rgba(255,255,255,.2); border-radius: 24px; background: #131a25; color: var(--text); max-width: 440px; padding: 24px; box-shadow: var(--shadow); }
.choice-dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.choice-dialog h3 { margin: 0 0 8px; }
.choice-dialog p { color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(120px); opacity: 0; background: #111827; color: var(--text); border: 1px solid rgba(255,255,255,.16); padding: 12px 15px; border-radius: 16px; box-shadow: var(--shadow); transition: .24s ease; z-index: 50; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
@media (max-width: 1120px) {
  .layout { grid-template-columns: 1fr; }
  .controls-panel { order: 2; }
  .board-card { order: 1; }
  .info-panel { order: 3; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .app-shell { width: min(100% - 16px, 1440px); padding: 12px 0; }
  .board-wrap { min-height: 230px; border-radius: 20px; }
  .panel, .hero-card, .board-card { border-radius: 20px; }
  .dialog-actions { flex-direction: column; }
}
