/* ==========================================================================
   INVADER REVERSE — UI / HUD layer
   1970s arcade cabinet x modern neon SF. Mobile-first, safe-area aware.
   The HUD floats: nothing here is ever an opaque full-screen layer in play.
   ========================================================================== */

:root {
  /* palette (mirrors src/game/constants.js PALETTE) */
  --cyan: #35f0ff;
  --cyan-lo: #16a7c4;
  --cyan-dk: #073b4c;
  --pink: #ff3d7f;
  --pink-lo: #b81b50;
  --amber: #ffd166;
  --lime: #7cff4d;
  --violet: #b388ff;
  --blue: #4d9dff;
  --red: #ff2b4e;

  --ink: #04050c;
  --ink-2: #070b16;
  --panel: linear-gradient(178deg, rgba(11, 20, 38, .84), rgba(5, 8, 17, .92));
  --panel-solid: rgba(6, 10, 20, .9);
  --glass: rgba(7, 12, 24, .62);
  --line: rgba(102, 214, 255, .22);
  --line-hi: rgba(102, 214, 255, .46);

  --txt: #dff4ff;
  --txt-2: #93b6c9;
  --txt-3: #5d7c8f;

  --f: ui-monospace, SFMono-Regular, "SF Mono", "Roboto Mono", Menlo, Consolas,
       "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, monospace;
  --f-d: "DIN Alternate", "Bahnschrift", "Arial Narrow", var(--f);

  /* type scale — clamp keeps phones and 1080p desktops both sane */
  --fs-2xs: clamp(8.5px, 2.1vmin, 10.5px);
  --fs-xs:  clamp(9.5px, 2.4vmin, 12px);
  --fs-sm:  clamp(11px, 2.9vmin, 13.5px);
  --fs-md:  clamp(12.5px, 3.4vmin, 15.5px);
  --fs-lg:  clamp(15px, 4.2vmin, 20px);
  --fs-xl:  clamp(19px, 5.6vmin, 28px);
  --fs-2xl: clamp(26px, 8vmin, 44px);

  --sa-t: env(safe-area-inset-top, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  --sa-r: env(safe-area-inset-right, 0px);

  --ease: cubic-bezier(.16, .84, .44, 1);
  --r: 3px;
}

/* --- page shell ---------------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: #04050c;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--f);
  color: var(--txt);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* 共通ヘッダー（--sgh-top）とフッター広告（--ad-space）のぶんだけ描画領域を縮める。
   キャンバスも入力も #app の実サイズを基準にするので、ここを縮めれば全部が追従する。 */
#app {
  position: fixed;
  top: var(--sgh-top, 0px);
  right: 0;
  bottom: var(--ad-space, 0px);
  left: 0;
  overflow: hidden;
}
/* 共通ヘッダーが出ているときは上のセーフエリアはヘッダーが吸収している */
:root:has(#sgh-header) #app { --sa-t: 0px; }
/* 下の広告が出ているときは下のセーフエリアを --ad-space（広告＋セーフエリア）が吸収している */
html.has-ad-banner #app { --sa-b: 0px; }

#gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: none;
}

/* The drag surface owned by src/core/input.js. Full-bleed, below the UI so
   HUD buttons win their own presses, but every non-button pixel of the UI is
   pointer-events:none so a drag over the HUD still reaches this layer. */
#touch-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#ui {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  --touch-h: 6px;
  contain: layout style;
}

#ui.touch-on[data-screen="hud"] { --touch-h: 116px; }

.sr-live {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

.hidden { display: none !important; }

/* ==========================================================================
   shared atoms
   ========================================================================== */

.tag {
  font-size: var(--fs-2xs);
  letter-spacing: .16em;
  font-weight: 700;
  padding: 1px 4px;
  border: 1px solid currentColor;
  border-radius: 2px;
  opacity: .85;
  line-height: 1.25;
  white-space: nowrap;
}
.tag--cy { color: var(--cyan); }
.tag--pk { color: var(--pink); }
.tag--am { color: var(--amber); }
.tag--bl { color: var(--blue); }

.meter {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, .09);
  overflow: hidden;
  position: relative;
  min-width: 34px;
}
.meter-f {
  display: block;
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 55%, transparent), var(--c));
  box-shadow: 0 0 8px var(--c);
  transition: width .3s var(--ease);
}

.pips-lv { display: inline-flex; gap: 3px; align-items: center; }
.lp {
  width: 7px; height: 7px;
  border: 1px solid rgba(120, 200, 230, .4);
  transform: rotate(45deg);
  border-radius: 1px;
}
.lp.on {
  background: var(--c, var(--cyan));
  border-color: var(--c, var(--cyan));
  box-shadow: 0 0 7px var(--c, var(--cyan));
}

.bitmark { display: block; height: auto; image-rendering: pixelated; }
.mark-inv { width: clamp(38px, 12vmin, 66px); filter: drop-shadow(0 0 10px rgba(255, 61, 127, .65)); }
.mark-ship { width: clamp(26px, 8.4vmin, 46px); filter: drop-shadow(0 0 10px rgba(53, 240, 255, .7)); }

.data-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 209, 102, .38);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(60, 42, 8, .5), rgba(12, 9, 4, .6));
  box-shadow: 0 0 16px rgba(255, 209, 102, .12), inset 0 1px 0 rgba(255, 255, 255, .06);
  color: var(--amber);
  white-space: nowrap;
}
.dc-g { font-size: var(--fs-sm); opacity: .9; }
.dc-v { font-size: var(--fs-md); font-weight: 700; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.dc-l { font-size: var(--fs-2xs); color: rgba(255, 209, 102, .6); letter-spacing: .1em; }
.data-chip.big .dc-v { font-size: var(--fs-lg); }

.note {
  margin: 0;
  font-size: var(--fs-2xs);
  color: var(--txt-3);
  line-height: 1.6;
  letter-spacing: .02em;
}

/* Japanese prose wraps at phrase boundaries where the engine supports it, so a
   word like 「スコア」 is never split across two lines. `line-break: strict`
   keeps kinsoku correct everywhere else; unsupported values are simply ignored. */
.note, .empty, .toast, .load-tip, .logo-tag, .choice-rule, .act-eff, .card-now,
.mr-desc, .mr-warn, .cx-d, .cx-x, .warn-hd, .gp-legend, .key-d b, .ds-d,
.go-data .brk-l, .set-lab b, .banner-s,
.card-name b, .cx-n b, .mr-name b, .lo-n b, .act-t b, .btn-l b, .tab b {
  line-break: strict;
  word-break: auto-phrase;
}

.empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--txt-3);
  font-size: var(--fs-sm);
  letter-spacing: .1em;
  border: 1px dashed rgba(120, 180, 210, .18);
  border-radius: var(--r);
}

.gold { color: var(--amber); }

/* ==========================================================================
   HUD
   ========================================================================== */

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
  transition: opacity .18s var(--ease), filter .18s var(--ease);
}
.hud.off { display: none; }
/* Under an overlay screen the HUD is context, not content — it must never
   compete with the screen's own header text. */
.hud.behind { opacity: .16; filter: saturate(.4) blur(1px); }

.danger-vig {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s linear;
  box-shadow: inset 0 0 min(26vmin, 200px) rgba(255, 43, 78, .85);
}
.danger-vig.on { opacity: calc(var(--danger, 0) * .85); }
.danger-vig.peak { animation: dangerPulse 1s ease-in-out infinite; }
@keyframes dangerPulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.7); } }

