:root {
  color-scheme: dark;
  --bg: #121513;
  --surface: #1b211d;
  --surface-2: #242b26;
  --line: #354238;
  --text: #f3f0e8;
  --muted: #b5b9ae;
  --green: #2d8b57;
  --green-dark: #16613c;
  --gold: #e0b84e;
  --black-disc: #101010;
  --white-disc: #f5efe2;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at 18% 12%, rgba(45, 139, 87, 0.22), transparent 28rem),
    linear-gradient(135deg, #121513 0%, #19201c 48%, #111413 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  align-items: start;
  display: grid;
  gap: clamp(1rem, 3vw, 2rem);
  grid-template-columns: minmax(19rem, 40rem) minmax(14rem, 20rem);
  justify-content: center;
  min-height: 100vh;
  padding: clamp(1rem, 3vw, 2.5rem);
}

.game,
.side {
  width: 100%;
}

.game {
  background: rgba(27, 33, 29, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.5rem);
}

.topbar {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 7vw, 5.2rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 0.9;
}

h2 {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status {
  color: var(--muted);
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  margin-top: 0.45rem;
}

.scores {
  display: grid;
  gap: 0.45rem;
  min-width: 5.5rem;
}

.score {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: flex;
  font-size: 1.2rem;
  font-weight: 800;
  gap: 0.5rem;
  justify-content: space-between;
  min-height: 2.35rem;
  padding: 0.45rem 0.65rem;
}

.board-wrap {
  aspect-ratio: 1;
  width: min(100%, 40rem);
}

.board {
  aspect-ratio: 1;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent),
    var(--green-dark);
  border: 0.5rem solid #20281f;
  border-radius: 8px;
  display: grid;
  gap: 0.125rem;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  height: 100%;
  overflow: hidden;
  width: 100%;
}

.cell {
  align-items: center;
  background: var(--green);
  border: 0;
  color: inherit;
  cursor: default;
  display: flex;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  padding: 0;
  position: relative;
}

.cell.playable {
  cursor: pointer;
}

.cell.playable::after {
  background: rgba(224, 184, 78, 0.78);
  border-radius: 999px;
  content: "";
  height: 18%;
  position: absolute;
  width: 18%;
}

.cell.playable:hover,
.cell:focus-visible {
  background: #36a565;
  outline: none;
}

.disc {
  border-radius: 999px;
  display: block;
}

.cell .disc {
  height: 72%;
  width: 72%;
}

.disc.black {
  background:
    radial-gradient(circle at 35% 28%, #4a4a4a 0 8%, transparent 18%),
    var(--black-disc);
  box-shadow:
    inset -0.35rem -0.5rem 0 rgba(0, 0, 0, 0.35),
    0 0.35rem 0.7rem rgba(0, 0, 0, 0.25);
}

.disc.white {
  background:
    radial-gradient(circle at 35% 28%, #ffffff 0 13%, transparent 26%),
    var(--white-disc);
  box-shadow:
    inset -0.25rem -0.45rem 0 rgba(179, 158, 118, 0.26),
    0 0.35rem 0.7rem rgba(0, 0, 0, 0.22);
}

.mini {
  flex: 0 0 auto;
  height: 1.1rem;
  width: 1.1rem;
}

.controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.controls button {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-size: 1.4rem;
  height: 2.75rem;
  justify-content: center;
  line-height: 1;
  transition:
    background 160ms ease,
    transform 160ms ease;
  width: 2.75rem;
}

.controls button:hover,
.controls button:focus-visible {
  background: #303a33;
  outline: none;
  transform: translateY(-1px);
}

.controls button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.toggle {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
}

.toggle input {
  accent-color: var(--gold);
  height: 1.05rem;
  width: 1.05rem;
}

.side {
  display: grid;
  gap: 1rem;
}

.panel {
  background: rgba(27, 33, 29, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 1rem;
}

.turn {
  align-items: center;
  display: flex;
  font-size: 1.55rem;
  font-weight: 800;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.turn .disc {
  height: 2.2rem;
  width: 2.2rem;
}

.metric {
  color: var(--gold);
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  margin-top: 0.6rem;
}

.history-panel {
  max-height: 18rem;
  overflow: auto;
}

.history {
  color: var(--muted);
  display: grid;
  font-size: 0.95rem;
  gap: 0.4rem;
  margin: 0.75rem 0 0;
  padding-left: 1.35rem;
}

.history li::marker {
  color: var(--gold);
}

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

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

  .history-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .shell {
    padding: 0.75rem;
  }

  .game {
    padding: 0.8rem;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .scores {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .side {
    grid-template-columns: 1fr;
  }
}
