:root {
  --void: #0A0B12;
  --stone: #16202E;
  --teal: #2BE6C8;
  --amber: #FFC63A;
  --red: #FF4D3D;
  --blue: #2F7BFF;
  --green: #6FE04B;
  --cream: #F0E6D2;
  --fire: #FF9636;
  --display: 'Silkscreen', monospace;
  --num: 'Jersey 10', 'Silkscreen', monospace;
  --text: 'Chivo', system-ui, -apple-system, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--cream);
  font-family: var(--text);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body { position: fixed; inset: 0; }

img { image-rendering: pixelated; image-rendering: crisp-edges; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }

#app { position: fixed; inset: 0; overflow: hidden; background: var(--void); }

#game { position: fixed; inset: 0; z-index: 0; }
#game canvas { display: block; width: 100% !important; height: 100% !important; image-rendering: pixelated; }

/* ---------- Loading screen --------------------------------------- */

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 40px);
  background: var(--void);
}
.loading-screen.done { display: none; }
.loading-card { width: min(92vw, 520px); text-align: center; }
.loading-logo {
  width: min(320px, 62vw);
  max-height: 34vh;
  object-fit: contain;
  display: block;
  margin: 0 auto 14px;
}
.loading-eyebrow {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(9px, 1.2vw, 13px);
  letter-spacing: .18em;
  color: var(--teal);
  margin-bottom: 10px;
}
.loading-bar {
  height: clamp(18px, 2.8vh, 26px);
  border: 3px solid var(--cream);
  background: var(--void);
  padding: 3px;
  box-shadow: 0 5px 0 rgba(0,0,0,.9);
}
.loading-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  transition: width .14s linear;
}
.loading-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  font-family: var(--display);
  font-size: clamp(9px, 1vw, 12px);
  letter-spacing: .12em;
  color: var(--cream);
}
#load-pct {
  font-family: var(--num);
  font-size: clamp(20px, 3.2vw, 30px);
  letter-spacing: .02em;
  color: var(--cream);
}

/* ---------- HUD -------------------------------------------------- */

.hud-plate {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: clamp(78px, 16vh, 128px);
  background: rgba(10, 11, 18, .8);
  border-bottom: 2px solid rgba(22, 32, 46, .9);
  z-index: 19;
  pointer-events: none;
}
body.overlay-open .hud-plate { display: none; }

.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: start;
  gap: clamp(4px, 1vw, 16px);
  padding: calc(6px + env(safe-area-inset-top)) clamp(8px, 1.4vw, 22px) 0;
  pointer-events: none;
}
.hud > div { min-width: 0; }
.hud-label {
  text-shadow: 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 -1px 0 #000;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(9px, 1.15vw, 17px);
  letter-spacing: .18em;
  color: var(--cream);
  opacity: .92;
  line-height: 1;
  white-space: nowrap;
}
.hud-left { text-align: left; }
 .hud-high {
  -webkit-text-stroke: 1.6px #0A0B12;
  paint-order: stroke fill;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--num);
  font-size: clamp(23px, 3.4vw, 56px);
  line-height: .92;
  color: var(--cream);
  margin-top: 2px;
}
.hud-coin { width: clamp(14px, 1.6vw, 24px); height: auto; }
.hud-center { text-align: center; }
.hud-score {
  font-family: var(--num);
  font-size: clamp(32px, min(7.2vw, 11.8vh), 116px);
  line-height: .82;
  color: var(--cream);
  -webkit-text-stroke: 3px #0A0B12;
  paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(0,0,0,.85);
  transition: transform .08s steps(2);
}
.hud-score.pop { transform: scale(1.08); }
.lives { display: flex; justify-content: center; gap: clamp(3px, .4vw, 8px); margin-top: 1px; }
.lives img { width: clamp(15px, 1.6vw, 26px); height: auto; }
.lives img.spent { opacity: .28; filter: grayscale(1); }

.hud-right { display: flex; flex-direction: column-reverse; align-items: flex-end; text-align: right; gap: 2px; }
.wave-block { display: flex; flex-direction: column; align-items: flex-end; }
.corner { display: flex; align-items: flex-start; gap: 5px; margin-bottom: 3px; pointer-events: auto; }
.pix-icon {
  width: clamp(32px, 3vw, 46px);
  height: clamp(32px, 3vw, 46px);
  border: 2px solid var(--cream);
  background: var(--void);
  color: var(--cream);
  font-family: var(--display);
  font-size: clamp(5px, .42vw, 8px);
  line-height: 1.05;
  letter-spacing: .04em;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 #000;
}
.pix-icon:active { transform: translateY(2px); box-shadow: none; }
.pause-icon { padding: 0; border: 0; box-shadow: none; width: clamp(42px, 4.4vw, 56px); height: clamp(42px, 4.4vw, 56px); }
.pause-icon img { width: 100%; height: 100%; object-fit: contain; }
.pause-icon:active { transform: translateY(2px); }

