:root {
  --bg: #090f1f;
  --panel: #111a34;
  --panel-soft: #18233f;
  --text: #eef3ff;
  --text-sub: #b3bfd8;
  --accent: #70e0ff;
  --accent2: #ff9ff5;
  --warn: #ffbf5a;
  --good: #4dffa8;
  --danger: #ff5a80;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Trebuchet", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 20% -10%, rgba(112, 224, 255, 0.16), transparent 65%),
    radial-gradient(1000px 420px at 85% 10%, rgba(255, 159, 245, 0.14), transparent 60%),
    linear-gradient(180deg, #071024, #040b1a 40%, #03060d 100%);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
}

#app {
  width: min(980px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  padding: 16px;
}

.topbar {
  padding: 6px 8px 12px;
}

h1, h2, p, li, button, label, strong {
  margin-top: 0;
  overflow-wrap: anywhere;
}

button {
  background: linear-gradient(180deg, #1b294f, #141d36);
  color: #eaf1ff;
  border: 1px solid rgba(112, 224, 255, 0.45);
  border-radius: 11px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
}

button:hover {
  border-color: #ff9ff5;
}

#game-root {
  position: relative;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

#screen-game {
  position: relative;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 250px;
  gap: 16px;
  align-items: start;
}

canvas {
  border: 1px solid rgba(112, 224, 255, 0.35);
  background: linear-gradient(180deg, rgba(7, 18, 40, 0.75), rgba(3, 9, 24, 0.9));
  border-radius: 12px;
  width: min(72vw, 360px);
  aspect-ratio: 1 / 2;
  touch-action: none;
}

.hud {
  background: rgba(14, 21, 39, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
  color: var(--text-sub);
}

.hud p, .hud div {
  margin: 0;
  font-size: 0.95rem;
}

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

#bossMeter {
  padding-top: 4px;
}

#bossFill {
  height: 14px;
  width: 100%;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

#bossFill::after {
  --boss: 0%;
  content: '';
  display: block;
  height: 100%;
  width: var(--boss);
  background: linear-gradient(90deg, var(--danger), var(--warn));
}

.hidden {
  display: none;
}

.screen#screen-overlay {
  position: absolute;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
}

.screen#screen-overlay.active { display: flex; }

#screen-overlay .overlay-box {
  background: rgba(11, 22, 40, 0.95);
  border: 1px solid rgba(112, 224, 255, 0.45);
  border-radius: 14px;
  padding: 18px;
  min-width: 280px;
  text-align: center;
}

#mobile-controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-items: stretch;
  min-height: 112px;
}

.joystick {
  grid-row: 1 / span 2;
  width: 124px;
  height: 124px;
  border: 2px solid rgba(112, 224, 255, 0.45);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(112,224,255,.08), rgba(7,18,40,.9));
  position: relative;
  touch-action: none;
}

.joystick::before,.joystick::after{content:'';position:absolute;background:rgba(112,224,255,.2)}
.joystick::before{left:12%;right:12%;height:1px;top:50%}.joystick::after{top:12%;bottom:12%;width:1px;left:50%}
.joystick i{position:absolute;left:35px;top:35px;width:50px;height:50px;border-radius:50%;background:linear-gradient(145deg,#70e0ff,#b46cff);box-shadow:0 0 18px rgba(112,224,255,.5);pointer-events:none}
.leaderboard{margin-top:18px;border-top:1px solid rgba(255,255,255,.1);padding-top:10px}.leaderboard h3{margin:0 0 6px}.leaderboard ol{columns:2;padding-left:24px;margin:0;color:var(--text-sub)}

#mobile-controls .pad-btn,
#mobile-controls .pad-btn.hold,
#mobile-controls .pad-btn.rotate,
#mobile-controls .pad-btn.hard {
  min-height: 64px;
  font-size: 1rem;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#overlayText {
  min-height: 72px;
}

@media (max-width: 900px), (max-aspect-ratio: 1 / 1) {
  #app {
    width: 100%;
    padding: 12px;
  }

  body:has(#screen-game.active) .topbar { display: none; }

  .game-shell { grid-template-columns: minmax(205px, 1fr) 112px; gap: 8px; }

  canvas {
    width: 100%;
    margin: 0 auto;
    display: block;
  }

  .hud { padding: 7px; gap: 4px; }
  .hud p,.hud div { font-size: .7rem; }
  .hud button { min-height: 44px; padding: 5px; }

  #mobile-controls { margin-top: 8px; grid-template-columns: 124px repeat(3,1fr); min-height: 124px; }

  .hud p {
    font-size: 0.93rem;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  body { align-items: flex-start; padding: 4px; }
  #app { padding: 5px; width: 100%; }
  #screen-game.active { display: grid; grid-template-columns: minmax(340px, 520px) minmax(260px, 1fr); gap: 8px; }
  .game-shell { grid-template-columns: minmax(170px, 230px) 145px; }
  canvas { width: auto; height: calc(100vh - 18px); }
  #mobile-controls { margin: 0; align-self: center; grid-template-columns: 124px repeat(2,1fr); }
}

.glitch {
  text-shadow: 0 0 8px rgba(255, 159, 245, 0.9);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
