/* 霓虹裂隙 — theme tokens + shared UI components (round 15: thin sci-fi glass redesign).
   Chrome art: UI-SF-BTN (1480x201), UI-SF-PANEL (1400x759), UI-SF-PLATE (1489x234), bound as 9-slice border-image.
   Panels / plates / cards draw their shell on a ::before layer (lowered opacity + backdrop blur) so the glass reads light
   while live text stays fully opaque above it. Touch rings, bars, crosshair and focus rings are code. */
:root {
  --nr-bg: #070a16;
  --nr-primary: #27e6ff;
  --nr-primary-dim: rgba(39, 230, 255, .55);
  --nr-hair: rgba(39, 230, 255, .38);
  --nr-secondary: #ff2e88;
  --nr-accent: #ffb224;
  --nr-danger: #ff4d3d;
  --nr-text: #e9f4ff;
  --nr-muted: #8fa3c4;
  --nr-glass: rgba(6, 14, 28, .34);
  --nr-gap: 12px;
  --nr-ease: cubic-bezier(.2, .8, .2, 1);
  --nr-fast: 140ms;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  /* shell scales (CSS px per source px) */
  --panel-k: .3;
  --card-k: .2;
  --plate-k: .3;
}

#scene { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; outline: none; }
#ui { position: fixed; inset: 0; pointer-events: none; color: var(--nr-text); font-family: var(--yoroll-font-body, sans-serif); user-select: none; -webkit-user-select: none; }
.screen { position: absolute; inset: 0; pointer-events: none; }
.screen[hidden] { display: none; }
.screen button, .screen .nr-touch, #lookpad { pointer-events: auto; }

/* ---------- shared components ---------- */

