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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1c1c1e;
  color: #f5f5f0;
  min-height: 100vh;
}

/* ─── Header ────────────────────────────────────────────────────────────────── */
.site-header {
  padding: 12px 24px;
  background: #111;
  border-bottom: 1px solid #333;
}

.site-header .logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: #dcb865;
  text-decoration: none;
  letter-spacing: 0.05em;
}

main { padding: 24px; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary   { background: #dcb865; color: #1c1c1e; }
.btn-secondary { background: #3a3a3c; color: #f5f5f0; }
.btn-danger    { background: #c0392b; color: #fff; }
.btn-small     { padding: 4px 10px; font-size: 0.8rem; }

/* ─── New Game Form ─────────────────────────────────────────────────────────── */
.new-game-page {
  max-width: 480px;
  margin: 60px auto;
}

.new-game-page h1 {
  font-size: 2rem;
  margin-bottom: 24px;
  color: #dcb865;
}

.new-game-form .field {
  margin-bottom: 20px;
}

.new-game-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #aaa;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.new-game-form select,
.new-game-form input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  background: #2c2c2e;
  border: 1px solid #444;
  border-radius: 6px;
  color: #f5f5f0;
  font-size: 1rem;
}

.new-game-form select:focus,
.new-game-form input:focus {
  outline: none;
  border-color: #dcb865;
}

.new-game-form .actions { margin-top: 28px; }

.new-game-form .field-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
}
.new-game-form .field-checkbox label {
  text-transform: none;
  font-size: 0.9rem;
  color: #ccc;
  margin-bottom: 0;
  letter-spacing: 0;
}
.new-game-form .field-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #dcb865;
  cursor: pointer;
  flex-shrink: 0;
}

.form-errors {
  background: #5c1010;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* ─── Game Page ─────────────────────────────────────────────────────────────── */
.game-page { position: relative; }

.game-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  max-width: 1000px;
  margin: 0 auto;
}

/* ─── Board ─────────────────────────────────────────────────────────────────── */
.board-column { flex: 0 0 auto; }

.go-board {
  width: min(580px, calc(100vw - 280px));
  height: min(580px, calc(100vw - 280px));
  cursor: crosshair;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.invite-panel,
.status-panel,
.controls,
.scoring-controls,
.move-list {
  background: #2c2c2e;
  border-radius: 10px;
  padding: 16px;
}

.invite-panel h2,
.status-panel h2 { font-size: 1rem; color: #dcb865; margin-bottom: 10px; }

.invite-panel p { font-size: 0.85rem; color: #aaa; margin-bottom: 8px; }

.invite-link { display: flex; gap: 6px; align-items: center; }
.link-input {
  flex: 1;
  background: #1c1c1e;
  border: 1px solid #444;
  border-radius: 4px;
  color: #f5f5f0;
  padding: 6px 8px;
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.waiting-msg { font-size: 0.8rem; color: #888; margin-top: 8px; font-style: italic; }

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 10px;
}
.game-meta span {
  background: #1c1c1e;
  padding: 2px 8px;
  border-radius: 4px;
}

.turn-info { font-size: 1rem; font-weight: 600; margin-bottom: 10px; }
.black-turn { color: #ccc; }
.white-turn { color: #fff; }
.result     { color: #dcb865; font-size: 1.1rem; }
.scoring-notice { color: #e8a838; }
.waiting-notice { color: #888; font-style: italic; }

.captures { font-size: 0.9rem; color: #aaa; }
.capture-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }

.stone-icon {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1px solid #555;
  flex-shrink: 0;
}
.black-stone { background: #1a1a1a; border-color: #000; }
.white-stone { background: #f0f0e8; }

/* Move list dots */
.black-dot, .white-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.black-dot { background: #1a1a1a; border: 1px solid #555; }
.white-dot { background: #f0f0e8; border: 1px solid #888; }

.controls { display: flex; gap: 10px; }

.move-list h3 { font-size: 0.9rem; color: #888; margin-bottom: 8px; }
.move-list-inner {
  max-height: 280px;
  overflow-y: auto;
  font-size: 0.82rem;
  color: #ccc;
}
.move-entry { display: flex; align-items: center; gap: 5px; padding: 2px 0; }
.move-num   { color: #555; min-width: 28px; text-align: right; }

.scoring-controls p { font-size: 0.85rem; color: #aaa; margin-bottom: 10px; }
.accept-reject-btns { display: flex; gap: 8px; margin-top: 8px; }

.undo-waiting-panel,
.undo-request-panel {
  background: #2c2c2e;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.85rem;
}
.undo-waiting-panel p,
.undo-request-panel p { color: #aaa; margin-bottom: 8px; }

/* ─── Result Overlay ────────────────────────────────────────────────────────── */
.result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

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

.result-card {
  background: #2c2c2e;
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.8);
}

.result-card h2 { font-size: 2rem; color: #dcb865; margin-bottom: 12px; }
.result-card p  { color: #ccc; margin-bottom: 16px; font-size: 1.1rem; }

.score-breakdown { margin-bottom: 24px; }
.breakdown-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.breakdown-table th,
.breakdown-table td { padding: 6px 14px; text-align: right; }
.breakdown-table th:first-child,
.breakdown-table td:first-child { text-align: left; color: #aaa; }
.breakdown-table thead tr { border-bottom: 1px solid #444; color: #aaa; font-size: 0.85rem; }
.breakdown-table tbody tr:hover { background: rgba(255,255,255,0.04); }
.breakdown-table tfoot tr { border-top: 2px solid #555; font-weight: 700; color: #dcb865; }

/* ─── Flash ─────────────────────────────────────────────────────────────────── */
.flash-error,
.flash-atari {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  z-index: 200;
  animation: fadeIn 0.2s;
}
.flash-error { background: #c0392b; color: #fff; }
.flash-atari { background: #dcb865; color: #1c1c1e; font-size: 1.1rem; letter-spacing: 0.05em; }

@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* ─── Utilities ─────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .game-layout { flex-direction: column; }
  .go-board { width: min(98vw, 460px); height: min(98vw, 460px); }
}
