/* ============================================================================
   BeatVerse — stylesheet
   Neon nightclub aesthetic: deep indigo base, lane-colored accents, gold ranks.
   Layering: #game-canvas (3D) below, #ui-root DOM above.
   ========================================================================== */

/* ------------------------------- base / reset ------------------------------ */

:root {
  --bg: #0b0c14;
  --panel: rgba(15, 17, 28, 0.86);
  --panel-border: rgba(143, 157, 255, 0.16);
  --text: #e8eaf6;
  --text-dim: #8a8fa8;
  --pink: #ff3d81;
  --cyan: #2de2ff;
  --violet: #8f6bff;
  --green: #3dff8f;
  --gold: #ffd23d;
  --red: #ff3d5e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body, sans-serif);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

#ui-root {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none; /* screens opt back in */
}

.hidden { display: none !important; }

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(143, 157, 255, 0.25);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

/* --------------------------------- buttons -------------------------------- */

.bv-btn {
  pointer-events: auto;
  font-family: var(--font-display, sans-serif);
  font-size: 15px;
  letter-spacing: 0.12em;
  padding: 12px 26px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(20, 22, 38, 0.8);
  color: var(--text);
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s;
}
.bv-btn:hover { transform: translateY(-2px); border-color: var(--cyan); box-shadow: 0 4px 24px rgba(45, 226, 255, 0.25); }
.bv-btn:active { transform: translateY(0) scale(0.97); }
.bv-btn.primary {
  background: linear-gradient(135deg, var(--pink), var(--violet));
  border-color: transparent;
  box-shadow: 0 4px 24px rgba(255, 61, 129, 0.35);
}
.bv-btn.primary:hover { box-shadow: 0 6px 32px rgba(255, 61, 129, 0.55); }
.bv-btn.ghost { background: transparent; }
.bv-btn.small { font-size: 12px; padding: 8px 14px; }
.bv-btn.big { font-size: 19px; padding: 16px 42px; }

/* --------------------------------- screens -------------------------------- */

.screen {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  animation: screen-in 0.35s ease both;
}
.screen.overlay {
  background: rgba(6, 7, 14, 0.72);
  backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  z-index: 20;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------- title --------------------------------- */

#screen-title { align-items: center; justify-content: center; cursor: pointer; }

.title-center { text-align: center; }

.title-logo {
  font-family: var(--font-display, sans-serif);
  font-size: clamp(56px, 10vw, 128px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1;
  text-shadow: 0 0 40px rgba(45, 226, 255, 0.5);
  animation: logo-glow 2.4s ease-in-out infinite;
}
.title-logo .logo-accent {
  background: linear-gradient(135deg, var(--pink), var(--violet), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
@keyframes logo-glow {
  0%, 100% { text-shadow: 0 0 34px rgba(45, 226, 255, 0.4); }
  50% { text-shadow: 0 0 60px rgba(255, 61, 129, 0.6); }
}

.title-tag {
  margin-top: 10px;
  font-size: clamp(12px, 1.6vw, 17px);
  letter-spacing: 0.5em;
  color: var(--text-dim);
}

.title-press {
  margin-top: 56px;
  font-family: var(--font-display, sans-serif);
  font-size: clamp(13px, 1.8vw, 19px);
  letter-spacing: 0.28em;
  color: var(--cyan);
  animation: press-blink 1.6s ease-in-out infinite;
}
.title-sep { color: var(--text-dim); margin: 0 8px; }
@keyframes press-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.title-eq {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 26px;
  height: 34px;
  align-items: flex-end;
}
.title-eq span {
  width: 8px;
  border-radius: 3px;
  background: linear-gradient(to top, var(--pink), var(--cyan));
  animation: eq-bounce 0.9s ease-in-out infinite;
}
.title-eq span:nth-child(1) { animation-delay: 0s; height: 40%; }
.title-eq span:nth-child(2) { animation-delay: 0.12s; height: 70%; }
.title-eq span:nth-child(3) { animation-delay: 0.24s; height: 100%; }
.title-eq span:nth-child(4) { animation-delay: 0.36s; height: 60%; }
.title-eq span:nth-child(5) { animation-delay: 0.48s; height: 90%; }
.title-eq span:nth-child(6) { animation-delay: 0.6s; height: 50%; }
.title-eq span:nth-child(7) { animation-delay: 0.72s; height: 75%; }
@keyframes eq-bounce { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1); } }

.title-version {
  position: absolute;
  bottom: 18px;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

/* ------------------------------- song select ------------------------------- */

#screen-songselect { padding: clamp(14px, 3vh, 32px) clamp(18px, 4vw, 56px); }

.ss-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.ss-title {
  font-family: var(--font-display, sans-serif);
  font-size: clamp(20px, 3vw, 32px);
  letter-spacing: 0.2em;
  text-shadow: 0 0 24px rgba(45, 226, 255, 0.4);
}
.ss-header-btns { display: flex; gap: 10px; }

.ss-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 5fr) 7fr;
  gap: clamp(14px, 2.5vw, 32px);
  min-height: 0;
}

.ss-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(143,157,255,0.3) transparent;
}

