/* ============================================================
   ALIEN DEMOLITION — UI stylesheet (DOM layer over the canvas)
   ============================================================ */
:root {
  --bg: #070b18;
  --panel: rgba(13, 20, 42, 0.92);
  --panel-edge: rgba(80, 130, 255, 0.28);
  --ink: #eaf6ff;
  --ink-dim: #9db4d8;
  --cyan: #37f2ff;
  --blue: #4f8dff;
  --hot: #ff3d6e;
  --lime: #7cff4e;
  --gold: #ffd166;
  --orange: #ff8f3d;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: var(--font); user-select: none; -webkit-user-select: none;
  overscroll-behavior: none; touch-action: manipulation;
}
#game {
  position: fixed; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; z-index: 0;
}
.hidden { display: none !important; }
button { font-family: var(--font); }

/* ---------------- HUD ---------------- */
.hud {
  position: fixed; inset: 0; z-index: 5; pointer-events: none;
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; justify-content: space-between;
}
.hud-top {
  display: flex; align-items: flex-start; gap: 8px;
}
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hud-left { align-items: flex-start; }
.hud-right { align-items: flex-end; }
.hearts { display: flex; gap: 4px; }
.heart { width: 15px; height: 15px; filter: drop-shadow(0 0 5px rgba(255,61,110,.8)); }
.heart.lost { opacity: .22; filter: none; }
.wave-tag {
  font-size: 12px; font-weight: 800; letter-spacing: .14em; color: var(--cyan);
  background: rgba(9, 16, 34, .72); border: 1px solid rgba(55,242,255,.35);
  padding: 3px 8px; border-radius: 999px;
}
.hud-center { flex: 1; display: flex; flex-direction: column; align-items: center; padding-top: 2px; }
.mission-label {
  font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--ink-dim);
}
.mission-bar {
  margin-top: 4px; width: min(200px, 60vw); height: 7px; border-radius: 999px;
  background: rgba(10, 16, 34, .75); border: 1px solid rgba(124,255,78,.3); overflow: hidden;
}
.mission-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--lime), var(--cyan));
  box-shadow: 0 0 10px rgba(124,255,78,.7); transition: width .25s ease;
}
.score-label { font-size: 10px; letter-spacing: .22em; color: var(--ink-dim); font-weight: 700; }
.score {
  font-size: clamp(20px, 6vw, 30px); font-weight: 900; line-height: 1;
  text-shadow: 0 0 12px rgba(55,242,255,.55); font-variant-numeric: tabular-nums;
}
.coin-line {
  display: flex; align-items: center; gap: 5px; font-weight: 800; font-size: 14px;
  color: var(--gold); text-shadow: 0 0 8px rgba(255,209,102,.5);
  font-variant-numeric: tabular-nums;
}
.coin-dot {
  width: 13px; height: 13px; border-radius: 50%; flex: none; display: inline-block;
  background: radial-gradient(circle at 35% 30%, #fff3c4 0%, #ffd166 45%, #e0a52e 75%, #c8871e 100%);
  border: 1px solid #8a5a10;
  box-shadow: 0 0 6px rgba(255, 209, 102, 0.8);
}
.icon-btn {
  pointer-events: auto; margin-top: 2px;
  width: 34px; height: 34px; border-radius: 12px; border: 1px solid rgba(157,180,216,.35);
  background: rgba(13, 20, 42, .85); color: var(--ink); font-size: 13px; font-weight: 900;
}
.icon-btn:active { transform: scale(.92); }

.combo-tag {
  align-self: center; margin-top: 8px;
  font-size: 20px; font-weight: 900; letter-spacing: .08em; color: var(--hot);
  text-shadow: 0 0 14px rgba(255,61,110,.85), 0 2px 0 #5c0f22;
  animation: comboPop .18s ease-out;
}
@keyframes comboPop { from { transform: scale(1.6); } to { transform: scale(1); } }

.hud-bottom {
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 2px;
}
.ability-btn {
  pointer-events: auto; position: relative; overflow: hidden;
  width: 74px; height: 74px; border-radius: 50%;
  border: 2px solid rgba(55,242,255,.5); background: rgba(10, 18, 38, .88);
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.ability-icon { width: 38px; height: 38px; position: relative; z-index: 2; }
.ability-label {
  position: relative; z-index: 2; font-size: 9px; font-weight: 900; letter-spacing: .12em;
  color: var(--cyan);
}
.ability-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: linear-gradient(180deg, rgba(55,242,255,.45), rgba(79,141,255,.65));
  transition: height .2s ease; z-index: 1;
}
.ability-btn.ready { animation: readyGlow 1s ease-in-out infinite; border-color: var(--gold); }
.ability-btn.ready .ability-label { color: var(--gold); }
@keyframes readyGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(255,209,102,.5); }
  50% { box-shadow: 0 0 26px rgba(255,209,102,1); }
}
.ability-btn.cooling { opacity: .8; }
.ability-btn .radar-fill { background: linear-gradient(180deg, rgba(55,242,255,.5), rgba(55,242,255,.8)); }

