:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body {
  margin: 0; background: #05050f; color: #eaf0ff;
  font-family: 'Quicksand', system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  overflow-x: hidden;
}
body {
  display: flex; justify-content: center; padding: 14px;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(0,240,255,0.10), transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(255,0,224,0.10), transparent 55%),
    #05050f;
  min-height: 100vh;
  min-height: 100dvh;
}
h1, h2, .neon-font { font-family: 'Orbitron', 'Quicksand', sans-serif; }

.wrap { width: 100%; max-width: 1400px; display: flex; flex-direction: column; align-items: center; gap: 8px; }

.topbar {
  width: 100%; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 6px 14px;
  border: 1px solid rgba(0,240,255,0.4); background: rgba(14,14,28,0.65);
  border-radius: 12px; padding: 8px 16px; font-size: 13px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.05);
  animation: dropIn 0.5s cubic-bezier(.2,.8,.2,1);
}
.topbar .stat { display: flex; align-items: center; gap: 5px; white-space: nowrap; transition: transform 0.15s ease; }
.topbar .val { color: #00f0ff; font-weight: 700; font-family: 'Orbitron', sans-serif; font-size: 13px; transition: color 0.2s; }
.topbar .val.gold { color: #ffd23f; }
.topbar .val.pink { color: #ff00e0; }
.topbar .val.bump { animation: valBump 0.35s ease-out; }
@keyframes valBump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes dropIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.iconbtn {
  border: 1px solid rgba(0,240,255,0.5); background: rgba(0,240,255,0.06); color: #eaf0ff;
  border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer; font-family: 'Quicksand', sans-serif; font-weight: 700;
  transition: background 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.iconbtn:hover { border-color: rgba(0,240,255,0.9); box-shadow: 0 0 10px rgba(0,240,255,0.35); }
.iconbtn:active { background: rgba(0,240,255,0.25); transform: scale(0.94); }
.iconbtn-row { display: flex; align-items: center; gap: 8px; }

.bar-block { width: 100%; }
.bar-label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.bar-label.health { color: #4ade80; }
.bar-label.boss { color: #ff00e0; justify-content: center; letter-spacing: 1px; }
.bar-label.progress { color: #8fb8ff; }
.bar-track {
  height: 12px; width: 100%; border-radius: 999px; overflow: hidden;
  background: rgba(0,0,0,0.5); border: 1px solid rgba(0,0,0,0.3);
}
.bar-track.health-track { border-color: rgba(74,222,128,0.6); }
.bar-track.boss-track { border-color: rgba(255,0,224,0.6); }
.bar-track.progress-track { border-color: rgba(143,184,255,0.5); height: 8px; }
.bar-fill { height: 100%; transition: width 0.4s ease-out; }
.bar-fill.health-fill { background: linear-gradient(90deg, #16a34a, #4ade80); box-shadow: 0 0 10px rgba(74,222,128,0.6); }
.bar-fill.boss-fill { background: linear-gradient(90deg, #ff00e0, #00f0ff); transition: width 0.15s; box-shadow: 0 0 10px rgba(255,0,224,0.6); }
.bar-fill.progress-fill { background: linear-gradient(90deg, #3b82f6, #8fb8ff); transition: width 0.3s; }
#bossBarBlock { display: none; }

.shield-row { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #7de8ff; font-weight: 700; }
.shield-pip {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid #00f0ff;
  background: rgba(0,240,255,0.15); box-shadow: 0 0 6px rgba(0,240,255,0.5);
  transition: all 0.3s;
}
.shield-pip.used { background: transparent; border-color: rgba(0,240,255,0.2); box-shadow: none; }

.stage {
  position: relative; width: 100%;
  border-radius: 16px; border: 2px solid #00f0ff; background: #000010;
  box-shadow: 0 0 50px rgba(0,240,255,0.45), inset 0 0 60px rgba(0,0,0,0.6);
  animation: stageGlow 4s ease-in-out infinite;
  overflow: hidden;
}
@keyframes stageGlow {
  0%, 100% { box-shadow: 0 0 50px rgba(0,240,255,0.45), inset 0 0 60px rgba(0,0,0,0.6); }
  50% { box-shadow: 0 0 65px rgba(0,240,255,0.65), 0 0 30px rgba(255,0,224,0.25), inset 0 0 60px rgba(0,0,0,0.6); }
}
.stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 14px;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.025) 0px, rgba(255,255,255,0.025) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: overlay; opacity: 0.5;
}
#gameCanvas { display: block; width: 100%; height: auto; max-height: 100%; touch-action: none; border-radius: 14px; object-fit: contain; }

.banner {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  pointer-events: none; border: 1px solid rgba(0,240,255,0.6); background: rgba(0,0,0,0.78);
  padding: 9px 22px; border-radius: 10px; font-weight: 800; font-size: 17px; color: #00f0ff;
  display: none; white-space: nowrap; box-shadow: 0 0 22px rgba(0,240,255,0.4);
  max-width: 92%; text-overflow: ellipsis; overflow: hidden; font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.5px;
}
.banner.warn { color: #ff4d6d; border-color: rgba(255,77,109,0.7); box-shadow: 0 0 22px rgba(255,77,109,0.5); animation: warnPulse 0.5s ease-in-out infinite; }
@keyframes warnPulse { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.05); } }

.floattext {
  position: absolute; pointer-events: none; font-family: 'Orbitron', sans-serif; font-weight: 800;
  font-size: 13px; text-shadow: 0 0 8px currentColor; animation: floatUp 1s ease-out forwards;
}
@keyframes floatUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-40px); } }

.overlay {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 16px 20px; border-radius: 14px;
  background: rgba(4,4,12,0.9); backdrop-filter: blur(3px); overflow-y: auto;
}
.overlay.active { display: flex; animation: overlayIn 0.32s cubic-bezier(.2,.8,.2,1); }
@keyframes overlayIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.overlay.active > * { animation: overlayContentIn 0.4s cubic-bezier(.2,.8,.2,1) backwards; }
.overlay.active > *:nth-child(1) { animation-delay: 0.02s; }
.overlay.active > *:nth-child(2) { animation-delay: 0.06s; }
.overlay.active > *:nth-child(3) { animation-delay: 0.10s; }
.overlay.active > *:nth-child(4) { animation-delay: 0.14s; }
.overlay.active > *:nth-child(5) { animation-delay: 0.18s; }
.overlay.active > *:nth-child(6) { animation-delay: 0.22s; }
@keyframes overlayContentIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.overlay h2 {
  margin: 0 0 10px; font-size: 24px; font-weight: 800;
  background: linear-gradient(90deg, #ff00e0, #00f0ff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.overlay h2.plain { color: #00f0ff; background: none; -webkit-text-fill-color: initial; }
.overlay h2.danger { color: #ff4d6d; background: none; -webkit-text-fill-color: initial; }
.overlay p { margin: 4px 0; font-size: 14px; color: #9aa0b4; }
.overlay p.hint { color: #ff00e0; font-size: 12px; }
.overlay .final { color: #eaf0ff; }
.overlay .final .val { color: #00f0ff; font-weight: 700; }
.overlay .newhigh { color: #ffd23f; font-weight: 800; font-size: 15px; margin-top: 6px; display: none; text-shadow: 0 0 10px rgba(255,210,63,0.7); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.primary-btn {
  border: none; cursor: pointer;
  background: linear-gradient(90deg, #00f0ff, #ff00e0); background-size: 160% 100%; color: #001018;
  font-weight: 800; font-size: 15px; padding: 10px 24px; border-radius: 10px;
  font-family: 'Quicksand', sans-serif;
  transition: transform 0.15s cubic-bezier(.2,.8,.2,1), box-shadow 0.2s ease, background-position 0.4s ease;
  box-shadow: 0 4px 16px rgba(0,240,255,0.3);
}
.primary-btn:hover { background-position: 100% 0; box-shadow: 0 6px 22px rgba(255,0,224,0.4); transform: translateY(-1px); }
.primary-btn:active { transform: scale(0.96); box-shadow: 0 2px 8px rgba(0,240,255,0.35); }
.secondary-btn {
  border: 1px solid rgba(0,240,255,0.6); cursor: pointer; background: rgba(0,240,255,0.08); color: #eaf0ff;
  font-weight: 700; font-size: 14px; padding: 9px 20px; border-radius: 10px; font-family: 'Quicksand', sans-serif;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.secondary-btn:hover { border-color: rgba(0,240,255,1); box-shadow: 0 0 14px rgba(0,240,255,0.35); }
.secondary-btn:active { transform: scale(0.96); background: rgba(0,240,255,0.2); }

.danger-btn {
  border: 1px solid rgba(255,77,109,0.6); cursor: pointer; background: rgba(255,77,109,0.08); color: #ff8fa3;
  font-weight: 700; font-size: 14px; padding: 9px 20px; border-radius: 10px; font-family: 'Quicksand', sans-serif;
  transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.danger-btn:hover { box-shadow: 0 0 14px rgba(255,77,109,0.4); }
.danger-btn:active { transform: scale(0.96); background: rgba(255,77,109,0.2); }

.playcount-note { font-size: 11px; color: #5b6178; margin-top: 10px; max-width: 380px; }

/* ---------- Instructions / How to Play ---------- */
#overlayInstructions {
  padding: 10px 14px 16px;
  justify-content: flex-start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.howto-topbar {
  width: 100%; display: flex; justify-content: flex-end; margin-bottom: 4px; flex-shrink: 0;
}
.howto-lang-btn { font-size: 12px !important; padding: 5px 10px !important; }
.howto-heading { font-size: 18px !important; margin: 0 0 6px !important; }
.howto-intro {
  font-size: 11px !important; line-height: 1.35; margin: 0 0 8px !important;
  max-width: 520px; color: #9aa0b4;
}
.howto-block { width: 100%; max-width: 520px; text-align: left; margin-top: 6px; }
.howto-title {
  font-family: 'Orbitron', sans-serif; color: #00f0ff; font-weight: 800; font-size: 11px;
  letter-spacing: 1px; margin-bottom: 4px; text-align: center;
}
.howto-line {
  font-size: 10.5px; color: #c7ccdc; margin: 3px 0; line-height: 1.35;
  border: 1px solid rgba(0,240,255,0.16); background: rgba(0,240,255,0.04);
  border-radius: 6px; padding: 4px 8px;
}
.howto-line b { color: #eaf0ff; }
.howto-hint { font-size: 10px !important; margin: 8px 0 6px !important; max-width: 520px; }
.howto-actions { margin-top: 6px; margin-bottom: env(safe-area-inset-bottom, 6px); }

/* Full-screen how-to (portrait + landscape) */
body.howto-open {
  padding: 0 !important;
  overflow: hidden;
}
body.howto-open .wrap {
  max-width: none;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  gap: 0;
}
body.howto-open .topbar,
body.howto-open .bar-block,
body.howto-open .shield-row,
body.howto-open .controls,
body.howto-open .hint-text {
  display: none !important;
}
body.howto-open .stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  aspect-ratio: unset;
  border-radius: 0;
  border: none;
  box-shadow: none;
  z-index: 50;
  overflow: hidden;
}
body.howto-open #gameCanvas { display: none !important; }
body.howto-open #overlayInstructions {
  position: absolute;
  inset: 0;
  border-radius: 0;
  background: rgba(4, 4, 14, 0.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- Shop ---------- */
/* Shop content can be taller than the stage (many ships to scroll through), and a
   centered flex container clips overflow equally off both the top AND bottom with
   no way to scroll back up to it — so this overlay specifically anchors to the top
   instead of centering, which keeps the title and every card reachable by scrolling. */
#overlayShop { padding: 10px 14px; justify-content: flex-start; }
.shop-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.shop-tab {
  border: 1px solid rgba(0,240,255,0.4); background: transparent; color: #9aa0b4; cursor: pointer;
  padding: 7px 18px; border-radius: 999px; font-family: 'Quicksand', sans-serif; font-weight: 700; font-size: 13px;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.15s ease, box-shadow 0.25s ease;
}
.shop-tab:hover { border-color: rgba(0,240,255,0.9); }
.shop-tab:active { transform: scale(0.95); }
.shop-tab.active { background: linear-gradient(90deg, #00f0ff, #ff00e0); color: #001018; border-color: transparent; box-shadow: 0 0 14px rgba(0,240,255,0.4); }
.shop-coins { font-family: 'Orbitron', sans-serif; color: #ffd23f; font-weight: 800; font-size: 15px; margin-bottom: 8px; text-shadow: 0 0 10px rgba(255,210,63,0.5); }
.shop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px;
  width: 100%; max-width: 720px; max-height: min(55vh, 420px); overflow-y: auto; padding: 4px;
  flex: 1 1 180px; min-height: 150px;
  scrollbar-width: thin; scrollbar-color: rgba(0,240,255,0.5) rgba(0,0,0,0.2);
}
.shop-grid::-webkit-scrollbar { width: 6px; }
.shop-grid::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 999px; }
.shop-grid::-webkit-scrollbar-thumb { background: rgba(0,240,255,0.5); border-radius: 999px; }
#overlayShop h2, #overlayShop .shop-coins, #overlayShop .shop-tabs, #overlayShop .close-shop {
  flex-shrink: 0;
}
.shop-card {
  border: 1px solid rgba(0,240,255,0.35); background: rgba(10,10,24,0.7); border-radius: 12px;
  padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform 0.18s cubic-bezier(.2,.8,.2,1), border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  animation: cardIn 0.35s cubic-bezier(.2,.8,.2,1) backwards;
}
.shop-card:hover { transform: translateY(-3px); border-color: rgba(0,240,255,0.7); box-shadow: 0 6px 18px rgba(0,240,255,0.25); background: rgba(14,16,32,0.85); }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.shop-grid .shop-card:nth-child(1) { animation-delay: 0.02s; }
.shop-grid .shop-card:nth-child(2) { animation-delay: 0.06s; }
.shop-grid .shop-card:nth-child(3) { animation-delay: 0.10s; }
.shop-grid .shop-card:nth-child(4) { animation-delay: 0.14s; }
.shop-grid .shop-card:nth-child(5) { animation-delay: 0.18s; }
.shop-grid .shop-card:nth-child(6) { animation-delay: 0.22s; }
.shop-grid .shop-card:nth-child(n+7) { animation-delay: 0.26s; }
.shop-card.owned { border-color: rgba(74,222,128,0.6); }
.shop-card.selected { border-color: #ffd23f; box-shadow: 0 0 14px rgba(255,210,63,0.4); }
.shop-card canvas { width: 60px; height: 60px; filter: drop-shadow(0 0 6px rgba(0,240,255,0.35)); }
.shop-card .upgrade-icon {
  font-size: 32px; line-height: 1; width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: radial-gradient(circle at 40% 35%, rgba(0,240,255,0.22), rgba(0,0,20,0.45));
  border: 2px solid rgba(0,240,255,0.35);
  box-shadow: 0 0 12px rgba(0,240,255,0.2);
}
.shop-card .name { font-weight: 800; font-size: 13px; color: #eaf0ff; font-family: 'Orbitron', sans-serif; }
.shop-card .stats { font-size: 10px; color: #9aa0b4; text-align: center; line-height: 1.4; }
.control-side-btn {
  margin: 6px auto 10px; display: block; font-size: 13px !important;
  padding: 8px 14px !important;
}
.shop-card button {
  margin-top: 4px; border: none; cursor: pointer; border-radius: 8px; padding: 6px 10px; font-size: 12px;
  font-weight: 700; font-family: 'Quicksand', sans-serif;
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.shop-card button:active:not(:disabled) { transform: scale(0.93); }
.shop-card .buy-btn { background: linear-gradient(90deg, #00f0ff, #ff00e0); color: #001018; }
.shop-card .buy-btn:not(:disabled):hover { filter: brightness(1.15); box-shadow: 0 0 12px rgba(0,240,255,0.5); }
.shop-card .buy-btn:disabled { background: #333; color: #777; cursor: not-allowed; }
.shop-card .select-btn { background: rgba(74,222,128,0.2); color: #4ade80; border: 1px solid #4ade80; }
.shop-card .select-btn.active-sel { background: #ffd23f; color: #001018; border-color: #ffd23f; }
.close-shop { margin-top: 12px; }

/* Pre-game screens (instructions + ready-to-launch): hide every HUD element
   so the overlay has the whole screen to itself, and let the stage grow tall
   instead of being squeezed into the 16:9 gameplay ratio. Everything comes
   back the moment Start Game is actually pressed (phase leaves "start"). */
body.pregame .topbar,
body.pregame .bar-block,
body.pregame .shield-row,
body.pregame .controls { display: none !important; }
body.pregame .stage { aspect-ratio: unset; min-height: 76vh; min-height: 76dvh; }

/* Joystick + FIRE only during active gameplay (playing / boss / warning). */
body:not(.gameplay) .controls { display: none !important; }

/* ---------- Full-screen shop (portrait + landscape) ---------- */
body.shop-open {
  padding: 0 !important;
  overflow: hidden;
}
body.shop-open .wrap {
  max-width: none;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  gap: 0;
}
body.shop-open .topbar,
body.shop-open .bar-block,
body.shop-open .shield-row,
body.shop-open .controls,
body.shop-open .hint-text {
  display: none !important;
}
body.shop-open .stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  aspect-ratio: unset;
  border-radius: 0;
  border: none;
  box-shadow: none;
  z-index: 50;
  overflow: hidden;
}
body.shop-open #gameCanvas {
  display: none !important;
}
body.shop-open #overlayShop {
  position: absolute;
  inset: 0;
  border-radius: 0;
  padding: 12px 14px 20px;
  justify-content: flex-start;
  background: rgba(4, 4, 14, 0.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 60;
}
body.shop-open .shop-grid {
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
  max-width: 100%;
  width: 100%;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 16px;
}
body.shop-open .close-shop {
  margin-top: 10px;
  margin-bottom: env(safe-area-inset-bottom, 8px);
}

.stage {
  aspect-ratio: 16 / 9;
}

.controls {
  width: 100%; display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; direction: ltr; user-select: none; padding: 4px 8px 8px;
}
.controls.controls-right {
  flex-direction: row-reverse;
}
.joystick-zone {
  /* larger touch pad for snappier, more forgiving control */
  width: 240px; height: 180px; position: relative; touch-action: none;
  flex-shrink: 0;
  background: radial-gradient(ellipse at 50% 55%, rgba(0,240,255,0.08), transparent 72%);
  border-radius: 28px;
  -webkit-user-select: none; user-select: none;
}
.joystick-base {
  width: 128px; height: 128px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(0,240,255,0.28), rgba(0,0,20,0.55));
  border: 3px solid rgba(0,240,255,0.65);
  box-shadow: 0 0 28px rgba(0,240,255,0.35), inset 0 0 22px rgba(0,0,0,0.55);
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  touch-action: none; pointer-events: none;
  opacity: 0.4;
  transition: opacity 0.08s ease, box-shadow 0.1s ease, border-color 0.1s ease;
}
.joystick-base.visible {
  opacity: 1;
}
.joystick-base.active {
  opacity: 1;
  border-color: rgba(255,0,224,0.85);
  box-shadow: 0 0 36px rgba(255,0,224,0.45), 0 0 18px rgba(0,240,255,0.4), inset 0 0 22px rgba(0,0,0,0.55);
}
.joystick-knob {
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(145deg, #00f0ff, #ff00e0);
  border: 3px solid rgba(255,255,255,0.55);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5), 0 0 18px rgba(0,240,255,0.5);
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  touch-action: none; pointer-events: none;
  will-change: transform;
  transition: none; /* no CSS lag — transform updates every pointer event */
}
.joystick-base.active .joystick-knob {
  box-shadow: 0 2px 10px rgba(0,0,0,0.6), 0 0 30px rgba(255,0,224,0.85);
}
.ctrlbtn {
  height: 84px; width: 104px; border-radius: 18px; border: 2px solid #00f0ff;
  background: linear-gradient(135deg, #00f0ff, #ff00e0); color: #001018;
  font-weight: 800; font-size: 30px; display: flex; align-items: center; justify-content: center;
  touch-action: none; user-select: none; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4), 0 0 16px rgba(0,240,255,0.25);
  transition: transform 0.1s cubic-bezier(.2,.8,.2,1), box-shadow 0.15s ease;
}
.ctrlbtn.fire {
  width: 150px; height: 90px; border-radius: 22px;
  border-color: rgba(255,0,224,0.55);
  background: linear-gradient(135deg, rgba(255,0,224,0.38), rgba(0,240,255,0.32));
  color: rgba(255,255,255,0.92);
  font-size: 20px; animation: firePulse 1.8s ease-in-out infinite;
  font-family: 'Quicksand', sans-serif; font-weight: 800;
  opacity: 0.72;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.ctrlbtn.fire:active { opacity: 0.95; }
.ctrlbtn:active { transform: scale(0.93); box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 22px rgba(0,240,255,0.5); }
@keyframes firePulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255,0,224,0.0); }
  50% { box-shadow: 0 0 16px rgba(255,0,224,0.65); }
}

.hint-text { text-align: center; font-size: 11px; color: #9aa0b4; margin: 0; }

.rotate-hint {
  position: fixed; inset: 0; background: rgba(2,2,10,0.96); z-index: 999;
  display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px;
}
.rotate-hint.show { display: flex; }
.rotate-hint .spin { font-size: 46px; animation: spin360 1.6s linear infinite; margin-bottom: 10px; }
@keyframes spin360 { from { transform: rotate(0deg); } to { transform: rotate(90deg); } }
.rotate-hint h3 { font-family: 'Orbitron', sans-serif; color: #00f0ff; margin: 6px 0; }
.rotate-hint p { color: #9aa0b4; font-size: 13px; max-width: 300px; }

@media (max-width: 900px) and (orientation: portrait) {
  .rotate-hint.enabled { display: flex; }
}

/* Landscape phones: instead of guessing a fixed viewport height (which varies a lot
   between devices and whether the browser's address bar is showing), make the whole
   layout a column flexbox that fills the real available height and let the stage
   flex-grow into whatever room is left. This can never overflow, no matter the device. */
@media (orientation: landscape) {
  html, body { height: 100%; overflow: hidden; }
  body {
    padding: 4px; align-items: center;
    height: 100vh; height: 100dvh;
  }
  .wrap {
    height: 100%; max-height: 100%; width: 100%; max-width: 100%;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
  }
  .topbar { padding: 2px 8px; font-size: 9px; gap: 1px 6px; flex: 0 0 auto; }
  .topbar .val { font-size: 9px; }
  .iconbtn { padding: 3px 6px; font-size: 9px; }
  .bar-block { flex: 0 0 auto; margin: 0; }
  #progressBlock { display: none; }
  .bar-label { font-size: 9px; margin-bottom: 1px; }
  .bar-track { height: 5px; }
  .bar-track.boss-track { height: 6px; }
  .shield-row { font-size: 9px; gap: 3px; flex: 0 0 auto; }
  .shield-pip { width: 10px; height: 10px; }
  /* Bigger playfield: stage eats almost all remaining height */
  .stage {
    flex: 1 1 auto; min-height: 0; align-self: stretch;
    width: 100%; max-width: 100%;
    aspect-ratio: auto;   /* fill available height instead of forcing 16:9 box */
  }
  #gameCanvas { width: 100%; height: 100%; object-fit: contain; }
  body.pregame .stage { aspect-ratio: unset; width: 100%; max-width: 100%; min-height: 70vh; }
  .controls {
    flex: 0 0 auto; gap: 24px; padding: 2px 12px 6px;
    max-width: 100%;
  }
  .joystick-zone { width: 180px; height: 140px; }
  .joystick-base { width: 110px; height: 110px; }
  .joystick-knob { width: 50px; height: 50px; }
  .ctrlbtn.fire { width: 130px; height: 78px; font-size: 17px; border-radius: 20px; }
  .hint-text { display: none; }
}

/* Very short landscape (phones) — still prioritize stage size */
@media (orientation: landscape) and (max-height: 420px) {
  .topbar { padding: 1px 6px; }
  .bar-track { height: 4px; }
  .shield-row { display: none; }
  .joystick-zone { width: 150px; height: 110px; }
  .joystick-base { width: 90px; height: 90px; }
  .joystick-knob { width: 42px; height: 42px; }
  .ctrlbtn.fire { width: 110px; height: 64px; font-size: 15px; }
}
