:root {
  --bg: #160d26;
  --bg2: #2a1a42;
  --ink: #f4efff;
  --ink-dim: #b9add6;
  --panel: rgba(28, 18, 48, 0.72);
  --panel-line: rgba(255, 255, 255, 0.12);
  --yellow: rgba(255, 241, 118, 0.85);   /* 原版按钮色 #BFFFF176 */
  --yellow-solid: #fff176;
  --teal: #00bfa5;                       /* 原版 Score 颜色 */
  --aqua: #03dac5;                       /* 原版 Lives 颜色 */
  --red: #ff3b4e;
  --green: #5dff8f;
  --violet: #9d7bff;
  --num: "Russo One", "PingFang SC", system-ui, sans-serif;
  --ui: -apple-system, "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; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; }
body {
  font-family: var(--ui);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none; overscroll-behavior: none;
}
#app { position: fixed; inset: 0; overflow: hidden; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; }
#touch-layer { position: absolute; inset: 0; touch-action: none; }
#vignette {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(ellipse at 50% 120%, rgba(255, 40, 60, .55), transparent 55%);
}
#vignette.hit { opacity: 1; transition: none; }

button { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; 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));
  opacity: 0; visibility: hidden; transition: opacity .35s ease, visibility 0s linear .35s;
  z-index: 20;
}
.screen.show { opacity: 1; visibility: visible; transition: opacity .35s ease; }
.screen:not(.show) { pointer-events: none; }
.screen.dim { background: rgba(10, 5, 20, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }

/* ---------- logo ---------- */
.logo { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.logo-text {
  font-family: var(--num); font-style: italic; font-size: clamp(44px, 13vw, 92px); letter-spacing: .01em;
  color: #fff; transform: skewX(-6deg);
  text-shadow: 0 0 2px #fff, 0 4px 0 #6a3dcf, 0 8px 0 #2b1659, 0 10px 30px rgba(157, 123, 255, .6);
}
.logo-sub {
  margin-top: 14px; font-size: clamp(11px, 3vw, 14px); letter-spacing: .45em; color: var(--yellow-solid);
  padding-left: .45em; opacity: .9;
}
.logo.small .logo-text { font-size: 44px; }
#splash { background: radial-gradient(ellipse at 50% 40%, #2d1d4a, #120a1f 70%); z-index: 40; }
#splash .logo { animation: pop 1s cubic-bezier(.2, 1.4, .4, 1) both; }
.splash-bar { margin-top: 48px; width: 160px; height: 3px; background: rgba(255,255,255,.12); border-radius: 2px; overflow: hidden; }
.splash-bar i { display: block; height: 100%; width: 0; background: var(--yellow-solid); animation: load 1.6s ease-out forwards; }
@keyframes load { to { width: 100%; } }
@keyframes pop { from { opacity: 0; transform: scale(.7) translateY(20px); } to { opacity: 1; transform: none; } }

/* ---------- menu ---------- */
#menu { justify-content: flex-start; }
.menu-top { margin-top: 4vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.best { font-family: var(--num); color: var(--ink-dim); font-size: 13px; letter-spacing: .08em; min-height: 1em; }
.menu-buttons { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; margin-top: auto; margin-bottom: 2.5vh; }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; }
.menu-foot { font-size: 11px; color: rgba(255,255,255,.4); letter-spacing: .1em; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--panel-line); cursor: pointer;
  padding: 13px 18px; border-radius: 20px; font-size: 18px; font-weight: 600; letter-spacing: .08em;
  background: rgba(255, 255, 255, .08); color: var(--ink);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform .12s ease, background .2s, box-shadow .2s;
}
.btn:hover { background: rgba(255, 255, 255, .15); }
.btn:active { transform: scale(.96); }
.btn:focus-visible { outline: 2px solid var(--yellow-solid); outline-offset: 2px; }
.btn.primary { background: var(--yellow); color: #2a1d3d; border-color: transparent; box-shadow: 0 6px 24px rgba(255, 241, 118, .18); font-size: 22px; }
.btn.primary:hover { background: #fff59d; }
.btn.primary.ghosty { background: rgba(255, 241, 118, .16); color: var(--yellow-solid); border: 1px solid rgba(255, 241, 118, .5); font-size: 19px; }
.btn small { font-family: var(--num); font-size: 11px; opacity: .7; margin-left: 4px; letter-spacing: .05em; }
.btn.danger { background: rgba(255, 59, 78, .14); border-color: rgba(255, 59, 78, .5); color: #ff9aa5; }
.btn.teal { font-family: var(--num); color: var(--teal); background: rgba(0, 191, 165, .08); border-color: rgba(0, 191, 165, .45); font-size: 20px; letter-spacing: .04em; }
.btn.teal.solid { background: var(--teal); color: #062a25; }
.btn.small { padding: 8px 14px; font-size: 14px; border-radius: 14px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--panel-line);
  background: rgba(255,255,255,.08); display: grid; place-items: center; cursor: pointer; pointer-events: auto;
}
.icon-btn svg { width: 20px; height: 20px; fill: var(--ink); }

/* ---------- panels ---------- */
.panel {
  width: min(440px, 100%); max-height: 100%; overflow: auto; padding: 24px 22px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 24px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
  touch-action: pan-y;
}
.panel h2 { margin: 0 0 4px; font-size: 24px; letter-spacing: .2em; text-align: center; }
.panel h3 { margin: 6px 0 0; font-size: 14px; color: var(--yellow-solid); letter-spacing: .2em; }
.panel p { margin: 0; color: var(--ink-dim); font-size: 14px; line-height: 1.7; }
.panel a { color: var(--aqua); }
.about .logo { margin: 4px 0 6px; }
.about-lead { color: var(--ink) !important; text-align: center; }
.credits { color: var(--ink) !important; }
.credits span { white-space: nowrap; }

.set-list { display: flex; flex-direction: column; gap: 4px; }
.set-item { display: flex; align-items: center; gap: 12px; padding: 9px 2px; border-bottom: 1px solid rgba(255,255,255,.06); flex-wrap: wrap; }
.set-item label { width: 84px; font-size: 14px; color: var(--ink-dim); }
.set-item input[type=range] { flex: 1; min-width: 100px; accent-color: var(--yellow-solid); }
.seg { display: flex; background: rgba(0,0,0,.25); border-radius: 12px; padding: 3px; gap: 3px; flex: 1; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 4px; border-radius: 9px; font-size: 14px; color: var(--ink-dim); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--yellow); color: #2a1d3d; font-weight: 700; }
.toggle { width: 46px; height: 26px; border-radius: 13px; background: rgba(255,255,255,.15); position: relative; cursor: pointer; flex: none; transition: background .2s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle.on { background: var(--teal); }
.toggle.on::after { transform: translateX(20px); }

.tabs { flex: none; }
.score-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.score-list li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.05); font-size: 13px; color: var(--ink-dim); }
.score-list li b { font-family: var(--num); color: var(--ink); font-size: 18px; font-weight: 400; margin-left: auto; }
.score-list li .rk { font-family: var(--num); width: 22px; color: var(--yellow-solid); }
.score-list .empty { justify-content: center; background: none; }
.lifetime { font-size: 12px; color: var(--ink-dim); text-align: center; line-height: 1.8; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10;
  padding: calc(10px + var(--safe-t)) calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) calc(12px + var(--safe-l)); }
.hud-left { position: absolute; left: calc(12px + var(--safe-l)); top: calc(10px + var(--safe-t)); }
.hud-right { position: absolute; right: calc(12px + var(--safe-r)); top: calc(10px + var(--safe-t)); }
.hud-center { position: absolute; left: 50%; top: calc(12px + var(--safe-t)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 5px; }
.score { display: flex; flex-direction: column; line-height: 1; }
.score .lbl { font-family: var(--num); font-size: 10px; color: var(--ink-dim); letter-spacing: .25em; }
.score b { font-family: var(--num); font-weight: 400; font-size: 28px; text-shadow: 0 2px 10px rgba(0,0,0,.5); }
.score b.bump { animation: bump .18s ease; }
@keyframes bump { 50% { transform: scale(1.12); } }
.combo { font-family: var(--num); font-size: 13px; color: var(--yellow-solid); min-height: 16px; margin-top: 2px; transition: opacity .2s; }
.combo .x { font-size: 18px; }
.lives { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; max-width: 132px; }
.lives i { width: 10px; height: 11px; background: var(--aqua); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); box-shadow: 0 0 6px var(--aqua); }
.lives i.lost { background: rgba(255,255,255,.14); }
.lives i.shield { background: #6fe0ff; }
.lives .n { font-family: var(--num); font-size: 12px; color: var(--aqua); margin-left: 4px; line-height: 11px; }
.wave { font-family: var(--num); font-size: 14px; letter-spacing: .25em; color: var(--ink); text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.wavebar { width: 90px; height: 3px; background: rgba(255,255,255,.15); border-radius: 2px; overflow: hidden; }
.wavebar i { display: block; height: 100%; width: 0; background: var(--yellow-solid); transition: width .3s; }
.powers { display: flex; gap: 6px; }
.pw { position: relative; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(255,255,255,.12) 0); }
.pw span { position: absolute; inset: 3px; border-radius: 50%; background: rgba(20,12,35,.9); display: grid; place-items: center; color: var(--c); }
.bossbar { position: absolute; left: 50%; transform: translateX(-50%); top: calc(84px + var(--safe-t)); width: min(420px, 78vw); text-align: center; }
.bossbar span { font-size: 12px; letter-spacing: .3em; color: #ff9aa5; }
.bb { height: 8px; margin-top: 4px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; border: 1px solid rgba(255,59,78,.4); }
.bb i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff3b4e, #ff8a3d); transition: width .15s; }
.calib { position: absolute; left: calc(12px + var(--safe-l)); bottom: calc(14px + var(--safe-b)); pointer-events: auto; color: var(--aqua); }
.classic-hud { position: absolute; left: calc(18px + var(--safe-l)); bottom: calc(18px + var(--safe-b)); font-size: 22px; line-height: 1.5; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.c-score { color: var(--teal); }
.c-lives { color: var(--aqua); }
#hud.classic .hud-left, #hud.classic .hud-center { display: none; }
#hud.classic .calib { bottom: calc(100px + var(--safe-b)); }

#banner { position: absolute; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none; z-index: 15; opacity: 0; }
#banner.show { animation: banner 2s ease forwards; }
#banner .b-main { font-family: var(--num); font-size: clamp(34px, 10vw, 64px); letter-spacing: .12em; font-style: italic; text-shadow: 0 4px 0 #2b1659, 0 0 30px rgba(157,123,255,.7); }
#banner .b-sub { margin-top: 10px; font-size: 15px; letter-spacing: .2em; color: var(--yellow-solid); }
#banner.boss .b-main { color: #ff6b7a; text-shadow: 0 4px 0 #4a0f1a, 0 0 30px rgba(255,59,78,.8); }
@keyframes banner { 0% { opacity: 0; transform: scale(1.4); } 15% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }

#fps { position: absolute; right: calc(12px + var(--safe-r)); bottom: calc(8px + var(--safe-b)); font: 11px var(--num); color: rgba(255,255,255,.5); z-index: 30; pointer-events: none; }

/* ---------- pause / build ---------- */
.build { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.build .chip { font-size: 12px; padding: 4px 9px; border-radius: 10px; background: rgba(255,255,255,.08); color: var(--ink-dim); }
.build .chip b { color: var(--yellow-solid); font-family: var(--num); font-weight: 400; margin-left: 3px; }
.quick { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--ink-dim); flex-wrap: wrap; }
.quick span { margin-left: 6px; }

/* ---------- upgrade cards ---------- */
.up-wrap { width: min(760px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.up-title { font-family: var(--num); font-size: clamp(24px, 6vw, 36px); letter-spacing: .1em; }
.up-sub { color: var(--ink-dim); font-size: 14px; letter-spacing: .1em; }
.kbd-hint { opacity: .6; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; margin: 8px 0; }
.card {
  position: relative; cursor: pointer; text-align: left; border-radius: 18px; padding: 16px 14px 14px;
  background: linear-gradient(160deg, rgba(60, 40, 100, .85), rgba(25, 15, 45, .9));
  border: 1px solid var(--rc, rgba(255,255,255,.15)); box-shadow: 0 0 0 0 var(--rc);
  display: flex; flex-direction: column; gap: 8px; min-height: 190px;
  animation: cardIn .45s cubic-bezier(.2, 1.3, .4, 1) both; transition: transform .15s, box-shadow .2s;
}
.card:nth-child(2) { animation-delay: .07s; } .card:nth-child(3) { animation-delay: .14s; }
.card:hover, .card:focus-visible { transform: translateY(-4px); box-shadow: 0 8px 30px -6px var(--rc); outline: none; }
.card .rar { font-size: 11px; letter-spacing: .2em; color: var(--rc); }
.card .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.07); font-size: 22px; color: var(--rc); font-weight: 800; }
.card .nm { font-size: 18px; font-weight: 700; }
.card .lv { font-family: var(--num); font-size: 12px; color: var(--ink-dim); }
.card .ds { font-size: 13px; color: var(--ink-dim); line-height: 1.55; }
.card .key { position: absolute; right: 12px; top: 12px; font-family: var(--num); font-size: 12px; color: rgba(255,255,255,.35); }
@keyframes cardIn { from { opacity: 0; transform: translateY(30px) scale(.9); } to { opacity: 1; transform: none; } }

/* ---------- game over ---------- */
.go { align-items: center; text-align: center; }
.go-title { font-family: var(--num); font-size: 30px; letter-spacing: .15em; color: #ff8a95; }
.go-label { font-family: var(--num); color: var(--ink-dim); font-size: 14px; letter-spacing: .1em; font-style: italic; }
.go-score { font-family: var(--num); font-size: 58px; line-height: 1; text-shadow: 0 0 30px rgba(157,123,255,.7); }
.go-record { color: #2a1d3d; background: var(--yellow-solid); border-radius: 10px; padding: 3px 12px; font-weight: 800; letter-spacing: .2em; animation: pop .5s both; }
.go-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.go-stats div { background: rgba(255,255,255,.05); border-radius: 12px; padding: 8px 4px; font-size: 11px; color: var(--ink-dim); }
.go-stats b { display: block; font-family: var(--num); font-weight: 400; font-size: 18px; color: var(--ink); margin-bottom: 2px; }
.go-btns { display: flex; gap: 12px; width: 100%; }
.go-btns .btn { flex: 1; }

/* ---------- dialog ---------- */
.dialog { width: min(320px, 100%); background: #f6f2ff; color: #1b1030; border-radius: 18px; padding: 22px 20px 14px; box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: pop .3s both; }
.dialog p { margin: 0 0 18px; font-size: 16px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 10px; }
.dialog .btn { color: #4b3a75; background: transparent; border: 0; font-size: 15px; padding: 8px 14px; backdrop-filter: none; }
.dialog .btn.primary { background: #4b2fa3; color: #fff; box-shadow: none; }

#goodbye { background: #07040d; z-index: 45; }
.bye { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; color: var(--ink-dim); }

#rotate-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); font-size: 12px; padding: 5px 12px; border-radius: 10px; background: rgba(0,0,0,.5); color: var(--ink-dim); z-index: 50; pointer-events: none; display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) { #rotate-hint { display: block; } }

#error { position: absolute; inset: auto 16px 16px 16px; z-index: 99; background: #3a0f18; color: #ffd0d6; border: 1px solid #ff3b4e; border-radius: 12px; padding: 12px; font-size: 13px; white-space: pre-wrap; }

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; gap: 8px; }
  .card { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 4px 12px; }
  .card .ic { width: 40px; height: 40px; }
  .card .rar { width: 100%; order: -1; }
  .card .ds { width: 100%; }
  .kbd-hint { display: none; }
  .go-score { font-size: 48px; }
}
@media (max-height: 640px) {
  .btn.primary { font-size: 19px; padding: 10px 16px; }
  .btn { padding: 10px 16px; }
  .menu-buttons { gap: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
