:root {
  --bg-top: #eef6ff;
  --bg-bottom: #d7e8ff;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-border: rgba(18, 57, 99, 0.12);
  --ink: #15304d;
  --muted: #55708d;
  --accent: #0f766e;
  --accent-strong: #0d9488;
  --shadow: 0 24px 60px rgba(19, 48, 77, 0.18);
  --player-col: #3b82f6;
  --ai-col: #ec4899;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.85), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.page {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
}

/* ── Hero ──────────────────────────────────────────────── */

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

.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(21,48,77,0.12);
}
.hero-link:hover { background: white; }

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 0.95;
  color: var(--ink);
}

.intro {
  max-width: 68ch;
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

/* ── Score area ────────────────────────────────────────── */

.score-area {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  flex-shrink: 0;
}

.scoreboard {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255,255,255,0.85);
  border: 1px solid rgba(21,48,77,0.12);
  border-radius: 16px;
  padding: 0.6rem 1rem;
}

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.score-name {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.player-color { color: var(--player-col); }
.ai-color     { color: var(--ai-col); }

.score-num {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  min-width: 1.5ch;
  text-align: center;
}

.score-sep {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 700;
}

.round-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

/* ── Layout ────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

/* ── Sidebar ───────────────────────────────────────────── */

.controls {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  background: rgba(59,130,246,0.1);
  color: var(--player-col);
  border: 1.5px solid rgba(59,130,246,0.25);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.turn-indicator.ai-turn {
  background: rgba(236,72,153,0.1);
  color: var(--ai-col);
  border-color: rgba(236,72,153,0.25);
}

.turn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.hand-display {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  background: rgba(21,48,77,0.05);
  border-radius: 12px;
}

.hand-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.hand-label {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  width: 1.8rem;
  flex-shrink: 0;
}

.hand-count {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  min-width: 1.5ch;
}

.hand-unit {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ── Buttons ───────────────────────────────────────────── */

.action-btn {
  padding: 0.65rem 1.1rem;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(15,118,110,0.25);
  transition: opacity 0.15s;
  width: 100%;
}
.action-btn:hover:not(:disabled) { opacity: 0.88; }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.action-btn--secondary {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid rgba(21,48,77,0.2);
  box-shadow: none;
}
.action-btn--secondary:hover:not(:disabled) { background: rgba(255,255,255,0.7); }

.hidden { display: none !important; }

/* ── Physics note ──────────────────────────────────────── */

.physics-note {
  padding: 0.6rem 0.75rem;
  background: rgba(239,247,255,0.7);
  border-radius: 12px;
  border: 1px solid rgba(21,48,77,0.08);
  border-left: 3px solid var(--accent-strong);
  font-size: 0.82rem;
  margin-top: auto;
}

.note-title {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.physics-note ul {
  margin: 0;
  padding-left: 1.1rem;
  color: #334155;
  line-height: 1.75;
}

/* ── Game canvas panel ─────────────────────────────────── */

.game-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.canvas-wrap {
  display: flex;
  justify-content: center;
  padding: 1rem 1rem 0;
}

canvas {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
  border-radius: 12px;
  cursor: crosshair;
}

.message-bar {
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  min-height: 2.2rem;
  display: flex;
  align-items: center;
  border-top: 1px solid rgba(21,48,77,0.07);
}

/* ── Modal ─────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
}

.modal-box {
  background: white;
  border-radius: 20px;
  padding: 2rem;
  max-width: 520px;
  width: calc(100% - 2rem);
  max-height: 82vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.3);
}

.modal-box h2 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  color: var(--ink);
  padding-right: 2.5rem;
}

.modal-body h3 {
  margin: 1.1rem 0 0.3rem;
  font-size: 0.82rem;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}

.modal-body p,
.modal-body li {
  font-size: 0.92rem;
  color: #334155;
  line-height: 1.6;
  margin: 0.2rem 0;
}

.modal-body ol,
.modal-body ul {
  padding-left: 1.4rem;
  margin: 0.3rem 0;
}

.modal-close {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  line-height: 1;
}
.modal-close:hover { background: rgba(21,48,77,0.08); }

.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0.5rem 0 0.2rem;
}

.rules-table th,
.rules-table td {
  text-align: left;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid rgba(21,48,77,0.1);
}

.rules-table th {
  font-weight: 700;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 760px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .score-area { align-items: flex-start; }
  .layout { grid-template-columns: 1fr; }
}
