:root {
  --bg: #0b0b0c;
  --panel: #0f0f11;
  --line: #232326;
  --line-2: #34343a;
  --fg: #ededea;
  --mute: #8a8a90;
  --dim: #55555b;
  --acc: #d4ff3a;
  --acc-ink: #0b0b0c;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --side-w: 440px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--mono); font-size: 13px; line-height: 1.55; }
body { overflow: hidden; }
button { font: inherit; color: inherit; background: transparent; border: 1px solid var(--line-2); padding: 7px 12px; cursor: pointer; text-transform: uppercase; letter-spacing: .04em; font-size: 11.5px; }
button:hover { border-color: var(--fg); }
button.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 700; }
button.primary:hover { background: var(--acc); border-color: var(--acc); }
button.ghost { border-color: transparent; color: var(--mute); }
button.ghost:hover { color: var(--fg); border-color: var(--line-2); }
button:disabled { opacity: .35; cursor: default; }
button i { font-style: normal; color: var(--dim); margin-right: 6px; }
button.primary i { color: #555; }
kbd { font-family: var(--mono); font-size: 10.5px; border: 1px solid var(--line-2); padding: 0 4px; margin: 0 1px; color: var(--fg); }
code { font-family: var(--mono); color: var(--acc); }
.kicker { margin: 0 0 8px; font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: .08em; }

/* top bar */
.bar { position: fixed; inset: 0 0 auto 0; height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--bg); z-index: 20; }
.brand { color: var(--fg); text-decoration: none; font-weight: 800; letter-spacing: .06em; font-size: 15px; }
.brand span { color: var(--acc); }
nav { display: flex; gap: 8px; }

/* stage */
#stage { position: fixed; inset: 52px 0 0 0; transition: right .35s cubic-bezier(.2,.8,.2,1); right: 0; }
body.side-open #stage { right: var(--side-w); }
#gl { width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
.intro { position: absolute; top: 28px; left: 24px; max-width: 360px; pointer-events: none; }
.intro h1 { font-size: 30px; line-height: 1.12; margin: 0 0 12px; font-weight: 800; letter-spacing: -.01em; }
.intro p { color: var(--mute); margin: 0; }
.intro p b { color: var(--fg); }
body.side-open .intro { opacity: 0; }
.intro { transition: opacity .3s; }

.legend { position: absolute; left: 24px; bottom: 24px; border: 1px solid var(--line); background: rgba(11,11,12,.8); padding: 12px 14px; }
.legend ul { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(2, auto); gap: 4px 18px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend li b { width: 14px; }
.legend .sw { width: 11px; height: 11px; display: inline-block; }
.legend li span:last-child { color: var(--mute); }
.toggle { display: flex; gap: 6px; align-items: center; color: var(--mute); cursor: pointer; font-size: 11.5px; }
.toggle input { accent-color: var(--acc); margin: 0; }
.keys { margin: 8px 0 0; color: var(--dim); font-size: 11px; }

.scramble-box { position: absolute; right: 24px; bottom: 24px; width: min(520px, calc(100% - 340px)); }
.scramble-row { display: flex; border: 1px solid var(--line-2); background: var(--bg); }
.scramble-row input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--fg); font: inherit; font-size: 14px; padding: 10px 12px; outline: none; }
.scramble-row button { border: 0; border-left: 1px solid var(--line-2); }
.scramble-row:focus-within { border-color: var(--fg); }
#hold { text-transform: none; letter-spacing: 0; color: var(--dim); }

.toast { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; font-weight: 700; font-size: 12px; z-index: 5; }

