:root {
  --hud-green: #58b947;
  --hud-hp: #22c55e;
  --hud-armor: #38bdf8;
  --hud-stamina: #f59e0b;
  --hud-dark: rgba(14, 17, 23, 0.88);
  --hud-panel: rgba(18, 22, 30, 0.94);
  --hud-border: rgba(255, 255, 255, 0.16);
  --text-light: #f8fafc;
  --text-muted: #94a3b8;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1412;
  color: var(--text-light);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#canvas-mount {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#canvas-mount canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* HUD Root */
#hud-root {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  transition: opacity 200ms ease;
}

body[data-state='title'] #hud-root {
  opacity: 0;
  visibility: hidden;
}

/* Top-Left Minimap Cluster */
.hud-top-left {
  position: fixed;
  top: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.minimap-shell {
  position: relative;
  width: 228px;
  background: #0d1016;
  border: 2px solid #090b0f;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  cursor: pointer;
}

.minimap-radar-badge {
  position: absolute;
  top: -7px;
  left: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #0d1016;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.minimap-compass-n {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #0d1016;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

#minimap-canvas {
  display: block;
  width: 224px;
  height: 148px;
}

.minimap-bars {
  display: grid;
  grid-template-columns: 1fr 0.68fr 0.68fr;
  gap: 3px;
  padding: 3px;
  background: #090b0f;
}

.bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  transition: width 120ms linear;
}

.bar-health .bar-fill {
  background: var(--hud-hp);
}

.bar-armor .bar-fill {
  background: var(--hud-armor);
}

.bar-stamina .bar-fill {
  background: var(--hud-stamina);
}

.map-hint-btn {
  pointer-events: auto;
  background: rgba(12, 15, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 5px 10px;
  color: #f1f5f9;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  transition: background 150ms ease, transform 150ms ease;
}

.map-hint-btn:hover {
  background: rgba(22, 27, 36, 0.9);
}

.map-hint-btn kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 3px;
  background: #f8fafc;
  color: #0f172a;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
}

/* Top-Right: Cash, Wanted Stars, Weapon Box, Utility */
.hud-top-right {
  position: fixed;
  top: 16px;
  right: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.hud-top-right-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hud-status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.cash-display {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 40px;
  line-height: 0.95;
  letter-spacing: 1.5px;
  color: var(--hud-green);
  font-variant-numeric: tabular-nums;
  -webkit-text-stroke: 1.8px #081108;
  text-shadow:
    0 2px 0 #081108,
    2px 0 0 #081108,
    -2px 0 0 #081108,
    0 -2px 0 #081108,
    0 4px 12px rgba(0, 0, 0, 0.75);
}

.wanted-stars {
  display: flex;
  align-items: center;
  gap: 3px;
}

.star-icon {
  width: 20px;
  height: 20px;
  fill: rgba(148, 163, 184, 0.5);
  stroke: #090b0f;
  stroke-width: 1.8;
  transition: fill 150ms ease, transform 150ms ease;
}

.star-icon.active {
  fill: #facc15;
  transform: scale(1.08);
}

.star-icon.flash-red {
  fill: #ef4444;
}

.star-icon.flash-blue {
  fill: #3b82f6;
}

.weapon-slot-btn {
  pointer-events: auto;
  width: 68px;
  height: 68px;
  border-radius: 12px;
  background: rgba(10, 12, 16, 0.65);
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: transform 140ms ease, border-color 140ms ease;
}

.weapon-slot-btn:hover {
  border-color: rgba(255, 255, 255, 0.55);
}

.weapon-slot-btn:active {
  transform: scale(0.92);
}

.utility-btn-row {
  display: flex;
  gap: 6px;
}

.utility-icon-btn {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--hud-dark);
  border: 1px solid var(--hud-border);
  color: #e2e8f0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

.utility-icon-btn:hover {
  background: rgba(38, 46, 62, 0.94);
}

.utility-icon-btn:active {
  transform: scale(0.93);
}

.speedometer-badge {
  background: var(--hud-dark);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}

#speed-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  color: #f8fafc;
}

.speed-unit {
  font-size: 11px;
  font-weight: 700;
  color: #f59e0b;
  letter-spacing: 0.08em;
}

