*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden;background:#1b1830;font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:#fff;user-select:none;-webkit-user-select:none;touch-action:none}
canvas#cv{position:fixed;inset:0;width:100%;height:100%;display:block}
.hidden{display:none!important}
button{font:inherit;color:inherit;cursor:pointer;touch-action:manipulation}

#btns{position:fixed;top:8px;right:8px;display:flex;gap:6px;z-index:40}
.ib{width:38px;height:38px;border-radius:10px;border:3px solid #15131f;background:#ffd23d;color:#15131f;display:grid;place-items:center;padding:6px;box-shadow:3px 3px 0 #15131f}
.ib svg{width:100%;height:100%}
.ib:active{transform:translate(2px,2px);box-shadow:1px 1px 0 #15131f}

#tip{position:fixed;left:50%;bottom:8px;transform:translateX(-50%);background:rgba(21,19,31,.85);color:#fff;font-weight:800;font-size:13px;padding:6px 14px;border-radius:999px;white-space:nowrap;max-width:calc(100% - 16px);overflow:hidden;text-overflow:ellipsis;z-index:10;pointer-events:none;border:2px solid #ffd23d}
#tip b{color:#ffd23d}
body.touch #tip{bottom:104px;font-size:11px;white-space:normal;text-align:center;width:max-content}
@media (max-height:420px){body.touch #tip{bottom:auto;top:8px;max-width:calc(100% - 420px);white-space:nowrap}}

#touch{position:fixed;left:0;right:0;bottom:0;display:flex;justify-content:space-between;align-items:flex-end;padding:10px;padding-bottom:max(10px,env(safe-area-inset-bottom));pointer-events:none;z-index:15}
#touch .tl,#touch .tr{display:flex;gap:10px;align-items:flex-end;pointer-events:auto}
.tb{width:76px;height:76px;border-radius:20px;border:3px solid #15131f;background:rgba(255,255,255,.9);color:#15131f;font-weight:900;font-size:28px;box-shadow:3px 4px 0 #15131f;touch-action:none;padding:0}
.tb.small{width:66px;height:58px;font-size:12px}
.tb.nit{background:#3de0ff}.tb.dr{background:#ffd23d}
.tb.brake{font-size:12px;background:#ff8a7a;height:84px}
.tb.on{transform:translate(2px,3px);box-shadow:1px 1px 0 #15131f;filter:brightness(.9)}
@media (max-height:420px){.tb{width:62px;height:62px;font-size:22px}.tb.brake{height:66px}.tb.small{width:56px;height:48px;font-size:11px}}
@media (max-width:420px){.tb{width:64px;height:68px}.tb.small{width:56px;height:52px;font-size:10.5px}#touch .tr{gap:6px}.tb.brake{height:74px;font-size:11px}}

.overlay{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;z-index:30;background:rgba(15,12,30,.55)}
.panel{background:#2a2550;border:4px solid #15131f;border-radius:20px;box-shadow:7px 8px 0 #15131f;padding:14px 16px 12px;width:820px;transform-origin:center center;flex:none;position:relative;
  background-image:repeating-linear-gradient(115deg,rgba(255,255,255,.035) 0 14px,transparent 14px 28px)}
.panel.small{width:440px;text-align:center}
.head{display:flex;align-items:center;gap:16px}
.logo{display:flex;flex-direction:column;line-height:.9;flex:none;transform:skewX(-8deg)}
.logo .k{font-size:44px;font-weight:900;color:#ffd23d;letter-spacing:1px;text-shadow:3px 3px 0 #ff3d7f,6px 6px 0 #15131f}
.logo .s{font-size:12px;font-weight:900;letter-spacing:4px;color:#3de0ff;margin-top:6px}
.intro{margin:0;font-size:14px;line-height:1.35;font-weight:600;color:#dcd8f5}
.cols{display:grid;grid-template-columns:1fr 1fr;gap:12px;margin-top:12px}
.box{background:#1e1a3d;border:3px solid #15131f;border-radius:14px;padding:8px 10px}
.bh{display:flex;justify-content:space-between;align-items:center;font-weight:900;font-size:14px;color:#ffd23d;text-transform:uppercase;letter-spacing:1px}
.medals{display:flex;gap:6px;font-size:11px;letter-spacing:0;text-transform:none;color:#cfc9f0}
.md{display:inline-flex;align-items:center;gap:3px}
.md i{width:13px;height:13px;border-radius:50%;border:2px solid #15131f;display:inline-block}
.stars{font-size:13px;color:#fff;letter-spacing:0}.st{color:#ffd23d;font-style:normal}
.pick{display:flex;align-items:center;gap:6px;margin-top:6px}
.pv{flex:1;display:flex;align-items:center;gap:10px;min-width:0}
.pv canvas{width:120px;height:72px;flex:none;border-radius:10px;background:#2e2a58;border:2px solid #15131f}
.pv.car canvas{width:104px;height:72px}
.pvt{display:flex;flex-direction:column;gap:3px;min-width:0}
.pvt b{font-size:16px;white-space:nowrap}
.pvt span{font-size:12px;color:#cfc9f0;font-weight:600}
#carStats{display:grid;grid-template-columns:auto 1fr;gap:1px 6px;font-size:10.5px;font-weight:700;color:#cfc9f0;align-items:center}
.bar{height:6px;border-radius:3px;background:#3a3566;overflow:hidden;width:70px}.bar i{display:block;height:100%;background:#3de0ff}
.lock{color:#ff8a7a;font-size:12px;font-weight:800}
.ar{width:34px;height:52px;border:3px solid #15131f;border-radius:10px;background:#ffd23d;color:#15131f;font-size:14px;flex:none;box-shadow:2px 3px 0 #15131f}
.ar:active{transform:translate(1px,2px);box-shadow:1px 1px 0 #15131f}
.rowsel{display:flex;gap:12px;margin-top:10px;justify-content:space-between}
.seg{display:flex;background:#1e1a3d;border:3px solid #15131f;border-radius:12px;overflow:hidden;flex:none}
#segMode{flex:1}
#segMode button{flex:1}
.seg button{border:0;background:transparent;font-size:13px;font-weight:800;padding:7px 10px;color:#dcd8f5;white-space:nowrap}
.seg button+button{border-left:2px solid #15131f}
.seg button.on{background:#3de0ff;color:#15131f}
#segDiff button.on{background:#ff3d7f;color:#fff}
.playrow{display:flex;align-items:center;gap:12px;margin-top:10px}
.keys,.tkeys{margin:0;flex:1;font-size:12px;font-weight:700;color:#cfc9f0;line-height:1.7}
.tkeys{display:none}
body.touch .keys{display:none}body.touch .tkeys{display:block}
.kb{display:inline-block;min-width:20px;padding:0 5px;border:2px solid #15131f;border-bottom-width:3px;border-radius:6px;background:#fff;color:#15131f;font-weight:900;font-size:11px;text-align:center;line-height:16px}
.play{border:4px solid #15131f;border-radius:16px;background:#ff3d7f;color:#fff;font-weight:900;font-size:24px;padding:10px 26px;box-shadow:4px 5px 0 #15131f;flex:none;letter-spacing:.5px}
.play:active,.btn:active{transform:translate(2px,3px);box-shadow:1px 1px 0 #15131f}
.msg{margin:4px 0 0;min-height:16px;font-size:13px;font-weight:800;color:#ffd23d;text-align:center}
.panel h2{margin:2px 0 6px;font-size:34px;font-weight:900;color:#ffd23d;text-shadow:3px 3px 0 #ff3d7f,5px 5px 0 #15131f;transform:skewX(-6deg)}
.row{display:flex;gap:10px;justify-content:center;margin-top:8px}
.btn{border:3px solid #15131f;border-radius:12px;background:#ff3d7f;color:#fff;font-weight:900;font-size:17px;padding:9px 16px;box-shadow:3px 4px 0 #15131f}
.btn.ghost{background:#3a3566}.btn.alt{background:#2ec4b6;color:#15131f}
#endMedal{display:flex;justify-content:center;gap:10px;align-items:center;font-weight:900;font-size:17px;min-height:8px}
.medal{width:34px;height:34px;border-radius:50%;border:3px solid #15131f;display:grid;place-items:center;color:#15131f;font-size:15px;box-shadow:2px 2px 0 #15131f}
#endList{display:flex;flex-direction:column;gap:3px;margin:6px auto;max-width:360px}
.rr{display:flex;align-items:center;gap:8px;background:#1e1a3d;border:2px solid #15131f;border-radius:9px;padding:3px 10px;font-weight:700;font-size:14px}
.rr.me{background:#ffd23d;color:#15131f}
.rr span{width:28px;text-align:left;font-weight:900}
.rr em{margin-left:auto;font-style:normal;font-variant-numeric:tabular-nums}
.rr i{width:14px;height:14px;border-radius:4px;border:2px solid #15131f;flex:none}
#endStats{margin:4px 0 0;font-size:13px;font-weight:700;color:#cfc9f0}

/* portrait phones: stacked layout */
body.portrait .panel{width:380px;padding:12px}
body.portrait .head{flex-direction:column;gap:8px;text-align:center}
body.portrait .cols{grid-template-columns:1fr;gap:8px}
body.portrait .rowsel{flex-direction:column;gap:8px}
body.portrait #segDiff{align-self:stretch}body.portrait #segDiff button{flex:1}
body.portrait .playrow{flex-direction:column}
body.portrait .seg button{font-size:12px;padding:8px 6px}
body.portrait .panel.small{width:360px}
body.portrait .btn{font-size:15px;padding:9px 11px;white-space:nowrap}
