:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  --background: #080b16;
  --surface: rgba(18, 23, 38, 0.83);
  --surface-strong: #111624;
  --line: rgba(186, 202, 236, 0.13);
  --text: #edf2ff;
  --muted: #8490a9;
  --accent: #69f2de;
  --accent-soft: rgba(105, 242, 222, 0.12);
  --amber: #fbc574;
  --rose: #ff6981;
  --violet: #af95ff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--background);
  overscroll-behavior: none; touch-action: manipulation;
}

button { color: inherit; font: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

#app {
  position: relative; width: min(100%, 540px); height: 100%; height: 100dvh;
  margin: 0 auto; overflow: hidden; background: var(--background); isolation: isolate;
}

#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }

.screen {
  position: absolute; inset: 0; display: none;
  padding: calc(18px + var(--safe-top)) 23px calc(18px + var(--safe-bottom));
}
.screen.active { display: flex; }
.screen-home { flex-direction: column; overflow: hidden; background: linear-gradient(180deg, rgba(8,11,22,.2), rgba(8,11,22,.94) 80%); }

.home-topline, .currency-bar, .section-heading, .map-toggle, .hud-top, .hud-stats { display: flex; align-items: center; justify-content: space-between; }
.eyebrow { font-size: 9px; letter-spacing: 2px; color: var(--muted); font-weight: 700; }
.icon-button, .pause-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.025); color: var(--accent); }
.icon-button.muted { color: var(--muted); }
.sound-button { display: flex; width: 64px; align-items: center; justify-content: center; gap: 5px; border-radius: 20px; }
.sound-button span { font-size: 15px; }
.sound-button small { font-size: 8px; letter-spacing: .5px; }

.brand-block { position: relative; padding: 19px 0 15px; }
.brand-block h1 { position: relative; margin: 8px 0 5px; font-size: clamp(38px, 10vw, 49px); font-weight: 760; letter-spacing: 7px; }
.brand-block h1 span { color: var(--accent); }
.brand-caption { position: relative; margin: 0; font-size: 12px; color: var(--muted); }
.brand-orbit { position: absolute; top: -6px; right: 0; width: 126px; height: 126px; opacity: .48; }
.brand-orbit span { position: absolute; inset: 12px; border: 1px solid rgba(105,242,222,.25); transform: rotate(45deg); animation: orbit 17s linear infinite; }
.brand-orbit span:nth-child(2) { inset: 24px; border-color: rgba(175,149,255,.38); animation-duration: 11s; animation-direction: reverse; }
.brand-orbit span:nth-child(3) { inset: 38px; border-color: rgba(251,197,116,.55); animation-duration: 7s; }
@keyframes orbit { to { transform: rotate(405deg); } }

.currency-bar { flex: 0 0 auto; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.025); color: var(--muted); font-size: 11px; }
.currency-bar strong { margin-left: 5px; color: var(--text); font-size: 13px; }

.nav-tabs { display: flex; flex: 0 0 auto; gap: 24px; margin-top: 16px; border-bottom: 1px solid var(--line); }
.nav-tab { position: relative; padding: 10px 1px; border: 0; background: none; color: var(--muted); font-size: 12px; }
.nav-tab.active { color: var(--text); }
.nav-tab.active::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--accent); content: ""; }

.tab-panel { display: none; min-height: 0; flex: 1 1 auto; overflow-y: auto; padding: 14px 1px 8px; scrollbar-width: none; }
.tab-panel::-webkit-scrollbar { display: none; }
.tab-panel.active { display: block; }

