:root {
  --page-bg: linear-gradient(135deg, #040810 0%, #0a1225 40%, #0d0a1a 70%, #060810 100%);
  --text-primary: #e0e0e0;
  --accent: #5ab0ff;
  --accent-rgb: 90, 176, 255;
  --heading-color: #5a8eb8;
  --panel-bg-top: rgba(13, 27, 46, 0.5);
  --panel-bg-bottom: rgba(8, 16, 30, 0.5);
  --panel-bg-top-soft: rgba(13, 27, 46, 0.5);
  --panel-bg-bottom-soft: rgba(8, 16, 30, 0.5);
  --panel-border: rgba(40, 80, 130, 0.35);
  --panel-border-soft: rgba(40, 80, 130, 0.3);
  --panel-shadow: rgba(0, 0, 0, 0.3);
  --canvas-bg: #0a1424;
  --canvas-border: rgba(40, 80, 130, 0.7);
  --canvas-panel-bg: #0c1a2e;
  --canvas-panel-border: rgba(40, 80, 130, 0.45);
  --btn-text: #c0d8f0;
  --btn-bg-top: rgba(20, 45, 75, 0.62);
  --btn-bg-bottom: rgba(10, 25, 45, 0.62);
  --btn-border: rgba(60, 120, 190, 0.45);
  --kbd-color: #5a7a9a;
  --stat-value-color: #fff;
  --high-score-color: #ffe060;
  --overlay-bg: rgba(3, 8, 18, 0.88);
  --overlay-text-color: #d0e4ff;
  --bg-mask-color: rgba(4, 8, 16, 0.55);
  --content-bg: #0a0e18;
}

body[data-ui-theme="light"] {
  --page-bg: linear-gradient(135deg, #eef2f8 0%, #e4ebf5 40%, #eef0f8 70%, #eef2f8 100%);
  --text-primary: #1a2436;
  --accent: #2f6fb0;
  --accent-rgb: 47, 111, 176;
  --heading-color: #3d6690;
  --panel-bg-top: rgba(255, 255, 255, 0.5);
  --panel-bg-bottom: rgba(240, 244, 250, 0.5);
  --panel-bg-top-soft: rgba(255, 255, 255, 0.5);
  --panel-bg-bottom-soft: rgba(240, 244, 250, 0.5);
  --panel-border: rgba(47, 111, 176, 0.25);
  --panel-border-soft: rgba(47, 111, 176, 0.2);
  --panel-shadow: rgba(60, 90, 130, 0.15);
  --canvas-bg: #f4f7fb;
  --canvas-border: rgba(47, 111, 176, 0.4);
  --canvas-panel-bg: #e9eef6;
  --canvas-panel-border: rgba(47, 111, 176, 0.3);
  --btn-text: #24405e;
  --btn-bg-top: rgba(255, 255, 255, 0.62);
  --btn-bg-bottom: rgba(230, 238, 248, 0.62);
  --btn-border: rgba(47, 111, 176, 0.3);
  --kbd-color: #4a6a8a;
  --stat-value-color: #182234;
  --high-score-color: #b8860b;
  --overlay-bg: rgba(255, 255, 255, 0.9);
  --overlay-text-color: #1a3a5c;
  --bg-mask-color: rgba(255, 255, 255, 0.12);
  --content-bg: #f4f6fa;
}

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

body {
  background: var(--page-bg);
  color: var(--text-primary);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  padding: 16px 0 24px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ─── Shared top navbar (index.html, how-to-play.html, faq.html) ───
   Minimal/flat by design: no gradients on links or the bar's own shape,
   just a translucent backdrop for legibility over photo backgrounds and
   thin flat borders on the small controls. */
/* Grid (not flex space-between) so .nav-links centers on the navbar's own
   midpoint exactly, regardless of the brand/controls groups having
   different widths. */
#site-nav {
  width: 100%;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 12px 32px;
  margin-bottom: 16px;
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  border-bottom: 1px solid var(--panel-border);
}

/* .nav-brand is the plain <a> in the navbar on every page. The single
   required <h1> on index.html is the descriptive #home-content heading
   below the game, not the brand. */
.nav-brand {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 2px;
  white-space: nowrap;
  justify-self: start;
}

.nav-brand,
.nav-brand a {
  color: var(--accent);
  text-decoration: none;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  gap: 20px;
  justify-self: center;
}

.nav-links a {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.nav-links a:hover {
  color: var(--accent);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

.nav-select {
  font-size: 12px;
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text-primary);
}

.nav-select option {
  background: var(--canvas-panel-bg);
  color: var(--btn-text);
}

.nav-icon-btn {
  font-size: 15px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
}

.nav-icon-btn:hover {
  background: rgba(var(--accent-rgb), 0.12);
}

.page-background-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 3.5s ease;
}

.page-background-layer.visible {
  opacity: 1;
}

.page-background-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-mask-color);
}

