:root {
  --bg-0: #01050c;
  --bg-1: #04101d;
  --cyan: #41f2ff;
  --sea-glass: #9cf1e5;
  --amber: #ffc06b;
  --magenta: #ff3df0;
  --violet: #a06bff;
  --orange: #ff8a3d;
  --lime: #7dff6b;
  --gold: #ffd94a;
  --rose: #ff5d7e;
  --ink: #dff6ff;
  --ink-dim: rgba(190, 225, 240, .55);
  --panel: rgba(8, 18, 32, .82);
  --line: rgba(65, 242, 255, .28);
  --font-ui: "Segoe UI", "Rubik", system-ui, -apple-system, sans-serif;
  --font-num: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

html.file-protocol body > :not(#file-protocol-guard) { display: none !important; }
html.file-protocol #file-protocol-guard {
  display: grid !important; place-content: center; min-height: 100vh; box-sizing: border-box;
  padding: 2rem; background: #06131f; color: #d9ffff; font: 18px/1.55 system-ui, sans-serif; text-align: center;
}
html.file-protocol #file-protocol-guard h1 { color: #41f2ff; }
html.file-protocol #file-protocol-guard code { color: #ffd94a; }

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--font-ui);
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
body[data-state="playing"]:not(.surface-entry) #game-canvas { cursor: none; }

#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 3;
  background:
    radial-gradient(120% 90% at 50% 42%, transparent 55%, rgba(0, 4, 10, .55) 88%, rgba(0, 2, 6, .8) 100%),
    linear-gradient(rgba(65, 242, 255, .03), transparent 18%);
}

#fader {
  position: fixed; inset: 0; background: var(--bg-0); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .28s ease;
}
#fader.on { opacity: 1; pointer-events: all; }
#campaign-loading { position:fixed; inset:0; z-index:70; display:grid; place-content:center; gap:12px; opacity:0; pointer-events:none; background:radial-gradient(circle at 50% 44%, rgba(21,71,92,.22), rgba(1,5,12,.94)); transition:opacity .18s ease; color:var(--ink); text-align:center; letter-spacing:.12em; font-size:13px; }
#campaign-loading i { width:32px; height:32px; margin:auto; border:2px solid rgba(191,252,255,.2); border-top-color:var(--cyan); border-radius:50%; animation:campaignSpin .8s linear infinite; }
body.campaign-loading #campaign-loading { opacity:1; pointer-events:all; }
@keyframes campaignSpin { to { transform:rotate(360deg); } }
#pwa-update { position:fixed; z-index:80; left:50%; transform:translateX(-50%); top:max(14px, env(safe-area-inset-top)); width:min(350px, calc(100vw - 28px)); display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 14px; color:var(--ink); background:rgba(4,16,29,.96); border:1px solid rgba(65,242,255,.6); box-shadow:0 0 24px rgba(65,242,255,.2); font-size:12px; }
#pwa-update[hidden] { display: none !important; }
#pwa-update button { min-height:38px; padding:0 13px; color:#021019; background:var(--cyan); border:0; font:inherit; font-weight:800; cursor:pointer; }
.save-sync-status { margin:12px 0 0; padding:9px 11px; color:rgba(207,239,250,.72); background:rgba(65,242,255,.055); border-inline-start:2px solid rgba(65,242,255,.6); font-size:11px; line-height:1.5; text-align:center; }

/* ---------- HUD ---------- */

#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; transition: opacity .35s ease; }
body:not([data-state="playing"]):not([data-state="paused"]) #hud { opacity: 0; }
body[data-state="paused"] #hud { opacity: .25; }
body.surface-entry #hud { opacity: 0; pointer-events: none; }
body.mode-intro #hud { opacity: 0; pointer-events: none; }
/* The title is never a translucent layer in the ocean-entry shot. */
body.surface-entry #screen-title { opacity: 0; visibility: hidden; pointer-events: none; transition: none; }
/* Ability control is a sibling of #hud, so it needs the same cinematic gate. */
body.surface-entry .hud-ability { opacity: 0; visibility: hidden; pointer-events: none; }
body.mode-intro .hud-ability { opacity: 0; visibility: hidden; pointer-events: none; }

.hud-corner { position: absolute; display: flex; gap: 14px; align-items: flex-start; }

.hud-rail {
  position: absolute; left: clamp(8px, 1.6vw, 22px); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  opacity: .32;
}
body:not([data-state="playing"]):not([data-state="paused"]) .hud-rail { opacity: 0; }
.rail-cap { font-family: var(--font-num); font-size: 9px; letter-spacing: .14em; color: var(--ink-dim); writing-mode: vertical-rl; }
.rail-track {
  position: relative; width: 3px; height: min(46vh, 380px);
  background: rgba(190, 225, 240, .12); border-radius: 2px;
}
.rail-ticks {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(180deg, transparent 0, transparent calc(10% - 1px), rgba(190, 225, 240, .25) calc(10% - 1px), rgba(190, 225, 240, .25) 10%);
}
.rail-marker {
  position: absolute; left: 50%; top: var(--p, 0%);
  width: 9px; height: 9px; transform: translate(-50%, -50%) rotate(45deg);
  background: var(--mc, var(--cyan)); box-shadow: 0 0 8px var(--mc, var(--cyan));
}
.rail-sub {
  position: absolute; left: 50%; top: 20%; transform: translate(-46%, -50%);
  width: 15px; height: 15px; color: var(--cyan);
  filter: drop-shadow(0 0 6px rgba(65, 242, 255, .8));
  transition: top .4s linear;
}
.rail-sub svg { width: 100%; height: 100%; fill: currentColor; }
@media (max-width: 900px) { .hud-rail { display: none; } }
.hud-tl { top: max(14px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left)); flex-direction: column; }
.hud-tr { top: max(14px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right)); flex-direction: column; align-items: flex-end; gap: 6px; }
.hud-bl { bottom: max(16px, env(safe-area-inset-bottom)); left: max(18px, env(safe-area-inset-left)); flex-direction: column; gap: 8px; }
.hud-bc { bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); flex-direction: row; }

.hud-block { display: flex; flex-direction: column; gap: 1px; text-shadow: 0 0 12px rgba(65, 242, 255, .45); }
.hud-block.right { align-items: flex-end; }
.hud-label { font-size: clamp(9px, 1.1vw, 11px); letter-spacing: .34em; color: var(--ink-dim); text-transform: uppercase; }
.hud-value { font-family: var(--font-num); font-size: clamp(20px, 3.2vw, 30px); font-weight: 700; color: var(--cyan); line-height: 1; }
.hud-sub { font-family: var(--font-num); font-size: 12px; letter-spacing: .18em; color: var(--ink-dim); }
.hud-sub b { color: var(--gold); font-weight: 600; }
.mode-identity { color: rgba(174, 242, 255, .86); font-size: 9px; letter-spacing: .16em; }

.hud-row { display: flex; gap: 8px; pointer-events: auto; margin-bottom: 6px; }

.icon-btn {
  width: 34px; height: 34px; border: 1px solid var(--line); background: rgba(6, 14, 26, .55);
  color: var(--ink-dim); cursor: pointer; display: grid; place-items: center; transition: all .18s ease;
  clip-path: polygon(20% 0, 100% 0, 100% 80%, 80% 100%, 0 100%, 0 20%);
}
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 14px rgba(65, 242, 255, .35); }
.icon-btn.off { color: var(--rose); border-color: rgba(255, 93, 126, .5); opacity: .7; }

