:root {
  --bg: #0b0c0f; --bg2: #101217; --panel: #15171d; --panel2: #1b1e25; --line: #262a33; --line2: #333845;
  --text: #eceef2; --soft: #c3c8d2; --muted: #8a919e;
  --accent: #ffcf5a; --accent-ink: #1b1403; --good: #5ee0a0; --mid: #ffcf5a; --bad: #ff7a6b; --cool: #8fb4ff;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 .5em; }
kbd { font: 500 10px var(--mono); padding: 1px 5px; border: 1px solid currentColor; border-radius: 4px; opacity: .6; margin-left: 6px; }

/* buttons */
.btn { font: 600 14px var(--font); border-radius: 10px; padding: 11px 18px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 4px; text-decoration: none !important; transition: filter .15s, transform .15s; }
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* nav */
.nav { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 12px clamp(16px, 4vw, 48px); background: #0b0c0fcc; backdrop-filter: blur(12px); border-bottom: 1px solid #ffffff0d; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); font-size: 17px; letter-spacing: -0.02em; text-decoration: none !important; }
.ball { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 8%, #b9bdc8 22%, #4a4f5c 60%, #15171c 100%); box-shadow: 0 3px 10px #0008; flex: none; }
.links { display: flex; gap: 20px; margin-right: auto; }
.links a { color: var(--soft); font-size: 14px; font-weight: 500; }
body.playing .nav { display: none; }

/* hero */
#home { max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 48px); }
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; padding: clamp(40px, 8vw, 96px) 0 56px; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; margin: 0 0 12px; }
.hero h1 { font-size: clamp(36px, 5.6vw, 64px); font-weight: 800; }
.lede { color: var(--soft); font-size: clamp(16px, 1.6vw, 18px); max-width: 560px; }
.byline { color: var(--muted); font-size: 14px; margin: 14px 0 0; max-width: 560px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 28px 0; }
.facts { display: flex; gap: 28px; list-style: none; padding: 0; margin: 0; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.facts b { color: var(--text); font-size: 22px; display: block; }

.hero-art { position: relative; aspect-ratio: 1 / .9; border-radius: 24px; background: radial-gradient(90% 70% at 70% 10%, #2a2e38 0%, #12141a 55%, #0b0c0f 100%); border: 1px solid var(--line); overflow: hidden; }
.orb { position: absolute; width: 30%; aspect-ratio: 1; border-radius: 50%; top: 14%; box-shadow: 0 30px 40px -10px #000c; }
.orb.chrome { left: 14%; background: radial-gradient(circle at 70% 24%, #fffbe8 0 5%, #ffe7a8 8%, transparent 14%), radial-gradient(circle at 50% 120%, #1a1c22 0 30%, transparent 60%), linear-gradient(180deg, #6d7484 0%, #c9ced8 46%, #2b2f38 54%, #4c5160 100%); }
.orb.grey { right: 14%; background: radial-gradient(circle at 68% 26%, #8a8a8a 0%, #565656 35%, #262626 70%, #141414 100%); }
.chart { position: absolute; left: 50%; bottom: 13%; transform: translateX(-50%) perspective(600px) rotateX(10deg); width: 58%; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4%; padding: 3%; background: #151515; border-radius: 6px; box-shadow: 0 20px 30px -10px #000c; }
.chart i { aspect-ratio: 1; border-radius: 2px; }
.floor { position: absolute; inset: auto 0 0 0; height: 22%; background: linear-gradient(#0000, #00000080); }

/* blocks */
.block { padding: 56px 0; border-top: 1px solid #ffffff0d; scroll-margin-top: 60px; }
.block > h2 { font-size: clamp(26px, 3vw, 34px); }
.sub { color: var(--soft); max-width: 640px; margin: 0 0 24px; }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 24px; }
.mode { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 4px; }
.mode p { color: var(--soft); font-size: 14px; margin: 0 0 8px; flex: 1; }
.mode .meta { flex: 0; color: var(--muted); font-size: 12.5px; }
.mode .btn { margin-top: 8px; align-self: flex-start; }
.mode.feature { background: linear-gradient(160deg, #2a2312 0%, var(--panel) 55%); border-color: #5a4a20; }
.tag { align-self: flex-start; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); border: 1px solid var(--line2); border-radius: 999px; padding: 2px 9px; margin-bottom: 10px; }
.tag.pro { color: var(--bad); border-color: #ff7a6b55; }
.mode h3 { font-size: 20px; margin: 0 0 6px; }

.profile { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.pcard .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.pcard .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.pcard small { color: var(--muted); }
.meter { height: 5px; border-radius: 5px; background: var(--line); margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--good); }

.lessons { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; counter-reset: l; }
.lesson { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.lesson .n { font: 500 12px var(--mono); color: var(--muted); }
.lesson h3 { font-size: 17px; margin: 0; }
.lesson p { color: var(--soft); font-size: 13.5px; margin: 0 0 6px; flex: 1; }
.lesson .st { font-size: 12.5px; color: var(--muted); }
.lesson.done { border-color: #2f6b52; }
.lesson.done .st { color: var(--good); }
.lesson.locked { opacity: .5; }
.lesson .btn { align-self: flex-start; }
.cert-row { margin-top: 18px; }

.learn { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.learn article { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.learn h3 { font-size: 17px; }
.learn p { color: var(--soft); font-size: 14px; margin: 0; }
.ic { width: 44px; height: 44px; border-radius: 50%; margin-bottom: 14px; }
.ic-chrome { background: radial-gradient(circle at 68% 28%, #fff 0 10%, transparent 20%), linear-gradient(180deg, #6d7484, #c9ced8 46%, #2b2f38 54%, #4c5160); }
.ic-grey { background: radial-gradient(circle at 66% 28%, #8a8a8a, #4a4a4a 45%, #161616); }
.ic-chart { border-radius: 8px; background: conic-gradient(#c15a63 0 25%, #469449 0 50%, #383d96 0 75%, #e7c71f 0); }
.ic-k { background: linear-gradient(90deg, #ff8a2a, #ffd6a8 35%, #fff 50%, #cfe0ff 70%, #9bbcff); }

.ticks { list-style: none; padding: 0; margin: 0 0 24px; }
.ticks li { padding: 10px 0 10px 28px; border-bottom: 1px solid var(--line); color: var(--soft); position: relative; }
.ticks li::before { content: ""; position: absolute; left: 4px; top: 17px; width: 10px; height: 6px; border-left: 2px solid var(--good); border-bottom: 2px solid var(--good); transform: rotate(-45deg); }
.ticks b { color: var(--text); }

.faq details { border-bottom: 1px solid var(--line); padding: 14px 0; max-width: 760px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { color: var(--soft); margin: 8px 0 0; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 32px 0 40px; border-top: 1px solid #ffffff0d; }

/* ---------- play ---------- */
#play { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; }
#play[hidden] { display: none; }
.hud { display: flex; align-items: center; gap: 14px; padding: 10px 18px; }
.hud-title { display: flex; flex-direction: column; line-height: 1.2; margin-right: auto; }
.hud-title b { font-size: 16px; }
.hud-title span { color: var(--muted); font-size: 12.5px; }
.stats { display: flex; gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; min-width: 70px; }
.stat .k { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.stat .v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 16px; }
.stat.warn .v { color: var(--bad); }

.stage { position: relative; margin: 0 18px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #000; min-height: 280px; }
#gl { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
#gl.dragging { cursor: grabbing; }
.stage.probing #gl { cursor: crosshair; }
.view-labels { position: absolute; inset: 0; pointer-events: none; display: grid; grid-template-columns: 1fr 1fr; z-index: 1; }
.view-labels::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #ffffff22; }
.lbl { align-self: start; justify-self: start; margin: 12px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; background: #000a; padding: 4px 10px; border-radius: 999px; backdrop-filter: blur(6px); }
.lbl.yours { color: var(--accent); }
.lbl.yours.flipped { color: var(--cool); }
.lbl em { font-style: normal; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); margin-left: 6px; }
.tools { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; z-index: 2; }
.tool { font: 600 12.5px var(--font); color: var(--text); background: #000b; border: 1px solid #ffffff22; border-radius: 8px; padding: 6px 10px; cursor: pointer; backdrop-filter: blur(6px); user-select: none; -webkit-user-select: none; touch-action: none; }
.tool[aria-pressed="true"], .tool.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.toast { position: absolute; left: 50%; top: 54px; transform: translateX(-50%); background: #000d; padding: 8px 14px; border-radius: 999px; font-size: 13px; z-index: 3; }
.probe-dot { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #000; pointer-events: none; z-index: 2; }
.probe-read { position: absolute; left: 12px; bottom: 12px; z-index: 2; background: #000c; border: 1px solid #ffffff22; border-radius: 10px; padding: 8px 10px; font: 500 12px/1.6 var(--mono); backdrop-filter: blur(6px); }
.probe-read .row { display: flex; align-items: center; gap: 8px; }
.probe-read .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid #fff4; }
.probe-read .nm { width: 52px; color: var(--muted); }

.panel { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 18px; align-items: end; padding: 14px 18px 18px; }
.ctrl label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; gap: 8px; }
.ctrl output { color: var(--text); font-variant-numeric: tabular-nums; text-transform: none; letter-spacing: 0; }
.ctrl.fixed { opacity: .35; }
.ctrl.fixed label::after { content: "given"; font-size: 10px; border: 1px solid var(--line2); border-radius: 4px; padding: 0 4px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input.kelvin { appearance: none; height: 6px; border-radius: 6px; background: linear-gradient(90deg, #ff8a2a, #ffd6a8 30%, #fff 50%, #cfe0ff 75%, #9bbcff); outline: none; }
input.kelvin::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid #0c0d10; box-shadow: 0 0 0 1px #fff8; cursor: pointer; }
input.kelvin::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid #0c0d10; }
.actions { display: flex; gap: 8px; }

/* dialogs */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px; width: min(500px, 94vw); box-shadow: 0 30px 80px #000c; }
dialog::backdrop { background: #000b; backdrop-filter: blur(4px); }
dialog h2 { font-size: 24px; }
dialog p { color: var(--soft); margin: 0 0 12px; }
dialog ul.cues { padding-left: 18px; color: var(--soft); margin: 0 0 14px; }
dialog ul.cues li { margin: 5px 0; }
dialog form { margin-top: 10px; }
.r-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.big { font-size: 60px; font-weight: 800; color: var(--accent) !important; margin: 0 !important; font-variant-numeric: tabular-nums; line-height: 1; }
.big small { font-size: 22px; color: var(--muted); font-weight: 600; }
#r-dome svg { display: block; width: 170px; height: 170px; }
.breakdown { list-style: none; padding: 0; margin: 12px 0; }
.breakdown li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.breakdown .bar { grid-column: 1 / -1; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.breakdown .bar i { display: block; height: 100%; background: var(--good); }
.breakdown small { color: var(--muted); }
.grid-sq { font-size: 22px; letter-spacing: 2px; }
.tip { font-size: 13.5px; color: var(--muted) !important; }
.r-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.r-actions .btn { flex: 1; }
/* leaderboard */
.mode .row { display: flex; gap: 8px; flex-wrap: wrap; }
.lb-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lb { list-style: none; padding: 0; margin: 0; max-width: 760px; }
.lb li { display: grid; grid-template-columns: 34px 28px 1fr auto 52px; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.lb li:nth-child(-n+3) .rk { color: var(--accent); font-weight: 800; }
.lb li.you { background: #ffcf5a14; border-radius: 8px; }
.lb .rk { color: var(--muted); font-weight: 600; }
.lb .fl { font-size: 18px; }
.lb .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb .nm em { font-style: normal; font-size: 11px; color: var(--accent-ink); background: var(--accent); border-radius: 4px; padding: 0 5px; margin-left: 6px; }
.lb .gr { letter-spacing: 1px; font-size: 13px; }
.lb b { text-align: right; }
.lb-count, .lb-empty { color: var(--muted); font-size: 13.5px; margin: 12px 0 0; }
#lb-dlg { width: min(560px, 94vw); }
#lb-dlg .lb { max-height: 60vh; overflow: auto; }
.submit-row { display: block !important; }
.submit-row label { display: block; font-size: 13px; color: var(--soft); margin-bottom: 8px; }
.submit { display: flex; gap: 8px; }
.submit input { flex: 1; min-width: 0; font: 15px var(--font); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line2); background: #0b0c0f; color: var(--text); }
#lb-msg { display: block; margin-top: 8px; color: var(--soft); }
@media (max-width: 760px) { .lb li { grid-template-columns: 28px 24px 1fr 44px; } .lb .gr { display: none; } }
/* player name */
.player-chip { gap: 8px; max-width: 220px; }
.player-chip .pn { overflow: hidden; text-overflow: ellipsis; }
.pc-ic { width: 16px; height: 16px; border-radius: 50%; flex: none; background: radial-gradient(circle at 35% 30%, #fff 0 10%, #b9bdc8 25%, #4a4f5c 65%, #15171c); }
#who input { width: 100%; font: 17px var(--font); padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line2); background: #0b0c0f; color: var(--text); margin-bottom: 12px; }
.submit-as { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.linkish { background: none; border: 0; color: var(--accent); font: 600 13px var(--font); cursor: pointer; padding: 0; }
@media (max-width: 760px) { .player-chip { max-width: 120px; } }
#cert-name { width: 100%; font: 16px var(--font); padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line2); background: #0b0c0f; color: var(--text); }

@media (max-width: 980px) {
  .modes, .learn, .profile { grid-template-columns: 1fr 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero-art { max-width: 520px; }
}
@media (max-width: 760px) {
  .links { display: none; }
  .nav { justify-content: space-between; }
  .modes, .learn { grid-template-columns: 1fr; }
  .panel { grid-template-columns: 1fr 1fr; gap: 12px 16px; padding: 12px; }
  .actions { grid-column: 1 / -1; }
  .actions .btn { flex: 1; }
  .actions kbd, .tool kbd { display: none; }
  .stage { margin: 0 10px; }
  .hud { padding: 8px 10px; gap: 8px; }
  .stat { min-width: 0; padding: 3px 8px; }
  .hud-title span { display: none; }
}
@media (orientation: portrait) and (max-width: 760px) {
  .view-labels { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .view-labels::after { left: 0; right: 0; top: 50%; bottom: auto; width: auto; height: 1px; }
}
