/* CSU: dark night sky with violet and cyan, warm yellow for highlights */
:root {
  --bg: #0d0b1e;
  --panel: rgba(20, 17, 44, .82);
  --panel-2: rgba(36, 30, 74, .9);
  --line: rgba(255, 255, 255, .1);
  --text: #f1eeff;
  --muted: #a49cc9;
  --violet: #8c5cff;
  --cyan: #36e2ff;
  --gold: #ffd166;
  --pink: #ff5fa2;
  --green: #5cf2a0;
  --red: #ff5a6e;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font);
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
body.playing, body.playing * { cursor: none; }

.screen { position: fixed; inset: 0; display: none; }
.screen.on { display: block; animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- splash ---------- */
#splash { display: none; cursor: pointer; }
#splash.on { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; }
.splash-logo { width: 220px; height: 220px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #2a2160, #120f2a 70%); box-shadow: 0 0 0 8px var(--violet), 0 0 0 16px rgba(54, 226, 255, .35), 0 0 80px rgba(140, 92, 255, .6);
  animation: breathe 2.4s ease-in-out infinite; }
.splash-logo span { font-size: 72px; font-weight: 900; letter-spacing: 4px; background: linear-gradient(135deg, #fff, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.splash-hint { color: var(--muted); letter-spacing: 2px; animation: blink 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04); } }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- main menu ---------- */
.menu-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 14px 20px;
  background: linear-gradient(rgba(0, 0, 0, .45), transparent); }
.np { font-size: 14px; color: var(--muted); }
.np b { color: var(--text); font-weight: 600; }
.np-label { text-transform: uppercase; letter-spacing: 2px; font-size: 11px; margin-right: 6px; }
.menu-top-btns { display: flex; gap: 6px; }
.icon-btn { background: rgba(255, 255, 255, .08); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 34px; }
.icon-btn:hover { background: rgba(255, 255, 255, .16); }
.menu-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.logo { --pulse: 1; position: relative; width: min(46vmin, 360px); height: min(46vmin, 360px); border-radius: 50%; border: none; padding: 0; z-index: 2;
  background: radial-gradient(circle at 50% 38%, #2f2570, #130f2e 68%); box-shadow: 0 0 0 10px var(--violet), 0 0 0 20px rgba(54, 226, 255, .28), 0 0 90px rgba(140, 92, 255, .55);
  transform: translateX(var(--shift, 0)) scale(calc(var(--scale, 1) * var(--pulse))); transition: transform .5s cubic-bezier(.2, .9, .2, 1), box-shadow .2s; }
.logo:hover { box-shadow: 0 0 0 10px #a07bff, 0 0 0 22px rgba(54, 226, 255, .4), 0 0 110px rgba(140, 92, 255, .75); }
.logo-word { font-size: min(13vmin, 104px); font-weight: 900; letter-spacing: .06em; background: linear-gradient(135deg, #fff 30%, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
#menu.open .logo { --shift: max(-28vw, -300px); --scale: .62; }
.menu-buttons { position: absolute; left: 50%; top: 50%; transform: translate(-30%, -50%); z-index: 1; pointer-events: none; }
.mb-row { display: flex; gap: 0; opacity: 0; transform: translateX(-60px); transition: opacity .3s, transform .4s cubic-bezier(.2, .9, .2, 1); position: absolute; top: 0; left: 0; transform-origin: left; }
#menu.open #mb-main.show, #menu.open #mb-play.show { opacity: 1; transform: translateX(0); pointer-events: auto; }
.mb { width: min(19vw, 190px); height: min(15vh, 120px); margin-top: calc(min(15vh, 120px) / -2); border: none; color: #fff; font-size: 20px; font-weight: 700; letter-spacing: 1px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; transform: skewX(-12deg); transition: width .2s, filter .2s; }
.mb > * { transform: skewX(12deg); }
.mb i { font-style: normal; font-size: 28px; line-height: 1; }
.mb:hover { width: min(23vw, 230px); filter: brightness(1.15); }
.mb-play, .mb-lazer { background: linear-gradient(135deg, #7b4dff, #5a35d6); }
.mb-opt, .mb-mania { background: linear-gradient(135deg, #22b8e0, #1384b3); }
.mb-exit { background: linear-gradient(135deg, #ff5f86, #c93a62); }
.mb-back { background: linear-gradient(135deg, #3d3768, #2a2550); }
.menu-bottom { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; padding: 12px 20px; font-size: 13px; color: var(--muted);
  background: linear-gradient(transparent, rgba(0, 0, 0, .45)); }

/* ---------- song select ---------- */
#select.on { display: flex; flex-direction: column; }
.sel-top { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: rgba(8, 6, 20, .75); border-bottom: 1px solid var(--line); }
.mode-switch, .keys-switch { display: flex; background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 3px; }
.mode-switch button, .keys-switch button { border: none; background: none; padding: 7px 16px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.mode-switch button.on { background: var(--violet); color: #fff; }
.keys-switch button.on { background: var(--cyan); color: #072433; }
.keys-switch.hide { display: none; }
#sel-search { margin-left: auto; width: min(320px, 40vw); padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .06); outline: none; }
#sel-search:focus { border-color: var(--cyan); }
.sel-body { flex: 1; display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.15fr); min-height: 0; }
.sel-info { padding: 28px 30px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.si-title { font-size: clamp(26px, 3.6vw, 44px); font-weight: 800; line-height: 1.05; margin: 0; text-shadow: 0 3px 18px rgba(0, 0, 0, .6); }
.si-artist { color: var(--muted); font-size: 18px; margin: 0; }
.si-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: rgba(255, 255, 255, .08); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.si-diff { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.si-diff h3 { margin: 0 0 10px; font-size: 16px; }
.si-bars { display: grid; grid-template-columns: auto 1fr auto; gap: 7px 12px; align-items: center; font-size: 13px; color: var(--muted); }
.si-bar { height: 7px; background: rgba(255, 255, 255, .1); border-radius: 4px; overflow: hidden; }
.si-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); border-radius: 4px; }
.si-best { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; font-size: 14px; color: var(--muted); }
.si-best b { color: var(--text); }
.sel-list { overflow-y: auto; padding: 30vh 18px 30vh 0; scrollbar-width: thin; mask-image: linear-gradient(transparent, #000 12%, #000 88%, transparent); }
.card { position: relative; margin: 8px 0 8px auto; width: 92%; border-radius: 14px 0 0 14px; padding: 14px 18px; background: var(--panel); border: 1px solid var(--line); border-right: none;
  transition: width .25s cubic-bezier(.2, .9, .2, 1), background .2s; cursor: pointer; overflow: hidden; }
.card::before { content: ""; position: absolute; inset: 0; background: var(--art); opacity: .35; z-index: 0; }
.card > * { position: relative; z-index: 1; }
.card:hover { width: 95%; }
.card.on { width: 100%; background: var(--panel-2); border-color: rgba(140, 92, 255, .7); box-shadow: inset 4px 0 0 var(--cyan); }
.card h4 { margin: 0; font-size: 18px; }
.card p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.diffs { display: none; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.card.on .diffs { display: flex; }
.diff { border: 1px solid var(--line); background: rgba(0, 0, 0, .3); border-radius: 10px; padding: 7px 12px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.diff b { font-weight: 700; }
.diff .stars { color: var(--gold); font-variant-numeric: tabular-nums; }
.diff.on { border-color: var(--gold); background: rgba(255, 209, 102, .14); }
.diff-dot { width: 10px; height: 10px; border-radius: 50%; }
.card .del { position: absolute; right: 10px; top: 10px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; padding: 2px 8px; color: var(--muted); }
.sel-bottom { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px 18px; background: rgba(8, 6, 20, .8); border-top: 1px solid var(--line); }
.foot-btn { background: rgba(255, 255, 255, .07); border: 1px solid var(--line); border-radius: 10px; padding: 10px 18px; font-weight: 600; cursor: pointer; }
.foot-btn:hover { background: rgba(255, 255, 255, .14); }
.foot-btn.lit { border-color: var(--gold); color: var(--gold); }
.play-big { margin-left: auto; border: none; border-radius: 12px; padding: 12px 34px; font-size: 18px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--violet), #5a35d6); box-shadow: 0 6px 24px rgba(140, 92, 255, .45); }
.play-big:hover { filter: brightness(1.12); }
.mods-panel { display: none; position: absolute; bottom: 64px; left: 90px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
  gap: 8px; flex-wrap: wrap; width: min(520px, 90vw); box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.mods-panel.on { display: flex; }
.mod { width: 92px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .3); padding: 10px 6px; text-align: center; font-size: 12px; color: var(--muted); }
.mod b { display: block; font-size: 18px; color: var(--text); margin-bottom: 2px; }
.mod.on { border-color: var(--gold); background: rgba(255, 209, 102, .16); color: var(--gold); }

/* ---------- results ---------- */
#results.on { display: flex; align-items: center; justify-content: center; }
.res-wrap { display: flex; gap: 40px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 34px 40px; max-width: 92vw; }
.res-grade { font-size: min(28vmin, 220px); font-weight: 900; line-height: 1; width: 1.1em; text-align: center; animation: gradeIn .8s cubic-bezier(.2, 1.6, .4, 1) both .2s; }
@keyframes gradeIn { from { transform: scale(2.4) rotate(-12deg); opacity: 0; } }
.res-main h2 { margin: 0; font-size: 28px; }
.res-main p { margin: 4px 0 12px; color: var(--muted); }
.res-score { font-size: 48px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.res-stats { display: grid; grid-template-columns: repeat(3, auto); gap: 8px 26px; margin: 14px 0; font-size: 15px; color: var(--muted); }
.res-stats b { display: block; color: var(--text); font-size: 22px; font-variant-numeric: tabular-nums; }
.res-graph canvas { width: 100%; max-width: 600px; height: 90px; background: rgba(0, 0, 0, .25); border-radius: 10px; }
.res-btns { display: flex; gap: 10px; margin-top: 16px; }

/* ---------- pause ---------- */
.overlay.on { display: flex; align-items: center; justify-content: center; background: rgba(5, 3, 15, .6); backdrop-filter: blur(3px); }
.pause-box { display: flex; flex-direction: column; gap: 12px; width: 300px; text-align: center; }
.pause-box h2 { margin: 0 0 8px; font-size: 40px; letter-spacing: 3px; }
.pause-btn { border: none; border-radius: 14px; padding: 14px; font-size: 20px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--violet), #5a35d6); }
.pause-btn:nth-of-type(2) { background: linear-gradient(135deg, #22b8e0, #1384b3); }
.pause-btn:nth-of-type(3) { background: linear-gradient(135deg, #ff5f86, #c93a62); }
.pause-btn:hover { filter: brightness(1.15); }
body.playing #pause.on, body.playing #pause.on * { cursor: default; }

/* ---------- options ---------- */
.options { position: fixed; top: 0; bottom: 0; left: 0; width: min(420px, 100vw); background: rgba(14, 11, 32, .97); border-right: 1px solid var(--line); z-index: 20;
  transform: translateX(-105%); transition: transform .35s cubic-bezier(.2, .9, .2, 1); display: flex; flex-direction: column; }
.options.on { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, .5); }
.opt-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
.opt-head h2 { margin: 0; }
.opt-body { overflow-y: auto; padding: 0 20px 30px; }
.opt-group h3 { margin: 22px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 2px; color: var(--cyan); }
.opt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.opt-row input[type=range] { width: 150px; accent-color: var(--violet); }
.opt-row output { width: 52px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.opt-row .keybind { min-width: 46px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, .07); font-weight: 700; text-transform: uppercase; }
.opt-row .keybind.wait { border-color: var(--gold); color: var(--gold); }
.opt-keys { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.opt-row select { background: rgba(255, 255, 255, .07); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.opt-row select option { background: #1a1638; }
.switch { position: relative; width: 44px; height: 24px; border-radius: 12px; background: rgba(255, 255, 255, .15); border: none; padding: 0; flex: none; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch.on { background: var(--violet); }
.switch.on::after { left: 23px; }
.opt-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* ---------- toast and busy ---------- */
.toast { position: fixed; left: 50%; bottom: 80px; transform: translate(-50%, 20px); background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 18px; font-size: 14px; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; z-index: 40; max-width: 90vw; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.busy { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 14px; background: rgba(5, 3, 15, .7); z-index: 50; }
.busy.on { display: flex; }
.busy-ring { width: 54px; height: 54px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, .15); border-top-color: var(--cyan); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .sel-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sel-info { padding: 14px 16px; gap: 8px; }
  .si-diff, .si-best { display: none; }
  .sel-list { padding: 10px 0 40vh; }
  .res-wrap { flex-direction: column; gap: 10px; padding: 20px; }
  .menu-buttons { transform: translate(-42%, -50%); }
  #menu.open .logo { --shift: -34vw; --scale: .5; }
  .foot-btn { padding: 9px 12px; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; transition-duration: .01s !important; } }
