/* EWGF Practice - graphite, white and one electric-blue accent */
:root {
  --bg: #0c0c0e; --panel: #141417; --cell: #1c1c20; --line: #27272c;
  --fg: #f5f5f7; --muted: #8e8e96; --ink: #0c0c0e;
  --gray: #8e8e96; --blue: #5e9bff;
  --accent: #5e9bff; --accent-strong: #3f86ff; --accent-soft: rgba(94, 155, 255, .12);
  --grad: #5e9bff;
  --bad: #ff5a5f;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font);
  max-width: 880px; margin: 0 auto; padding: 0 16px 96px;
  -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--ink); }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 28px 0 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 6px; }
.brand h1 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -.02em; }
.brand p { margin: 0; color: var(--muted); font-size: 12.5px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.keyhint { color: var(--muted); font-size: 12px; font-family: var(--mono); margin-right: 6px; }

.banner { border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; margin: 0 0 12px;
  color: var(--muted); font-size: 13.5px; cursor: pointer; }
.banner.warn { border-color: var(--bad); color: var(--bad); }

/* tabs */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 0; margin-bottom: -1px;
  color: var(--muted); font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.tab:hover { color: var(--fg); }

/* controls */
.btn { border: 1px solid transparent; border-radius: 999px; padding: 7px 16px; cursor: pointer; font-weight: 500; font-size: 14px;
  transition: background .15s, border-color .15s, color .15s; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: none; }
.btn.primary:hover { background: #77abff; }
.btn.gold { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn.gold:hover { background: var(--accent-soft); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--fg); }
.btn.ghost:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
select, input[type=number] { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; }
select:focus, input:focus { outline: none; border-color: var(--accent); }
input[type=number] { width: 72px; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
input[type=range] { accent-color: var(--accent); width: 140px; vertical-align: middle; }
label { color: var(--muted); font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
label.check { color: var(--fg); }

.panel { border: 1px solid var(--line); border-radius: 16px; padding: 12px 18px; margin-bottom: 16px; background: var(--panel); }
.row { display: flex; align-items: center; gap: 10px 18px; flex-wrap: wrap; padding: 5px 0; }
.row .right { margin-left: auto; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }

.label { color: var(--muted); font-weight: 500; font-size: 12px; letter-spacing: .02em; margin: 22px 0 8px; }
.label span { font-weight: 400; margin-left: 8px; opacity: .8; }

/* results */
.glow { position: fixed; inset: -30vh 0 auto; height: 70vh; pointer-events: none; z-index: -1;
  background: radial-gradient(ellipse 60% 55% at 50% 30%, rgba(94, 155, 255, .10), transparent 70%); }

/* the big result card */
.stage { position: relative; text-align: center; padding: 34px 20px 26px; margin: 0 0 14px; border-radius: 20px;
  border: 1px solid var(--line); overflow: hidden;
  background: radial-gradient(ellipse 70% 90% at 50% 0%, rgba(94, 155, 255, .07), transparent 70%), var(--panel); }
.big { font-size: 64px; font-weight: 700; line-height: 1.05; letter-spacing: -.035em;
  text-shadow: 0 0 48px color-mix(in srgb, currentColor 40%, transparent); transition: color .2s; }
.stage .lamps { margin: 22px 0 0; }
.frames { display: inline-block; margin-top: 12px; padding: 5px 16px; border-radius: 999px; font-size: 17px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(94, 155, 255, .35); font-variant-numeric: tabular-nums; }
.frames:empty { display: none; }

/* stat tiles */
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 14px; }
.chip { border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px; text-align: center; background: var(--panel); }
.chip b { display: block; font-size: 22px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.chip span { color: var(--muted); font-size: 12px; }

/* compact control row */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.toolbar .right { margin-left: auto; }

/* nerd mode: detail is hidden until switched on */
body:not(.nerd-on) .nerd, body:not(.nerd-on) .nerd-inline, body:not(.nerd-on) .nerd-cell { display: none !important; }
.nerd-toggle { position: fixed; right: 20px; bottom: 20px; z-index: 10; display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 18px 10px 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .28); background: rgba(20, 20, 23, .92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); color: var(--fg); font-size: 14px; font-weight: 600;
  cursor: pointer; box-shadow: 0 8px 28px rgba(0, 0, 0, .55);
  transition: transform .15s, box-shadow .15s; }
.nerd-toggle:hover { transform: translateY(-1px); box-shadow: 0 10px 32px rgba(0, 0, 0, .65); border-color: rgba(255, 255, 255, .5); }
.nerd-toggle .switch { width: 32px; height: 18px; border-radius: 999px; background: #3a3a40; position: relative; transition: background .2s; }
.nerd-toggle .switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--fg); transition: transform .2s; }
.nerd-on .nerd-toggle { color: var(--accent); border-color: var(--accent); }
.nerd-on .nerd-toggle .switch { background: var(--grad); }
.nerd-on .nerd-toggle .switch::after { transform: translateX(14px); background: var(--ink); }

.hero { text-align: center; margin: 12px 0 20px; min-height: 76px; }
.sub { color: var(--muted); font-size: 15px; white-space: pre-line; margin-top: 6px; }
.detail { color: var(--muted); font-family: var(--mono); font-size: 13px; margin-top: 6px; }
.mathline { color: var(--accent); font-weight: 500; font-size: 15px; margin-top: 6px; white-space: pre-line; }
.timing { border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-size: 13px; overflow-x: auto; white-space: nowrap; }
.help { color: var(--muted); font-size: 14px; text-align: center; margin: 4px 0 10px; }

.lamps { display: flex; justify-content: center; gap: 6px; margin: 4px 0 8px; flex-wrap: wrap; }
.lamps span { width: 36px; text-align: center; padding: 4px 0; border-radius: 8px; border: 1px solid var(--line);
  color: var(--muted); font-weight: 600; font-size: 14px; }
.lamps span.on { background: var(--accent); border-color: var(--accent); color: var(--ink); }
/* lamps match the chart: directions white / gray, buttons blue */
.lamps span[data-btn="f"].on, .lamps span[data-btn="b"].on { background: #fff; border-color: #fff; }
.lamps span[data-btn="d"].on, .lamps span[data-btn="u"].on { background: var(--gray); border-color: var(--gray); }

canvas.cv { display: block; width: 100%; background: var(--panel); border-radius: 16px; border: 1px solid var(--line); }
canvas.cv.ladder { background: transparent; border: 0; margin-bottom: 14px; }

.breakdown { width: 100%; border-collapse: collapse; margin-top: 16px; }
.breakdown th, .breakdown td { padding: 7px 4px; text-align: right; border-bottom: 1px solid var(--line); }
.breakdown th:first-child, .breakdown td:first-child { text-align: left; }
.breakdown th { color: var(--muted); font-size: 12px; font-weight: 500; }
.breakdown td + td { font-family: var(--mono); }
.breakdown tr.strong td { font-weight: 600; }
.breakdown tbody tr:last-child td { border-bottom: 0; }

.stats { color: var(--muted); font-size: 13px; text-align: center; margin: 16px 0 4px; }
.log { list-style: none; margin: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px;
  font-family: var(--mono); font-size: 12.5px; min-height: 56px; }
.log li { padding: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log:empty::before { content: "Nothing yet"; color: var(--muted); }

footer { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 44px; }
footer p { margin: 8px 0 0; }
footer .download { font-size: 13.5px; color: var(--fg); margin: 0 0 8px; }
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* settings dialog */
dialog { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 14px; padding: 0;
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(0, 0, 0, .7); }
.settings { padding: 22px 24px; display: flex; flex-direction: column; gap: 8px; }
.settings h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.settings h3 { margin: 14px 0 0; font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: .02em; }
.settings p { margin: 0; }
.bindgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.bind { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 8px; font-size: 13.5px; }
.bind button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; cursor: pointer;
  font-family: var(--mono); font-size: 12.5px; min-width: 60px; }
.bind button.listening { border-color: var(--accent); color: var(--accent); }

/* leaderboard */
.center { text-align: center; }
.center p { margin: 4px 0; }
input.text { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; width: 170px;
  -webkit-user-select: text; user-select: text; }
.lb-msg { margin: 4px 0 0; min-height: 1em; color: var(--bad); }
.lb-msg.ok { color: var(--accent); }
#lb-hint { margin: 4px 0 0; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.seg button { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 7px 14px; cursor: pointer;
  text-align: left; color: var(--muted); transition: border-color .15s; }
.seg button:hover { border-color: var(--muted); }
.seg button b { display: block; color: var(--fg); font-size: 14px; font-weight: 500; }
.seg button span { font-size: 11.5px; }
.seg button.active { border-color: var(--accent); background: var(--accent-soft); }
.seg button.active b { color: var(--accent); }
.board { width: 100%; border-collapse: collapse; }
.board th, .board td { padding: 9px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.board th { color: var(--muted); font-size: 12px; font-weight: 500; }
.board td:nth-child(1) { width: 44px; color: var(--muted); font-family: var(--mono); }
.board td:nth-child(3) { font-family: var(--mono); font-weight: 600; }
.board td:nth-child(4) { color: var(--muted); font-size: 13px; }
.board tr.me td { background: var(--accent-soft); }
.board tr.me td:nth-child(2) { color: var(--accent); font-weight: 600; }
.board tr.top1 td:nth-child(1), .board tr.top1 td:nth-child(3) { color: var(--accent); }
.board td.empty { color: var(--muted); text-align: center; padding: 22px; }

@media (max-width: 640px) {
  .top { padding-top: 18px; }
  .big { font-size: 40px; }
  .stage { padding: 26px 14px 20px; }
  .chip b { font-size: 19px; }
  .brand p, .keyhint { display: none; }
  .tabs { gap: 18px; }
  .lamps { gap: 4px; }
  .lamps span { width: 32px; }
}