/* UI-SF-BTN: slim glass strip. Slice: caps 150 / 170, rails 60. Measured inner field inset 44/5/43/14 (source px). */
.nr-btn {
  position: relative; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 200px; min-height: 50px; margin: 0; padding: 0 30px 2px; cursor: pointer;
  font-family: var(--yoroll-font-body, sans-serif); font-weight: 500; font-size: 17px; letter-spacing: .14em; line-height: 1.2;
  color: var(--nr-text); white-space: nowrap; text-shadow: 0 0 8px rgba(39, 230, 255, .45);
  border: 1px solid transparent; background: none;
  border-image-source: url("assets/ui_sf_btn.webp");
  border-image-slice: 60 170 60 150 fill;
  border-image-width: 15px 42px 15px 37px;
  border-image-repeat: stretch;
  transition: transform var(--nr-fast) var(--nr-ease), filter var(--nr-fast) var(--nr-ease), opacity var(--nr-fast);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.nr-btn:hover { filter: brightness(1.25) drop-shadow(0 0 6px rgba(39, 230, 255, .45)); }
.nr-btn:active { transform: translateY(1px); filter: brightness(1.5); }
.nr-btn:focus-visible { outline: 1px solid var(--nr-accent); outline-offset: 3px; }
.nr-btn.is-secondary { opacity: .78; filter: saturate(.35); color: #c6d4ea; text-shadow: none; }
.nr-btn.is-secondary:hover { opacity: 1; filter: saturate(.8) brightness(1.15); }
.nr-btn.is-secondary:active { filter: saturate(1) brightness(1.4); }
.nr-btn.is-compact { min-width: 88px; min-height: 40px; padding: 0 22px 1px; font-size: 15px; letter-spacing: .08em; border-image-width: 11px 30px 11px 27px; }
.nr-btn.is-on, .nr-btn.is-on:hover { opacity: 1; filter: hue-rotate(-155deg) saturate(1.6) brightness(1.15); color: #fff3dc; text-shadow: 0 0 8px rgba(255, 178, 36, .6); }
.nr-btn[disabled], .nr-btn[disabled]:hover { opacity: .4; filter: grayscale(.9); cursor: default; }
.nr-btn[hidden] { display: none; }

/* glass shell layer shared by panel / plate / card */
.nr-panel, .nr-plate, .nr-card { isolation: isolate; }
.nr-panel::before, .nr-plate::before, .nr-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border: 1px solid transparent; border-image-repeat: stretch;
}

/* UI-SF-PLATE: HUD readout strip. Slice: end brackets 120, rails 30; inner field inset 37/7/31/11 (source px). */
.nr-plate {
  position: relative; box-sizing: border-box; margin: 0; padding: 8px 30px 10px;
  font-size: 14px; line-height: 1.45; color: var(--nr-text);
}
.nr-plate::before {
  border-image-source: url("assets/ui_sf_plate.webp");
  border-image-slice: 30 120 30 120 fill;
  border-image-width: calc(30px * var(--plate-k)) calc(120px * var(--plate-k));
  opacity: .72;
}

.nr-backdrop {
  position: fixed; inset: 0; z-index: 50; pointer-events: auto;
  display: flex; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  background-color: rgba(3, 6, 14, .58);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}

/* UI-SF-PANEL: thin glass dialog. Slice 180 / 190 corners (bracket ornaments). Inner field inset 15/47/12/41 (source px);
   padding additionally keeps live text clear of the corner brackets (≈185 x 175 source px). */
.nr-panel {
  position: relative; box-sizing: border-box;
  display: flex; flex-direction: column;
  width: min(560px, 100%); max-height: 100%;
  padding: 34px 40px 32px;
  color: var(--nr-text);
}
.nr-panel::before {
  border-image-source: url("assets/ui_sf_panel.webp");
  border-image-slice: 180 190 180 190 fill;
  border-image-width: calc(180px * var(--panel-k)) calc(190px * var(--panel-k));
  opacity: .9;
}
.nr-panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--nr-gap); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--nr-hair); }
.nr-panel-title { margin: 0; font-size: 24px; letter-spacing: .1em; color: var(--nr-primary); text-shadow: 0 0 12px rgba(39, 230, 255, .45); font-family: var(--yoroll-font-title, sans-serif); font-style: var(--yoroll-font-title-style, normal); font-weight: var(--yoroll-font-title-weight, 400); }
.nr-close {
  flex: none; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 40px; padding: 0 0 2px; cursor: pointer; pointer-events: auto;
  color: var(--nr-text); font-size: 20px; line-height: 1; background: none;
  border: 1px solid transparent;
  border-image-source: url("assets/ui_sf_btn.webp");
  border-image-slice: 60 170 60 150 fill;
  border-image-width: 11px 21px 11px 19px;
  opacity: .8;
}
.nr-close:hover { opacity: 1; }
.nr-close:active { filter: brightness(1.5); }
.nr-panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; font-size: 15px; line-height: 1.7; color: #cfdcf0; }
.nr-panel-body p { margin: 0 0 10px; }
.nr-panel-actions { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--nr-gap); margin-top: 18px; padding: 0 8px; }
.nr-panel-actions .nr-btn { flex: 1 1 170px; }

.nr-row { display: flex; align-items: center; justify-content: space-between; gap: var(--nr-gap); padding: 9px 0; border-bottom: 1px solid rgba(39, 230, 255, .14); }
.nr-row-label { flex: 1 1 auto; color: var(--nr-text); letter-spacing: .04em; }
.nr-seg { display: flex; gap: 6px; flex: none; }
.nr-seg .nr-btn { min-width: 62px; }
.nr-keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; margin: 0 0 10px; }
.nr-keys dt { color: var(--nr-primary); white-space: nowrap; letter-spacing: .06em; }
.nr-keys dd { margin: 0; }

/* ---------- loading ---------- */
#screen-loading { display: flex; align-items: center; justify-content: center; pointer-events: auto; background-color: var(--nr-bg); }
/* key art sits on its own layer and is only shown once the whole image is decoded (html.art-ready), so it never paints in bit by bit */
#screen-loading::before { content: ""; position: absolute; inset: 0; opacity: 0;
  background-image: linear-gradient(rgba(5, 8, 18, .6), rgba(5, 8, 18, .8)), url("assets/title_keyart.webp"); background-size: cover; background-position: 70% 50%; }
