:root {
  --page-bg: #f5f1e8;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: #fffaf1;
  --text: #1f2933;
  --muted: #667085;
  --accent: #d97706;
  --accent-2: #7c3aed;
  --line: rgba(31, 41, 51, 0.12);
  --shadow: 0 24px 70px rgba(45, 35, 20, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(217, 119, 6, 0.22), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(124, 58, 237, 0.14), transparent 30rem),
    var(--page-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #111827, #3f2d17);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(17, 24, 39, 0.18);
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(17, 24, 39, 0.22);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  box-shadow: none;
}

.app-shell {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.hero {
  overflow: hidden;
  margin-bottom: 22px;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(16, 24, 40, 0.96), rgba(91, 59, 24, 0.92)),
    url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="160" height="160" viewBox="0 0 160 160"%3E%3Cg fill="none" stroke="rgba(255,255,255,.09)" stroke-width="1"%3E%3Cpath d="M20 0v160M60 0v160M100 0v160M140 0v160M0 20h160M0 60h160M0 100h160M0 140h160"/%3E%3C/g%3E%3C/svg%3E');
  color: #fff;
  box-shadow: var(--shadow);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: rgba(255, 255, 255, 0.62);
  font-size: 14px;
}

.crumbs a {
  color: #ffe0b7;
  text-decoration: none;
}

.hero-content {
  max-width: 860px;
  padding: 38px 0 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #fbbf24;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(40px, 7vw, 86px);
  letter-spacing: -0.07em;
  line-height: 0.98;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 18px;
  line-height: 1.85;
}

.game-layout {
  display: grid;
  grid-template-columns: 300px minmax(420px, 1fr) 340px;
  gap: 20px;
  align-items: start;
}

.control-card,
.board-card,
.review-card,
.teach-card {
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.control-card,
.review-card,
.teach-card {
  padding: 22px;
}

.board-card {
  overflow: hidden;
  padding: 22px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.section-title.compact {
  align-items: flex-start;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  outline: none;
}

select:focus {
  border-color: rgba(217, 119, 6, 0.55);
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.14);
}

.button-grid,
.replay-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.status-box {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.62);
}

.status-box p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.stone-badge {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  box-shadow: inset -7px -8px 12px rgba(0, 0, 0, 0.28), inset 5px 5px 9px rgba(255, 255, 255, 0.3), 0 9px 16px rgba(0, 0, 0, 0.18);
}

.stone-badge.black {
  background: radial-gradient(circle at 32% 28%, #77808c, #111827 46%, #020617 76%);
}

.stone-badge.white {
  background: radial-gradient(circle at 32% 28%, #fff, #f1f5f9 48%, #cbd5e1 80%);
}

.board-topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.score-panel {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.score-panel span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.score-panel strong {
  color: var(--text);
}

.canvas-wrap {
  overflow: hidden;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.38);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6), inset 0 -18px 40px rgba(0, 0, 0, 0.08);
}

#boardCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  cursor: crosshair;
  touch-action: manipulation;
}

.summary {
  min-height: 92px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  line-height: 1.65;
}

.summary strong {
  color: var(--text);
}

.summary.empty {
  display: grid;
  place-items: center;
  text-align: center;
}

.move-list {
  display: grid;
  gap: 8px;
  max-height: 390px;
  margin: 16px 0 0;
  padding: 0 0 0 24px;
  overflow: auto;
}

.move-list li {
  border-radius: 12px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
}

.move-list li.active {
  background: rgba(217, 119, 6, 0.13);
  color: var(--text);
  font-weight: 900;
}

.teach-card {
  margin-top: 20px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.lesson-grid article {
  min-height: 180px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.62);
}

.lesson-grid span {
  display: inline-grid;
  width: 38px;
  height: 38px;
  margin-bottom: 16px;
  place-items: center;
  border-radius: 14px;
  background: rgba(217, 119, 6, 0.14);
  color: var(--accent);
  font-weight: 900;
}

.lesson-grid h3 {
  margin-bottom: 8px;
}

.lesson-grid p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 1180px) {
  .game-layout {
    grid-template-columns: 280px minmax(420px, 1fr);
  }

  .review-card {
    grid-column: 1 / -1;
  }

  .lesson-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 18px, 1480px);
    padding-top: 14px;
  }

  .hero,
  .control-card,
  .board-card,
  .review-card,
  .teach-card {
    border-radius: 22px;
  }

  .game-layout,
  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .board-card {
    padding: 12px;
  }

  .board-topbar,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
}