/* --- top ---------------------------------------------------------------- */

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: calc(var(--sa-t) + 8px) calc(var(--sa-r) + 9px) 0 calc(var(--sa-l) + 9px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-r1 { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }

.hp-block { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hp-row { display: flex; align-items: center; gap: 6px; }
.hp-row--sh.hidden { display: none; }

.pips { display: flex; gap: 3px; align-items: center; }
.pip {
  width: clamp(8px, 2.4vmin, 12px);
  height: clamp(13px, 3.6vmin, 18px);
  border: 1px solid rgba(53, 240, 255, .35);
  border-radius: 1px;
  background: rgba(53, 240, 255, .06);
  transition: background .16s var(--ease), box-shadow .16s var(--ease);
}
.pip.on {
  background: linear-gradient(180deg, #b7fbff, var(--cyan));
  border-color: #c9fdff;
  box-shadow: 0 0 9px rgba(53, 240, 255, .8);
}
.pips--sh .pip { border-color: rgba(77, 157, 255, .35); background: rgba(77, 157, 255, .06); height: clamp(9px, 2.6vmin, 13px); }
.pips--sh .pip.on {
  background: linear-gradient(180deg, #cfe4ff, var(--blue));
  border-color: #dbeaff;
  box-shadow: 0 0 9px rgba(77, 157, 255, .8);
}
.hud.critical .hp-row:not(.hp-row--sh) .pip.on { animation: critPip .7s ease-in-out infinite; }
@keyframes critPip { 0%, 100% { box-shadow: 0 0 9px rgba(255, 43, 78, .9); background: var(--red); } 50% { box-shadow: 0 0 3px rgba(255, 43, 78, .4); background: #7a1024; } }
.pips.shake { animation: pipShake .22s var(--ease); }
@keyframes pipShake { 0% { transform: translateX(0); } 25% { transform: translateX(-4px); } 60% { transform: translateX(3px); } 100% { transform: translateX(0); } }

.score-block { display: flex; align-items: flex-start; gap: 8px; }
.score-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }

.score {
  font-family: var(--f-d);
  font-size: clamp(20px, 6vmin, 38px);
  line-height: 1;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(255, 209, 102, .45), 0 0 30px rgba(255, 209, 102, .18);
  letter-spacing: .02em;
  transition: transform .12s var(--ease);
}
.score.bump { animation: scoreBump .16s var(--ease); }
@keyframes scoreBump { 0% { transform: scale(1.07); } 100% { transform: scale(1); } }

.odo { display: inline-flex; gap: 1px; line-height: 1; }
.odo-d { display: block; width: .60em; height: 1em; overflow: hidden; position: relative; }
.odo-d.z { opacity: .14; }
.odo-r { display: block; transform: translateY(calc(var(--d, 0) * -1em)); transition: transform .24s var(--ease); }
.odo-r i { display: block; height: 1em; line-height: 1em; text-align: center; font-style: normal; }

.combo {
  display: flex; align-items: baseline; gap: 6px;
  opacity: 0;
  transition: opacity .16s var(--ease);
  color: var(--cyan);
}
.combo.show { opacity: 1; }
.combo-x {
  font-family: var(--f-d);
  font-size: var(--fs-lg);
  font-weight: 700;
  display: inline-block;
  text-shadow: 0 0 12px currentColor;
}
.combo-n { font-size: var(--fs-2xs); letter-spacing: .12em; color: var(--txt-2); }
.combo.hot { color: var(--amber); }
.combo.blaze { color: var(--pink); }
.combo.pulse .combo-x { animation: comboPulse .22s var(--ease); }
@keyframes comboPulse { 0% { transform: scale(1.45); filter: brightness(1.7); } 100% { transform: scale(1); filter: none; } }

.icon-btn {
  pointer-events: auto;
  touch-action: manipulation;
  width: 44px; height: 44px;
  min-width: 44px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--glass);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  padding: 0;
  transition: border-color .14s, box-shadow .14s, transform .1s;
}
.icon-btn:active, .icon-btn.is-down { transform: scale(.94); border-color: var(--cyan); }
.icon-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.icon-pause {
  width: 13px; height: 15px;
  border-left: 4px solid var(--cyan);
  border-right: 4px solid var(--cyan);
  box-shadow: 0 0 9px rgba(53, 240, 255, .45);
}

/* --- wave / remaining --------------------------------------------------- */

.wave-row { display: flex; align-items: center; gap: 8px; }
.wavechip { display: flex; align-items: baseline; gap: 5px; flex: 0 0 auto; max-width: 52%; }
.wave-n { font-family: var(--f-d); font-size: var(--fs-md); color: var(--pink); text-shadow: 0 0 10px rgba(255, 61, 127, .5); }
.wave-name {
  font-size: var(--fs-2xs);
  color: var(--txt-2);
  letter-spacing: .06em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ebar {
  flex: 1 1 auto;
  height: 5px;
  background: rgba(255, 61, 127, .13);
  border: 1px solid rgba(255, 61, 127, .22);
  border-radius: 3px;
  overflow: hidden;
  min-width: 40px;
}
.ebar-f {
  display: block; height: 100%;
  background: linear-gradient(90deg, rgba(255, 61, 127, .55), var(--pink));
  box-shadow: 0 0 10px rgba(255, 61, 127, .7);
  transition: width .25s var(--ease);
}
.ebar-f.low { background: linear-gradient(90deg, rgba(255, 209, 102, .6), var(--amber)); box-shadow: 0 0 10px rgba(255, 209, 102, .7); }
.ecount { font-size: var(--fs-2xs); color: var(--txt-2); letter-spacing: .06em; flex: 0 0 auto; }

/* --- area progress ------------------------------------------------------- */
/* Where this run sits inside the 5 x 10 structure. The pips are the part that
   survives a 320px phone; the numerals are the part that survives a glance. */
.areachip {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 1px 6px 2px;
  border: 1px solid rgba(102, 214, 255, .22);
  border-radius: 2px;
  background: rgba(6, 14, 26, .5);
}
.ar-l { font-size: 8px; letter-spacing: .18em; color: var(--txt-3); }
.ar-v { font-family: var(--f-d); font-size: var(--fs-xs); line-height: 1.2; color: var(--cyan); text-shadow: 0 0 9px rgba(53, 240, 255, .5); }
.ar-t { font-style: normal; font-size: 8.5px; color: var(--txt-3); text-shadow: none; }
.ar-pips { display: flex; align-items: center; gap: 2px; }
.ap {
  width: 5px; height: 5px;
  border-radius: 50%;
  border: 1px solid rgba(53, 240, 255, .3);
  transition: background .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.ap.done { background: rgba(53, 240, 255, .5); border-color: rgba(53, 240, 255, .5); }
.ap.on {
  background: var(--cyan);
  border-color: #cbfdff;
  box-shadow: 0 0 8px var(--cyan);
  transform: scale(1.3);
}
.areachip.final { border-color: rgba(255, 209, 102, .5); background: rgba(30, 21, 4, .58); }
.areachip.final .ar-v { color: var(--amber); text-shadow: 0 0 10px rgba(255, 209, 102, .6); }
.areachip.final .ap.done { background: rgba(255, 209, 102, .5); border-color: rgba(255, 209, 102, .5); }
.areachip.final .ap.on { background: var(--amber); border-color: #ffeab4; box-shadow: 0 0 10px var(--amber); }
.areachip.bump { animation: areaBump .5s var(--ease); }
@keyframes areaBump {
  0% { transform: scale(1); }
  30% { transform: scale(1.12); box-shadow: 0 0 20px rgba(53, 240, 255, .5); }
  100% { transform: scale(1); }
}

/* --- boss bar ------------------------------------------------------------ */
.bossbar {
  display: none;
  flex-direction: column;
  gap: 4px;
  align-self: center;
  width: min(100%, 520px);
  padding: 5px 8px 6px;
  border: 1px solid rgba(255, 61, 127, .3);
  border-left: 3px solid var(--pink);
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(58, 6, 26, .74), rgba(5, 8, 16, .68));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.bossbar.show { display: flex; }
.bossbar.in { animation: bossIn .34s var(--ease); }
@keyframes bossIn {
  0% { opacity: 0; transform: translateY(-8px) scaleY(.7); }
  100% { opacity: 1; transform: none; }
}

.bb-hd { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.bb-tag {
  flex: 0 0 auto;
  font-size: 8px;
  letter-spacing: .18em;
  padding: 1px 5px;
  border: 1px solid var(--pink);
  border-radius: 2px;
  color: var(--pink);
}
.bb-n {
  font-family: var(--f-d);
  font-size: var(--fs-sm);
  letter-spacing: .13em;
  color: #fff;
  text-shadow: 0 0 12px rgba(255, 61, 127, .85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 0 1 auto;
}
.bb-t {
  font-size: 8px;
  letter-spacing: .14em;
  color: var(--txt-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.bb-p { flex: 0 0 auto; font-family: var(--f-d); font-size: var(--fs-xs); color: var(--pink); font-variant-numeric: tabular-nums; }

.bb-track {
  height: 9px;
  border: 1px solid rgba(255, 61, 127, .3);
  border-radius: 2px;
  background: rgba(255, 61, 127, .1);
  overflow: hidden;
}
.bb-f {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, rgba(255, 61, 127, .5), #ff6ea1 62%, #ffd9e5);
  box-shadow: 0 0 14px rgba(255, 61, 127, .75);
  transition: width .16s linear;
}
.bossbar.low .bb-p { color: var(--amber); }
.bossbar.low .bb-f { background: linear-gradient(90deg, rgba(255, 209, 102, .55), var(--amber) 70%, #fff2cf); box-shadow: 0 0 14px rgba(255, 209, 102, .7); }
.bossbar.crit .bb-p { color: var(--red); }
.bossbar.crit .bb-f { background: linear-gradient(90deg, var(--red), #ffb1c0); box-shadow: 0 0 16px rgba(255, 43, 78, .9); }
.bossbar.crit .bb-track { animation: bossCrit .62s ease-in-out infinite; }
@keyframes bossCrit { 0%, 100% { border-color: rgba(255, 43, 78, .35); } 50% { border-color: rgba(255, 43, 78, .95); } }

.bb-noderow { display: flex; align-items: center; gap: 6px; }
.bb-noderow.hidden { display: none; }
.bb-nl { font-size: 8px; letter-spacing: .2em; color: var(--txt-3); flex: 0 0 auto; }
.bb-nc { font-size: 8.5px; color: var(--txt-2); font-variant-numeric: tabular-nums; margin-left: auto; flex: 0 0 auto; }
.bb-nodes { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; min-width: 0; }
.bn {
  width: 8px; height: 8px;
  transform: rotate(45deg);
  border: 1px solid var(--pink);
  background: rgba(255, 61, 127, .6);
  box-shadow: 0 0 7px rgba(255, 61, 127, .65);
  transition: background .2s var(--ease), box-shadow .2s var(--ease), opacity .2s var(--ease);
}
/* a destroyed node has stripped an ability off the boss — it must read as gone */
.bn.dead { background: transparent; border-color: rgba(120, 136, 156, .45); box-shadow: none; opacity: .45; }
.bn.blown { animation: nodeBlown .42s var(--ease); }
@keyframes nodeBlown {
  0% { transform: rotate(45deg) scale(2.1); box-shadow: 0 0 18px #fff; background: #fff; opacity: 1; }
  100% { transform: rotate(45deg) scale(1); }
}
.bb-noderow.stripped .bb-nc { color: var(--lime); }

/* the wave-50 boss is the only one that ends the run — it gets its own key */
.bossbar.final {
  border-color: rgba(255, 209, 102, .5);
  border-left-color: var(--amber);
  background: linear-gradient(90deg, rgba(54, 34, 4, .8), rgba(28, 8, 40, .7));
  box-shadow: 0 0 26px rgba(255, 209, 102, .16), inset 0 0 22px rgba(179, 136, 255, .12);
}
.bossbar.final .bb-tag { border-color: var(--amber); color: var(--amber); animation: finalTag 1.5s ease-in-out infinite; }
@keyframes finalTag { 0%, 100% { box-shadow: 0 0 0 rgba(255, 209, 102, 0); } 50% { box-shadow: 0 0 14px rgba(255, 209, 102, .6); } }
.bossbar.final .bb-n { letter-spacing: .2em; text-shadow: 0 0 10px var(--amber), 0 0 28px rgba(179, 136, 255, .8); }
.bossbar.final .bb-t { color: rgba(255, 209, 102, .6); }
.bossbar.final .bb-p { color: var(--amber); }
.bossbar.final .bb-track { height: 13px; border-color: rgba(255, 209, 102, .45); background: rgba(179, 136, 255, .1); }
.bossbar.final .bb-f { background: linear-gradient(90deg, rgba(179, 136, 255, .8), var(--amber) 58%, #fffaf0); box-shadow: 0 0 18px rgba(255, 209, 102, .7); }
.bossbar.final.crit .bb-f { background: linear-gradient(90deg, var(--violet), var(--red) 55%, #fff); }
.bossbar.final .bn { border-color: var(--amber); background: rgba(255, 209, 102, .62); box-shadow: 0 0 8px rgba(255, 209, 102, .75); }
.bossbar.final .bn.dead { background: transparent; border-color: rgba(120, 136, 156, .45); box-shadow: none; }

/* during a boss the enemy-remaining bar is meaningless (escorts against a
   total of one) and the wave name just repeats the boss name — the boss bar
   owns the row instead */
.hud.boss .ebar,
.hud.boss .ecount,
.hud.boss .wave-name { display: none; }

/* --- evolution ticker ---------------------------------------------------- */

.evo {
  position: absolute;
  right: calc(var(--sa-r) + 9px);
  top: 31%;
  width: clamp(132px, 43vw, 214px);
  padding: 7px 8px 8px;
  border: 1px solid rgba(255, 61, 127, .2);
  border-left: 2px solid rgba(255, 61, 127, .55);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(28, 6, 18, .58), rgba(6, 5, 12, .62));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  pointer-events: none;
  /* hidden by default: it only slides in when the swarm changes (HUD.peekEvo) */
  opacity: 0;
  visibility: hidden;
  transform: translateX(10px);
  transition: opacity .22s var(--ease), transform .22s var(--ease), visibility 0s linear .22s;
}
.evo.show {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease), visibility 0s;
}
.hud.bannering .evo { opacity: .1; }
.evo-h { display: flex; align-items: baseline; gap: 5px; margin-bottom: 6px; flex-wrap: wrap; }
.evo-t { font-size: var(--fs-2xs); letter-spacing: .2em; color: var(--pink); font-weight: 700; text-shadow: 0 0 10px rgba(255, 61, 127, .5); }
.evo-sub { font-size: var(--fs-2xs); color: var(--txt-3); }
.evo-gen { margin-left: auto; font-size: var(--fs-2xs); color: var(--txt-3); letter-spacing: .08em; }
.evo-list { display: flex; flex-direction: column; gap: 4px; }
.evo-empty { font-size: var(--fs-2xs); color: var(--txt-3); letter-spacing: .1em; text-align: center; padding: 3px 0; }

.evo-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  grid-template-rows: auto 3px;
  gap: 2px 5px;
  align-items: center;
}
.evo-row.in { animation: evoIn .2s var(--ease) backwards; }
@keyframes evoIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.evo-row.bump { animation: evoBump .3s var(--ease); }
@keyframes evoBump { 0% { filter: brightness(2.4); } 100% { filter: none; } }
.evo-g { grid-row: 1; color: var(--c); font-size: var(--fs-sm); text-align: center; text-shadow: 0 0 8px var(--cg); line-height: 1; }
.evo-n { grid-row: 1; min-width: 0; display: flex; align-items: baseline; gap: 4px; overflow: hidden; }
.evo-n b { font-size: var(--fs-2xs); font-weight: 700; color: var(--txt); white-space: nowrap; }
.evo-n i { font-size: 8px; font-style: normal; color: var(--txt-3); letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evo-lv { grid-row: 1; font-size: var(--fs-2xs); color: var(--c); font-weight: 700; text-shadow: 0 0 8px var(--cg); }
.evo-b { grid-row: 2; grid-column: 1 / -1; height: 3px; background: rgba(255, 255, 255, .08); border-radius: 2px; overflow: hidden; }
.evo-bf { display: block; height: 100%; width: 0; background: var(--c); box-shadow: 0 0 7px var(--cg); transition: width .35s var(--ease); }

/* --- event chip ---------------------------------------------------------- */

.event-chip {
  position: absolute;
  left: 50%;
  top: calc(var(--sa-t) + 112px);
  transform: translate(-50%, -8px);
  display: none;
  align-items: center;
  gap: 8px;
  max-width: min(88vw, 460px);
  padding: 6px 12px;
  border: 1px solid var(--c, var(--amber));
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(10, 14, 26, .88), rgba(4, 6, 14, .9));
  box-shadow: 0 0 22px var(--cg, rgba(255, 209, 102, .4));
  pointer-events: none;
}
.event-chip.show { display: flex; }
.event-chip.in { animation: evChip .22s var(--ease); }
@keyframes evChip { from { opacity: 0; transform: translate(-50%, -20px); } to { opacity: 1; transform: translate(-50%, -8px); } }
.ev-mark { color: var(--c, var(--amber)); font-size: var(--fs-md); animation: evBlink 1.2s steps(2) infinite; }
@keyframes evBlink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.ev-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ev-name { font-size: var(--fs-sm); font-weight: 700; color: var(--c, var(--amber)); letter-spacing: .1em; }
.ev-desc { font-size: var(--fs-2xs); color: var(--txt-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- banner -------------------------------------------------------------- */

.banner {
  position: absolute;
  left: 0; right: 0;
  top: 34%;
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}
.banner.show { animation: bannerIn .22s var(--ease) forwards; visibility: visible; }
@keyframes bannerIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
.banner-in {
  position: relative;
  padding: 10px clamp(18px, 7vw, 54px);
  text-align: center;
  background: linear-gradient(90deg, transparent, rgba(6, 12, 24, .88) 12%, rgba(6, 12, 24, .88) 88%, transparent);
  border-top: 1px solid rgba(255, 61, 127, .55);
  border-bottom: 1px solid rgba(255, 61, 127, .55);
  box-shadow: 0 0 40px rgba(255, 61, 127, .22);
  max-width: 96vw;
}
.banner-t {
  font-family: var(--f-d);
  font-size: var(--fs-xl);
  letter-spacing: .16em;
  color: #fff;
  text-shadow: 0 0 14px var(--pink), 0 0 34px rgba(255, 61, 127, .7);
  white-space: nowrap;
}
.banner-s { font-size: var(--fs-xs); letter-spacing: .18em; color: var(--txt-2); margin-top: 3px; }
.banner-s.hidden { display: none; }

/* --- bottom rail --------------------------------------------------------- */

.hud-bottom {
  position: absolute;
  left: calc(var(--sa-l) + 9px);
  right: calc(var(--sa-r) + 9px);
  bottom: calc(var(--sa-b) + var(--touch-h));
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: bottom .2s var(--ease);
}
.hud-b-row { display: flex; align-items: center; gap: 7px; min-width: 0; }

.wp-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--c, var(--cyan));
  border-radius: var(--r);
  background: rgba(6, 12, 24, .6);
  color: var(--c, var(--cyan));
  flex: 0 0 auto;
}
.wp-g { font-size: var(--fs-sm); text-shadow: 0 0 8px var(--cg, rgba(53, 240, 255, .5)); }
.wp-n { font-size: var(--fs-2xs); letter-spacing: .12em; font-weight: 700; }

.cores { display: flex; gap: 4px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.core-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px 2px 5px;
  border: 1px solid var(--c);
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(0, 0, 0, .3));
  box-shadow: 0 0 10px var(--cg);
  flex: 0 0 auto;
  animation: chipIn .18s var(--ease) backwards;
}
@keyframes chipIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.cc-g { color: var(--c); font-size: var(--fs-sm); line-height: 1; text-shadow: 0 0 8px var(--cg); }
.cc-l { font-size: var(--fs-2xs); color: var(--txt); opacity: .85; font-weight: 700; }
.core-empty { font-size: var(--fs-2xs); color: var(--txt-3); letter-spacing: .14em; align-self: center; }

.hackbar {
  position: relative;
  height: 16px;
  border: 1px solid rgba(53, 240, 255, .28);
  border-radius: var(--r);
  background: rgba(4, 10, 20, .66);
  overflow: hidden;
}
.hk-track { position: absolute; inset: 0; display: block; }
.hk-f {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0;
  background: linear-gradient(90deg, rgba(53, 240, 255, .35), rgba(53, 240, 255, .8));
  box-shadow: 0 0 14px rgba(53, 240, 255, .6);
  transition: width .12s linear;
}
.hk-txt {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 7px;
  font-size: var(--fs-2xs);
  letter-spacing: .22em;
  color: #dff6ff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}
.hk-l { font-weight: 700; }
.hk-p { letter-spacing: .06em; color: var(--txt-2); }
.hackbar.ready { border-color: var(--cyan); box-shadow: 0 0 18px rgba(53, 240, 255, .5); }
.hackbar.ready .hk-l { color: #fff; animation: readyBlink .8s steps(2) infinite; }
.hackbar.active { border-color: var(--lime); }
.hackbar.active .hk-f { background: linear-gradient(90deg, rgba(124, 255, 77, .4), rgba(124, 255, 77, .85)); box-shadow: 0 0 16px rgba(124, 255, 77, .6); }
.hackbar.active .hk-l { color: #d9ffcb; }
@keyframes readyBlink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.hackbar.flash { animation: hkFlash .3s var(--ease); }
@keyframes hkFlash { 0% { filter: brightness(2.6); } 100% { filter: none; } }

.fps {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--sa-t) + 2px);
  font-size: 9px;
  letter-spacing: .1em;
  color: rgba(120, 160, 180, .45);
  display: none;
}
.fps.show { display: block; }

/* ==========================================================================
   touch controls
   ========================================================================== */

.touch {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.touch.off { display: none; }

.tbtn {
  pointer-events: auto;
  touch-action: none;
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-hi);
  background: radial-gradient(circle at 50% 35%, rgba(20, 40, 62, .8), rgba(4, 8, 16, .82));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--cyan);
  cursor: pointer;
  transition: transform .09s var(--ease), border-color .14s, box-shadow .18s;
  -webkit-user-select: none; user-select: none;
}
.tbtn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.tbtn.is-down { transform: scale(.93); }

.tbtn--hack {
  right: calc(var(--sa-r) + 14px);
  bottom: calc(var(--sa-b) + 12px);
  width: 84px; height: 84px;
  box-shadow: 0 0 24px rgba(53, 240, 255, .16), inset 0 0 20px rgba(53, 240, 255, .08);
}
.tb-ring {
  position: absolute; inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from -90deg, var(--cyan) calc(var(--g, 0) * 360deg), rgba(53, 240, 255, .09) 0);
  -webkit-mask: radial-gradient(circle, transparent 0 60%, #000 61%);
  mask: radial-gradient(circle, transparent 0 60%, #000 61%);
  filter: drop-shadow(0 0 6px rgba(53, 240, 255, .5));
  pointer-events: none;
}
.tb-core { display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.05; }
.tb-lab { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .16em; text-shadow: 0 0 10px rgba(53, 240, 255, .55); }
.tb-sub { font-size: 9px; letter-spacing: .1em; color: var(--txt-2); min-height: 10px; }
.tbtn--hack.ready {
  border-color: var(--cyan);
  box-shadow: 0 0 34px rgba(53, 240, 255, .55), inset 0 0 26px rgba(53, 240, 255, .18);
  animation: hackReady 1.15s ease-in-out infinite;
}
.tbtn--hack.ready .tb-sub { color: var(--cyan); }
@keyframes hackReady {
  0%, 100% { box-shadow: 0 0 26px rgba(53, 240, 255, .38), inset 0 0 20px rgba(53, 240, 255, .12); }
  50% { box-shadow: 0 0 46px rgba(53, 240, 255, .72), inset 0 0 30px rgba(53, 240, 255, .26); }
}
.tbtn--hack.active { border-color: var(--lime); color: var(--lime); }
.tbtn--hack.active .tb-ring { background: conic-gradient(from -90deg, var(--lime) calc(var(--g, 0) * 360deg), rgba(124, 255, 77, .1) 0); }
.tbtn--hack.active .tb-sub { color: var(--lime); }

.dpad {
  position: absolute;
  left: calc(var(--sa-l) + 12px);
  bottom: calc(var(--sa-b) + 12px);
  display: flex;
  gap: 10px;
}
.dpad.off { display: none; }
.tbtn--dir {
  position: relative;
  width: 62px; height: 62px;
  font-size: var(--fs-lg);
}
.tb-arrow { text-shadow: 0 0 10px rgba(53, 240, 255, .5); }

.drag-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sa-b) + var(--touch-h) + 76px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease);
}
.drag-hint.show { opacity: 1; }
.dh-track {
  position: relative;
  width: clamp(120px, 40vw, 190px);
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(53, 240, 255, .35), transparent);
}
.dh-thumb {
  position: absolute; top: 50%; left: 0;
  width: 22px; height: 22px;
  margin-top: -11px; margin-left: -11px;
  border-radius: 50%;
  border: 1px solid rgba(53, 240, 255, .7);
  background: rgba(53, 240, 255, .16);
  box-shadow: 0 0 16px rgba(53, 240, 255, .5);
  animation: dhSlide 2.1s ease-in-out infinite;
}
@keyframes dhSlide { 0%, 100% { left: 12%; } 50% { left: 88%; } }
/* The hint sits over the playfield, whose brightness is unpredictable — it
   carries its own small scrim so it is legible without hiding the action. */
.dh-txt {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 13px;
  border: 1px solid rgba(53, 240, 255, .3);
  border-radius: var(--r);
  background: rgba(3, 7, 15, .82);
  backdrop-filter: blur(4px) saturate(.8);
  -webkit-backdrop-filter: blur(4px) saturate(.8);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .6), 0 0 18px rgba(53, 240, 255, .12);
}
.dh-txt b {
  font-size: var(--fs-xs); letter-spacing: .16em;
  color: #fff; text-shadow: 0 0 10px rgba(53, 240, 255, .5);
}
.dh-txt i {
  font-size: 9px; font-style: normal; letter-spacing: .18em;
  color: var(--cyan); opacity: .8;
}

/* ==========================================================================
   screens
   ========================================================================== */

.screen-layer { position: absolute; inset: 0; pointer-events: none; }
.screen-layer[hidden] { display: none; }

.screen {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  display: flex;
  opacity: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(20, 44, 72, .34), transparent 60%),
    linear-gradient(180deg, rgba(4, 6, 14, .82), rgba(3, 4, 10, .93));
  backdrop-filter: blur(9px) saturate(1.15);
  -webkit-backdrop-filter: blur(9px) saturate(1.15);
  overflow: hidden;
}
.screen.in { animation: scrIn .18s var(--ease) forwards; }
/* A rebuild of the screen already on show skips the entrance — see UI.setScreen */
.screen.in.instant { animation: none; opacity: 1; transform: none; }
@keyframes scrIn { from { opacity: 0; transform: translateY(12px) scale(.99); } to { opacity: 1; transform: none; } }

/* overlays keep the playfield readable underneath */
.screen--choice, .screen--pause {
  background:
    radial-gradient(110% 70% at 50% 0%, rgba(255, 61, 127, .12), transparent 62%),
    linear-gradient(180deg, rgba(4, 6, 14, .70), rgba(3, 4, 10, .86));
  backdrop-filter: blur(5px) saturate(1.1);
  -webkit-backdrop-filter: blur(5px) saturate(1.1);
}

.crt {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    repeating-linear-gradient(to bottom, rgba(180, 240, 255, .045) 0 1px, transparent 1px 3px),
    radial-gradient(125% 92% at 50% 46%, transparent 42%, rgba(0, 0, 0, .62) 100%);
}
.crt::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(120, 220, 255, .05) 48%, transparent 52%);
  animation: crtSweep 7s linear infinite;
}
@keyframes crtSweep { from { transform: translateY(-100%); } to { transform: translateY(100%); } }

.scr {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding:
    calc(var(--sa-t) + 12px)
    calc(var(--sa-r) + 14px)
    calc(var(--sa-b) + 12px)
    calc(var(--sa-l) + 14px);
  gap: 10px;
  min-height: 0;
}
.scr--wide { max-width: 860px; }

.scr-hd { flex: 0 0 auto; display: flex; flex-direction: column; gap: 9px; }
.scr-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(102, 214, 255, .3) transparent;
}
.scr-body::-webkit-scrollbar { width: 4px; }
.scr-body::-webkit-scrollbar-thumb { background: rgba(102, 214, 255, .28); border-radius: 2px; }
.scr-ft { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }

.scr-title { margin: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.t-jp {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--txt);
  text-shadow: 0 0 16px rgba(53, 240, 255, .3);
}
.t-en { font-size: var(--fs-2xs); letter-spacing: .28em; color: var(--cyan); opacity: .75; }

/* --- buttons ------------------------------------------------------------- */

.btn {
  position: relative;
  pointer-events: auto;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(16, 28, 48, .8), rgba(5, 9, 18, .86));
  color: var(--txt);
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: transform .09s var(--ease), border-color .14s, box-shadow .18s, background .18s;
  flex: 1 1 auto;
}
.btn::before, .btn::after {
  content: '';
  position: absolute;
  width: 9px; height: 9px;
  pointer-events: none;
  opacity: .85;
}
.btn::before { top: 2px; left: 2px; border-top: 1px solid currentColor; border-left: 1px solid currentColor; }
.btn::after { bottom: 2px; right: 2px; border-bottom: 1px solid currentColor; border-right: 1px solid currentColor; }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn.is-down, .btn:active { transform: translateY(1px) scale(.985); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .38; cursor: default; }
.btn--wide { width: 100%; }

.btn-g { font-size: var(--fs-sm); opacity: .9; }
.btn-l { display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.15; }
.btn-l b { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .1em; }
.btn-l i { font-size: 9px; font-style: normal; letter-spacing: .2em; color: var(--txt-3); }

.btn--primary {
  color: var(--cyan);
  border-color: rgba(53, 240, 255, .55);
  background: linear-gradient(180deg, rgba(12, 62, 82, .85), rgba(5, 18, 28, .9));
  box-shadow: 0 0 24px rgba(53, 240, 255, .2), inset 0 0 22px rgba(53, 240, 255, .1);
  min-height: 54px;
}
.btn--primary .btn-l b { font-size: var(--fs-md); text-shadow: 0 0 14px rgba(53, 240, 255, .6); }
.btn--primary .btn-l i { color: rgba(53, 240, 255, .55); }
.btn--primary:hover { box-shadow: 0 0 34px rgba(53, 240, 255, .34), inset 0 0 26px rgba(53, 240, 255, .16); }

.btn--gold {
  color: var(--amber);
  border-color: rgba(255, 209, 102, .5);
  background: linear-gradient(180deg, rgba(66, 48, 10, .82), rgba(16, 11, 4, .9));
  box-shadow: 0 0 22px rgba(255, 209, 102, .18);
}
.btn--gold .btn-l i { color: rgba(255, 209, 102, .5); }

.btn--danger {
  color: var(--pink);
  border-color: rgba(255, 61, 127, .45);
  background: linear-gradient(180deg, rgba(58, 10, 30, .8), rgba(14, 4, 10, .88));
}
.btn--danger .btn-l i { color: rgba(255, 61, 127, .45); }

.btn--ghost { color: var(--txt-2); }
.btn--ghost:hover { border-color: var(--line-hi); color: var(--txt); }

/* --- stats --------------------------------------------------------------- */

.stat {
  display: flex; flex-direction: column; gap: 3px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--glass);
  min-width: 0;
}
.stat-l { font-size: var(--fs-2xs); letter-spacing: .18em; color: var(--txt-3); }
.stat-v {
  font-family: var(--f-d);
  font-size: var(--fs-lg);
  color: var(--txt);
  letter-spacing: .03em;
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis;
}
.stat.wide { grid-column: 1 / -1; }
.stat.wide .stat-v { color: var(--amber); font-size: var(--fs-xl); text-shadow: 0 0 16px rgba(255, 209, 102, .4); }

/* --- tabs ---------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 5px;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  pointer-events: auto;
  touch-action: manipulation;
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 5px 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--r);
  background: rgba(6, 11, 22, .6);
  color: var(--txt-3);
  font-family: inherit;
  cursor: pointer;
  transition: color .14s, border-color .14s, background .14s, box-shadow .18s;
  white-space: nowrap;
}
.tab b { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; white-space: nowrap; }
.tab i {
  font-size: 8.5px; font-style: normal; letter-spacing: .12em; opacity: .7;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 520px) { .tabs--compact .tab i { display: none; } }
.tab[aria-selected="true"] {
  color: var(--cyan);
  border-color: rgba(53, 240, 255, .5);
  border-bottom-color: var(--cyan);
  background: linear-gradient(180deg, rgba(10, 44, 60, .7), rgba(5, 12, 22, .8));
  box-shadow: 0 0 18px rgba(53, 240, 255, .16);
}
.tab:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* --- cards --------------------------------------------------------------- */

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: 0 6px 26px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .045);
  overflow: hidden;
}
.card::before, .card::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  pointer-events: none;
  z-index: 2;
}
.card::before { top: 0; left: 0; border-top: 2px solid var(--c, var(--cyan)); border-left: 2px solid var(--c, var(--cyan)); }
.card::after { bottom: 0; right: 0; border-bottom: 2px solid var(--c, var(--cyan)); border-right: 2px solid var(--c, var(--cyan)); }

/* Screens whose content is short read better centred; the flexible spacers
   collapse to zero the moment the content overflows, so scrolling still works. */
.screen--title .scr-body::before, .screen--title .scr-body::after,
.screen--daily .scr-body::before, .screen--daily .scr-body::after,
.screen--pause .scr-body::before, .screen--pause .scr-body::after {
  content: '';
  flex: 1 1 0;
  min-height: 0;
}

/* pause: control reference */
.pause-help { display: flex; flex-direction: column; gap: 6px; }
.key-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-left: 2px solid rgba(53, 240, 255, .3);
  background: rgba(255, 255, 255, .022);
  border-radius: 0 2px 2px 0;
}
.key-k {
  display: grid; place-items: center;
  padding: 3px 4px;
  font-size: 9px;
  letter-spacing: .12em;
  color: var(--cyan);
  border: 1px solid rgba(53, 240, 255, .4);
  border-radius: 2px;
  background: rgba(6, 26, 36, .7);
}
.key-d { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.key-d b { font-size: var(--fs-2xs); font-weight: 400; color: var(--txt-2); }
.key-d i { font-size: 8px; font-style: normal; letter-spacing: .18em; color: var(--txt-3); }

/* ==========================================================================
   loading
   ========================================================================== */

.screen--loading { opacity: 1; align-items: center; justify-content: center; }
.load-wrap {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 0 24px;
  width: min(440px, 90vw);
  text-align: center;
}
.load-title {
  font-family: var(--f-d);
  font-size: var(--fs-lg);
  letter-spacing: .34em;
  color: var(--txt-2);
}
.load-title b { color: var(--pink); font-weight: 700; text-shadow: 0 0 16px rgba(255, 61, 127, .6); }
.load-bar {
  width: 100%;
  height: 3px;
  background: rgba(53, 240, 255, .12);
  border-radius: 2px;
  overflow: hidden;
}
.load-f {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, rgba(53, 240, 255, .4), var(--cyan));
  box-shadow: 0 0 16px rgba(53, 240, 255, .8);
  transition: width .2s var(--ease);
}
.load-row { display: flex; justify-content: space-between; width: 100%; font-size: var(--fs-2xs); letter-spacing: .18em; color: var(--txt-3); }
.load-p { color: var(--cyan); }
.load-tip { font-size: var(--fs-xs); color: var(--txt-3); line-height: 1.7; max-width: 34ch; }

/* ==========================================================================
   title
   ========================================================================== */

.title-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.best { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.best-l { font-size: var(--fs-2xs); letter-spacing: .22em; color: var(--txt-3); }
.best-v { font-family: var(--f-d); font-size: var(--fs-md); color: var(--txt); font-variant-numeric: tabular-nums; }
.best-sub { display: flex; align-items: baseline; gap: 6px; font-size: 8.5px; letter-spacing: .14em; }
.bs-w { color: var(--txt-3); font-variant-numeric: tabular-nums; }
.bs-none { color: var(--txt-3); opacity: .8; }
.bs-clear {
  color: var(--amber);
  font-weight: 700;
  padding: 0 4px;
  border: 1px solid rgba(255, 209, 102, .45);
  border-radius: 2px;
  text-shadow: 0 0 10px rgba(255, 209, 102, .5);
}

.logo { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0 2px; }
.logo-marks { display: flex; align-items: center; gap: clamp(10px, 4vw, 22px); margin-bottom: 6px; }
.logo-arrow { font-size: var(--fs-lg); color: var(--txt-3); animation: arrowPulse 2.4s ease-in-out infinite; }
@keyframes arrowPulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; color: var(--amber); } }

.logo-a {
  font-family: var(--f-d);
  font-size: clamp(28px, 10vmin, 58px);
  line-height: .96;
  letter-spacing: .22em;
  text-indent: .22em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(53, 240, 255, .9);
  text-shadow: 0 0 26px rgba(53, 240, 255, .45);
}
.logo-b {
  position: relative;
  font-family: var(--f-d);
  font-size: clamp(30px, 11.4vmin, 66px);
  line-height: 1;
  letter-spacing: .16em;
  text-indent: .16em;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 10px var(--pink), 0 0 30px rgba(255, 61, 127, .8), 0 0 60px rgba(255, 61, 127, .4);
  margin-bottom: .4em;
}
.logo-b::after {
  content: attr(data-t);
  position: absolute;
  left: 0; right: 0; top: 100%;
  transform: scaleY(-1);
  color: rgba(255, 61, 127, .3);
  text-shadow: none;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .45), transparent 30%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .45), transparent 30%);
  pointer-events: none;
}
.logo-tag {
  margin-top: 6px;
  font-size: var(--fs-sm);
  letter-spacing: .14em;
  color: var(--txt);
  text-shadow: 0 0 14px rgba(255, 61, 127, .35);
}
.logo-tag-en { font-size: 8.5px; letter-spacing: .2em; color: var(--txt-3); text-align: center; }