.btn-mute .ic-off { display: none; }
.career-card { margin: 12px 0; padding: 12px; border: 1px solid rgba(65,242,255,.28); border-radius: 14px; background: linear-gradient(135deg,rgba(6,22,42,.84),rgba(22,9,48,.72)); text-align: left; box-shadow: inset 0 1px rgba(255,255,255,.05); }
.career-head { display:flex; justify-content:space-between; gap:12px; align-items:baseline; color:#dff6ff; font-size:.85rem; }
.career-head b { color:#41f2ff; letter-spacing:.08em; }.career-head span,.career-card small { color:#a7c7d8; font-size:.73rem; }
.career-xp { height:6px; margin:9px 0 4px; overflow:hidden; border-radius:99px; background:rgba(255,255,255,.1); }.career-xp i { display:block; height:100%; width:0; background:linear-gradient(90deg,#41f2ff,#a06bff); box-shadow:0 0 12px #41f2ff; transition:width .35s ease; }
.career-missions { display:grid; gap:5px; margin:9px 0 0; padding:0; list-style:none; }.career-missions li { display:flex; justify-content:space-between; gap:9px; font-size:.72rem; color:#dff6ff; }.career-missions li.done { color:#7dff6b; }
.career-result { width:min(100%,440px); padding:10px 12px; border:1px solid rgba(65,242,255,.3); border-radius:12px; background:linear-gradient(135deg,rgba(6,22,42,.9),rgba(22,9,48,.82)); }
.career-result-head,.career-result-crystals,.career-result-missions li { display:flex; justify-content:space-between; align-items:baseline; gap:10px; }
.career-result-head b { color:var(--cyan); letter-spacing:.1em; }.career-result-head span { color:var(--lime); font:700 12px var(--font-num); }
.career-result-crystals { margin-top:6px; color:var(--gold); font-size:11px; }
.career-result-missions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; margin:8px 0 0; padding:0; list-style:none; }
.career-result-missions li { min-width:0; padding:5px 6px; border:1px solid rgba(190,225,240,.12); color:var(--ink-dim); font-size:10px; }
.career-result-missions li span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }.career-result-missions li b { color:var(--ink); white-space:nowrap; }
body.muted .btn-mute .ic-on { display: none; }
body.muted .btn-mute .ic-off { display: block; }
body.muted .btn-mute { color: var(--rose); border-color: rgba(255, 93, 126, .5); }

.hud-combo { display: flex; align-items: center; gap: 8px; opacity: 1; transform: none; min-height:18px; transition: color .2s ease; }
.hud-combo.live { color: var(--magenta); }
.score-ledger::before { content:'LEDGER'; color:var(--ink-dim); font:9px var(--font-num); letter-spacing:.12em; }
#hud-mult { font-family: var(--font-num); font-weight: 700; color: var(--magenta); font-size: 15px; text-shadow: 0 0 10px rgba(255, 61, 240, .6); }
.combo-track { width: 74px; height: 3px; background: rgba(255, 255, 255, .08); display: block; overflow: hidden; }
#hud-combo-bar { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--violet), var(--magenta)); box-shadow: 0 0 8px var(--magenta); }

#hud-hearts { display: flex; gap: 7px; align-items: flex-end; }
.pcell {
  --lvl: 100%;
  position: relative; width: 20px; height: 27px;
  border: 1px solid rgba(255, 93, 126, .55);
  clip-path: polygon(50% 0, 100% 30%, 82% 100%, 18% 100%, 0 30%);
  background: rgba(255, 93, 126, .07);
  overflow: hidden;
}
.pcell i {
  position: absolute; left: 2px; right: 2px; bottom: 0; height: var(--lvl);
  background: linear-gradient(180deg, #ff9db1, #ff3050);
  box-shadow: 0 0 10px #ff3050;
}
.pcell.off { opacity: .22; }
.pcell.off i { height: 14%; box-shadow: none; }
.pcell.cyan { border-color: rgba(65, 242, 255, .65); }
.pcell.cyan i { background: linear-gradient(180deg, #c8fcff, #41f2ff); box-shadow: 0 0 10px #41f2ff; }
.cell.pop { animation: cellPop .45s ease; }
@keyframes cellPop { 40% { transform: scale(1.35); } }

.dash-meter { display: flex; align-items: center; gap: 8px; }
.dash-track { width: 86px; height: 4px; background: rgba(255, 255, 255, .08); display: block; overflow: hidden; }
#hud-dash-fill { display: block; height: 100%; width: 100%; background: var(--lime); box-shadow: 0 0 8px rgba(125, 255, 107, .7); transition: background .2s; }
#hud-dash-fill.charging { background: var(--orange); box-shadow: 0 0 8px rgba(255, 138, 61, .7); }
.dash-state { min-height: 14px; color: var(--lime); font-size: 10px; letter-spacing: .12em; }
.dash-state.cooling { color: var(--orange); }
.dash-state.safe { color: var(--cyan); }

.pwr-chip {
  display: flex; align-items: center; gap: 8px; padding: 7px 13px;
  border: 1px solid var(--line); background: rgba(6, 14, 26, .72);
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  animation: chipIn .25s ease;
}
@keyframes chipIn { from { opacity: 0; transform: translateY(8px); } }
.pwr-chip i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.pwr-chip b { font-size: 12px; letter-spacing: .12em; font-weight: 600; }
.pwr-chip em { font-style: normal; font-family: var(--font-num); font-size: 12px; color: var(--ink-dim); min-width: 26px; text-align: right; }

/* ---------- Banner ---------- */

#banner {
  position: fixed; top: 22%; left: 0; right: 0; z-index: 6; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  opacity: 0; transform: translateY(-14px) scale(.96);
}
#banner.show { animation: bannerIn 1.7s cubic-bezier(.2, .8, .2, 1) forwards; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateY(-14px) scale(.96); }
  14% { opacity: 1; transform: none; }
  78% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(10px) scale(.98); }
}
#banner-main {
  max-width: min(92vw, 680px); overflow-wrap: anywhere; text-align: center; font-size: clamp(22px, 4.4vw, 42px); font-weight: 800; letter-spacing: clamp(.04em, .5vw, .16em); text-indent: 0;
  color: var(--cyan); text-shadow: 0 0 24px rgba(65, 242, 255, .8), 0 0 70px rgba(65, 242, 255, .35);
}
#banner-sub { max-width: min(88vw, 560px); text-align:center; font-style: normal; letter-spacing: .06em; color: rgba(223,246,255,.82); font-size: clamp(11px, 1.6vw, 14px); }

.mode-select { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0 2px; }
.mode-card { min-height: 54px; padding: 8px 7px; color: rgba(223,246,255,.76); background: rgba(5, 15, 28, .7); border: 1px solid rgba(190,225,240,.28); text-align: center; cursor: pointer; font: inherit; transition: .18s ease; }
.mode-card b { display: block; font-size: 11px; color: #eafcff; }
.mode-card span { display: block; margin-top: 4px; font-size: 10px; line-height: 1.25; }
.mode-card:hover, .mode-card.active { border-color: var(--cyan); color: var(--cyan); box-shadow: inset 0 0 18px rgba(65,242,255,.08), 0 0 13px rgba(65,242,255,.12); }
.mode-card.active b { color: var(--cyan); }
.rank-select { width: 100%; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; padding: 7px; border: 1px solid rgba(125, 255, 107, .18); background: rgba(3, 12, 24, .56); }
.rank-label { grid-column: 1 / -1; color: rgba(223,246,255,.56); font-size: 10px; letter-spacing: .12em; }
.rank-card { min-height: 48px; padding: 6px 4px; color: rgba(223,246,255,.74); background: rgba(8, 20, 35, .72); border: 1px solid rgba(190,225,240,.22); font: inherit; text-align: center; cursor: pointer; }
.rank-card b { display: block; color: #eafcff; font-size: 10px; letter-spacing: .05em; }
.rank-card span { display: block; margin-top: 3px; font-size: 9px; line-height: 1.2; }
.rank-card:hover, .rank-card.active { border-color: var(--lime); color: var(--lime); box-shadow: inset 0 0 16px rgba(125,255,107,.07); }
.rank-card.active b { color: var(--lime); }
.rank-card:disabled { opacity: .38; cursor: not-allowed; filter: saturate(.45); }
.rank-select.rank-unavailable { opacity: .5; }
.rank-note { max-width: 620px; margin: -5px 0 0; color: rgba(223,246,255,.58); font-size: 10px; line-height: 1.35; letter-spacing: .04em; }
.title-config { width: 100%; display: flex; flex-direction: column; gap: 9px; }
.title-config-toggle {
  width:100%; min-height:54px; display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:10px 14px; color:var(--sea-glass); background:rgba(9,30,43,.54); border:1px solid rgba(125,232,224,.24);
  font:inherit; cursor:pointer; text-align:start; transition:background .18s ease,border-color .18s ease;
}
.title-config-toggle:hover,.title-config-toggle:focus-visible { background:rgba(20,58,68,.62); border-color:rgba(125,232,224,.56); outline:none; }
.title-config-toggle span { font:700 12px/1.25 var(--font-num); letter-spacing:.06em; }
.title-config-toggle small { color:rgba(223,246,255,.58); font-size:10px; white-space:nowrap; }
.title-config-toggle::after { content:'＋'; color:var(--sea-glass); font-size:17px; }
#screen-title.config-open .title-config-toggle::after { content:'−'; }
#screen-title:not(.config-open) #title-config { display:none; }
#screen-title:not(.config-open) .journey-strip { display:none; }
.title-secondary-actions { width: 100%; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.title-secondary-actions .btn { min-width: 0; flex: 1 1 150px; max-width: 220px; }

/* ---------- Screens ---------- */

.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transform: scale(1.035);
  transition: opacity .38s ease, transform .38s ease;
}
.screen.visible { opacity: 1; pointer-events: auto; transform: none; }

.panel {
  background: linear-gradient(165deg, rgba(12, 24, 42, .92), rgba(4, 9, 18, .95));
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .6), 0 24px 80px rgba(0, 0, 0, .65), 0 0 44px rgba(65, 242, 255, .07) inset;
  backdrop-filter: blur(10px);
  clip-path: polygon(26px 0, 100% 0, 100% calc(100% - 26px), calc(100% - 26px) 100%, 0 100%, 0 26px);
  padding: clamp(22px, 4vw, 38px);
}

.title-wrap { width:min(100%, 820px); max-width: calc(100vw - 24px); display:flex; flex-direction:column; align-items:center; gap:clamp(13px,2.2vh,22px); text-align:center; padding:clamp(14px,2.4vw,24px); margin:auto; }
/* Auto margins keep short menus centered, but collapse before oversized content.
   This leaves the logo reachable instead of centering it above the scrollport. */
#screen-title { overflow: auto; padding: 12px; align-items: flex-start; }

.title-eyebrow { width:min(100%,680px); display:flex; align-items:center; justify-content:center; gap:12px; margin:0; color:rgba(183,243,232,.72); font:700 10px/1.2 var(--font-num); letter-spacing:.22em; text-transform:uppercase; animation:logoRise .8s cubic-bezier(.2,.9,.25,1) both; }
.title-eyebrow::before,.title-eyebrow::after { content:''; width:min(9vw,64px); height:1px; background:linear-gradient(90deg,transparent,rgba(125,232,224,.44)); }
.title-eyebrow::after { transform:scaleX(-1); }
.logo { width:100%; max-width:100%; display:flex; flex-direction:column; align-items:center; line-height:.9; animation:logoRise 1s cubic-bezier(.2,.9,.25,1) both; }
.logo-neon {
  max-width: 100%; white-space: nowrap; font-size: clamp(28px, 6.4vw, 58px); font-weight: 200; letter-spacing: clamp(.22em, 1.55vw, .55em); text-indent: 0;
  color: var(--sea-glass); text-shadow: 0 0 15px rgba(120, 235, 222, .48), 0 0 46px rgba(65, 210, 224, .2);
}
.logo-abyss {
  max-width: 100%; white-space: nowrap; font-size: clamp(48px, 10.8vw, 102px); font-weight: 900; letter-spacing: clamp(.04em, .45vw, .12em); text-indent: 0;
  background: linear-gradient(105deg, #b7f3e8 0%, #52dbe0 32%, #bfe9c3 58%, var(--amber) 78%, #a7eee5 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 20px rgba(70, 208, 217, .32)) drop-shadow(0 0 28px rgba(255, 192, 107, .12));
  animation: sheen 16s ease-in-out infinite alternate;
}
@keyframes sheen { to { background-position: 220% 0; } }
@keyframes logoRise { from { opacity: 0; transform: translateY(26px) scale(.94); } }

.tagline { margin:0; color:rgba(223,246,255,.7); letter-spacing:.05em; font-size:clamp(12px,1.8vw,15px); animation:logoRise 1s .15s cubic-bezier(.2,.9,.25,1) both; }
.orientation-hint { display:none; align-items:center; justify-content:center; gap:8px; max-width:min(92vw, 340px); color:rgba(189, 239, 231, .78); font-size:11px; line-height:1.35; }
.orientation-hint button { min-height:30px; padding:4px 9px; border:1px solid rgba(156,241,229,.38); color:var(--sea-glass); background:rgba(15,57,67,.42); font:inherit; cursor:pointer; }
.orientation-hint[hidden] { display:none !important; }

/* Hero console: the ocean is the backdrop, so the default title view is just
   the dive action and the local record. Dense info lives in the disclosure. */
.menu-panel { position:relative; width:min(100%,680px); display:flex; flex-direction:column; align-items:center; gap:13px; padding:0; overflow:visible; background:none; border:0; box-shadow:none; animation:logoRise 1s .3s cubic-bezier(.2,.9,.25,1) both; }
.menu-panel .btn { min-height: 48px; }
.menu-panel .btn.cta { width:min(100%,420px); min-height:64px; font-size:19px; letter-spacing:.14em; animation:none; box-shadow:0 14px 44px rgba(65,242,255,.2),0 0 0 1px rgba(125,232,224,.35) inset; }
.menu-panel .btn.cta:hover { box-shadow:0 16px 54px rgba(65,242,255,.3),0 0 0 1px rgba(125,232,224,.55) inset; }
.best-chip {
  display:inline-flex; align-items:center; gap:8px;
  font-size:12px; letter-spacing:.14em; color:var(--ink-dim);
  border:1px solid rgba(255,217,74,.28); padding:7px 18px;
  clip-path:polygon(12px 0,100% 0,calc(100% - 12px) 100%,0 100%);
  background:rgba(6,14,26,.5);
}
.best-chip small { color:rgba(223,246,255,.42); font:700 8px var(--font-num); letter-spacing:.18em; }
.best-chip b { font-family: var(--font-num); color: var(--gold); font-size: 15px; }

#title-config {
  width:min(100%,640px); display:flex; flex-direction:column; gap:10px;
  padding:16px 14px; margin-top:2px;
  background:linear-gradient(145deg,rgba(5,20,32,.88),rgba(10,20,38,.8));
  border:1px solid rgba(147,229,221,.2);
  box-shadow:0 22px 70px rgba(0,0,0,.34),inset 0 1px rgba(255,255,255,.05);
  backdrop-filter:blur(14px);
  clip-path:polygon(18px 0,100% 0,100% calc(100% - 18px),calc(100% - 18px) 100%,0 100%,0 18px);
}
.menu-panel .career-card { width:100%; margin:0; padding:10px 12px; border:0; border-radius:0; background:linear-gradient(90deg,rgba(65,242,255,.055),rgba(160,107,255,.045)); box-shadow:none; }

.journey-strip {
  display: flex; gap: 9px; list-style: none;
  animation: logoRise 1s .38s cubic-bezier(.2, .9, .25, 1) both;
}
.journey-strip li {
  --sw: var(--cyan);
  border: 1px solid rgba(190, 225, 240, .1);
  border-left: 3px solid var(--sw);
  background: linear-gradient(120deg, rgba(8, 18, 32, .78), rgba(4, 9, 18, .88));
  padding: 7px 13px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  transition: transform .18s ease, box-shadow .18s ease;
}
.journey-strip li:hover { transform: translateY(-3px); box-shadow: 0 0 18px -4px var(--sw); }
.journey-strip b { display: block; font-size: clamp(9px, 1.3vw, 12px); letter-spacing: .16em; font-weight: 700; color: var(--ink); }
.journey-strip span { font-family: var(--font-num); font-size: 11px; color: var(--ink-dim); }
@media (max-width: 700px) {
  .journey-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; width: min(92vw, 360px); }
  .journey-strip li { padding: 6px 10px; }
}

.nextgoal-chip {
  font-size: 12px; letter-spacing: .1em; color: var(--ink-dim);
  border: 1px dashed rgba(190, 225, 240, .25); padding: 6px 14px;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}
.nextgoal-chip:empty { display: none; }

/* Paused-run snapshot: depth, score, loadout — glanceable, not a menu. */
.pause-stats { width:100%; display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:6px 10px; padding:10px 12px; border:1px solid rgba(190,225,240,.14); background:rgba(4,12,24,.6); }
.pause-stats div { display:flex; flex-direction:column; gap:2px; min-width:0; }
.pause-stats span { color:rgba(223,246,255,.44); font:700 8px var(--font-num); letter-spacing:.16em; }
.pause-stats b { color:var(--ink); font-family:var(--font-num); font-size:14px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pause-stats .pause-temps { grid-column:1 / -1; }
.pause-stats .pause-temps b { font-family:inherit; font-size:11.5px; white-space:normal; line-height:1.35; color:var(--sea-glass); }

.challenge-strip { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; list-style:none; width:100%; }
.challenge-strip li {
  display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; gap:7px; text-align:start;
  border: 1px solid rgba(190, 225, 240, .12); border-inline-start: 3px solid var(--gold);
  background: linear-gradient(120deg, rgba(8, 18, 32, .7), rgba(4, 9, 18, .85));
  padding:7px 8px;
}
.challenge-strip li i {
  flex: none; width: 22px; height: 22px; display: grid; place-items: center;
  font-style: normal; font-size: 11px; color: var(--gold);
  border: 1px solid rgba(255, 217, 74, .4); background: rgba(255, 217, 74, .06);
}
.challenge-strip li div { flex: 1; min-width: 0; }
.challenge-strip li b { display: block; font-size: 12px; letter-spacing: .06em; }
.challenge-strip li small { display: block; font-size: 10.5px; color: var(--ink-dim); }
.challenge-strip li em { grid-column:2; font-style:normal; font-family:var(--font-num); font-size:10px; color:var(--gold); white-space:nowrap; }
.challenge-strip li.done { border-inline-start-color: var(--lime); opacity: .75; }
.challenge-strip li.done i { color: var(--lime); border-color: rgba(125, 255, 107, .4); }
.challenge-strip li.done em { color: var(--lime); }

.btn {
  position: relative; font-family: inherit; font-size: clamp(14px, 1.9vw, 17px); font-weight: 600;
  letter-spacing: .22em; text-indent: .22em; color: var(--cyan); cursor: pointer;
  background: rgba(65, 242, 255, .05); border: 1px solid var(--line);
  padding: 13px 34px; padding-inline-end: 52px; min-width: 250px;
  clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
  transition: all .18s ease;
}
.btn:hover, .btn:focus-visible { background: rgba(65, 242, 255, .16); border-color: var(--cyan); box-shadow: 0 0 26px rgba(65, 242, 255, .35); outline: none; transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(90deg, rgba(65, 242, 255, .22), rgba(160, 107, 255, .25));
  border-color: rgba(65, 242, 255, .6); color: #eafcff;
}
.btn.primary:hover { box-shadow: 0 0 34px rgba(65, 242, 255, .5); }
.btn.cta { animation: ctaPulse 2.2s ease infinite; }
@keyframes ctaPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(65, 242, 255, .3); }
  50% { box-shadow: 0 0 44px rgba(65, 242, 255, .65); }
}
.btn.ghost { color: var(--ink-dim); border-color: rgba(190, 225, 240, .18); }
.btn.ghost:hover { color: var(--ink); box-shadow: none; background: rgba(190, 225, 240, .07); }
.key-hint {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 10px; letter-spacing: .1em; text-indent: 0; font-family: var(--font-num);
  border: 1px solid rgba(190, 225, 240, .25); color: var(--ink-dim); padding: 2px 7px;
}

.foot-hint { color: rgba(190, 225, 240, .4); font-size: clamp(10px, 1.5vw, 12.5px); letter-spacing: .1em; animation: logoRise 1s .45s both; }

.pause-panel, .over-panel { display: flex; flex-direction: column; align-items: center; gap: 20px; min-width: min(420px, 88vw); }
.pause-panel h2, .over-title {
  letter-spacing: .5em; text-indent: .5em; font-size: clamp(24px, 4.5vw, 36px); font-weight: 800; color: var(--cyan);
  text-shadow: 0 0 22px rgba(65, 242, 255, .6);
}
.over-title { color: var(--magenta); text-shadow: 0 0 22px rgba(255, 61, 240, .65); }
.pause-sub { color: var(--ink-dim); font-size: 13px; letter-spacing: .08em; margin-top: -12px; }
.btn-col { display: flex; flex-direction: column; gap: 11px; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn-row .btn { min-width: 210px; }

.record-badge {
  display: none; font-weight: 700; letter-spacing: .3em; text-indent: .3em; font-size: 14px;
  color: #1a0b02; background: linear-gradient(90deg, var(--gold), #fff2c4, var(--gold));
  padding: 7px 22px; box-shadow: 0 0 30px rgba(255, 217, 74, .55);
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  animation: badgePulse 1.1s ease infinite alternate;
}
.record-badge.on { display: block; }
@keyframes badgePulse { from { filter: brightness(.92); } to { filter: brightness(1.12); } }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 26px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; }
.stat span { font-size: 10px; letter-spacing: .28em; color: var(--ink-dim); text-transform: uppercase; }
.stat b { font-family: var(--font-num); font-size: clamp(17px, 2.6vw, 23px); color: var(--ink); font-weight: 700; }
.stat.main { grid-column: span 3; border-bottom: 1px solid rgba(65, 242, 255, .18); padding-bottom: 14px; margin-bottom: 6px; }
.stat.main b { font-size: clamp(34px, 6vw, 52px); color: var(--cyan); text-shadow: 0 0 22px rgba(65, 242, 255, .55); }

.modal { background: rgba(1, 4, 10, .6); backdrop-filter: blur(4px); }
.screen.modal { z-index: 45; }
.screen.modal.modal-top { z-index: 55; }
body.modal-open #screen-title, body.modal-open #hud, body.modal-open #game-canvas { pointer-events:none; }
.help-panel { width: min(880px, 94vw); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: 20px; }
.help-panel h2 { letter-spacing: .3em; font-size: clamp(18px, 3vw, 24px); color: var(--cyan); text-shadow: 0 0 16px rgba(65, 242, 255, .5); text-align: center; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 22px; }
.rose-t { color: var(--rose); } .orange-t { color: var(--orange); } .cyan-t { color: var(--cyan); }
.gold-t { color: var(--gold); } .violet-t { color: var(--violet); }
.boss-help b { display: block; margin-bottom: 2px; font-size: 12.5px; letter-spacing: .06em; }
.help-col h3 { font-size: 12px; letter-spacing: .3em; color: var(--violet); margin-bottom: 12px; text-transform: uppercase; }
.ctrl-list, .beast-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.ctrl-list li, .beast-list li { display: flex; align-items: baseline; gap: 9px; font-size: 13px; color: var(--ink); flex-wrap: wrap; }
.ctrl-list li > span, .beast-list li > span { color: var(--ink-dim); font-size: 12px; flex: 1 1 100%; padding-inline-start: 2px; }
kbd {
  font-family: var(--font-num); font-size: 11px; border: 1px solid rgba(190, 225, 240, .3);
  padding: 2px 7px; background: rgba(190, 225, 240, .06); color: var(--cyan);
}
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; align-self: center; }
.dot.lurker { background: var(--magenta); box-shadow: 0 0 9px var(--magenta); }
.dot.darter { background: var(--orange); box-shadow: 0 0 9px var(--orange); }
.dot.medusa { background: var(--violet); box-shadow: 0 0 9px var(--violet); }
.dot.eel { background: var(--lime); box-shadow: 0 0 9px var(--lime); }
.dot.shield { background: var(--cyan); box-shadow: 0 0 9px var(--cyan); }
.dot.magnet { background: var(--gold); box-shadow: 0 0 9px var(--gold); }
.dot.slow { background: var(--violet); box-shadow: 0 0 9px var(--violet); }
.dot.x2 { background: var(--lime); box-shadow: 0 0 9px var(--lime); }
.dot.heart { background: var(--rose); box-shadow: 0 0 9px var(--rose); }

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat.main { grid-column: span 2; }
  .btn { min-width: 200px; }
  .foot-hint { display: none; }
  .hud-value { font-size: 19px; }
}

