/* Squipy Drive: garage + zone driving. Animations use transform/opacity only (no animated filters). */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root { --bg: #07080d; --cream: #e8eef8; --purple: #a78bfa; --cyan: #3df0ff; --gold: #fbbf24; --red: #ff5a6a; }
html, body { height: 100%; background: var(--bg); color: var(--cream); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#app { height: 100%; display: flex; flex-direction: column; background: radial-gradient(ellipse 70% 45% at 50% -5%, rgba(124, 58, 237, .2), transparent 55%), var(--bg); }
.top-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: max(.4rem, env(safe-area-inset-top)) .85rem .3rem; flex-shrink: 0; }
.home-link { color: #7dd3fc; text-decoration: none; font-size: .78rem; font-weight: 650; letter-spacing: .06em; }
.logo { font-size: .95rem; font-weight: 800; letter-spacing: .08em; }
.logo span { color: var(--gold); text-shadow: 0 0 12px rgba(251, 191, 36, .45); }
.version { font-size: .62rem; letter-spacing: .1em; opacity: .5; color: #86efac; }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #05060a; touch-action: none; cursor: grab; }
#game:active { cursor: grabbing; }
[hidden] { display: none !important; }

/* HUD */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.hud-tl { position: absolute; top: .6rem; left: .7rem; display: grid; gap: .3rem; min-width: 11.5rem; padding: .55rem .7rem; border-radius: .7rem; background: rgba(8, 10, 18, .62); border: 1px solid rgba(167, 139, 250, .28); }
.hud-zone { font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #c4b5fd; }
.hud-line { display: flex; gap: .7rem; font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hud-line .scrap { color: var(--gold); }
.bar-row { display: flex; align-items: center; gap: .45rem; font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .9; }
.bar-row > span:first-child { width: 3.6rem; }
.bar { flex: 1; height: .45rem; border-radius: .3rem; background: rgba(255, 255, 255, .1); overflow: hidden; }
.bar i { display: block; height: 100%; transform-origin: left center; background: linear-gradient(90deg, #22d3ee, #a78bfa); transition: transform .15s linear; }
#bar-sq { background: linear-gradient(90deg, #86efac, #fbbf24); }
.hud-clock { font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: #fdba74; opacity: .85; }
.hud-obj { position: absolute; top: .6rem; left: 50%; transform: translateX(-50%); max-width: min(30rem, 58vw); text-align: center; font-size: .8rem; font-weight: 650; padding: .4rem .75rem; border-radius: 999px; background: rgba(8, 10, 18, .55); border: 1px solid rgba(255, 255, 255, .1); }
.hud-gate { position: absolute; top: 2.9rem; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 800; color: #c4b5fd; text-shadow: 0 1px 4px #000; }
#gate-arrow { display: inline-block; width: 1.3rem; height: 1.3rem; line-height: 1.3rem; text-align: center; color: var(--cyan); font-size: 1.1rem; }
.minimap { position: absolute; right: .7rem; top: 3.4rem; width: 150px; height: 150px; border-radius: 50%; opacity: .95; }
.hud-speed { position: absolute; right: 1rem; bottom: 1rem; text-align: right; text-shadow: 0 2px 10px rgba(0, 0, 0, .7); }
.hud-speed b { display: block; font-size: 2.6rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.hud-speed span { font-size: .7rem; letter-spacing: .14em; opacity: .7; }
.pause-btn { position: absolute; top: .6rem; right: .7rem; z-index: 8; width: 2.7rem; height: 2.4rem; display: flex; gap: .3rem; align-items: center; justify-content: center; border-radius: .6rem; border: 1.5px solid rgba(167, 139, 250, .6); background: rgba(10, 8, 24, .6); cursor: pointer; pointer-events: auto; }
.pause-btn span { width: .32rem; height: 1rem; border-radius: 2px; background: #c4b5fd; }
.prompt { position: absolute; left: 50%; bottom: 5.2rem; transform: translateX(-50%); z-index: 9; pointer-events: auto; padding: .55rem 1rem; border-radius: 999px; border: 1px solid rgba(61, 240, 255, .55); background: rgba(6, 14, 24, .78); color: #fff; font: inherit; font-size: .9rem; font-weight: 750; cursor: pointer; white-space: nowrap; box-shadow: 0 0 18px rgba(61, 240, 255, .18); }
.toasts { position: absolute; left: 50%; bottom: 8.6rem; transform: translateX(-50%); display: grid; gap: .3rem; justify-items: center; z-index: 9; pointer-events: none; width: min(26rem, 92vw); }
.toast { padding: .4rem .8rem; border-radius: .6rem; background: rgba(8, 10, 18, .8); border: 1px solid rgba(251, 191, 36, .35); font-size: .82rem; font-weight: 650; text-align: center; animation: tin .3s ease-out both; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.dmg { position: absolute; inset: 0; pointer-events: none; z-index: 4; opacity: 0; box-shadow: inset 0 0 110px 30px rgba(255, 40, 60, .75); }
.veil { position: absolute; inset: 0; z-index: 30; pointer-events: none; background: #f2f7ff; opacity: 0; }
.veil.soft { background: #05060a; }
kbd { display: inline-block; min-width: 1.3rem; padding: .05rem .32rem; border-radius: .3rem; border: 1px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .08); font: inherit; font-size: .75rem; font-weight: 800; text-align: center; }

/* touch controls */
.touch { position: absolute; inset: auto 0 0 0; height: 0; z-index: 8; }
.stick { position: absolute; left: max(1rem, env(safe-area-inset-left)); bottom: max(1rem, env(safe-area-inset-bottom)); width: 8.4rem; height: 8.4rem; border-radius: 50%; border: 2px solid rgba(167, 139, 250, .45); background: rgba(10, 8, 24, .35); touch-action: none; }
.knob { position: absolute; left: 50%; top: 50%; width: 3.4rem; height: 3.4rem; margin: -1.7rem 0 0 -1.7rem; border-radius: 50%; background: rgba(167, 139, 250, .55); border: 2px solid rgba(196, 181, 253, .8); pointer-events: none; }
.tbtn { position: absolute; width: 4.4rem; height: 4.4rem; border-radius: 50%; border: 2px solid rgba(61, 240, 255, .5); background: rgba(8, 16, 30, .55); color: #fff; font: inherit; font-weight: 800; font-size: .8rem; touch-action: none; opacity: .9; }
.tbtn.on, .tbtn:active { transform: scale(.93); opacity: 1; }
#t-act { right: max(1rem, env(safe-area-inset-right)); bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 4.9rem); font-size: 1.3rem; border-color: rgba(251, 191, 36, .7); }
#t-hb { right: calc(max(1rem, env(safe-area-inset-right)) + 4.9rem); bottom: max(1rem, env(safe-area-inset-bottom)); }
#t-pause { display: none; }
body.is-touch .hud-speed { bottom: auto; top: 12.2rem; right: .9rem; }
body.is-touch .hud-speed b { font-size: 1.8rem; }
body.is-touch .prompt { bottom: 10.2rem; }
body.is-touch .toasts { bottom: 13.4rem; }

/* overlays */
.overlay { position: fixed; inset: var(--rg-bar, 0) 0 0 0; z-index: 40; display: grid; place-items: center; padding: 1rem; background: rgba(4, 6, 12, .74); overflow-y: auto; }
.overlay.side { background: linear-gradient(90deg, transparent 40%, rgba(4, 6, 12, .7)); place-items: center end; }
.panel { width: min(28rem, 100%); padding: 1.3rem 1.15rem 1.1rem; border-radius: 1rem; border: 1px solid rgba(167, 139, 250, .32); background: linear-gradient(165deg, #171428, #0b0a16); box-shadow: 0 22px 50px rgba(0, 0, 0, .5); text-align: center; animation: rise .35s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.eyebrow { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: #fdba74; margin-bottom: .35rem; }
.panel h2 { font-size: 1.6rem; font-weight: 850; margin-bottom: .45rem; background: linear-gradient(90deg, #c4b5fd, #fbbf24); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { font-size: .86rem; line-height: 1.5; opacity: .82; margin-bottom: .8rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: .8rem 0 .3rem; }
.btn { min-width: 6.5rem; min-height: 2.6rem; padding: .55rem .95rem; border-radius: .6rem; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .07); color: inherit; font: inherit; font-weight: 750; font-size: .9rem; cursor: pointer; }
.btn.primary { background: linear-gradient(135deg, #a78bfa, #7c3aed); border-color: transparent; color: #fff; box-shadow: 0 0 18px rgba(167, 139, 250, .3); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .tbtn:focus-visible, .prompt:focus-visible, .pause-btn:focus-visible, .home-link:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.keys { margin-top: .8rem; text-align: left; font-size: .76rem; line-height: 1.7; opacity: .78; columns: 2; column-gap: 1rem; list-style: none; }
.keys li { break-inside: avoid; }
.bench-panel { width: min(25rem, 100%); max-height: 100%; overflow-y: auto; text-align: left; margin-right: max(0rem, env(safe-area-inset-right)); }
.bench-panel h2 { text-align: left; }
.bench-scrap { font-weight: 800; color: var(--gold); }
.ups { list-style: none; display: grid; gap: .5rem; margin: .7rem 0; }
.up { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "main pips" "main btn"; gap: .25rem .6rem; align-items: center; padding: .6rem .7rem; border-radius: .7rem; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); }
.up-main { grid-area: main; }
.up-name { font-weight: 800; font-size: .92rem; }
.up-desc { font-size: .74rem; opacity: .7; }
.up-stat { font-size: .74rem; color: #7dd3fc; margin-top: .15rem; }
.pips { grid-area: pips; display: flex; gap: .2rem; justify-content: flex-end; }
.pips span { width: .9rem; height: .45rem; border-radius: .2rem; background: #28324a; }
.pips span.on { background: var(--cyan); }
.up .btn { grid-area: btn; min-width: 0; min-height: 2.2rem; padding: .35rem .6rem; font-size: .8rem; }
.status { min-height: 1.2em; font-size: .8rem; color: #86efac; }
.res-list { list-style: none; display: grid; gap: .25rem; margin: .5rem auto .3rem; max-width: 18rem; text-align: left; font-size: .86rem; }
.res-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem .5rem; border-radius: .4rem; background: rgba(255, 255, 255, .05); }
.res-list b { color: var(--gold); }
.load-panel { width: min(26rem, 100%); }
.load-bar { height: .55rem; border-radius: .4rem; background: rgba(255, 255, 255, .1); overflow: hidden; margin: .9rem 0 .7rem; }
.load-bar i { display: block; height: 100%; transform: scaleX(0); transform-origin: left center; background: linear-gradient(90deg, #3df0ff, #a78bfa, #fbbf24); transition: transform .2s ease-out; }
.load-tip { font-size: .8rem; opacity: .75; }
.err { color: var(--red); font-size: .84rem; margin-top: .6rem; }
@media (max-width: 40em) {
  .hud-tl { min-width: 9.8rem; padding: .45rem .55rem; top: .45rem; left: .45rem; }
  .hud-obj { top: auto; bottom: auto; left: .45rem; right: auto; transform: none; position: absolute; margin-top: 7.4rem; top: 0; max-width: 60vw; text-align: left; border-radius: .6rem; font-size: .72rem; }
  .hud-gate { top: .55rem; left: auto; right: 3.9rem; transform: none; }
  .minimap { width: 110px; height: 110px; top: 3.2rem; right: .45rem; }
  .overlay.side { place-items: end center; background: linear-gradient(180deg, transparent 35%, rgba(4, 6, 12, .75)); }
  .bench-panel { max-height: 62%; }
  .keys { columns: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .panel { animation: fade .45s ease-out both; }
  .toast { animation: fade .5s ease-out both; }
  .bar i, .load-bar i { transition-duration: .3s; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#loading { background: radial-gradient(ellipse 60% 50% at 50% 40%, rgba(124, 58, 237, .28), transparent 65%), #07080d; }
.t-only { display: none; }
body.is-touch .t-only { display: list-item; }
body.is-touch .k-only { display: none; }
/* pause menu: sound + quality */
.settings { margin: .7rem 0 .2rem; padding: .6rem .5rem .3rem; border-top: 1px solid rgba(167, 139, 250, .2); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin: .35rem 0; flex-wrap: wrap; }
.set-label { font-size: .8rem; font-weight: 750; opacity: .85; }
.set-ctl { display: flex; align-items: center; gap: .35rem; }
.btn.sm { min-width: 2.6rem; min-height: 2.3rem; padding: .35rem .6rem; font-size: .85rem; }
.btn.sm[aria-pressed="true"] { border-color: var(--red); color: var(--red); }
.vol-val { min-width: 3rem; text-align: center; font-variant-numeric: tabular-nums; font-weight: 750; font-size: .85rem; }
.seg { display: inline-flex; border: 1px solid rgba(255, 255, 255, .16); border-radius: .6rem; overflow: hidden; }
.seg button { min-height: 2.3rem; padding: .35rem .7rem; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 700; font-size: .8rem; cursor: pointer; }
.seg button + button { border-left: 1px solid rgba(255, 255, 255, .12); }
.seg button[aria-checked="true"] { background: rgba(167, 139, 250, .3); color: #fff; }
.seg button:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
.set-note { font-size: .72rem; opacity: .65; margin-top: .2rem; min-height: 1em; }