.lo-sec { display: flex; flex-direction: column; gap: 6px; }
.lo-h { display: flex; align-items: baseline; gap: 7px; }
.lo-h b { font-size: var(--fs-xs); letter-spacing: .16em; color: var(--txt-2); }
.lo-h i { font-size: 8.5px; font-style: normal; letter-spacing: .24em; color: var(--txt-3); }

.lo-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding-bottom: 3px;
  touch-action: pan-x;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 26px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 26px), transparent 100%);
}
.lo-row::-webkit-scrollbar { display: none; }

.lo-chip {
  pointer-events: auto;
  touch-action: manipulation;
  flex: 0 0 auto;
  min-height: 52px;
  min-width: 108px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(120, 200, 230, .2);
  border-radius: var(--r);
  background: rgba(6, 11, 22, .66);
  color: var(--txt-2);
  font-family: inherit;
  cursor: pointer;
  transition: border-color .14s, box-shadow .18s, background .18s, transform .09s;
}
.lo-chip.is-down { transform: scale(.97); }
.lo-chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.lo-g { font-size: var(--fs-md); color: var(--c); text-shadow: 0 0 10px var(--cg); }
.lo-n { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
.lo-n b { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.lo-n i { font-size: 8.5px; font-style: normal; letter-spacing: .14em; color: var(--txt-3); white-space: nowrap; }
.lo-ok { margin-left: auto; color: var(--c); opacity: 0; font-size: var(--fs-sm); }
.lo-cost { margin-left: auto; font-size: 9px; color: var(--amber); letter-spacing: .06em; white-space: nowrap; }

.lo-chip.sel {
  border-color: var(--c);
  color: var(--txt);
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(0, 0, 0, .3));
  box-shadow: 0 0 20px var(--cg), inset 0 0 18px rgba(255, 255, 255, .04);
}
.lo-chip.sel .lo-ok { opacity: 1; }
.lo-chip.locked { opacity: .45; filter: saturate(.25); }
.lo-chip.locked .lo-g { color: var(--txt-3); text-shadow: none; }

.title-menu { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.title-menu .btn { min-height: 46px; padding: 6px 4px; }
.title-menu .btn-l b { font-size: var(--fs-xs); }
.title-menu .btn-l i { font-size: 7.5px; letter-spacing: .1em; }

/* modal (settings from title) */
.modal {
  position: absolute; inset: 0;
  z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--sa-t) + 12px) 12px calc(var(--sa-b) + 12px);
  background: rgba(2, 4, 10, .74);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: scrIn .16s var(--ease);
}
.modal-card {
  position: relative;
  width: min(520px, 100%);
  max-height: 100%;
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px;
  border: 1px solid var(--line-hi);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .7);
  overflow: hidden;
}
.modal-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-hd .btn { flex: 0 0 auto; min-height: 44px; }
.modal-card .settings { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ==========================================================================
   settings
   ========================================================================== */

.settings { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.set-list {
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  min-height: 0;
}
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid rgba(102, 214, 255, .09);
}
.set-lab { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 0 0 auto; }
.set-lab b { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; color: var(--txt); }
.set-lab i { font-size: 8.5px; font-style: normal; letter-spacing: .16em; color: var(--txt-3); }
.set-ctl { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; justify-content: flex-end; min-width: 0; }
.set-v { font-size: var(--fs-2xs); color: var(--cyan); letter-spacing: .08em; min-width: 42px; text-align: right; flex: 0 0 auto; }

.slider {
  -webkit-appearance: none; appearance: none;
  flex: 1 1 auto;
  max-width: 190px;
  min-width: 96px;
  height: 44px;
  background: transparent;
  pointer-events: auto;
  touch-action: pan-y;
  margin: 0;
}
.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--cyan) 0 calc(var(--p, 0) * 100%), rgba(255, 255, 255, .12) calc(var(--p, 0) * 100%) 100%);
  box-shadow: 0 0 10px rgba(53, 240, 255, .25);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: #eafcff;
  border: 1px solid var(--cyan);
  box-shadow: 0 0 12px rgba(53, 240, 255, .8);
}
.slider::-moz-range-track {
  height: 4px; border-radius: 2px;
  background: rgba(255, 255, 255, .12);
}
.slider::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--cyan); }
.slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: #eafcff; border: 1px solid var(--cyan);
  box-shadow: 0 0 12px rgba(53, 240, 255, .8);
}
.slider:focus-visible { outline: 2px solid var(--cyan); outline-offset: 4px; }