/* Real, visible sentence describing the game — sits over an arbitrary
   photo background like the sidebar panels, so it gets the same
   translucent backdrop + light-mode text-shadow treatment as those. */
#hero-intro {
  max-width: 640px;
  margin: 20px 0 0;
  padding: 10px 18px;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  border: 1px solid var(--panel-border-soft);
  border-radius: 10px;
}

body[data-ui-theme="light"] #hero-intro {
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.9), 0 0 8px rgba(255, 255, 255, 0.6);
}

/* Crawlable SEO copy below the game — same translucent panel treatment as
   #hero-intro so it reads cleanly over any photo background. */
#home-content {
  max-width: 640px;
  margin: 16px 0 0;
  padding: 20px 22px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  border: 1px solid var(--panel-border-soft);
  border-radius: 10px;
}

#home-content h1 {
  font-size: 20px;
  color: var(--heading-color);
  margin: 0 0 8px;
}

#home-content h2 {
  font-size: 16px;
  color: var(--heading-color);
  margin: 20px 0 6px;
}

#home-content p {
  margin: 0;
}

#home-content a {
  color: var(--accent);
  text-decoration: none;
}

#home-content a:hover {
  text-decoration: underline;
}

body[data-ui-theme="light"] #home-content {
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.9), 0 0 8px rgba(255, 255, 255, 0.6);
}

#site-footer {
  margin-top: 16px;
  text-align: center;
}

#site-footer a {
  font-size: 12px;
  color: var(--kbd-color);
  text-decoration: none;
}

#site-footer a:hover {
  color: var(--accent);
}

/* Sidebar panels sit at 0.5 alpha over an arbitrary photo — a soft glow
   alone isn't enough contrast insurance in light mode, so add a subtle
   white halo behind heading/label/key text too. */
body[data-ui-theme="light"] h3,
body[data-ui-theme="light"] .field-label,
body[data-ui-theme="light"] .key-row {
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.9), 0 0 8px rgba(255, 255, 255, 0.6);
}

#game-container {
  display: flex;
  align-items: stretch;
  gap: 24px;
}

#left-panel,
#right-panel {
  width: 170px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#left-panel {
  align-self: stretch;
}

#center-panel {
  position: relative;
  /* Don't stretch to match a taller sidebar (align-items: stretch on
     #game-container) — the board stays its natural size, and the
     absolutely-positioned #overlay would otherwise stretch with it. */
  align-self: flex-start;
}

#game-canvas {
  display: block;
  border: 2px solid var(--canvas-border);
  border-radius: 6px;
  background-color: transparent;
  box-shadow:
    0 0 40px rgba(30, 70, 120, 0.35),
    0 0 80px rgba(30, 70, 120, 0.12),
    inset 0 0 30px rgba(0, 0, 0, 0.4);
}

#hold-canvas,
#next-canvas {
  display: block;
  border: 1px solid var(--canvas-panel-border);
  border-radius: 8px;
  background-color: transparent;
}

#hold-section,
#next-section {
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 4px 20px var(--panel-shadow);
}

#score-section {
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 4px 20px var(--panel-shadow);
}

h3 {
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--heading-color);
  margin-bottom: 8px;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 0 6px rgba(var(--accent-rgb), 0.15);
}

/* Sub-label distinguishing multiple controls grouped in one box (e.g. SFX vs BGM volume). */
.field-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--heading-color);
  margin-bottom: 4px;
  text-align: center;
  text-transform: uppercase;
  opacity: 0.85;
}

.stat {
  text-align: center;
}

#score-value,
#level-value,
#lines-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--stat-value-color);
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', 'Consolas', monospace;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.35);
}

#overlay {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: var(--overlay-bg);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px;
  transition: opacity 0.4s ease;
  opacity: 0;
  pointer-events: none;
  overflow-y: auto;
}

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

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

#overlay-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--overlay-text-color);
  text-align: center;
  line-height: 1.8;
  text-shadow: 0 0 16px rgba(var(--accent-rgb), 0.5);
  transform: scale(0.9);
  transition: transform 0.4s ease;
  white-space: pre-line;
}

