:root {
  --accent: #ffb04a;
  --accent2: #78f2ff;
  --ink: #fff6f0;
  --panel: rgba(18, 10, 40, 0.62);
  --line: rgba(255, 255, 255, 0.14);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0c0718; color: var(--ink);
  font-family: 'Chakra Petch', ui-sans-serif, system-ui, sans-serif; user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
.dim { opacity: 0.6; }
kbd { display: inline-block; min-width: 1.7em; padding: 1px 6px; margin-right: 3px; border: 1px solid var(--line);
  border-bottom-width: 3px; border-radius: 5px; font: 600 12px 'Chakra Petch', monospace; text-align: center; background: rgba(255,255,255,0.06); }

#vignette { position: fixed; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, color-mix(in srgb, var(--accent2) 35%, transparent) 100%);
  transition: opacity 0.15s; }

/* ---------- logo / loading ---------- */
.logo { font-weight: 700; font-style: italic; font-size: 64px; letter-spacing: 0.12em; line-height: 1;
  background: linear-gradient(180deg, #fff 10%, var(--accent) 90%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 60%, transparent)); }
.logo span { background: linear-gradient(180deg, #fff 10%, var(--accent2) 90%); -webkit-background-clip: text; background-clip: text; }
#loading { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; gap: 18px;
  background: radial-gradient(ellipse at 50% 70%, #3a1a5c, #0c0718 70%); z-index: 50; transition: opacity 0.6s; }
#loading-text { letter-spacing: 0.3em; text-transform: uppercase; font-size: 13px; opacity: 0.8; animation: pulse 1.2s infinite alternate; }
@keyframes pulse { from { opacity: 0.35; } to { opacity: 0.9; } }

/* ---------- panels ---------- */
.panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(760px, 94vw); max-height: 94vh; overflow: auto;
  padding: 30px 34px; background: var(--panel); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 30px 80px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.12);
  text-align: center; z-index: 20; animation: rise 0.35s ease-out; }
.panel.small { width: min(380px, 92vw); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, -46%); } }
.sub { margin-top: 8px; letter-spacing: 0.25em; text-transform: uppercase; font-size: 12px; opacity: 0.75; }
.card { margin: 22px auto 6px; padding: 14px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, transparent), color-mix(in srgb, var(--accent2) 10%, transparent)); }
.eyebrow { letter-spacing: 0.35em; font-size: 12px; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.course-name { font-size: 34px; font-weight: 700; font-style: italic; letter-spacing: 0.04em; margin: 4px 0; }
.meta { font-size: 14px; letter-spacing: 0.08em; margin-top: 4px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 18px; text-align: left; }
@media (max-width: 640px) { .cols { grid-template-columns: 1fr; } .logo { font-size: 44px; } }
.col h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.25em; text-transform: uppercase; font-weight: 600; opacity: 0.85; display: flex; align-items: center; gap: 8px; }
.chip { font-size: 10px; letter-spacing: 0.15em; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); opacity: 0.8; }
.chip.on { color: #7dffb0; border-color: #7dffb066; }
.keys { border-collapse: collapse; font-size: 13px; }
.keys td { padding: 3px 6px 3px 0; vertical-align: middle; }
.tip { font-size: 12.5px; opacity: 0.75; line-height: 1.45; margin: 10px 0 0; }
.board { list-style: none; margin: 0; padding: 0; font-size: 14px; counter-reset: r; }
.board li { display: flex; justify-content: space-between; padding: 5px 10px; border-radius: 8px; counter-increment: r; }
.board li::before { content: counter(r); width: 1.8em; opacity: 0.5; }
.board li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .t { font-variant-numeric: tabular-nums; font-weight: 600; }
.board li:nth-child(odd) { background: rgba(255,255,255,0.04); }
.board li.me { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.board li.empty::before { content: ''; }
.board li.empty { opacity: 0.6; justify-content: center; font-size: 13px; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.col-row { flex-direction: column; align-items: stretch; }
input { font: 600 16px 'Chakra Petch', sans-serif; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(0,0,0,0.25); color: var(--ink); outline: none; width: 220px; letter-spacing: 0.05em; user-select: text; }
input:focus { border-color: var(--accent); }
button { font: 700 15px 'Chakra Petch', sans-serif; letter-spacing: 0.15em; padding: 11px 20px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,0.08); color: var(--ink); transition: transform 0.1s, background 0.15s; }
button:hover { background: rgba(255,255,255,0.16); transform: translateY(-1px); }
button.primary { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #ff4f9a)); color: #1a0c22; border: none;
  box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 50%, transparent); }
button kbd { font-size: 10px; padding: 0 4px; margin-left: 6px; border-color: currentColor; opacity: 0.6; }
.big-time { font-size: 68px; font-weight: 700; font-style: italic; font-variant-numeric: tabular-nums; margin: 6px 0;
  text-shadow: 0 0 30px color-mix(in srgb, var(--accent) 70%, transparent); }
.laps { display: flex; gap: 8px; justify-content: center; margin: 12px 0; flex-wrap: wrap; }
.laps span { padding: 4px 12px; border-radius: 99px; border: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums; }
.laps span.best { border-color: var(--accent2); color: var(--accent2); }
#results .board { max-width: 380px; margin: 14px auto 0; text-align: left; }
.good { color: #7dffb0; } .bad { color: #ff7a8a; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; text-shadow: 0 2px 10px rgba(0,0,0,0.45); }
#h-top { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); text-align: center; }
#h-lap { letter-spacing: 0.35em; font-size: 13px; font-weight: 600; color: var(--accent); }
#h-time { font-size: 44px; font-weight: 700; font-style: italic; font-variant-numeric: tabular-nums; line-height: 1.05; }
#h-delta { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; height: 22px; transition: opacity 0.4s; }
#h-gate { position: absolute; top: 24px; right: 28px; font-size: 14px; letter-spacing: 0.25em; font-weight: 600; opacity: 0.85; }
#h-ghost { position: absolute; top: 24px; left: 28px; font-size: 12px; letter-spacing: 0.2em; opacity: 0.6; }
#h-bottom { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); text-align: center; }
#h-meter { display: flex; align-items: center; gap: 14px; justify-content: center; }
#h-speed { font-size: 34px; font-weight: 700; font-style: italic; font-variant-numeric: tabular-nums; min-width: 130px; text-align: right; }
#h-speed small { font-size: 12px; margin-left: 4px; opacity: 0.7; font-style: normal; letter-spacing: 0.1em; }
#h-boost, #h-drift { width: 220px; height: 12px; border-radius: 99px; background: rgba(0,0,0,0.35); border: 1px solid var(--line); overflow: hidden; }
#h-drift { width: 70px; }
#h-boost-fill { height: 100%; width: 30%; background: linear-gradient(90deg, var(--accent2), #fff); box-shadow: 0 0 14px var(--accent2); }
#h-drift-fill { height: 100%; width: 0%; background: var(--accent); }
#h-tags { display: flex; gap: 10px; justify-content: center; margin-bottom: 8px; height: 22px; }
#h-tags span { font-size: 13px; font-weight: 700; letter-spacing: 0.3em; padding: 1px 10px; border-radius: 99px; opacity: 0; transition: opacity 0.12s, transform 0.12s; transform: scale(0.85); }
#h-tags span.on { opacity: 1; transform: scale(1); }
#t-skim { background: color-mix(in srgb, var(--accent2) 30%, transparent); color: #fff; }
#t-drift { background: color-mix(in srgb, var(--accent) 35%, transparent); }
#t-boost { background: rgba(255,255,255,0.25); }
#h-arrow { position: absolute; left: 0; top: 0; font-size: 34px; color: var(--accent); transform-origin: 50% 50%;
  filter: drop-shadow(0 0 10px var(--accent)); opacity: 0; transition: opacity 0.2s; }
#h-pop { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); font-size: 30px; font-weight: 700; font-style: italic;
  letter-spacing: 0.12em; opacity: 0; white-space: nowrap; }
#h-pop.show { animation: pop 1.1s ease-out forwards; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.8); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70%) scale(1); } }
#countdown { position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%); font-size: 140px; font-weight: 700; font-style: italic;
  z-index: 15; pointer-events: none; color: #fff; text-shadow: 0 0 40px var(--accent); }
#countdown.tick { animation: tick 0.9s ease-out; }
@keyframes tick { from { transform: translate(-50%, -50%) scale(1.5); opacity: 0.2; } 30% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
#toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 12px; background: var(--panel);
  border: 1px solid var(--line); opacity: 0; transition: opacity 0.3s; z-index: 40; pointer-events: none; font-size: 14px; letter-spacing: 0.08em; }
#toast.show { opacity: 1; }