.switch {
  pointer-events: auto;
  touch-action: manipulation;
  position: relative;
  width: 56px; height: 30px;
  min-width: 56px;
  border-radius: 15px;
  border: 1px solid rgba(120, 200, 230, .3);
  background: rgba(6, 12, 22, .8);
  cursor: pointer;
  padding: 0;
  transition: border-color .14s, background .18s, box-shadow .18s;
}
.switch::after { content: ''; position: absolute; inset: -8px; }
.sw-k {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #4d6a7a;
  transition: transform .16s var(--ease), background .16s;
}
.switch[aria-checked="true"] { border-color: var(--cyan); background: rgba(10, 50, 66, .8); box-shadow: 0 0 16px rgba(53, 240, 255, .25); }
.switch[aria-checked="true"] .sw-k { transform: translateX(26px); background: var(--cyan); box-shadow: 0 0 12px rgba(53, 240, 255, .9); }
.switch:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.seg { display: flex; gap: 3px; }
.seg-b {
  pointer-events: auto;
  touch-action: manipulation;
  min-height: 34px;
  min-width: 44px;
  padding: 4px 8px;
  border: 1px solid rgba(120, 200, 230, .22);
  border-radius: 2px;
  background: rgba(6, 12, 22, .7);
  color: var(--txt-3);
  font-family: inherit;
  font-size: 9.5px;
  letter-spacing: .1em;
  cursor: pointer;
  transition: color .14s, border-color .14s, background .14s;
}
.seg-b[aria-pressed="true"] { color: var(--cyan); border-color: var(--cyan); background: rgba(10, 44, 60, .8); box-shadow: 0 0 12px rgba(53, 240, 255, .2); }
.seg-b:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.set-foot { display: flex; flex-direction: column; gap: 8px; }