.character-list { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.character-chip { position: relative; display: grid; height: 60px; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.025); font-size: 23px; }
.character-chip.selected { border-color: var(--character-color, var(--accent)); background: color-mix(in srgb, var(--character-color, var(--accent)) 11%, transparent); }
.character-chip.locked { color: #596276; }
.character-chip.locked::after { position: absolute; right: 4px; bottom: 3px; color: var(--muted); font-size: 8px; content: "锁"; }

.detail-card { margin-top: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(17, 22, 36, .79); }
.character-title { display: flex; align-items: center; justify-content: space-between; }
.character-title h3 { margin: 0; font-size: 17px; }
.role-label { font-size: 10px; color: var(--character-color, var(--accent)); }
.character-copy { margin: 8px 0 11px; line-height: 1.6; font-size: 11px; color: var(--muted); }
.stat-list { display: grid; gap: 8px; }
.stat-row { display: grid; grid-template-columns: 37px 1fr 30px; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.stat-track { height: 4px; overflow: hidden; border-radius: 4px; background: rgba(255,255,255,.08); }
.stat-track i { display: block; height: 100%; border-radius: inherit; background: var(--character-color, var(--accent)); }
.skill-description { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); line-height: 1.55; color: var(--muted); font-size: 10px; }
.skill-description strong { color: var(--text); }
.locked-callout { margin-top: 12px; color: var(--amber); font-size: 11px; line-height: 1.5; }

.section-heading { margin-bottom: 11px; color: var(--text); font-size: 11px; }
.section-heading strong { color: var(--muted); font-size: 10px; font-weight: 500; }
.option-list { display: grid; gap: 9px; }
.option-card { display: grid; grid-template-columns: 39px 1fr auto; align-items: center; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 12px; background: rgba(17,22,36,.75); text-align: left; }
.option-card.active { border-color: rgba(105,242,222,.65); background: rgba(105,242,222,.065); }
.option-card.unavailable { opacity: .58; }
.option-icon { display: grid; width: 37px; height: 37px; place-items: center; border-radius: 10px; background: rgba(255,255,255,.045); color: var(--option-color, var(--accent)); font-size: 19px; }
.option-copy strong { display: block; font-size: 11px; }
.option-copy small { display: block; margin-top: 4px; line-height: 1.45; color: var(--muted); font-size: 9px; }
.option-action { color: var(--amber); font-size: 10px; white-space: nowrap; }
.option-action.equipped { color: var(--accent); }
.research-pips { display: flex; gap: 3px; margin-top: 6px; }
.research-pips i { width: 12px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.13); }
.research-pips i.filled { background: var(--accent); }
.milestone-heading { margin-top: 18px; }
.milestone-list { display: grid; gap: 7px; }
.milestone-item { display: flex; gap: 8px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.milestone-item.complete { color: var(--accent); }

.launch-area { flex: 0 0 auto; padding-top: 8px; }
.map-toggle { width: 100%; margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); color: var(--muted); font-size: 10px; }
.map-toggle strong { color: var(--text); font-weight: 600; }
.start-button { display: flex; width: 100%; min-height: 50px; align-items: center; justify-content: space-between; padding: 0 17px; border: 0; border-radius: 11px; background: var(--accent); color: #071511; font-size: 14px; font-weight: 760; }
.start-button:disabled { background: #394351; color: #8a94a3; cursor: not-allowed; }
.launch-tip { margin: 8px 0 0; color: var(--muted); text-align: center; font-size: 9px; }

.hud { position: absolute; inset: 0; display: none; pointer-events: none; }
.hud.active { display: block; }
.xp-track { position: absolute; top: 0; right: 0; left: 0; height: max(4px, var(--safe-top)); overflow: hidden; background: rgba(255,255,255,.09); }
.xp-fill { width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), #a69dff); transition: width .18s; }
.hud-top { padding: calc(15px + var(--safe-top)) 18px 9px; }
.hud-level, .hud-center { display: grid; gap: 2px; }
.hud-level span, .hud-center span { color: var(--muted); font-size: 9px; letter-spacing: 1px; }
.hud-level strong { color: var(--accent); font-size: 22px; }
.hud-center { justify-items: center; padding-left: 10px; }
.hud-center strong { font-size: 18px; }
.pause-button { width: 36px; height: 36px; pointer-events: auto; }
.health-shell { position: relative; height: 6px; margin: 0 18px; overflow: hidden; border-radius: 6px; background: rgba(255,255,255,.09); }
.health-fill, .shield-fill { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .16s; }
.health-fill { background: linear-gradient(90deg, #ff687e, #ffa27a); }
.shield-fill { width: 0; background: rgba(105,242,222,.75); }
.hud-stats { padding: 6px 19px; color: var(--muted); font-size: 10px; }
.arena-radar { position: absolute; top: calc(119px + var(--safe-top)); right: 13px; display: grid; width: 99px; justify-items: center; gap: 4px; padding: 8px 6px 7px; border: 1px solid rgba(142,164,204,.16); border-radius: 11px; background: rgba(8,12,22,.78); }
.arena-radar.boss-active { top: calc(158px + var(--safe-top)); }
.radar-heading { display: flex; align-items: center; gap: 4px; color: var(--accent); font-size: 8px; letter-spacing: .8px; }
.radar-heading i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
#radar-canvas { width: 80px; height: 80px; }
.coordinate-display { color: var(--text); font-size: 9px; font-variant-numeric: tabular-nums; }
.movement-display { color: var(--muted); font-size: 8px; }
.music-indicator { position: absolute; top: calc(119px + var(--safe-top)); left: 18px; display: flex; align-items: center; gap: 7px; max-width: 155px; padding: 6px 9px; border: 1px solid rgba(142,164,204,.13); border-radius: 12px; background: rgba(8,12,22,.62); color: var(--muted); font-size: 8px; letter-spacing: .4px; }
.music-bars { display: flex; height: 12px; align-items: flex-end; gap: 2px; }
.music-bars i { width: 2px; height: 5px; border-radius: 2px; background: var(--accent); animation: music-bar .8s ease-in-out infinite alternate; }
.music-bars i:nth-child(2) { height: 10px; animation-delay: -.45s; }
.music-bars i:nth-child(3) { height: 7px; animation-delay: -.2s; }
.music-indicator.paused .music-bars i { animation-play-state: paused; height: 2px; }
@keyframes music-bar { to { height: 11px; opacity: .55; } }
.boss-bar { position: absolute; top: calc(115px + var(--safe-top)); right: 33px; left: 33px; display: none; text-align: center; }
.boss-bar.active { display: block; }
.boss-bar span { color: var(--rose); font-size: 10px; letter-spacing: 2px; }
.boss-bar > div { height: 5px; margin-top: 7px; border-radius: 5px; background: rgba(255,255,255,.1); }
.boss-bar i { display: block; width: 100%; height: 100%; border-radius: inherit; background: var(--rose); }
.notice { position: absolute; top: 23%; right: 20px; left: 20px; opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s; color: var(--text); text-align: center; font-size: 15px; letter-spacing: 1px; }
.notice.visible { opacity: 1; transform: translateY(0); }
.synergy-banner { position: absolute; top: 31%; right: 26px; left: 26px; padding: 11px; border: 1px solid rgba(175,149,255,.48); border-radius: 10px; background: rgba(20,17,42,.84); opacity: 0; transition: opacity .25s; color: #c5b7ff; text-align: center; font-size: 12px; }
.synergy-banner.visible { opacity: 1; }

.joystick-zone { position: absolute; bottom: calc(31px + var(--safe-bottom)); left: 23px; display: grid; width: 112px; height: 126px; justify-items: center; align-content: center; gap: 7px; pointer-events: auto; touch-action: none; }
.joystick-zone > span { color: var(--muted); font-size: 8px; letter-spacing: 1.8px; }
.joystick-ring { position: relative; display: grid; width: 92px; height: 92px; place-items: center; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; background: rgba(12,17,30,.32); }
.joystick-zone.active .joystick-ring { border-color: rgba(105,242,222,.55); background: rgba(105,242,222,.07); }
.joystick-knob { width: 39px; height: 39px; border: 1px solid rgba(105,242,222,.52); border-radius: 50%; background: rgba(105,242,222,.17); }
.skill-button { position: absolute; right: 34px; bottom: calc(58px + var(--safe-bottom)); display: grid; width: 78px; height: 78px; place-content: center; gap: 1px; overflow: hidden; border: 1px solid rgba(105,242,222,.62); border-radius: 50%; background: rgba(16,25,35,.82); pointer-events: auto; touch-action: manipulation; }
.skill-button span { position: relative; z-index: 1; color: var(--accent); font-size: 27px; }
.skill-button small { position: relative; z-index: 1; color: var(--muted); font-size: 9px; }
.skill-button i { position: absolute; right: 0; bottom: 0; left: 0; height: 0; background: rgba(8,11,22,.75); transition: height .1s linear; }

.overlay { position: absolute; inset: 0; z-index: 4; display: none; align-items: center; justify-content: center; padding: calc(22px + var(--safe-top)) 19px calc(22px + var(--safe-bottom)); background: rgba(5,8,15,.78); backdrop-filter: blur(11px); }
.overlay.active { display: flex; }
.overlay-panel { width: min(100%, 410px); max-height: 100%; overflow-y: auto; padding: 21px 18px; border: 1px solid var(--line); border-radius: 18px; background: rgba(14,19,31,.93); scrollbar-width: none; }
.overlay-panel::-webkit-scrollbar { display: none; }
.overlay-panel h2 { margin: 8px 0 5px; font-size: 26px; }
.overlay-panel > p { margin: 0 0 15px; line-height: 1.65; color: var(--muted); font-size: 11px; }
.upgrade-options { display: grid; gap: 9px; }
.upgrade-card { position: relative; display: grid; grid-template-columns: 40px 1fr; gap: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); text-align: left; }
.upgrade-card.rare { border-color: rgba(105,242,222,.39); }
.upgrade-card.epic { border-color: rgba(175,149,255,.54); }
.upgrade-icon { display: grid; width: 39px; height: 39px; place-items: center; border-radius: 10px; background: rgba(255,255,255,.05); color: var(--upgrade-color, var(--accent)); font-size: 19px; }
.upgrade-copy strong { display: block; padding-right: 78px; font-size: 12px; }
.upgrade-copy small { display: block; margin-top: 5px; line-height: 1.5; color: var(--muted); font-size: 10px; }
.upgrade-copy small em { color: color-mix(in srgb, var(--upgrade-color, var(--accent)) 72%, var(--muted)); font-size: 8px; font-style: normal; }
.rarity-tag { position: absolute; top: 9px; right: 10px; color: var(--muted); font-size: 8px; }
.rarity-tag.rare { color: var(--accent); }
.rarity-tag.epic { color: var(--violet); }
.text-button { display: block; width: 100%; margin-top: 14px; padding: 8px; border: 0; background: none; color: var(--muted); font-size: 11px; }
.text-button:disabled { opacity: .45; }
.upgrade-card, .option-card, .character-chip, .start-button { transition: transform .12s ease, border-color .16s ease, background-color .16s ease; }
.upgrade-card:active, .option-card:active, .character-chip:active, .start-button:active { transform: scale(.985); }

.run-build { display: flex; flex-wrap: wrap; gap: 7px; min-height: 54px; margin: 17px 0; }
.build-chip { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 10px; }
.audio-control { display: grid; width: 100%; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; margin: 0 0 13px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.025); text-align: left; }
.audio-control > span:first-child { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 17px; }
.audio-control strong, .audio-control small { display: block; }
.audio-control strong { font-size: 10px; }
.audio-control small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.audio-control i { color: var(--accent); font-size: 9px; font-style: normal; }
.audio-control.muted { opacity: .65; }
.audio-control.muted i { color: var(--muted); }
.result-panel { text-align: center; }
.result-emblem { margin-bottom: 5px; color: var(--accent); font-size: 56px; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 17px 0; text-align: left; }
.result-stat { padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.result-stat span { display: block; color: var(--muted); font-size: 9px; }
.result-stat strong { display: block; margin-top: 5px; font-size: 15px; }
.unlock-notice { min-height: 5px; margin: 0 0 14px; color: var(--amber); font-size: 11px; line-height: 1.6; }

@media (min-width: 650px) {
  body { background: radial-gradient(circle at 50% 30%, #182035, #080b16 60%); }
  #app { box-shadow: 0 0 90px rgba(0,0,0,.55); }
}

@media (max-height: 720px) {
  .screen { padding-right: 18px; padding-left: 18px; }
  .brand-block { padding-top: 10px; padding-bottom: 10px; }
  .brand-block h1 { margin-top: 5px; font-size: 37px; }
  .character-chip { height: 53px; }
  .detail-card { margin-top: 9px; padding: 12px; }
  .nav-tabs { margin-top: 10px; }
  .tab-panel { padding-top: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
