@font-face { font-family: 'Orbitron'; font-weight: 500; font-display: swap; src: url('fonts/orbitron-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Orbitron'; font-weight: 700; font-display: swap; src: url('fonts/orbitron-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Orbitron'; font-weight: 900; font-display: swap; src: url('fonts/orbitron-latin-900-normal.woff2') format('woff2'); }

:root {
  --bg: #04060d;
  --cyan: #4fe3ff;
  --mag: #ff3d9a;
  --gold: #ffd166;
  --red: #ff4d5e;
  --text: #e8f4ff;
  --dim: #8fa3bb;
  --panel: rgba(7, 12, 26, 0.74);
  --line: rgba(79, 227, 255, 0.22);
  --font: 'Orbitron', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; overscroll-behavior: none; }
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.hidden { display: none !important; }

#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
body.playing #game-canvas { cursor: none; }

/* ---------- full-screen effect layers ---------- */
#vignette, #flash, #damage-layer { position: fixed; inset: 0; pointer-events: none; }
#vignette { z-index: 5; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 30, 60, 0.55) 100%); transition: opacity 0.5s ease-out; }
#vignette.hit { opacity: 1; transition: none; }
body.low-hp #vignette { animation: lowhp 1s ease-in-out infinite; }
@keyframes lowhp { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.6; } }
#flash { z-index: 6; opacity: 0; background: radial-gradient(circle at center, rgba(255, 255, 255, 0.95), rgba(120, 220, 255, 0.55) 60%, rgba(255, 61, 154, 0.3)); transition: opacity 0.6s ease-out; }
#flash.on { opacity: var(--flash, 0.22); transition: none; } /* peak set by the light-effects setting (fx.setComfort) */
#damage-layer { z-index: 7; overflow: hidden; }
.dmg { position: absolute; left: 0; top: 0; font-weight: 700; font-size: 15px; color: #fff; text-shadow: 0 0 6px rgba(79, 227, 255, 0.9), 0 1px 2px #000; will-change: transform, opacity; white-space: nowrap; }
.dmg.crit { font-size: 22px; font-weight: 900; color: var(--gold); text-shadow: 0 0 10px rgba(255, 170, 40, 0.95), 0 1px 2px #000; }
.dmg.heal { color: #6dffb0; text-shadow: 0 0 8px rgba(60, 255, 150, 0.9), 0 1px 2px #000; }
.dmg.hurt { color: #ff6b7a; font-size: 18px; text-shadow: 0 0 8px rgba(255, 40, 70, 0.9), 0 1px 2px #000; }

#crosshair { position: fixed; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px; z-index: 30; pointer-events: none; display: none; border: 2px solid rgba(79, 227, 255, 0.9); border-radius: 50%; box-shadow: 0 0 10px rgba(79, 227, 255, 0.6); }
#crosshair::before, #crosshair::after { content: ''; position: absolute; left: 50%; top: 50%; background: #fff; }
#crosshair::before { width: 4px; height: 4px; margin: -2px; border-radius: 50%; }
#crosshair::after { width: 46px; height: 2px; margin: -1px -23px; background: linear-gradient(90deg, var(--cyan) 0 8px, transparent 8px 38px, var(--cyan) 38px); }
body.playing:not(.is-touch) #crosshair { display: block; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.28em; color: var(--cyan); opacity: 0.85; }

.hud-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#hud-vitals { position: absolute; left: calc(14px + var(--safe-l)); top: calc(14px + var(--safe-t)); width: min(300px, 44vw); padding: 10px 12px; display: grid; gap: 8px; }
.vital-row { display: flex; align-items: center; gap: 8px; }
.vital-label { flex: none; width: 42px; font-size: 12px; font-weight: 700; color: var(--dim); letter-spacing: 0.08em; }
.vital-label b { margin-left: 3px; color: var(--gold); font-size: 14px; }
.vital-num { flex: none; min-width: 34px; text-align: right; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { position: relative; flex: 1; height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar-fill, .bar-lag { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; transform-origin: left center; border-radius: inherit; }
.bar-hp .bar-fill { background: linear-gradient(90deg, #26e07a, #9dff6a); box-shadow: 0 0 10px rgba(60, 255, 140, 0.6); transition: transform 0.12s linear; }
.bar-hp .bar-lag { background: rgba(255, 90, 100, 0.85); transition: transform 0.6s ease-out 0.15s; }
.bar-hp.warn .bar-fill { background: linear-gradient(90deg, #ff3b4f, #ff8a4c); box-shadow: 0 0 10px rgba(255, 70, 70, 0.7); }
.bar-xp { height: 7px; }
.bar-xp .bar-fill { background: linear-gradient(90deg, #36b8ff, var(--cyan)); box-shadow: 0 0 8px rgba(79, 227, 255, 0.7); transition: transform 0.15s linear; }

#hud-wave { position: absolute; left: 50%; top: calc(12px + var(--safe-t)); transform: translateX(-50%); text-align: center; text-shadow: 0 2px 8px #000; }
#wave-text { font-size: 34px; font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; }
#enemy-text { font-size: 12px; color: var(--dim); letter-spacing: 0.06em; }

#hud-score { position: absolute; right: calc(70px + var(--safe-r)); top: calc(12px + var(--safe-t)); text-align: right; text-shadow: 0 2px 8px #000; }
#score-text { font-size: 26px; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
#combo-text { font-size: 12px; font-weight: 700; color: var(--gold); letter-spacing: 0.04em; }
#combo-text.hot { color: #ff8a3d; text-shadow: 0 0 10px rgba(255, 120, 40, 0.9); }
.combo-bar { margin: 4px 0 0 auto; width: 110px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
#combo-fill { width: 100%; height: 100%; background: var(--gold); transform-origin: right center; transform: scaleX(0); }

#btn-pause { position: absolute; right: calc(14px + var(--safe-r)); top: calc(14px + var(--safe-t)); width: 44px; height: 44px; pointer-events: auto; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 15px; font-weight: 900; letter-spacing: 0.1em; color: var(--cyan); }
#btn-pause:hover { background: rgba(79, 227, 255, 0.16); }

#boss-bar { position: absolute; left: 50%; top: calc(98px + var(--safe-t)); transform: translateX(-50%); width: min(560px, 76vw); text-align: center; }
#boss-name { font-size: 13px; font-weight: 700; letter-spacing: 0.3em; color: #ff8fc4; text-shadow: 0 0 10px rgba(255, 61, 154, 0.8); margin-bottom: 5px; }
.bar-boss { height: 10px; border: 1px solid rgba(255, 61, 154, 0.5); background: rgba(40, 0, 20, 0.7); }
.bar-boss .bar-fill { background: linear-gradient(90deg, #ff2d6f, var(--mag), #ff9ad0); box-shadow: 0 0 12px rgba(255, 61, 154, 0.8); transition: transform 0.12s linear; }

#hud-skills { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); display: flex; gap: 18px; }
.skill { --p: 1; --c: var(--cyan); position: relative; width: 68px; height: 68px; display: grid; place-content: center; text-align: center; border-radius: 50%; background: var(--panel); opacity: 0.75; }
.skill-ring { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.1) 0); -webkit-mask: radial-gradient(circle, transparent 60%, #000 62%); mask: radial-gradient(circle, transparent 60%, #000 62%); }
.skill-key { font-size: 12px; font-weight: 900; color: var(--c); }
.skill-name { font-size: 10px; color: var(--dim); margin-top: 2px; }
.skill.ready { opacity: 1; box-shadow: 0 0 18px color-mix(in srgb, var(--c) 55%, transparent); }
#skill-ult { --c: var(--mag); }
#skill-ult.ready { animation: ultready 0.9s ease-in-out infinite; }
@keyframes ultready { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

#radar { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); width: 140px; height: 140px; border-radius: 50%; background: rgba(4, 8, 18, 0.6); border: 1px solid var(--line); }

#announce { position: absolute; left: 0; right: 0; top: 24%; text-align: center; opacity: 0; transform: scale(0.9); transition: opacity 0.35s ease, transform 0.35s ease; padding: 0 16px; }
#announce.show { opacity: 1; transform: scale(1); }
#announce-title { font-size: clamp(30px, 6vw, 62px); font-weight: 900; letter-spacing: 0.12em; text-shadow: 0 0 24px rgba(79, 227, 255, 0.85), 0 4px 14px #000; }
#announce-sub { margin-top: 8px; font-size: clamp(13px, 2vw, 18px); color: #cfe6ff; letter-spacing: 0.2em; text-shadow: 0 2px 8px #000; }
#announce.danger #announce-title { color: #ff6aa8; text-shadow: 0 0 26px rgba(255, 61, 154, 0.95), 0 4px 14px #000; animation: danger 0.5s steps(2) infinite; }
@keyframes danger { 50% { opacity: 0.55; } }
#announce.good #announce-title { color: #8dffcb; text-shadow: 0 0 24px rgba(60, 255, 170, 0.8), 0 4px 14px #000; }

/* ---------- touch controls ---------- */
#touch-ui { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
.stick { position: absolute; bottom: calc(26px + var(--safe-b)); width: 132px; height: 132px; border-radius: 50%; pointer-events: auto; touch-action: none; background: radial-gradient(circle, rgba(79, 227, 255, 0.1), rgba(79, 227, 255, 0.03)); border: 2px solid rgba(79, 227, 255, 0.3); }
#stick-move { left: calc(22px + var(--safe-l)); }
#stick-aim { right: calc(22px + var(--safe-r)); border-color: rgba(255, 61, 154, 0.35); background: radial-gradient(circle, rgba(255, 61, 154, 0.1), rgba(255, 61, 154, 0.03)); }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(79, 227, 255, 0.45); box-shadow: 0 0 16px rgba(79, 227, 255, 0.5); will-change: transform; }
#stick-aim .stick-knob { background: rgba(255, 61, 154, 0.5); box-shadow: 0 0 16px rgba(255, 61, 154, 0.5); }
.touch-btn { --p: 1; position: absolute; right: calc(34px + var(--safe-r)); width: 66px; height: 66px; border-radius: 50%; pointer-events: auto; touch-action: none; font-size: 13px; font-weight: 700; color: #fff; border: 2px solid rgba(79, 227, 255, 0.6); background: conic-gradient(rgba(79, 227, 255, 0.45) calc(var(--p) * 360deg), rgba(8, 14, 28, 0.7) 0); }
#btn-dash { bottom: calc(176px + var(--safe-b)); right: calc(108px + var(--safe-r)); }
#btn-ult { bottom: calc(176px + var(--safe-b)); border-color: rgba(255, 61, 154, 0.7); background: conic-gradient(rgba(255, 61, 154, 0.55) calc(var(--p) * 360deg), rgba(8, 14, 28, 0.7) 0); }
.touch-btn.ready { box-shadow: 0 0 18px rgba(255, 255, 255, 0.45); }
body:not(.is-touch) #touch-ui { display: none; }
body.is-touch #hud-skills { display: none; }
body.is-touch #radar { right: auto; bottom: auto; left: calc(14px + var(--safe-l)); top: calc(86px + var(--safe-t)); width: 92px; height: 92px; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; background: rgba(2, 4, 10, 0.72); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.screen-menu { background: linear-gradient(180deg, rgba(2, 4, 10, 0.25), rgba(2, 4, 10, 0.5) 45%, rgba(2, 4, 10, 0.9)); backdrop-filter: none; -webkit-backdrop-filter: none; }
.screen-loading { z-index: 40; background: var(--bg); }

.menu-inner { width: min(640px, 100%); text-align: center; display: grid; gap: 16px; justify-items: center; }
.title { display: grid; gap: 6px; }
.title-cn { font-size: clamp(42px, 9.5vw, 86px); font-weight: 900; letter-spacing: 0.14em; margin-right: -0.14em; line-height: 1.1; background: linear-gradient(180deg, #ffffff 20%, #8eeaff 60%, #3aa8ff); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 22px rgba(79, 227, 255, 0.55)); }
.title-en { font-size: clamp(13px, 2.6vw, 22px); font-weight: 700; letter-spacing: 0.62em; margin-right: -0.62em; color: var(--mag); text-shadow: 0 0 14px rgba(255, 61, 154, 0.7); }
.tagline { font-size: clamp(14px, 2.2vw, 17px); color: #c5d8ee; letter-spacing: 0.12em; }
.best { min-height: 18px; font-size: 13px; color: var(--gold); letter-spacing: 0.08em; }

.btn { display: block; width: min(300px, 100%); min-height: 50px; padding: 12px 22px; border-radius: 10px; font-size: 16px; font-weight: 700; letter-spacing: 0.24em; text-indent: 0.24em; border: 1px solid var(--line); background: rgba(79, 227, 255, 0.07); transition: transform 0.12s ease, background 0.12s ease, box-shadow 0.12s ease; }
.btn:hover, .btn:focus-visible { background: rgba(79, 227, 255, 0.18); transform: translateY(-1px); outline: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { min-height: 58px; font-size: 19px; color: #021018; border: 0; background: linear-gradient(180deg, #a6f3ff, var(--cyan) 55%, #1fb6e6); box-shadow: 0 0 30px rgba(79, 227, 255, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.7); }
.btn-primary:hover, .btn-primary:focus-visible { background: linear-gradient(180deg, #d4faff, #7cecff 55%, #35c8f5); box-shadow: 0 0 44px rgba(79, 227, 255, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.8); }

.options { display: grid; gap: 10px; justify-items: center; }
.option-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.option-label { font-size: 12px; color: var(--dim); letter-spacing: 0.2em; margin-right: 2px; }
.chip { min-height: 38px; padding: 8px 14px; border-radius: 19px; font-size: 13px; letter-spacing: 0.06em; color: #cfe2f5; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(255, 255, 255, 0.05); }
.chip:hover { border-color: var(--cyan); }
.chip.active { color: #021018; font-weight: 700; background: var(--cyan); border-color: var(--cyan); }

.help { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 22px; font-size: 13px; color: var(--dim); text-align: left; padding: 14px 18px; border-radius: 12px; background: rgba(6, 10, 22, 0.6); border: 1px solid rgba(255, 255, 255, 0.07); }
.help-touch { grid-column: 1 / -1; display: none; }
body.is-touch .help li { display: none; }
body.is-touch .help .help-touch { display: block; text-align: center; }
kbd { display: inline-block; min-width: 22px; padding: 2px 6px; margin-right: 3px; border-radius: 5px; font-family: inherit; font-size: 11px; font-weight: 700; text-align: center; color: var(--text); background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-bottom-width: 2px; }

.panel, .panel-wide { width: min(430px, 100%); padding: 26px 24px; display: grid; gap: 14px; justify-items: center; text-align: center; border-radius: 16px; background: rgba(6, 11, 24, 0.94); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(79, 227, 255, 0.08); }
.panel-wide { width: min(920px, 100%); }
.panel h2, .panel-wide h2 { font-size: clamp(24px, 4.4vw, 34px); font-weight: 900; letter-spacing: 0.16em; }
.hint { font-size: 12px; color: var(--dim); }

.cards { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.card { --c: var(--cyan); position: relative; display: grid; gap: 9px; justify-items: center; align-content: start; padding: 20px 14px 18px; min-height: 216px; border-radius: 14px; text-align: center; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 14%, transparent), rgba(8, 12, 26, 0.9) 60%); transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease; animation: cardin 0.32s ease backwards; }
.card:nth-child(2) { animation-delay: 0.06s; }
.card:nth-child(3) { animation-delay: 0.12s; }
@keyframes cardin { from { opacity: 0; transform: translateY(18px); } }
.card:hover, .card:focus-visible { transform: translateY(-5px); border-color: var(--c); box-shadow: 0 10px 34px color-mix(in srgb, var(--c) 40%, transparent); outline: none; }
.card-key { position: absolute; left: 10px; top: 8px; font-size: 11px; font-weight: 700; color: var(--dim); }
.card-icon { width: 54px; height: 54px; padding: 12px; border-radius: 50%; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); box-shadow: 0 0 20px color-mix(in srgb, var(--c) 35%, transparent); }
.card-icon svg { width: 100%; height: 100%; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card-name { font-size: 18px; font-weight: 700; letter-spacing: 0.1em; color: #fff; }
.card-pips { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.card-pips i { width: 11px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.16); }
.card-pips i.on { background: var(--c); box-shadow: 0 0 6px var(--c); }
.card-pips i.next { background: #fff; animation: pip 0.7s ease-in-out infinite; }
@keyframes pip { 50% { opacity: 0.35; } }
.card-desc { font-size: 13px; line-height: 1.55; color: #c4d3e6; }

.stats { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stats > div { padding: 10px 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.045); }
.stats dt { font-size: 11px; color: var(--dim); letter-spacing: 0.16em; }
.stats dd { margin-top: 3px; font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.record { padding: 5px 16px; border-radius: 14px; font-size: 13px; font-weight: 900; letter-spacing: 0.3em; text-indent: 0.3em; color: #201400; background: var(--gold); box-shadow: 0 0 22px rgba(255, 209, 102, 0.7); }

#toast { position: fixed; left: 50%; bottom: calc(104px + var(--safe-b)); transform: translateX(-50%); z-index: 35; max-width: 90vw; padding: 9px 18px; border-radius: 20px; font-size: 13px; color: #dff3ff; background: rgba(6, 11, 24, 0.92); border: 1px solid var(--line); pointer-events: none; }

.loading-inner { display: grid; gap: 18px; justify-items: center; font-size: 13px; color: var(--dim); letter-spacing: 0.2em; }
.loading-inner { max-width: min(520px, 88vw); text-align: center; line-height: 1.7; }
#loading[data-state="error"] .loading-mark { display: none; }
#loading[data-state="error"] #loading-text { color: #ffb4bd; letter-spacing: 0.04em; font-size: 15px; }
.loading-hint { font-size: 13px; letter-spacing: 0.04em; color: var(--dim); }
.loading-hint a { color: var(--cyan); }
.gpu-note { max-width: 460px; padding: 9px 14px; border-radius: 10px; font-size: 12px; line-height: 1.6; letter-spacing: 0.02em; color: #ffe2a8; background: rgba(60, 40, 0, 0.55); border: 1px solid rgba(255, 209, 102, 0.35); }
.chip:disabled { opacity: 0.4; cursor: not-allowed; }
.chip:disabled:hover { border-color: rgba(255, 255, 255, 0.16); }
.loading-mark { width: 46px; height: 46px; border-radius: 50%; border: 3px solid rgba(79, 227, 255, 0.18); border-top-color: var(--cyan); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  #hud-vitals { width: min(210px, 46vw); padding: 8px 9px; gap: 6px; }
  .vital-label { width: 36px; font-size: 11px; }
  .vital-num { min-width: 28px; font-size: 12px; }
  #hud-wave { top: calc(70px + var(--safe-t)); }
  #hud-wave .kicker { display: none; }
  #wave-text { font-size: 24px; }
  #wave-text::before { content: 'WAVE '; font-size: 11px; letter-spacing: 0.2em; color: var(--cyan); vertical-align: middle; }
  #hud-score { right: calc(64px + var(--safe-r)); }
  #score-text { font-size: 19px; }
  .combo-bar { width: 80px; }
  #boss-bar { top: calc(124px + var(--safe-t)); }
  body.is-touch #radar { top: calc(130px + var(--safe-t)); width: 78px; height: 78px; }
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .card { min-height: 0; grid-template-columns: 48px 1fr; justify-items: start; text-align: left; column-gap: 12px; padding: 14px 14px 14px 12px; }
  .card-icon { grid-row: 1 / span 3; width: 48px; height: 48px; padding: 11px; align-self: center; }
  .card-key { display: none; }
  .card-pips { justify-content: flex-start; }
  .panel, .panel-wide { padding: 20px 16px; }
  .help { grid-template-columns: 1fr; }
}
@media (max-height: 520px) {
  .menu-inner { gap: 9px; }
  .title-cn { font-size: clamp(32px, 11vh, 60px); }
  .help { display: none; }
  .tagline { display: none; }
  .stick { width: 112px; height: 112px; bottom: calc(14px + var(--safe-b)); }
  #btn-dash, #btn-ult { bottom: calc(138px + var(--safe-b)); width: 58px; height: 58px; }
  #btn-dash { right: calc(100px + var(--safe-r)); }
  .panel, .panel-wide { gap: 9px; padding: 14px 16px; }
  .card { min-height: 0; padding: 12px 10px; gap: 5px; }
  .card-icon { width: 40px; height: 40px; padding: 9px; }
  .stats dd { font-size: 17px; }
  .stats > div { padding: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  #announce.danger #announce-title, #skill-ult.ready, body.low-hp #vignette, .card, .card-pips i.next { animation: none; }
}

/* ---------- ships / hangar / evolutions (v1.1) ---------- */
.ships { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ship-chip { display: grid; gap: 3px; align-content: center; min-height: 54px; padding: 9px 6px; border-radius: 10px; text-align: center; color: #cfe2f5; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(6, 10, 22, 0.6); transition: border-color 0.12s ease, background 0.12s ease; }
.ship-chip:hover:not(:disabled) { border-color: var(--cyan); }
.ship-chip.active { color: #fff; border-color: var(--cyan); background: rgba(79, 227, 255, 0.16); box-shadow: 0 0 18px rgba(79, 227, 255, 0.3); }
.ship-chip.locked { opacity: 0.5; cursor: not-allowed; }
.ship-name { font-size: 14px; font-weight: 700; letter-spacing: 0.1em; }
.ship-sub { font-size: 11px; line-height: 1.3; color: var(--dim); }
.ship-desc { min-height: 2.9em; max-width: 520px; font-size: 13px; line-height: 1.5; color: #c5d8ee; }
.btn-small { width: auto; min-height: 42px; padding: 8px 20px; font-size: 13px; letter-spacing: 0.14em; text-indent: 0.14em; }
.cores { font-size: 14px; color: var(--dim); letter-spacing: 0.16em; }
.cores b { margin-left: 8px; font-size: 26px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }
.panel-hangar { width: min(560px, 100%); }
.perks { list-style: none; width: 100%; display: grid; gap: 8px; text-align: left; }
.perk { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; align-items: center; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.045); }
.perk-name { font-size: 14px; font-weight: 700; letter-spacing: 0.08em; }
.perk-name i { margin-left: 8px; font-style: normal; font-size: 12px; color: var(--cyan); }
.perk-desc { grid-column: 1; font-size: 12px; color: var(--dim); }
.perk-buy { grid-column: 2; grid-row: 1 / span 2; min-width: 96px; }
.card-evo { border-width: 2px; border-color: var(--c); box-shadow: 0 0 26px color-mix(in srgb, var(--c) 45%, transparent); }
.card-badge { padding: 2px 10px; border-radius: 9px; font-size: 11px; font-weight: 900; letter-spacing: 0.3em; text-indent: 0.3em; color: #06101c; background: var(--c); }
.card-note { font-size: 11px; line-height: 1.5; color: var(--dim); }
.card-evo .card-note { color: var(--c); }
.evo-list { display: flex; flex-wrap: wrap; gap: 4px; }
.evo-list:empty { display: none; }
.evo-pill { --c: var(--cyan); padding: 2px 7px; border-radius: 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 12%, transparent); }
.unlock { font-size: 13px; color: var(--gold); letter-spacing: 0.06em; }
.help-pad { grid-column: 1 / -1; display: none; }
body.is-pad .help .help-pad { display: block; }
.pad-only { display: none; }
body.is-pad .pad-only { display: inline; }
body.is-pad #crosshair { display: none !important; }
.menu-inner { gap: 12px; }
@media (max-height: 800px) {
  .menu-inner { gap: 8px; }
  .title-cn { font-size: clamp(34px, 8.5vh, 64px); }
  .ship-desc { min-height: 0; }
  .ship-chip { min-height: 46px; padding: 6px; }
  .btn-primary { min-height: 50px; }
  .btn-small { min-height: 36px; padding: 6px 18px; }
  .help { padding: 9px 16px; gap: 5px 22px; font-size: 12px; }
  .gpu-note { padding: 6px 12px; line-height: 1.45; }
}
@media (max-height: 660px) {
  .tagline { display: none; }
  .options { gap: 7px; }
  .chip { min-height: 34px; padding: 6px 13px; }
}
@media (max-width: 720px) {
  .ships { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-note { grid-column: 1 / -1; }
  .card-badge { justify-self: start; }
}
@media (max-height: 520px) {
  .ships { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ship-chip { min-height: 36px; padding: 5px; }
  .ship-sub, .ship-desc, .menu-inner > .kicker { display: none; }
  .menu-inner { gap: 7px; }
  .btn-primary { min-height: 44px; font-size: 17px; }
  .btn-small { min-height: 32px; padding: 4px 16px; }
  .options { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; }
}

/* ---------- v1.2: language, daily challenge, threat levels, share ---------- */
:root { --font: 'Orbitron', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', 'Noto Sans JP', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif; }
.lang-box { position: absolute; right: calc(12px + var(--safe-r)); top: calc(12px + var(--safe-t)); z-index: 2; }
.lang-select { min-height: 34px; padding: 5px 10px; border-radius: 17px; font-family: inherit; font-size: 12px; color: #cfe2f5; background: rgba(6, 10, 22, 0.8); border: 1px solid rgba(255, 255, 255, 0.2); cursor: pointer; }
.lang-select:hover, .lang-select:focus-visible { border-color: var(--cyan); outline: none; }
.lang-select option { color: #e8f4ff; background: #0a1020; }
.menu-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.btn-small.fresh { border-color: var(--gold); color: #ffe7a8; box-shadow: 0 0 16px rgba(255, 209, 102, 0.35); }
.threat-row { gap: 6px; }
.threat-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.threat-chip { min-width: 38px; padding: 6px 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.threat-chip.active { background: var(--mag); border-color: var(--mag); color: #fff; }
.threat-desc { max-width: 560px; font-size: 12px; line-height: 1.45; color: #ffb9d9; }
#mode-text { margin-top: 2px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--gold); }
#mode-text:empty { display: none; }
.pause-mode { max-width: 380px; line-height: 1.6; color: #ffe2a8; }
.panel-daily { width: min(520px, 100%); }
.daily-date { font-size: 14px; font-weight: 700; letter-spacing: 0.12em; color: var(--gold); font-variant-numeric: tabular-nums; }
.daily-info { width: 100%; display: grid; gap: 8px; text-align: left; }
.daily-info > div { padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.045); }
.daily-info dt { font-size: 11px; color: var(--dim); letter-spacing: 0.16em; }
.daily-info dd { margin-top: 4px; font-size: 15px; font-weight: 700; }
.mods { list-style: none; display: grid; gap: 6px; font-weight: 400; }
.mod { --c: var(--cyan); display: grid; gap: 2px; padding-left: 10px; border-left: 3px solid var(--c); }
.mod b { font-size: 14px; color: var(--c); letter-spacing: 0.06em; }
.mod span { font-size: 12px; line-height: 1.45; color: #c4d3e6; }
.daily-rules { line-height: 1.6; text-align: left; }
.panel .best { min-height: 0; }
/* The title is 15 letters outside Chinese (5 characters in Chinese): keep it on one line, sized to fit the 640px column */
html:not([lang^="zh"]) .title-cn { white-space: nowrap; font-size: clamp(20px, min(6.4vw, 7.2vh), 48px); letter-spacing: 0.06em; margin-right: -0.06em; }
html:not([lang^="zh"]) .title-en { letter-spacing: 0.4em; margin-right: -0.4em; }
/* longer words outside Chinese: tighter tracking so buttons and labels fit */
html:not([lang^="zh"]) .btn { letter-spacing: 0.1em; text-indent: 0.1em; }
html:not([lang^="zh"]) .panel h2, html:not([lang^="zh"]) .panel-wide h2 { letter-spacing: 0.06em; }
html:not([lang^="zh"]) .card-name { font-size: 16px; letter-spacing: 0.04em; }
html:not([lang^="zh"]) .skill-name { font-size: 9px; }
html:not([lang^="zh"]) .stats dt, html:not([lang^="zh"]) .daily-info dt { letter-spacing: 0.06em; }
html:not([lang^="zh"]) .tagline, html:not([lang^="zh"]) .option-label { letter-spacing: 0.06em; }
html:not([lang^="zh"]) .record, html:not([lang^="zh"]) .card-badge { letter-spacing: 0.12em; text-indent: 0.12em; }
html:not([lang^="zh"]) #boss-name { letter-spacing: 0.16em; }
html:not([lang^="zh"]) .touch-btn { font-size: 11px; }
.gpu-note { max-width: 560px; }
/* Set by ui.fitMenu(): when the menu does not fit the window, optional lines are hidden, least important first */
.menu-inner.fit-1 .tagline, .menu-inner.fit-2 > .kicker, .menu-inner.fit-3 .ship-desc, .menu-inner.fit-4 .threat-desc,
.menu-inner.fit-5 .help, .menu-inner.fit-6 .gpu-note { display: none !important; }
/* below this width the language box would sit on top of the centred title, so the menu starts under it */
@media (max-width: 900px) and (min-height: 521px) {
  .screen-menu { padding-top: calc(46px + var(--safe-t)); }
}
@media (max-height: 800px) {
  .threat-desc { font-size: 11px; }
  .daily-rules { font-size: 11px; }
}
@media (max-height: 660px) {
  .threat-chip { min-height: 30px; padding: 4px 9px; }
  .panel-daily .kicker { display: none; }
}
@media (max-height: 520px) {
  .lang-select { min-height: 28px; padding: 3px 8px; }
  .panel-daily { gap: 7px; }
  .daily-info > div { padding: 6px 10px; }
}
@media (max-width: 720px) {
  .lang-box { right: calc(8px + var(--safe-r)); top: calc(8px + var(--safe-t)); }
  #mode-text { font-size: 10px; }
}

/* ---------- v1.3: floating touch sticks, power-ups, friend challenge, phone fixes ---------- */
@supports (height: 100dvh) { html, body { height: 100dvh; } }
body { -webkit-touch-callout: none; }
button, select { touch-action: manipulation; }
/* the left half of the screen moves and the right half aims; the zones stop below the top HUD so the pause button stays reachable */
.zone { position: absolute; top: calc(64px + var(--safe-t)); bottom: 0; width: 50%; pointer-events: auto; touch-action: none; }
#zone-move { left: 0; }
#zone-aim { right: 0; }
.stick { pointer-events: none; opacity: 0.5; transition: opacity 0.15s; }
.stick.held { opacity: 1; }
.buff-list { display: flex; flex-wrap: wrap; gap: 4px; }
.buff-list:empty { display: none; }
.buff { --c: #fff; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; color: var(--c); border: 1px solid var(--c); background: rgba(4, 8, 18, 0.65); }
.buff b { color: #fff; font-weight: 900; }
.dmg.power { font-size: 17px; font-weight: 900; letter-spacing: 0.08em; color: #fff; text-shadow: 0 0 10px rgba(255, 209, 102, 0.95), 0 1px 2px #000; }
.vs-box { display: grid; gap: 6px; justify-items: center; width: min(520px, 100%); padding: 10px 14px; border-radius: 12px; border: 1px solid var(--gold); background: rgba(40, 28, 6, 0.6); }
.vs-title { font-size: 12px; font-weight: 700; letter-spacing: 0.2em; color: var(--gold); }
.vs-text { font-size: 14px; color: #ffe7a8; }
@media (max-height: 520px) {
  .vs-box { padding: 6px 12px; gap: 4px; }
  .vs-text { font-size: 12px; }
}

/* top HUD as a grid: its pieces can grow (evolutions, power-ups, boss bar) without ever covering each other */
#hud-top { position: absolute; left: calc(14px + var(--safe-l)); right: calc(14px + var(--safe-r)); top: calc(12px + var(--safe-t)); display: grid; grid-template-columns: minmax(0, 1fr) min(560px, 40vw) minmax(0, 1fr); gap: 6px 10px; align-items: start; }
#hud-vitals { position: static; grid-column: 1; grid-row: 1 / span 2; width: min(300px, 100%); }
#hud-wave { position: static; transform: none; grid-column: 2; grid-row: 1; }
#hud-right { grid-column: 3; grid-row: 1 / span 2; justify-self: end; display: flex; gap: 10px; align-items: flex-start; }
#hud-score { position: static; }
#btn-pause { position: static; flex: none; }
#boss-bar { position: static; transform: none; grid-column: 2; grid-row: 2; width: 100%; }
#radar { position: fixed; }
body.is-touch #radar { position: static; grid-column: 1; grid-row: 3; width: 84px; height: 84px; }
@media (orientation: portrait) and (max-width: 720px) {
  #hud-top { grid-template-columns: minmax(0, 1fr) auto; }
  #hud-vitals { width: min(230px, 100%); }
  #hud-right { grid-column: 2; grid-row: 1; }
  #hud-wave { grid-column: 2; grid-row: 2; justify-self: end; text-align: right; }
  #boss-bar { grid-column: 1 / -1; grid-row: 3; }
  body.is-touch #radar { grid-row: 4; width: 78px; height: 78px; }
  #announce { top: 36%; }
}
.btn-row { width: 100%; display: grid; gap: 14px; justify-items: center; }
.menu-inner.fit-7 .title-en, .menu-inner.fit-8 .best { display: none !important; }
@media (max-height: 520px) {
  .vs-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px; width: auto; max-width: 100%; padding: 4px 12px; }
  .vs-title { display: none; }
}
/* phones held sideways: upgrade cards side by side, result screens in one view */
@media (orientation: landscape) and (max-height: 520px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .card { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 8px; gap: 4px; }
  .card-icon { grid-row: auto; width: 34px; height: 34px; padding: 7px; }
  .card-name, html:not([lang^="zh"]) .card-name { font-size: 14px; }
  .card-desc { font-size: 11px; line-height: 1.35; }
  .card-note { grid-column: auto; font-size: 10px; line-height: 1.3; }
  .card-badge { justify-self: center; }
  .card-pips { justify-content: center; }
  .panel-wide { padding: 10px 12px; gap: 6px; }
  .panel-wide .kicker, .panel-wide .hint, .panel > .kicker { display: none; }
  .panel h2, .panel-wide h2 { font-size: 20px; }
  .panel { width: min(640px, 100%); gap: 8px; padding: 12px 16px; }
  .panel-daily, .panel-hangar { width: min(720px, 100%); }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .stats dd { font-size: 16px; }
  .btn-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .btn-row .btn { width: auto; min-height: 40px; padding: 8px 16px; font-size: 14px; letter-spacing: 0.1em; text-indent: 0.1em; }
  .daily-info { grid-template-columns: 1fr 1.5fr; }
  .perks { grid-template-columns: 1fr 1fr; }
}

/* short phones held upright (e.g. 360x640, 375x667): result screens and upgrade cards in one view */
@media (orientation: portrait) and (max-height: 720px) {
  .vs-box { padding: 6px 12px; gap: 4px; }
  .panel, .panel-wide { gap: 8px; padding: 12px 12px; }
  .panel > .kicker, .panel-wide .kicker, .panel-wide .hint { display: none; }
  .stats { gap: 6px; }
  .stats > div { padding: 5px 6px; }
  .stats dd { font-size: 17px; margin-top: 1px; }
  .btn-row { gap: 8px; }
  .btn-row .btn { min-height: 40px; padding: 8px 16px; font-size: 15px; }
  .btn-row .btn-primary { min-height: 46px; font-size: 17px; }
  .card { grid-template-columns: 40px 1fr; padding: 9px 12px 9px 10px; gap: 3px; column-gap: 10px; }
  .card-icon { width: 40px; height: 40px; padding: 9px; }
  .card-name, html:not([lang^="zh"]) .card-name { font-size: 15px; }
  .card-desc { font-size: 12px; line-height: 1.35; }
  .card-note { font-size: 10px; line-height: 1.3; }
}
@media (max-height: 520px), (max-width: 720px) {
  #announce-sub { letter-spacing: 0.05em; }
  #announce-title { letter-spacing: 0.06em; }
}
/* touch screens fire by themselves whenever the right thumb is up, so the auto-fire switch (it only affects the mouse) is not shown */
body.is-touch .js-autofire { display: none; }
/* narrow screens: once the small heading above the title is hidden, keep the title clear of the language box */
@media (max-width: 900px) and (min-height: 521px) {
  .menu-inner.fit-2 .title { margin-top: 12px; }
}

/* ---------- v1.4: online leaderboard ---------- */
.panel-board { width: min(540px, 100%); gap: 12px; }
.board-list { list-style: none; width: 100%; display: grid; gap: 3px; max-height: min(42vh, 340px); overflow-y: auto; -webkit-overflow-scrolling: touch; text-align: left; }
.board-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; column-gap: 8px; align-items: baseline; padding: 5px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.045); font-size: 13px; }
.board-list li.me { background: rgba(79, 227, 255, 0.18); }
.board-list .rk { color: var(--dim); font-variant-numeric: tabular-nums; }
.board-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #eaf4ff; }
.board-list .sc { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.board-list .wv { grid-column: 2 / 4; font-size: 11px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; font-size: 13px; color: var(--dim); }
.name-input { width: 168px; min-height: 38px; padding: 6px 14px; border-radius: 19px; border: 1px solid rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.07); color: #fff; font: inherit; font-size: 16px; user-select: text; -webkit-user-select: text; }
.name-input:focus { outline: none; border-color: var(--cyan); }
.rank-line { font-size: 13px; color: var(--cyan); letter-spacing: 0.06em; }
@media (max-height: 560px) {
  .board-list { max-height: 30vh; }
  .panel-board { gap: 8px; padding-top: 14px; padding-bottom: 14px; }
  .panel-board > .kicker { display: none; }
}

/* v1.4: the menu got a leaderboard button and two comfort chips. On the smallest phones with long text (and a threat
   row or a friend challenge on top) they no longer fit, so as the last steps the menu drops the comfort chips, then
   the whole settings block. Both stay available on the pause screen. */
.menu-inner.fit-9 .opt-comfort, .menu-inner.fit-10 .options { display: none !important; }

/* ---------- v1.5: bonus objectives, live duel, confirm-twice buttons ---------- */
#obj-text { margin-top: 2px; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--gold); }
#obj-text:empty { display: none; }
#obj-text.done { color: #7dffb0; }
#obj-text.failed { color: var(--dim); text-decoration: line-through; font-weight: 400; }
.btn.armed { border-color: #ff5d73; color: #ffd0d6; }
.panel-duel { width: min(480px, 100%); gap: 12px; }
.duel-setup, .duel-room { width: 100%; display: grid; gap: 12px; justify-items: center; }
.code-input { width: 104px; text-align: center; text-transform: uppercase; letter-spacing: 0.3em; font-weight: 700; }
.duel-code-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; font-size: 13px; color: var(--dim); }
.duel-code-row b { font-size: 30px; letter-spacing: 0.3em; color: var(--gold); user-select: text; -webkit-user-select: text; }
.duel-players { list-style: none; width: 100%; display: grid; gap: 4px; text-align: left; }
.duel-players li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline; padding: 7px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.045); font-size: 14px; }
.duel-players li.me { background: rgba(79, 227, 255, 0.16); }
.duel-players .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #eaf4ff; }
.duel-players .sh { font-size: 12px; color: var(--dim); }
.duel-players .rd { font-size: 12px; color: var(--dim); }
.duel-players .rd.on { color: #7dffb0; font-weight: 700; }
.duel-note { font-size: 13px; color: #cfe2f5; }
.duel-note.big { font-size: 26px; font-weight: 900; color: var(--gold); letter-spacing: 0.1em; }
@media (max-height: 560px) {
  .panel-duel { gap: 8px; padding-top: 12px; padding-bottom: 12px; }
  .panel-duel > .kicker, .panel-duel > .hint:not(.duel-note) { display: none; }
  .duel-code-row b { font-size: 22px; }
  .panel-duel .btn { min-height: 40px; padding: 8px 16px; font-size: 14px; }
}

/* v1.5: arrow at the edge of the screen pointing to a "hold the zone" objective that is out of view */
#zone-arrow { position: fixed; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 4; will-change: transform; }
#zone-arrow::before { content: ''; position: absolute; left: -9px; top: -13px; border-style: solid; border-width: 13px 0 13px 20px;
  border-color: transparent transparent transparent var(--gold); filter: drop-shadow(0 0 6px rgba(255, 200, 80, 0.7)); opacity: 0.9; animation: zone-arrow 0.9s ease-in-out infinite; }
#zone-arrow.hidden { display: none; }
@keyframes zone-arrow { 0%, 100% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { #zone-arrow::before { animation: none; } }