.wave-row { display: flex; align-items: baseline; gap: 6px; }
.hud-wave { font-family: var(--num); font-size: clamp(24px, 3.1vw, 52px); line-height: .9; -webkit-text-stroke: 1.6px #0A0B12; paint-order: stroke fill; }
.timerbar {
  width: clamp(86px, 11vw, 180px);
  height: clamp(8px, .9vw, 13px);
  border: 2px solid var(--cream);
  background: var(--void);
  padding: 1px;
  margin-top: 1px;
}
.timerfill { height: 100%; width: 100%; background: var(--cream); transition: width .12s linear, background-color .2s; }
.timerfill.low { background: var(--red); }
.hud-time { font-family: var(--num); font-size: clamp(16px, 1.8vw, 30px); line-height: 1; letter-spacing: .04em; -webkit-text-stroke: 1px #0A0B12; paint-order: stroke fill; }

.boss-alert {
  display: none;
  position: relative;
  width: clamp(150px, 18vw, 280px);
  margin-top: 6px;
}
.boss-alert.show { display: block; animation: slam .28s steps(3) both; }
.boss-alert img { width: 100%; height: auto; display: block; }
.boss-alert span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(9px, 1.1vw, 16px);
  letter-spacing: .12em;
  color: var(--cream);
  text-shadow: 0 2px 0 #000;
  padding-bottom: 3px;
}
@keyframes slam {
  0% { transform: translateY(-14px) scale(1.1); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.controls-hint {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(5px + env(safe-area-inset-bottom));
  z-index: 18;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(8px, .95vw, 14px);
  letter-spacing: .13em;
  color: var(--cream);
  opacity: .7;
  pointer-events: none;
  white-space: nowrap;
}
.controls-hint .hint-touch { display: none; }
body.is-touch .controls-hint { display: none; }
body.is-touch .controls-hint .hint-touch { display: inline; }
body.is-touch .controls-hint .hint-keyboard { display: none; }

/* ---------- Touch controls --------------------------------------- */

.touch { display: none; }
body.is-touch .touch { display: block; }
body.overlay-open .touch { display: none !important; }

.stick-zone {
  position: fixed;
  left: 0; bottom: 0;
  width: 46%;
  height: 52%;
  z-index: 26;
  touch-action: none;
}
.stick-base {
  position: absolute;
  left: clamp(10px, 2.5vw, 32px);
  bottom: calc(clamp(12px, 3vh, 40px) + env(safe-area-inset-bottom));
  width: clamp(104px, 17vh, 168px);
  aspect-ratio: 1;
  pointer-events: none;
}
.stick-ring { width: 100%; height: 100%; opacity: .62; }
.stick-knob {
  position: absolute;
  width: 40%;
  height: 40%;
  left: 30%;
  top: 30%;
  transform: translate(0, 0);
  will-change: transform;
}
body.stick-active .stick-ring { opacity: .95; }

.touch-btn {
  position: fixed;
  z-index: 27;
  border-radius: 50%;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,.9));
}
.touch-btn img { width: 100%; height: 100%; object-fit: contain; display: block; }
.touch-btn:active, .touch-btn.pressed { transform: translateY(3px) scale(.97); filter: brightness(.82); }
.touch-word {
  position: absolute;
  left: 0; right: 0;
  bottom: 7%;
  text-align: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(7px, .8vw, 10px);
  letter-spacing: .08em;
  color: var(--cream);
  text-shadow: 0 2px 0 #000;
  pointer-events: none;
}
.touch-btn.attack {
  --btn: clamp(92px, 15vh, 132px);
  right: clamp(12px, 2vw, 28px);
  bottom: calc(clamp(12px, 2.6vh, 30px) + env(safe-area-inset-bottom));
  width: var(--btn);
  height: var(--btn);
}
.touch-btn.skill {
  --btn: clamp(62px, 10.4vh, 92px);
  right: calc(clamp(12px, 2vw, 28px) + 4px);
  bottom: calc(clamp(12px, 2.6vh, 30px) + clamp(92px, 15vh, 132px) + 14px + env(safe-area-inset-bottom));
  width: var(--btn);
  height: var(--btn);
}

/* ---------- Overlays --------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2vw, 26px);
  background: rgba(10, 11, 18, .86);
  overflow: hidden;
}
.overlay.show { display: flex; }

.overlay-card {
  width: min(94vw, 560px);
  max-height: 96dvh;
  overflow-y: auto;
  border: 3px solid var(--cream);
  background: var(--void);
  box-shadow: 0 8px 0 rgba(0,0,0,.9);
  padding: clamp(14px, 3vh, 30px) clamp(14px, 3vw, 32px);
  text-align: center;
  scrollbar-width: none;
}
.overlay-card::-webkit-scrollbar { display: none; }

#title { background: rgba(10, 11, 18, .5); }
.title-card { border-width: 3px; }
.title-art { width: min(480px, 82vw); height: auto; display: block; margin: 0 auto 4px; }
.title-tag {
  font-family: var(--display);
  font-size: clamp(9px, 1.1vw, 14px);
  letter-spacing: .1em;
  color: var(--teal);
  margin-bottom: 12px;
}
.title-high {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--display);
  font-size: clamp(9px, .95vw, 12px);
  letter-spacing: .14em;
  margin-bottom: 14px;
}
.title-high img { width: 20px; height: auto; }
.title-high b { font-family: var(--num); font-size: clamp(24px, 2.6vw, 38px); font-weight: 400; letter-spacing: .02em; }
.title-how { font-size: clamp(12px, 1.05vw, 15px); line-height: 1.35; opacity: .8; margin: 12px auto 8px; max-width: 34ch; }
.title-keys { font-family: var(--display); font-size: clamp(8px, .85vw, 11px); letter-spacing: .1em; opacity: .72; line-height: 1.7; margin-top: 4px; max-width: none; white-space: nowrap; margin-left: auto; margin-right: auto; }
.title-card .link-btn { display: block; margin: 8px auto 0; }
body.is-touch .title-keys.hint-keyboard { display: none; }
body:not(.is-touch) .title-keys.hint-touch { display: none; }
body.is-touch .title-keys.hint-touch { display: block; }

.card-eyebrow {
  font-family: var(--display);
  font-size: clamp(9px, 1vw, 13px);
  letter-spacing: .18em;
  color: var(--teal);
  margin-bottom: 4px;
}
.card-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(24px, 5vw, 44px);
  letter-spacing: .1em;
  margin-bottom: 16px;
}

.big-btn {
  display: block;
  width: 100%;
  min-height: clamp(48px, 8vh, 68px);
  border: 3px solid var(--cream);
  box-shadow: 0 7px 0 rgba(0,0,0,.9);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(13px, 2vw, 22px);
  letter-spacing: .14em;
  padding: 8px 12px;
  margin: 10px 0;
  transition: transform .06s steps(1), box-shadow .06s steps(1);
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 3px 0 rgba(0,0,0,.9); }
.big-btn.green { background: var(--green); color: var(--void); border-color: var(--cream); }
.big-btn.red { background: var(--red); color: var(--cream); }
.big-btn.blue { background: var(--blue); color: var(--cream); }
.big-btn.cream { background: var(--cream); color: var(--void); }
.big-btn.ghost { background: var(--void); color: var(--cream); }
.link-btn {
  font-family: var(--display);
  font-size: clamp(9px, .95vw, 12px);
  letter-spacing: .12em;
  color: var(--cream);
  opacity: .7;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px;
  margin-top: 4px;
}
.link-btn:active { opacity: 1; }

.pause-card { width: min(92vw, 400px); }

/* ---------- Game over ------------------------------------------- */

.over-card { width: min(94vw, 600px); }
.over-logo { width: min(300px, 62vw); height: auto; display: block; margin: 0 auto 2px; }
.score-rows { margin: 10px 0 6px; border-top: 2px solid rgba(240,230,210,.16); border-bottom: 2px solid rgba(240,230,210,.16); padding: 8px 0; }
.score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  text-align: left;
  position: relative;
}
.score-label { font-family: var(--display); font-size: clamp(9px, 1vw, 13px); letter-spacing: .14em; opacity: .9; }
.score-num { font-family: var(--num); font-size: clamp(32px, 4.4vw, 58px); line-height: .9; text-align: right; }
.score-row.newbest .score-num { color: var(--amber); }
.score-row.newbest .over-coin { display: inline-block; position: absolute; right: -6px; top: 50%; width: clamp(18px, 2vw, 26px); animation: coinhop .6s steps(4) infinite; }
.over-coin { display: none; }
@keyframes coinhop { 0%,100% { transform: translateY(-50%); } 50% { transform: translateY(-90%); } }
.best-row { grid-template-columns: 1fr auto; }
.best-name { font-family: var(--display); font-size: clamp(10px, 1.1vw, 14px); letter-spacing: .1em; color: var(--amber); text-align: right; grid-column: 2; }
.best-bar { grid-column: 1 / -1; display: flex; gap: 3px; height: 12px; margin-top: 5px; border: 2px solid var(--cream); padding: 1px; }
.best-bar i { display: block; height: 100%; }
.best-bar .frost, .bp-bar .frost { background: var(--blue); }
.best-bar .fire, .bp-bar .fire { background: var(--fire); }
.best-bar .stun, .bp-bar .stun { background: var(--amber); }
.best-bar .dmg, .bp-bar .dmg { background: var(--red); }

