/* HUD + panel in-game. Semua angka dari tokens.css (§7). */

html, body { height: 100%; overflow: hidden; background: var(--bg-deep); }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: var(--z-world); }

/* ---------- loading ---------- */
#loading {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: radial-gradient(120% 90% at 50% 30%, #131826 0%, var(--bg-deep) 70%);
  display: grid; place-content: center; justify-items: center; gap: var(--s4);
  transition: opacity var(--t-slow) var(--ease), visibility var(--t-slow);
  padding: var(--s5);
}
#loading.gone { opacity: 0; visibility: hidden; pointer-events: none; }
#loading img { width: 108px; height: 108px; animation: spinNeedle 2.6s var(--ease) infinite; }
@keyframes spinNeedle { 0%,70%,100% { transform: rotate(0); } 82% { transform: rotate(9deg); } }
.load__title { font-family: var(--font-display); font-size: 40px; letter-spacing: .02em; }
.load__bar { width: min(320px, 70vw); height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; }
.load__fill { height: 100%; width: 0; background: var(--acid); transition: width var(--t-med) var(--ease); }
.load__msg { color: var(--muted); font-size: 13px; letter-spacing: .04em; }

/* ---------- HUD ---------- */
#hudRoot { position: fixed; inset: 0; z-index: var(--z-hud); pointer-events: none;
  transition: opacity var(--t-med) var(--ease); }
.hud { position: absolute; inset: 0; --accent: var(--acid); }
/* Scrim: angka HUD harus terbaca di atas gedung terang mana pun, bukan
   bergantung pada kebetulan latar belakangnya gelap. */
.hud__tl { position: absolute; top: var(--s4); left: var(--s4); display: grid; gap: var(--s3);
  padding: var(--s3) var(--s5) var(--s4) var(--s3); border-radius: var(--r3);
  background: radial-gradient(120% 130% at 0% 0%, rgba(6,7,10,.86) 0%, rgba(6,7,10,.62) 52%, transparent 100%); }
.hud__tc { text-shadow: 0 2px 10px rgba(0,0,0,.9); }
.hud__tc { position: absolute; top: var(--s4); left: 50%; transform: translateX(-50%); text-align: center; }
.hud__tr { position: absolute; top: var(--s4); right: var(--s4); display: grid; gap: var(--s2); justify-items: end; }
.hud__br { position: absolute; bottom: var(--s4); right: var(--s4); display: grid; justify-items: center; }
.hud__bl { position: absolute; bottom: var(--s4); left: var(--s4); }

.streak { display: grid; gap: var(--s1); }
.streak__mult { font-family: var(--font-display); font-size: 54px; line-height: .85; color: var(--paper);
  text-shadow: 0 2px 0 rgba(0,0,0,.6); transition: color var(--t-fast) var(--ease); }
.streak__mult i { font-size: 26px; font-style: normal; color: var(--muted); margin-left: 2px; }
.streak.is-hot .streak__mult { color: var(--acid); text-shadow: 0 0 22px rgba(199,255,61,.5); }
.streak__bar { width: 128px; height: 4px; background: rgba(237,239,234,.16); border-radius: 99px; overflow: hidden; }
.streak__fill { height: 100%; width: 0; background: var(--acid); }

.money { display: grid; gap: 2px; }
.money__row { display: flex; align-items: baseline; gap: var(--s2); }
.money__label { font-size: 10px; letter-spacing: .18em; color: var(--muted); width: 76px; }
.money__val { font-family: var(--font-display); font-size: 22px; color: var(--paper); }
.money__row--un .money__val { color: var(--acid); }

.district { font-family: var(--font-display); font-size: 22px; letter-spacing: .1em;
  color: var(--paper); opacity: .92; text-shadow: 0 2px 8px rgba(0,0,0,.7); }
.district__tag { font-size: 11px; letter-spacing: .16em; color: var(--muted); }

