* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden; background: #0a0a0f;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
canvas {
  display: block;
  width: 100%; height: 100%;
  touch-action: none;
}

#ui-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 10;
  font-family: 'Special Elite', 'Courier New', monospace;
  color: #c8b88a;
}
#ui-overlay .screen,
#ui-overlay .pause-overlay,
#ui-overlay .gameover-overlay {
  pointer-events: auto;
}
#ui-overlay * {
  pointer-events: auto;
}

.screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 12, 0.85);
}

.title {
  font-family: 'IM Fell English SC', serif;
  font-size: clamp(1.8rem, 6vw, 3.5rem);
  text-align: center;
  line-height: 1.2;
  color: #e8d5a0;
  text-shadow: 0 0 40px rgba(200, 180, 120, 0.2), 0 2px 4px rgba(0,0,0,0.8);
  margin-bottom: 0.3em;
  letter-spacing: 0.05em;
}
.subtitle {
  font-size: clamp(0.9rem, 2.5vw, 1.2rem);
  color: #8a7a5a;
  margin-bottom: 2em;
  font-style: italic;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.menu-nav {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  align-items: center;
}
.menu-btn {
  background: transparent;
  border: 1px solid #5a4a3a;
  color: #c8b88a;
  font-family: 'Special Elite', monospace;
  font-size: clamp(0.9rem, 2.2vw, 1.1rem);
  padding: 0.5em 2em;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 200px;
  text-align: center;
  letter-spacing: 0.1em;
}
.menu-btn:hover, .menu-btn:focus-visible {
  background: rgba(200, 180, 120, 0.1);
  border-color: #c8b88a;
  color: #f0e0b0;
  outline: none;
}
.menu-btn.primary {
  border-color: #b89a50;
  color: #f0e0b0;
}
.menu-btn.primary:hover {
  background: rgba(200, 180, 120, 0.15);
  border-color: #d4b860;
}
.menu-btn:active {
  transform: scale(0.97);
}

.menu-footer {
  position: absolute;
  bottom: 1.5em;
  right: 1.5em;
  display: flex;
  gap: 0.8em;
  align-items: center;
}
.menu-footer button {
  background: transparent;
  border: 1px solid #3a2a1a;
  color: #8a7a5a;
  font-size: 1.2rem;
  padding: 0.3em 0.5em;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.menu-footer button:hover {
  border-color: #8a7a5a;
  color: #c8b88a;
}
.version {
  font-size: 0.7rem;
  color: #4a3a2a;
  letter-spacing: 0.15em;
}

/* Tutorial */
.tutorial-content {
  max-width: 480px;
  padding: 2em;
  text-align: center;
}
.tutorial-content h2 {
  font-family: 'IM Fell English SC', serif;
  font-size: 1.6rem;
  color: #e8d5a0;
  margin-bottom: 1em;
}
.tutorial-step {
  display: none;
  min-height: 200px;
}
.tutorial-step.active { display: block; }
.tutorial-step p {
  font-size: 1rem;
  line-height: 1.7;
  color: #b8a888;
  margin-bottom: 1em;
}
.control-hint {
  background: rgba(200, 180, 120, 0.06);
  border: 1px solid #3a2a1a;
  padding: 1em;
  font-size: 0.85rem !important;
  line-height: 1.6 !important;
  color: #8a7a5a !important;
}
.tutorial-nav {
  display: flex;
  gap: 0.5em;
  align-items: center;
  justify-content: center;
  margin-top: 1.5em;
  flex-wrap: wrap;
}
.tutorial-nav button {
  background: transparent;
  border: 1px solid #5a4a3a;
  color: #c8b88a;
  font-family: 'Special Elite', monospace;
  font-size: 0.85rem;
  padding: 0.4em 1em;
  cursor: pointer;
  transition: all 0.2s;
}
.tutorial-nav button:hover:not(:disabled) {
  border-color: #c8b88a;
}
.tutorial-nav button:disabled {
  opacity: 0.3;
  cursor: default;
}
.skip-btn {
  margin-left: 0.5em;
  font-size: 0.75rem !important;
  color: #5a4a3a !important;
  border-color: #2a1a0a !important;
}
#tutorial-counter {
  font-size: 0.8rem;
  color: #6a5a4a;
}

/* Leaderboard */
#leaderboard-screen h2 {
  font-family: 'IM Fell English SC', serif;
  font-size: 1.6rem;
  color: #e8d5a0;
  margin-bottom: 1em;
}
#leaderboard-entries {
  max-width: 400px;
  width: 90%;
  margin-bottom: 1.5em;
}
.lb-entry {
  display: flex;
  justify-content: space-between;
  padding: 0.3em 0.5em;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(90, 74, 58, 0.3);
  color: #b8a888;
}
.lb-entry .rank { color: #6a5a4a; width: 2em; }
.lb-entry .name { flex: 1; text-align: left; }
.lb-entry .score { text-align: right; font-family: monospace; }
.lb-entry.new-highlight {
  color: #f0e0b0;
  background: rgba(200, 180, 120, 0.08);
}
.lb-empty {
  color: #5a4a3a;
  font-style: italic;
  text-align: center;
  padding: 2em;
}
#leaderboard-back {
  margin-top: 0.5em;
}