/* ==========================================================================
   choice
   ========================================================================== */

.choice-hd { display: flex; flex-direction: column; gap: 6px; }
.choice-wave { display: flex; align-items: baseline; gap: 8px; }
.choice-wave b {
  font-family: var(--f-d);
  font-size: var(--fs-md);
  letter-spacing: .2em;
  color: var(--pink);
  text-shadow: 0 0 14px rgba(255, 61, 127, .6);
}
.choice-wave i { font-size: var(--fs-2xs); font-style: normal; letter-spacing: .3em; color: var(--txt-3); }
.choice-rule {
  margin: 0;
  font-size: var(--fs-2xs);
  line-height: 1.75;
  color: var(--txt-2);
  padding: 7px 9px;
  border-left: 2px solid rgba(255, 61, 127, .5);
  background: rgba(255, 61, 127, .06);
  border-radius: 0 var(--r) var(--r) 0;
}
.choice-rule b { color: var(--txt); }
.choice-rule em { font-style: normal; color: var(--pink); font-weight: 700; }

.cards { display: flex; flex-direction: column; gap: 10px; }
.cards > .card { animation: cardIn .2s var(--ease) backwards; }
.cards > .card:nth-child(2) { animation-delay: .05s; }
.cards > .card:nth-child(3) { animation-delay: .1s; }
.cards > .card:nth-child(4) { animation-delay: .15s; }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.core-card { padding: 10px; display: flex; flex-direction: column; gap: 8px; transition: opacity .18s, filter .18s; }
.core-card.dim { opacity: .28; filter: grayscale(.7); }
.core-card.elite { box-shadow: 0 6px 26px rgba(0, 0, 0, .5), 0 0 26px var(--cg); }

.card-hd { display: flex; align-items: center; gap: 9px; }
.card-glyph {
  width: 38px; height: 38px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: var(--fs-lg);
  color: var(--c);
  border: 1px solid var(--c);
  border-radius: var(--r);
  background: radial-gradient(circle at 50% 40%, var(--cg), transparent 72%);
  text-shadow: 0 0 12px var(--c);
}
.card-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.card-name b { font-size: var(--fs-md); font-weight: 700; letter-spacing: .05em; color: var(--txt); }
.card-name i { font-size: 9px; font-style: normal; letter-spacing: .2em; color: var(--c); opacity: .8; }
.card-lv { flex: 0 0 auto; }

.card-now { display: flex; gap: 7px; align-items: baseline; font-size: var(--fs-2xs); color: var(--txt-3); }
.now-l { letter-spacing: .16em; }
.now-v { color: var(--txt-2); }

.card-acts { display: flex; flex-direction: column; gap: 8px; }

.act {
  pointer-events: auto;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid rgba(120, 200, 230, .22);
  border-radius: var(--r);
  background: rgba(4, 8, 16, .6);
  color: var(--txt);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .14s, box-shadow .18s, background .18s, transform .09s;
}
.act.is-down { transform: scale(.99); }
.act:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.act[aria-disabled="true"] { pointer-events: none; opacity: .5; }

.act--equip { border-color: rgba(255, 61, 127, .38); background: linear-gradient(180deg, rgba(40, 8, 22, .6), rgba(6, 4, 12, .7)); }
.act--equip:hover { border-color: var(--pink); box-shadow: 0 0 22px rgba(255, 61, 127, .22); }
.act--analyse { border-color: rgba(255, 209, 102, .34); background: linear-gradient(180deg, rgba(40, 30, 8, .5), rgba(6, 6, 10, .7)); }
.act--analyse:hover { border-color: var(--amber); box-shadow: 0 0 22px rgba(255, 209, 102, .2); }

.act-hd { display: flex; align-items: center; gap: 8px; }
.act-k {
  width: 22px; height: 22px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: var(--fs-2xs);
  font-weight: 700;
  border: 1px solid currentColor;
  border-radius: 2px;
  opacity: .8;
}
.act--equip .act-k { color: var(--pink); }
.act--analyse .act-k { color: var(--amber); }
.act-t { display: flex; flex-direction: column; gap: 0; flex: 1 1 auto; min-width: 0; }
.act-t b { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .06em; }
.act-t i { font-size: 8.5px; font-style: normal; letter-spacing: .24em; color: var(--txt-3); }
.act-lv { flex: 0 0 auto; font-size: var(--fs-2xs); color: var(--txt-2); letter-spacing: .06em; }
.act--equip .act-lv { color: var(--cyan); }

.act-eff { font-size: var(--fs-xs); color: var(--txt); line-height: 1.5; }
.yield { color: var(--amber); font-weight: 700; text-shadow: 0 0 12px rgba(255, 209, 102, .5); }

.warn {
  display: flex; flex-direction: column; gap: 5px;
  padding: 7px 8px;
  border-radius: 2px;
  border: 1px dashed rgba(255, 61, 127, .35);
  background: rgba(255, 61, 127, .07);
}
.warn-hd { display: flex; align-items: center; gap: 6px; font-size: var(--fs-2xs); color: var(--pink); letter-spacing: .06em; }
.warn-i { font-size: var(--fs-sm); line-height: 1; }
/* Narrow columns (landscape phone) must never shred the gene name into one
   character per line — the name stays on one line and the level badge wraps. */
