/* ===========================================================================
   SuperInno v2 – Layout & UI
   =========================================================================== */
:root {
  --bg: #07090e;
  --panel: rgba(10, 13, 20, 0.9);
  --panel2: rgba(255, 255, 255, 0.045);
  --line: rgba(255, 255, 255, 0.13);
  --text: #e8edf6;
  --dim: #9ea9bc;
  --gold: #ffd23f;
  --green: #7cfc8e;
  --cyan: #6fdcff;
  --red: #ff6a7f;
  --orange: #ffb15c;
  --pink: #ff4fd8;
  --mono: "DejaVu Sans Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  --T: 32px;
  --topbar: 54px;
  --tb: 70px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 600px at 50% -12%, #13213a 0%, rgba(7, 9, 14, 0) 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--mono);
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ------------------------------ top bar ---------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px)) 6px calc(8px + env(safe-area-inset-left, 0px));
  position: relative;
  z-index: 20;
}
.tools { display: flex; gap: 6px; flex: none; }
.tool {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  padding: 0;
  color: var(--text);
  background: rgba(16, 19, 25, 0.82);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.tool:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); }
.tool:active { transform: translateY(1px); }
.tool:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.6); }
.tool svg { width: 20px; height: 20px; fill: currentColor; }
#btnPause .i-play { display: none; }
#app[data-mode="paused"] #btnPause .i-play { display: inline; }
#app[data-mode="paused"] #btnPause .i-pause { display: none; }
#btnSound .i-off { display: none; }
#btnSound[aria-pressed="false"] .i-on { display: none; }
#btnSound[aria-pressed="false"] .i-off { display: inline; }
#btnSound[aria-pressed="false"] { color: var(--red); }

/* ------------------------------- stage ----------------------------------- */
#stage {
  position: relative;
  flex: none;
  height: calc(100vh - var(--topbar));
  height: calc(100dvh - var(--topbar));
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  -webkit-user-select: none;
  user-select: none;
}
#app:not([data-mode="play"]):not([data-mode="intro"]) #stage { touch-action: pan-y; }
#screen {
  touch-action: none;
  position: relative;
  flex: none;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 80px rgba(80, 160, 255, 0.06);
}
#cv { display: block; image-rendering: auto; }

/* CRT effect (static layers only: cheap to composite) */
#crt {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.45) 100%),
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.18) 2px, rgba(0, 0, 0, 0.18) 3px);
}
body.crt-off #crt { display: none; }

/* HUD */
#hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(var(--T) * 0.18) calc(var(--T) * 0.4);
  font-size: clamp(11px, calc(var(--T) * 0.52), 22px);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f2f5fb;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9), 0 1px 0 #000;
  background: linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0));
  pointer-events: none;
  white-space: nowrap;
}
#hud b { font-weight: 700; }
.h-left { display: flex; gap: 1.1em; }
.h-right { display: flex; gap: 1.1em; justify-content: flex-end; }
.h-mid { color: var(--gold); text-shadow: 0 0 10px rgba(255, 210, 63, 0.45), 0 1px 0 #000; letter-spacing: 0.12em; }
.g-inno { color: var(--green); text-shadow: 0 0 8px rgba(124, 252, 142, 0.7); }
.g-coin { color: var(--gold); text-shadow: 0 0 8px rgba(255, 210, 63, 0.7); }
.h-time b { color: var(--cyan); font-weight: 400; margin-right: .2em; }
#hud.warn .h-time { color: var(--red); animation: pulse .6s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .55; } }
#app[data-mode="menu"] #hud, #app[data-mode="levels"] #hud, #app[data-mode="win"] #hud, #app:not([data-run]) #hud { visibility: hidden; }

#bossbar {
  position: absolute; z-index: 3; left: 50%; transform: translateX(-50%);
  top: calc(var(--T) * 1.05);
  display: flex; align-items: center; gap: .6em;
  font-size: clamp(10px, calc(var(--T) * 0.42), 16px); font-weight: 700; color: #ffb0bd;
  text-shadow: 0 0 8px rgba(255, 84, 112, 0.7);
  pointer-events: none;
}
#bossbar i { display: block; width: calc(var(--T) * 6); height: calc(var(--T) * 0.32); border: 2px solid #ff5470; border-radius: 4px; background: rgba(0, 0, 0, 0.5); overflow: hidden; }
#bossbar b { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff3a5a, #ffb347); transition: width .3s ease; }
#bossbar[hidden] { display: none; }

