:root {
  --ink: #171426;
  --ink-soft: #24213a;
  --glass: rgba(18, 16, 31, .82);
  --bone: #f3e8cf;
  --muted: #9ca0ba;
  --coral: #ff6b67;
  --cyan: #61e8dc;
  --amber: #ffbf69;
  --danger: #ff445f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--ink); }
body { color: var(--bone); font-family: "Arial Narrow", "Roboto Condensed", "Segoe UI", sans-serif; letter-spacing: .08em; }
button { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
[hidden] { display: none !important; }

#game { position: relative; width: 100%; height: 100%; overflow: hidden; isolation: isolate; }
#world { display: block; width: 100%; height: 100%; background: #34354e; touch-action: none; }

.hud {
  position: absolute; z-index: 10; top: 0; left: 0; right: 0; min-height: 82px;
  padding: calc(15px + var(--safe-top)) 18px 12px; display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(260px, 1.1fr) minmax(210px, 1fr) 44px;
  align-items: center; gap: 18px; pointer-events: none;
  background: linear-gradient(180deg, rgba(11, 10, 20, .91), rgba(11, 10, 20, .55) 72%, transparent);
  text-transform: uppercase;
}
.brand-block, .stat-block, .nav-block { min-width: 0; }
.brand-block { display: flex; align-items: center; gap: 11px; }
.brand-block span, .nav-block span, .stat-block span, .modifier-hud span { display: block; color: var(--muted); font-size: 9px; font-weight: 800; }
.brand-block strong { display: block; font-size: 17px; letter-spacing: .18em; }
.brand-mark { width: 31px; height: 31px; display: flex; gap: 3px; align-items: flex-end; flex: 0 0 auto; }
.brand-mark i { width: 7px; background: var(--coral); transform: skewY(-35deg); box-shadow: 0 0 10px rgba(255,107,103,.5); }
.brand-mark i:nth-child(1) { height: 13px; }.brand-mark i:nth-child(2) { height: 22px; }.brand-mark i:nth-child(3) { height: 30px; }
.nav-block { text-align: center; padding: 0 12px; border-left: 1px solid rgba(255,255,255,.1); border-right: 1px solid rgba(255,255,255,.1); }
.nav-block strong { display: block; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--cyan); font-size: 18px; }
.nav-block small { color: var(--bone); font-size: 10px; }
.stat-block { display: flex; justify-content: flex-end; align-items: center; gap: 25px; }
.stat-block strong { display: block; font-size: 17px; }
.integrity { width: 100px; }
.meter { width: 100%; height: 7px; margin-top: 6px; padding: 1px; border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.25); }
.meter i { display: block; width: 100%; height: 100%; background: var(--cyan); box-shadow: 0 0 8px rgba(97,232,220,.6); transition: width .2s, background .2s; }
.icon-button { width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; background: rgba(23,20,38,.7); pointer-events: auto; cursor: pointer; }

.offer { position: absolute; z-index: 14; top: calc(102px + var(--safe-top)); right: 18px; width: 245px; padding: 14px; background: var(--glass); border: 1px solid rgba(97,232,220,.45); border-top: 3px solid var(--cyan); box-shadow: 0 16px 40px rgba(0,0,0,.28), 0 0 35px rgba(97,232,220,.06); text-transform: uppercase; backdrop-filter: blur(12px); }
.offer::before { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(255,255,255,.05); pointer-events: none; }
.offer-head, .offer-meta, .offer-actions { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.offer-head { color: var(--cyan); font-size: 9px; font-weight: 800; }
.offer > strong { position: relative; display: block; margin: 11px 0 8px; font-size: 21px; letter-spacing: .1em; }
.offer-meta { margin-bottom: 13px; }.offer-meta b { color: var(--amber); font-size: 18px; }.offer-meta span { color: var(--coral); font-size: 9px; font-weight: 900; }
.offer-actions button, .menu-stack button, .shop-footer button, .confirm-row button { min-height: 40px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.05); cursor: pointer; }
.offer-actions button { flex: 1; font-size: 10px; }
.offer-actions .accent, .primary-button { color: var(--ink); background: var(--cyan); border-color: var(--cyan); font-weight: 900; }
kbd { padding: 2px 5px; border: 1px solid currentColor; border-radius: 2px; background: transparent; font: inherit; font-size: .8em; }

