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

html, body {
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 10%, rgba(124, 77, 255, 0.18), transparent 45%),
    radial-gradient(circle at 85% 30%, rgba(0, 229, 255, 0.12), transparent 45%),
    linear-gradient(180deg, #060818 0%, #04050f 100%) fixed;
  color: #fff;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  padding: 24px 12px 40px;
}

#game-shell {
  width: min(420px, 100%, max(150px, calc((100vh - var(--gp-header-h, 80px) - 82px) * 0.7)));
  width: min(420px, 100%, max(150px, calc((100dvh - var(--gp-header-h, 80px) - 82px) * 0.7)));
}

#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(30, 44, 96, 0.72), rgba(14, 20, 48, 0.72));
  border: 1px solid rgba(110, 160, 255, 0.28);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-variant-numeric: tabular-nums;
}

#hud > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.hud-label {
  color: #6979a7;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
}

#hud strong {
  color: #00e5ff;
  font-size: 20px;
  text-shadow: 0 0 12px currentColor;
}

#hud > div:nth-child(2) strong { color: #ffd54a; }
#hud > div:nth-child(3) strong { color: #ff5c8a; }
#hud > div:nth-child(4) strong { color: #c084fc; }

#powerup-status {
  min-height: 26px;
  padding: 6px 12px;
  background: rgba(10, 16, 40, 0.8);
  border: 1px solid rgba(110, 160, 255, 0.22);
  border-top: 0;
  color: #9fb6e8;
  font-size: 10px;
  letter-spacing: 0.8px;
  text-align: center;
  text-transform: uppercase;
}

#game-area {
  position: relative;
  width: 100%;
  overflow: hidden;
  touch-action: none;
  border: 1px solid rgba(110, 160, 255, 0.28);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6), 0 0 70px rgba(80, 120, 255, 0.16);
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #050816;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  align-items: safe center;
  justify-content: center;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 35%, rgba(30, 30, 90, 0.72), rgba(4, 6, 18, 0.9));
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 10;
}

.overlay.hidden, .hidden { display: none !important; }

.overlay-content {
  width: min(360px, calc(100% - 32px));
  text-align: center;
  padding: 24px 16px;
}

.overlay h1 {
  background: linear-gradient(180deg, #ffffff 0%, #7ff3ff 45%, #7c4dff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: clamp(28px, 8vw, 42px);
  letter-spacing: 4px;
  line-height: 1.1;
  filter: drop-shadow(0 0 16px rgba(0, 229, 255, 0.45));
  margin-bottom: 12px;
}

#overlay-message {
  color: #b8c5e8;
  font-size: 16px;
  margin-bottom: 18px;
}

.how-to-play {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(140, 180, 255, 0.16);
  border-radius: 12px;
  color: #b4c0e2;
  font-size: 13px;
  line-height: 1.8;
  text-align: left;
  margin-bottom: 20px;
}

.how-title {
  color: #6575a5;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 6px;
  text-transform: uppercase;
}

#overlay-button {
  min-width: 150px;
  padding: 13px 30px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #00e5ff, #7c4dff);
  color: #050816;
  cursor: pointer;
  font: 800 15px 'Segoe UI', sans-serif;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 5px 24px rgba(0, 212, 255, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

#overlay-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 212, 255, 0.5);
}

#wave-banner {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffd54a;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 4px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 20px rgba(255, 213, 74, 0.8), 0 0 40px rgba(255, 140, 60, 0.5);
  animation: wave-in 0.5s cubic-bezier(.2, 1.4, .4, 1);
  z-index: 5;
}

@keyframes wave-in {
  from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#mobile-controls {
  display: none;
  gap: 10px;
  justify-content: center;
  padding: 12px 0 0;
}

.control-button {
  width: 86px;
  height: 52px;
  border: 1px solid rgba(110, 160, 255, 0.35);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(36, 52, 110, 0.8), rgba(16, 24, 56, 0.8));
  color: #9fc0ff;
  cursor: pointer;
  font: 800 22px 'Segoe UI', sans-serif;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.control-button.fire {
  width: 116px;
  border-color: rgba(0, 229, 255, 0.7);
  color: #7ff3ff;
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.25);
  font-size: 14px;
  letter-spacing: 1px;
}

.control-button:active, .control-button.pressed {
  background: #1c3261;
  border-color: #00e5ff;
  color: #fff;
  transform: scale(0.96);
}

#highscores {
  list-style: none;
  margin: 18px 0 0;
  padding: 12px 16px;
  background: rgba(16, 24, 56, 0.75);
  border: 1px solid rgba(110, 160, 255, 0.24);
  border-radius: 12px;
  color: #a9b8e0;
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
}

#highscores::before {
  content: 'TOP SCORES';
  display: block;
  color: #ffd54a;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

#highscores li:first-child { color: #fff; font-weight: 800; }

@media (pointer: coarse), (max-width: 600px) {
  #mobile-controls { display: flex; }
  #game-shell {
    width: min(420px, 100%, max(150px, calc((100vh - var(--gp-header-h, 80px) - 146px) * 0.7)));
    width: min(420px, 100%, max(150px, calc((100dvh - var(--gp-header-h, 80px) - 146px) * 0.7)));
  }
}

