/* Dark, single-column, phone first. Same look as the drm doc page: slate background, flat buttons, a gear in the navbar. */
:root {
  --bg: #1d232a;
  --bg2: #191e24;
  --bg3: #15191e;
  --btn: #2a323c;
  --btn-hover: #323c48;
  --line: #2f3944;
  --ink: #e3e7ee;
  --muted: #8d97a6;
  --accent: #8ab4ff;
  --hit: #4cc38a;
  --miss: #f0716a;
  --warn: #e9a23b;
  --chip: #262e38;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); color-scheme: dark; }
body { font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--btn); border: 0; border-radius: 8px; padding: 0 16px; min-height: 44px; cursor: pointer; font-weight: 500; touch-action: manipulation; }
button:hover { background: var(--btn-hover); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: #0f1a2b; }
button.primary:hover { background: #a3c3ff; }
button.danger { color: var(--miss); }
button kbd { margin-left: 6px; font-size: 11px; opacity: .6; font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select, input[type=number] { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 40px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
input[type=number] { width: 4.5em; }

.app { min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom, 0px); }
.navbar {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
  min-height: calc(56px + env(safe-area-inset-top, 0px)); background: var(--bg); box-shadow: 0 1px 0 var(--line);
}
.navbar h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.nav-side { display: flex; }
.nav-side.right { justify-content: flex-end; }
button.icon { width: 44px; padding: 0; border-radius: 99px; background: transparent; display: grid; place-items: center; }
button.icon:hover { background: var(--btn); }
button.icon svg { width: 22px; height: 22px; }

main { width: 100%; max-width: 560px; margin: 0 auto; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 10px; }
footer { margin-top: auto; text-align: center; color: var(--muted); font-size: 12px; padding: 14px; background: var(--bg2); }

.pickrow { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: var(--muted); font-size: 13px; }
.pickrow label { display: inline-flex; gap: 6px; align-items: center; }
.pickrow select { color: var(--ink); }
.pickrow .count { margin-left: auto; font-family: var(--mono); color: var(--ink); font-weight: 600; }
.pickrow .check { cursor: pointer; }

.stat { display: flex; justify-content: space-between; align-items: baseline; }
.stat .pos { color: var(--muted); font-size: 13px; }
.stat .pos b { color: var(--ink); font-family: var(--mono); font-size: 18px; }
#timer { font-family: var(--mono); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
#timer.over { color: var(--warn); }
.caseline { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 8px 12px; background: var(--bg2); border-radius: 8px; }
.caseline b { font-family: var(--mono); font-size: 18px; }
.caseline span { color: var(--muted); font-family: var(--mono); font-size: 13px; }

#cube { width: 100%; height: min(78vw, 340px); display: grid; place-items: center; touch-action: none; }
#cube twisty-player { width: 100%; height: 100%; }
#scramble { margin: 0; text-align: center; font-family: var(--mono); font-size: 15px; word-spacing: .15em; overflow-wrap: anywhere; padding: 0 4px; }
#status { min-height: 1.5em; text-align: center; font-weight: 500; font-size: 14px; }
#status.hit { color: var(--hit); } #status.warn { color: var(--miss); } #status.info { color: var(--muted); }
#sols { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
#sols button { min-height: 36px; padding: 0 12px; font-family: var(--mono); font-size: 14px; background: var(--chip); }
#sols button.mine { box-shadow: inset 0 0 0 2px var(--hit); }
#sols .more { color: var(--muted); font-size: 13px; align-self: center; }

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.actions button { min-height: 52px; font-size: 16px; }
.divider { height: 1px; background: var(--line); margin: 6px 0; }

.seg { display: grid; grid-template-columns: 1fr 1fr; border-radius: 8px; overflow: hidden; background: var(--btn); }
.seg button { border-radius: 0; background: transparent; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #0f1a2b; }
.setpanel { display: grid; gap: 10px; }
.note { margin: 0; font-size: 12.5px; color: var(--muted); }
.bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--chip); }
.bar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; background: var(--sw); }
.s-new { --sw: var(--chip); } .s-learn { --sw: var(--miss); } .s-young { --sw: var(--warn); } .s-known { --sw: var(--hit); }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 5px; max-height: 320px; overflow-y: auto; padding: 2px; }
.chips button { font-family: var(--mono); font-size: 12px; padding: 4px 2px; min-height: 40px; line-height: 1.25; display: grid; background: var(--bg2); border-left: 4px solid var(--sw); border-radius: 6px; }
.chips button em { font-style: normal; color: var(--muted); font-size: 10.5px; }
.chips button.slow em { color: var(--warn); }
.chips button.cur { box-shadow: 0 0 0 2px var(--accent); }
.chips button.due { background: #2c2a24; }
h2 { margin: 6px 0 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.big div { display: grid; gap: 2px; }
.big b { font-family: var(--mono); font-size: 22px; font-variant-numeric: tabular-nums; }
.big span { font-size: 12px; color: var(--muted); }
.hist { display: grid; gap: 3px; max-height: 300px; overflow-y: auto; }
.hist div { display: grid; grid-template-columns: 5.6em 1.4em minmax(0, 1fr) 4.4em; gap: 8px; font-family: var(--mono); font-size: 12.5px; padding: 4px 6px; border-radius: 5px; background: var(--bg2); }
.hist div.ok { background: #1f2f2b; } .hist div.slow { background: #302b21; } .hist div.miss { background: #332427; }
.hist em { font-style: normal; color: var(--muted); text-align: right; }
.hist .empty { display: block; color: var(--muted); font-family: var(--font); background: none; }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(340px, 88vw); z-index: 21; background: var(--bg2); overflow-y: auto; display: grid; gap: 10px; align-content: start;
  padding: calc(14px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) 16px; box-shadow: -8px 0 24px rgba(0,0,0,.4); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer h2 { margin: 0; font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--ink); }
.drawer h3 { margin: 10px 0 0; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; }
.btnrow button { flex: 1 1 120px; }

dialog { border: 0; border-radius: 12px; background: var(--bg2); color: var(--ink); width: min(440px, calc(100vw - 32px)); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 8px; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--ink); }
dialog p { margin: 0 0 10px; }
dialog form { margin-top: 12px; }

@media (prefers-reduced-motion: reduce) { button:active { transform: none; } }

.scrrow { display: flex; justify-content: center; }
button.linkbtn { background: none; min-height: 36px; color: var(--muted); font-size: 13px; text-decoration: underline; padding: 0 10px; }
#sols button.trig { box-shadow: inset 4px 0 0 var(--hit); }
#sols button.brk { box-shadow: inset 4px 0 0 var(--warn); }
#sols button.mine { outline: 2px solid var(--ink); outline-offset: -2px; }
#sols .key { flex-basis: 100%; margin: 2px 0 0; text-align: center; font-size: 12px; color: var(--muted); }
#sols .key i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 5px 0 8px; }
#sols .key i.trig { background: var(--hit); } #sols .key i.brk { background: var(--warn); }

.moverow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 6px 6px 12px; background: var(--bg2); border-radius: 8px; }
#mymoves { min-width: 0; font-family: var(--mono); font-size: 15px; overflow-wrap: anywhere; }
#mymoves b { font-weight: 600; word-spacing: .15em; }
#mymoves span { color: var(--muted); font-size: 12.5px; font-family: var(--font); }
.moverow button { min-height: 38px; flex: none; }