/* ---------------- Screens ---------------- */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px; text-align: center;
  background: radial-gradient(120% 90% at 50% 10%, rgba(10, 16, 36, .55), rgba(4, 7, 16, .94));
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  overflow-y: auto;
}
.screen.show { display: flex; animation: screenIn .28s ease-out; }
@keyframes screenIn { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: none; } }

/* menu keeps the animated city visible */
#screen-menu {
  background: radial-gradient(120% 90% at 50% 10%, rgba(10, 16, 36, 0.5), rgba(4, 7, 16, 0.82));
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.btn-ico { width: 16px; height: 16px; vertical-align: -2px; margin-right: 6px; }

.menu-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; max-width: 430px; }
.logo-sub { font-size: 11px; font-weight: 800; letter-spacing: .34em; color: var(--cyan); text-shadow: 0 0 10px rgba(55,242,255,.8); }
.logo {
  margin: 2px 0 6px; font-size: clamp(38px, 13vw, 62px); line-height: .95; font-weight: 900;
  letter-spacing: .02em; font-style: italic;
}
.logo .l1 {
  background: linear-gradient(180deg, #d9ffb0, var(--lime) 55%, #2ea63c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #123312) drop-shadow(0 0 22px rgba(124,255,78,.55));
}
.logo .l2 {
  background: linear-gradient(180deg, #9ffbff, var(--cyan) 55%, #1266c8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #0a2a3a) drop-shadow(0 0 22px rgba(55,242,255,.6));
}
.idle-stats { font-size: 12px; font-weight: 700; letter-spacing: .12em; color: var(--ink-dim); }

.btn {
  pointer-events: auto; cursor: pointer; border: none; border-radius: var(--radius);
  font-weight: 900; letter-spacing: .06em; color: var(--ink);
  transition: transform .08s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:active { transform: scale(.95); }
.btn-primary {
  background: linear-gradient(180deg, #5fe94c, #1fb33b 60%, #128a2c);
  box-shadow: 0 8px 0 #0c5f1e, 0 14px 26px rgba(31, 179, 59, .45), inset 0 1px 0 rgba(255,255,255,.5);
  color: #06230c;
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 4px 0 #0c5f1e, 0 8px 16px rgba(31,179,59,.4); }
.btn-xl { font-size: 22px; padding: 15px 54px; }
.btn-ghost {
  background: rgba(18, 27, 54, .9); border: 1px solid rgba(120, 160, 255, .4);
  box-shadow: 0 4px 0 rgba(30, 44, 88, .9); padding: 11px 18px; font-size: 14px;
}
.btn-mini { background: transparent; border: 1px solid rgba(157,180,216,.35); color: var(--ink-dim); padding: 7px 12px; font-size: 11px; }
.btn-mini[aria-pressed="false"] { opacity: .55; }
.menu-row { display: flex; gap: 10px; justify-content: center; width: 100%; }
.menu-row.small { gap: 10px; }
.credit { font-size: 10px; color: rgba(157,180,216,.5); letter-spacing: .1em; }
.danger-text { color: var(--hot); }

.panel {
  pointer-events: auto;
  width: min(430px, 100%); max-height: 92vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 22px;
  padding: 22px 20px 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.07);
  display: flex; flex-direction: column; gap: 14px; align-items: center;
}
.panel-title { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: .1em; color: var(--ink); }
.panel-title.danger { color: var(--hot); text-shadow: 0 0 16px rgba(255,61,110,.7); }

.help-list { text-align: left; margin: 0; padding-left: 22px; font-size: 14px; line-height: 1.55; color: var(--ink-dim); }
.help-list b { color: var(--ink); }
.help-list li { margin-bottom: 8px; }

/* ---------------- Shop ---------------- */
.shop-panel { width: min(460px, 100%); }
.balance { font-size: 16px; color: var(--gold); display: inline-flex; align-items: center; gap: 6px; }
.upgrade-list { width: 100%; display: flex; flex-direction: column; gap: 10px; margin: 4px 0 6px; }
.upgrade {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: rgba(20, 30, 58, .75); border: 1px solid rgba(90, 130, 220, .25);
  border-radius: 14px; padding: 10px 12px;
}
.upgrade .u-icon { font-size: 24px; width: 34px; text-align: center; flex: none; }
.upgrade .u-icon svg { width: 24px; height: 24px; display: inline-block; vertical-align: middle; }
.upgrade .u-icon { display: flex; align-items: center; justify-content: center; }
.upgrade .u-body { flex: 1; min-width: 0; }
.upgrade .u-name { font-weight: 800; font-size: 14px; }
.upgrade .u-desc { font-size: 11px; color: var(--ink-dim); line-height: 1.3; margin-top: 1px; }
.upgrade .u-pips { display: flex; gap: 4px; margin-top: 6px; }
.u-pip { width: 16px; height: 6px; border-radius: 3px; background: rgba(90,110,150,.35); }
.u-pip.on { background: linear-gradient(90deg, var(--lime), var(--cyan)); box-shadow: 0 0 6px rgba(124,255,78,.7); }
.buy-btn {
  pointer-events: auto; flex: none; border: none; border-radius: 12px; padding: 10px 12px;
  font-weight: 900; font-size: 12px; color: #06230c;
  background: linear-gradient(180deg, var(--gold), #e8a63b 60%, #c8871e);
  box-shadow: 0 3px 0 #7c5210; min-width: 78px;
}
.buy-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #7c5210; }
.buy-btn.maxed { background: rgba(90,110,150,.35); color: var(--ink-dim); box-shadow: none; }
.buy-btn.cant { filter: grayscale(.8) brightness(.7); }

/* ---------------- Wave clear / game over ---------------- */
.wc-list { font-size: 14px; color: var(--ink-dim); line-height: 1.7; }
.wc-list b { color: var(--gold); }
.wc-stars { font-size: 26px; letter-spacing: 4px; display: flex; gap: 8px; justify-content: center; }
.wc-stars .heart { width: 26px; height: 26px; }
.go-stats { display: flex; gap: 26px; font-size: 12px; color: var(--ink-dim); letter-spacing: .06em; }
.go-stats b { display: block; font-size: 26px; color: var(--ink); margin-top: 3px; }
.go-sub { font-size: 13px; color: var(--gold); font-weight: 700; }

@media (max-height: 640px) {
  .help-list { font-size: 12.5px; }
  .btn-xl { font-size: 18px; padding: 12px 42px; }
  .logo { font-size: clamp(30px, 10vw, 44px); }
}

/* ---------------- DOM confetti (wave clear) ---------------- */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confetti-bit {
  position: absolute; top: -14px; width: 9px; height: 13px; border-radius: 2px; opacity: 0.95;
  animation: confFall linear forwards; will-change: transform, top;
}
@keyframes confFall {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(112vh) rotate(760deg); }
}
