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

body {
  background: #0d1117;
  color: #e6edf3;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px 48px;
}

/* ── App Container ────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 620px;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #e6edf3;
}

#subtitle {
  font-size: 0.95rem;
  color: #8b949e;
  text-align: center;
  max-width: 480px;
  line-height: 1.5;
  margin-top: -8px;
}

/* ── Controls ─────────────────────────────────────────────────────── */
#controls {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.select-label {
  font-size: 0.9rem;
  color: #c9d1d9;
  white-space: nowrap;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: #c9d1d9;
  cursor: pointer;
  white-space: nowrap;
}

#newGameBtn {
  align-self: flex-start;
  background: #238636;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
#newGameBtn:hover { background: #2ea043; }
#newGameBtn:active { background: #1a7f37; }

#takeBackBtn {
  background: transparent;
  color: #8b949e;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  align-self: flex-start;
}
#takeBackBtn:hover { border-color: #8b949e; color: #c9d1d9; }
#takeBackBtn:active { background: #21262d; }

.radio-label input[type="radio"] {
  accent-color: #58a6ff;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

#controls select {
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}
#controls select:hover { border-color: #58a6ff; }

/* ── Status Bar ───────────────────────────────────────────────────── */
#statusBar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 10px 16px;
  width: 100%;
  font-size: 1rem;
  font-weight: 500;
  min-height: 44px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-idle    { background: #6e7681; }
.dot-human   { background: #e53935; }
.dot-ai      { background: #fdd835; }
.dot-win     { background: #00e676; }
.dot-draw    { background: #6e7681; }
.dot-loading { background: #58a6ff; animation: pulse 1.2s ease-in-out infinite; }
.dot-error   { background: #f85149; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Canvas Wrapper ───────────────────────────────────────────────── */
#canvasWrapper {
  line-height: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#gameCanvas {
  display: block;
  cursor: pointer;
}

/* ── Legend ───────────────────────────────────────────────────────── */
#legend {
  display: flex;
  gap: 24px;
  font-size: 0.9rem;
  color: #8b949e;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
}
.swatch-human { background: #e53935; }
.swatch-ai    { background: #fdd835; }

/* ── Footer ───────────────────────────────────────────────────────── */
footer {
  font-size: 0.85rem;
  color: #8b949e;
  text-align: center;
}

footer a {
  color: #8b949e;
  text-decoration: underline;
  text-underline-offset: 3px;
}

footer a:hover { color: #c9d1d9; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 620px) {
  h1 { font-size: 1.4rem; }
  #controls { gap: 10px; padding: 12px 14px; }
}
