/* ── Chess Gauntlet Styles ─────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --bg: #162614;
  --bg2: #213520;
  --ink: #0a110a;
  --cream: #e3f3e6;
  --moss: #9bc6a0;
  --moss-dim: #79a37e;
  --leaf: #44c767;
  --gold: #ffe46b;
  --rose: #ff5d5d;
  --ui-accent: #ff5d72;
}

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

html { height: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 2vh, 20px);
  padding: clamp(12px, 3vh, 28px) 12px;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 50% 40%, rgba(105,240,154,0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 46%, var(--bg2) 0%, var(--bg) 78%);
  font-family: 'Press Start 2P', monospace;
  color: var(--cream);
  overflow: hidden;
}

body.loading .score-hud,
body.loading .moves-hud,
body.loading footer { visibility: hidden; }

/* ── Score HUD ───────────────────────────────────────────────── */
.score-hud {
  order: 1;
  position: relative;
  z-index: 2;
  visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  user-select: none;
}

.score-label {
  font-size: 0.45em;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  color: var(--moss);
  text-shadow: 2px 2px 0 var(--ink);
}

.score-val {
  font-size: clamp(1.5em, 4vh, 2.5em);
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* ── Moves HUD ───────────────────────────────────────────────── */
.moves-hud {
  position: fixed;
  top: clamp(12px, 3vh, 28px);
  left: clamp(12px, 3vw, 28px);
  z-index: 5;
  visibility: hidden;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9em;
  color: var(--moss-dim);
  text-shadow: 2px 2px 0 var(--ink);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  user-select: none;
}

.moves-icon {
  font-size: 0.8em;
  filter: drop-shadow(2px 2px 0 var(--ink));
}

/* ── Board ───────────────────────────────────────────────────── */
#board {
  order: 2;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#board-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 4px solid var(--ink);
  box-shadow:
    0 0 0 6px #2c4528,
    0 0 0 9px var(--ink),
    0 0 0 11px rgba(68,199,103,0.35),
    0 20px 50px rgba(0,0,0,0.55);
  border-radius: 2px;
}

/* ── Footer ──────────────────────────────────────────────────── */
footer {
  order: 3;
  display: flex;
  gap: 12px;
  z-index: 2;
}

.mute-btn,
.help-btn,
.danger-btn,
.back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--moss-dim);
  background: rgba(255,255,255,0.05);
  color: var(--moss);
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mute-btn:hover,
.help-btn:hover,
.danger-btn:hover,
.back-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--leaf);
  color: var(--cream);
}
.back-btn {
  font-size: 1.2em;
  line-height: 1;
  padding-bottom: 4px; /* optical centering of the chevron */
}
.mute-btn {
  font-size: 1em;
  line-height: 1;
}
.danger-btn {
  padding: 0;
  line-height: 0;
}
.danger-btn svg {
  display: block;
}
.danger-btn[aria-pressed="true"] {
  background: rgba(255, 60, 60, 0.18);
  border-color: rgba(255, 80, 80, 0.85);
  color: #ff7878;
}

/* ── Start Screen ────────────────────────────────────────────── */
.start {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: var(--bg);
  cursor: pointer;
  transition: opacity 0.45s ease-out;
  -webkit-tap-highlight-color: transparent;
}

.start.gone {
  opacity: 0;
  pointer-events: none;
}

.start-title {
  font-size: clamp(1.2em, 4vw, 2em);
  color: var(--gold);
  text-shadow: 3px 3px 0 var(--ink);
  text-align: center;
  line-height: 1.3;
}

.start-prompt {
  font-size: 0.6em;
  color: var(--moss);
  text-shadow: 2px 2px 0 var(--ink);
  animation: pulse 2s ease-in-out infinite;
}

.start-credit {
  font-size: 0.4em;
  color: var(--moss-dim);
  text-shadow: 1px 1px 0 var(--ink);
  text-align: center;
}

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

/* ── Overlay (Game Over, Tutorial) ───────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 17, 10, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.25s ease-out;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.panel {
  position: relative;
  background: var(--bg);
  border: 3px solid #2c4528;
  border-radius: 12px;
  padding: 28px 24px;
  max-width: 380px;
  width: 90vw;
  box-shadow: 0 0 0 5px var(--ink), 0 24px 60px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.panel-title {
  font-size: 0.85em;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--ink);
  text-align: center;
}

/* ── Panel Stats ─────────────────────────────────────────────── */
.panel-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 8px;
}

.stat-label {
  font-size: 0.5em;
  color: var(--moss-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.stat-value {
  font-size: 0.7em;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}

.seed-row .stat-value {
  font-size: 0.5em;
  color: var(--moss-dim);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.button {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5em;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #fff;
  background: rgba(255,93,114,0.3);
  border: 1px solid rgba(255,150,165,0.65);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  box-shadow:
    inset 0 2px rgba(255,255,255,0.12),
    0 3px 0 0 #3a0e16,
    0 3px 0 3px var(--ink);
  transition: background 0.12s, transform 0.08s, box-shadow 0.08s;
}

.button:hover {
  background: rgba(255,93,114,0.45);
  border-color: rgba(255,150,165,0.85);
}

.button:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 2px rgba(255,255,255,0.12),
    0 1px 0 0 #3a0e16,
    0 1px 0 3px var(--ink);
}

/* ── Tutorial ────────────────────────────────────────────────── */
.tutorial-panel {
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
}

.tut-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: var(--moss-dim);
  font-size: 1.3em;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.tut-close:hover { color: var(--cream); }

.tut-cards {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.tut-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
}

.tut-icon {
  font-size: 1.2em;
  flex-shrink: 0;
  width: 40px;
  text-align: center;
  line-height: 1.4;
}

.tut-text {
  font-size: 0.42em;
  line-height: 1.8;
  color: var(--cream);
}

.tut-text strong {
  color: var(--gold);
}

.tut-got-it {
  margin-top: 4px;
}