/* ---------- Budget panel ---------------------------------------- */

.budget-overlay { background: var(--void); padding: clamp(4px, 1.5vw, 20px); }
.bp-card {
  width: min(96vw, 1040px);
  max-height: 98dvh;
  overflow-y: auto;
  border: 3px solid var(--cream);
  background: var(--void);
  box-shadow: 0 8px 0 rgba(0,0,0,.95);
  padding: clamp(8px, 2vh, 22px) clamp(10px, 2.4vw, 28px);
  scrollbar-width: none;
}
.bp-card::-webkit-scrollbar { display: none; }
.bp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-bottom: 8px; border-bottom: 2px solid rgba(240,230,210,.16); }
.bp-headline { display: flex; align-items: center; gap: clamp(10px, 2vw, 26px); flex-wrap: wrap; }
.bp-eyebrow { font-family: var(--display); font-size: clamp(9px, 1.1vw, 13px); letter-spacing: .18em; color: var(--teal); }
.bp-total { display: flex; align-items: baseline; gap: 6px; }
.bp-total-label { font-family: var(--display); font-size: clamp(10px, 1.2vw, 15px); letter-spacing: .12em; }
.bp-total-num { font-family: var(--num); font-size: clamp(38px, 5.4vw, 64px); line-height: .8; color: var(--cream); }
.bp-pctsign { font-family: var(--display); font-size: .45em; letter-spacing: .06em; margin-left: 2px; }
.bp-total.invalid .bp-total-num, .bp-total.invalid .bp-total-label { color: var(--red); }
.bp-total.invalid { animation: jitter .5s steps(2) infinite; }
@keyframes jitter { 0%,100% { transform: translateX(0); } 50% { transform: translateX(3px); } }
.bp-total.landed .bp-total-num { animation: flashnum .38s steps(2) 1; }
@keyframes flashnum { 0% { transform: scale(1.18); color: var(--amber); } 100% { transform: scale(1); } }