/* Bottom-Left: Virtual Analog Stick + Vitals */
.hud-bottom-left {
  position: fixed;
  left: 20px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.joystick-zone {
  pointer-events: auto;
  position: relative;
  width: 146px;
  height: 146px;
  border-radius: 50%;
  background: rgba(14, 17, 23, 0.42);
  border: 2px solid rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.35);
  touch-action: none;
  cursor: grab;
  margin-left: 16px;
}

.joystick-zone:active {
  cursor: grabbing;
}

.joy-arrow {
  position: absolute;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.45);
  pointer-events: none;
}

.joy-up {
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.joy-down {
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.joy-left {
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
}

.joy-right {
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  margin-top: -26px;
  margin-left: -26px;
  border-radius: 50%;
  background: rgba(185, 194, 208, 0.72);
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.vitals-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vitals-bars-col {
  width: 158px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.vital-main-bar {
  height: 13px;
  background: rgba(10, 12, 16, 0.72);
  border: 1.5px solid #090b0f;
  border-radius: 2px;
  overflow: hidden;
}

.vital-main-fill {
  height: 100%;
  background: linear-gradient(90deg, #16a34a, #4ade80);
  transition: width 120ms linear;
}

.vital-sub-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.vital-sub-track {
  height: 5px;
  background: rgba(10, 12, 16, 0.72);
  border-radius: 2px;
  overflow: hidden;
}

.vital-sub-fill {
  height: 100%;
  transition: width 120ms linear;
}

.vital-armor {
  background: #38bdf8;
}

.vital-stamina {
  background: #f59e0b;
}

.vitals-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.vital-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(12, 15, 20, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Bottom-Right: 3 Circular Action Buttons */
.hud-bottom-right {
  position: fixed;
  right: 22px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.action-circle-btn {
  pointer-events: auto;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: rgba(14, 17, 23, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.42);
  transition: transform 120ms ease, background 150ms ease, border-color 150ms ease;
}

.action-circle-btn:hover {
  background: rgba(24, 30, 42, 0.72);
  border-color: rgba(255, 255, 255, 0.65);
}

.action-circle-btn:active,
.action-circle-btn.active {
  transform: scale(0.92);
  background: rgba(245, 158, 11, 0.42);
  border-color: #fbbf24;
}

.action-circle-btn.highlight-car {
  border-color: #38bdf8;
  background: rgba(14, 116, 144, 0.55);
}

/* Contextual Prompt & Toast */
.interaction-prompt {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 15, 22, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 700;
  color: #f8fafc;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.toast-banner {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 15, 22, 0.92);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 700;
  color: #fde68a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}

/* Title Screen Overlay */
.title-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 48px 34px;
  background: linear-gradient(
    90deg,
    rgba(10, 12, 18, 0.52) 0%,
    rgba(10, 12, 18, 0.18) 46%,
    rgba(10, 12, 18, 0) 78%
  );
  transition: opacity 280ms ease;
}

body:not([data-state='title']) .title-overlay {
  opacity: 0;
  visibility: hidden;
}

.title-card {
  pointer-events: auto;
  margin-top: auto;
  margin-bottom: auto;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}

.title-emblem {
  display: block;
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, 0.6));
}

.start-btn {
  appearance: none;
  border: 2px solid #fbbf24;
  background: #f59e0b;
  color: #0b0d12;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 14px 36px;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  transition: transform 150ms cubic-bezier(0.16, 1, 0.3, 1), background 150ms ease;
}

.start-btn:hover {
  background: #fbbf24;
  transform: translateY(-2px);
}

.start-btn:active {
  transform: translateY(0) scale(0.97);
}

.title-controls-line {
  font-size: 13px;
  font-weight: 600;
  color: rgba(248, 250, 252, 0.88);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  line-height: 1.5;
}

/* Game Modals (Map, Mall, Pause) */
.game-modal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border: none;
  background: rgba(6, 8, 12, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}

.game-modal:not([open]) {
  display: none;
}

.modal-surface {
  background: var(--hud-panel);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 24px;
  color: var(--text-light);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
  width: 100%;
}

.map-modal-surface {
  max-width: 810px;
}

.mall-modal-surface {
  max-width: 560px;
}

.pause-modal-surface {
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-header h2,
.pause-modal-surface h2 {
  font-family: 'Bebas Neue', Impact, sans-serif;
  font-size: 32px;
  letter-spacing: 1.5px;
  color: #fbbf24;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 8px 14px;
  color: #f8fafc;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

#fullmap-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #141820;
  cursor: crosshair;
}

.map-legend {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.legend-items {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #e2e8f0;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 2px;
}

.dot-player { background: #ffffff; }
.dot-mall { background: #38bdf8; }
.dot-home { background: #4ade80; }
.dot-pickup { background: #facc15; }

.mall-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.mall-subtitle strong {
  color: var(--hud-green);
  font-variant-numeric: tabular-nums;
}

.mall-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.mall-item-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 14px;
  text-align: left;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}

.mall-item-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #fbbf24;
}

.mall-item-name {
  font-size: 15px;
  font-weight: 700;
}

.mall-item-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.mall-item-price {
  margin-top: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--hud-green);
}

.pause-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pause-stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.primary-action-btn {
  background: #f59e0b;
  color: #0b0d12;
  border: none;
  border-radius: 6px;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.primary-action-btn:hover {
  background: #fbbf24;
}

.secondary-action-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 11px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.secondary-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.pause-controls-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
}

/* Responsive adjustments for mobile viewports */
@media (max-width: 720px) {
  .minimap-shell {
    width: 152px;
  }

  #minimap-canvas {
    width: 148px;
    height: 100px;
  }

  .map-hint-btn {
    font-size: 11px;
    padding: 4px 8px;
  }

  .cash-display {
    font-size: 28px;
  }

  .star-icon {
    width: 15px;
    height: 15px;
  }

  .weapon-slot-btn {
    width: 52px;
    height: 52px;
  }

  .weapon-slot-btn svg {
    width: 38px;
    height: 38px;
  }

  .joystick-zone {
    width: 112px;
    height: 112px;
    margin-left: 4px;
  }

  .joystick-knob {
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
  }

  .vitals-bars-col {
    width: 122px;
  }

  .action-circle-btn {
    width: 58px;
    height: 58px;
  }

  .action-circle-btn svg {
    width: 24px;
    height: 24px;
  }

  .title-overlay {
    padding: 24px;
  }

  .mall-grid {
    grid-template-columns: 1fr;
  }
}

/* Improved touch and map controls */
#canvas-mount canvas,.action-circle-btn,.utility-icon-btn,.weapon-slot-btn,.joystick-zone{touch-action:none}
.map-toolbar{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:10px;color:#cbd5e1;font-size:12px}.map-zoom-controls{display:flex;gap:7px}.map-zoom-controls button{background:#273244;color:white;border:1px solid #64748b;border-radius:6px;min-width:38px;min-height:34px;padding:5px 10px;font-weight:800}#fullmap-canvas{max-height:min(62vh,680px);touch-action:none}.mission-list{display:grid;gap:9px}.mission-item{display:flex;flex-direction:column;gap:5px;text-align:left;padding:13px;border:1px solid #475569;border-radius:8px;color:#fff;background:#202a39}.mission-item span{color:#cbd5e1;font-size:12px}.mission-status{margin-top:12px;color:#86efac;font-size:13px}.room-row{display:flex;gap:8px;flex-wrap:wrap}.room-row input{min-width:120px;flex:1;border-radius:6px;border:1px solid #64748b;background:#111827;color:#fff;padding:10px}.room-row button{padding:9px 12px;border-radius:6px}@media(max-width:600px){.map-modal-surface{padding:12px}.room-row button{flex:1}}

/* Context interaction control */
#btn-interact {
  position: fixed;
  right: 26px;
  bottom: 300px;
  z-index: 30;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: #fff;
  font: 800 22px 'Plus Jakarta Sans', sans-serif;
  background: rgba(22, 163, 74, .72);
  border: 2px solid rgba(255,255,255,.7);
  pointer-events: auto;
  touch-action: manipulation;
}
@media (max-height: 650px) {
  #btn-interact { bottom: 230px; width:50px; height:50px; }
}
