@font-face {
  font-family: "Neon CJK";
  src: url("fonts/NotoSansCJKsc-Regular.woff2?v=5") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Neon CJK";
  src: url("fonts/NotoSansCJKsc-Bold.woff2?v=5") format("woff2");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

/* ============================================================
   NEON BEAT — interface styling
   ============================================================ */

:root {
  --bg: #06030e;
  --ink: #f5f2ff;
  --muted: #8b91b8;
  --faint: #5b6085;
  --line: rgba(153, 169, 255, 0.15);
  --line-strong: rgba(170, 187, 255, 0.28);
  --accent: #ff4f9a;
  --accent2: #35e6ff;
  --gold: #ffe27a;
  --ink-dark: #0b0614;
  --font-cn: "Neon CJK", "Noto Sans CJK SC", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "DejaVu Sans", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "DejaVu Sans Mono", "Neon CJK", monospace;
  --font-display: "Arial Black", "Helvetica Neue", "Neon CJK", var(--font-cn), "DejaVu Sans", sans-serif;
  color-scheme: dark;
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(72% 48% at 50% 108%, rgba(255, 79, 154, 0.2), transparent 64%),
    radial-gradient(36% 58% at 100% 78%, rgba(53, 230, 255, 0.1), transparent 72%),
    radial-gradient(42% 38% at 6% 8%, rgba(164, 79, 255, 0.12), transparent 74%),
    #05030c;
  color: var(--ink);
  font-family: var(--font-cn);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

button { font-family: inherit; }
button, input { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }


#app {
  width: min(100vw, 700px);
  height: 100vh;
  height: 100dvh;
  padding:
    calc(8px + env(safe-area-inset-top, 0px))
    calc(10px + env(safe-area-inset-right, 0px))
    calc(6px + env(safe-area-inset-bottom, 0px))
    calc(10px + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 7px;
  position: relative;
  z-index: 2;
  min-height: 0;
}

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

.hud {
  height: 56px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px;
  min-width: 0;
}
.hud.is-hidden { display: none; }

.hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}
.hud-kicker { display: none; }
.hud-left::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
#hud-song {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 145px;
}
.hud-pill {
  font: 800 7.5px/1 var(--font-mono);
  letter-spacing: 0.12em;
  color: var(--accent2);
  border: 1px solid rgba(53, 230, 255, 0.28);
  border-radius: 999px;
  padding: 4px 6px;
  white-space: nowrap;
}
.hud-stats {
  display: flex;
  align-items: center;
  gap: 17px;
  margin-left: auto;
  min-width: 0;
}
.hud-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hud-stat span {
  font: 700 7px/1 var(--font-mono);
  letter-spacing: 0.16em;
  color: var(--faint);
}
.hud-stat b {
  font: 800 14px/1 var(--font-mono);
  color: #fff;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.score-stat b { color: var(--gold); text-shadow: 0 0 14px rgba(255, 226, 122, 0.28); }
.combo-stat b { color: #fff; }
#hud-acc { font-size: 12px; color: #bfe7ff; }
.hud-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(20, 14, 38, 0.62);
  color: #d7d9f2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
  flex: 0 0 auto;
}
.icon-btn:hover { background: rgba(42, 30, 73, 0.8); border-color: var(--line-strong); color: #fff; }
.icon-btn:active { transform: scale(0.92); }
.icon-btn:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid rgba(130, 238, 255, 0.9);
  outline-offset: 2px;
}
.icon-btn svg { width: 17px; height: 17px; fill: currentColor; }
.icon-btn svg path.wave { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.icon-btn .sound-off { display: none; }
.icon-btn.muted .sound-on { display: none; }
.icon-btn.muted .sound-off { display: block; }
.pause-btn { font: 900 13px/1 var(--font-mono); letter-spacing: -0.15em; padding-right: 3px; }

.foot {
  flex: 0 0 auto;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: 600 7px/1 var(--font-mono);
  letter-spacing: 0.18em;
  color: var(--faint);
  opacity: 0.7;
}
.foot-dot { opacity: 0.5; }
#app.in-game .foot { display: none; }

/* ============================ STAGE ============================ */

.stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 22px;
  background: #070310;
  border: 1px solid rgba(150, 168, 255, 0.18);
  box-shadow:
    0 0 0 1px rgba(5, 3, 14, 0.8),
    0 0 44px rgba(255, 65, 150, 0.08),
    0 28px 80px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  touch-action: none;
}
.stage-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 75% at 50% 46%, transparent 48%, rgba(2, 1, 7, 0.5) 100%),
    linear-gradient(180deg, rgba(4, 2, 10, 0.28), transparent 16%, transparent 84%, rgba(4, 2, 10, 0.38));
}
.stage-scanlines {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0.55;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: screen;
}