.art-ready #screen-loading::before { opacity: 1; }
#screen-loading[hidden] { display: none; }
.load-box { position: relative; z-index: 1; width: min(420px, 82vw); text-align: center; }
#ui-prewarm { position: fixed; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; opacity: .01; pointer-events: none; z-index: -1; }
#ui-prewarm i { position: absolute; left: 0; top: 0; width: 1px; height: 1px; background-size: 1px 1px; }
#ui-prewarm .pw-btn { background-image: url("assets/ui_sf_btn.webp"); }
#ui-prewarm .pw-plate { background-image: url("assets/ui_sf_plate.webp"); }
#ui-prewarm .pw-panel { background-image: url("assets/ui_sf_panel.webp"); }
.logo { margin: 0; font-size: clamp(44px, 8.6vw, 100px); line-height: 1.05; letter-spacing: .06em; color: var(--nr-text);
  text-shadow: 0 0 14px rgba(39, 230, 255, .55), 2px 0 0 rgba(255, 46, 136, .55); }
.logo-sub { display: flex; align-items: center; gap: 12px; margin: 8px 0 0; font-size: clamp(14px, 2.1vw, 20px); letter-spacing: .55em; color: var(--nr-primary); }
.logo-sub::before { content: ""; flex: none; width: 34px; height: 1px; background-color: var(--nr-secondary); box-shadow: 0 0 6px var(--nr-secondary); }
.load-box .logo-sub { justify-content: center; }
.load-bar { position: relative; height: 2px; margin: 28px 0 10px; background-color: rgba(39, 230, 255, .16); }
.load-bar::before, .load-bar::after { content: ""; position: absolute; top: -4px; width: 1px; height: 10px; background-color: var(--nr-primary-dim); }
.load-bar::before { left: 0; } .load-bar::after { right: 0; }
.load-bar i { display: block; width: 0; height: 100%; background-color: var(--nr-primary); box-shadow: 0 0 8px var(--nr-primary); transition: width 200ms linear; }
#load-text { margin: 0 0 14px; font-size: 13px; letter-spacing: .2em; color: var(--nr-muted); min-height: 1.5em; }

/* ---------- title: left column over live scene ---------- */
#screen-title { display: flex; align-items: center; background-image: linear-gradient(90deg, rgba(4, 7, 16, .82) 0%, rgba(4, 7, 16, .42) 38%, rgba(4, 7, 16, 0) 62%); }
#screen-title[hidden] { display: none; }
.title-col { box-sizing: border-box; width: min(46%, 620px); min-width: 280px; padding: calc(20px + var(--safe-t)) 20px calc(20px + var(--safe-b)) calc(max(32px, 5vw) + var(--safe-l)); }
.title-note { margin: 16px 0 0; padding-left: 12px; border-left: 1px solid var(--nr-accent); font-size: 14px; letter-spacing: .06em; color: #d9c6a0; }
.title-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: clamp(18px, 4vh, 40px); }
.title-actions .nr-btn { width: min(270px, 100%); justify-content: flex-start; padding-left: 46px; }

#lang-switch { position: absolute; z-index: 2; top: calc(14px + var(--safe-t)); right: calc(20px + var(--safe-r)); }
#lang-switch .nr-btn { min-width: 84px; min-height: 44px; font-size: 14px; }
html.lang-en .title-actions .nr-btn, html.lang-en .nr-panel-actions .nr-btn { letter-spacing: .04em; }
#title-records { position: absolute; right: calc(20px + var(--safe-r)); bottom: calc(20px + var(--safe-b)); padding: 7px 26px 9px; font-size: 13px; letter-spacing: .06em; text-align: right; white-space: nowrap; }
#title-records b { color: var(--nr-accent); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- combat HUD ---------- */
#vignette { position: absolute; inset: 0; opacity: 0; background-image: radial-gradient(ellipse at center, rgba(255, 77, 61, 0) 52%, rgba(255, 77, 61, .55) 100%); }
#vignette.is-low { opacity: .3; }
#vignette.is-hp { animation: nr-hurt 320ms ease-out; }
#vignette.is-shield { background-image: radial-gradient(ellipse at center, rgba(39, 230, 255, 0) 56%, rgba(39, 230, 255, .45) 100%); animation: nr-hurt 260ms ease-out; }
@keyframes nr-hurt { from { opacity: .95; } to { opacity: 0; } }

