/* Jungle — Dou Shou Qi web UI */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a2416;
  --bg-panel: #22301c;
  --card: #2b3d24;
  --border: #3d5232;
  --text: #eef3e6;
  --text-dim: #9fb18f;
  --accent: #7bc144;
  --accent-dark: #5a9c2e;
  --gold: #ffd700;
}

html, body {
  height: 100%;
  background: radial-gradient(ellipse at top, #24331d 0%, var(--bg) 70%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

h1 { font-size: 2rem; letter-spacing: 1px; }
h1 .subtitle { font-size: 1rem; color: var(--text-dim); font-weight: normal; margin-left: 6px; }
h2 { font-size: 1.3rem; }
h3 { font-size: 0.95rem; color: var(--text-dim); margin-top: 12px; text-transform: uppercase; letter-spacing: 1px; }

.hint { color: var(--text-dim); font-size: 0.82rem; }

/* Overlays */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at top, #24331d 0%, var(--bg) 70%);
}
.overlay.translucent { background: rgba(10, 16, 8, 0.75); }
.overlay[hidden] { display: none; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 40px;
  max-width: 440px;
  width: min(92vw, 440px);
  text-align: center;
  display: flex; flex-direction: column; gap: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
}

/* Menu */
.menu-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.label { color: var(--text-dim); font-size: 0.95rem; }

.segmented { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button {
  background: transparent; color: var(--text-dim); border: none;
  padding: 8px 14px; cursor: pointer; font-size: 0.9rem;
}
.segmented button.active { background: var(--accent-dark); color: #fff; }

.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 13px;
  background: var(--border); transition: 0.2s; cursor: pointer;
}
.switch .slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  left: 3px; top: 3px; background: #fff; transition: 0.2s;
}
.switch input:checked + .slider { background: var(--accent-dark); }
.switch input:checked + .slider::before { transform: translateX(20px); }

button.primary, button.secondary {
  font-size: 1.05rem; padding: 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); transition: 0.15s;
}
button.primary { background: var(--accent-dark); color: #fff; border-color: var(--accent-dark); }
button.primary:hover { background: var(--accent); }
button.secondary { background: transparent; color: var(--text); }
button.secondary:hover { background: var(--border); }

.rules { text-align: left; font-size: 0.85rem; color: var(--text-dim); }
.rules summary { cursor: pointer; color: var(--text); }
.rules p { margin-top: 8px; line-height: 1.5; }

/* Spinner */
.spinner {
  width: 36px; height: 36px; margin: 0 auto;
  border: 4px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
.spinner.small { width: 14px; height: 14px; border-width: 2px; display: inline-block; margin: 0 6px 0 0; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Game layout */
#game-area {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  gap: 24px; padding: 16px;
}
#game-area[hidden] { display: none; }

#board {
  border: 3px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

#panel {
  width: 240px; max-height: 92vh; overflow: hidden;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
}

#status { font-size: 1rem; min-height: 24px; }

.buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.buttons button {
  flex: 1 1 45%; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 4px; font-size: 0.82rem; cursor: pointer;
}
.buttons button:hover:not(:disabled) { background: var(--border); }
.buttons button:disabled { opacity: 0.4; cursor: default; }
.buttons button[hidden] { display: none; }

.captured { font-size: 0.8rem; color: var(--text-dim); display: flex; flex-direction: column; gap: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot.blue { background: #3c78dc; }
.dot.black { background: #111; border: 1px solid #555; }

#history-list {
  list-style: none; overflow-y: auto; flex: 1; min-height: 60px;
  font-size: 0.78rem; font-family: Consolas, monospace; color: var(--text-dim);
  border-top: 1px solid var(--border); padding-top: 6px;
}
#history-list li { padding: 2px 0; white-space: nowrap; }
#history-list li:last-child { color: var(--text); }

/* Narrow screens: stack panel under board */
@media (max-width: 720px) {
  html, body { overflow: auto; }
  #game-area { flex-direction: column; height: auto; }
  #panel { width: min(92vw, 448px); }
}