/* Keep every first-play choice above the fold on common short desktop windows. */
@media (max-height: 850px) and (min-width: 521px) {
  .career-card { margin: 2px 0; padding: 5px 8px; border-radius: 9px; }
  .career-head { font-size: .72rem; }
  .career-head span { font-size: .66rem; }
  .career-xp { height: 4px; margin: 4px 0 1px; }
  .career-card small, .career-missions { display: none; }
  #screen-gameover { overflow:auto; padding:8px; align-items:flex-start; }
  #screen-gameover .over-panel { margin:auto; gap:5px; padding:9px 14px; }
  #screen-gameover .over-title { font-size:20px; }
  #screen-gameover .stats-grid { grid-template-columns:repeat(6,minmax(0,1fr)); gap:3px 10px; }
  #screen-gameover .stat.main { grid-column:span 6; padding:2px; margin:0; }
  #screen-gameover .stat { padding:2px; }
  #screen-gameover .stat.main b { font-size:28px; }
  #screen-gameover .career-result { padding:5px 8px; }
  #screen-gameover .career-result-crystals { margin-top:2px; }
  #screen-gameover .career-result-missions { margin-top:3px; }
  #screen-gameover .nextgoal-chip, #screen-gameover .bay-note { display:none; }
  #screen-gameover .btn-row .btn { min-height:36px; padding:6px 12px; }
  .title-wrap { gap: 6px; padding: 8px; }
  .logo-neon { font-size: 30px; }
  .logo-abyss { font-size: 82px; }
  .tagline { font-size: 11px; }
  .menu-panel { gap: 6px; }
  .challenge-strip { display: none; }
  .journey-strip { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 4px; width: min(94vw, 420px); max-height: 70px; overflow-y: auto; }
  .journey-strip li { padding: 4px 5px; }
  .journey-strip b { font-size: 8px; letter-spacing: .08em; }
  .journey-strip span { font-size: 9px; }
  .best-chip, .nextgoal-chip { padding: 5px 12px; font-size: 11px; }
  .menu-panel .btn { padding: 8px 16px; }
  .mode-card { min-height: 52px; }
  .mode-card span { font-size: 9.5px; }
  .rank-card { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .logo-abyss { animation: none !important; background-position: 50% 0; }
}

.no-anim *, .no-anim *::before, .no-anim *::after {
  animation: none !important;
  transition: none !important;
}

/* ---------- Boss bar ---------- */

#boss-bar {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(560px, 86vw); z-index: 8; display: none; pointer-events: none;
}
#boss-bar.on { display: block; animation: bossBarIn .6s cubic-bezier(.2,.9,.3,1.2); }
@keyframes bossBarIn { from { opacity: 0; transform: translateX(-50%) translateY(-16px) scale(.92); } }
.boss-name {
  font-size: clamp(11px, 1.7vw, 15px); font-weight: 800; letter-spacing: .34em; text-align: center;
  color: #ffd9a0; text-shadow: 0 0 14px rgba(255, 106, 61, .8); margin-bottom: 5px;
}
.boss-cue { min-height: 17px; margin: 3px 0 7px; color: var(--ink-dim); font-size: 10px; letter-spacing: .16em; text-align: center; }
.boss-cue.open { color: var(--gold); text-shadow: 0 0 12px rgba(255,217,74,.7); }
.boss-track {
  height: 10px; border: 1px solid rgba(255, 138, 61, .55);
  background: rgba(20, 8, 4, .75);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 100%, 0 100%);
  overflow: hidden; padding: 1px; display: block;
}
#boss-fill {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, #ff5230, #ffb36b);
  box-shadow: 0 0 14px rgba(255, 82, 48, .8);
  transition: width .18s ease;
}