#lookpad { position: absolute; top: 0; right: 0; bottom: 0; width: 58%; touch-action: none; display: none; }
/* UI-SF-TOUCH (code): hairline double ring over light glass */
.nr-touch {
  position: absolute; box-sizing: border-box; border-radius: 50%;
  border: 1px solid var(--nr-primary-dim);
  background-color: var(--nr-glass);
  background-image: radial-gradient(circle, rgba(39, 230, 255, .1) 0%, rgba(39, 230, 255, 0) 62%);
  box-shadow: inset 0 0 0 5px rgba(5, 10, 22, .25), inset 0 0 0 6px rgba(39, 230, 255, .22), 0 0 10px rgba(39, 230, 255, .18);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  touch-action: none; display: none;
}
#stick { left: calc(24px + var(--safe-l)); bottom: calc(24px + var(--safe-b)); width: 128px; height: 128px; }
#stick::before { content: ""; position: absolute; inset: 22%; border-radius: 50%; border: 1px dashed rgba(39, 230, 255, .25); pointer-events: none; }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; box-sizing: border-box; border-radius: 50%;
  border: 1px solid var(--nr-primary); background-color: rgba(39, 230, 255, .22); box-shadow: 0 0 10px rgba(39, 230, 255, .5); pointer-events: none; }
