/* Display font: the original game writes its Latin, digits and Korean in a rounded hand-drawn face. Its own font file is
   not available, so Gaegu Bold (OFL, fonts/OFL.txt), the closest open face with all three, stands in. Shipped next to
   the page and inlined by the single-file build, so it also shows offline. */
@font-face { font-family: 'BS Hand'; src: url(fonts/Gaegu-Bold.ttf) format('truetype'); font-weight: 100 900; font-display: swap; }
:root {
  --bg: #15132a;
  --bg-2: #1d1a38;
  --line: #2f2b52;
  --fire: #ff5b3d;
  --ice: #46a6ff;
  --gold: #e3c27f;
  --text: #eeeaf8;
  --muted: #8b86a6;
  --perfect: #7dff8a;
  --great: #ffe36b;
  --good: #ff9f43;
  --miss: #ff4b5c;
  --display: 'BS Hand', 'IBM Plex Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  --body: 'IBM Plex Sans KR', system-ui, -apple-system, 'Malgun Gothic', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--body); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

#stage { position: fixed; inset: 0; background: #000; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#post { z-index: 1; }
#judgeLayer { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }

.screen { position: fixed; inset: 0; z-index: 10; display: none; background: var(--bg); }
.screen.active { display: block; }
.screen.overlay { background: rgba(10, 9, 22, 0.72); backdrop-filter: blur(6px); z-index: 30; }
.screen.overlay.active { display: grid; place-items: center; }

/* ---- start screen: BinaryStar title over a binary pair. The red and blue planets circle their common centre on a
   faint orbit, one turn per 2.4 s (a 100 BPM bar); the night has a few fixed stars */
#scr-menu { overflow: hidden; cursor: pointer; background: radial-gradient(120% 90% at 50% 42%, #24204a 0%, var(--bg) 58%, #0d0b1d 100%); }
#scr-menu::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 23px 41px, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1px 1px at 131px 97px, rgba(255, 255, 255, 0.4), transparent 60%),
    radial-gradient(1.5px 1.5px at 77px 163px, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(1px 1px at 191px 19px, rgba(220, 230, 255, 0.45), transparent 60%),
    radial-gradient(1px 1px at 59px 211px, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(1.5px 1.5px at 167px 233px, rgba(220, 230, 255, 0.4), transparent 60%);
  background-size: 240px 240px;
}
.title-screen {
  position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; justify-items: center;
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  text-align: center; user-select: none;
}
.binary { position: relative; width: clamp(96px, 17vh, 168px); aspect-ratio: 1; margin-bottom: clamp(14px, 3vh, 30px); pointer-events: none; }
.binary .orbit { position: absolute; inset: 14%; border-radius: 50%; border: 1px solid rgba(238, 234, 248, 0.18); box-shadow: 0 0 40px rgba(120, 110, 220, 0.12) inset; }
.binary .arm { position: absolute; inset: 14%; animation: bs-orbit 2.4s linear infinite; }
.binary .star { position: absolute; top: 50%; width: 24%; aspect-ratio: 1; margin-top: -12%; border-radius: 50%; }
.binary .fire { left: -12%; background: radial-gradient(circle at 38% 36%, #ffb39a, var(--fire) 55%, #b8261a); box-shadow: 0 0 18px 4px rgba(255, 91, 61, 0.55), 0 0 60px 10px rgba(255, 91, 61, 0.25); }
.binary .ice { right: -12%; background: radial-gradient(circle at 38% 36%, #b9ddff, var(--ice) 55%, #1f55b8); box-shadow: 0 0 18px 4px rgba(70, 166, 255, 0.55), 0 0 60px 10px rgba(70, 166, 255, 0.25); }
@keyframes bs-orbit { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .binary .arm { animation: none; transform: rotate(-24deg); } }
.logo {
  position: relative; margin: 0; display: grid; line-height: 0.92;
  font-family: var(--display); font-weight: 800; font-size: clamp(44px, 11vw, 132px); letter-spacing: 0.04em; color: var(--text);
  text-shadow: 0 0 24px rgba(160, 150, 255, 0.35);
}
.logo span:first-child { background: linear-gradient(90deg, #ffd2c4, var(--text) 60%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo span:last-child { background: linear-gradient(90deg, var(--text) 40%, #c9e4ff); -webkit-background-clip: text; background-clip: text; color: transparent; letter-spacing: 0.32em; margin-right: -0.28em; }
.tagline { position: relative; margin: 18px 0 0; color: var(--muted); font-size: clamp(13px, 1.6vw, 17px); letter-spacing: 0.06em; }
.cover-prompt {
  position: relative; margin: clamp(40px, 9vh, 96px) 0 0; color: #fff; font-family: var(--body); font-weight: 700;
  font-size: clamp(16px, 2.2vw, 26px); letter-spacing: 0.04em;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.6), 0 0 22px rgba(190, 210, 255, 0.45);
  animation: bs-blink 2.4s ease-in-out infinite;
}
@keyframes bs-blink { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .cover-prompt { animation: none; } }

button.big { background: none; border: 0; padding: 8px 0; font-family: var(--display); font-weight: 600; font-size: clamp(22px, 2.6vw, 30px); color: var(--text); position: relative; text-align: left; }
button.big::before { content: ''; position: absolute; left: -26px; top: 50%; width: 12px; height: 12px; margin-top: -6px; border-radius: 50%; background: var(--fire); transform: scale(0); transition: transform 0.15s; }
button.big:hover::before, button.big:focus-visible::before { transform: scale(1); }
button.big:hover { color: #fff; }
button.big.ghost { color: var(--muted); }
button.big:disabled { opacity: 0.35; cursor: default; }

/* ---- bars */
.bar { display: flex; align-items: center; gap: 24px; padding: 18px clamp(16px, 4vw, 48px); border-bottom: 1px solid var(--line); }
.bar h2 { font-family: var(--display); font-weight: 600; font-size: 20px; margin: 0; flex: 1; }
.back { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; color: var(--muted); }
.back:hover { color: var(--text); border-color: var(--muted); }
.file-btn { border: 1px solid var(--gold); color: var(--gold); border-radius: 999px; padding: 6px 18px; cursor: pointer; }
.file-btn:hover { background: var(--gold); color: var(--bg); }
button.file-btn { background: none; font: inherit; }
button.file-btn:disabled { opacity: 0.55; cursor: default; background: none; color: var(--gold); }
/* forum map browser */
.forum-panel { width: min(760px, 92vw); padding: 24px clamp(16px, 4vw, 32px); display: flex; flex-direction: column; gap: 10px; }
.forum-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.forum-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.forum-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2); }
.forum-card .fi { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.forum-card .fb { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.forum-card .fb a { color: var(--muted); font-size: 13px; }
.forum-card .warn { color: var(--miss); font-size: 12px; }
#forumMore { align-self: center; }
@media (max-width: 560px) { .forum-card { flex-direction: column; align-items: stretch; } .forum-card .fb { flex-wrap: wrap; } }

/* ---- select */
.select-body { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; height: calc(100% - 71px); }
.map-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.map-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 12px 4px; }
.map-tools input { flex: 1 1 140px; min-width: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.map-tools select { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.map-tools .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.map-list { list-style: none; margin: 0; padding: 8px 12px 12px; overflow: auto; flex: 1; }
.map-list li { position: relative; }
.map-list li.none { color: var(--muted); padding: 16px 6px; }
.map-row { width: 100%; text-align: left; background: none; border: 0; border-radius: 10px; padding: 10px 80px 10px 10px; display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto auto; column-gap: 12px; row-gap: 2px; }
.map-row:hover { background: var(--bg-2); }
.map-row.on { background: var(--bg-2); box-shadow: inset 3px 0 0 var(--fire); }
.map-row .th { grid-row: 1 / 4; width: 96px; height: 54px; border-radius: 6px; object-fit: cover; background: #0e0c1e; }
.map-row .t { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-row .a { color: var(--muted); font-size: 13px; }
.map-row .m { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.row-play { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--fire); display: grid; place-items: center; padding: 0; }
.row-play:hover { background: var(--fire); color: #fff; border-color: var(--fire); }
.md-desc { color: var(--muted); margin: -10px 0 18px; max-width: 60ch; line-height: 1.6; }
.map-detail { overflow: auto; padding: clamp(16px, 3vw, 40px); }
.map-detail .empty { max-width: 34em; color: var(--muted); line-height: 1.7; margin-top: 8vh; }
.map-detail .empty p:first-child { color: var(--text); font-size: 20px; }
.md-head { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; }
.md-title { font-family: var(--display); font-weight: 800; font-size: clamp(28px, 4vw, 48px); line-height: 1.05; margin: 0 0 8px; }
.md-artist { color: var(--gold); margin: 0; font-size: 18px; }
.md-author { color: var(--muted); margin: 6px 0 0; }
.md-play { background: var(--fire); color: #fff; border: 0; border-radius: 999px; padding: 14px 38px; font-family: var(--display); font-weight: 600; font-size: 20px; }
.md-play:hover { filter: brightness(1.1); }
.md-play:disabled { opacity: 0.5; }
.md-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 18px; margin: 28px 0; }
.md-stats .v { font-family: var(--display); font-size: 22px; }
.md-stats .k { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 11px; }
.md-stats small.of { font-size: 13px; color: var(--muted); margin-left: 2px; }
#preview { width: 100%; height: 260px; background: #0e0c1e; border-radius: 12px; display: block; }
.md-opts { display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: center; margin: 20px 0; }
.md-opts label { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.md-opts input[type=range] { width: 220px; }
.md-opts output { color: var(--text); min-width: 4ch; }
details.support { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 18px; }
details.support summary { cursor: pointer; color: var(--muted); }
.support table { border-collapse: collapse; margin-top: 12px; font-size: 14px; min-width: 420px; }
.support td { padding: 5px 16px 5px 0; border-bottom: 1px solid var(--line); }
.support td:nth-child(2) { text-align: right; font-variant-numeric: tabular-nums; }
.tag { border-radius: 999px; padding: 1px 10px; font-size: 12px; }
.tag.full { background: #1f4a33; color: #93f2b4; }
.tag.loadtime { background: #263f63; color: #a9cdff; }
.tag.approx { background: #5a4a1d; color: #ffe08a; }
.tag.editor { background: #3a3550; color: #c2bcdc; }
.tag.unsupported { background: #5c1f2a; color: #ffa3af; }
.drop-hint { position: fixed; inset: 16px; border: 3px dashed var(--gold); border-radius: 20px; display: none; place-items: center; font-size: 26px; color: var(--gold); background: rgba(21, 19, 42, 0.9); z-index: 40; pointer-events: none; }
.drop-hint.on { display: grid; }

/* ---- settings */
.settings { max-width: 720px; padding: 12px clamp(16px, 4vw, 48px) 60px; overflow: auto; height: calc(100% - 71px); }
.settings fieldset { border: 0; border-bottom: 1px solid var(--line); padding: 20px 0; margin: 0; display: grid; gap: 14px; }
.settings legend { font-family: var(--display); font-weight: 600; font-size: 16px; color: var(--gold); padding: 0; margin-bottom: 8px; float: left; width: 100%; }
.settings label { display: grid; grid-template-columns: 180px 1fr 60px; gap: 14px; align-items: center; }
.settings label.check { display: flex; gap: 10px; }
.settings select { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; grid-column: 2 / 4; }
.settings output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.note { color: var(--muted); font-size: 13px; margin: 0; }

/* ---- input offset calibration */
.calib-entry { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.calib { max-width: 720px; margin: 0 auto; padding: 20px clamp(16px, 4vw, 48px) 40px; display: grid; gap: 22px; justify-items: center; text-align: center; overflow: auto; height: calc(100% - 71px); }
.calib > .note { font-size: 14px; line-height: 1.6; text-align: left; }
#scr-calib.running { cursor: pointer; user-select: none; }
.calib-beat { --pulse: 0; position: relative; width: 150px; height: 150px; border-radius: 50%; border: 2px solid var(--line);
  transform: scale(calc(1 + var(--pulse) * 0.14)); box-shadow: 0 0 calc(var(--pulse) * 36px) rgba(227, 194, 127, calc(var(--pulse) * 0.7)); }
.calib-beat.lead { border-style: dashed; }
.calib-beat .planet { position: absolute; top: 50%; width: 30px; height: 30px; margin-top: -15px; border-radius: 50%; }
.calib-beat .fire { left: 22px; background: var(--fire); box-shadow: 0 0 14px var(--fire); }
.calib-beat .ice { right: 22px; background: var(--ice); box-shadow: 0 0 14px var(--ice); opacity: calc(0.45 + var(--pulse) * 0.55); }
.calib-status { margin: 0; min-height: 3em; font-size: 15px; max-width: 560px; }
.calib-meter { position: relative; width: min(560px, 100%); height: 44px; margin-top: 18px; border-radius: 8px; background: linear-gradient(90deg, transparent, rgba(125, 255, 138, 0.14) 44%, rgba(125, 255, 138, 0.14) 56%, transparent); border: 1px solid var(--line); }
.calib-meter::after { content: ''; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 2px; margin-left: -1px; background: var(--muted); }
.calib-meter .lbl { position: absolute; top: -20px; font-size: 12px; color: var(--muted); }
.calib-meter .lbl.l { left: 0; } .calib-meter .lbl.c { left: 50%; transform: translateX(-50%); } .calib-meter .lbl.r { right: 0; }
.calib-meter .marks i { position: absolute; top: 9px; bottom: 9px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: var(--great); opacity: 0.75; }
.calib-meter .avg { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--fire); box-shadow: 0 0 10px var(--fire); }
.calib-stats { display: flex; gap: clamp(18px, 5vw, 48px); margin: 0; }
.calib-stats div { display: grid; gap: 2px; justify-items: center; }
.calib-stats dt { font-size: 12px; color: var(--muted); }
.calib-stats dd { margin: 0; font-family: var(--display); font-size: 20px; font-variant-numeric: tabular-nums; }
.calib-actions { display: flex; gap: 48px; padding-left: 26px; }
input[type=range] { accent-color: var(--fire); }
input[type=checkbox] { accent-color: var(--ice); width: 18px; height: 18px; }

/* ---- log */
.log-filter { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 14px; }
.log-filter label { display: flex; gap: 6px; align-items: center; }
.log-list { list-style: none; margin: 0; padding: 12px clamp(16px, 4vw, 48px) 40px; overflow: auto; height: calc(100% - 71px); font-size: 14px; }
.log-list li { display: grid; grid-template-columns: 90px 1fr auto; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.log-list .lv { font-size: 12px; }
.log-list .c { color: var(--muted); font-variant-numeric: tabular-nums; }
.lv.error { color: var(--miss); } .lv.unsupported { color: #ff8fa0; } .lv.approx { color: var(--great); } .lv.warn { color: var(--good); } .lv.info { color: var(--ice); }

/* ---- loading */
.loading-box { text-align: center; min-width: 280px; }
.orbit-spinner { width: 80px; height: 80px; margin: 0 auto 22px; position: relative; animation: spin 1s linear infinite; }
.orbit-spinner i { position: absolute; width: 22px; height: 22px; border-radius: 50%; top: 29px; }
.orbit-spinner i:first-child { left: 8px; background: var(--fire); box-shadow: 0 0 18px var(--fire); }
.orbit-spinner i:last-child { right: 8px; background: var(--ice); box-shadow: 0 0 18px var(--ice); }
@keyframes spin { to { transform: rotate(360deg); } }
.pbar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 14px; }
.pbar div { height: 100%; width: 0; background: var(--gold); transition: width 0.15s; }

/* ---- HUD */
.hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; display: none; }
.hud.active { display: block; }
/* play HUD (photo 7 layout): equal margins from each corner, readable on bright and dark scenes */
.hud { --m: clamp(10px, 1.6vw, 26px); --hud-shadow: 0 0 2px rgba(0, 0, 0, 0.95), 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.55); }
.hud-top { position: absolute; left: 50%; top: var(--m); transform: translateX(-50%); width: min(34vw, 560px); text-align: center; }
.hud-bar { height: clamp(6px, 0.8vw, 10px); border-radius: 999px; background: rgba(255, 255, 255, 0.22); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); overflow: hidden; }
.hud-bar div { height: 100%; width: 0; border-radius: 999px; background: #c9a7ff; }
.hud-judge { margin-top: clamp(6px, 1vw, 14px); min-height: 1.2em; font-family: var(--display); font-weight: 600; font-size: clamp(16px, 2vw, 30px); color: #fff; text-shadow: var(--hud-shadow); }
.hud-streak { font-family: var(--display); font-weight: 800; font-size: clamp(34px, 4.6vw, 72px); line-height: 1; color: #b37cff; text-shadow: var(--hud-shadow); min-height: 1em; }
.hud-info { position: absolute; top: var(--m); margin: 0; font-family: var(--display); font-weight: 600; font-size: clamp(12px, 1.3vw, 20px); line-height: 1.45; color: #fff; text-shadow: var(--hud-shadow); }
.hud-info div { display: flex; gap: 0.45em; }
.hud-info dt::after { content: ' |'; }
.hud-info dd { margin: 0; font-variant-numeric: tabular-nums; }
.hud-left { left: var(--m); }
.hud-right { right: var(--m); text-align: right; }
.hud-right div { justify-content: flex-end; }
.hud-info .acc { color: #ffe36b; }
.hud-info .best { color: #c9a7ff; }
@media (max-width: 700px) { .hud-top { width: 46vw; } .hud-info { font-size: 10px; } }
.pause-btn { pointer-events: auto; position: absolute; left: var(--m); bottom: var(--m); width: 36px; height: 36px; opacity: 0.75; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(0, 0, 0, 0.3); display: flex; gap: 5px; align-items: center; justify-content: center; }
.pause-btn span { width: 4px; height: 14px; background: #fff; border-radius: 1px; }
.num { font-family: var(--display); font-weight: 600; font-variant-numeric: tabular-nums; }
.sub { color: rgba(255, 255, 255, 0.6); font-size: 13px; }
@keyframes bump { from { transform: scale(1.15); } to { transform: scale(1); } }
@keyframes hudfade { to { opacity: 0; } }
.countdown { position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); font-family: var(--display); font-weight: 800; font-size: 96px; color: #fff; text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6); opacity: 0; }
.countdown.show { animation: cd 0.45s ease-out; }
@keyframes cd { from { opacity: 1; transform: translate(-50%, -50%) scale(1.25); } to { opacity: 0; transform: translate(-50%, -50%) scale(1); } }
.hud-bottom { position: absolute; left: 50%; bottom: var(--m); transform: translateX(-50%); width: min(360px, 44vw); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.error-meter { width: 100%; aspect-ratio: 720 / 84; }
.hud-counts { display: flex; justify-content: center; gap: 0.3em; font-size: clamp(15px, 1.9vw, 27px); line-height: 1.2; text-shadow: var(--hud-shadow); }
.hud-counts span { min-width: 2.6ch; text-align: center; }
/* colours of the original counter (photo 4): purple fail, red too early/late, salmon early/late, light green early/late perfect, green perfect */
.hud-counts [data-k="miss"] { color: #b45cf0; }
.hud-counts [data-k="too"] { color: #e8141e; }
.hud-counts [data-k="very"] { color: #f2765a; }
.hud-counts [data-k="ep"] { color: #a5f56a; }
.hud-counts [data-k="p"] { color: #5ff04a; }
@media (max-width: 700px) { .hud-bottom { width: 60vw; bottom: calc(var(--m) + 48px); } } /* above the pause / Auto Play buttons */
.hud-tools { position: absolute; right: 14px; bottom: 14px; opacity: 0.85; display: flex; gap: 10px; align-items: center; pointer-events: auto; }
.auto-btn { display: flex; align-items: center; gap: 8px; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 999px; padding: 6px 14px; color: #fff; font-size: 13px; }
.auto-btn .dot { width: 9px; height: 9px; border-radius: 50%; background: #555; }
.auto-btn .st { font-family: var(--display); font-weight: 600; color: var(--muted); min-width: 3ch; }
.auto-btn[aria-pressed="true"] { border-color: var(--ice); background: rgba(70, 166, 255, 0.22); }
.auto-btn[aria-pressed="true"] .dot { background: var(--ice); box-shadow: 0 0 8px var(--ice); }
.auto-btn[aria-pressed="true"] .st { color: var(--ice); }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(255, 255, 255, 0.25); color: #fff; display: grid; place-items: center; padding: 0; }
.ghost-btn { border-color: var(--line); color: var(--muted); }
.debug { position: absolute; right: 22px; top: 90px; margin: 0; color: #cfe; font: 12px/1.45 ui-monospace, monospace; background: rgba(0, 0, 0, 0.45); padding: 8px 10px; border-radius: 6px; display: none; }
.jt { position: absolute; left: 0; top: 0; will-change: transform, opacity; font-family: var(--display); font-weight: 600; font-size: 20px; white-space: nowrap; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8); }
.jt small { display: block; text-align: center; font-family: var(--body); font-size: 11px; opacity: 0.8; }
@keyframes jt { from { opacity: 1; margin-top: 0; } 70% { opacity: 1; } to { opacity: 0; margin-top: -28px; } }

/* ---- panels */
.panel { background: var(--bg); border: 1px solid var(--line); border-radius: 18px; padding: 34px 44px; min-width: min(420px, 92vw); max-width: 92vw; max-height: 94vh; overflow: auto; }
.panel h2 { font-family: var(--display); margin: 0 0 6px; }
.panel .col { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; padding-left: 26px; }
.panel .row { display: flex; gap: 36px; margin-top: 22px; padding-left: 26px; }
.muted { color: var(--muted); }
.results { width: min(720px, 94vw); }
.res-top { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 20px; margin: 10px 0 26px; align-items: end; }
.num.xl { font-size: clamp(36px, 6vw, 58px); color: var(--gold); }
.num.l { font-size: clamp(24px, 3.4vw, 34px); }
.res-grades { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 0; }
.res-grades small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.g-early { border-color: #c56cff !important; }
@media (max-width: 560px) { .res-grades { grid-template-columns: repeat(3, 1fr); } }
.res-grades div { border-top: 3px solid; padding-top: 8px; }
.res-grades dt { font-size: 13px; color: var(--muted); }
.res-grades dd { margin: 4px 0 0; font-family: var(--display); font-size: 26px; }
.g-perfect { border-color: var(--perfect) !important; } .g-great { border-color: var(--great) !important; }
.g-good { border-color: var(--good) !important; } .g-miss { border-color: var(--miss) !important; }
#resHist { width: 100%; height: 120px; margin-top: 16px; }

.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); background: var(--bg-2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; z-index: 50; opacity: 0; transition: opacity 0.2s; pointer-events: none; max-width: 90vw; }
.toast.on { opacity: 1; }

@media (max-width: 760px) {
  .select-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .map-side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 42vh; }
  .md-head { grid-template-columns: 1fr; }
  .settings label { grid-template-columns: 1fr; }
  .bar { flex-wrap: wrap; gap: 12px; }
  .res-top { grid-template-columns: 1fr 1fr; }
  .res-grades { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .orbit-spinner { animation-duration: 3s; }
  .jt, .countdown.show { animation-duration: 0.01s; }
}

@media (max-width: 640px), (max-height: 420px) {
  .auto-btn .lbl { display: none; }
  .auto-badge { top: auto; bottom: 46px; }
}

/* clear / all-perfect / autoplay header */
.res-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.res-head h2 { font-size: clamp(26px, 4vw, 38px); }
.res-badge { font-family: var(--display); font-size: 14px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--perfect); color: var(--perfect); }
.results.allperfect { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(227, 194, 127, 0.35), 0 0 48px rgba(227, 194, 127, 0.18); }
.results.allperfect .res-head h2 { color: var(--gold); }
.results.allperfect .res-badge { border-color: var(--gold); color: #1a1408; background: var(--gold); }
.results.autoplay .res-badge { border-color: var(--muted); color: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .results.allperfect .res-badge { animation: ap-glow 1.6s ease-in-out 3; }
  @keyframes ap-glow { 50% { box-shadow: 0 0 18px rgba(227, 194, 127, 0.8); } }
}

/* failure: big progress over the frozen frame */
.screen.overlay.fail-screen { background: rgba(8, 6, 16, 0.5); backdrop-filter: none; }
.fail-body { text-align: center; padding: 26px 40px 30px; margin: 0 16px; background: rgba(10, 9, 22, 0.62); border-radius: 20px; }
.fail-body .muted { color: #b3aecb; }
.fail-pct { font-size: clamp(88px, 18vw, 200px); line-height: 1; color: #fff; text-shadow: 0 6px 40px rgba(0, 0, 0, 0.7); }
.fail-label { font-family: var(--display); font-size: 22px; letter-spacing: 0.2em; color: var(--miss); margin: 6px 0 14px; }
.fail-reason { font-size: 16px; margin: 0 0 6px; }
.fail-body .row { justify-content: center; padding-left: 0; gap: 44px; }
kbd { font-family: var(--display); font-size: 0.6em; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }

/* clear screen (photo 8 layout): big title + difficulty line + 3-column judgement rows over the ending scene */
.screen.overlay.clear-screen { background: radial-gradient(ellipse at 50% 55%, rgba(5, 4, 12, 0.62), rgba(5, 4, 12, 0.25) 70%); backdrop-filter: none; }
.clear-body { text-align: center; padding: 0 16px; max-width: min(1100px, 96vw); text-shadow: 0 0 3px #000, 0 2px 10px rgba(0, 0, 0, 0.85); }
.clear-title { font-family: var(--display); font-weight: 800; font-size: clamp(40px, 7.5vw, 112px); line-height: 1.05; margin: 0; color: #fff; letter-spacing: 0.01em; }
.clear-sub { font-family: var(--display); font-weight: 600; font-size: clamp(22px, 3.6vw, 56px); margin: 0.2em 0 0.5em; color: #fff; min-height: 0.5em; }
.clear-sub:empty { margin: 0 0 0.4em; }
.clear-stats { display: grid; grid-template-columns: repeat(3, auto); justify-content: center; column-gap: clamp(28px, 5vw, 90px); row-gap: 0.25em; margin: 0 auto; font-family: var(--display); font-weight: 600; font-size: clamp(15px, 2vw, 30px); }
.clear-stats div { display: flex; gap: 0.35em; justify-content: center; white-space: nowrap; }
.clear-stats dt { color: #fff; }
.clear-stats dt::after { content: ':'; }
.clear-stats dd { margin: 0; font-variant-numeric: tabular-nums; }
.clear-stats .wide { grid-column: span 1; }
.clear-stats .c-acc { grid-column: 1 / span 2; }
.clear-stats .full { grid-column: 1 / -1; }
.c-perfect dd { color: #7dff8a; } .c-great dd { color: #ffe36b; } .c-good dd { color: #ff9f43; } .c-miss dd { color: #ff4b5c; } .c-acc dd { color: #ffe36b; }
.clear-mode { display: inline-block; min-height: 1.4em; font-size: clamp(11px, 1.1vw, 14px); color: #cfe6ff; border: 1px solid rgba(70, 166, 255, 0.6); border-radius: 999px; padding: 2px 12px; margin-bottom: 6px; }
.clear-mode:empty { visibility: hidden; }
.clear-body .row, .fail-body .row { display: flex; flex-wrap: wrap; justify-content: center; padding-left: 0; gap: 36px; margin-top: 18px; }
.clear-body .row { margin-top: clamp(14px, 2.2vw, 30px); }
.clear-screen.allperfect .clear-title { color: #fff6d8; text-shadow: 0 0 3px #000, 0 0 24px rgba(255, 214, 120, 0.55); }
@media (prefers-reduced-motion: no-preference) {
  .clear-screen.active .clear-title { animation: clear-in 0.5s ease-out both; }
  .clear-screen.active .clear-stats { animation: clear-in 0.5s ease-out 0.15s both; }
  @keyframes clear-in { from { opacity: 0; transform: translateY(8px); } }
}
/* compatibility report (map detail) */
.diag-wrap { overflow-x: auto; max-width: 100%; }
.support table.diag { min-width: 640px; font-size: 13px; }
.diag th { text-align: left; font-weight: 600; color: var(--muted); padding: 4px 14px 4px 0; border-bottom: 1px solid var(--line); }
.support table.diag td:nth-child(2) { text-align: left; }
.diag td:nth-child(5) { text-align: right; font-variant-numeric: tabular-nums; }
.diag code { font-size: 12px; color: var(--gold); }
.tag.ok { background: #1f4a33; color: #93f2b4; }
.tag.partial { background: #3f3a63; color: #cfc6ff; }
.tag.ignored { background: #3a3a46; color: #c9c7d6; }
.tag.differs { background: #5a4a1d; color: #ffe08a; }
.tag.unverified { background: #24435a; color: #a8dcff; }
.tag.mod { background: #5a2450; color: #ffb3ec; }
.diag .tag, .diag th { white-space: nowrap; }
.forum-card .fid { color: var(--muted); font-weight: 400; font-size: 13px; }
.forum-card .fmeta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; }
.forum-card .fdiff { padding: 1px 7px; border-radius: 6px; font-weight: 700; font-size: 12px; color: #111; background: var(--dc); }
.forum-card .fstat { display: inline-flex; align-items: center; gap: 4px; color: var(--text, #e8e6f0); font-variant-numeric: tabular-nums; }
.forum-card .fstat svg { opacity: .85; }
.row-del { position: absolute; right: 46px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border-radius: 50%; border: 0; background: none; color: var(--muted); display: grid; place-items: center; padding: 0; opacity: .55; }
.map-list li:hover .row-del, .row-del:focus-visible { opacity: 1; }
.row-del:hover { color: var(--miss); background: var(--bg); }
.map-row .fs { grid-column: 2; display: flex; align-items: center; gap: 4px; color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.map-row .fs svg { width: 12px; height: 12px; opacity: .85; }
.map-row .fs small { color: var(--muted); margin-left: 4px; }
/* header buttons never break inside a word; a narrow window wraps whole buttons onto a second row */
.bar { flex-wrap: wrap; row-gap: 10px; }
.bar > * { white-space: nowrap; flex-shrink: 0; }

/* Netlify injects a fixed "Powered by Netlify" badge (iframe #nl-badge-frame, 197×64 px at the bottom-right corner, also
   over fullscreen): keep the Auto Play / fullscreen buttons, and on narrow screens the judgement bar, above it */
body:has(#nl-badge-frame) .hud-tools { bottom: 74px; }
@media (max-width: 700px) { body:has(#nl-badge-frame) .hud-bottom { bottom: calc(var(--m) + 108px); } }