/* ---------- Ability button + run crystals ---------- */

.hud-ability {
  position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(64px, env(safe-area-inset-bottom));
  pointer-events: auto;
}
#btn-ability {
  position: relative; width: 56px; height: 56px; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, rgba(65,242,255,.28), rgba(8,18,32,.85) 70%);
  border: 1px solid var(--line); color: var(--cyan);
  clip-path: polygon(30% 0, 100% 0, 100% 70%, 70% 100%, 0 100%, 0 30%);
}
#btn-ability svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; }
#btn-ability.ready { box-shadow: 0 0 22px rgba(65,242,255,.55); animation: abReadyPulse 1.6s ease infinite; }
#btn-ability.cooling { color: var(--ink-dim); }
#btn-ability.invalid { opacity: .45; }
#btn-ability.none { opacity: .3; }
@keyframes abReadyPulse { 0%, 100% { box-shadow: 0 0 14px rgba(65,242,255,.35); } 50% { box-shadow: 0 0 30px rgba(65,242,255,.7); } }
.ab-sec {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-num); font-size: 17px; font-weight: 700; color: var(--ink);
  pointer-events: none; text-shadow: 0 0 8px rgba(0,0,0,.8);
}
.ab-name {
  position: absolute; right: 0; bottom: -20px; white-space: nowrap;
  font-size: 10.5px; letter-spacing: .08em; color: var(--ink-dim);
  text-shadow: 0 1px 4px rgba(0,0,0,.9);
}
.ab-cd {
  position: absolute; inset: 0;
  background: conic-gradient(rgba(4,8,16,.85) var(--cd, 0%), transparent 0);
  pointer-events: none;
}
#btn-ability .key-hint { right: 4px; top: 4px; transform: none; }