.ss-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s, box-shadow 0.25s;
}
.ss-card:hover { border-color: hsl(var(--song-hue), 80%, 60%); }
.ss-card.selected {
  border-color: hsl(var(--song-hue), 90%, 62%);
  box-shadow: 0 0 28px hsla(var(--song-hue), 90%, 60%, 0.3);
  transform: translateX(6px);
}
.ss-card-disc {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #0b0c14 0 18%, transparent 19%),
    conic-gradient(hsl(var(--song-hue), 85%, 55%), hsl(calc(var(--song-hue) + 60), 85%, 55%), hsl(var(--song-hue), 85%, 55%));
  box-shadow: 0 0 16px hsla(var(--song-hue), 90%, 60%, 0.45);
}
.ss-card.selected .ss-card-disc { animation: disc-spin 3.5s linear infinite; }
@keyframes disc-spin { to { transform: rotate(360deg); } }
.ss-card-info { min-width: 0; flex: 1; }
.ss-card-title {
  font-family: var(--font-display, sans-serif);
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ss-card-artist { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.ss-card-meta { font-size: 12px; color: var(--text-dim); margin-top: 3px; letter-spacing: 0.08em; }
.ss-card-rank {
  font-family: var(--font-display, sans-serif);
  font-size: 22px;
  font-weight: 700;
}

.rank-sss, .rank-ss, .rank-s { color: var(--gold); text-shadow: 0 0 12px rgba(255, 210, 61, 0.6); }
.rank-a { color: var(--green); }
.rank-b { color: var(--cyan); }
.rank-c { color: var(--violet); }
.rank-d { color: var(--text-dim); }

.ss-detail {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: clamp(16px, 2.5vw, 30px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.ss-detail-title {
  font-family: var(--font-display, sans-serif);
  font-size: clamp(20px, 2.6vw, 30px);
}
.ss-detail-artist { color: var(--text-dim); font-size: 15px; }
.ss-detail-stats { font-size: 13px; color: var(--text-dim); letter-spacing: 0.1em; }
.ss-empty { margin: auto; text-align: center; color: var(--text-dim); font-size: 17px; line-height: 1.8; }

.ss-diffs { display: flex; gap: 8px; flex-wrap: wrap; }
.ss-diff {
  flex: 1 1 100px;
  min-width: 96px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(10, 11, 20, 0.6);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.12s;
}
.ss-diff:hover { transform: translateY(-2px); }
.ss-diff.selected {
  border-color: var(--diff-color);
  box-shadow: 0 0 18px color-mix(in srgb, var(--diff-color) 40%, transparent);
}
.ss-diff-name { font-family: var(--font-display, sans-serif); font-size: 13px; color: var(--diff-color); letter-spacing: 0.1em; }
.ss-diff-level { font-size: 11px; color: var(--text-dim); }
.ss-diff-best { font-size: 11px; }
.ss-diff-best.none { color: var(--text-dim); }

.ss-mods { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ss-mod {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.14em;
  font-family: var(--font-display, sans-serif);
  transition: all 0.2s;
}
.ss-mod.on { color: var(--text); border-color: var(--green); box-shadow: 0 0 14px rgba(61, 255, 143, 0.3); }
.ss-mod-state { opacity: 0.7; margin-left: 6px; }
.ss-mod.on .ss-mod-state { color: var(--green); opacity: 1; }

.ss-rate { display: flex; align-items: center; gap: 10px; font-size: 12px; letter-spacing: 0.1em; color: var(--text-dim); }
.ss-rate.disabled { opacity: 0.35; }
.ss-rate input { width: 110px; }

.ss-costumes { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ss-costumes-label { font-size: 11px; letter-spacing: 0.2em; color: var(--text-dim); font-family: var(--font-display, sans-serif); }
.ss-costume {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 12px;
  transition: all 0.2s;
}
.ss-costume-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cost-color); box-shadow: 0 0 8px var(--cost-color); }
.ss-costume.selected { border-color: var(--cost-color); box-shadow: 0 0 14px color-mix(in srgb, var(--cost-color) 45%, transparent); }
.ss-costume.locked { opacity: 0.45; cursor: not-allowed; }

.ss-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: auto; }

.ss-hints {
  display: flex;
  gap: 18px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  flex-wrap: wrap;
}
.ss-keys b { color: var(--cyan); }

.ss-achievements {
  position: absolute;
  right: clamp(18px, 4vw, 56px);
  top: 84px;
  bottom: 24px;
  width: min(360px, 80vw);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px;
  overflow-y: auto;
  z-index: 5;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
.ss-achievements h3 { font-family: var(--font-display, sans-serif); letter-spacing: 0.2em; font-size: 14px; margin-bottom: 12px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 9px 6px; border-bottom: 1px solid rgba(143,157,255,0.08); opacity: 0.45; }
.ach.unlocked { opacity: 1; }
.ach-icon { font-size: 20px; }
.ach-text { flex: 1; display: flex; flex-direction: column; }
.ach-text b { font-size: 13px; }
.ach-text small { font-size: 11px; color: var(--text-dim); }
.ach-state { color: var(--green); }

/* --------------------------------- loading -------------------------------- */

#screen-loading { align-items: center; justify-content: center; }
.loading-box { text-align: center; width: min(480px, 84vw); }
.loading-song { font-family: var(--font-display, sans-serif); font-size: clamp(20px, 3vw, 30px); }
.loading-artist { color: var(--text-dim); margin-top: 6px; }
.loading-diff {
  display: inline-block;
  margin-top: 14px;
  padding: 5px 18px;
  border-radius: 999px;
  border: 1px solid var(--diff-color);
  color: var(--diff-color);
  font-family: var(--font-display, sans-serif);
  font-size: 13px;
  letter-spacing: 0.2em;
}
.loading-bar {
  margin-top: 30px;
  height: 8px;
  border-radius: 4px;
  background: rgba(143, 157, 255, 0.15);
  overflow: hidden;
}
.loading-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--pink), var(--cyan));
  box-shadow: 0 0 16px var(--cyan);
  transition: width 0.15s ease;
}
.loading-label { margin-top: 12px; font-size: 13px; color: var(--text-dim); letter-spacing: 0.15em; }

/* ---------------------------------- HUD ----------------------------------- */

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 15; }