.warn-body { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; }
.warn-dot {
  width: 10px; height: 10px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--gc);
  box-shadow: 0 0 12px var(--gcg);
}
.warn-n { display: flex; align-items: baseline; gap: 5px; min-width: 0; flex: 1 1 auto; }
.warn-n b { font-size: var(--fs-xs); color: var(--gc); font-weight: 700; white-space: nowrap; }
.warn-n i {
  font-size: 8px; font-style: normal; letter-spacing: .16em; color: var(--txt-3);
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.warn-lv {
  flex: 0 0 auto;
  margin-left: auto;
  display: inline-flex; align-items: baseline; gap: 4px;
  font-size: var(--fs-2xs); font-weight: 700;
  color: var(--gc); letter-spacing: .04em;
  white-space: nowrap;
}
.lv-from { color: var(--txt-3); }
.lv-ar { color: var(--gc); opacity: .9; }
.lv-to { color: var(--gc); }

/* the level-up moment gets a boxed, breathing badge */
.warn-lv.is-up {
  font-size: var(--fs-xs);
  padding: 2px 7px;
  border: 1px solid var(--gc);
  border-radius: 2px;
  background: linear-gradient(180deg, var(--gcg), transparent);
  box-shadow: 0 0 14px var(--gcg);
}
.warn-lv.is-up .lv-to { color: #fff; text-shadow: 0 0 10px var(--gc), 0 0 20px var(--gc); }
.screen.in .warn-lv.is-up { animation: lvUp 1.9s var(--ease) .35s infinite; }
@keyframes lvUp {
  0%, 62%, 100% { box-shadow: 0 0 14px var(--gcg); }
  30% { box-shadow: 0 0 24px var(--gc); }
}
.warn-lv.is-max { color: var(--txt-2); }
.warn-lv.is-max em {
  font-style: normal; font-size: 8px; letter-spacing: .18em;
  padding: 1px 4px;
  border: 1px solid rgba(147, 182, 201, .5);
  border-radius: 2px;
  color: var(--txt-3);
}

/* --- evolution-pressure bar ---------------------------------------------- */
.gp-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05);
  overflow: hidden;
}
.gp-fill,
.gp-add {
  position: absolute;
  top: 0; bottom: 0;
  width: 0;
}
/* what the swarm already carries — deliberately muted, so the added segment
   below reads as *new pressure* rather than as more of the same */
.gp-fill {
  left: 0;
  border-radius: 4px 0 0 4px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--gc) 40%, transparent),
    color-mix(in srgb, var(--gc) 76%, transparent));
  transition: width .42s var(--ease) .06s;
}
/* the increase this core buys — hatched so it reads as *added*, not as state */
.gp-add {
  left: calc(var(--p, 0) * 100%);
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .4) 0 2px, transparent 2px 8px),
    var(--gc);
  box-shadow: 0 0 14px var(--gc);
  border-left: 2px solid #fff;
  transition: width .6s var(--ease) .34s;
}
.gp-edge {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, .3);
}
.screen.in .gp-fill { width: calc(var(--p, 0) * 100%); }
.screen.in .gp-add { width: calc(var(--d, 0) * 100%); }

.gp-track.is-up { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16), 0 0 16px var(--gcg); }
.gp-track.is-up .gp-edge { background: #fff; box-shadow: 0 0 10px var(--gc); }
.screen.in .gp-track.is-up::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 35%, rgba(255, 255, 255, .34) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: gpSweep 2.4s var(--ease) .9s infinite;
}
@keyframes gpSweep {
  0% { transform: translateX(-100%); }
  55%, 100% { transform: translateX(100%); }
}
.gp-track.is-max {
  background: repeating-linear-gradient(115deg, rgba(147, 182, 201, .3) 0 3px, rgba(147, 182, 201, .12) 3px 7px);
  box-shadow: inset 0 0 0 1px rgba(147, 182, 201, .22);
}
.gp-track.is-max .gp-fill,
.gp-track.is-max .gp-add { display: none; }
.gp-track.is-max .gp-edge { background: rgba(147, 182, 201, .45); }