#touch-actions { display:none; position:fixed; right:max(clamp(18px, 22vw, 88px), env(safe-area-inset-right)); bottom:max(64px, env(safe-area-inset-bottom)); z-index:11; flex-direction:column; align-items:center; gap:20px; pointer-events:none; touch-action:none; isolation:isolate; transition:opacity .12s ease; }
.touch-btn {
  display: none;
  position: relative;
  width: 70px; height: 70px; border-radius: 50%;
  background: rgba(8, 18, 32, .72); border: 1px solid var(--line);
  color: var(--cyan); z-index: 9; touch-action: none; pointer-events: auto;
  -webkit-tap-highlight-color: transparent; will-change: transform; transition:transform .07s ease,background .09s ease,border-color .09s ease;
}
.touch-btn:disabled { color:rgba(190,225,240,.42); border-color:rgba(190,225,240,.18); background:rgba(8,18,32,.5); box-shadow:none; }
#touch-dash { color:#7dffe8; border-color:rgba(125,255,232,.72); background:rgba(8,42,44,.82); z-index:2; }
#touch-ability { color:#d9b5ff; border-color:rgba(217,181,255,.58); background:rgba(34,20,55,.8); z-index:1; }
.touch-btn svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; transform:translateY(-5px); }
.touch-btn span { position:absolute; left:50%; bottom:10px; transform:translateX(-50%); font-size:8px; font-weight:900; letter-spacing:.08em; line-height:1; color:currentColor; pointer-events:none; }
/* Invisible circular halo: a fat thumb landing in the seam between the two
   discs still activates the nearest control instead of tapping dead layout.
   The halo never changes layout or getBoundingClientRect, only hit-testing. */
