:root {
  --ink: #172033;
  --muted: #687386;
  --felt: #0f766e;
  --felt-dark: #0a4f49;
  --line: rgba(255, 255, 255, 0.24);
  --panel: #fbfaf6;
  --accent: #c8a24a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.16), transparent 36%),
    linear-gradient(315deg, rgba(200, 162, 74, 0.2), transparent 38%),
    #f4f1e9;
  font-family: Arial, Helvetica, sans-serif;
}

.game {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  min-height: 100vh;
  padding: 22px;
}

header,
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

header {
  justify-content: space-between;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1;
}

#contextLabel {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  color: white;
  background: var(--felt);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  background: #9aa4b2;
  cursor: not-allowed;
}

.play-area {
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-columns: minmax(320px, min(72vh, 72vw, 720px)) minmax(250px, 320px);
  gap: 18px;
  align-items: stretch;
  width: min(100%, 1058px);
}

.board {
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
  width: 100%;
  max-width: min(72vh, 72vw, 720px);
  border: 4px solid #083c38;
  border-radius: 8px;
  background: var(--felt-dark);
  box-shadow: 0 24px 56px rgba(23, 32, 51, 0.22);
  overflow: hidden;
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--felt);
}

.cell.legal::before {
  content: "";
  width: 24%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(200, 162, 74, 0.28);
}

.cell.last {
  box-shadow: inset 0 0 0 5px rgba(250, 204, 21, 0.64);
}

.disc {
  width: 76%;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow:
    inset 0 4px 9px rgba(255, 255, 255, 0.35),
    inset 0 -7px 12px rgba(0, 0, 0, 0.32),
    0 7px 14px rgba(0, 0, 0, 0.24);
}

.disc.black {
  background: radial-gradient(circle at 35% 28%, #596273, #111827 62%, #05070a);
}

.disc.white {
  background: radial-gradient(circle at 35% 28%, #ffffff, #f0eadf 64%, #b6aa98);
}

.hidden {
  display: none !important;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto;
  gap: 12px;
  min-height: 0;
}

.scoreboard,
.status-card {
  border: 1px solid rgba(8, 60, 56, 0.14);
  border-radius: 8px;
  background: rgba(251, 250, 246, 0.94);
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.08);
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.scoreboard > div {
  padding: 14px;
}

.scoreboard > div + div {
  border-left: 1px solid rgba(8, 60, 56, 0.14);
}

.status-card {
  padding: 14px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.score {
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
}

.player-color-graphic {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.color-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 8px;
  border: 1px solid rgba(8, 60, 56, 0.16);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
}

.disc-preview {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.35),
    inset 0 -3px 6px rgba(0, 0, 0, 0.32),
    0 3px 6px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.disc-preview.black {
  background: radial-gradient(circle at 35% 28%, #596273, #111827 62%, #05070a);
  border: 1px solid rgba(0, 0, 0, 0.4);
}

.disc-preview.white {
  background: radial-gradient(circle at 35% 28%, #ffffff, #f0eadf 64%, #b6aa98);
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.disc-preview.waiting {
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  border: 1px dashed rgba(100, 116, 139, 0.6);
}

.disc-preview.both {
  background: linear-gradient(90deg, #111827 50%, #ffffff 50%);
  border: 1px solid rgba(0, 0, 0, 0.3);
}

.color-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.result-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 20;
  display: grid;
  min-width: min(78vw, 360px);
  padding: 26px 32px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: rgba(251, 250, 246, 0.97);
  box-shadow: 0 24px 60px rgba(23, 32, 51, 0.3);
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.result-overlay.hidden {
  display: none;
}

.result-message {
  color: var(--felt);
  font-size: clamp(44px, 10vmin, 84px);
  font-weight: 900;
  line-height: 1;
}

@media (max-width: 860px) {
  .play-area {
    grid-template-columns: minmax(300px, min(88vw, 650px));
  }

  .board {
    max-width: min(88vw, 650px);
  }
}

@media (max-width: 620px) {
  .game {
    gap: 12px;
    min-height: 0;
    padding: 12px;
  }

  header {
    align-items: flex-start;
    flex-direction: column;
  }

  .play-area {
    grid-template-columns: 1fr;
    width: 100%;
    gap: 12px;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .board {
    width: min(100%, calc(100dvh - 276px));
    min-width: 280px;
    max-width: 100%;
    border-width: 3px;
  }

  .scoreboard > div,
  .status-card {
    padding: 12px;
  }

  .score {
    font-size: 34px;
  }
}

@media (max-width: 360px) {
  .board {
    min-width: 0;
  }
}