.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr minmax(200px, 420px) 1fr;
  align-items: start;
  gap: 18px;
  padding: 14px clamp(14px, 3vw, 36px);
  background: linear-gradient(to bottom, rgba(6, 7, 14, 0.75), transparent);
}
.hud-label { font-size: 10px; letter-spacing: 0.3em; color: var(--text-dim); display: block; }
.hud-score-value {
  font-family: var(--font-display, sans-serif);
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 700;
  text-shadow: 0 0 18px rgba(45, 226, 255, 0.45);
}
.hud-life { padding-top: 8px; }
.hud-life-bar {
  height: 12px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: rgba(10, 11, 20, 0.7);
  overflow: hidden;
}
.hud-life-fill {
  height: 100%;
  width: 55%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  box-shadow: 0 0 14px rgba(61, 255, 143, 0.5);
  transition: width 0.2s ease;
  position: relative;
  overflow: hidden;
}
.hud-life-fill::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  animation: life-shimmer 2.2s linear infinite;
}
@keyframes life-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.hud-life-fill.danger {
  background: linear-gradient(90deg, var(--red), #ff7a3d);
  animation: danger-pulse 0.5s ease-in-out infinite;
}
@keyframes danger-pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.6); } }
.hud-right { text-align: right; }
.hud-acc {
  font-family: var(--font-display, sans-serif);
  font-size: clamp(15px, 2vw, 21px);
  display: block;
}
.hud-fps { font-size: 12px; color: var(--green); letter-spacing: 0.1em; }

