:root {
  --bg: #07090c; --panel: #0e1217; --panel2: #141a21; --line: #222b35; --line2: #2f3a47;
  --text: #e6edf3; --muted: #7f8c99; --accent: #ff4a2a; --accent2: #ffae2a; --ok: #3aff8a; --info: #3aa0ff; --bad: #ff3b30;
  --f-head: 'Orbitron', system-ui, sans-serif; --f-ui: 'Rajdhani', system-ui, sans-serif; --f-mono: 'Share Tech Mono', ui-monospace, monospace;
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--f-ui); overflow: hidden; overscroll-behavior: none; }
button { font-family: inherit; color: inherit; cursor: pointer; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; padding-left: var(--safe-l); padding-right: var(--safe-r); user-select: none; -webkit-user-select: none; touch-action: none; }

/* ---------- top bar */
#topbar { flex: 0 0 auto; height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 8px; background: linear-gradient(#11161c, #0a0d11); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 6px; font-family: var(--f-head); font-size: 14px; letter-spacing: 1px; color: var(--accent); white-space: nowrap; }
.brand span { color: var(--text); } .brand b { color: var(--accent); }
#modes { display: flex; gap: 2px; background: #05070a; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
#modes button { white-space: nowrap; border: 0; background: transparent; padding: 6px 10px; border-radius: 6px; font-weight: 700; font-size: 14px; color: var(--muted); }
#modes button.on { background: var(--accent); color: #fff; }
#preset { min-width: 0; flex: 1 1 140px; max-width: 260px; background: #05070a; color: var(--text); border: 1px solid var(--line2); border-radius: 8px; padding: 6px 8px; font-family: var(--f-ui); font-weight: 600; font-size: 14px; }
.tb-actions { margin-left: auto; display: flex; gap: 4px; }
.ib { border: 1px solid var(--line); background: #0b0f14; border-radius: 8px; height: 32px; min-width: 34px; padding: 0 8px; font-size: 15px; display: flex; align-items: center; gap: 5px; }
.ib span { font-size: 13px; font-weight: 700; }
.ib:active, .ib.on { border-color: var(--accent); color: var(--accent); }

/* ---------- stage */
#stage { position: relative; flex: 1 1 auto; min-height: 120px; overflow: hidden; background: #1d2a17; }
#track { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#hud { position: absolute; top: 8px; left: 8px; min-width: 170px; max-width: 46%; background: rgba(5,7,10,0.72); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 8px 10px; backdrop-filter: blur(4px); font-size: 13px; pointer-events: none; overflow: hidden; }
.hud-title { font-family: var(--f-head); font-size: 10px; letter-spacing: 1px; color: var(--accent2); margin-bottom: 4px; }
.hud-big { font-family: var(--f-head); font-size: 26px; font-weight: 700; line-height: 1.1; }
.hud-big small { font-size: 12px; color: var(--muted); margin-left: 3px; }
.hud-row { display: flex; gap: 8px; justify-content: space-between; font-family: var(--f-mono); font-size: 12.5px; line-height: 1.45; }
.hud-row span { color: var(--muted); } .hud-row i { color: #9fb4c8; font-style: normal; }
.hud-row b { font-weight: 400; } .bad { color: var(--bad) !important; }
.hud-hint { color: #b8c4cf; font-size: 13px; line-height: 1.3; }
.hud-best { margin-top: 4px; color: var(--ok); font-family: var(--f-mono); font-size: 12px; }
.hud-rec { color: var(--bad); font-family: var(--f-mono); font-size: 12px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
#quick { position: absolute; top: 8px; right: 8px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 52%; }
#quick button { border: 1px solid rgba(255,255,255,0.12); background: rgba(5,7,10,0.7); border-radius: 6px; padding: 4px 8px; font-weight: 700; font-size: 12px; color: var(--muted); }
#quick button.on { color: #111; background: var(--ok); border-color: var(--ok); }
#stage-actions { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; max-width: 52%; }
#stage-actions button, .btn { border: 1px solid var(--line2); background: rgba(10,13,18,0.85); border-radius: 8px; padding: 7px 12px; font-weight: 700; font-size: 14px; }
#stage-actions button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
#stage-actions label { background: rgba(10,13,18,0.85); border: 1px solid var(--line2); border-radius: 8px; padding: 4px 8px; font-size: 13px; display: flex; gap: 6px; align-items: center; }
#stage-actions input[type=range] { width: 110px; }
#toasts { position: absolute; left: 50%; top: 44px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: 90%; }
.toast { background: rgba(10,13,18,0.92); border: 1px solid var(--line2); border-left: 3px solid var(--info); padding: 7px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; animation: tin .25s ease-out; max-width: 100%; text-align: center; }
.toast.bad { border-left-color: var(--bad); } .toast.good { border-left-color: var(--ok); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- cockpit */
#cockpit { flex: 0 0 auto; height: min(44vh, 330px); display: grid; grid-template-columns: auto 1fr auto auto; grid-template-areas: "ped cluster shift gas"; gap: 8px; padding: 8px 8px calc(8px + var(--safe-b)); background: linear-gradient(#0b0e12, #040507); border-top: 1px solid var(--line); }
.pedals { grid-area: ped; display: flex; gap: 8px; }
.pedal { position: relative; width: clamp(54px, 8vw, 86px); height: 100%; border-radius: 12px; overflow: hidden; touch-action: none;
  background: repeating-linear-gradient(0deg, #1a2028 0 6px, #232b35 6px 12px); border: 1px solid #39434f; box-shadow: inset 0 -12px 24px rgba(0,0,0,0.6), 0 3px 0 #000; }
.pedal i { position: absolute; left: 0; right: 0; top: 0; height: 0%; background: linear-gradient(rgba(58,160,255,0.15), rgba(58,160,255,0.55)); border-bottom: 2px solid var(--info); }
.pedal.gas i { background: linear-gradient(rgba(58,255,138,0.12), rgba(58,255,138,0.5)); border-bottom-color: var(--ok); }
#p-brake i { background: linear-gradient(rgba(255,59,48,0.12), rgba(255,59,48,0.55)); border-bottom-color: var(--bad); }
.pedal span { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; font-weight: 700; font-size: 12px; letter-spacing: 1px; color: #aab6c2; pointer-events: none; }
.pedal.gas { grid-area: gas; width: clamp(64px, 9.5vw, 100px); }
.pedal.active { border-color: #fff; }
#cluster-wrap { grid-area: cluster; position: relative; min-width: 0; border-radius: 14px; overflow: hidden; border: 1px solid #1f2731; }
#cluster { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.shift-col { grid-area: shift; display: flex; flex-direction: column; gap: 6px; width: clamp(110px, 15vw, 170px); }
#btn-start { flex: 0 0 auto; height: 58px; border-radius: 50px; border: 2px solid #5a1410; background: radial-gradient(circle at 50% 35%, #e5372b, #7d0f0a); color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 0 0 3px #1a1f26, 0 4px 10px rgba(0,0,0,0.6); }
#btn-start b { font-family: var(--f-head); font-size: 10px; letter-spacing: 1px; }
#btn-start span { font-size: 11px; font-weight: 700; line-height: 1; text-align: left; }
#btn-start.running { background: radial-gradient(circle at 50% 35%, #31d86b, #0c6b30); border-color: #0a4d22; }
#btn-start.cranking { animation: blink .3s infinite; }
#shifter { flex: 1 1 auto; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto; gap: 6px; min-height: 0; }
.paddle { border: 1px solid #3b4652; background: linear-gradient(#232b35, #12171d); border-radius: 10px; font-size: 22px; color: #dfe6ee; touch-action: none; }
.paddle:active, .paddle.flash { background: var(--accent); }
#gears { grid-column: 1 / 3; display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
#gears button { border: 1px solid #2b343f; background: #0d1116; border-radius: 6px; padding: 5px 0; font-family: var(--f-head); font-size: 11px; color: var(--muted); }
#gears button.on { background: var(--accent2); color: #111; border-color: var(--accent2); }

/* ---------- panel */
#panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100%); background: rgba(9,12,16,0.97); border-left: 1px solid var(--line2); z-index: 20; display: flex; flex-direction: column; transition: transform .22s ease; box-shadow: -10px 0 30px rgba(0,0,0,0.5); padding-right: var(--safe-r); }
#panel.hidden { transform: translateX(105%); }
.p-head { display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.p-head h2 { margin: 0; font-family: var(--f-head); font-size: 15px; letter-spacing: 1px; flex: 1; }
#p-close { border: 1px solid var(--line2); background: transparent; border-radius: 8px; width: 34px; height: 34px; font-size: 16px; }
#p-tabs { display: flex; gap: 4px; padding: 8px 10px; overflow-x: auto; border-bottom: 1px solid var(--line); flex: 0 0 auto; scrollbar-width: none; }
#p-tabs button { flex: 0 0 auto; border: 1px solid var(--line); background: #0b0f14; border-radius: 8px; padding: 6px 10px; font-weight: 700; font-size: 13px; color: var(--muted); }
#p-tabs button.on { color: #fff; border-color: var(--accent); background: rgba(255,74,42,0.15); }
#p-body { flex: 1; overflow-y: auto; padding: 8px 12px 30px; touch-action: pan-y; user-select: text; -webkit-overflow-scrolling: touch; }
.grp { font-family: var(--f-head); font-size: 10.5px; letter-spacing: 1.5px; color: var(--accent2); margin: 14px 0 6px; text-transform: uppercase; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid #141a21; }
.row label { font-weight: 600; font-size: 14.5px; }
.row .val { font-family: var(--f-mono); font-size: 13px; color: var(--accent2); text-align: right; min-width: 70px; }
.row .desc { grid-column: 1 / 3; font-size: 12px; color: var(--muted); }
.row input[type=range] { grid-column: 1 / 3; width: 100%; accent-color: var(--accent); height: 26px; }
.row select { background: #05070a; color: var(--text); border: 1px solid var(--line2); border-radius: 6px; padding: 5px 6px; font-family: var(--f-ui); font-size: 14px; font-weight: 600; max-width: 230px; }
.row.dis { opacity: 0.35; pointer-events: none; }
.sw { position: relative; width: 44px; height: 24px; border-radius: 20px; background: #232b35; border: 1px solid var(--line2); transition: background .15s; }
.sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #aab6c2; transition: left .15s; }
.sw.on { background: var(--accent); } .sw.on::after { left: 22px; background: #fff; }
.bar { height: 8px; background: #161c23; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.pid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 6px; }
.pid div { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.pid span { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.pid b { font-family: var(--f-mono); font-weight: 400; font-size: 17px; }
.pid em { font-style: normal; font-size: 11px; color: var(--muted); margin-left: 3px; }
.dtc { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent2); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; }
.dtc b { font-family: var(--f-mono); color: var(--accent2); font-size: 16px; margin-right: 8px; }
.dtc small { display: block; color: var(--muted); font-family: var(--f-mono); margin-top: 3px; }
.cyl { display: grid; grid-template-columns: 52px 1fr 1fr 1fr; gap: 6px; align-items: center; padding: 5px 0; border-bottom: 1px solid #141a21; font-family: var(--f-mono); font-size: 13px; }
.cyl.h { color: var(--muted); font-family: var(--f-ui); font-weight: 700; font-size: 12px; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.res { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: 14px; }
.res .t { font-family: var(--f-head); font-size: 11px; color: var(--accent2); letter-spacing: 1px; }
.res .m { font-family: var(--f-mono); font-size: 12.5px; color: #b9c6d2; margin-top: 3px; line-height: 1.5; }
#chart { width: 100%; height: 260px; display: block; border-radius: 8px; border: 1px solid var(--line); }
.runs .res { display: flex; align-items: center; gap: 8px; }
.runs .dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.help h3 { font-family: var(--f-head); font-size: 12px; color: var(--accent2); letter-spacing: 1px; margin: 16px 0 6px; }
.help p, .help li { font-size: 14.5px; line-height: 1.45; color: #c9d3dc; }
.help kbd { font-family: var(--f-mono); background: #1a2029; border: 1px solid var(--line2); border-radius: 4px; padding: 0 5px; }
.mystery { background: rgba(255,174,42,0.08); border: 1px dashed var(--accent2); border-radius: 10px; padding: 10px; margin: 10px 0; }

/* ---------- splash */
#splash { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, #1a1f27, #040506); }
#splash.gone { display: none; }
.sp-in { text-align: center; padding: 20px; max-width: 520px; }
.sp-logo { font-family: var(--f-head); font-size: clamp(32px, 7vw, 56px); font-weight: 900; letter-spacing: 3px; }
.sp-logo b { color: var(--accent); }
.sp-in p { color: #aab6c2; font-size: 16px; }
#sp-go { margin: 14px 0; font-family: var(--f-head); font-size: 15px; letter-spacing: 2px; padding: 14px 28px; border-radius: 40px; border: 0; background: var(--accent); color: #fff; box-shadow: 0 0 30px rgba(255,74,42,0.4); }
#sp-go:disabled { opacity: 0.4; }
.sp-in small { display: block; color: var(--muted); margin-top: 6px; font-size: 13px; }

/* ---------- responsive */
@media (max-width: 1240px) { .ib span { display: none; } }
@media (max-width: 760px) { .brand span { display: none; } }
@media (max-height: 430px) and (orientation: landscape) {
  #topbar { height: 38px; }
  #modes button { padding: 4px 8px; font-size: 13px; }
  #cockpit { height: 48vh; padding-top: 6px; gap: 6px; }
  #btn-start { height: 44px; }
  #hud { font-size: 12px; padding: 6px 8px; } .hud-big { font-size: 20px; }
}
@media (orientation: portrait) {
  #topbar { flex-wrap: wrap; height: auto; padding: 6px 8px; row-gap: 6px; }
  #modes { order: 3; flex: 1 1 100%; } #modes button { flex: 1; }
  #preset { order: 2; flex: 1 1 100px; }
  .tb-actions { order: 1; margin-left: auto; }
  #cockpit { height: 52vh; grid-template-columns: auto 1fr auto; grid-template-rows: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-areas: "cluster cluster cluster" "ped shift gas"; }
  .shift-col { width: auto; }
  .pedal { width: clamp(52px, 15vw, 80px); }
  .pedal.gas { width: clamp(64px, 19vw, 96px); }
  #topbar { padding: 5px 8px; row-gap: 5px; }
  #preset { flex: 1 1 130px; max-width: none; }
  #modes { flex: 1 1 236px; } #modes button { padding: 5px 4px; }
  #cockpit { height: min(41vh, 460px); }
  /* overlay trek disusun bertumpuk -> tidak saling menimpa; trek terlihat di #view */
  #stage { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(56px, 1fr) auto auto auto; gap: 5px; padding: 6px 8px 8px; }
  #quick { grid-row: 1; position: relative; top: auto; right: auto; max-width: none; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  #quick::-webkit-scrollbar { display: none; }
  #quick button { flex: 0 0 auto; white-space: nowrap; }
  #hud { grid-row: 2; position: relative; top: auto; left: auto; min-width: 0; max-width: none; display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; padding: 6px 10px; }
  #hud > :not(.hud-row) { grid-column: 1 / -1; }
  #hud .hud-row { font-size: 12px; } #hud .hud-hint { font-size: 12px; } .hud-big { font-size: 20px; }
  #stage > #view { display: block; grid-row: 3; min-height: 0; }
  #stage > #elev { grid-row: 4; position: relative; right: auto; }
  #stage > #graph { grid-row: 5; position: relative; left: auto; bottom: auto; }
  #stage-actions { grid-row: 6; position: relative; right: auto; bottom: auto; max-width: none; justify-content: stretch; }
  #stage-actions > * { flex: 1 1 auto; }
  #stage-actions label { flex: 1 1 44%; justify-content: space-between; }
  #stage-actions input[type=range] { flex: 1 1 0; width: 0; min-width: 40px; }
  #stage-actions button, #stage-actions label { padding-top: 6px; padding-bottom: 6px; font-size: 13px; }
  #stage-actions label.sel { flex: 0 1 auto; } #stage-actions .lbl { display: none; }
  #hud .hud-hint.opt { display: none; }
  #hud, #quick button:not(.on), #stage-actions button:not(.primary), #stage-actions label { background-color: rgba(5,7,10,0.9); }
  #toasts { top: 36px; } #toasts > :nth-last-child(n+3) { display: none; }
}

/* ---------- grafik live, hotkey, garasi, status simpan */
#graph { position: absolute; left: 8px; bottom: 8px; pointer-events: none; }
#elev { position: absolute; right: 8px; pointer-events: none; }
#view { display: none; pointer-events: none; }
.save-dot { width: 9px; height: 9px; border-radius: 50%; background: #555; align-self: center; margin-left: 2px; flex: 0 0 auto; }
.save-dot.saved { background: var(--ok); } .save-dot.saving { background: var(--accent2); } .save-dot.error { background: var(--bad); }
.kslots { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.kslot { min-width: 54px; border: 1px solid var(--line2); background: #0b0f14; border-radius: 6px; padding: 5px 8px; font-family: var(--f-mono); font-size: 13px; color: var(--text); }
.kslot.empty { color: var(--muted); border-style: dashed; }
.kslot.cap { border-color: var(--accent); color: var(--accent); animation: blink .8s infinite; }
.wiz-prog { height: 4px; background: #161c23; border-radius: 3px; overflow: hidden; margin: 8px 0 12px; }
.wiz-prog i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.wiz { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.wiz-n { font-family: var(--f-head); font-size: 10px; color: var(--accent2); letter-spacing: 1px; }
.wiz-q { font-size: 20px; font-weight: 700; margin: 6px 0; }
.wiz-d { color: var(--muted); font-size: 13.5px; margin-bottom: 8px; }
.wiz-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 8px; }
.wiz-opt { text-align: left; border: 1px solid var(--line2); background: #0b0f14; border-radius: 10px; padding: 10px; font-size: 14px; }
.wiz-opt small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.wiz-opt.on, .wiz-car.on { border-color: var(--accent); background: rgba(255,74,42,0.14); }
.wiz-opts.look { grid-template-columns: repeat(5, 1fr); }
.wiz-car { border: 1px solid var(--line2); background: #0b0f14; border-radius: 8px; padding: 6px; }
.wiz-car img { width: 100%; height: 46px; object-fit: contain; transform: rotate(90deg); }
.wiz-text { width: 100%; background: #05070a; border: 1px solid var(--line2); border-radius: 8px; color: var(--text); font-family: var(--f-ui); font-size: 18px; padding: 10px; margin-top: 6px; user-select: text; }
.wiz-val { font-family: var(--f-head); font-size: 22px; color: var(--accent2); margin: 6px 0; }
.wiz input[type=range] { width: 100%; accent-color: var(--accent); height: 30px; }
.wiz-est { margin-top: 8px; border-left: 3px solid var(--ok); }
.res.cur { border-color: var(--accent); }
.btn:disabled { opacity: 0.4; }

.wiz-car.suv img { transform: scaleX(1.16); }
.wiz-car.suv::after { content: 'SUV'; position: absolute; right: 3px; bottom: 2px; font-size: 9px; font-family: var(--f-head); color: var(--accent2); }
.wiz-car { position: relative; }
/* ---------- kesehatan */
.hrow { grid-template-columns: 1fr auto auto; }
.hrow .bar { grid-column: 1 / 3; }
.hrow .btn.sm { grid-row: 1; grid-column: 3; padding: 2px 8px; min-height: 0; font-size: 13px; }
.hrow .desc { grid-column: 1 / 4; font-size: 11.5px; color: var(--muted); }
/* ---------- kunci kontrol saat tes */
body.locked .pedal, body.locked #shifter, body.locked #btn-start, body.locked #quick, body.locked #modes, body.locked #preset { opacity: 0.35; pointer-events: none; filter: grayscale(0.6); }
body.locked #cockpit { position: relative; }
body.locked #cockpit::after { content: '🔒 TES DYNO BERJALAN — KONTROL DIKUNCI'; position: absolute; left: 50%; top: 6px; transform: translateX(-50%); background: rgba(255,59,48,0.92); color: #fff; font-family: var(--f-head); font-size: 11px; letter-spacing: 1px; padding: 4px 12px; border-radius: 20px; pointer-events: none; z-index: 5; white-space: nowrap; }
.lockmsg { border-left: 3px solid var(--bad); }
/* ---------- template tes dyno */
.tcard .tc-head { display: flex; gap: 10px; align-items: flex-start; }
.tc-ico { font-size: 24px; line-height: 1; }
.tc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.tc-stats div { background: #0b0f14; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.tc-stats span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.tc-stats b { font-family: var(--f-head); font-size: 18px; }
.tc-stats em { display: block; font-style: normal; font-size: 11px; color: #9fb4c8; font-family: var(--f-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-chart { width: 100%; height: 150px; display: block; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.rank { display: grid; grid-template-columns: 34px 64px 1fr; gap: 2px 8px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 4px; }
.rank b { font-family: var(--f-head); color: var(--accent2); } .rank span { font-family: var(--f-head); font-size: 17px; }
.rank em { font-style: normal; font-family: var(--f-mono); font-size: 12.5px; } .rank i { grid-column: 2 / 4; font-style: normal; color: #9fb4c8; font-size: 13px; }
.rank small { grid-column: 2 / 4; color: var(--muted); font-size: 11px; }
.res.best { border-color: var(--accent2); }

/* ---------------------------------------------------------------- akun pemain (layar pembuka) */
#login { margin: 16px auto 0; max-width: 360px; text-align: left; background: rgba(14,18,23,0.92); border: 1px solid var(--line2); border-radius: 12px; padding: 14px 16px; }
#login .lg-t { font-family: var(--f-head); font-size: 12px; letter-spacing: 2px; color: var(--accent2); }
#login p { font-size: 14px; margin: 6px 0 10px; }
#login input { display: block; width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line2); background: #0a0d12; color: var(--text); font: 600 16px var(--f-ui); }
#login input:focus { outline: none; border-color: var(--accent); }
#login .lg-b { display: flex; gap: 8px; } #login .lg-b .btn { flex: 1; padding: 10px; font-family: var(--f-head); font-size: 12px; letter-spacing: 1px; }
#login small { display: block; margin-top: 8px; min-height: 16px; } #login small.bad { color: var(--bad); }
#login .lg-skip { display: block; margin: 10px auto 0; background: none; border: 0; color: var(--muted); text-decoration: underline; font: 500 13px var(--f-ui); cursor: pointer; }
#splash.login .sp-tip { display: none; }
@media (max-height: 560px) { #splash.login .sp-in p { display: none; } #splash.login .sp-logo { font-size: 26px; } #login { margin-top: 6px; } }
#splash { overflow-y: auto; }

/* ---------------------------------------------------------------- pemain */
.prow { cursor: pointer; } .prow:hover { border-color: var(--line2); background: #18202a; }
.pr-n { font-family: var(--f-head); font-size: 13px; letter-spacing: 0.5px; display: flex; align-items: center; gap: 7px; }
.pr-n em { font-style: normal; color: var(--muted); font-family: var(--f-ui); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3a4450; display: inline-block; flex: none; } .dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }

/* ---------------------------------------------------------------- arena */
#panel.wide { width: min(860px, 100%); }
.ar-pick { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; margin-top: 6px; }
.ar-slot { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.ar-slot .t { font-family: var(--f-head); font-size: 11px; letter-spacing: 1.5px; }
.ar-slot select { width: 100%; margin: 6px 0 4px; padding: 7px 8px; border-radius: 6px; border: 1px solid var(--line2); background: #0a0d12; color: var(--text); font: 600 14px var(--f-ui); }
.ar-slot .m { font-family: var(--f-mono); font-size: 11.5px; color: #9fb4c8; line-height: 1.4; }
.ar-swap { padding: 6px 8px !important; font-size: 16px !important; }
.ar-tracks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.ar-track { text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; color: var(--text); cursor: pointer; }
.ar-track b { display: block; font-size: 14px; } .ar-track small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; margin-top: 2px; }
.ar-track.on { border-color: var(--accent); background: rgba(255,74,42,0.12); }
.ar-go { display: block; width: 100%; margin: 12px 0 8px; padding: 12px !important; font-family: var(--f-head); letter-spacing: 2px; font-size: 14px !important; }
.ar-prog { position: relative; height: 30px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ar-prog i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); opacity: 0.5; transition: width .1s; }
.ar-prog span { position: relative; display: block; text-align: center; line-height: 30px; font-family: var(--f-mono); font-size: 12.5px; }
.ar-cv { display: block; width: 100%; height: 230px; border-radius: 8px; border: 1px solid var(--line); background: #0a0d12; }
.ar-ctl { margin: 6px 0; }
.ar-win { text-align: center; padding: 12px; margin: 6px 0; border-radius: 10px; border: 1px solid #ffd02b; background: radial-gradient(circle at 50% 0, rgba(255,208,43,0.18), transparent 70%), var(--panel2); }
.ar-win small { display: block; font-family: var(--f-head); font-size: 11px; letter-spacing: 2px; color: #ffd02b; }
.ar-win b { display: block; font-family: var(--f-head); font-size: 20px; margin: 4px 0; } .ar-win span { color: #aab6c2; font-size: 14px; }
.ar-win.draw { border-color: var(--bad); font-family: var(--f-head); color: var(--bad); }
.ar-tab { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 10px; table-layout: fixed; }
.ar-tab th { text-align: left; color: var(--muted); font-weight: 600; width: 92px; padding: 5px 4px; vertical-align: top; }
.ar-tab td { padding: 5px 6px; border-top: 1px solid var(--line); vertical-align: top; font-family: var(--f-mono); font-size: 12.5px; word-wrap: break-word; }
.ar-tab tr:first-child td { font-family: var(--f-ui); font-weight: 700; font-size: 14px; border-top: 0; }
.ar-tab td.w { background: rgba(255,208,43,0.07); } .ar-tab small { color: var(--muted); font-family: var(--f-ui); font-size: 12px; }
@media (max-width: 560px) {
  .ar-pick { grid-template-columns: 1fr; } .ar-swap { justify-self: center; transform: rotate(90deg); padding: 2px 8px !important; }
  .ar-cv { height: 200px; } .ar-tab th { width: 70px; }
}

/* ---------------------------------------------------------------- rem tangan (di bawah pedal rem) */
.brk-col { display: flex; flex-direction: column; gap: 6px; height: 100%; min-height: 0; }
.brk-col .pedal { flex: 1 1 auto; height: auto; min-height: 0; }
#btn-hb { flex: 0 0 auto; width: clamp(54px, 8vw, 86px); padding: 4px 2px; border-radius: 10px; border: 1px solid #39434f; background: #161c24; color: #aab6c2; display: flex; flex-direction: column; align-items: center; line-height: 1.05; box-shadow: 0 3px 0 #000; touch-action: manipulation; }
#btn-hb b { font-family: var(--f-head); font-size: 15px; width: 22px; height: 22px; line-height: 20px; border: 2px solid currentColor; border-radius: 50%; }
#btn-hb span { font-size: 9.5px; font-weight: 700; letter-spacing: 0.5px; margin-top: 2px; }
#btn-hb em { font-style: normal; font-family: var(--f-mono); font-size: 11px; }
#btn-hb.on { color: #ffae2a; border-color: #ffae2a; }
#btn-hb.lock { color: #fff; background: #b3261e; border-color: var(--bad); box-shadow: 0 0 14px rgba(255,59,48,0.45), 0 3px 0 #000; }
@media (orientation: portrait) { #btn-hb { width: clamp(52px, 15vw, 80px); } }

/* ---------------------------------------------------------------- topbar sempit (HP): ikon menyusut, tidak keluar layar */
.tb-actions { min-width: 0; }
@media (pointer: coarse) { .ib[data-panel="keys"] { display: none; } } /* HP tanpa keyboard */
@media (max-width: 900px) {
  .brand span { display: none; }
  .tb-actions { flex: 0 1 auto; overflow-x: auto; scrollbar-width: none; gap: 3px; }
  .tb-actions::-webkit-scrollbar { display: none; }
  .ib { flex: 0 1 34px; min-width: 26px; padding: 0 4px; justify-content: center; }
  #preset { min-width: 110px; }
  #modes button { padding: 4px 7px; }
}
@media (orientation: portrait) {
  .tb-actions { flex: 1 1 calc(100% - 44px); justify-content: space-between; overflow: visible; }
  .ib { flex: 1 1 0; min-width: 0; max-width: 44px; padding: 0; }
}
@media (orientation: portrait) and (max-height: 820px) {
  #btn-start { height: 42px; }
  #gears button { padding: 3px 0; }
  .paddle { min-height: 0; font-size: 18px; }
}

/* ---------------------------------------------------------------- arena live (balapan di layar utama) */
#arena-live { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: 6; background: #16210f; }
body.arena #cockpit { display: none; }
body.arena #hud, body.arena #quick, body.arena #graph, body.arena #elev { visibility: hidden; }
body.arena #stage-actions { position: absolute !important; z-index: 8; right: 8px; bottom: 50px; left: auto; max-width: calc(100% - 16px); grid-row: auto; justify-content: flex-end; }
body.arena #stage-actions > * { flex: 0 0 auto; }
body.arena #toasts { z-index: 9; }
@media (orientation: portrait) { body.arena #stage { display: block; } body.arena #stage-actions { left: 8px; justify-content: center; } }
