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

:root {
  --bg: #0a0a0f;
  --surface: #14141e;
  --border: #2a2a3a;
  --accent: #4a9eff;
  --accent2: #7fff47;
  --fg: #e8e8f0;
  --muted: #6a6a8a;
  --danger: #ff4a6a;
  --white-piece: #f5f0e0;
  --black-piece: #2a2a2a;
  --light-sq: #f0d9b5;
  --dark-sq: #b58863;
  --highlight: rgba(74, 158, 255, 0.5);
  --arrow: #ff9500;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}

/* ── Loading ── */
#loading-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 1000;
  transition: opacity 0.4s;
}
#loading-screen.fade-out { opacity: 0; pointer-events: none; }

.loader-inner { text-align: center; width: 280px; }
.loader-logo { font-size: 64px; margin-bottom: 12px; }
.loader-title { font-size: 22px; font-weight: 700; letter-spacing: 2px; color: var(--accent); margin-bottom: 24px; }
.loader-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.loader-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.3s; width: 0%; }
.loader-status { font-size: 13px; color: var(--muted); }

/* ── Landing ── */
#landing {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #1a1a2e 0%, var(--bg) 70%);
  overflow-y: auto;
  padding: 24px;
}
#landing.hidden { display: none; }

.landing-inner {
  max-width: 700px;
  width: 100%;
  text-align: center;
}

.landing-inner h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--accent);
  margin-bottom: 8px;
}

.subtitle { color: var(--muted); margin-bottom: 40px; font-size: 15px; }

.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}
@media (max-width: 520px) { .mode-cards { grid-template-columns: 1fr; } }

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.mode-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.mode-icon { font-size: 32px; margin-bottom: 12px; }
.mode-card h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.mode-card p { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 20px; }

.btn-primary {
  display: inline-block;
  padding: 10px 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: #3a8eef; }

.settings-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.settings-row label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.settings-row select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}

#browser-warning {
  background: #2a1a0e;
  border: 1px solid #ff6a00;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: #ffb060;
}

/* ── Desktop HUD ── */
#desktop-hud {
  position: fixed; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 24px;
  background: var(--bg);
}
#desktop-hud.hidden { display: none; }

#desktop-board-wrap {
  flex-shrink: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border-radius: 4px;
  overflow: hidden;
}

#desktop-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 200px;
  max-width: 280px;
}

#desktop-fen-display {
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  background: var(--surface);
  padding: 8px;
  border-radius: 6px;
}

#desktop-move-hint {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent2);
  min-height: 32px;
}

#desktop-controls button {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.2s;
}
#desktop-controls button:hover { border-color: var(--accent); }

#desktop-controls label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#fen-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 11px;
  width: 100%;
}

#promotion-panel {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
}
#promotion-panel.hidden { display: none; }
.promo-btn {
  font-size: 24px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 4px 8px;
  transition: background 0.15s;
}
.promo-btn:hover { background: var(--border); }

#xr-hud { display: none; }
.hidden { display: none !important; }