.touch-btn::after { content:''; position:absolute; inset:-9px; border-radius:50%; }
#touch-joystick-zone { display:none; position:fixed; left:max(8px, env(safe-area-inset-left)); bottom:max(8px, env(safe-area-inset-bottom)); width:min(46vw, 260px); height:min(42vh, 270px); z-index:10; touch-action:none; pointer-events:auto; }
#touch-regrip-cue { display:none; position:fixed; z-index:12; pointer-events:none; opacity:0; color:#dffbf7; background:rgba(4,18,29,.9); border:1px solid rgba(125,255,232,.38); padding:7px 10px; font:800 9px/1.2 var(--font-num); letter-spacing:.1em; text-align:center; box-shadow:0 10px 28px rgba(0,0,0,.34); transition:opacity .14s ease; }
#touch-regrip-cue[hidden] { display:none !important; }
#touch-regrip-cue span { display:block; margin-top:3px; color:rgba(223,246,255,.64); font:600 9px/1.2 inherit; letter-spacing:.02em; }
.a11y-live { position:fixed !important; width:1px !important; height:1px !important; padding:0 !important; margin:-1px !important; overflow:hidden !important; clip:rect(0,0,0,0) !important; white-space:nowrap !important; border:0 !important; }
#touch-joystick { position:absolute; left:var(--joy-x, 0px); top:var(--joy-y, calc(100% - 132px)); width:132px; height:132px; border-radius:50%; border:1px solid rgba(130,246,255,.55); background:radial-gradient(circle,rgba(65,242,255,.2),rgba(4,16,29,.7) 66%); box-shadow:0 8px 28px rgba(0,0,0,.24); }
#touch-joystick::before { content:''; position:absolute; inset:30px; border:1px solid rgba(223,246,255,.26); border-radius:50%; }
#touch-stick { position:absolute; width:52px; height:52px; left:39px; top:39px; border-radius:50%; background:rgba(65,242,255,.46); border:1px solid #bdfaff; box-shadow:0 0 22px rgba(65,242,255,.5); pointer-events:none; transform:translate(var(--jx,0px),var(--jy,0px)); will-change:transform; }
.touch-btn.pressed { transform:scale(.92); background:rgba(65,242,255,.28); }
/* Not-ready answer for an ability tap during cooldown/boss-card states. */
.touch-btn.tap-wait { animation: touchTapWait .34s ease; }
@keyframes touchTapWait { 0% { transform:scale(.9); } 45% { transform:scale(1.06); } 100% { transform:scale(1); } }
body.surface-entry #touch-actions, body.surface-entry #touch-joystick-zone,
body.mode-intro #touch-actions, body.mode-intro #touch-joystick-zone,
body.modal-open #touch-actions, body.modal-open #touch-joystick-zone { pointer-events:none; opacity:0; visibility:hidden; }
body.surface-entry .touch-btn, body.mode-intro .touch-btn, body.modal-open .touch-btn { pointer-events:none; }
body[data-state="playing"] #touch-dash, body[data-state="playing"] #touch-ability { min-width:64px; min-height:64px; }
@media (pointer: coarse) {
  /* On touch there is exactly one visible Ability control. The keyboard shell
     remains available to fine-pointer/keyboard players but never clips a Q. */
  .hud-ability { display:none !important; }
  body[data-state="playing"] #touch-actions { display:flex; }
  body[data-state="playing"] .touch-btn { display: grid; place-items: center; }
  body[data-state="playing"] #touch-joystick-zone { display:block; }
}

@media (pointer: coarse) and (orientation: landscape) {
  body[data-state="playing"], body[data-state="playing"] #hud { touch-action:none; overscroll-behavior:none; }
  /* Lower corners are reserved for hit targets. Read-only HUD is kept in an
     upper safe band, leaving a real 16px visual/action gap at 844x390. */
  #touch-joystick-zone { width:min(34vw, 286px); height:180px; left:max(10px, env(safe-area-inset-left)); bottom:max(8px, env(safe-area-inset-bottom)); }
  #touch-joystick { width:124px; height:124px; top:var(--joy-y, calc(100% - 124px)); }
  #touch-joystick::before { inset:28px; }
  #touch-stick { width:48px; height:48px; left:37px; top:37px; }
  #touch-actions { right:max(18px, env(safe-area-inset-right)); bottom:max(16px, env(safe-area-inset-bottom)); gap:18px; }
  .touch-btn { width:76px; height:76px; }
  #touch-regrip-cue { display:block; left:max(18px, env(safe-area-inset-left)); bottom:max(190px, calc(env(safe-area-inset-bottom) + 188px)); }
  body[data-state="playing"].touch-regrip #touch-regrip-cue { opacity:1; }
  .hud-tl { top:max(12px, env(safe-area-inset-top)); left:max(14px, env(safe-area-inset-left)); gap:3px; max-width:220px; }
  .hud-tl .mode-identity { display:none; }
  .hud-tl #hud-mult { display:block; max-width:178px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; }
  .hud-tl .score-ledger { gap:4px; min-height:15px; }
  .hud-tr { top:max(12px, env(safe-area-inset-top)); right:max(14px, env(safe-area-inset-right)); gap:3px; }
  .hud-tr .hud-row { gap:5px; margin-bottom:2px; }
  .hud-tr .icon-btn { width:30px; height:30px; }
  .hud-tr .hud-value { font-size:22px; }
  .hud-bl { bottom:auto; top:max(116px, calc(env(safe-area-inset-top) + 104px)); left:max(14px, env(safe-area-inset-left)); display:grid; grid-template-columns:auto auto; column-gap:8px; row-gap:4px; align-items:center; max-width:248px; }
  .hud-bl #hud-hearts { grid-column:1; grid-row:1; gap:5px; }
  .hud-bl .dash-meter { grid-column:2; grid-row:1; gap:5px; }
  .hud-bl .dash-track { width:70px; }
  .hud-bl .dash-state, .hud-bl #hud-run-crystals { grid-column:1 / -1; min-height:12px; font-size:9px; letter-spacing:.08em; }
  #boss-bar { width:min(480px, 62vw); }
}

@media (orientation: landscape) and (max-height: 520px) {
  #screen-title { padding:6px 10px; }
  #screen-title .title-wrap { width:min(100%,720px); gap:5px; padding:6px 10px; }
  #screen-title .title-eyebrow { font-size:8px; }
  #screen-title .logo-neon { font-size:24px; }
  #screen-title .logo-abyss { font-size:clamp(52px,14vh,64px); }
  #screen-title .tagline { display:none; }
  #screen-title .menu-panel { width:min(100%,640px); gap:6px; }
  #screen-title .best-chip { min-height:34px; padding:4px 8px; }
  #screen-title .menu-panel .btn { min-height:40px; padding-block:7px; }
  #screen-title .title-config-toggle { min-height:38px; padding:6px 10px; }
  #screen-title .title-secondary-actions .btn { min-height:36px; }
  #screen-title .journey-strip { width:min(100%,560px); grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; max-height:none; overflow:visible; }
  #screen-title:not(.config-open) .journey-strip { display:grid; }
  #screen-title .journey-strip li { display:none; padding:4px 7px; }
  #screen-title .journey-strip li:nth-child(1),#screen-title .journey-strip li:nth-child(4),#screen-title .journey-strip li:nth-child(7) { display:block; }
  #screen-title .journey-strip b { font-size:8px; letter-spacing:.06em; }
  #screen-title .journey-strip span { font-size:9px; }
}

#boss-vault { width:100%; border:1px solid rgba(255,217,74,.32); background:rgba(10,15,29,.72); padding:9px; text-align:center; }
#boss-vault h3 { margin:0; color:var(--gold); font-size:12px; letter-spacing:.16em; }
#boss-vault p { margin:5px 0 8px; color:var(--ink-dim); font-size:10px; }
#boss-vault-list { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:5px; margin-bottom:8px; }
.vault-boss { min-height:48px; padding:5px; border:1px solid rgba(190,225,240,.22); color:var(--ink); background:rgba(7,16,29,.9); font:inherit; font-size:9px; cursor:pointer; }
.vault-boss:disabled { opacity:.35; cursor:not-allowed; }
#bestiary-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; }
.bestiary-replay { min-height:48px; padding:5px; border:1px solid rgba(65,242,255,.3); color:var(--cyan); background:rgba(4,18,31,.75); font:inherit; font-size:10px; cursor:pointer; }

/* ---------- Upgrade Bay ---------- */