.bp-bar {
  display: flex;
  gap: 3px;
  flex: 1 1 280px;
  min-width: 200px;
  height: clamp(24px, 3.4vh, 34px);
  border: 3px solid var(--cream);
  padding: 3px;
  background: var(--void);
}
.bp-bar.invalid { border-color: var(--red); }
.bp-bar .seg { height: 100%; transition: flex-basis .06s steps(2); }
.bp-bar .seg.frost { background: var(--blue); }
.bp-bar .seg.fire { background: var(--fire); }
.bp-bar .seg.stun { background: var(--amber); }
.bp-bar .seg.dmg { background: var(--red); }

.bp-body { display: grid; grid-template-columns: 1fr; gap: 8px; padding-top: 8px; }

.bp-presets { display: flex; gap: 8px; }
.preset {
  flex: 1 1 0;
  min-width: 0;
  min-height: 50px;
  border: 2px solid var(--cream);
  background: #101925;
  color: var(--cream);
  padding: 6px 5px;
  box-shadow: 0 4px 0 rgba(0,0,0,.9);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.preset-name { font-family: var(--display); font-weight: 700; font-size: clamp(8px, 1vw, 12px); letter-spacing: .08em; }
.preset-desc { font-family: var(--text); font-size: clamp(9px, .9vw, 11px); line-height: 1.2; opacity: .72; }
.preset.selected { background: var(--cream); color: var(--void); transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.9); }
.preset.selected .preset-desc { opacity: .8; }
.preset:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.9); }