#overlay.visible #overlay-text {
  transform: scale(1);
}

/* Full control reference, shown only on the idle "press enter to start" screen. */
#overlay-controls {
  display: none;
}

#overlay.show-controls #overlay-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 100%;
}

.overlay-control-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  row-gap: 4px;
  column-gap: 6px;
  font-size: 13px;
  color: var(--kbd-color);
}

.overlay-key-sep {
  opacity: 0.6;
}

.overlay-controls-mobile {
  display: none;
}

#button-section {
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 20px var(--panel-shadow);
}

.game-btn {
  padding: 7px 8px;
  font-size: 11px;
  font-weight: 700;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--btn-text);
  background: linear-gradient(180deg, var(--btn-bg-top), var(--btn-bg-bottom));
  border: 1px solid var(--btn-border);
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  width: 100%;
}

.game-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.25), rgba(var(--accent-rgb), 0.12));
  border-color: rgba(var(--accent-rgb), 0.7);
  color: var(--stat-value-color);
  box-shadow: 0 2px 12px rgba(var(--accent-rgb), 0.25);
}

.game-btn:active:not(:disabled) {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.game-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.game-btn.active {
  color: #ffe080;
  background: linear-gradient(180deg, rgba(60, 45, 10, 0.7), rgba(40, 30, 5, 0.8));
  border-color: rgba(255, 224, 128, 0.6);
  box-shadow: 0 0 10px rgba(255, 224, 128, 0.2);
}

#keys-section {
  background: linear-gradient(180deg, var(--panel-bg-top-soft), var(--panel-bg-bottom-soft));
  border: 1px solid var(--panel-border-soft);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Collapsible submenus opened via the CONFIGURATION/AUDIO buttons. */
.config-hidden {
  display: none;
}

#config-submenu,
#audio-submenu {
  margin-top: 10px;
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 4px 20px var(--panel-shadow);
}

.key-row {
  font-size: 10px;
  color: var(--kbd-color);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  color: var(--btn-text);
  background: linear-gradient(180deg, var(--btn-bg-top), var(--btn-bg-bottom));
  border: 1px solid var(--btn-border);
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  min-width: 22px;
  text-align: center;
  line-height: 1.4;
}

#theme-section,
#background-section {
  background: linear-gradient(180deg, var(--panel-bg-top), var(--panel-bg-bottom));
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 4px 20px var(--panel-shadow);
}

/* Background picker hidden for now — random-pick-on-start + 60s
   auto-rotation still run under the hood, just not user-exposed. */
#background-section {
  display: none;
}

.theme-select {
  width: 100%;
  padding: 7px 6px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--btn-text);
  background: linear-gradient(180deg, var(--btn-bg-top), var(--btn-bg-bottom));
  border: 1px solid var(--btn-border);
  border-radius: 5px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235a8eb8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.theme-select:hover {
  border-color: rgba(var(--accent-rgb), 0.7);
  color: var(--stat-value-color);
}

.theme-select:focus {
  border-color: rgba(var(--accent-rgb), 0.8);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.3);
}

.theme-select option {
  background: var(--canvas-panel-bg);
  color: var(--btn-text);
  padding: 6px;
}

.volume-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(var(--accent-rgb), 0.3);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1b3a5c;
  box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.4);
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #1b3a5c;
  box-shadow: 0 0 6px rgba(var(--accent-rgb), 0.4);
  cursor: pointer;
}

.speed-label {
  text-align: center;
  color: var(--accent);
  font-size: 12px;
  margin-top: 4px;
  letter-spacing: 1px;
}

/* High score */
.high-score-stat {
  border-top: 1px solid var(--panel-border);
  padding-top: 8px;
  margin-top: 4px;
}

.high-score-stat h3 {
  color: var(--high-score-color);
}

#high-score {
  color: var(--high-score-color);
}

/* Hamburger hint — hidden by default */
#hamburger-hint {
  display: none;
}

/* Desktop settings highlight after first game start */
.settings-highlight {
  animation: settingsGlow 1.2s ease-in-out 3;
}

@keyframes settingsGlow {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 15px rgba(90, 176, 255, 0.4), 0 0 30px rgba(90, 176, 255, 0.2); border-radius: 8px; }
}

/* Touch controls — hidden on desktop */
#touch-controls {
  display: none;
}

/* Mobile-only elements — hidden on desktop */
#mobile-stats,
#mobile-drawer,
#mobile-menu-toggle,
#mobile-hold,
#mobile-next {
  display: none;
}