.hud-combo {
  position: absolute;
  left: 50%;
  top: 56%;
  transform: translateX(-50%);
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s;
}
.hud-combo.active { opacity: 1; }
.hud-combo-num {
  display: block;
  font-family: var(--font-display, sans-serif);
  font-size: clamp(38px, 6vw, 68px);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(255, 210, 61, 0.55);
}
.hud-combo-num.pop { animation: combo-pop 0.16s ease; }
@keyframes combo-pop { 0% { transform: scale(1.22); } 100% { transform: scale(1); } }
.hud-combo-label { font-size: 12px; letter-spacing: 0.5em; color: var(--text-dim); }
.hud-combo.shatter { animation: combo-shatter 0.4s ease; }
@keyframes combo-shatter {
  0% { transform: translateX(-50%) scale(1.15); filter: blur(0); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.9); filter: blur(3px); opacity: 0.4; }
}

.hud-judgement {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, 0);
  font-family: var(--font-display, sans-serif);
  font-size: clamp(24px, 4vw, 44px);
  font-weight: 900;
  letter-spacing: 0.14em;
  opacity: 0;
}
.hud-judgement.pop { animation: judge-pop 0.5s ease forwards; }
@keyframes judge-pop {
  0% { opacity: 0; transform: translate(-50%, 14px) scale(0.7); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.12); }
  30% { transform: translate(-50%, 0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}
.judge-perfect { color: var(--gold); text-shadow: 0 0 26px rgba(255, 233, 94, 0.8); }
.judge-great { color: var(--cyan); text-shadow: 0 0 22px rgba(45, 226, 255, 0.7); }
.judge-good { color: var(--violet); text-shadow: 0 0 18px rgba(143, 107, 255, 0.6); }
.judge-bad { color: #ff9d5e; }
.judge-miss { color: var(--red); text-shadow: 0 0 20px rgba(255, 61, 94, 0.7); }
.judge-hint { display: block; font-size: 12px; letter-spacing: 0.4em; color: var(--text-dim); text-shadow: none; }

.hud-milestone {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  font-family: var(--font-display, sans-serif);
  font-size: clamp(26px, 4.5vw, 48px);
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  opacity: 0;
}
.hud-milestone.pop { animation: milestone-pop 1.2s ease forwards; }
@keyframes milestone-pop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.5); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.2); }
  28% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-16px); }
}

.hud-countdown {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display, sans-serif);
  font-size: clamp(72px, 14vw, 150px);
  font-weight: 900;
  color: var(--cyan);
  text-shadow: 0 0 60px rgba(45, 226, 255, 0.7);
}
.hud-countdown.zoom { animation: count-zoom 0.9s ease; }
@keyframes count-zoom {
  0% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.92); opacity: 0.85; }
}

.hud-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 4px;
  background: rgba(143, 157, 255, 0.12);
}
.hud-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--pink), var(--cyan));
  box-shadow: 0 0 10px var(--cyan);
}