/* sign bubble */
#bubble {
  position: absolute; z-index: 4; left: 50%; top: calc(var(--T) * 1.15);
  transform: translateX(-50%);
  width: max-content; max-width: min(92%, 640px);
  padding: .55em .9em;
  font-size: clamp(12px, calc(var(--T) * 0.46), 18px);
  line-height: 1.4;
  color: #fff6dd;
  background: rgba(30, 20, 10, 0.88);
  border: 3px double #c9944a;
  border-radius: 6px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.5);
  text-align: center;
  pointer-events: none;
  animation: pop .2s ease-out;
}
#bubble[hidden] { display: none; }
#bubble kbd {
  font: inherit; font-weight: 700; color: var(--gold);
  padding: 0 .25em; border: 1px solid rgba(255, 210, 63, .45); border-radius: 4px;
}
@keyframes pop { from { transform: translateX(-50%) translateY(6px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }

/* toast */
#toast {
  position: absolute; z-index: 4; left: 50%; top: 40%;
  transform: translate(-50%, -50%) scale(.9);
  font-size: clamp(14px, calc(var(--T) * 0.7), 30px); font-weight: 700;
  letter-spacing: .08em;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 210, 63, 0.7), 0 2px 0 #000;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity .25s ease, transform .25s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#toast.green { color: var(--green); text-shadow: 0 0 12px rgba(124, 252, 142, 0.7), 0 2px 0 #000; }
#toast.red { color: var(--red); text-shadow: 0 0 12px rgba(255, 106, 127, 0.7), 0 2px 0 #000; }

/* level intro card */
#card {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35em;
  background: radial-gradient(ellipse at center, rgba(5, 7, 12, 0.82), rgba(5, 7, 12, 0.96));
  text-align: center;
  font-size: clamp(14px, calc(var(--T) * 0.6), 26px);
  animation: fadein .25s ease-out;
}
#card[hidden] { display: none; }
#card .c-world { font-size: 2.1em; font-weight: 700; color: var(--gold); letter-spacing: .15em; text-shadow: 0 0 16px rgba(255, 210, 63, .55); }
#card .c-name { font-size: 1.1em; color: #fff; }
#card .c-lives { color: var(--green); text-shadow: 0 0 10px rgba(124, 252, 142, .6); margin-top: .6em; }
#card .c-hint { color: var(--dim); font-size: .7em; margin-top: .8em; max-width: 30em; padding: 0 1em; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------ overlay ---------------------------------- */
#overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 10px max(10px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: radial-gradient(ellipse at 50% 40%, rgba(5, 8, 14, 0.35), rgba(5, 7, 12, 0.8));
}
#overlay:empty, #overlay[hidden] { display: none; }
.panel {
  width: min(760px, 100%);
  margin: auto;
  padding: clamp(14px, 3vw, 26px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: panelIn .25s cubic-bezier(.2, .9, .3, 1.1);
}
.panel.narrow { width: min(460px, 100%); }
.panel.clear { background: rgba(8, 10, 16, 0.55); }
@keyframes panelIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.panel h2 {
  margin: 0 0 .6em; font-size: clamp(20px, 4vw, 30px); letter-spacing: .06em; color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 210, 63, 0.35);
}
.panel h2.red { color: var(--red); text-shadow: 0 0 14px rgba(255, 106, 127, 0.45); }
.panel h2.green { color: var(--green); text-shadow: 0 0 14px rgba(124, 252, 142, 0.45); }
.panel h3 { margin: 1.1em 0 .5em; font-size: 15px; color: var(--cyan); letter-spacing: .05em; }
.panel p { margin: .4em 0; line-height: 1.55; color: #cdd5e3; }
.center { text-align: center; }
.dim { color: var(--dim); }

.logo {
  margin: 0 auto .4em;
  width: max-content; max-width: 100%;
  font-family: var(--mono);
  font-size: clamp(7px, 1.95vw, 15px);
  line-height: 1.0;
  font-weight: 700;
  white-space: pre;
  background: linear-gradient(180deg, #fff7c8 0%, #ffd23f 45%, #ff8a3a 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 190, 60, 0.45));
}
.logo .inno { background: linear-gradient(180deg, #e8fff0 0%, #7cfc8e 45%, #2fbf6a 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.runner { height: 1.6em; position: relative; overflow: hidden; margin: 0 auto .2em; width: min(420px, 90%); font-weight: 700; }
.runner span { position: absolute; top: 0; animation: run 7s linear infinite; white-space: pre; }
.runner .r1 { color: var(--green); text-shadow: 0 0 8px rgba(124, 252, 142, .8); }
.runner .r2 { color: #ff7a5c; animation-delay: -2.2s; }
.runner .r3 { color: var(--gold); animation-delay: -4.4s; }
@keyframes run { from { left: -5%; } to { left: 100%; } }
.tag { text-align: center; max-width: 36em; margin: 0 auto .9em !important; font-size: 14px; }
.tag .k1 { color: var(--green); } .tag .k2 { color: #ff7a5c; } .tag .k3 { color: var(--orange); }
.tag .k4 { color: var(--gold); } .tag .k5 { color: #ff6a3a; } .tag .k6 { color: var(--cyan); }

.menu { display: grid; gap: 10px; width: min(380px, 100%); margin: 0 auto; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: .6em;
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  font: 700 15px/1.2 var(--mono);
  color: var(--text);
  background: var(--panel2);
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.4), 0 0 22px rgba(255, 210, 63, 0.25); }
.btn.primary { color: #17130a; background: linear-gradient(180deg, #ffe27a, #ffc21f); border-color: #ffd23f; box-shadow: 0 6px 22px rgba(255, 190, 40, 0.25); }
.btn.primary:hover { background: linear-gradient(180deg, #fff0a8, #ffd23f); }
.btn.primary:focus-visible { box-shadow: 0 0 0 3px #fff, 0 0 26px rgba(255, 210, 63, 0.6); }
.btn small { font-weight: 400; opacity: .8; font-size: 12px; }
.btn.big { min-height: 56px; font-size: 18px; flex-direction: column; gap: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.row .btn { width: auto; flex: 1 1 150px; }
.stats { text-align: center; color: var(--dim); font-size: 13px; margin-top: 14px !important; }
.stats b { color: var(--text); }

/* level select */
.worlds { display: grid; gap: 12px; }
.world { padding: 10px 12px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(255, 255, 255, 0.07); }
.world h3 { margin: 0 0 8px; display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.world h3 span { color: var(--dim); font-weight: 400; }
.world.w1 h3 { color: #7cfc8e; } .world.w2 h3 { color: #b49cff; } .world.w3 h3 { color: #ffb0d0; } .world.w4 h3 { color: #ff8a6a; }
.lvls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.lvl {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  min-height: 74px; padding: 8px 10px;
  font: 400 12px/1.3 var(--mono); color: var(--text); text-align: left;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.12); border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.lvl b { font-size: 15px; color: var(--gold); }
.lvl .nm { font-weight: 700; font-size: 13px; overflow-wrap: break-word; hyphens: auto; }
.lvl .st { color: var(--dim); font-size: 11px; }
.lvl .badges { position: absolute; top: 7px; right: 8px; font-size: 13px; letter-spacing: .15em; }
.lvl .ok { color: var(--green); } .lvl .sec { color: var(--cyan); }
.lvl:hover { border-color: rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.06); }
.lvl:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.4); }
.lvl[aria-disabled="true"] { opacity: .42; cursor: not-allowed; }
.lvl[aria-disabled="true"] b { color: var(--dim); }
.lvl.next { border-color: rgba(255, 210, 63, 0.55); box-shadow: 0 0 18px rgba(255, 210, 63, 0.15); }

/* help */
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 14px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.legend li { display: flex; gap: .6em; align-items: baseline; color: #cdd5e3; }
.legend .g { display: inline-block; width: 1.4em; text-align: center; font-weight: 700; font-size: 16px; text-shadow: 0 0 8px currentColor; }
.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys th, .keys td { text-align: left; padding: 5px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); vertical-align: top; }
.keys th { color: var(--dim); font-weight: 400; width: 34%; }
kbd { font: 700 12px var(--mono); padding: 1px 6px; border: 1px solid rgba(255, 255, 255, 0.25); border-bottom-width: 2px; border-radius: 5px; background: rgba(255, 255, 255, 0.06); color: #fff; white-space: nowrap; }

/* settings */
.opts { display: grid; gap: 8px; }
.opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 48px; padding: 8px 14px;
  font: 700 14px var(--mono); color: var(--text); text-align: left;
  background: var(--panel2); border: 2px solid rgba(255, 255, 255, 0.12); border-radius: 12px; cursor: pointer;
}
.opt small { display: block; font-weight: 400; color: var(--dim); font-size: 11.5px; margin-top: 2px; }
.opt .sw { flex: none; width: 46px; height: 26px; border-radius: 13px; background: rgba(255, 255, 255, 0.15); position: relative; transition: background .15s ease; }
.opt .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #cfd6e3; transition: transform .15s ease, background .15s ease; }
.opt[aria-pressed="true"] .sw { background: rgba(124, 252, 142, 0.35); }
.opt[aria-pressed="true"] .sw::after { transform: translateX(20px); background: var(--green); }
.opt .val { color: var(--gold); }
.opt:hover { border-color: rgba(255, 255, 255, 0.3); }
.opt:focus-visible { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.4); }
.opt.danger { color: #ffb0bd; }

/* results */
.tally { width: 100%; max-width: 360px; margin: 6px auto 4px; border-collapse: collapse; font-size: 14px; }
.tally td { padding: 5px 4px; border-bottom: 1px dashed rgba(255, 255, 255, 0.1); }
.tally td:last-child { text-align: right; font-weight: 700; color: #fff; }
.tally .rec td:last-child { color: var(--gold); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: rgba(255, 210, 63, 0.15); color: var(--gold); border: 1px solid rgba(255, 210, 63, 0.4); margin: 4px 3px 0; }
.badge.c { background: rgba(111, 220, 255, 0.12); color: var(--cyan); border-color: rgba(111, 220, 255, 0.4); }
.big-glyph { font-size: 44px; text-align: center; margin: 0 0 .1em; text-shadow: 0 0 16px currentColor; }

/* ------------------------------ touch ------------------------------------ */
#touch { display: none; }
body.touch #touch { display: flex; }
#touch {
  justify-content: space-between; align-items: flex-end;
  pointer-events: none;
  z-index: 6;
}
.pad-l, .pad-r { pointer-events: auto; display: grid; gap: 10px; }
.pad-l { grid-template-columns: var(--tb) calc(var(--tb) * 0.82) var(--tb); grid-template-rows: var(--tb) calc(var(--tb) * 0.7); }
.pad-l [data-k="left"] { grid-area: 1 / 1; }
.pad-l [data-k="right"] { grid-area: 1 / 3; }
.pad-l [data-k="down"] { grid-area: 2 / 2; }
.pad-r { grid-template-columns: calc(var(--tb) * 0.9) calc(var(--tb) * 1.1); grid-template-rows: calc(var(--tb) * 0.55) calc(var(--tb) * 1.1); }
.pad-r .act { grid-area: 1 / 1 / 3 / 2; align-self: start; height: calc(var(--tb) * 0.9); }
.pad-r .jump { grid-area: 2 / 2; }
.tbtn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font: 700 26px var(--mono);
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  transition: background .08s ease, transform .08s ease, border-color .08s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.tbtn small { font: 700 9px var(--mono); opacity: .8; margin-top: 1px; letter-spacing: .02em; white-space: nowrap; }
.tbtn.jump { border-radius: 50%; background: rgba(124, 252, 142, 0.16); border-color: rgba(124, 252, 142, 0.55); color: var(--green); }
.tbtn.act { border-radius: 50%; background: rgba(111, 220, 255, 0.12); border-color: rgba(111, 220, 255, 0.45); color: var(--cyan); font-size: 22px; }
.tbtn.on { background: rgba(255, 255, 255, 0.28); transform: scale(.94); border-color: #fff; }
.tbtn.jump.on { background: rgba(124, 252, 142, 0.4); }
.tbtn.act.on { background: rgba(111, 220, 255, 0.35); }

/* portrait phones: controls under the screen */
body.touch.portrait { --tb: min(76px, 19vw); }
body.touch.portrait .pad-l { grid-template-columns: var(--tb) var(--tb); grid-template-rows: var(--tb) calc(var(--tb) * 0.78); }
body.touch.portrait .pad-l [data-k="left"] { grid-area: 1 / 1; }
body.touch.portrait .pad-l [data-k="right"] { grid-area: 1 / 2; }
body.touch.portrait .pad-l [data-k="down"] { grid-area: 2 / 1 / 3 / 3; justify-self: center; width: calc(var(--tb) * 1.1); }
body.touch.portrait #stage { justify-content: flex-start; padding-top: 4px; }
body.touch.portrait #touch {
  flex: 1 1 auto; width: 100%; max-width: 560px;
  padding: 12px max(14px, env(safe-area-inset-left, 0px)) max(22px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  align-items: flex-end;
}
/* portrait info panel between screen and controls */
#pinfo { display: none; }
body.touch.portrait #pinfo {
  display: flex; flex-direction: column; gap: 8px;
  width: min(100% - 24px, 520px); margin: 14px auto 0;
  font-size: 13px; color: var(--dim);
}
body.touch.portrait #bubble { display: none; }
#app:not([data-mode="play"]):not([data-mode="intro"]):not([data-mode="paused"]) #pinfo { visibility: hidden; }
.pi-top { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; color: #cfd6e3; }
.pi-pct { color: var(--gold); }
.pi-bar { position: relative; height: 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1); }
.pi-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 6px; background: linear-gradient(90deg, rgba(124, 252, 142, 0.25), rgba(124, 252, 142, 0.7)); }
.pi-bar b { position: absolute; top: 50%; left: 0; transform: translate(-50%, -52%); color: var(--green); font-size: 16px; text-shadow: 0 0 8px rgba(124, 252, 142, 0.8); }
.pi-bar::after { content: "¶"; position: absolute; right: -4px; top: 50%; transform: translateY(-55%); color: var(--cyan); font-weight: 700; text-shadow: 0 0 8px rgba(111, 220, 255, 0.8); }
.pi-hint { min-height: 3.2em; padding: 8px 10px; line-height: 1.45; color: #fff6dd; background: rgba(30, 20, 10, 0.6); border: 3px double rgba(201, 148, 74, 0.7); border-radius: 6px; text-align: center; }
.pi-hint:empty { visibility: hidden; }
.pi-hint kbd { font: inherit; font-weight: 700; color: var(--gold); padding: 0 .25em; border: 1px solid rgba(255, 210, 63, .45); border-radius: 4px; }

/* landscape phones: controls left and right of the screen */
body.touch.landscape #touch {
  position: absolute; inset: 0;
  padding: 0 max(10px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  align-items: flex-end;
}
body.touch.landscape .pad-l { grid-template-columns: var(--tb) var(--tb); grid-template-rows: var(--tb) calc(var(--tb) * 0.78); }
body.touch.landscape .pad-l [data-k="left"] { grid-area: 1 / 1; }
body.touch.landscape .pad-l [data-k="right"] { grid-area: 1 / 2; }
body.touch.landscape .pad-l [data-k="down"] { grid-area: 2 / 1 / 3 / 3; justify-self: center; width: calc(var(--tb) * 1.1); }
body.touch.landscape .pad-r { grid-template-columns: calc(var(--tb) * 1.15); grid-template-rows: calc(var(--tb) * 0.85) calc(var(--tb) * 1.15); }
body.touch.landscape .pad-r .act { grid-area: 1 / 1; justify-self: center; width: calc(var(--tb) * 0.85); height: calc(var(--tb) * 0.85); }
body.touch.landscape .pad-r .jump { grid-area: 2 / 1; }
body.touch.landscape.overlap .tbtn { background: rgba(10, 12, 18, 0.28); }
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { padding-top: max(4px, env(safe-area-inset-top, 0px)); padding-bottom: 4px; }
  .tool { width: 34px; height: 34px; border-radius: 10px; }
}
#app:not([data-mode="play"]):not([data-mode="intro"]) #touch .pad-l,
#app:not([data-mode="play"]):not([data-mode="intro"]) #touch .pad-r { visibility: hidden; }

/* small screens */
@media (max-width: 480px) {
  .hide-xs { display: none !important; }
  .tool { width: 36px; height: 36px; }
  .lvls { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .world { padding: 8px 8px 10px; }
  .world h3 { font-size: 13px; }
  .lvl { min-height: 64px; padding: 6px 7px; }
  .lvl .nm { font-size: 10.5px; letter-spacing: -0.02em; }
  .lvl b { font-size: 14px; }
  .lvl .st { font-size: 10px; }
  .btn { font-size: 14px; }
}
@media (max-width: 360px) {
  :root { --tb: 60px; }
  .lvls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-height: 420px) {
  :root { --tb: 58px; }
  .panel { padding: 12px 14px; }
  .logo { font-size: clamp(5px, 1.3vw, 10px); }
}

/* footer spacing */
#app > .s05-footer { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  .runner span { animation: none; position: static; }
  .panel, #bubble, #card { animation: none; }
  #hud.warn .h-time { animation: none; }
}
