:root {
  color-scheme: only light;
  --bg: #f3efe6;
  --ink: #1b1b1b;
  --muted: #6b645b;
  --board: #0e6b47;
  --board-dark: #0b5d3e;
  --line: rgba(255, 255, 255, 0.45);
  --black: #151515;
  --white: #f6f3ee;
  --accent: #f2b705;
  --shadow: rgba(0, 0, 0, 0.18);
  font-family: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Noto Sans JP",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, #fffdf8 0%, var(--bg) 58%);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px 48px;
}

.app {
  width: min(980px, 95vw);
  display: grid;
  gap: 24px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.title h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: 0.05em;
}

.sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.scores {
  display: flex;
  gap: 14px;
}

.score {
  background: #fffdfa;
  border-radius: 16px;
  padding: 12px 18px;
  min-width: 96px;
  text-align: center;
  box-shadow: 0 8px 20px var(--shadow);
}

.score .label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.score .value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  margin-top: 4px;
}

.status {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.turn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  font-size: 16px;
}

.turn::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--black);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.turn.white::before {
  background: var(--white);
  border: 1px solid #dcd2c3;
  box-shadow: none;
}

.message {
  color: var(--muted);
  font-size: 14px;
  grid-column: 1 / -1;
  min-height: 18px;
}

.reset {
  border: none;
  background: var(--accent);
  color: #2b2314;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 18px var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.reset:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px var(--shadow);
}

.board-wrap {
  display: flex;
  justify-content: center;
}

.board {
  width: min(640px, 92vw);
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, var(--board), var(--board-dark));
  border-radius: 18px;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  box-shadow: 0 18px 36px var(--shadow);
}

.cell {
  position: relative;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.cell:hover {
  background: rgba(255, 255, 255, 0.15);
}

.cell.valid::after {
  content: "";
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.8);
}

.disc {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: var(--black);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.1),
    0 6px 10px rgba(0, 0, 0, 0.25);
  transform: scale(0);
  animation: pop 0.25s ease forwards;
}

.disc.white {
  background: var(--white);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08),
    0 6px 10px rgba(0, 0, 0, 0.2);
}

.disc.flip {
  animation: flip 0.35s ease;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.dialog {
  width: min(420px, 92vw);
  background: #fffdfa;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

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

.dialog-sub {
  margin: 6px 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.field select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #e4d9c9;
  font-size: 16px;
  background: #fff;
}

.start {
  width: 100%;
  border: none;
  background: #1d8b5c;
  color: #fff;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.18);
}

@keyframes pop {
  to {
    transform: scale(1);
  }
}

@keyframes flip {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  50% {
    transform: rotateY(90deg) scale(0.8);
  }
  100% {
    transform: rotateY(180deg) scale(1);
  }
}

@media (max-width: 720px) {
  .status {
    grid-template-columns: 1fr;
  }

  .reset {
    width: 100%;
  }
}