.gatecue {
  margin-top: var(--s3); display: inline-flex; align-items: center; gap: var(--s2);
  background: rgba(8,9,11,.72); border: 1px solid var(--line); border-radius: 99px;
  padding: 5px var(--s3); backdrop-filter: blur(6px);
}
.gatecue__arrow { color: var(--acid); font-size: 13px; line-height: 1; display: inline-block; }
.gatecue__txt { font-size: 10px; letter-spacing: .16em; color: var(--muted); }
.gatecue__txt b { color: var(--paper); font-family: var(--font-display); letter-spacing: .04em; margin-left: 4px; }
.gatecue.is-close { border-color: var(--acid); box-shadow: var(--glow); }
.gatecue.is-close .gatecue__txt b { color: var(--acid); }

.track, .ghostbar {
  display: flex; align-items: center; gap: var(--s2);
  background: rgba(8,9,11,.62); border: 1px solid var(--line);
  border-radius: var(--r2); padding: var(--s2) var(--s3); min-width: 190px;
  backdrop-filter: blur(6px);
}
.ghostbar { font-size: 10px; letter-spacing: .16em; color: #dff6ff; }
.track__name { font-family: var(--font-display); font-size: 13px; letter-spacing: .06em; margin-bottom: 4px; }
.track__bar { display: block; width: 100%; min-width: 120px; height: 3px; background: rgba(237,239,234,.14); border-radius: 99px; overflow: hidden; }
.track__fill { display: block; height: 100%; width: 0; background: var(--acid); transition: width var(--t-med) var(--ease); }
.track__fill--ghost { background: #dff6ff; }

.speedo { width: 168px; height: 168px; display: block; filter: drop-shadow(0 4px 14px rgba(0,0,0,.55)); }
.speedo__digits { margin-top: -104px; margin-bottom: 44px; text-align: center; pointer-events: none; }
.speedo__digits span { font-family: var(--font-display); font-size: 40px; line-height: 1; display: block; }
.speedo__digits small { font-size: 9px; letter-spacing: .22em; color: var(--muted); display: block; margin-top: 2px; }
.speedo__digits .gear { font-size: 15px; color: var(--acid); margin-top: var(--s2); }

.meters { display: grid; gap: var(--s2); width: 168px; }
.meter { display: flex; align-items: center; gap: var(--s2); }
.meter__bar { flex: 1; height: 6px; background: rgba(237,239,234,.14); border-radius: 99px; overflow: hidden; }
.meter__fill { height: 100%; width: 0; transition: width .1s linear; }
.meter__fill--nitro { background: linear-gradient(90deg, #2ff0ff, #8ce6ff); }
.meter__fill--rewind { background: var(--acid); }
.meter__note { font-size: 9px; letter-spacing: .12em; color: var(--acid); width: 42px; text-align: right; }
.meter.is-locked .meter__note { color: var(--muted); }

.minimap { width: 132px; height: 132px; display: block; opacity: .92; }

.drifttag {
  position: absolute; left: 50%; top: 40%; transform: translateX(-50%);
  font-family: var(--font-display); font-size: 32px; letter-spacing: .3em;
  color: var(--acid); text-shadow: 0 0 26px rgba(199,255,61,.6);
  animation: driftPulse .6s var(--ease) infinite alternate;
}
@keyframes driftPulse { from { opacity: .55; } to { opacity: 1; } }

.mods { position: absolute; bottom: var(--s4); left: 50%; transform: translateX(-50%);
  display: flex; gap: var(--s2); }
.chip { font-size: 9px; letter-spacing: .14em; color: var(--muted);
  border: 1px solid var(--line); border-radius: 99px; padding: 4px var(--s3);
  background: rgba(8,9,11,.55); }
.chip b { color: var(--paper); font-weight: 500; }

/* ---------- tutorial ---------- */
.tut {
  position: absolute; left: 50%; bottom: 13%; transform: translateX(-50%) translateY(14px);
  z-index: var(--z-panel); pointer-events: none; opacity: 0;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
  width: min(460px, calc(100vw - var(--s6)));
}
.tut.in { opacity: 1; transform: translateX(-50%) translateY(0); }
.tut__card {
  background: rgba(8,9,11,.92); border: 1px solid var(--line); border-left: 3px solid var(--acid);
  border-radius: var(--r3); padding: var(--s4) var(--s5); display: grid; gap: 5px;
  backdrop-filter: blur(10px); box-shadow: var(--sh2); text-align: left; pointer-events: auto;
}
.tut__step { font-size: 9px; letter-spacing: .2em; color: var(--muted); }
.tut__title { font-family: var(--font-display); font-size: 21px; letter-spacing: .05em; color: var(--acid); }
.tut__body { font-size: 13px; color: var(--paper); line-height: 1.5; }
.tut__hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.tut__skip {
  justify-self: start; margin-top: var(--s2); background: none; border: 0;
  color: var(--muted); font-family: var(--font-body); font-size: 11px;
  letter-spacing: .08em; text-decoration: underline; cursor: pointer; padding: 6px 0;
}
.tut__skip:hover { color: var(--paper); }
@media (max-width: 760px) { .tut { bottom: 30%; } }

/* ---------- panel ---------- */
#panelRoot { position: fixed; inset: 0; z-index: var(--z-panel); pointer-events: none; }
#panelRoot > * { pointer-events: auto; }
.scrim { position: fixed; inset: 0; background: rgba(4,5,7,.82); backdrop-filter: blur(8px); z-index: -1; }

.panel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -48%);
  width: min(560px, calc(100vw - var(--s5) * 2));
  max-height: calc(100dvh - var(--s6));
  overflow: auto; overscroll-behavior: contain;
  background: linear-gradient(180deg, var(--bg-panel), #0b0d11);
  border: 1px solid var(--line); border-radius: var(--r4);
  box-shadow: var(--sh3);
  padding: var(--s6);
  opacity: 0; transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
  display: grid; gap: var(--s4); justify-items: center; text-align: center;
}
.panel.in { opacity: 1; transform: translate(-50%, -50%); }
.panel--wide { width: min(1020px, calc(100vw - var(--s5) * 2)); justify-items: stretch; text-align: left; }
.panel--map { width: min(880px, calc(100vw - var(--s5) * 2)); justify-items: center; }

.panel__head { display: flex; align-items: center; gap: var(--s4); width: 100%; }
.panel__head h2 { font-size: 34px; }
.panel__sub { color: var(--muted); font-size: 12px; letter-spacing: .1em; margin-right: auto; }
.panel__sub b { color: var(--acid); }
.panel__title { font-size: 40px; }
.panel__note { color: var(--muted); font-size: 13px; }
.panel__foot { display: flex; justify-content: flex-end; width: 100%; }
.btn--sq { padding: 0; width: 44px; min-width: 44px; }

.menu__logo { image-rendering: auto; }
.menu__title { font-size: clamp(56px, 12vw, 104px); letter-spacing: -.01em; }
.menu__tag { color: var(--muted); font-size: 14px; max-width: 38ch; margin: 0; }
.menu__stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3); width: 100%;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: var(--s3) 0; }
.menu__stats div { display: grid; gap: 2px; }
.menu__stats b { font-family: var(--font-display); font-size: 22px; color: var(--paper); }
.menu__stats span { font-size: 9px; letter-spacing: .14em; color: var(--muted); }
.menu__actions { display: flex; flex-wrap: wrap; gap: var(--s3); justify-content: center; }
.menu__foot { display: flex; align-items: center; gap: var(--s3); }
.menu__hint { font-size: 11px; letter-spacing: .1em; color: var(--muted); }
.menu__link { text-decoration: none; }
.menu__link:hover { color: var(--acid); }

.garage { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s5); }
.garage__col { min-width: 0; }
.col__title { font-size: 18px; letter-spacing: .12em; margin-bottom: var(--s2); }
.col__title small { color: var(--muted); font-size: 11px; font-family: var(--font-body); margin-left: var(--s2); }
.col__note { color: var(--muted); font-size: 11px; margin: 0 0 var(--s3); }
.cards { display: grid; gap: var(--s2); max-height: 46dvh; overflow: auto; padding-right: var(--s1); }
.cards--contracts { max-height: 62dvh; }