@media (max-height: 760px) {
  .overlay-content { padding: 14px 12px; }
  .overlay h1 { margin-bottom: 6px; }
  #overlay-message { margin-bottom: 10px; }
  .how-to-play { padding: 10px 14px; line-height: 1.5; font-size: 12.5px; margin-bottom: 12px; }
}

@media (max-width: 500px) {
  body { padding: 12px 8px 28px; }
  #hud { gap: 5px; padding: 9px 8px; }
  #hud > div { gap: 4px; }
  #hud strong { font-size: 15px; }
  .hud-label { font-size: 8px; letter-spacing: 0.5px; }
}

@media (max-width: 500px), (max-height: 500px) {
  .overlay { position: fixed; top: var(--gp-header-h, 48px); right: 0; bottom: 0; left: 0; z-index: 900; }
}

@media (orientation: landscape) and (max-height: 500px) {
  body { padding-bottom: 8px; }
  #game-shell { width: min(420px, 100%, max(150px, calc((100dvh - var(--gp-header-h, 48px) - 90px) * 0.7))); }
  #mobile-controls {
    position: fixed;
    left: 0;
    right: 0;
    top: calc(50% + var(--gp-header-h, 48px) / 2);
    transform: translateY(-50%);
    padding: 0 16px;
    gap: 10px;
    pointer-events: none;
    z-index: 50;
  }
  #mobile-controls .control-button { pointer-events: auto; }
  .control-button[data-action="left"] { order: 1; }
  .control-button[data-action="right"] { order: 2; margin-right: auto; }
  .control-button.fire { order: 3; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .overlay-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 24px; align-items: center; align-content: center; justify-items: center; width: min(780px, calc(100% - 24px)); max-width: none; }
  .overlay-content > * { grid-column: 2; }
  .overlay-content > .how-to-play { grid-column: 1; grid-row: 1 / span 6; margin: 0; max-width: 340px; width: 100%; }
  .overlay h1 { font-size: 30px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #game-shell {
    width: auto;
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 8px;
    align-items: start;
    justify-content: center;
  }
  #hud {
    grid-column: 1;
    grid-row: 1;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid #26345e;
    border-radius: 12px;
  }
  #powerup-status { grid-column: 1; grid-row: 2; max-width: 130px; margin-top: 6px; border: 1px solid #26345e; border-radius: 10px; }
  #game-area {
    grid-column: 2;
    grid-row: 1 / span 3;
    width: max(150px, calc((100vh - var(--gp-header-h, 48px) - 12px) * 0.7));
    width: max(150px, calc((100dvh - var(--gp-header-h, 48px) - 12px) * 0.7));
    border-top: 1px solid #26345e;
    border-radius: 12px;
  }
  #highscores { grid-column: 1 / -1; }
}

@media (pointer: coarse) and (min-width: 700px) and (min-height: 700px) {
  #game-shell {
    width: min(560px, 100%, max(150px, calc((100vh - var(--gp-header-h, 80px) - 146px) * 0.7)));
    width: min(560px, 100%, max(150px, calc((100dvh - var(--gp-header-h, 80px) - 146px) * 0.7)));
  }
}

[data-theme="light"] html,
[data-theme="light"] body { background: var(--gp-page-grad) fixed; color: var(--gp-ink); }
[data-theme="light"] #hud, [data-theme="light"] #powerup-status, [data-theme="light"] #highscores { background: var(--gp-surface); color: var(--gp-ink); box-shadow: inset 0 0 0 1px var(--gp-line), var(--gp-shadow); }
[data-theme="light"] #hud strong { color: #0a84b8; }
[data-theme="light"] #hud > div:nth-child(2) strong, [data-theme="light"] #highscores::before { color: #b7791f; }
[data-theme="light"] #hud > div:nth-child(3) strong { color: #db2777; }
[data-theme="light"] #hud > div:nth-child(4) strong { color: #9333ea; }
[data-theme="light"] #powerup-status, [data-theme="light"] #highscores { color: var(--gp-ink-2); }
[data-theme="light"] #highscores li:first-child { color: var(--gp-ink); }
[data-theme="light"] .overlay { background: var(--gp-overlay); }
[data-theme="light"] .overlay h1 { background: linear-gradient(180deg, #0a84b8, #5b3bd6); -webkit-background-clip: text; background-clip: text; filter: none; }
[data-theme="light"] #overlay-message { color: var(--gp-ink-2); }
[data-theme="light"] .how-to-play { background: rgba(31, 27, 69, 0.05); border-color: var(--gp-line); color: var(--gp-ink-2); }
[data-theme="light"] .control-button { background: var(--gp-surface); color: var(--gp-ink-2); border-color: var(--gp-line); box-shadow: 0 3px 10px rgba(31, 27, 69, 0.08); }
[data-theme="light"] .control-button.fire { color: #0a84b8; }

.gp-btn-music.off { opacity: .4; }