.alert { position: absolute; z-index: 13; top: 112px; left: 50%; width: min(330px, calc(100% - 32px)); padding: 9px 18px; transform: translateX(-50%); text-align: center; text-transform: uppercase; background: rgba(27,14,27,.85); border: 1px solid var(--danger); box-shadow: 0 0 35px rgba(255,68,95,.22); }
.alert span, .alert small { display: block; font-size: 9px; color: #ff97a6; }.alert strong { display: block; margin: 2px 0; color: white; font-size: 22px; letter-spacing: .25em; }
.alert.pulse { animation: warningPulse .65s infinite alternate; }
@keyframes warningPulse { to { background: rgba(99,15,35,.88); transform: translateX(-50%) scale(1.02); } }

.modifier-hud { position: absolute; z-index: 11; top: 105px; left: 18px; display: flex; gap: 10px; }
.modifier-hud > div { min-width: 120px; padding: 8px 11px; background: rgba(18,16,31,.72); border-left: 2px solid var(--amber); }
.modifier-hud strong { display: block; margin-top: 2px; color: var(--amber); }.modifier-hud .meter { margin-top: 4px; }.meter.warning i { background: var(--amber); }
.modifier-hud .special-readout { border-color: var(--danger); }.modifier-hud .special-readout strong { color: #ff7185; }
.dock-prompt { position: absolute; z-index: 12; left: 50%; bottom: calc(27px + var(--safe-bottom)); transform: translateX(-50%); min-width: 176px; padding: 8px 18px; text-align: center; background: rgba(18,16,31,.86); border-bottom: 3px solid var(--cyan); text-transform: uppercase; }
.dock-prompt span { display: block; color: var(--cyan); font-size: 8px; }.dock-prompt strong { display: block; margin-top: 3px; font-size: 12px; }
.drop-button { position: absolute; z-index: 14; right: 22px; bottom: calc(25px + var(--safe-bottom)); min-width: 112px; min-height: 52px; border: 1px solid var(--danger); background: rgba(48,15,29,.88); box-shadow: 0 0 28px rgba(255,68,95,.15); cursor: pointer; text-transform: uppercase; }
.drop-button small, .drop-button strong { display: block; }.drop-button small { color: #ff8fa0; font-size: 7px; }.drop-button strong { margin-top: 3px; font-size: 11px; }
.toast { position: absolute; z-index: 18; left: 50%; bottom: 84px; max-width: min(500px, calc(100% - 32px)); padding: 11px 18px; transform: translate(-50%, 18px); opacity: 0; text-align: center; color: var(--ink); background: var(--bone); font-size: 11px; font-weight: 900; text-transform: uppercase; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.district-title { position: absolute; z-index: 9; top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 0; text-align: center; text-transform: uppercase; text-shadow: 0 4px 30px #000; pointer-events: none; }
.district-title.show { animation: districtReveal 2.3s both; }.district-title span, .district-title small { display: block; font-size: 10px; }.district-title strong { display: block; margin: 4px 0; font-size: clamp(38px, 8vw, 78px); letter-spacing: .26em; }
@keyframes districtReveal { 0% { opacity: 0; transform: translate(-50%,-40%); } 18%,68% { opacity: 1; transform: translate(-50%,-50%); } 100% { opacity: 0; transform: translate(-50%,-57%); } }

.touch-controls { position: absolute; z-index: 12; inset: auto 0 calc(14px + var(--safe-bottom)); display: none; justify-content: space-between; align-items: flex-end; padding: 0 20px; pointer-events: none; }
.stick { position: relative; width: 116px; height: 116px; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; background: rgba(17,15,29,.35); pointer-events: auto; touch-action: none; }
.stick::before, .stick::after { content: ""; position: absolute; background: rgba(255,255,255,.16); }.stick::before { width: 1px; height: 82%; top: 9%; left: 50%; }.stick::after { height: 1px; width: 82%; left: 9%; top: 50%; }
.stick i { position: absolute; width: 44px; height: 44px; left: 35px; top: 35px; border-radius: 50%; background: rgba(97,232,220,.68); box-shadow: 0 0 20px rgba(97,232,220,.25); }
.touch-controls button { width: 88px; height: 88px; border-radius: 50%; border: 1px solid rgba(255,255,255,.28); background: rgba(23,20,38,.68); pointer-events: auto; touch-action: manipulation; }
.touch-controls button small, .touch-controls button strong { display: block; }.touch-controls button small { font-size: 7px; color: var(--muted); }.touch-controls button strong { margin-top: 3px; font-size: 10px; color: var(--cyan); }

.modal-backdrop { position: absolute; z-index: 30; inset: 0; display: grid; place-items: center; padding: calc(18px + var(--safe-top)) 18px calc(18px + var(--safe-bottom)); background: rgba(9,8,17,.72); backdrop-filter: blur(14px); overflow: auto; }
.modal { width: min(700px, 100%); max-height: 100%; overflow: auto; padding: 30px; color: var(--bone); background: linear-gradient(145deg, rgba(36,33,58,.98), rgba(17,15,29,.98)); border: 1px solid rgba(255,255,255,.15); border-top: 4px solid var(--coral); box-shadow: 0 30px 90px rgba(0,0,0,.5); }
.modal .eyebrow { margin: 0 0 8px; color: var(--coral); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.modal h1, .modal h2 { margin: 0; line-height: .9; text-transform: uppercase; }.modal h1 { font-size: clamp(55px, 12vw, 98px); letter-spacing: .07em; }.modal h2 { font-size: clamp(28px, 6vw, 48px); }
.intro-copy { max-width: 530px; margin: 21px 0; color: #c7c4d2; line-height: 1.65; letter-spacing: .04em; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 24px; }.control-grid div { display: flex; align-items: center; gap: 12px; padding: 12px; background: rgba(255,255,255,.05); }.control-grid span { font-size: 9px; color: var(--muted); text-transform: uppercase; }
.primary-button { min-height: 48px; padding: 0 25px; border: 0; cursor: pointer; text-transform: uppercase; }.modal-note { display: block; margin-top: 11px; color: var(--muted); font-size: 8px; text-transform: uppercase; }
.compact-modal { width: min(430px, 100%); }.compact-modal > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.menu-stack { display: grid; gap: 9px; margin-top: 25px; }.menu-stack button { width: 100%; }
.danger-button { color: #ff8f9e !important; border-color: rgba(255,68,95,.5) !important; background: rgba(255,68,95,.08) !important; }
.manual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 24px 0; }.manual-grid article { padding: 16px; background: rgba(255,255,255,.045); }.manual-grid b { color: var(--coral); }.manual-grid h3 { margin: 8px 0; font-size: 14px; text-transform: uppercase; }.manual-grid p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; letter-spacing: .03em; }
.shop-modal { width: min(920px, 100%); }.shop-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 18px; }.shop-heading p { margin: 8px 0 0; color: var(--muted); font-size: 10px; }.shop-heading > strong { color: var(--amber); font-size: 24px; }
.vehicle-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }.vehicle-card { padding: 14px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1); }.vehicle-card.current { border-color: var(--cyan); }.vehicle-card img { display: block; width: 100%; height: 65px; object-fit: contain; filter: drop-shadow(0 7px 8px rgba(0,0,0,.4)); }.vehicle-card h3 { margin: 9px 0 2px; font-size: 13px; text-transform: uppercase; }.vehicle-card .role { min-height: 28px; margin: 0 0 10px; color: var(--muted); font-size: 8px; line-height: 1.5; }.vehicle-card .price { color: var(--amber); font-weight: 900; }.vehicle-card button { width: 100%; min-height: 34px; margin-top: 10px; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08); cursor: pointer; font-size: 9px; }.vehicle-card button:disabled { opacity: .42; cursor: default; }.stat-row { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 8px; margin: 4px 0; color: var(--muted); font-size: 7px; }.stat-row i { display: block; height: 4px; background: rgba(255,255,255,.08); }.stat-row i::after { content: ""; display: block; width: var(--value); height: 100%; background: var(--coral); }
.shop-footer { display: flex; justify-content: flex-end; gap: 9px; margin-top: 15px; }.shop-footer button { padding: 0 18px; }.confirm-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }.confirm-row button { padding: 0 20px; }

@media (pointer: coarse), (max-width: 780px) {
  .touch-controls { display: flex; }
  .hud { min-height: 66px; padding: calc(9px + var(--safe-top)) 10px 8px; grid-template-columns: 1fr 1fr 38px; gap: 8px; }
  .brand-block { display: none; }.nav-block { order: 0; text-align: left; padding: 0; border: 0; }.nav-block strong { font-size: 12px; }.nav-block small { font-size: 8px; }
  .stat-block { order: 1; gap: 12px; }.stat-block strong { font-size: 12px; }.integrity { width: 65px; }.icon-button { width: 36px; height: 36px; }
  .offer { top: calc(73px + var(--safe-top)); right: 10px; width: 210px; padding: 11px; }.offer > strong { font-size: 17px; margin: 8px 0; }.offer-actions button { min-height: 36px; }
  .modifier-hud { top: calc(73px + var(--safe-top)); left: 10px; }.modifier-hud > div { min-width: 100px; }
  .dock-prompt { bottom: calc(42px + var(--safe-bottom)); }.toast { bottom: calc(150px + var(--safe-bottom)); }
  .drop-button { right: 20px; bottom: calc(112px + var(--safe-bottom)); min-width: 88px; min-height: 42px; }
  .modal { padding: 22px; }.control-grid, .manual-grid { grid-template-columns: 1fr; }.control-grid { display: none; }
  .vehicle-list { grid-template-columns: repeat(2, 1fr); }.vehicle-card img { height: 45px; }
}

@media (max-width: 520px) {
  .stat-block .integrity { display: none; }.hud { grid-template-columns: 1fr auto 36px; }.offer { left: 10px; right: 10px; width: auto; }
  .vehicle-list { grid-template-columns: 1fr; }.vehicle-card { display: grid; grid-template-columns: 90px 1fr; column-gap: 10px; }.vehicle-card img { grid-row: 1 / span 5; }.vehicle-card h3 { margin-top: 0; }.vehicle-card .role { min-height: 0; }.stat-row { display: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