.card {
  display: flex; align-items: flex-start; gap: var(--s3);
  background: var(--bg-raise); border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: var(--r2); padding: var(--s3); text-align: left; width: 100%;
  color: var(--paper); font-family: var(--font-body); cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.card:hover { border-color: var(--muted); border-left-color: var(--acid); transform: translateX(2px); }
.card:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }
.card.is-on { border-left-color: var(--acid); background: #141a12; }
.card.is-locked { opacity: .45; cursor: not-allowed; }
.card.is-locked:hover { transform: none; border-left-color: var(--line); }
.card.is-done { opacity: .6; }
.card__body { display: grid; gap: 4px; flex: 1; min-width: 0; }
.card__body b { font-family: var(--font-display); font-size: 15px; letter-spacing: .05em; }
.card__body i { font-style: normal; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.card__body i.up { color: #b8d98f; }
.card__body i.down { color: #d99a8f; }
.card__body i.hint { color: #8a7f5f; font-style: italic; }
.card__swatch { width: 22px; height: 40px; border-radius: var(--r1); background: var(--c); flex: none; }
.card__stats { display: flex; gap: var(--s3); flex-wrap: wrap; }
.card__stats em { font-style: normal; font-size: 9.5px; letter-spacing: .1em; color: var(--muted); }
.card__stats .reward { color: var(--acid); margin-left: auto; }
.card__flag { font-size: 9px; letter-spacing: .14em; color: var(--acid); align-self: center; flex: none; }
.card__lock { font-size: 9.5px; letter-spacing: .08em; color: var(--muted); align-self: center; flex: none; text-align: right; }
.card--contract { cursor: default; align-items: center; }
.card--contract:hover { transform: none; border-left-color: var(--line); }
.card--contract .btn { flex: none; font-size: 12px; min-height: 40px; padding: 0 var(--s4); }

#mapCanvas { width: min(760px, 100%); height: auto; aspect-ratio: 1; border-radius: var(--r3);
  border: 1px solid var(--line); background: #0a0c10; }
.map__legend { display: flex; gap: var(--s4); flex-wrap: wrap; justify-content: center; }
.legend { display: grid; gap: 2px; text-align: center; opacity: .5; }
.legend.is-on { opacity: 1; }
.legend b { font-family: var(--font-display); font-size: 13px; letter-spacing: .08em; }
.legend i { font-style: normal; font-size: 10px; color: var(--muted); }

/* ---------- how to play ---------- */
.howto__lead { color: var(--paper); font-size: 14px; line-height: 1.6; margin: 0; max-width: 62ch; }
.howto__lead b { color: var(--paper); }
.howto__lead b.acid { color: var(--acid); }
.howto__lead i { color: var(--muted); }
.howto { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.howto li { display: flex; gap: var(--s4); align-items: baseline; }
.howto__n { font-family: var(--font-display); font-size: 26px; color: transparent;
  -webkit-text-stroke: 1.5px rgba(199,255,61,.45); flex: none; min-width: 1.6em; }
.howto li b { font-family: var(--font-display); font-size: 15px; letter-spacing: .05em; display: block; margin-bottom: 3px; }
.howto li i { font-style: normal; font-size: 13px; color: var(--muted); line-height: 1.5; display: block; }
.howto li i.hint { color: #8a8f6f; margin-top: 2px; }
.howto__keys { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4);
  border-top: 1px solid var(--line); padding-top: var(--s4); }
.howto__keys h4 { font-family: var(--font-display); font-size: 12px; letter-spacing: .18em; margin: 0 0 var(--s2); color: var(--muted); }
.howto__keys p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.9; }
.howto__keys kbd { display: inline-block; background: var(--bg-raise); color: var(--paper);
  border: 1px solid var(--line); border-radius: 4px; padding: 2px 7px; font-size: 11px;
  font-family: var(--font-body); margin-right: 3px; }
@media (max-width: 760px) { .howto__keys { grid-template-columns: 1fr; } }

/* ---------- toast ---------- */
.toasts { position: fixed; top: var(--s7); left: 50%; transform: translateX(-50%);
  z-index: var(--z-toast); display: grid; gap: var(--s2); justify-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast {
  background: rgba(8,9,11,.9); border: 1px solid var(--line); border-left: 3px solid var(--acid);
  border-radius: var(--r2); padding: var(--s2) var(--s4); display: grid; gap: 2px; text-align: center;
  opacity: 0; transform: translateY(-10px);
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
  backdrop-filter: blur(8px);
}
.toast.in { opacity: 1; transform: none; }
.toast__text { font-family: var(--font-display); font-size: 15px; letter-spacing: .08em; }
.toast__sub { font-size: 11px; color: var(--muted); }
.toast--crash { border-left-color: var(--redline); }
.toast--crash .toast__text { color: var(--redline); }
.toast--reward .toast__text { color: var(--acid); }
.toast--secret { border-left-color: #ffd08a; }
.toast--secret .toast__text { color: #ffd08a; }
.toast--warn { border-left-color: #d9a441; }
.toast--district { border-left-color: var(--paper); }

/* ---------- kontrol sentuh ---------- */
#touch { position: fixed; inset: 0; z-index: var(--z-hud); pointer-events: none; }
#touch button {
  position: absolute; pointer-events: auto; border: 1px solid rgba(237,239,234,.22);
  background: rgba(8,9,11,.42); color: var(--paper); border-radius: 50%;
  width: 68px; height: 68px; font-family: var(--font-display); font-size: 12px;
  letter-spacing: .06em; backdrop-filter: blur(4px); touch-action: none; user-select: none;
}
#touch button:active { background: rgba(199,255,61,.22); border-color: var(--acid); }
#tLeft { left: 16px; bottom: 108px; }
#tRight { left: 96px; bottom: 108px; }
#tGas { right: 16px; bottom: 168px; width: 84px; height: 84px; }
#tBrake { right: 112px; bottom: 108px; }
#tDrift { right: 16px; bottom: 72px; width: 60px; height: 60px; }
#tNitro { right: 112px; bottom: 200px; width: 60px; height: 60px; }
#tRewind { left: 16px; bottom: 190px; width: 52px; height: 52px; font-size: 10px; }
#tMap { left: 16px; top: 16px; width: 48px; height: 48px; font-size: 10px; }
#tPause { right: 16px; top: 16px; width: 48px; height: 48px; font-size: 10px; }

/* ---------- responsif ---------- */
@media (max-width: 860px) {
  .garage { grid-template-columns: 1fr; }
  .menu__stats { grid-template-columns: repeat(2, 1fr); }
  .panel { padding: var(--s5); }
  .speedo { width: 132px; height: 132px; }
  .speedo__digits { margin-top: -84px; margin-bottom: 36px; }
  .speedo__digits span { font-size: 30px; }
  .meters { width: 132px; }
  .minimap { width: 104px; height: 104px; }
  .streak__mult { font-size: 40px; }
  .hud__tc { top: 60px; }
  .mods { display: none; }
}
@media (max-width: 420px) {
  .panel__head h2 { font-size: 24px; }
  .menu__title { font-size: 52px; }
  .hud__bl { bottom: 92px; }
}