/* ============================ OVERLAYS ============================ */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(160, 180, 255, 0.25) transparent;
}
.overlay::-webkit-scrollbar { width: 4px; }
.overlay::-webkit-scrollbar-thumb { background: rgba(160, 180, 255, 0.25); border-radius: 99px; }
.is-hidden { display: none !important; }

/* ============================ MENU ============================ */

.menu {
  align-items: flex-start;
  justify-content: center;
  z-index: 20;
  background:
    radial-gradient(78% 52% at 50% 4%, rgba(255, 79, 154, 0.14), transparent 62%),
    linear-gradient(180deg, rgba(6, 3, 15, 0.72) 0%, rgba(6, 3, 15, 0.88) 58%, rgba(5, 3, 12, 0.96) 100%);
  backdrop-filter: blur(5px) saturate(0.95);
  -webkit-backdrop-filter: blur(7px) saturate(0.9);
}

.menu-inner {
  width: 100%;
  max-width: 530px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: max(10px, 2.2vh) 4px 12px;
  animation: menuIn 0.55s cubic-bezier(0.22, 0.9, 0.2, 1) both;
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.menu-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
}
.menu-session {
  font: 700 7px/1 var(--font-mono);
  letter-spacing: 0.26em;
  color: var(--faint);
}
.menu-tools { display: flex; gap: 6px; }
.settings-btn svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }

.brand { display: flex; flex-direction: column; gap: 7px; padding: 2px 0 0; }
.brand-kicker {
  font: 700 8px/1 var(--font-mono);
  letter-spacing: 0.32em;
  color: var(--accent);
  text-transform: uppercase;
}
.logo {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(48px, 12.5vw, 80px);
  line-height: 0.78;
  letter-spacing: -0.055em;
  display: flex;
  align-items: flex-end;
  gap: 0.07em;
  flex-wrap: wrap;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35));
}
.logo > span:first-child {
  color: #f8f5ff;
  text-shadow: 0 0 28px rgba(255, 255, 255, 0.12);
}
.logo-beat {
  background: linear-gradient(112deg, var(--accent) 8%, #ff8b6a 48%, var(--accent2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  position: relative;
  padding-right: 0.18em;
}
.logo-beat i {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.18em;
  line-height: 1;
  letter-spacing: 0;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  position: absolute;
  right: 0;
  top: 0.05em;
  width: 0.86em;
  height: 0.86em;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 4, 20, 0.7);
  box-shadow: 0 0 14px rgba(255, 79, 154, 0.3);
}
.brand-sub { display: flex; align-items: baseline; gap: 11px; flex-wrap: wrap; }
.brand-cn {
  font-size: 12px;
  letter-spacing: 0.34em;
  color: #c9c5e2;
  font-weight: 600;
}
.brand-tag { font-size: 9px; letter-spacing: 0.08em; color: var(--faint); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 3px;
}
.section-label {
  font: 700 7.5px/1 var(--font-mono);
  letter-spacing: 0.2em;
  color: #a6a9c9;
}
.section-meta {
  font: 600 7.5px/1 var(--font-mono);
  letter-spacing: 0.08em;
  color: var(--faint);
  white-space: nowrap;
}

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