/* sidebar */
.side { position: fixed; top: 52px; right: 0; bottom: 0; width: var(--side-w); background: var(--panel); border-left: 1px solid var(--line); transform: translateX(100%); transition: transform .35s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; z-index: 15; }
.side.show { transform: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 10px; }
.side-head .kicker { margin: 0; }
.x { border: 0; font-size: 20px; padding: 0 6px; line-height: 1; }
.progress { display: flex; gap: 3px; padding: 0 18px 14px; border-bottom: 1px solid var(--line); }
.progress div { flex: 1; height: 6px; background: var(--line); position: relative; cursor: pointer; }
.progress div span { position: absolute; inset: 0 auto 0 0; background: var(--fg); width: 0; }
.progress div.cur span { background: var(--acc); }
.progress div:hover { outline: 1px solid var(--line-2); }
.side-body { flex: 1; overflow-y: auto; padding: 18px; }
.side-body h2 { margin: 0 0 14px; font-size: 20px; font-weight: 800; }
.side-body h2 #s-tag { color: var(--dim); }
.txt p { margin: 0 0 10px; }
.txt ul { margin: 0 0 12px; padding-left: 0; list-style: none; }
.txt li { padding-left: 16px; position: relative; margin-bottom: 6px; }
.txt li::before { content: '▪'; position: absolute; left: 0; color: var(--acc); }
.txt b { color: #fff; }
.txt .note { color: var(--mute); border-left: 2px solid var(--line-2); padding-left: 10px; }
.txt .alg code { font-size: 14px; }
.kicker.sub { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.moves { display: flex; flex-wrap: wrap; gap: 4px; }
.moves span { border: 1px solid var(--line-2); padding: 3px 7px; min-width: 32px; text-align: center; color: var(--mute); font-weight: 500; }
.moves span.done { color: var(--fg); border-color: var(--line-2); background: #18181b; }
.moves span.now { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); font-weight: 800; }
.moves .empty { border: 0; color: var(--dim); padding: 0; }
.side-foot { border-top: 1px solid var(--line); padding: 14px 18px 18px; display: grid; gap: 10px; }
.transport { display: grid; grid-template-columns: 48px 1fr 48px; gap: 6px; }
.speed { display: flex; gap: 4px; align-items: center; color: var(--mute); font-size: 11px; text-transform: uppercase; }
.speed span { margin-right: auto; }
.speed button { padding: 4px 9px; }
.speed button.on { border-color: var(--acc); color: var(--acc); }
.nav2 { display: grid; grid-template-columns: 1fr 1.3fr; gap: 6px; }
.follow { border-style: dashed; }
.follow.on { border-color: var(--acc); color: var(--acc); border-style: solid; }

/* timer */
.timer { position: fixed; top: 52px; left: 0; right: 0; bottom: 0; background: rgba(11,11,12,.94); z-index: 30; display: flex; flex-direction: column; align-items: center; padding: 28px 20px; }
.timer[hidden] { display: none; }
.timer-head { width: 100%; max-width: 760px; display: flex; justify-content: space-between; align-items: center; }
.tm-scr { font-size: 18px; text-align: center; max-width: 760px; margin: 16px 0 0; word-spacing: .2em; }
.tm-time { font-size: clamp(64px, 16vw, 160px); font-weight: 800; letter-spacing: -.03em; margin: 3vh 0 0; font-variant-numeric: tabular-nums; }
.tm-time.hold { color: #ff5a4a; } .tm-time.ready { color: var(--acc); }
.tm-help { color: var(--mute); }
.tm-stats { display: flex; gap: 22px; color: var(--mute); margin: 8px 0; }
.tm-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; max-width: 760px; justify-content: center; }
.tm-list li { border: 1px solid var(--line); padding: 2px 8px; color: var(--mute); }
.tm-actions { display: flex; gap: 8px; margin-top: auto; }

@media (max-width: 900px) {
  :root { --side-w: 100vw; }
  body.side-open #stage { right: 0; }
  .side { top: 45%; border-left: 0; border-top: 1px solid var(--line); }
  body.side-open #stage { bottom: 55%; }
  .intro { display: none; }
  .legend { display: none; }
  .scramble-box { left: 16px; right: 16px; width: auto; bottom: 16px; }
  nav button i { display: none; }
  nav { gap: 4px; } nav button { padding: 6px 8px; font-size: 10.5px; }
  .bar { padding: 0 12px; }
  #btn-reset { display: none; }
}

/* trainer */
.tabs { display: flex; flex-wrap: wrap; gap: 0; padding: 0 18px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 2px solid transparent; padding: 9px 10px; color: var(--mute); }
.tabs button.on { color: var(--fg); border-bottom-color: var(--acc); }
.tabs button:hover { color: var(--fg); }
.tr-blurb { color: var(--mute); margin: 0 0 16px; }
.tr-cases-head { display: flex; justify-content: space-between; align-items: center; }
.tr-cases-head .kicker { margin: 0; }
button.mini { padding: 2px 7px; font-size: 10px; margin-left: 4px; }
.cases { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-top: 8px; }
.cases.wide { grid-template-columns: 1fr; }
.case { border: 1px solid var(--line-2); padding: 8px 6px 6px; cursor: pointer; text-align: center; position: relative; text-transform: none; letter-spacing: 0; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.cases.wide .case { flex-direction: row; text-align: left; justify-content: space-between; padding: 9px 10px; }
.case.off { opacity: .35; }
.case:hover { border-color: var(--fg); opacity: 1; }
.case .acc { color: var(--dim); font-size: 10px; }
.case .acc.good { color: var(--acc); }
.case svg { display: block; }
.scen .setup-label { color: var(--mute); margin: 0 0 4px; }
.setup { font-size: 13px; color: var(--fg); background: #141417; border: 1px solid var(--line); padding: 8px 10px; margin: 0 0 14px; word-spacing: .18em; line-height: 1.7; }
.ask p { margin: 0 0 8px; }
.quiz { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 5px; margin-bottom: 10px; }
.quiz button { text-transform: none; letter-spacing: 0; font-size: 12px; padding: 7px 6px; }
.quiz button.right { border-color: var(--acc); color: var(--acc); }
.quiz button.wrong { border-color: #ff5a4a; color: #ff5a4a; text-decoration: line-through; }
.verdict { font-weight: 700; margin: 4px 0 12px; }
.verdict.good { color: var(--acc); } .verdict.bad { color: #ff5a4a; }
.reveal-btn { width: 100%; margin-bottom: 12px; }
.algcard { border: 1px solid var(--line-2); padding: 12px; margin-bottom: 10px; display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; }
.algcard.nopic { grid-template-columns: 1fr; }
.algcard h3 { margin: 0 0 6px; font-size: 15px; }
.algcard .groups { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 8px; }
.algcard .groups code { font-size: 14px; }
.algcard .groups code + code::before { content: '·'; color: var(--dim); margin-right: 10px; }
.algcard p { margin: 0 0 6px; color: var(--mute); }
.algcard p b { color: var(--fg); }
.inspect { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.inspect .cd { font-size: 22px; font-weight: 800; min-width: 44px; }
.side.train { z-index: 16; }
.hintline { color: var(--mute); border-left: 2px solid var(--line-2); padding-left: 10px; }
.grade { display: flex; gap: 6px; margin-top: 8px; }
.grade button { flex: 1; }
.grade .verdict { margin: 0; }