.bay-panel { width: min(760px, 94vw); max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.bay-close-sticky { position:sticky; top:0; z-index:2; align-self:center; min-height:48px; box-shadow:0 4px 18px rgba(0,0,0,.32); }
.bay-panel h2 { letter-spacing: .3em; color: var(--gold); text-shadow: 0 0 16px rgba(255,217,74,.45); text-align: center; font-size: clamp(17px, 3vw, 22px); }
.bay-wallet {
  display: flex; align-items: baseline; justify-content: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid rgba(255,217,74,.25); padding: 8px 18px;
  background: rgba(255,217,74,.04);
}
.bay-wallet span { font-size: 12px; color: var(--ink-dim); letter-spacing: .1em; }
.bay-wallet b { font-family: var(--font-num); font-size: 21px; color: var(--gold); }
.bay-score-note { font-size: 10px !important; opacity: .7; }

.bay-tabs { display: flex; gap: 8px; justify-content: center; }
.bay-tab {
  font-family: inherit; background: rgba(8,18,32,.5); border: 1px solid rgba(190,225,240,.15);
  color: var(--ink-dim); padding: 8px 20px; cursor: pointer; font-size: 13px; letter-spacing: .1em;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.bay-tab.active { color: var(--cyan); border-color: var(--line); background: rgba(65,242,255,.08); }

.bay-list { display: flex; flex-direction: column; gap: 9px; }
.bay-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid rgba(190,225,240,.12); background: rgba(6,14,26,.55);
  padding: 10px 14px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
}
.bay-icon {
  flex: none; width: 40px; height: 40px; display: grid; place-items: center;
  color: var(--sw, var(--cyan));
}
.bay-icon svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.bay-info { flex: 1; min-width: 0; }
.bay-info b { display: block; font-size: 14px; letter-spacing: .06em; }
.bay-info small { color: var(--ink-dim); font-size: 11.5px; }
.pip-row { display: flex; gap: 4px; margin-top: 4px; }
.pip { width: 16px; height: 5px; background: rgba(190,225,240,.15); }
.pip.on { background: var(--sw, var(--cyan)); box-shadow: 0 0 6px var(--sw, var(--cyan)); }
.bay-buy {
  flex: none; font-family: inherit; cursor: pointer; min-width: 108px;
  background: rgba(255,217,74,.1); border: 1px solid rgba(255,217,74,.5); color: var(--gold);
  padding: 8px 12px; font-size: 13px; font-family: var(--font-num);
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.bay-buy:hover:not(:disabled) { background: rgba(255,217,74,.25); }
.bay-buy:disabled { opacity: .38; cursor: default; }
.bay-buy.equip { background: rgba(65,242,255,.12); border-color: rgba(65,242,255,.5); color: var(--cyan); }
.bay-buy.equipped { background: rgba(125,255,107,.12); border-color: rgba(125,255,107,.5); color: var(--lime); cursor: default; }
.skin-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.skin-dock {
  position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--sw, var(--cyan));
  background: radial-gradient(120% 95% at 78% 12%, rgba(65,242,255,.13), transparent 62%), linear-gradient(155deg, rgba(9,23,43,.98), rgba(2,7,16,.98));
  padding: 12px; clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}
.skin-dock.equipped { box-shadow: inset 0 0 0 1px rgba(125,255,107,.5), 0 0 28px rgba(65,242,255,.18); }
.skin-stage { display: block; width: 100%; height: 150px; margin-bottom: 7px; border-bottom: 1px solid rgba(190,225,240,.13); background: linear-gradient(180deg, rgba(160,220,255,.06), rgba(1,5,15,.06)); }
.skin-topline { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.skin-topline b { font-size: 14px; letter-spacing: .07em; color: var(--ink); }
.skin-rarity { flex:none; font-family: var(--font-num); font-size: 9px; letter-spacing:.12em; color:var(--sw,var(--cyan)); border:1px solid var(--sw,var(--cyan)); padding:4px 6px; }
.skin-dock p { min-height: 34px; margin: 6px 0 10px; color: rgba(223,246,255,.76); font-size: 11px; line-height: 1.45; }
.skin-signature { display:flex; flex-wrap:wrap; gap:5px; margin-bottom:10px; }
.skin-signature i { font-style:normal; font-size:9px; letter-spacing:.04em; color:var(--ink-dim); border:1px solid rgba(190,225,240,.16); padding:3px 5px; }
.skin-mastery { margin: 0 0 9px; color: var(--ink-dim); font: 10px/1.35 var(--font-num); }
.skin-mastery > span { display:block; margin-bottom:4px; }
.skin-mastery > i { display:block; height:4px; overflow:hidden; background:rgba(190,225,240,.14); }
.skin-mastery > i > b { display:block; height:100%; min-width:2px; background:linear-gradient(90deg,var(--cyan),var(--lime)); box-shadow:0 0 8px var(--cyan); }
.skin-actions { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:7px; }
.skin-dock .bay-buy { width:100%; min-width:0; }
.bay-buy.try { color:var(--cyan); border-color:rgba(65,242,255,.5); background:rgba(65,242,255,.09); font-size:11px; }
.danger { border-color: rgba(255,93,126,.4) !important; color: var(--rose) !important; }

/* ---------- Temp pick modal ---------- */

.temp-panel { text-align: center; }
.temp-panel h3 { letter-spacing: .2em; color: var(--violet); margin-bottom: 16px; font-size: clamp(15px, 2.6vw, 19px); }
.temp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; width: min(640px, 84vw); margin: 0 auto; }
.temp-card {
  cursor: pointer; text-align: center; padding: 18px 14px 14px;
  border: 1px solid rgba(160,107,255,.35);
  background: linear-gradient(160deg, rgba(42,32,102,.35), rgba(8,10,24,.75));
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
  color: var(--ink); font-family: inherit;
}
.temp-card:hover, .temp-card:focus-visible { transform: translateY(-4px); border-color: var(--violet); box-shadow: 0 0 26px -6px var(--violet); outline: none; background: linear-gradient(160deg, rgba(56,42,138,.45), rgba(10,12,28,.8)); }

.bosscard-panel { max-width: min(560px, 92vw); }
.bosscard-panel h3 { color: var(--rose); }
.bosscard-body { text-align: right; }
.boss-portrait { display:block; width:100%; max-height:180px; object-fit:cover; object-position:center; margin:0 0 12px; border:1px solid rgba(110,242,255,.4); }
.card-steps { list-style: none; display: flex; flex-direction: column; gap: 11px; margin-bottom: 14px; counter-reset: step; }
.card-steps li { position: relative; padding-inline-start: 34px; font-size: 14px; line-height: 1.55; color: var(--ink); }
.card-steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; inset-inline-start: 0; top: 1px;
  width: 24px; height: 24px; display: grid; place-items: center;
  font-family: var(--font-num); font-size: 12px; font-weight: 700;
  color: var(--cyan); border: 1px solid var(--line); background: rgba(65,242,255,.07);
}
.card-steps b { color: var(--gold); }
.card-steps em { color: var(--magenta); font-style: normal; font-weight: 700; }
.card-keys { font-size: 12px; color: var(--ink-dim); line-height: 1.8; }
.temp-card .bay-icon { margin: 0 auto 10px; width: 46px; height: 46px; color: var(--violet); }
.temp-card b { display: block; font-size: 15px; margin-bottom: 6px; }
.temp-card small { color: var(--ink-dim); font-size: 12px; line-height: 1.5; display: block; }
.temp-tag { display: inline-block; margin-top: 10px; font-size: 9px; letter-spacing: .3em; color: var(--ink-dim); border: 1px solid rgba(190,225,240,.2); padding: 2px 8px; }

/* ---------- Confirm reset ---------- */

.modal-confirm {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center;
  background: rgba(1,3,8,.72); backdrop-filter: blur(3px);
}
.modal-confirm.hidden { display: none; }
.data-devices { margin-top: 14px; }
.data-devices summary { cursor: pointer; color: var(--cyan); font-weight: 700; letter-spacing: .04em; }
.data-devices[open] summary { margin-bottom: 8px; }
.confirm-panel { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; max-width: 340px; }
.confirm-panel p { color: var(--ink-dim); font-size: 13px; }

.hidden { display: none !important; }

/* ---------- Victory ---------- */