.song-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.song-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(14, 9, 29, 0.72);
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.22s ease, box-shadow 0.22s ease;
}
.song-card:hover { transform: translateY(-2px); border-color: rgba(190, 203, 255, 0.32); }
.song-card.is-active {
  transform: translateY(-3px);
  border-color: var(--c1);
  box-shadow: 0 0 0 1px var(--c1), 0 12px 32px rgba(0, 0, 0, 0.4), 0 0 26px rgba(255, 79, 154, 0.14);
}
.song-card.is-active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  box-shadow: 0 0 12px var(--c1);
}
.song-cover {
  display: block;
  position: relative;
  width: 100%;
  height: 51px;
  overflow: hidden;
  background:
    radial-gradient(120% 160% at 82% 18%, var(--c2) 0%, transparent 45%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.06), transparent 40%),
    linear-gradient(135deg, var(--c1), #160b28 78%);
}
.song-cover::before {
  content: "";
  position: absolute;
  width: 76%;
  aspect-ratio: 1;
  border-radius: 50%;
  right: -16%;
  top: 30%;
  background: repeating-linear-gradient(
    to bottom,
    rgba(8, 4, 20, 0.15) 0 2px,
    rgba(8, 4, 20, 0.52) 2px 4px
  );
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.15);
  opacity: 0.85;
}
.song-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 45%, rgba(8, 4, 20, 0.6));
}
.cover-glyph {
  position: absolute;
  right: 7px;
  top: 5px;
  z-index: 2;
  font: 900 26px/1 var(--font-display);
  color: rgba(255, 255, 255, 0.42);
  transform: rotate(-8deg);
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.35);
}
.cover-index {
  position: absolute;
  left: 8px;
  top: 7px;
  z-index: 2;
  font: 800 7px/1 var(--font-mono);
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.78);
}
.song-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px 9px;
  position: relative;
  z-index: 2;
  min-width: 0;
}
.song-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-en {
  font: 700 6.5px/1.2 var(--font-mono);
  letter-spacing: 0.13em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.song-bpm {
  font: 600 7px/1 var(--font-mono);
  letter-spacing: 0.06em;
  color: var(--faint);
  margin-top: 2px;
}
.song-card.is-active .song-en { color: #ddd9ef; }
.song-card.is-active .song-bpm { color: rgba(255, 255, 255, 0.6); }

/* ---------- difficulty ---------- */

.difficulty-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.diff-btn {
  --dc: #8e97c2;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(14, 9, 29, 0.68);
  color: var(--ink);
  padding: 8px 5px 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.diff-btn:hover { border-color: var(--line-strong); background: rgba(26, 17, 48, 0.78); }
.diff-btn.is-active {
  border-color: var(--dc);
  background: linear-gradient(180deg, rgba(30, 22, 53, 0.95), rgba(15, 10, 30, 0.95));
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.035), 0 0 18px rgba(0, 0, 0, 0.3);
}
.diff-btn.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--dc);
  box-shadow: 0 0 12px var(--dc);
}
.diff-btn b { font-size: 12px; font-weight: 800; letter-spacing: 0.04em; }
.diff-btn span {
  font: 800 6.5px/1 var(--font-mono);
  letter-spacing: 0.14em;
  color: var(--faint);
}
.diff-btn.is-active span { color: var(--dc); }
.diff-btn .diff-stars {
  font-size: 7px;
  letter-spacing: 0.14em;
  color: var(--dc);
  margin-top: 1px;
  opacity: 0.8;
}
.diff-blurb {
  margin: -2px 1px 0;
  font-size: 8.5px;
  line-height: 1.4;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.best-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 8px 1px 0;
  min-height: 18px;
}
.best-label { font: 700 7px/1 var(--font-mono); letter-spacing: 0.18em; color: var(--faint); }
.best-score {
  font: 600 9px/1.3 var(--font-mono);
  letter-spacing: 0.03em;
  color: #c6c9e4;
  text-align: right;
}
.best-score .best-rank { font-weight: 900; margin-left: 5px; text-shadow: 0 0 10px currentColor; }
.best-score .best-new { color: var(--gold); }

/* ---------- start ---------- */