.hud-flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.hud-flash.flash-perfect {
  animation: flash-white 0.28s ease;
  box-shadow: inset 0 0 120px rgba(255, 255, 255, 0.55);
}
.hud-flash.flash-miss {
  animation: flash-white 0.3s ease;
  box-shadow: inset 0 0 140px rgba(255, 40, 70, 0.5);
}
@keyframes flash-white { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ------------------------------ pause / fail ------------------------------- */

.pause-box, .set-box {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: clamp(22px, 4vw, 40px);
  box-shadow: 0 18px 80px rgba(0, 0, 0, 0.7);
  animation: screen-in 0.25s ease both;
}
.pause-box { text-align: center; min-width: min(340px, 86vw); }
.pause-box h2 {
  font-family: var(--font-display, sans-serif);
  letter-spacing: 0.4em;
  margin-bottom: 24px;
  font-size: 26px;
}
.pause-btns { display: flex; flex-direction: column; gap: 12px; }

.fail-stamp {
  font-family: var(--font-display, sans-serif);
  font-size: clamp(42px, 9vw, 96px);
  font-weight: 900;
  color: var(--red);
  letter-spacing: 0.12em;
  text-shadow: 0 0 70px rgba(255, 61, 94, 0.8);
  border: 4px solid var(--red);
  border-radius: 14px;
  padding: 12px 42px;
  transform: rotate(-6deg);
  animation: fail-slam 0.5s cubic-bezier(0.2, 2.2, 0.4, 1) both;
}
@keyframes fail-slam {
  0% { transform: rotate(-6deg) scale(2.4); opacity: 0; }
  100% { transform: rotate(-6deg) scale(1); opacity: 1; }
}

/* -------------------------------- settings -------------------------------- */

.set-box {
  width: min(640px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.set-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.set-head h2 { font-family: var(--font-display, sans-serif); letter-spacing: 0.3em; font-size: 20px; }
.set-head-btns { display: flex; gap: 8px; }
.set-body { overflow-y: auto; padding-right: 8px; }
.set-section {
  font-family: var(--font-display, sans-serif);
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--cyan);
  margin: 18px 0 8px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 6px;
}
.set-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 2px;
}
.set-label { flex: 1; font-size: 15px; }
.set-value { width: 64px; text-align: right; font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.set-row input[type="range"] { width: min(200px, 34vw); }
.set-toggle {
  width: 74px;
  padding: 7px 0;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-family: var(--font-display, sans-serif);
  font-size: 12px;
  letter-spacing: 0.15em;
  transition: all 0.2s;
}
.set-toggle.on { color: #06131a; background: var(--green); border-color: var(--green); box-shadow: 0 0 14px rgba(61, 255, 143, 0.4); }
.set-select { display: flex; gap: 6px; }
.set-opt {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-size: 13px;
  transition: all 0.2s;
}
.set-opt.selected { color: var(--text); border-color: var(--cyan); box-shadow: 0 0 12px rgba(45, 226, 255, 0.3); }
.set-keys { display: flex; gap: 8px; flex-wrap: wrap; }
.set-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 66px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  color: var(--text);
  transition: all 0.2s;
}
.set-key-arrow { font-size: 18px; color: var(--cyan); }
.set-key-code { font-size: 12px; color: var(--text-dim); letter-spacing: 0.08em; }
.set-key.capturing { border-color: var(--gold); box-shadow: 0 0 16px rgba(255, 210, 61, 0.4); animation: press-blink 0.8s infinite; }

/* --------------------------------- results -------------------------------- */

#screen-results { align-items: center; justify-content: center; padding: 20px; }
.res-wrap {
  width: min(860px, 94vw);
  max-height: 94vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: clamp(18px, 3vw, 34px);
  box-shadow: 0 24px 100px rgba(0, 0, 0, 0.7);
}
.res-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.res-song { font-family: var(--font-display, sans-serif); font-size: clamp(17px, 2.4vw, 24px); }
.res-song small { color: var(--text-dim); font-size: 0.7em; margin-left: 8px; }
.res-diff {
  padding: 4px 16px;
  border-radius: 999px;
  border: 1px solid var(--diff-color);
  color: var(--diff-color);
  font-family: var(--font-display, sans-serif);
  font-size: 12px;
  letter-spacing: 0.2em;
}
.res-main {
  display: grid;
  grid-template-columns: auto 1fr minmax(150px, auto);
  gap: clamp(14px, 2.2vw, 32px);
  align-items: center;
  margin: 18px 0;
}
.res-rank {
  font-family: var(--font-display, sans-serif);
  font-size: clamp(80px, 12vw, 150px);
  font-weight: 900;
  color: var(--rank-color);
  text-shadow: 0 0 60px color-mix(in srgb, var(--rank-color) 70%, transparent);
  animation: rank-slam 0.6s cubic-bezier(0.2, 2, 0.4, 1) 0.3s both;
  line-height: 1;
}
@keyframes rank-slam {
  0% { transform: scale(2.6) rotate(8deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.res-wrap.failed .res-rank { color: var(--red); }
.res-score {
  font-family: var(--font-display, sans-serif);
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.res-record { color: var(--gold); font-family: var(--font-display, sans-serif); letter-spacing: 0.2em; font-size: 14px; animation: press-blink 1.2s infinite; }
.res-fc { color: var(--green); font-family: var(--font-display, sans-serif); letter-spacing: 0.2em; font-size: 14px; }
.res-failed-tag { color: var(--red); font-family: var(--font-display, sans-serif); letter-spacing: 0.2em; font-size: 14px; }
.res-unsaved { color: var(--text-dim); font-size: 12px; letter-spacing: 0.1em; }
.res-acc, .res-combo { font-size: clamp(17px, 2.4vw, 24px); font-family: var(--font-display, sans-serif); margin-top: 6px; }
.res-acc small, .res-combo small { font-size: 0.55em; color: var(--text-dim); font-family: var(--font-body, sans-serif); letter-spacing: 0.15em; }
.res-counts { display: flex; flex-direction: column; gap: 7px; padding-right: 4px; }
.res-count {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-size: 13px;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.res-count b { font-variant-numeric: tabular-nums; }
.res-graph {
  width: 100%;
  height: auto;
  background: rgba(8, 9, 16, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
}
.res-actions { display: flex; gap: 12px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.res-best { text-align: center; margin-top: 12px; font-size: 12px; color: var(--text-dim); letter-spacing: 0.12em; }

/* ------------------------------ touch controls ----------------------------- */

#touch-controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 10px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0));
  pointer-events: auto;
  z-index: 18;
}
.touch-pad {
  position: relative;
  flex: 1;
  height: clamp(74px, 16vh, 120px);
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--pad-color) 50%, transparent);
  background: color-mix(in srgb, var(--pad-color) 10%, rgba(10, 11, 20, 0.75));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
  touch-action: none;
}
.touch-arrow {
  font-size: clamp(34px, 7vh, 52px);
  color: var(--pad-color);
  text-shadow: 0 0 18px var(--pad-color);
  pointer-events: none;
}
.touch-pad.pressed {
  transform: scale(0.94);
  box-shadow: 0 0 30px color-mix(in srgb, var(--pad-color) 60%, transparent), inset 0 0 26px color-mix(in srgb, var(--pad-color) 35%, transparent);
  background: color-mix(in srgb, var(--pad-color) 26%, rgba(10, 11, 20, 0.7));
}
.touch-ripple {
  position: absolute;
  left: 50%; top: 50%;
  width: 20px; height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  background: var(--pad-color);
  opacity: 0;
  pointer-events: none;
}
.touch-ripple.go { animation: ripple 0.45s ease-out; }
@keyframes ripple {
  0% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0; transform: scale(9); }
}

/* --------------------------------- toasts --------------------------------- */

#toasts {
  position: absolute;
  top: 74px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 40;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14px;
  box-shadow: 0 8px 40px rgba(255, 210, 61, 0.2);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1), opacity 0.3s;
}
.toast.in { transform: none; opacity: 1; }
.toast-icon { font-size: 20px; }

/* -------------------------------- responsive ------------------------------- */

@media (max-width: 900px) {
  .ss-body { grid-template-columns: 1fr; grid-template-rows: 2fr 3fr; }
  .res-main { grid-template-columns: auto 1fr; }
  .res-counts { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; gap: 14px; }
}

@media (max-height: 520px) {
  .hud-combo { top: 60%; }
  .title-press { margin-top: 26px; }
  .set-box { max-height: 96vh; }
}

/* fatal boot error card (injected by main.js) */
.fatal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 99;
  pointer-events: auto;
}
.fatal-box {
  max-width: min(560px, 90vw);
  background: var(--panel);
  border: 1px solid var(--red);
  border-radius: 16px;
  padding: 30px;
  text-align: center;
  line-height: 1.7;
}
.fatal-box h2 { color: var(--red); font-family: var(--font-display, sans-serif); margin-bottom: 10px; }
.fatal-box code { color: var(--cyan); font-size: 13px; }