.bp-sliders { display: flex; flex-direction: column; gap: 2px; }
.slider-row {
  display: grid;
  grid-template-columns: clamp(54px, 8vw, 96px) minmax(0, 1fr) clamp(48px, 6vw, 72px);
  align-items: center;
  gap: clamp(6px, 1.4vw, 16px);
  min-height: 52px;
}
.slider-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(10px, 1.25vw, 15px);
  letter-spacing: .1em;
  text-align: left;
}
.slider-name.frost { color: var(--blue); }
.slider-name.fire { color: var(--fire); }
.slider-name.stun { color: var(--amber); }
.slider-name.dmg { color: var(--red); }
.slider-track {
  position: relative;
  height: 52px;
  display: flex;
  align-items: center;
  cursor: grab;
  touch-action: none;
}
.slider-track:active { cursor: grabbing; }
.slider-shell {
  position: relative;
  width: 100%;
  height: clamp(28px, 4.2vh, 36px);
  border: 2px solid var(--cream);
  background: #0d1520;
  overflow: hidden;
}
.slider-fill { position: absolute; inset: 0 auto 0 0; width: 0%; background: var(--blue); }
.slider-ticks {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(240,230,210,.22) 0 1px, transparent 1px 10%);
  pointer-events: none;
}
.slider-handle {
  position: absolute;
  top: 50%;
  left: 0%;
  width: clamp(44px, 5.6vw, 62px);
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}
.slider-pct {
  font-family: var(--num);
  font-size: clamp(26px, 3.2vw, 42px);
  line-height: .9;
  text-align: right;
  color: var(--cream);
}
.slider-pct small { font-family: var(--display); font-size: .4em; letter-spacing: .04em; margin-left: 1px; }

.bp-foot {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--void);
  padding-top: 3px;
}
.bp-hint { font-family: var(--text); font-size: clamp(10px, 1vw, 13px); line-height: 1.3; opacity: .7; text-align: center; }
.start-btn {
  position: relative;
  display: block;
  width: 100%;
  min-height: clamp(50px, 8vh, 72px);
  margin-top: 2px;
  filter: drop-shadow(0 5px 0 rgba(0,0,0,.9));
}
.start-btn img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.start-btn span {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(50px, 8vh, 72px);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(15px, 2vw, 24px);
  letter-spacing: .14em;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(0,0,0,.6);
  padding-bottom: 4px;
}
.start-btn:active { transform: translateY(3px); filter: drop-shadow(0 2px 0 rgba(0,0,0,.9)); }

/* short landscape: two columns */
@media (orientation: landscape) and (max-height: 560px) {
  .title-card { padding: 10px 18px; }
  .title-art { width: min(360px, 52vw); }
  .title-tag { font-size: 10px; margin-bottom: 6px; }
  .title-high { margin-bottom: 6px; }
  .title-high b { font-size: 26px; }
  .title-card .big-btn { min-height: 46px; font-size: 16px; margin: 8px 0; }
  .title-how { display: none; }
  .title-keys { font-size: 8px; margin-top: 2px; }
  .title-card .link-btn { margin-top: 2px; padding: 4px; }
  .over-card { width: min(94vw, 660px); padding: 8px 18px; }
  .over-logo { width: 170px; }
  .over-card .card-eyebrow { font-size: 9px; margin-bottom: 2px; }
  .score-rows { margin: 4px 0; padding: 2px 0; }
  .score-row { padding: 1px 0; }
  .score-num { font-size: 30px; }
  .score-label { font-size: 8px; }
  .best-bar { height: 9px; margin-top: 2px; }
  .over-card .big-btn { min-height: 44px; font-size: 14px; margin: 6px 0; }
  .over-card .link-btn { font-size: 8px; padding: 4px; }
  .hud-plate { height: clamp(58px, 18vh, 78px); }
  .hud-right { flex-direction: row; align-items: flex-start; gap: 10px; }
  .corner { margin-bottom: 0; }
  .hud-score { font-size: clamp(30px, 9.5vh, 54px); }
  .hud-label { font-size: 9px; }
  .hud-high { font-size: clamp(20px, 4.4vh, 30px); }
  .hud-wave { font-size: clamp(20px, 5vh, 28px); }
  .lives img { width: 16px; }
  .timerbar { width: 86px; height: 8px; }
  .hud-time { font-size: 17px; }
  .pix-icon { width: 36px; height: 36px; font-size: 5px; }
  .pause-icon { width: 44px; height: 44px; }
  .hub-note { display: none; }
  .bp-card { padding: 8px 12px; }
  .bp-head { flex-wrap: nowrap; gap: 14px; padding-bottom: 6px; }
  .bp-total-num { font-size: clamp(34px, 6.5vh, 48px); }
  .bp-eyebrow { font-size: 10px; }
  .bp-body {
    grid-template-columns: minmax(170px, .8fr) minmax(240px, 1.2fr);
    grid-template-areas: "presets sliders" "foot sliders";
    gap: 6px 14px;
    padding-top: 6px;
  }
  .bp-presets { grid-area: presets; flex-direction: column; gap: 5px; }
  .bp-sliders { grid-area: sliders; }
  .bp-foot { grid-area: foot; }
  .preset { min-height: 40px; padding: 3px 5px; }
  .preset-name { font-size: 9px; }
  .preset-desc { font-size: 9px; }
  .slider-row { min-height: 46px; grid-template-columns: 52px minmax(0,1fr) 50px; gap: 8px; }
  .slider-track { height: 46px; }
  .slider-shell { height: 28px; }
  .slider-pct { font-size: 27px; }
  .bp-hint { font-size: 9px; text-align: left; }
  .start-btn, .start-btn span { min-height: 44px; }
  .start-btn span { font-size: 12px; }
  .bp-total-label { font-size: 10px; }
  .bp-bar { height: 26px; flex-basis: 200px; }
}