.gp-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 8px;
  font-size: var(--fs-2xs);
  line-height: 1.5;
  color: var(--txt-2);
}
.gp-l { letter-spacing: .1em; color: var(--txt-3); white-space: nowrap; }
.gp-nums { display: inline-flex; align-items: baseline; gap: 5px; font-variant-numeric: tabular-nums; }
.gp-nl { letter-spacing: .1em; color: var(--txt-3); }
.gp-a { color: var(--txt-2); }
.gp-ar { color: var(--gc); }
.gp-b { color: var(--gc); font-weight: 700; text-shadow: 0 0 10px var(--gcg); }
.gp-chip {
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid var(--gc);
  border-radius: 2px;
  background: var(--gcg);
  color: #fff;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.gp-flat { margin-left: auto; color: var(--txt-3); white-space: nowrap; }

.warn--gene.is-up { border-style: solid; border-color: var(--gc); background: rgba(255, 61, 127, .1); }
.warn--gene.is-up .warn-hd { color: #fff; font-weight: 700; }
.warn--gene.is-max { border-color: rgba(147, 182, 201, .32); background: rgba(147, 182, 201, .06); }
.warn--gene.is-max .warn-hd { color: var(--txt-2); }
.warn--gene.is-max .warn-dot { background: var(--txt-3); box-shadow: none; }

.warn--safe { border-color: rgba(124, 255, 77, .28); background: rgba(124, 255, 77, .05); }
.warn--safe .warn-hd { color: var(--lime); }

.swarm { display: flex; flex-direction: column; gap: 6px; }
.swarm-h, .gsw-h { display: flex; align-items: baseline; gap: 8px; }
.swarm-h b, .gsw-h b { font-size: var(--fs-xs); letter-spacing: .12em; color: var(--txt-2); }
.swarm-h i, .gsw-h i { font-size: 8.5px; font-style: normal; letter-spacing: .2em; color: var(--txt-3); }
.swarm-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto minmax(46px, 84px);
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-left: 2px solid var(--c);
  background: rgba(255, 255, 255, .022);
  border-radius: 0 2px 2px 0;
}
.sw-g { color: var(--c); text-align: center; font-size: var(--fs-sm); }
.sw-n { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.sw-n b { font-size: var(--fs-2xs); color: var(--txt); white-space: nowrap; }
.sw-n i { font-size: 8px; font-style: normal; color: var(--txt-3); letter-spacing: .12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-lv { font-size: var(--fs-2xs); color: var(--c); font-weight: 700; }

/* ==========================================================================
   pause
   ========================================================================== */

.pause-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pause-settings { transition: opacity .18s var(--ease); display: flex; min-height: 0; }
.pause-settings.collapsed { display: none; }
.pause-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ==========================================================================
   game over
   ========================================================================== */

.go-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.go-title { display: flex; flex-direction: column; gap: 2px; }
.go-title b {
  font-family: var(--f-d);
  font-size: var(--fs-xl);
  letter-spacing: .18em;
  color: var(--pink);
  text-shadow: 0 0 18px rgba(255, 61, 127, .6);
}
.go-title i { font-size: var(--fs-2xs); font-style: normal; letter-spacing: .24em; color: var(--txt-3); }
.go-best {
  padding: 5px 10px;
  border: 1px solid var(--amber);
  border-radius: var(--r);
  color: var(--amber);
  font-size: var(--fs-2xs);
  letter-spacing: .2em;
  font-weight: 700;
  box-shadow: 0 0 22px rgba(255, 209, 102, .3);
  animation: bestBlink 1.4s ease-in-out infinite;
}
@keyframes bestBlink { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.go-score {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
}
.gs-l { font-size: var(--fs-2xs); letter-spacing: .3em; color: var(--txt-3); }
.gs-v {
  font-family: var(--f-d);
  font-size: var(--fs-2xl);
  line-height: 1;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px rgba(255, 209, 102, .55), 0 0 50px rgba(255, 209, 102, .25);
}
.gs-b { font-size: var(--fs-2xs); letter-spacing: .16em; color: var(--txt-3); }

.go-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.go-data { display: flex; flex-direction: column; gap: 8px; }
.go-data-hd { display: flex; }
.go-break { display: flex; flex-direction: column; gap: 3px; }
.brk { display: flex; justify-content: space-between; font-size: var(--fs-2xs); color: var(--txt-3); padding: 2px 4px; border-bottom: 1px dotted rgba(255, 209, 102, .14); }
.brk-v { color: var(--amber); }
.go-total { display: flex; justify-content: space-between; align-items: baseline; font-size: var(--fs-xs); color: var(--txt-3); letter-spacing: .1em; }
.gt-v { color: var(--amber); font-size: var(--fs-md); font-weight: 700; }

.go-swarm, .go-cores { display: flex; flex-direction: column; gap: 6px; }
.gsw-list { display: flex; flex-direction: column; gap: 4px; }
.gsw-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto minmax(50px, 90px) 38px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, .06);
  border-left: 2px solid var(--c);
  border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, var(--cg), transparent 46%), rgba(4, 7, 15, .72);
}
.gsw-g { color: var(--c); text-align: center; font-size: var(--fs-md); text-shadow: 0 0 10px var(--c); }
.gsw-n { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.gsw-n b { font-size: var(--fs-xs); color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsw-n i { font-size: 8px; font-style: normal; letter-spacing: .16em; color: var(--txt-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsw-lv { font-size: var(--fs-xs); font-weight: 700; color: var(--c); }
.gsw-p { font-size: var(--fs-2xs); color: var(--txt-2); text-align: right; }
.go-core-list { display: flex; flex-wrap: wrap; gap: 5px; }
.core-chip.static { animation: none; }
.go-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* --- victory -------------------------------------------------------------
   The death screen is red and reports. This one is cyan and gold and
   congratulates: same numbers, opposite story. Everything under .is-win
   re-keys the shared gameover chrome away from the loss palette. */

.screen--gameover.is-win .crt {
  background:
    radial-gradient(120% 78% at 50% 0%, rgba(255, 209, 102, .12), transparent 62%),
    radial-gradient(100% 70% at 50% 100%, rgba(53, 240, 255, .1), transparent 66%);
}

.win-hd {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 4px 0 2px;
  text-align: center;
}
.mark-win {
  width: clamp(38px, 11vmin, 62px);
  filter: drop-shadow(0 0 12px rgba(255, 209, 102, .8));
  animation: winMark 2.6s ease-in-out infinite;
}
@keyframes winMark { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

.win-band {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 14px;
  border-top: 1px solid rgba(255, 209, 102, .55);
  border-bottom: 1px solid rgba(255, 209, 102, .55);
  background: linear-gradient(90deg, transparent, rgba(255, 209, 102, .14), transparent);
}
.wb-l, .wb-r {
  font-family: var(--f-d);
  font-size: var(--fs-sm);
  letter-spacing: .34em;
  text-indent: .34em;
  color: var(--amber);
  text-shadow: 0 0 16px rgba(255, 209, 102, .7);
}
.wb-r { color: #fff; text-shadow: 0 0 14px rgba(255, 209, 102, .9), 0 0 34px rgba(255, 209, 102, .4); }
.win-band { animation: winBand 2.4s ease-in-out infinite; }
@keyframes winBand { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.28); } }

.win-jp {
  margin: 2px 0 0;
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(53, 240, 255, .6), 0 0 46px rgba(53, 240, 255, .22);
}
.win-sub { font-size: var(--fs-2xs); letter-spacing: .18em; color: var(--txt-3); }
.win-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.win-clears {
  padding: 4px 10px;
  border: 1px solid rgba(53, 240, 255, .5);
  border-radius: var(--r);
  color: var(--cyan);
  font-size: var(--fs-2xs);
  letter-spacing: .2em;
  font-weight: 700;
}
.win-clears.first { border-color: var(--amber); color: var(--amber); box-shadow: 0 0 20px rgba(255, 209, 102, .28); }

.screen--gameover.is-win .go-score {
  border-color: rgba(53, 240, 255, .38);
  background: linear-gradient(180deg, rgba(6, 34, 46, .7), rgba(5, 8, 17, .9));
  box-shadow: inset 0 0 30px rgba(53, 240, 255, .08);
}
.screen--gameover.is-win .stat { border-color: rgba(53, 240, 255, .26); }
.screen--gameover.is-win .stat-v { color: #e9fbff; }

/* the trophy: the same gene list the loss screen uses as an epitaph */
.go-swarm--win { padding: 8px; border: 1px solid rgba(255, 209, 102, .3); border-radius: var(--r); background: linear-gradient(180deg, rgba(30, 22, 4, .42), rgba(5, 8, 17, .5)); }
.go-swarm--win .gsw-h b { color: var(--amber); }
.go-swarm--win .gsw-h i { color: rgba(255, 209, 102, .55); }
.win-note { font-size: var(--fs-2xs); line-height: 1.75; color: var(--txt-2); letter-spacing: .04em; }
.win-note em { font-style: normal; color: var(--cyan); text-shadow: 0 0 12px rgba(53, 240, 255, .45); }

.btn--gold.btn--wide { min-height: 54px; }
.btn--gold.btn--wide .btn-l b { font-size: var(--fs-md); text-shadow: 0 0 14px rgba(255, 209, 102, .55); }

/* ==========================================================================
   meta
   ========================================================================== */

.meta-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.meta-hd-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.meta-hd-l .btn { flex: 0 0 auto; min-height: 44px; min-width: 74px; }

.meta-list { display: flex; flex-direction: column; gap: 7px; }
.meta-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  animation: cardIn .16s var(--ease) backwards;
}
.meta-row.double { border-color: rgba(255, 61, 127, .34); background: linear-gradient(180deg, rgba(38, 8, 22, .68), rgba(6, 5, 12, .86)); }
.meta-row.is-max { opacity: .68; }
.mr-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: var(--fs-md);
  color: var(--c);
  border: 1px solid var(--c);
  border-radius: var(--r);
  background: radial-gradient(circle at 50% 40%, var(--cg), transparent 74%);
  text-shadow: 0 0 10px var(--c);
}
.mr-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.mr-name { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.mr-name b { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .04em; color: var(--txt); }
.mr-name i { font-size: 8.5px; font-style: normal; letter-spacing: .18em; color: var(--txt-3); }
.badge-double {
  font-size: 8.5px;
  letter-spacing: .14em;
  padding: 1px 5px;
  border: 1px solid var(--pink);
  color: var(--pink);
  border-radius: 2px;
  box-shadow: 0 0 12px rgba(255, 61, 127, .3);
}
.mr-desc { font-size: var(--fs-2xs); color: var(--txt-2); line-height: 1.55; }
.mr-warn { display: flex; align-items: baseline; gap: 4px; font-size: var(--fs-2xs); color: rgba(255, 61, 127, .85); flex-wrap: wrap; }
.mr-warn b { color: var(--c); }
.mr-lv { display: flex; align-items: center; gap: 7px; }
.mr-lvt { font-size: 9px; color: var(--txt-3); letter-spacing: .1em; }

.buy {
  pointer-events: auto;
  touch-action: manipulation;
  min-width: 84px;
  min-height: 46px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 209, 102, .45);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(58, 42, 8, .7), rgba(12, 9, 4, .8));
  color: var(--amber);
  font-family: inherit;
  cursor: pointer;
  transition: border-color .14s, box-shadow .18s, transform .09s;
}
.buy.is-down { transform: scale(.96); }
.buy:hover { box-shadow: 0 0 20px rgba(255, 209, 102, .28); }
.buy:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.buy-in { display: flex; align-items: baseline; justify-content: center; gap: 4px; }
.buy-g { font-size: var(--fs-2xs); opacity: .8; }
.buy-v { font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.buy.poor { opacity: .4; border-color: rgba(150, 150, 150, .3); color: var(--txt-3); cursor: default; }
.buy.maxed { border-color: rgba(53, 240, 255, .4); color: var(--cyan); background: rgba(6, 30, 40, .6); cursor: default; }
.buy-max { font-size: var(--fs-xs); letter-spacing: .18em; font-weight: 700; }

/* ==========================================================================
   daily
   ========================================================================== */

.daily-seed {
  display: flex; flex-direction: column; gap: 5px;
  padding: 12px;
  border: 1px solid rgba(255, 209, 102, .28);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(38, 28, 6, .5), rgba(6, 6, 12, .8));
}
.ds-l { display: flex; align-items: baseline; gap: 8px; }
.ds-l b { font-size: var(--fs-xs); letter-spacing: .1em; color: var(--txt-2); }
.ds-l i { font-size: 8.5px; font-style: normal; letter-spacing: .18em; color: var(--txt-3); }
.ds-v {
  font-family: var(--f-d);
  font-size: clamp(13px, 4.2vmin, 22px);
  letter-spacing: .08em;
  color: var(--amber);
  text-shadow: 0 0 16px rgba(255, 209, 102, .4);
  word-break: break-all;
  -webkit-user-select: text; user-select: text;
}
.ds-d { font-size: var(--fs-2xs); color: var(--txt-3); letter-spacing: .2em; }

.daily-today, .daily-hist { display: flex; flex-direction: column; gap: 6px; }
.hist-list { display: flex; flex-direction: column; gap: 2px; }
.hist-row {
  display: grid;
  grid-template-columns: 26px 1fr 46px auto;
  gap: 8px;
  align-items: baseline;
  padding: 7px 8px;
  border-bottom: 1px solid rgba(102, 214, 255, .08);
  font-size: var(--fs-xs);
}
.hist-row:nth-child(1) .hr-s { color: var(--amber); }
.hr-i { color: var(--txt-3); font-size: var(--fs-2xs); letter-spacing: .1em; }
.hr-d { color: var(--txt-2); }
.hr-w { color: var(--pink); font-size: var(--fs-2xs); }
.hr-s { color: var(--txt); font-variant-numeric: tabular-nums; text-align: right; }

/* ==========================================================================
   codex
   ========================================================================== */

/* --- codex: run structure ------------------------------------------------ */
.cx-brief {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 10px;
  border: 1px solid rgba(102, 214, 255, .2);
  border-radius: var(--r);
  background: linear-gradient(180deg, rgba(8, 20, 34, .6), rgba(5, 8, 17, .7));
}
.rb-map { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.rb-a {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 4px;
  border: 1px solid rgba(102, 214, 255, .16);
  border-top: 2px solid rgba(102, 214, 255, .22);
  border-radius: 2px;
  background: rgba(4, 8, 16, .6);
  text-align: center;
  min-width: 0;
}
.rb-a.seen { border-top-color: rgba(53, 240, 255, .6); background: rgba(6, 26, 36, .6); }
.rb-a.done { border-top-color: var(--cyan); box-shadow: inset 0 0 16px rgba(53, 240, 255, .12); }
.rb-i { font-size: 8px; letter-spacing: .12em; color: var(--txt-3); }
.rb-w { font-family: var(--f-d); font-size: var(--fs-xs); color: var(--txt); font-variant-numeric: tabular-nums; }
.rb-b { font-size: 8px; letter-spacing: .04em; color: rgba(255, 61, 127, .8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-a.is-final { border-color: rgba(255, 209, 102, .4); border-top-color: var(--amber); background: linear-gradient(180deg, rgba(30, 21, 4, .6), rgba(20, 6, 26, .6)); }
.rb-a.is-final .rb-i, .rb-a.is-final .rb-w { color: var(--amber); }
.rb-a.is-final .rb-b { color: var(--amber); font-weight: 700; text-shadow: 0 0 10px rgba(255, 209, 102, .5); }
.cx-brief .note b { color: var(--amber); font-weight: 700; }
.rb-best { color: var(--txt-2); letter-spacing: .1em; }

.cx-count { display: flex; align-items: baseline; gap: 4px; }
.cx-count b { font-family: var(--f-d); font-size: var(--fs-md); color: var(--cyan); }
.cx-count i { font-size: var(--fs-2xs); font-style: normal; color: var(--txt-3); letter-spacing: .1em; }

.cx-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.cx-card { padding: 9px 10px; display: flex; flex-direction: column; gap: 6px; }
.cx-card.locked { --c: #33454f; opacity: .55; border-style: dashed; }
.cx-hd { display: flex; align-items: center; gap: 9px; }
.cx-g {
  width: 32px; height: 32px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: var(--fs-md);
  color: var(--c);
  border: 1px solid var(--c);
  border-radius: var(--r);
  background: radial-gradient(circle at 50% 40%, var(--cg, transparent), transparent 74%);
  text-shadow: 0 0 10px var(--c);
}
.cx-n { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.cx-n b { font-size: var(--fs-sm); font-weight: 700; color: var(--txt); }
.cx-n i { font-size: 8.5px; font-style: normal; letter-spacing: .18em; color: var(--c); opacity: .75; }
.cx-m { font-size: 9px; color: var(--txt-3); letter-spacing: .08em; flex: 0 0 auto; }
.cx-d { font-size: var(--fs-2xs); color: var(--txt-2); line-height: 1.65; }
.cx-x { display: flex; justify-content: space-between; gap: 8px; font-size: var(--fs-2xs); padding-top: 5px; border-top: 1px dotted rgba(102, 214, 255, .14); }
.cx-x-l { color: var(--txt-3); letter-spacing: .1em; }
.cx-x-v { color: var(--txt); }

.fdiag { width: 100%; height: clamp(70px, 22vw, 96px); background: rgba(0, 0, 0, .28); border-radius: 2px; }
.fd-n { fill: rgba(255, 61, 127, .45); }
.fd-key { fill: #ff3d7f; }
.fd-core { fill: #ffd166; }

/* ==========================================================================
   toasts
   ========================================================================== */

.toasts {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sa-b) + var(--touch-h) + 112px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  width: max-content;
  max-width: min(90vw, 460px);
  z-index: 20;
}
.ui.has-screen .toasts { bottom: calc(var(--sa-b) + 158px); top: auto; }

.toast {
  padding: 8px 14px;
  border: 1px solid var(--c);
  border-radius: var(--r);
  background: rgba(4, 8, 16, .92);
  box-shadow: 0 0 24px color-mix(in srgb, var(--c) 30%, transparent), 0 6px 20px rgba(0, 0, 0, .6);
  color: var(--txt);
  font-size: var(--fs-xs);
  letter-spacing: .04em;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.toast.big { font-size: var(--fs-md); padding: 12px 20px; }

/* ==========================================================================
   responsive
   ========================================================================== */

/* wide / desktop */
@media (min-width: 720px) {
  .cx-grid { grid-template-columns: repeat(2, 1fr); }
  /* six result stats — three columns fill two exact rows; four leaves a hole */
  .go-grid { grid-template-columns: repeat(3, 1fr); }
  /* 212px still fits the widest warning legend, and keeps all four offered
     cores on one row at the .scr--wide max — the choice is judged as a set. */
  .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(212px, 1fr)); }
  .evo { width: 232px; top: 22%; }
  .tbtn--hack { width: 96px; height: 96px; right: calc(var(--sa-r) + 22px); bottom: calc(var(--sa-b) + 22px); }
  #ui.touch-on[data-screen="hud"] { --touch-h: 134px; }
}

@media (min-width: 900px) {
  /* menus read as a cabinet panel, not an edge-to-edge column */
  .scr { max-width: 620px; }
  .scr--wide { max-width: 940px; }
}

@media (min-width: 900px) and (min-height: 720px) {
  .screen { align-items: center; }
  .scr { max-height: min(100%, 880px); }
}

@media (min-width: 900px) {
  /* the play box is centred, so the HUD rails must be too — a 1920px-wide
     enemy bar reads as broken, not as spacious */
  .hud-top {
    padding-left: max(calc(var(--sa-l) + 16px), calc(50% - 520px));
    padding-right: max(calc(var(--sa-r) + 16px), calc(50% - 520px));
  }
  .hud-bottom {
    left: max(calc(var(--sa-l) + 16px), calc(50% - 520px));
    right: max(calc(var(--sa-r) + 16px), calc(50% - 520px));
  }
  .evo { right: max(calc(var(--sa-r) + 16px), calc(50% - 520px)); }
  .drag-hint { bottom: calc(var(--sa-b) + var(--touch-h) + 60px); }
}

@media (min-width: 1100px) {
  .cx-grid { grid-template-columns: repeat(3, 1fr); }
}

/* landscape phone — push the HUD to the edges, never stack it vertically */
@media (orientation: landscape) and (max-height: 560px) {
  #ui.touch-on[data-screen="hud"] { --touch-h: 8px; }
  /* keep clear of the hack ring on the right; only reserve the left rail when
     the on-screen d-pad is actually enabled */
  .hud-bottom { right: calc(var(--sa-r) + 108px); left: calc(var(--sa-l) + 12px); }
  #ui.dpad-on .hud-bottom { left: calc(var(--sa-l) + 96px); }
  .evo {
    top: calc(var(--sa-t) + 96px);
    width: clamp(120px, 26vw, 190px);
    max-height: 50vh;
    overflow: hidden;
  }
  .banner { top: 28%; }
  .event-chip { top: calc(var(--sa-t) + 52px); }
  /* keep the boss bar clear of the evolution ticker pinned to the right rail */
  .bossbar { align-self: flex-start; width: calc(100% - 208px); }
  .bb-t { display: none; }
  .tbtn--hack { width: 74px; height: 74px; }
  .dpad { left: calc(var(--sa-l) + 10px); }
  .tbtn--dir { width: 56px; height: 56px; }
  .drag-hint { bottom: calc(var(--sa-b) + 96px); }
  .scr { padding-top: calc(var(--sa-t) + 8px); padding-bottom: calc(var(--sa-b) + 8px); gap: 7px; }
  .logo-marks { margin-bottom: 0; }
  .logo-tag { margin-top: 6px; }

  /* Title: the loadout is the point of this screen, so in landscape it moves
     beside the logo instead of being pushed a full screen below it. */
  .screen--title .scr-body {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    grid-auto-rows: min-content;
    align-content: center;
    gap: 10px 18px;
  }
  .screen--title .scr-body::before,
  .screen--title .scr-body::after { display: none; }
  .screen--title .logo { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
  .screen--title .lo-sec { grid-column: 2; }
  /* Vertical room is the scarce resource here. Fit every offered core in one
     row so the whole choice is visible at a glance, and tighten the chrome so
     each card shows its consequence without scrolling. */
  .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 8px; }
  .choice-hd { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 3px 10px; }
  .choice-rule { flex: 1 1 100%; padding: 4px 8px; line-height: 1.55; }
  .core-card { padding: 8px; gap: 6px; }
  .card-glyph { width: 30px; height: 30px; }
  .card-acts { gap: 6px; }
  .act { padding: 7px 8px; gap: 5px; }
  .act-k { width: 18px; height: 18px; }
  .warn { padding: 6px 7px; gap: 4px; }
  /* Victory: the celebration must not eat the result it is celebrating —
     fold the whole fanfare onto two short rows so the stats stay on screen. */
  .win-hd { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 3px 12px; padding: 0; }
  .mark-win { width: 26px; }
  .win-band { padding: 2px 10px; }
  .wb-l, .wb-r { font-size: var(--fs-2xs); }
  .win-jp { font-size: var(--fs-lg); margin: 0; }
  .win-sub { flex: 0 1 auto; }
  .win-tags { margin-top: 0; }
  .win-clears, .win-hd .go-best { padding: 2px 8px; }
  .win-note { line-height: 1.55; }

  .go-grid { grid-template-columns: repeat(3, 1fr); }
  .pause-help { gap: 4px; }
  .key-row { padding: 4px 8px; }
  .cx-grid { grid-template-columns: repeat(2, 1fr); }
  .toasts { bottom: calc(var(--sa-b) + 96px); }
}

/* phones — the wave row now carries the area chip too, so the wave name gives
   up the space it was hoarding and AREA shrinks to its numerals + pips */
@media (max-width: 460px) {
  .ar-l { display: none; }
  .wavechip { max-width: 40%; }
  .bossbar { width: 100%; }
  .bb-t { display: none; }
}

/* very small phones */
@media (max-width: 340px) {
  .title-menu { grid-template-columns: repeat(3, 1fr); }
  .evo { width: 122px; }
  .ar-t { display: none; }
  .ap { width: 4px; height: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .04s !important;
  }
  .crt::after { display: none; }
}

/* ==========================================================================
   スマートゲーム共通パーツ
   ========================================================================== */

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  color: #fff;
  font: 16px/1.6 var(--f);
  padding: 2rem;
}

/* 共通ヘッダーのメニューから click() されるだけの隠しボタン */
.sgh-hooks {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* フッター（バージョン・クレジット）。タイトル画面のときだけ見せる */
.sg-credits {
  position: fixed;
  left: 0; right: 0;
  bottom: max(var(--ad-space, 0px), var(--sa-b));
  z-index: 3;
  display: none;
  padding: 4px 8px 6px;
  text-align: center;
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: .06em;
  color: var(--txt-3);
  pointer-events: none;
}
.sg-credits p { margin: 0; }
.sg-credits a {
  color: var(--txt-2);
  text-decoration: none;
  pointer-events: auto;
}
.sg-credits a:hover { color: var(--cyan); }
body.on-title .sg-credits { display: block; }
/* タイトル画面の下端をクレジットぶん空ける */
.screen--title .scr-ft { padding-bottom: 34px; }

/* ==========================================================================
   全国ランキング（SGRanking 共通モジュール / js/ranking.js）
   body 直下（#ui の外）に生えるので pointer-events は既定のまま。
   ========================================================================== */
.sgr-hidden { display: none !important; }

.sgr-overlay {
  position: fixed;
  inset: 0;
  /* 共通ヘッダー(2147482500)・フッター広告(2147482000)より上に出す */
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(2, 4, 10, .84);
  font-family: var(--f);
  color: var(--txt);
  -webkit-user-select: text;
  user-select: text;
}

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  color: var(--txt);
  border: 1px solid var(--line-hi);
  border-radius: var(--r);
  padding: 20px 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .7), 0 0 0 1px rgba(53, 240, 255, .08), 0 0 34px rgba(53, 240, 255, .12);
}

.sgr-title {
  margin: 0;
  font-family: var(--f-d);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .12em;
  text-align: center;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(53, 240, 255, .5);
}

.sgr-tabs { display: flex; gap: 6px; justify-content: center; }

.sgr-tab {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  background: rgba(7, 12, 24, .8);
  color: var(--txt-2);
  cursor: pointer;
}
.sgr-tab-active {
  background: var(--cyan);
  border-color: var(--cyan);
  color: var(--ink);
}

.sgr-register-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  color: var(--amber);
}

.sgr-form { display: flex; gap: 8px; }

.sgr-name {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  font-size: 16px;
  font-family: inherit;
  padding: 9px 10px;
  border: 1px solid var(--line-hi);
  border-radius: var(--r);
  background: var(--ink-2);
  color: var(--txt);
}
.sgr-name:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(53, 240, 255, .25); }

.sgr-submit {
  border: 1px solid var(--cyan);
  border-radius: var(--r);
  padding: 9px 18px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  background: var(--cyan);
  color: var(--ink);
  cursor: pointer;
}
.sgr-submit:hover { filter: brightness(1.1); }
.sgr-submit:disabled { opacity: .5; cursor: default; }

.sgr-error {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--pink);
}

.sgr-status {
  margin: 0;
  font-size: 13px;
  text-align: center;
  color: var(--txt-2);
}

.sgr-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.sgr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r);
  font-size: 14px;
}
.sgr-row:nth-child(even) { background: rgba(53, 240, 255, .06); }
.sgr-row.sgr-row-me {
  background: var(--cyan);
  color: var(--ink);
}

.sgr-rank {
  width: 2em;
  text-align: right;
  font-weight: 700;
  flex-shrink: 0;
}

.sgr-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sgr-row-score { font-weight: 700; flex-shrink: 0; font-variant-numeric: tabular-nums; }

.sgr-close {
  border: 1px solid var(--line-hi);
  border-radius: var(--r);
  padding: 11px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  background: rgba(7, 12, 24, .8);
  color: var(--txt);
  cursor: pointer;
}
.sgr-close:hover { background: rgba(53, 240, 255, .12); }

/* リザルト画面に差し込まれる登録CTA */
.sgr-cta {
  margin: 0 0 10px;
  text-align: center;
  pointer-events: auto;
}

.sgr-cta-msg {
  margin: 0 0 7px;
  font-size: 14px;
  font-weight: 700;
  color: var(--amber);
  text-shadow: 0 0 10px rgba(255, 209, 102, .4);
}

.sgr-cta-btn {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--amber);
  border-radius: var(--r);
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #ffe08a, #f2b83c);
  color: #2a1d00;
  cursor: pointer;
  box-shadow: 0 3px 16px rgba(255, 209, 102, .35);
}
.sgr-cta-btn:hover { filter: brightness(1.06); }