.tbtn { align-items: center; justify-content: center; padding: 0; margin: 0; color: var(--nr-text); font-family: var(--yoroll-font-hud, sans-serif); font-weight: 500; font-size: 14px; letter-spacing: .08em; line-height: 1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
#tb-fire { right: calc(24px + var(--safe-r)); bottom: calc(28px + var(--safe-b)); width: 92px; height: 92px; font-size: 17px; color: var(--nr-primary); border-color: var(--nr-primary); }
#tb-dodge { right: calc(130px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); width: 66px; height: 66px; }
#tb-reload { right: calc(36px + var(--safe-r)); bottom: calc(134px + var(--safe-b)); width: 58px; height: 58px; }
#tb-aim { right: calc(122px + var(--safe-r)); bottom: calc(104px + var(--safe-b)); width: 58px; height: 58px; }
.tbtn.is-down { background-color: rgba(39, 230, 255, .26); box-shadow: inset 0 0 0 1px var(--nr-primary), 0 0 16px rgba(39, 230, 255, .55); }
.tbtn.is-cd { opacity: .4; }
.is-touch #lookpad, .is-touch #stick { display: block; }
.is-touch .tbtn { display: flex; }

#hud-top { position: absolute; top: calc(10px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(520px, 46vw); }
#hud-wave { display: flex; align-items: baseline; gap: 16px; white-space: nowrap; padding: 6px 30px 8px; font-size: 14px; }
#wave-title { color: var(--nr-primary); font-weight: 500; font-size: 16px; letter-spacing: .08em; }
#wave-sub { color: var(--nr-text); }
#hud-credits-box { color: var(--nr-muted); }
#hud-credits { display: inline-block; min-width: 4ch; text-align: right; color: var(--nr-accent); font-weight: 500; font-variant-numeric: tabular-nums; }
#hud-boss { width: 100%; padding: 6px 30px 10px; }
#hud-boss[hidden] { display: none; }
#boss-name { display: block; margin-bottom: 5px; font-size: 13px; letter-spacing: .1em; color: var(--nr-accent); white-space: nowrap; }

/* thin segmented meters (code) */
.bar { position: relative; height: 6px; background-color: rgba(143, 163, 196, .16); overflow: hidden;
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 9px, transparent 9px 11px); mask-image: repeating-linear-gradient(90deg, #000 0 9px, transparent 9px 11px); }
.bar i { display: block; width: 100%; height: 100%; transform-origin: 0 50%; background-color: var(--nr-primary); box-shadow: 0 0 6px currentColor; transition: transform 90ms linear; }
.bar-hp i { background-color: var(--nr-secondary); }
.bar-shield { height: 4px; }
.bar-boss { height: 6px; }
.bar-boss i { background-color: var(--nr-accent); }
.bar-boss.is-phase2 i { background-color: var(--nr-danger); }
.bar-reload { height: 2px; -webkit-mask-image: none; mask-image: none; }
.bar-reload i { background-color: var(--nr-accent); transition: none; }

#hud-vitals { position: absolute; left: calc(16px + var(--safe-l)); bottom: calc(16px + var(--safe-b)); width: 290px; display: grid; grid-template-columns: auto 1fr 3.4ch; align-items: center; gap: 7px 10px; padding: 10px 30px 12px; font-size: 13px; }
#hud-vitals .lbl { color: var(--nr-muted); white-space: nowrap; letter-spacing: .1em; }
#hud-vitals .num { text-align: right; font-variant-numeric: tabular-nums; }
#hud-ammo { position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); min-width: 180px; display: grid; grid-template-columns: 1fr auto; align-items: baseline; column-gap: 6px; row-gap: 4px; padding: 8px 30px 12px; text-align: right; }
#ammo-now { font-size: 36px; line-height: 1; font-weight: 400; letter-spacing: .02em; min-width: 2ch; font-variant-numeric: tabular-nums; text-shadow: 0 0 10px rgba(39, 230, 255, .5); }
#ammo-now.is-low { color: var(--nr-danger); text-shadow: 0 0 10px rgba(255, 77, 61, .6); }
#ammo-max { color: var(--nr-muted); font-size: 15px; white-space: nowrap; }
#hud-ammo .bar, #ammo-state { grid-column: 1 / -1; }
#ammo-state { min-height: 1.3em; font-size: 12px; line-height: 1.3; letter-spacing: .08em; color: var(--nr-accent); white-space: nowrap; }
.is-touch #hud-vitals { top: calc(10px + var(--safe-t)); bottom: auto; width: clamp(170px, 27vw, 220px); padding: 6px 22px 8px; gap: 5px 8px; font-size: 12px; }
.is-touch #hud-ammo { top: calc(10px + var(--safe-t)); bottom: auto; right: calc(76px + var(--safe-r)); min-width: 116px; padding: 5px 22px 8px; }
.is-touch #ammo-now { font-size: 24px; }
.is-touch #ammo-max { font-size: 13px; }
.is-touch #hud-top { width: min(520px, 40vw); }
.is-touch #hud-credits-box { display: none; }
.is-touch #hud-wave, .is-touch #hud-vitals, .is-touch #hud-ammo, #hud-wave, #hud-boss, #title-records { --plate-k: .22; }

#btn-pause { position: absolute; top: calc(10px + var(--safe-t)); right: calc(12px + var(--safe-r)); min-width: 58px; width: 58px; min-height: 40px; padding: 0 0 1px; font-size: 13px; letter-spacing: 0; border-image-width: 10px 20px 10px 18px; }
html:not(.is-touch) #btn-pause { top: calc(14px + var(--safe-t)); right: calc(16px + var(--safe-r)); }

#hud-combo { position: absolute; right: calc(22px + var(--safe-r)); top: 38%; display: flex; align-items: baseline; gap: 6px; white-space: nowrap; padding-right: 10px; border-right: 1px solid var(--nr-secondary); color: var(--nr-text); text-shadow: 0 0 8px rgba(255, 46, 136, .8); }
#hud-combo[hidden] { display: none; }
#combo-num { font-family: var(--yoroll-font-title, sans-serif); font-style: var(--yoroll-font-title-style, normal); font-weight: 400; font-size: 40px; line-height: 1.25; color: var(--nr-secondary); display: inline-block; box-sizing: content-box; min-width: 1.2ch; padding: 0 .18em 0 .08em; text-align: right; }
#combo-mult { font-style: normal; color: var(--nr-accent); font-size: 16px; }
.is-touch #hud-combo { top: 26%; }

/* thin crosshair with a centre dot */
#crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
#crosshair::after { content: ""; position: absolute; left: -1px; top: -1px; width: 2px; height: 2px; border-radius: 50%; background-color: var(--nr-text); box-shadow: 0 0 3px rgba(39, 230, 255, .9); }
#crosshair i { position: absolute; background-color: rgba(233, 244, 255, .92); box-shadow: 0 0 3px rgba(39, 230, 255, .9); }
#crosshair i:nth-child(1) { left: -.5px; top: -16px; width: 1px; height: 9px; }
#crosshair i:nth-child(2) { left: -.5px; top: 7px; width: 1px; height: 9px; }
#crosshair i:nth-child(3) { left: -16px; top: -.5px; width: 9px; height: 1px; }
#crosshair i:nth-child(4) { left: 7px; top: -.5px; width: 9px; height: 1px; }
/* sighted: the holo reticle in the weapon takes over, the screen crosshair fades out */
#crosshair i, #crosshair::after { transition: opacity 90ms linear; }
#crosshair.is-ads i, #crosshair.is-ads::after { opacity: 0; }
/* holographic smart-scope overlay drawn while aiming down sights */
#ads-scope { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#hitmarker { position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; opacity: 0; color: var(--nr-text);
  background-image: linear-gradient(45deg, transparent 47%, currentColor 47%, currentColor 53%, transparent 53%), linear-gradient(-45deg, transparent 47%, currentColor 47%, currentColor 53%, transparent 53%);
  -webkit-mask-image: radial-gradient(circle, transparent 0 5px, #000 5.5px); mask-image: radial-gradient(circle, transparent 0 5px, #000 5.5px); }
#hitmarker.is-hit { animation: nr-mark 130ms ease-out; }
#hitmarker.is-head { color: var(--nr-accent); animation: nr-mark 170ms ease-out; }
#hitmarker.is-kill { color: var(--nr-danger); animation: nr-mark-kill 260ms ease-out; }
@keyframes nr-mark { from { opacity: 1; transform: scale(1.25); } to { opacity: 0; transform: scale(1); } }
@keyframes nr-mark-kill { from { opacity: 1; transform: scale(1.7); } to { opacity: 0; transform: scale(1.1); } }
/* damage direction: a thin arc on a ring around the crosshair, rotated toward the attacker */
#dmg-dir { position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: 0; pointer-events: none; }
#dmg-dir i { position: absolute; left: -80px; top: calc(-1 * min(27vh, 200px)); width: 160px; height: 22px;
  background-image: radial-gradient(ellipse at 50% 100%, rgba(255, 77, 61, .95) 0%, rgba(255, 77, 61, .5) 42%, rgba(255, 77, 61, 0) 74%);
  clip-path: polygon(0 100%, 10% 40%, 50% 0, 90% 40%, 100% 100%, 50% 70%); filter: drop-shadow(0 0 5px rgba(255, 77, 61, .8)); }
#dmg-dir.is-on { animation: nr-dmg-dir 900ms ease-out; }
@keyframes nr-dmg-dir { 0% { opacity: 1; } 55% { opacity: .85; } 100% { opacity: 0; } }

#banner { position: absolute; left: 50%; top: 20%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 92vw; padding: 0 28px 8px; text-align: center; animation: nr-banner 2000ms both;
  border-bottom: 1px solid var(--nr-hair); }
#banner[hidden] { display: none; }
#banner-title { font-size: clamp(28px, 5.4vw, 54px); line-height: 1.1; letter-spacing: .12em; color: var(--nr-text); text-shadow: 0 0 14px rgba(39, 230, 255, .6), 2px 0 0 rgba(255, 46, 136, .55); white-space: nowrap; }
#banner-sub { font-size: clamp(13px, 1.8vw, 16px); color: var(--nr-accent); letter-spacing: .3em; white-space: nowrap; }
@keyframes nr-banner { 0% { opacity: 0; transform: translateX(-50%) scaleX(.6); } 10% { opacity: 1; transform: translateX(-50%) scaleX(1); } 82% { opacity: 1; transform: translateX(-50%); } 100% { opacity: 0; transform: translateX(-50%) translateY(-8px); } }

#float-layer { position: absolute; inset: 0; overflow: hidden; }
.float { position: absolute; transform: translate(-50%, -50%); font-size: 15px; font-weight: 500; white-space: nowrap; color: var(--nr-text); font-variant-numeric: tabular-nums; text-shadow: 0 0 6px rgba(39, 230, 255, .9), 0 1px 2px #000; animation: nr-float 620ms ease-out forwards; }
.float.is-head { color: var(--nr-accent); font-size: 19px; text-shadow: 0 0 8px rgba(255, 178, 36, .9), 0 1px 2px #000; }
.float.is-credit { color: var(--nr-accent); animation-duration: 900ms; }
.float.is-heal { color: #7dffb6; animation-duration: 900ms; }
@keyframes nr-float { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -46px; } }

/* ---------- upgrade terminal & result (full screens over the paused scene) ---------- */
#screen-upgrade, #screen-result {
  box-sizing: border-box; pointer-events: auto; display: flex; align-items: center; justify-content: center;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(14px + var(--safe-b)) calc(16px + var(--safe-l));
  background-color: rgba(3, 6, 14, .62);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
#screen-upgrade[hidden], #screen-result[hidden] { display: none; }
.up-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(900px, 100%); max-height: 100%; }
.up-title { margin: 0; font-size: clamp(24px, 4vw, 38px); line-height: 1.1; letter-spacing: .14em; color: var(--nr-primary); text-shadow: 0 0 14px rgba(39, 230, 255, .5); }
.up-sub { margin: 0; font-size: 14px; letter-spacing: .06em; color: var(--nr-muted); text-align: center; }
.up-row { box-sizing: border-box; display: flex; gap: 14px; width: 100%; flex: 1 1 auto; min-height: 0; padding: 6px; overflow: auto; -webkit-overflow-scrolling: touch; }
/* upgrade card: same UI-SF-PANEL shell at a smaller slice scale */
.nr-card {
  position: relative; box-sizing: border-box; flex: 1 1 0; min-width: 150px; margin: 0 auto; max-width: 270px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 250px; padding: 34px 26px 30px;
  border: 0; background: none; cursor: pointer; color: var(--nr-text); text-align: center;
  font-family: var(--yoroll-font-body, sans-serif); font-weight: 500;
  transition: filter var(--nr-fast) var(--nr-ease), transform var(--nr-fast) var(--nr-ease);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.nr-card::before {
  border-image-source: url("assets/ui_sf_panel.webp");
  border-image-slice: 180 190 180 190 fill;
  border-image-width: calc(180px * var(--card-k)) calc(190px * var(--card-k));
  opacity: .78; transition: opacity var(--nr-fast);
}
.nr-card:hover { filter: brightness(1.15); }
.nr-card:hover::before { opacity: .95; }
.nr-card:focus-visible { outline: 1px solid var(--nr-accent); outline-offset: 2px; }
/* UI-SF-CARD-RING (code): amber hairline inset ring + lift */
.nr-card[aria-pressed="true"] { transform: translateY(-3px); filter: drop-shadow(0 0 10px rgba(255, 178, 36, .45)); }
.nr-card[aria-pressed="true"]::before { opacity: 1; }
.nr-card[aria-pressed="true"]::after { content: ""; position: absolute; inset: 9px 10px; border: 1px solid var(--nr-accent); pointer-events: none;
  clip-path: polygon(0 0, 22% 0, 22% 1px, 78% 1px, 78% 0, 100% 0, 100% 100%, 0 100%); }
.up-icon { flex: none; width: 58px; height: 58px; color: var(--nr-primary); filter: drop-shadow(0 0 6px rgba(39, 230, 255, .55)); }
.up-icon svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: square; stroke-linejoin: miter; }
.up-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.up-name { font-size: 18px; line-height: 1.25; letter-spacing: .06em; }
.up-desc { font-size: 13px; line-height: 1.5; color: #c3d1e8; font-weight: 400; }
.up-confirm { flex: none; }

.result-panel { width: min(700px, 100%); }
.result-panel .nr-panel-head { justify-content: center; }
.result-grid { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px 34px; }
.result-rank { min-width: 1.3em; text-align: center; font-family: var(--yoroll-font-title, sans-serif); font-style: var(--yoroll-font-title-style, normal); font-weight: 400; font-size: clamp(72px, 19vh, 140px); line-height: 1; color: var(--nr-accent); text-shadow: 0 0 20px rgba(255, 178, 36, .5), 2px 0 0 rgba(255, 46, 136, .55); }
.result-rank small { display: block; margin-top: 8px; font-family: var(--yoroll-font-body, sans-serif); font-style: normal; font-weight: 500; font-size: 12px; letter-spacing: .4em; color: var(--nr-muted); text-shadow: none; }
.result-table { display: grid; grid-template-columns: 1fr auto; gap: 0 18px; margin: 0; font-size: 15px; line-height: 1.5; }
.result-table dt, .result-table dd { padding: 4px 0; border-bottom: 1px solid rgba(39, 230, 255, .12); }
.result-table dt { color: var(--nr-muted); letter-spacing: .06em; }
.result-table dd { margin: 0; text-align: right; color: var(--nr-text); font-variant-numeric: tabular-nums; }
.result-table dd.is-hot { color: var(--nr-accent); }
.result-note { min-height: 1.5em; margin: 10px 0 0; font-size: 13px; letter-spacing: .04em; color: var(--nr-accent); text-align: center; }
.is-fail .nr-panel-title { color: var(--nr-danger); text-shadow: 0 0 12px rgba(255, 77, 61, .45); }
.is-fail .result-rank { color: var(--nr-muted); text-shadow: 2px 0 0 rgba(255, 77, 61, .5); }
.is-fail::before { filter: hue-rotate(150deg) saturate(.8); }

/* ---------- short landscape phones ---------- */
@media (max-height: 420px) {
  :root { --panel-k: .24; --card-k: .16; }
  .logo { font-size: clamp(34px, 12vh, 62px); }
  .title-actions { flex-direction: row; flex-wrap: wrap; margin-top: 12px; }
  .title-actions .nr-btn { width: auto; min-width: 132px; min-height: 44px; padding: 0 22px; justify-content: center; font-size: 15px; }
  .title-note { margin-top: 8px; }
  #title-records { font-size: 12px; }
  .nr-panel { padding: 22px 30px 22px; }
  .nr-panel-actions { padding: 0 6px; margin-top: 10px; }
  .nr-panel-head { margin-bottom: 8px; padding-bottom: 6px; }
  .nr-panel-title { font-size: 20px; }
  .nr-panel-body { font-size: 14px; line-height: 1.55; }
  .nr-panel-actions .nr-btn { min-height: 44px; min-width: 120px; flex-basis: 120px; padding: 0 20px; font-size: 15px; }
  .up-wrap { gap: 8px; }
  .up-sub { font-size: 13px; }
  .nr-card { min-height: 0; padding: 24px 22px 20px; gap: 6px; }
  .up-icon { width: 40px; height: 40px; }
  .up-name { font-size: 16px; }
  .up-desc { font-size: 12px; line-height: 1.4; }
  .up-confirm { min-height: 44px; }
  .result-rank { font-size: clamp(56px, 24vh, 92px); }
  .result-table { font-size: 13px; line-height: 1.35; }
  .result-table dt, .result-table dd { padding: 2px 0; }
  .result-note { margin-top: 4px; }
  #stick { width: 116px; height: 116px; left: calc(18px + var(--safe-l)); bottom: calc(14px + var(--safe-b)); }
  #tb-fire { width: 84px; height: 84px; bottom: calc(18px + var(--safe-b)); }
  #tb-dodge { right: calc(120px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); width: 60px; height: 60px; }
  #tb-reload { bottom: calc(112px + var(--safe-b)); width: 54px; height: 54px; }
  #tb-aim { right: calc(112px + var(--safe-r)); bottom: calc(86px + var(--safe-b)); width: 52px; height: 52px; }
  #banner { top: 24%; }
}
/* ---------- portrait ---------- */
@media (orientation: portrait) {
  :root { --panel-k: .26; --card-k: .15; }
  #screen-title { align-items: flex-end; background-image: linear-gradient(0deg, rgba(4, 7, 16, .88) 0%, rgba(4, 7, 16, .5) 42%, rgba(4, 7, 16, 0) 70%); }
  .title-col { width: 100%; padding-bottom: calc(40px + var(--safe-b)); }
  #title-records { top: calc(68px + var(--safe-t)); bottom: auto; }
  #lookpad { width: 100%; height: 64%; bottom: auto; }
  #hud-top, .is-touch #hud-top { top: calc(74px + var(--safe-t)); width: min(520px, 88vw); }
  .up-row { flex-direction: column; }
  .nr-card { flex: none; width: 100%; max-width: none; min-width: 0; min-height: 0; flex-direction: row; justify-content: flex-start; text-align: left; padding: 22px 24px 20px; gap: 14px; }
  .result-grid { grid-template-columns: 1fr; }
  .nr-panel { padding: 28px 28px 26px; }
  .nr-panel-actions { padding: 0 4px; }
}
@media (max-width: 640px) {
  #hud-wave { gap: 10px; padding: 5px 22px 7px; font-size: 13px; }
  #wave-title { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .nr-btn, .nr-card, .load-bar i, .bar i { transition: none; }
  #banner { animation-name: nr-banner-still; }
  @keyframes nr-banner-still { 0% { opacity: 0; } 10% { opacity: 1; } 82% { opacity: 1; } 100% { opacity: 0; } }
}