.victory-title {
  letter-spacing: .4em !important; color: var(--gold) !important;
  text-shadow: 0 0 26px rgba(255,217,74,.7) !important;
  font-size: clamp(20px, 4vw, 32px) !important;
  max-inline-size: 100%; text-align: center; overflow-wrap: anywhere;
}
.victory-panel {
  width: min(920px, calc(100vw - 48px)); min-width: 0; gap: 18px;
  background: linear-gradient(165deg, rgba(7,19,33,.985), rgba(1,7,14,.995));
  border-color: rgba(255,217,74,.28);
}
.victory-panel .stats-grid { width: min(100%, 520px); }
.victory-panel > .btn-row { width: 100%; display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 10px; }
.victory-panel > .btn-row .btn { width: 100%; min-width: 0; padding-inline: 18px 38px; font-size: 14px; letter-spacing: .14em; text-indent: .14em; }
.first-badge {
  font-size: 12px; letter-spacing: .2em; color: #04250f;
  background: linear-gradient(90deg, var(--lime), #d8ffe0, var(--lime));
  padding: 6px 18px; box-shadow: 0 0 24px rgba(125,255,107,.5);
}

.bay-note {
  text-align: center; font-size: 13px; color: var(--gold);
  letter-spacing: .08em; padding: 6px;
}
.teach-diagram { margin: 0 0 8px; padding: 5px; border: 1px solid rgba(110,242,255,.28); background: radial-gradient(circle at 20% 50%,rgba(128,246,255,.14),transparent 46%); }
.teach-canonical { display:block; width:100%; height:132px; margin:0 0 9px; border:1px solid rgba(110,242,255,.36); background:#061425; }
.teach-diagram svg { display:block; width:100%; height:76px; }
.teach-lane,.teach-beam { stroke:#80f6ff; stroke-width:3; stroke-dasharray:8 7; fill:none; animation:teachFlow .72s linear infinite; }
.teach-beam { stroke:#c86bff; }
.teach-prism,.teach-medusa { fill:#d9ffff; stroke:#80f6ff; stroke-width:2; animation:teachPulse .85s ease-in-out infinite; }
.teach-medusa { stroke:#c86bff; fill:#f4d9ff; }
.teach-sub { fill:#ffd94a; animation:teachSlide 1.2s ease-in-out infinite; }
.teach-dodge { stroke:#7dff6b; stroke-width:3; fill:none; animation:teachPulse .7s ease-in-out infinite; }
@keyframes teachFlow { to { stroke-dashoffset:-30; } }
@keyframes teachPulse { 50% { opacity:.3; transform:scale(1.18); transform-origin:center; } }
@keyframes teachSlide { 50% { transform:translateY(-18px); } }
.bay-buy.deny-flash { animation: denyShake .35s ease; border-color: var(--rose) !important; color: var(--rose) !important; }
@keyframes denyShake { 0%,100%{transform:none} 25%{transform:translateX(-4px)} 50%{transform:translateX(4px)} 75%{transform:translateX(-3px)} }
.temp-chip b { opacity: .9; }

@media (max-width: 520px) {
  #screen-gameover { overflow:auto; padding:8px; align-items:flex-start; }
  #screen-gameover .over-panel { width:calc(100vw - 16px); min-width:0; margin:auto; gap:8px; padding:12px 10px; }
  #screen-gameover .over-title { font-size:22px; }
  #screen-gameover .stats-grid { width:100%; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px; }
  #screen-gameover .stat.main { grid-column:span 3; margin:0; padding:4px; }
  #screen-gameover .stat { padding:3px 2px; }
  #screen-gameover .stat.main b { font-size:30px; }
  #screen-gameover .career-result { padding:7px 8px; }
  #screen-gameover .career-result-missions { gap:3px; margin-top:5px; }
  #screen-gameover .career-result-missions li { padding:4px 3px; }
  #screen-gameover .btn-row { width:100%; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
  #screen-gameover .btn-row .btn { min-width:0; width:100%; min-height:42px; padding:7px 9px; padding-inline-end:9px; font-size:11px; letter-spacing:.08em; text-indent:.08em; }
  #screen-gameover #btn-bay-over { grid-column:1 / -1; }
  .rank-select { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #boss-bar { top: 124px; width: min(356px, calc(100vw - 28px)); }
  .boss-name { font-size: 10px; letter-spacing: .18em; }
  .boss-cue { font-size: 9px; letter-spacing: .08em; }
  .title-wrap { width: 100%; gap: 9px; padding: 12px 10px; }
  .logo-neon { font-size: 28px; }
  .logo-abyss { font-size: 52px; }
  .tagline { max-width: 300px; font-size: 11px; }
  .menu-panel { width: min(94vw, 350px); gap: 8px; padding: 0; background: none; border: 0; box-shadow: none; }
  .title-config-toggle {
    position: relative; width: 100%; min-height: 56px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px;
    padding: 9px 14px 9px 42px; color: var(--cyan); background: rgba(65,242,255,.07); border: 1px solid rgba(65,242,255,.42);
    font: inherit; cursor: pointer; text-align: start;
  }
  .title-config-toggle span { font: 700 12px/1.25 var(--font-num); letter-spacing: .04em; white-space: nowrap; }
  .title-config-toggle small { color: rgba(223,246,255,.64); font-size: 10px; white-space: nowrap; }
  .title-config-toggle::after { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); margin: 0; }
  #screen-title.config-open .title-config-toggle::after { content: '−'; }
  #screen-title:not(.config-open) #title-config,
  #screen-title:not(.config-open) .journey-strip { display: none; }
  .title-config { width: 100%; display: flex; flex-direction: column; gap: 7px; }
  .best-chip, .nextgoal-chip { font-size: 10px; padding: 5px 9px; }
  .challenge-strip { display: none; }
  .journey-strip { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 4px; width: min(94vw, 360px); max-height: 70px; overflow-y: auto; }
  .journey-strip li { padding: 4px; }
  .journey-strip b { font-size: 8px; letter-spacing: .06em; }
  .journey-strip span { font-size: 9px; }
  .menu-panel .btn { min-width: 230px; padding: 9px 13px; font-size: 13px; }
  .mode-select { grid-template-columns: 1fr; gap: 5px; margin-top: 2px; }
  .mode-card { min-height: 54px; padding: 8px 10px; text-align: start; }
  .mode-card b { font-size: 11px; }
  .mode-card span { font-size: 10px; line-height: 1.25; color: rgba(223,246,255,.82); }
  .rank-select { gap: 4px; padding: 5px; }
  .rank-card { min-height: 42px; padding: 5px 2px; }
  .rank-card b { font-size: 9.5px; }
  .rank-card span { font-size: 8.5px; }
  .title-secondary-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .title-secondary-actions .btn { min-width: 0; width: 100%; padding: 9px 4px; padding-inline-end: 4px; font-size: 10.5px; letter-spacing: .06em; text-indent: .06em; white-space: nowrap; }
  .title-secondary-actions .key-hint { display: none; }
  .victory-panel { width: calc(100vw - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 20px 16px; gap: 14px; }
  .victory-title { font-size: clamp(18px, 6vw, 26px) !important; letter-spacing: clamp(.10em, 1.2vw, .22em) !important; text-indent: 0; }
  .victory-panel .stats-grid { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .victory-panel .stat.main { grid-column: 1 / -1; margin-bottom: 2px; padding-bottom: 10px; }
  .victory-panel .stat { min-width: 0; gap: 2px; padding: 5px 2px; }
  .victory-panel .stat span { font-size: 8px; letter-spacing: .14em; }
  .victory-panel .stat b { max-width: 100%; font-size: 15px; overflow-wrap: anywhere; }
  .victory-panel .stat.main b { font-size: clamp(28px, 10vw, 40px); }
  .victory-panel > .btn-row { grid-template-columns: 1fr; gap: 8px; }
  .victory-panel > .btn-row .btn { width: 100%; min-width: 0; padding: 10px 18px; padding-inline-end: 40px; font-size: 12.5px; letter-spacing: .12em; text-indent: .12em; }
  .victory-panel .first-badge { max-width: 100%; font-size: 10px; letter-spacing: .12em; text-align: center; }
  #hud-powers, .hud-rail { display: none; }
  .hud-tl { gap:5px; }
  .score-ledger { gap:5px; }
  .score-ledger::before { font-size:8px; }
  .skin-gallery { grid-template-columns: 1fr; }
  .skin-stage { height: 132px; }
  .skin-actions { grid-template-columns: 1fr; }
  .bay-panel { width: 96vw; padding: 18px 14px; }
  .bay-tabs { gap: 4px; }
  .bay-tab { padding: 8px 10px; font-size: 12px; }
  .bay-item { padding: 9px; gap: 8px; }
  .bay-buy { min-width: 76px; padding: 8px 7px; }
}

@media (pointer: coarse) and (max-width: 520px) {
  .hud-bl { top:max(112px, calc(env(safe-area-inset-top) + 98px)); bottom:auto; left:max(14px, env(safe-area-inset-left)); gap:5px; max-width:172px; }
}

@media (pointer: coarse) and (orientation: portrait) {
  .orientation-hint:not([hidden]) { display:inline-flex; }
  .hud-tl { top:max(12px, env(safe-area-inset-top)); left:max(14px, env(safe-area-inset-left)); max-width:190px; }
  .hud-tl #hud-mult { max-width:174px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; }
  .hud-tr { top:max(12px, env(safe-area-inset-top)); right:max(14px, env(safe-area-inset-right)); }
  .hud-tr .hud-row { gap:5px; margin-bottom:3px; }
}
