/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  --board-green:      #2d6a4f;
  --board-green-alt:  #256255;
  --board-border:     #1b4332;
  --board-line:       #1b4332;

  --disc-black:       #1a1a1a;
  --disc-white:       #f5f5f5;
  --disc-shadow:      rgba(0, 0, 0, 0.5);

  --hint-color:       rgba(255, 230, 50, 0.55);

  --bg:               #081c15;
  --surface:          #0f2d1c;
  --surface-2:        #1b4332;
  --text:             #d8f3dc;
  --text-muted:       #95d5b2;
  --accent:           #f4c430;
  --accent-hover:     #f9d85a;

  --btn-bg:           #2d6a4f;
  --btn-hover:        #40916c;
  --btn-disabled:     #1b4332;

  --overlay-bg:       rgba(0, 0, 0, 0.78);
  --radius:           0.5rem;
  --gap:              2px;
}

/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0.75rem 2rem;
}

h1 {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 0.75rem;
  text-align: center;
}

/* ============================================================
   Score / HUD
   ============================================================ */
#hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.5rem;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.55rem 1.2rem;
  margin-bottom: 0.75rem;
  width: 100%;
  max-width: 560px;
}

.score-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1rem;
  font-weight: 600;
}

.disc-pip {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.disc-pip--black { background: var(--disc-black); border: 2px solid #555; }
.disc-pip--white { background: var(--disc-white); border: 2px solid #bbb; }

.turn-indicator {
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 0.35rem;
  background: rgba(255,255,255,0.07);
}
.turn-black { color: #95d5b2; }
.turn-white { color: #aaa; }
.turn-over  { color: var(--accent); }

/* ============================================================
   Controls bar
   ============================================================ */
#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.75rem;
  width: 100%;
  max-width: 560px;
}

button, select {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 0.42rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--btn-bg);
  color: var(--text);
  transition: background 0.15s, opacity 0.15s;
  min-height: 36px;
}

button:hover:not(:disabled), select:hover {
  background: var(--btn-hover);
}

button:disabled {
  background: var(--btn-disabled);
  opacity: 0.45;
  cursor: not-allowed;
}

button:focus-visible, select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

select {
  appearance: none;
  padding-right: 1.6rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7'%3E%3Cpath d='M0 0l5 7 5-7z' fill='%23d8f3dc'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 10px 7px;
}

/* ============================================================
   Board
   ============================================================ */
#board-wrap {
  position: relative;
}

#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: var(--gap);
  background: var(--board-border);
  border: 3px solid var(--board-border);
  border-radius: 4px;
  width: min(90vw, 80vh, 520px);
  height: min(90vw, 80vh, 520px);
}

/* ============================================================
   Cells
   ============================================================ */
.cell {
  background: var(--board-green);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  padding: 0;
  min-width: 44px;
  min-height: 44px;
  transition: background 0.1s;
}

/* Checkerboard pattern — alternating rows */
.cell:nth-child(16n+2), .cell:nth-child(16n+4), .cell:nth-child(16n+6), .cell:nth-child(16n+8),
.cell:nth-child(16n+9), .cell:nth-child(16n+11), .cell:nth-child(16n+13), .cell:nth-child(16n+15) {
  background: var(--board-green-alt);
}

.cell:hover { filter: brightness(1.15); }

.cell:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  z-index: 1;
}

/* ============================================================
   Discs
   ============================================================ */
.disc {
  width: 76%;
  aspect-ratio: 1;
  border-radius: 50%;
  flex-shrink: 0;
  animation: place-disc 0.22s ease-out;
}

.disc--black {
  background: radial-gradient(circle at 38% 35%, #555 0%, var(--disc-black) 60%);
  box-shadow: 0 2px 6px var(--disc-shadow), inset 0 1px 2px rgba(255,255,255,0.08);
}

.disc--white {
  background: radial-gradient(circle at 38% 35%, #fff 0%, #d0d0d0 70%);
  box-shadow: 0 2px 6px var(--disc-shadow), inset 0 1px 2px rgba(255,255,255,0.6);
}

@keyframes place-disc {
  0%   { transform: scale(0.25); opacity: 0.5; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   Hint dots
   ============================================================ */
.hint-dot {
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--hint-color);
  pointer-events: none;
}

/* ============================================================
   Shake (illegal click)
   ============================================================ */
.cell.shake {
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* ============================================================
   Thinking spinner
   ============================================================ */
#thinking-spinner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: 0.5rem;
}

#thinking-spinner.hidden { display: none; }

.spinner-ring {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(244, 196, 48, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Pass message
   ============================================================ */
#pass-message {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--accent);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 200;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}

#pass-message.hidden { display: none; }

/* ============================================================
   Continue banner
   ============================================================ */
#continue-banner {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
}

#continue-banner.hidden { display: none; }

.banner-card {
  background: var(--surface);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.banner-card h2 { color: var(--accent); margin-bottom: 0.4rem; }
.banner-card p  { color: var(--text-muted); margin-bottom: 1.2rem; font-size: 0.9rem; }

.banner-btns {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* ============================================================
   Game-over overlay
   ============================================================ */
#gameover-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

#gameover-overlay.hidden { display: none; }

.gameover-card {
  background: var(--surface);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.gameover-card h2 { color: var(--accent); margin-bottom: 0.5rem; font-size: 1.5rem; }

#gameover-result {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0.75rem 0;
  color: var(--text);
}

.gameover-scores {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1.4rem;
  color: var(--text-muted);
}

/* ============================================================
   Utility
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 400px) {
  #board {
    gap: 1px;
    border-width: 2px;
  }
  button, select { font-size: 0.78rem; padding: 0.38rem 0.7rem; }
}

@media (max-height: 600px) {
  h1 { margin-bottom: 0.4rem; font-size: 1.2rem; }
  #hud { padding: 0.35rem 0.8rem; margin-bottom: 0.4rem; }
  #controls { margin-bottom: 0.4rem; }
}