/* Settings */
#settings-screen h2 {
  font-family: 'IM Fell English SC', serif;
  font-size: 1.6rem;
  color: #e8d5a0;
  margin-bottom: 1.5em;
}
.setting-row {
  display: flex;
  align-items: center;
  gap: 1em;
  margin-bottom: 1em;
  min-width: 280px;
}
.setting-row label {
  width: 100px;
  color: #b8a888;
  font-size: 0.9rem;
}
.setting-row input[type="range"] {
  flex: 1;
  accent-color: #b89a50;
  background: transparent;
}
.setting-row select {
  background: transparent;
  border: 1px solid #5a4a3a;
  color: #c8b88a;
  font-family: 'Special Elite', monospace;
  font-size: 0.9rem;
  padding: 0.3em 0.5em;
  cursor: pointer;
}
.setting-row select:focus {
  outline: none;
  border-color: #c8b88a;
}
#settings-back { margin-top: 1.5em; }

/* Pause */
.pause-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1em;
  background: rgba(5, 5, 12, 0.8);
}
.pause-overlay h2 {
  font-family: 'IM Fell English SC', serif;
  font-size: 2rem;
  color: #e8d5a0;
  margin-bottom: 0.5em;
}

/* Game Over */
.gameover-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7em;
  background: rgba(5, 5, 12, 0.9);
}
.gameover-overlay h2 {
  font-family: 'IM Fell English SC', serif;
  font-size: 2rem;
  color: #c04040;
  text-shadow: 0 0 30px rgba(192, 64, 64, 0.3);
  margin-bottom: 0.3em;
}
.gameover-overlay p {
  color: #b8a888;
  font-size: 1rem;
}
#final-score-text { font-size: 1.4rem; }
#final-highscore-text { font-size: 0.9rem; color: #6a5a4a; }
.name-entry { margin: 0.5em 0; }
.initials-input input {
  background: transparent;
  border: 1px solid #5a4a3a;
  color: #c8b88a;
  font-family: 'Special Elite', monospace;
  font-size: 1.5rem;
  width: 80px;
  text-align: center;
  padding: 0.2em;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}
.initials-input input:focus { outline: none; border-color: #c8b88a; }
#save-score-btn {
  background: transparent;
  border: 1px solid #5a4a3a;
  color: #c8b88a;
  font-family: 'Special Elite', monospace;
  font-size: 0.8rem;
  padding: 0.4em 1.2em;
  cursor: pointer;
  margin-top: 0.5em;
  transition: all 0.2s;
}
#save-score-btn:hover { border-color: #c8b88a; }
.gameover-buttons {
  display: flex;
  gap: 0.8em;
  margin-top: 0.5em;
}

/* HUD */
#hud {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
}
#storm-meter-container {
  position: absolute;
  top: 1em; right: 1em;
  width: 12px;
  height: 200px;
  border: 1px solid rgba(200, 180, 120, 0.3);
  background: rgba(0,0,0,0.5);
}
#storm-meter-fill {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to top, #c04040, #802020);
  transition: height 0.3s;
}
#score-display {
  position: absolute;
  bottom: 1.5em; left: 1.5em;
  font-family: 'Special Elite', monospace;
  color: #c8b88a;
  font-size: 1.2rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
#combo-display {
  position: absolute;
  bottom: 3em; left: 50%;
  transform: translateX(-50%);
  font-family: 'Special Elite', monospace;
  color: #e8d5a0;
  font-size: 1rem;
  opacity: 0;
  transition: opacity 0.3s;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

/* Mobile controls */
#mobile-controls {
  position: fixed;
  bottom: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 6;
  display: none;
}
#mobile-controls.active {
  display: block;
}
#mobile-tap-area {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: auto;
  touch-action: none;
}

/* Toast messages */
#toast {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Special Elite', monospace;
  color: #e8d5a0;
  font-size: 1.5rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.3s;
  text-align: center;
}