:root {
  --paper: #f3ede3;
  --paper-2: #fbf8f2;
  --ink: #16122b;
  --ink-soft: #4d4668;
  --indigo: #1d1a5e;
  --violet: #7b3cf0;
  --purple: #5b2aa6;
  --magenta: #e23fc8;
  --pink: #ff4f9a;
  --green: #22e37d;
  --green-deep: #0b8f47;
  --red: #ff3d5c;
  --red-deep: #b8163a;
  --display: "Dela Gothic One", "Hiragino Sans", "Arial Black", sans-serif;
  --hand: "Yusei Magic", "Hiragino Maru Gothic ProN", "Comic Sans MS", cursive;
  --ui: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  --crt: "VT323", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 500 14px/1.4 var(--ui);
  -webkit-tap-highlight-color: transparent;
}
/* paper grain over everything */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: .55;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42  0 0 0 0 .36  0 0 0 0 .3  0 0 0 .2 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- page: one manga page, never scrolls ---------- */
.page {
  height: 100vh; height: 100svh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.page.quake { animation: quake .7s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes quake {
  10%, 90% { transform: translate(-2px, 1px); }
  20%, 80% { transform: translate(5px, -3px); }
  30%, 50%, 70% { transform: translate(-9px, 4px) rotate(-.4deg); }
  40%, 60% { transform: translate(9px, -4px) rotate(.4deg); }
}

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand img { width: 46px; height: 46px; display: block; filter: drop-shadow(2px 3px 0 var(--ink)); }
.brand-txt { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font: 400 27px/1 var(--display); letter-spacing: .02em; }
.brand-jp { margin-top: 4px; font: 400 11px/1 var(--hand); letter-spacing: .3em; color: var(--magenta); }
.tagline {
  flex: 1; margin: 0; min-width: 0; text-align: center;
  font: 400 clamp(15px, 1.5vw, 21px)/1.2 var(--hand);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tagline b { font-weight: 400; background: linear-gradient(transparent 58%, rgba(255, 79, 154, .4) 58%, rgba(255, 79, 154, .4) 90%, transparent 90%); padding: 0 3px; }
.links { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; }
.ca {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 5px 5px 12px;
  border: 2.5px solid var(--ink); border-radius: 999px;
  background: var(--paper-2);
}
.ca-label { font: 400 11px/1 var(--display); letter-spacing: .12em; color: var(--magenta); }
.ca code { font: 400 17px/1 var(--crt); max-width: 20ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ca-copy, .pill {
  font: 700 12px/1 var(--ui); letter-spacing: .08em; text-transform: uppercase; text-decoration: none;
  border: 2.5px solid var(--ink); border-radius: 999px; background: var(--paper-2);
  padding: 7px 12px; cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .15s;
}
.ca-copy { background: var(--ink); color: var(--paper); padding: 6px 11px; border-width: 0; }
.pill { box-shadow: 2px 3px 0 var(--ink); }
.pill:hover { transform: translate(-1px, -1px); box-shadow: 3px 4px 0 var(--ink); background: #ffe3f3; }
.pill:active { transform: translate(2px, 3px); box-shadow: 0 0 0 var(--ink); }
.sound { padding: 5px 8px; line-height: 0; }
.sound svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sound .spk { fill: var(--ink); }
.sound .mute { display: none; }
.sound[aria-pressed="false"] .wave { display: none; }
.sound[aria-pressed="false"] .mute { display: inline; }

/* ---------- stage ---------- */
.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(270px, 27vw, 400px);
  gap: 14px;
  min-height: 0;
}
.panel {
  position: relative;
  overflow: hidden;
  background: var(--paper-2);
  border: 3.5px solid var(--ink);
  border-radius: 5px 9px 6px 11px / 10px 5px 9px 6px;
}
.side { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 14px; min-height: 0; }

/* the room panel: six stacked SVGs sharing one viewBox */
.scene-panel { background: var(--paper); isolation: isolate; }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
#L-bg { will-change: transform; }
.o { stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.o2 { stroke: var(--ink); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.skin { fill: #f8d6c6; }
.hair { fill: #efeaf7; }
.suit { fill: #5b2aa6; }
.lapel { fill: #6c37bd; }
.shirt { fill: #f7f4fb; }
.tie { fill: #7a3df0; }
.skirt { fill: #3a1d78; }
.stock { fill: #2b2352; }
.shoe { fill: #8a33f5; }
.lens { fill: #0e0b24; }
.sheen { fill: none; stroke: #9d8df0; stroke-width: 2.4; stroke-linecap: round; opacity: .75; }
.mon-label { font: 400 15px var(--display); fill: #8d7fc2; letter-spacing: .06em; }
.note { font: 400 15px var(--hand); fill: var(--ink); }
.neon-txt { font: 400 128px "Neonderthaw", cursive; fill: #ffeafb; }
#neon { animation: neon 7s steps(1) infinite; }
@keyframes neon { 0%, 61%, 63.5%, 65%, 100% { opacity: 1; } 62%, 64% { opacity: .35; } }
.crt { font: 400 21px var(--crt); fill: #7dffb0; }
.crt.small { font-size: 16px; }
.crt.big { font-size: 26px; fill: #eafff2; }
#live { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.wash {
  position: absolute; inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity .6s;
  background: radial-gradient(ellipse var(--wr, 40%) var(--wr2, 50%) at var(--wx, 25%) var(--wy, 45%), rgba(40, 255, 130, .75), rgba(40, 255, 130, .22) 45%, rgba(40, 255, 130, 0) 75%);
}

/* SFX lettering */
.sfx {
  font: 400 54px var(--display);
  paint-order: stroke;
  stroke: var(--ink); stroke-width: 9px; stroke-linejoin: round;
  opacity: 0;
  transition: opacity .3s;
}
.sfx.small { font-size: 40px; }
.sfx.pink { fill: #ff5fa8; }
.sfx.white { fill: #fff; }
.sfx.green { fill: #6dffab; font-size: 46px; }
.sfx.on { opacity: 1; }
.sfx.pulse { animation: pulse .5s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { to { transform: scale(1.14); } }

/* manga narration box */
.narration {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  margin: 0; max-width: 60%;
  padding: 7px 12px 6px;
  background: var(--paper-2);
  border: 2.5px solid var(--ink);
  font: 400 clamp(12px, 1.1vw, 16px)/1.25 var(--hand);
  box-shadow: 3px 3px 0 var(--ink);
}

/* speech bubble: HTML text over a JS-drawn SVG shape, so it stays readable on phones */
.speech {
  position: absolute; left: 0; top: 0; z-index: 6;
  max-width: min(46%, 280px);
  padding: 16px 22px;
  font: 400 clamp(12.5px, 1.2vw, 17px)/1.25 var(--hand);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(.6);
  transform-origin: var(--ox, 0) var(--oy, 100%);
  transition: opacity .2s, transform .35s cubic-bezier(.3, 1.6, .5, 1);
}
.speech.on { opacity: 1; transform: none; }
.speech.shout { font-family: var(--display); letter-spacing: .02em; }
.speech-shape { position: absolute; left: 0; top: 0; overflow: visible; z-index: -1; }
.speech-shape path { fill: #fff; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }

/* ---------- close-up panel ---------- */
.close-panel { background: #1a1560; }
.cam { position: absolute; inset: 0; will-change: transform; }
.cam svg { width: 100%; height: 100%; display: block; }
.mult { mix-blend-mode: multiply; }
.bpm {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; align-items: center; gap: 10px;
  padding: 5px 10px;
  background: rgba(22, 18, 43, .82);
  border: 2px solid var(--ink);
  border-radius: 6px;
  color: #ffd1ea;
}
.bpm-num { font: 400 13px/1 var(--display); white-space: nowrap; }
.bpm-num b { font-weight: 400; font-size: 20px; color: #ff5fa8; display: inline-block; min-width: 3ch; text-align: right; }
.ecg { flex: 1; height: 26px; overflow: hidden; }
.ecg path { fill: none; stroke: #ff5fa8; stroke-width: 2.4; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

/* ---------- controls ---------- */
.ctrl-panel { padding: 12px 14px 10px; background: var(--paper-2); }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.meter-label { font: 400 17px/1 var(--display); }
.meter-label small { margin-left: 6px; font: 700 10px/1 var(--ui); letter-spacing: .2em; color: var(--ink-soft); }
.meter-state { font: 400 13px/1 var(--display); color: var(--magenta); letter-spacing: .04em; text-align: right; }
.hearts-row { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; margin: 8px 0 12px; }
.hearts-row svg { width: 100%; height: auto; display: block; overflow: visible; }
.hearts-row path { fill: var(--paper-2); stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; transition: fill .25s; }
.hearts-row .on path { fill: #ff4f9a; }
.hearts-row .hot path { fill: #ff1f5e; }
.hearts-row .on { animation: thump .6s ease-out; }
@keyframes thump { 30% { transform: scale(1.3); } }

.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 68px;
  padding: 8px 6px 6px;
  border: 3.5px solid var(--ink);
  border-radius: 14px 18px 12px 20px / 18px 12px 20px 14px;
  box-shadow: 4px 5px 0 var(--ink);
  cursor: pointer;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn span { font: 400 30px/1 var(--display); letter-spacing: .04em; paint-order: stroke; -webkit-text-stroke: 1.5px var(--ink); }
.btn small { font: 400 12px/1 var(--hand); letter-spacing: .3em; }
.btn.buy { background: var(--green); color: #fff; }
.btn.buy small { color: #073d20; }
.btn.sell { background: var(--red); color: #fff; }
.btn.sell small { color: #4d0616; }
.btn:hover { transform: translate(-1px, -2px) rotate(-1deg); box-shadow: 5px 7px 0 var(--ink); }
.btn.sell:hover { transform: translate(-1px, -2px) rotate(1deg); }
.btn:active, .btn.hit { transform: translate(3px, 4px); box-shadow: 1px 1px 0 var(--ink); filter: brightness(1.1); }
.btn:focus-visible { outline: 3px dashed var(--magenta); outline-offset: 4px; }
.btn[disabled] { cursor: wait; filter: grayscale(.6) brightness(.9); }
.btn.buy::after {
  content: ""; position: absolute; inset: -8px; border-radius: inherit; pointer-events: none;
  border: 3px solid var(--green); opacity: 0;
}
.btn.buy.hit::after { animation: ring .45s ease-out; }
@keyframes ring { from { opacity: .9; transform: scale(.9); } to { opacity: 0; transform: scale(1.25); } }
.stats { margin: 10px 0 0; font: 500 11.5px/1.3 var(--ui); color: var(--ink-soft); text-align: center; }
.stats b { font-family: var(--display); font-weight: 400; color: var(--ink); }

.foot { margin: 0; font: 500 10.5px/1.35 var(--ui); color: var(--ink-soft); text-align: center; }

/* ---------- the blast ---------- */
#blast { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }
.bigsfx {
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1vh;
  pointer-events: none;
  visibility: hidden;
}
.bigsfx span { display: block; paint-order: stroke; stroke-linejoin: round; opacity: 0; }
.bigsfx .boom {
  font: 400 clamp(64px, 13vw, 190px)/1 var(--display);
  color: #6dffab;
  -webkit-text-stroke: clamp(8px, 1.2vw, 16px) var(--ink);
  transform: rotate(-8deg);
}
.bigsfx .found {
  font: 400 clamp(22px, 3.6vw, 52px)/1 var(--display);
  color: #fff;
  background: #ff3fa6;
  padding: .25em .6em .2em;
  border: 4px solid var(--ink);
  box-shadow: 6px 7px 0 var(--ink);
  transform: rotate(3deg);
}
.bigsfx.on { visibility: visible; }
.bigsfx.warm { visibility: visible; }
.bigsfx.warm span { opacity: .004; }
.bigsfx.on .boom { animation: slam 2.6s cubic-bezier(.2, 1.4, .4, 1) both; }
.bigsfx.on .found { animation: slam2 3.2s cubic-bezier(.2, 1.4, .4, 1) .35s both; }
@keyframes slam {
  0% { opacity: 0; transform: rotate(-8deg) scale(3); }
  12% { opacity: 1; transform: rotate(-8deg) scale(1); }
  20% { transform: rotate(-6deg) scale(1.06); }
  80% { opacity: 1; transform: rotate(-8deg) scale(1.02); }
  100% { opacity: 0; transform: rotate(-8deg) scale(1.1); }
}
@keyframes slam2 {
  0% { opacity: 0; transform: rotate(3deg) translateY(30px) scale(.6); }
  14% { opacity: 1; transform: rotate(3deg) scale(1); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: rotate(3deg) translateY(-10px); }
}

/* ---------- the wand: cursor on mouse devices, and the one left stuck in the screen ---------- */
html.has-wand, html.has-wand * { cursor: none !important; }
html.has-wand.wand-stuck, html.has-wand.wand-stuck * { cursor: default !important; }
.wand-cursor {
  position: fixed; left: 0; top: 0; z-index: 95;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  will-change: transform;
}
html.has-wand .wand-cursor.seen { opacity: 1; }
html.wand-stuck .wand-cursor { opacity: 0 !important; }
html .wand-cursor.flying { opacity: 1 !important; transition: transform .32s cubic-bezier(.55, 0, .85, .35); }
.wand-cursor svg {
  position: absolute; left: -20px; top: -7px;
  width: 40px; height: auto; overflow: visible;
  transform-origin: 20px 7px; transform: rotate(-35deg);
  filter: drop-shadow(2px 3px 0 rgba(22, 18, 43, .3));
}
.wand-cursor .buzz-lines { opacity: 0; }
.wand-cursor.buzz .wand-body, .wand-cursor.auto .wand-body { animation: buzz .06s linear infinite; }
.wand-cursor.buzz .buzz-lines, .wand-cursor.auto .buzz-lines, .wand-cursor.hard .buzz-lines { opacity: 1; }
.wand-cursor.hard .wand-body { animation: buzz-hard .04s linear infinite; }
.wand-cursor.off { --wand-led: #6b6680; }
.wand-cursor.off .wand-body { animation: none; }
.wand-cursor.off .buzz-lines { opacity: 0; }
.wand-cursor.frozen { --wand-head: #bfe6ff; --wand-led: #7fd0ff; }
.wand-cursor.frozen .wand-body { animation: none; }
.wand-sfx {
  position: absolute; left: 12px; top: -30px;
  font: 400 13px/1 var(--display); color: #ff4fa6; white-space: nowrap;
  -webkit-text-stroke: 3px var(--ink); paint-order: stroke;
  transform: rotate(-8deg);
  opacity: 0;
}
.wand-cursor.hard .wand-sfx { opacity: 1; }
@keyframes buzz {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2.4px, 1.4px); }
  50% { transform: translate(2px, -1.8px); }
  75% { transform: translate(-1px, -2.2px); }
}
@keyframes buzz-hard {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 2.5px); }
  50% { transform: translate(3.5px, -3px); }
  75% { transform: translate(-2px, -3.5px); }
}
@keyframes buzz-s {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-1.6px, 1px); }
  50% { transform: translate(1.4px, -1.2px); }
  75% { transform: translate(-.8px, -1.5px); }
}
.stuck-buzz { animation: buzz-s .045s linear infinite; }

/* X stays locked until the first blast */
.x-pill.unlocked { background: #ff5fa8; color: #fff; position: relative; }
.x-pill.unlocked::after {
  content: "♡"; position: absolute; top: -9px; right: -7px;
  font: 400 13px/1 var(--display); color: #ff2d7a;
  -webkit-text-stroke: 3px var(--paper-2); paint-order: stroke;
}

/* speech tip under a header button */
.tip {
  position: fixed; left: 0; top: 0; z-index: 85;
  display: flex; align-items: center; gap: 10px;
  max-width: min(330px, calc(100vw - 20px));
  padding: 9px 16px 9px 9px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 18px 22px 16px 20px;
  box-shadow: 4px 5px 0 var(--ink);
  font: 400 16px/1.25 var(--hand);
  animation: tip-in .35s cubic-bezier(.3, 1.6, .5, 1);
}
.tip img { width: 34px; height: 34px; flex: none; }
.tip-tail { position: absolute; top: -13px; left: var(--tx, 50%); width: 22px; height: 14px; margin-left: -11px; overflow: visible; }
.tip-tail path { fill: #fff; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
@keyframes tip-in { from { opacity: 0; transform: translateY(-8px) scale(.8); } }

/* ---------- frozen wallet ---------- */
.freeze {
  position: fixed; inset: 0; z-index: 88;
  display: grid; place-items: center;
  padding: 20px;
  background: radial-gradient(ellipse at center, rgba(214, 240, 255, .35), rgba(165, 215, 255, .78) 70%, rgba(236, 248, 255, .95));
  -webkit-backdrop-filter: blur(2px) saturate(.45);
  backdrop-filter: blur(2px) saturate(.45);
  animation: frost-in .25s ease-out;
}
.freeze.out { opacity: 0; transition: opacity .3s; }
.freeze-box {
  position: relative;
  width: min(620px, 100%);
  padding: 22px 26px 24px;
  text-align: center;
  background: linear-gradient(#f4fbff, #c4e9ff);
  border: 4px solid var(--ink);
  border-radius: 14px 18px 12px 20px / 18px 12px 20px 14px;
  box-shadow: 8px 9px 0 var(--ink);
  transform: rotate(-2deg);
  animation: ice-slam .45s cubic-bezier(.2, 1.5, .4, 1) both, shiver .12s linear .45s infinite;
}
.flake { width: 62px; height: 62px; fill: none; stroke: #2f8fe0; stroke-width: 6; stroke-linecap: round; animation: spin 4s linear infinite; }
.freeze-sfx {
  position: absolute; top: -28px; right: -16px; margin: 0;
  font: 400 34px/1 var(--display); color: #8fdcff;
  -webkit-text-stroke: 5px var(--ink); paint-order: stroke;
  transform: rotate(10deg);
}
.freeze h2 {
  margin: 4px 0 6px;
  font: 400 clamp(30px, 6.4vw, 52px)/1.05 var(--display);
  color: #fff;
  -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke;
  text-shadow: 3px 4px 0 #3aa0ff;
}
.freeze-sub { margin: 0 0 14px; font: 400 16px/1.2 var(--hand); color: #0b3a66; }
.freeze-bar { height: 12px; border: 2.5px solid var(--ink); border-radius: 99px; background: #fff; overflow: hidden; }
.freeze-bar i { display: block; height: 100%; background: #56b8ff; transform-origin: left; animation: drain 3s linear forwards; }
.icicles { position: absolute; left: 6px; right: 6px; top: 100%; width: calc(100% - 12px); height: 40px; margin-top: -2px; overflow: visible; }
.icicles path { fill: #e6f7ff; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
@keyframes frost-in { from { opacity: 0; } }
@keyframes ice-slam { from { opacity: 0; transform: scale(1.35) rotate(-6deg); } to { transform: rotate(-2deg); } }
@keyframes shiver { 0%, 100% { transform: rotate(-2deg) translate(0, 0); } 25% { transform: rotate(-2deg) translate(-1.5px, .5px); } 75% { transform: rotate(-2deg) translate(1.5px, -.5px); } }
@keyframes drain { to { transform: scaleX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- narrow / portrait: room on top, then the close-up and the buttons ---------- */
@media (max-width: 820px), (max-aspect-ratio: 1/1) {
  .page { gap: 8px; }
  .tagline { display: none; }
  .top { justify-content: space-between; }
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 10px; }
  .scene-panel { width: 100%; aspect-ratio: 1.5; max-height: 50svh; }
  .side { grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .ctrl-panel { display: flex; flex-direction: column; justify-content: center; gap: 4px; }
  .btns { grid-template-columns: 1fr; }
  .btn { min-height: clamp(56px, 9vh, 110px); }
  .btn span { font-size: clamp(26px, 4.4vw, 46px); }
  .speech { max-width: 58%; padding: 12px 16px; }
}
@media (max-width: 560px) {
  .page { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .side { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .ctrl-panel { padding: 9px 10px 7px; }
  .btns { grid-template-columns: 1fr 1fr; }
  .btn { min-height: 56px; }
  .btn span { font-size: 26px; }
  .hearts-row { margin: 6px 0 9px; gap: 3px; }
  .stats { margin-top: 7px; font-size: 10.5px; }
  .bpm { left: 7px; right: 7px; bottom: 7px; padding: 3px 8px; gap: 8px; }
  .bpm-num { font-size: 11px; }
  .bpm-num b { font-size: 16px; }
  .ecg { height: 20px; }
  .brand img { width: 38px; height: 38px; }
  .brand-name { font-size: 22px; }
  .brand-jp { font-size: 9px; }
  .ca { padding: 4px 4px 4px 10px; gap: 6px; }
  .pill[data-todo="chart"] { display: none; }
  .meter-label { font-size: 15px; }
  .narration { max-width: 70%; top: 7px; left: 7px; padding: 4px 8px 3px; font-size: 11.5px; }
  .foot { font-size: 9.5px; }
}
@media (max-width: 480px) {
  .ca code { display: none; }
}
@media (max-width: 400px) {
  .links { gap: 5px; }
  .pill { padding: 6px 9px; }
  .brand { gap: 7px; }
  .brand-name { font-size: 20px; }
}
/* short landscape screens (laptops with toolbars, phones sideways) */
@media (max-height: 640px) and (min-aspect-ratio: 1/1) {
  .page { gap: 6px; padding-top: 6px; }
  .brand img { width: 34px; height: 34px; }
  .brand-name { font-size: 21px; }
  .btn { min-height: 48px; }
  .btn span { font-size: 22px; }
  .hearts-row { margin: 5px 0 7px; }
  .stats { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .page.quake, .sfx.pulse, #neon, #live, .hearts-row .on, .stuck-buzz, .wand-cursor .wand-body, .flake, .freeze-box { animation: none !important; }
}