@media (orientation: portrait) {
  .hud { padding-top: calc(5px + env(safe-area-inset-top)); }
  
  .hud-high { font-size: 21px; }
  .hud-score { font-size: clamp(42px, 12.5vw, 60px); }
  .hud-wave { font-size: 26px; }
  .lives img { width: 15px; }
  .timerbar { width: 76px; }
  .hud-time { font-size: 15px; }
  .pix-icon { width: 31px; height: 31px; font-size: 5px; }
  .pause-icon { width: 44px; height: 44px; }
  .boss-alert { width: 150px; }
  .bp-total-num { font-size: 42px; }
  .bp-total-label { font-size: 10px; }
  .bp-bar { min-width: 150px; height: 24px; flex-basis: 150px; }
  .bp-eyebrow { font-size: 9px; }
  .preset { min-height: 54px; }
  .preset-name { font-size: 8px; }
  .preset-desc { font-size: 9px; }
  .slider-row { min-height: 56px; }
  .slider-track { height: 56px; }
  .slider-shell { height: 34px; }
  .slider-pct { font-size: 30px; }
  .over-card { padding-top: 14px; }
  .score-num { font-size: clamp(30px, 9vw, 44px); }
  .title-art { width: min(360px, 78vw); }
  .title-how { font-size: 12px; }
}

@media (max-width: 460px) {
  .bp-presets { gap: 5px; }
  .preset { min-height: 62px; }
  .preset-desc { font-size: 8px; line-height: 1.15; }
}

@media (orientation: portrait) and (max-height: 620px) {
  .bp-card { padding: 6px 10px; }
  .bp-head { gap: 4px 10px; padding-bottom: 4px; }
  .bp-eyebrow { font-size: 8px; }
  .bp-total { gap: 4px; }
  .bp-total-label { font-size: 9px; }
  .bp-total-num { font-size: 34px; }
  .bp-bar { height: 20px; flex-basis: 120px; min-width: 120px; }
  .bp-body { gap: 4px; padding-top: 4px; }
  .bp-presets { gap: 5px; }
  .preset { min-height: 44px; padding: 2px 4px; }
  .preset-name { font-size: 8px; }
  .preset-desc { font-size: 8px; line-height: 1.12; }
  .bp-sliders { gap: 0; }
  .slider-row { min-height: 46px; grid-template-columns: 46px minmax(0,1fr) 46px; gap: 6px; }
  .slider-track { height: 46px; }
  .slider-shell { height: 26px; }
  .slider-name { font-size: 9px; }
  .slider-pct { font-size: 24px; }
  .slider-handle { width: 44px; }
  .bp-hint { display: none; }
  .start-btn, .start-btn span { min-height: 44px; }
  .start-btn span { font-size: 13px; }
}


@media (prefers-reduced-motion: reduce) {
  .boss-alert.show, .bp-total.invalid, .score-row.newbest .over-coin { animation: none; }
}

body.playing #game canvas { cursor: crosshair; }
body.is-touch #game canvas { cursor: default; }