.sgr-cta-link {
  border: none;
  background: none;
  padding: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--txt-2);
  text-decoration: underline;
  cursor: pointer;
}
.sgr-cta-link:hover { color: var(--txt); }

/* ==========================================================================
   フッター固定バナー広告（スマホ表示時のみ / js/ad-banner.js が挿入する）
   --ad-h    : 広告そのものの高さ。広告なしのときは 0px
   --ad-space: レイアウトが空けるべき高さ（広告 + セーフエリア）
   ========================================================================== */
:root {
  --ad-h: 0px;
  --ad-space: 0px;
}
html.has-ad-banner {
  --ad-space: calc(var(--ad-h, 0px) + env(safe-area-inset-bottom, 0px));
}

.ad-banner {
  /* height は広告そのものの高さ。セーフエリアぶんの padding は外側に足す */
  box-sizing: content-box;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  /* ランキング等の全画面オーバーレイ（2147483000）よりは下に置く */
  z-index: 2147482000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  height: var(--ad-h, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  background: rgba(14, 16, 20, 0.86);
  /* border ではなく inset shadow にして、枠線ぶん高さがずれないようにする */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.ad-banner__frame {
  display: block;
  width: 100%;
  height: var(--ad-h, 0px);
  border: 0;
  color-scheme: light;
}

@media print {
  .ad-banner { display: none; }
}

/* --- how to play ---------------------------------------------------------- */
.howto-sec { margin: 0 0 14px; }
.howto-sec .gsw-h { margin-bottom: 6px; }
.howto-sec .note { margin: 0; line-height: 1.75; }
.howto-sec .note b { color: var(--cyan); font-weight: 700; }
.howto-sec .note em { color: var(--pink); font-style: normal; font-weight: 700; }
.howto-sec .key-row + .key-row { margin-top: 4px; }