.btn-start {
  position: relative;
  border: none;
  border-radius: 15px;
  height: 53px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(102deg, var(--accent) 0%, #ff8a6b 45%, var(--accent2) 100%);
  color: var(--ink-dark);
  font-weight: 900;
  font-size: 16px;
  letter-spacing: 0.13em;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 12px 34px rgba(255, 79, 154, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-start::before {
  content: "";
  position: absolute;
  top: -60%;
  bottom: -60%;
  left: -35%;
  width: 24%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: rotate(18deg);
  animation: startShimmer 4.8s ease-in-out infinite;
}
@keyframes startShimmer {
  0%, 55% { left: -35%; }
  82%, 100% { left: 125%; }
}
.btn-start:hover { transform: translateY(-1px); box-shadow: 0 16px 44px rgba(255, 79, 154, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.45); filter: brightness(1.04); }
.btn-start:active { transform: translateY(1px) scale(0.995); }
.btn-start:disabled { cursor: wait; filter: saturate(0.5); opacity: 0.7; }
.start-label { position: relative; z-index: 2; padding-left: 0.13em; }
.start-icon {
  position: relative;
  z-index: 2;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  background: rgba(8, 4, 18, 0.82);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.start-glow { position: absolute; inset: 0; background: radial-gradient(80% 120% at 50% 110%, rgba(255, 255, 255, 0.25), transparent 60%); }

.menu-hints {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font: 500 8px/1.5 var(--font-mono);
  color: var(--faint);
  letter-spacing: 0.02em;
  padding-bottom: 2px;
}
.menu-hints kbd, .pause-hint kbd {
  display: inline-block;
  padding: 2px 4px;
  margin: 0 1px;
  border: 1px solid rgba(170, 185, 255, 0.2);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.045);
  color: #c8cce4;
  font: 700 7px/1 var(--font-mono);
}
.hint-divider { opacity: 0.35; }

/* ============================ COUNTDOWN ============================ */

.countdown {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
  background: radial-gradient(42% 34% at 50% 48%, rgba(6, 3, 17, 0.58), transparent 75%);
}
.countdown.is-hidden { display: none !important; }
.cd-label {
  font: 800 9px/1 var(--font-mono);
  letter-spacing: 0.36em;
  color: rgba(226, 230, 255, 0.62);
  padding-left: 0.36em;
}
.cd-number {
  font: 900 clamp(76px, 20vw, 132px)/0.94 var(--font-display);
  letter-spacing: -0.05em;
  color: #fff;
  background: linear-gradient(180deg, #ffffff 0%, #ffe27a 38%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 32px rgba(255, 79, 154, 0.38));
  min-width: 1.2em;
  text-align: center;
}
.cd-number.pop { animation: countPop 0.48s cubic-bezier(0.18, 0.9, 0.25, 1) both; }
.cd-number.go {
  background: linear-gradient(180deg, #ffffff 0%, #c8ffe6 45%, var(--accent2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 34px rgba(53, 230, 255, 0.45));
  font-size: clamp(62px, 17vw, 112px);
  letter-spacing: 0.02em;
}
@keyframes countPop {
  0% { opacity: 0; transform: scale(1.55); filter: blur(7px); }
  22% { opacity: 1; filter: blur(0); }
  100% { opacity: 0.95; transform: scale(1); }
}
.cd-hint {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: rgba(202, 207, 235, 0.58);
  margin-top: 6px;
}

/* ============================ SHEETS ============================ */

.sheet {
  width: 100%;
  max-width: 430px;
  margin: auto;
  border-radius: 20px;
  border: 1px solid rgba(160, 178, 255, 0.18);
  background:
    radial-gradient(110% 90% at 50% 0%, rgba(255, 79, 154, 0.07), transparent 55%),
    linear-gradient(180deg, rgba(18, 11, 34, 0.98), rgba(7, 4, 17, 0.99));
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 20px;
  animation: sheetIn 0.32s cubic-bezier(0.2, 0.85, 0.2, 1) both;
}
@keyframes sheetIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.sheet-kicker {
  display: block;
  font: 800 7px/1 var(--font-mono);
  letter-spacing: 0.28em;
  color: var(--accent);
  margin-bottom: 7px;
}
.sheet h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.close-btn { font-size: 12px; }
.settings { background: rgba(3, 2, 9, 0.82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); z-index: 40; }
.settings-sheet { max-width: 400px; }
.setting-row { margin-bottom: 16px; }
.setting-row.compact { margin: 14px 0 18px; }
.setting-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #daddf2;
  margin-bottom: 8px;
}
.setting-title output {
  font: 700 10px/1 var(--font-mono);
  color: var(--accent2);
  background: rgba(53, 230, 255, 0.08);
  border: 1px solid rgba(53, 230, 255, 0.16);
  border-radius: 6px;
  padding: 4px 6px;
  min-width: 42px;
  text-align: center;
}
.setting-help {
  margin: 7px 0 0;
  font-size: 8px;
  line-height: 1.5;
  color: var(--faint);
}
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  display: block;
}
.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 79, 154, 0.65), rgba(53, 230, 255, 0.55));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.range::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 79, 154, 0.65), rgba(53, 230, 255, 0.55));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #201537;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.3), 0 0 14px rgba(255, 79, 154, 0.45);
}
.range::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #201537;
  box-shadow: 0 0 12px rgba(255, 79, 154, 0.45);
}
.sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.sheet-actions.stack { flex-direction: column; }
.sheet-actions .row-actions { display: flex; gap: 8px; }
.sheet-actions .row-actions > button { flex: 1; }
.btn-primary, .btn-ghost {
  border-radius: 12px;
  height: 44px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  transition: transform 0.16s ease, filter 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  flex: 1;
}
.btn-primary {
  border: none;
  background: linear-gradient(102deg, var(--accent), #ff8a6b 48%, var(--accent2));
  color: var(--ink-dark);
  box-shadow: 0 8px 26px rgba(255, 79, 154, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-primary.small { flex: 0 0 auto; min-width: 100px; }
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: #d7d9ef;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.075); border-color: var(--line-strong); }
.btn-ghost:active { transform: translateY(1px); }
.settings-note {
  margin: 14px 0 0;
  text-align: center;
  font: 500 7.5px/1.4 var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--faint);
}

/* ============================ PAUSE ============================ */

.pause {
  z-index: 30;
  background: rgba(3, 2, 9, 0.8);
  backdrop-filter: blur(12px) saturate(0.8);
  -webkit-backdrop-filter: blur(12px) saturate(0.8);
}
.pause-sheet { max-width: 400px; }
.diff-chip {
  font: 800 7.5px/1 var(--font-mono);
  letter-spacing: 0.12em;
  color: var(--accent2);
  border: 1px solid rgba(53, 230, 255, 0.25);
  border-radius: 999px;
  padding: 5px 8px;
  white-space: nowrap;
}
.pause-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 13px 0;
}
.pause-stats > div { display: flex; flex-direction: column; gap: 5px; }
.pause-stats span { font: 700 7px/1 var(--font-mono); letter-spacing: 0.15em; color: var(--faint); }
.pause-stats b { font: 800 17px/1 var(--font-mono); color: #fff; font-variant-numeric: tabular-nums; }
.pause-stats > div:nth-child(2) b { color: var(--accent2); }
.pause-stats > div:nth-child(3) b { color: var(--gold); }
.pause-hint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 8px;
  color: var(--faint);
  letter-spacing: 0.04em;
}

/* ============================ RESULTS ============================ */

.results {
  z-index: 30;
  background:
    radial-gradient(60% 60% at 50% 42%, rgba(255, 79, 154, 0.1), transparent 70%),
    rgba(3, 2, 9, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.results-sheet { max-width: 410px; position: relative; z-index: 2; }
.results-sheet h2 { font-size: 16px; color: #d6d4e8; font-weight: 700; letter-spacing: 0.04em; margin-top: 2px; }
.result-top {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 14px 0 10px;
}
.result-rank {
  --rank-color: #ffe27a;
  flex: 0 0 auto;
  width: 88px;
  height: 88px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font: 900 54px/1 var(--font-display);
  color: var(--rank-color);
  background: radial-gradient(70% 70% at 50% 35%, rgba(255, 255, 255, 0.08), transparent 62%);
  border: 1px solid currentColor;
  box-shadow: 0 0 32px color-mix(in srgb, var(--rank-color) 22%, transparent), inset 0 0 34px color-mix(in srgb, var(--rank-color) 7%, transparent);
  text-shadow: 0 0 30px currentColor;
  animation: rankIn 0.65s cubic-bezier(0.16, 1.1, 0.25, 1) both;
  letter-spacing: -0.06em;
}
@keyframes rankIn {
  from { opacity: 0; transform: scale(1.45) rotate(-7deg); filter: blur(9px); }
  to { opacity: 1; transform: scale(1) rotate(0); filter: blur(0); }
}
.result-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.result-rating {
  font: 800 8px/1 var(--font-mono);
  letter-spacing: 0.24em;
  color: var(--rank-color, var(--gold));
}
.result-score {
  font: 900 30px/1.2 var(--font-mono);
  letter-spacing: -0.04em;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(255, 255, 255, 0.16);
}
.result-acc { font: 600 8.5px/1 var(--font-mono); letter-spacing: 0.06em; color: var(--muted); }
.result-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin: 0 0 12px;
  padding: 5px 9px;
  border: 1px solid rgba(255, 226, 122, 0.35);
  border-radius: 999px;
  background: rgba(255, 226, 122, 0.08);
  color: var(--gold);
  font: 800 7.5px/1 var(--font-mono);
  letter-spacing: 0.18em;
  box-shadow: 0 0 18px rgba(255, 226, 122, 0.12);
}
.result-badge.is-hidden { display: none !important; }
.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  margin-top: 4px;
}
.result-stats > div { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.result-stats span { font: 700 6.5px/1 var(--font-mono); letter-spacing: 0.12em; color: var(--faint); }
.result-stats b { font: 800 17px/1 var(--font-mono); color: #fff; font-variant-numeric: tabular-nums; }
.result-stats > div:nth-child(1) b { color: var(--gold); }
.result-stats > div:nth-child(2) b { color: var(--accent2); }
.result-stats > div:nth-child(3) b { color: #8dff9b; }
.result-stats > div:nth-child(4) b { color: #ff5e83; }
.result-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 1px 0;
  font: 600 8px/1 var(--font-mono);
  letter-spacing: 0.05em;
  color: var(--muted);
}
.result-foot b { color: #fff; font-weight: 800; }
#result-best { color: var(--faint); text-align: right; }

.result-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.result-confetti i {
  position: absolute;
  top: -8%;
  width: 4px;
  height: 9px;
  border-radius: 1px;
  opacity: 0;
  animation: confettiFall var(--dur, 3s) linear var(--delay, 0s) forwards;
}
@keyframes confettiFall {
  0% { opacity: 0; transform: translate3d(0, -10px, 0) rotate(0deg); }
  8% { opacity: 0.9; }
  100% { opacity: 0; transform: translate3d(var(--drift, 20px), 105vh, 0) rotate(var(--spin, 540deg)); }
}

/* ============================ TOAST ============================ */

.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  transform: translateX(-50%) translateY(8px);
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(10, 6, 22, 0.92);
  color: #e6e8f7;
  font: 600 9px/1.3 var(--font-mono);
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================ RESPONSIVE ============================ */

@media (max-width: 560px) {
  #app { padding-left: calc(6px + env(safe-area-inset-left, 0px)); padding-right: calc(6px + env(safe-area-inset-right, 0px)); }
  .stage { border-radius: 18px; }
  .menu { padding: 14px 13px 16px; }
  .menu-inner { padding-top: 2px; gap: 9px; }
  .hud { height: 52px; gap: 8px; }
  #hud-song { font-size: 12.5px; max-width: 112px; }
  .hud-kicker { display: none; }
  .hud-stats { gap: 11px; }
  .hud-stat.combo-stat { display: none; }
  .hud-stat b { font-size: 12px; }
  .score-stat b { font-size: 13px; }
  .hud-pill { font-size: 6.5px; padding: 3px 5px; }
  .icon-btn { width: 30px; height: 30px; border-radius: 9px; }
  .overlay { padding: 12px; }
  .sheet { padding: 17px; border-radius: 17px; }
  .brand-tag { display: none; }
  .brand-sub { gap: 8px; }
  .song-cover { height: 47px; }
  .song-title { font-size: 12px; }
  .btn-start { height: 50px; font-size: 15px; }
  .cd-hint { font-size: 8px; }
}

@media (max-width: 390px) {
  .hud-stats { gap: 8px; }
  .hud-actions { gap: 4px; }
  #hud-song { max-width: 94px; }
  .song-en { display: none; }
  .song-info { padding: 7px 7px 8px; }
  .song-title { font-size: 11.5px; }
  .song-bpm { font-size: 6.5px; }
  .song-cover { height: 44px; }
  .cover-glyph { font-size: 22px; }
  .menu-hints { gap: 3px 6px; font-size: 7.5px; }
  .best-score { font-size: 8px; }
  .result-top { gap: 13px; }
  .result-rank { width: 76px; height: 76px; font-size: 46px; border-radius: 19px; }
  .result-score { font-size: 26px; }
  .sheet h2 { font-size: 20px; }
}

@media (max-height: 740px) {
  .menu-inner { gap: 8px; padding-top: 0; }
  .logo { font-size: clamp(42px, 11.5vw, 66px); }
  .brand { gap: 5px; }
  .song-card { min-height: 0; }
  .song-cover { height: 44px; }
  .song-info { padding: 6px 8px 7px; }
  .diff-btn { padding: 6px 4px 5px; }
  .btn-start { height: 48px; font-size: 15px; }
  .menu-hints { font-size: 7.5px; }
  .foot { display: none; }
  .section-head { margin-top: 0; }
  .diff-blurb { display: none; }
}

@media (max-height: 620px) {
  .brand-kicker, .menu-session, .diff-blurb { display: none; }
  .logo { font-size: clamp(38px, 10vw, 56px); }
  .menu-inner { gap: 7px; }
  .song-cover { height: 38px; }
  .cover-glyph { font-size: 20px; }
  .song-info { padding: 5px 7px 6px; }
  .song-title { font-size: 11px; }
  .section-label { font-size: 7px; }
  .best-line { padding-top: 6px; }
  .btn-start { height: 44px; }
  .sheet { padding: 15px; }
  .sheet-head { margin-bottom: 10px; }
  .setting-row { margin-bottom: 10px; }
  .result-rank { width: 68px; height: 68px; font-size: 41px; }
  .result-stats { padding: 9px 0; }
  .result-top { margin: 8px 0 6px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .overlay { padding: 10px; }
  .browser-tip { display: none !important; }
  .menu-inner { max-width: 640px; display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "topbar topbar" "brand brand" "songs diff" "best best" "start start" "hints hints"; gap: 8px 12px; }
  .menu-topbar { grid-area: topbar; min-height: 20px; justify-content: flex-end; }
  .brand { grid-area: brand; }
  .logo { font-size: 42px; }
  .song-list { grid-area: songs; }
  .difficulty-list { grid-area: diff; align-self: start; }
  .diff-head, .diff-blurb, .section-meta { display: none; }
  .best-line { grid-area: best; }
  .btn-start { grid-area: start; }
  .menu-hints { grid-area: hints; }
  .section-head { display: none; }
  .hud { height: 44px; }
  .hud-kicker, .hud-stat.combo-stat { display: none; }
  .sheet { max-width: 500px; padding: 14px 18px; }
  .settings-sheet, .pause-sheet, .results-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
  .sheet-head, .sheet-actions, .settings-note, .result-stats, .result-foot, .pause-hint { grid-column: 1 / -1; }
  .result-top { margin: 4px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #06030e;
  color: #f5f2ff;
  font-family: var(--font-cn);
  text-align: center;
}

/* ============================ AUDIO DIAGNOSTICS ============================ */

.browser-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(255, 208, 103, 0.28);
  border-radius: 11px;
  background: linear-gradient(90deg, rgba(255, 184, 67, 0.12), rgba(255, 79, 154, 0.06));
}
.browser-tip-mark {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 208, 103, 0.16);
  color: var(--gold);
  font: 900 11px/1 var(--font-mono);
  box-shadow: 0 0 12px rgba(255, 208, 103, 0.16);
}
.browser-tip-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.browser-tip-copy b { font-size: 9px; color: #ffe4a1; font-weight: 800; letter-spacing: 0.03em; }
.browser-tip-copy span { font-size: 8px; line-height: 1.4; color: #c8c0ad; }
.browser-tip-close {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.15);
  color: #d8d3c4;
  font-size: 10px;
  cursor: pointer;
}
.audio-check {
  margin: 2px 0 15px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}
.audio-check .setting-title { margin-bottom: 8px; }
.audio-status {
  font: 700 8px/1 var(--font-mono);
  letter-spacing: 0.04em;
  padding: 5px 7px;
  border-radius: 6px;
  border: 1px solid rgba(141, 255, 155, 0.2);
  color: #9dffae;
  background: rgba(141, 255, 155, 0.06);
}
.audio-status[data-tone="warn"] {
  color: #ffd27a;
  border-color: rgba(255, 210, 122, 0.24);
  background: rgba(255, 210, 122, 0.07);
}
.audio-actions { display: flex; gap: 7px; }
.audio-actions .audio-btn {
  flex: 1;
  height: 34px;
  padding: 0 8px;
  border-radius: 9px;
  font-size: 10px;
  letter-spacing: 0.03em;
}
.audio-help { margin: 8px 0 0; }

@media (max-height: 520px) and (orientation: landscape) {
  .audio-check { grid-column: 1 / -1; }
}
