:root {
  --bg-deep: #0c0807;
  --bg-warm: #1a1208;
  --gold: #f7c63a;
  --gold-dim: #b8862a;
  --red: #d4453a;
  --green: #7ab84a;
  --paper: #f5e9c8;
  --shadow: rgba(0, 0, 0, 0.65);
}

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

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--paper);
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at center, #2b1e0e 0%, #0c0807 70%, #000 100%);
}

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #87b4d6;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  outline: none;
  box-shadow: 0 0 60px #000, 0 0 0 2px var(--gold-dim) inset;
}

@media (min-aspect-ratio: 16/9) {
  #game { width: auto; height: 100vh; aspect-ratio: 16 / 9; }
}
@media (max-aspect-ratio: 16/9) {
  #game { width: 100vw; height: auto; aspect-ratio: 16 / 9; }
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-shadow: 2px 2px 0 #000;
  font-size: 11px;
}
.hud.hidden { display: none; }

.hud-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.hud-block { display: flex; flex-direction: column; gap: 4px; }
.hud-label { font-size: 8px; color: var(--gold-dim); letter-spacing: 1px; }
.hud-value { font-size: 13px; color: var(--gold); }
#lives { color: var(--red); }

.powerup-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.powerup-pill {
  background: rgba(0,0,0,0.55);
  border: 2px solid var(--gold-dim);
  padding: 4px 8px;
  font-size: 9px;
  color: var(--paper);
  display: flex;
  align-items: center;
  gap: 6px;
  image-rendering: pixelated;
}
.powerup-pill .timer { color: var(--gold); }

.combo-banner {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 28px;
  color: var(--gold);
  text-shadow: 3px 3px 0 #000, 0 0 20px var(--red);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.combo-banner.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55), rgba(0,0,0,0.85));
  text-align: center;
  padding: 30px;
}
.overlay.hidden { display: none; }

.title {
  font-size: clamp(28px, 6vw, 64px);
  line-height: 1.1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-shadow: 4px 4px 0 #000, 0 0 30px var(--red);
}
.t1 { color: var(--gold); }
.t2 { color: var(--red); font-size: 0.7em; }

.subtitle {
  font-size: 12px;
  color: var(--paper);
  opacity: 0.85;
  letter-spacing: 2px;
}

h2 {
  font-size: clamp(20px, 4vw, 40px);
  color: var(--gold);
  text-shadow: 3px 3px 0 #000;
}

.big-btn, .small-btn {
  font-family: inherit;
  background: var(--gold);
  color: var(--bg-warm);
  border: 4px solid #000;
  box-shadow: 4px 4px 0 #000;
  padding: 16px 32px;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}
.big-btn:hover, .small-btn:hover { background: #ffd84a; }
.big-btn:active, .small-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 #000;
}
.small-btn {
  background: var(--paper);
  padding: 10px 20px;
  font-size: 10px;
}

.controls-hint {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 9px;
  opacity: 0.85;
}
.controls-hint .dim { opacity: 0.55; }

#highscores {
  font-size: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--paper);
  background: rgba(0,0,0,0.4);
  padding: 12px 18px;
  border: 2px solid var(--gold-dim);
  min-width: 240px;
}
.hs-row { display: flex; justify-content: space-between; gap: 18px; }
.hs-row .hs-rank { color: var(--gold); }

/* ---------- Touch Controls ---------- */
.touch-controls {
  position: absolute;
  inset: auto 0 0 0;
  height: 35%;
  display: flex;
  justify-content: space-between;
  padding: 0 16px 16px;
  pointer-events: none;
  z-index: 5;
}
.touch-controls.hidden { display: none; }
.touch-left, .touch-right {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  pointer-events: auto;
}
.tbtn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: rgba(0,0,0,0.55);
  color: var(--gold);
  font-family: inherit;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}
.tbtn:active { background: rgba(247, 198, 58, 0.4); }

/* Auto-show touch controls on touch devices */
@media (hover: none) and (pointer: coarse) {
  .touch-controls.during-play { display: flex; }
}
