:root {
  --qp-ink: #060708;
  --qp-carbon: #0e1114;
  --qp-carbon-2: #13171c;
  --qp-line: rgba(255, 255, 255, 0.08);
  --qp-mint: #00d7bd;
  --qp-mint-hi: #37f0d6;
  --qp-paper: #eef3f2;
  --qp-mute: #97a1aa;
  --qp-glass: rgba(14, 17, 20, 0.78);
  --qp-panel-bg: rgba(14, 17, 20, 0.72);
  --qp-panel-bg-2: rgba(19, 23, 28, 0.68);
  --qp-line-menu: rgba(30, 36, 43, 0.65);
  --qp-line-menu-2: rgba(42, 50, 59, 0.7);
  --qp-radius: 14px;
  --qp-radius-sm: 8px;
  --qp-font: 'Inter', system-ui, sans-serif;

  --color-health: #ff6b6b;
  --color-armor: #5dade2;
  --color-hunger: #f5b041;
  --color-thirst: #5dade2;
  --color-stamina: #00d7bd;
  --color-accent: #00d7bd;
  --text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: transparent;
  font-family: var(--qp-font);
  user-select: none;
  pointer-events: none;
}

.qp-hud { width: 100%; height: 100%; }
.stat-block {
  position: fixed;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.edit-mode .stat-block {
  pointer-events: auto !important;
  cursor: grab;
  z-index: 250;
  outline: 1px dashed rgba(0, 215, 189, 0.45);
  outline-offset: 4px;
  border-radius: var(--qp-radius-sm);
  touch-action: none;
}
body.edit-mode .stat-block:hover {
  outline-color: var(--qp-mint);
  filter: drop-shadow(0 0 10px rgba(0, 215, 189, 0.25));
}
.stat-block.visible { opacity: 1; }

body.edit-mode .stat-block.resizing,
body.edit-mode .hud-draggable.resizing {
  opacity: 0.88 !important;
  z-index: 999;
  transition: none;
}
.stat-block.dragging,
body.edit-mode .hud-draggable.dragging {
  cursor: grabbing !important;
  opacity: 0.88 !important;
  z-index: 999;
  transition: none;
}

.drag-handle {
  display: none;
  position: absolute;
  top: -16px; left: 2px;
  font-size: 12px;
  color: var(--qp-mint);
  letter-spacing: -3px;
  pointer-events: none;
}
body.edit-mode .drag-handle { display: block; }

body.edit-mode .stat-block *:not(.resize-handle) { pointer-events: none; }

.display-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
.stat-block .display-circle { display: none; }
body.style-circle .stat-block .display-bar { display: none; }
body.style-circle .stat-block .display-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.icon {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--qp-paper);
  flex-shrink: 0;
  filter: drop-shadow(var(--text-shadow));
}
.icon svg { width: 14px; height: 14px; }

.bar {
  position: relative;
  width: 148px; height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
  border: none;
  box-shadow: none;
}
.fill {
  height: 100%;
  border-radius: 999px;
  width: 100%;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
}
.value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--qp-paper);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.health-fill  { background: var(--color-health); }
.armor-fill   { background: var(--color-armor); }
.hunger-fill  { background: var(--color-hunger); }
.thirst-fill  { background: var(--color-thirst); }
.stamina-fill { background: var(--color-stamina); }
.fill.critical { animation: qp-pulse 1s infinite; }
@keyframes qp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.gauge-wrapper { position: relative; width: 64px; height: 64px; }
.gauge-svg { width: 64px; height: 64px; display: block; }
.gauge-track { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 5; }
.gauge-arc {
  fill: none; stroke-width: 5; stroke-linecap: round;
  transition: stroke-dashoffset 0.35s cubic-bezier(0.4,0,0.2,1);
}
.health-arc  { stroke: var(--color-health); }
.armor-arc   { stroke: var(--color-armor); }
.hunger-arc  { stroke: var(--color-hunger); }
.thirst-arc  { stroke: var(--color-thirst); }
.stamina-arc { stroke: var(--color-stamina); }
.gauge-icon-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--qp-paper);
}
.gauge-icon-overlay svg { width: 20px; height: 20px; }


.stat-block.hidden-stat { display: none !important; }
.panel-block,
#vehicle-info.hud-draggable {
  position: fixed;
  z-index: 3;
  pointer-events: none;
}
.panel-block.hidden-panel { display: none !important; }

.hud-draggable .drag-handle {
  display: none;
  position: absolute;
  top: -18px;
  left: 0;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(0, 215, 189, 0.15);
  border: 1px solid rgba(0, 215, 189, 0.35);
  color: var(--qp-mint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}
body.edit-mode .hud-draggable {
  pointer-events: auto !important;
  cursor: grab;
  z-index: 250;
  outline: 1px dashed rgba(0, 215, 189, 0.45);
  outline-offset: 4px;
  border-radius: var(--qp-radius-sm);
  touch-action: none;
}
body.edit-mode .hud-draggable:hover {
  outline-color: var(--qp-mint);
  filter: drop-shadow(0 0 10px rgba(0, 215, 189, 0.2));
}
body.edit-mode .hud-draggable .drag-handle { display: block; }
body.edit-mode .hud-draggable.dragging {
  cursor: grabbing !important;
  opacity: 0.88;
  z-index: 999;
  transition: none;
}
body.edit-mode .hud-draggable *:not(.resize-handle) { pointer-events: none; }
body.edit-mode #vehicle-info {
  display: flex !important;
  opacity: 0.75 !important;
  pointer-events: auto !important;
}
body.edit-mode .stat-block.hidden-stat,
body.edit-mode .panel-block.hidden-panel {
  display: flex !important;
  opacity: 0.45 !important;
}
body.edit-mode .stat-block.hidden-stat { display: block !important; }

#money-display {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.money-row, .job-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
.money-icon { width: 14px; height: 14px; flex-shrink: 0; }
.cash-row .money-icon { color: #f5d76e; }
.bank-row .money-icon { color: var(--qp-mint); }
.money-row span, .job-row span {
  font-size: 13px;
  font-weight: 700;
  color: var(--qp-paper);
  font-variant-numeric: tabular-nums;
  text-shadow: var(--text-shadow);
}
.job-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--qp-mint);
  box-shadow: 0 0 8px rgba(0, 215, 189, 0.6);
  flex-shrink: 0;
}
#job-val { font-size: 11px; font-weight: 600; color: var(--qp-mute); }

#location-display {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.loc-compass {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(0, 215, 189, 0.35);
  color: var(--qp-mint);
  font-size: 9px;
  font-weight: 800;
  flex-shrink: 0;
  text-shadow: var(--text-shadow);
}
#loc-street {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 700; color: var(--qp-paper);
  text-shadow: 0 1px 8px rgba(0,0,0,0.9);
}
.loc-pin { width: 11px; height: 11px; color: var(--qp-mint); flex-shrink: 0; }
#loc-zone {
  margin-top: 2px;
  padding-left: 16px;
  font-size: 11px;
  font-weight: 500;
  color: var(--qp-mute);
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
}

#voice-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  opacity: 0.35;
  transition: opacity 0.2s, filter 0.2s;
}
#voice-indicator svg {
  width: 15px; height: 15px;
  color: var(--qp-paper);
  filter: drop-shadow(var(--text-shadow));
}
.voice-bars { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.voice-bars span {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.25);
  height: 4px;
  transition: height 0.15s, background 0.15s;
}
#voice-indicator.talking {
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(0, 215, 189, 0.35));
}
#voice-indicator.talking svg { color: var(--qp-mint); }
#voice-indicator.mode-1 .voice-bars span:nth-child(1),
#voice-indicator.mode-2 .voice-bars span:nth-child(-n+2),
#voice-indicator.mode-3 .voice-bars span { background: var(--qp-mint); }
#voice-indicator.talking .voice-bars span { animation: voice-bounce 0.5s ease infinite alternate; }
#voice-indicator.talking .voice-bars span:nth-child(2) { animation-delay: 0.08s; }
#voice-indicator.talking .voice-bars span:nth-child(3) { animation-delay: 0.16s; }
@keyframes voice-bounce { from { height: 4px; } to { height: 11px; } }
#vehicle-info {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 280px;
  opacity: 0;
  transition: opacity 0.3s;
}
#vehicle-info.visible { display: flex; opacity: 1; }
#speedo-svg { width: 280px; filter: drop-shadow(0 2px 12px rgba(0,0,0,0.35)); }
.speedo-wrap {
  position: relative;
  width: 280px;
}
.speedo-cluster {
  position: absolute;
  left: 50%;
  top: 76%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}
.speedo-cell {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.speedo-cell-status {
  border: 1.5px solid rgba(93, 173, 226, 0.55);
  box-shadow: 0 0 8px rgba(93, 173, 226, 0.12);
}
.speedo-lamp {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.speedo-lamp.running {
  background: #5dade2;
  box-shadow: 0 0 6px rgba(93, 173, 226, 0.9);
  animation: speedo-engine-pulse 1.5s ease-in-out infinite;
}
.speedo-lamp.off {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: none;
}
.speedo-cell-health {
  width: 24px;
  height: 24px;
  border: 1.5px solid rgba(255, 107, 107, 0.45);
  box-shadow: 0 0 8px rgba(255, 107, 107, 0.1);
}
.speedo-health-ring {
  display: block;
  width: 20px;
  height: 20px;
}
.speedo-cell-gear {
  width: 22px;
  height: 22px;
  border: 1.5px solid rgba(192, 132, 252, 0.55);
  box-shadow: 0 0 8px rgba(192, 132, 252, 0.12);
  font-size: 9px;
  font-weight: 800;
  color: #c084fc;
  letter-spacing: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.speedo-cell-gear.shift-pop {
  animation: speedo-gear-pop 0.28s ease;
}
.speedo-blinkers {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10%;
  display: flex;
  justify-content: space-between;
  padding: 0 20%;
  pointer-events: none;
}
.blinker {
  width: 14px;
  height: 14px;
  color: rgba(238, 243, 242, 0.18);
  transition: color 0.15s ease;
}
.blinker svg {
  display: block;
  width: 100%;
  height: 100%;
}
.blinker.active {
  color: var(--qp-mint);
  animation: blinker-flash 0.95s step-end infinite;
}
@keyframes blinker-flash {
  0%, 45% { opacity: 1; }
  50%, 100% { opacity: 0.15; }
}
@keyframes speedo-engine-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes speedo-gear-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
#speedo-svg.gear-shift #speedo-fill {
  filter: drop-shadow(0 0 10px rgba(0, 215, 189, 0.55));
}
.vi-fuel-wrap {
  display: flex; align-items: center; gap: 7px;
  width: 150px; margin-top: 4px; margin-bottom: 12px;
}
.vi-fuel-icon { width: 12px; height: 12px; color: var(--qp-mute); }
.vi-fuel-track {
  flex: 1; height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 999px; overflow: hidden;
}
.vi-fuel-fill {
  height: 100%; width: 100%;
  background: var(--qp-mint);
  border-radius: 999px;
  transition: width 0.5s ease, background 0.3s;
}
.vi-fuel-fill.low { background: #f5b041; }
.vi-fuel-fill.crit { background: #ff6b6b; animation: qp-pulse 1s infinite; }
.vi-fuel-val { font-size: 9px; font-weight: 700; color: var(--qp-mute); min-width: 28px; text-align: right; }
.edit-hint {
  position: fixed;
  bottom: 2%;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(0, 215, 189, 0.1);
  border: 1px solid rgba(0, 215, 189, 0.3);
  color: var(--qp-mint);
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  z-index: 200;
  transition: opacity 0.35s, transform 0.35s;
  pointer-events: none;
}
.edit-hint.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.menu-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 94vw);
  display: none;
  z-index: 100;
  pointer-events: none;
  background: transparent;
}
.menu-overlay.visible { display: block; }

.menu,
.menu * {
  pointer-events: auto;
}

.menu {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  background: var(--qp-panel-bg);
  border-left: 1px solid rgba(0, 215, 189, 0.28);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.03) inset,
    -8px 0 32px rgba(0, 0, 0, 0.25);
  color: var(--qp-paper);
  animation: menu-slide 0.25s ease;
}
@keyframes menu-slide {
  from { transform: translateX(100%); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

.menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--qp-line-menu);
  background: var(--qp-panel-bg-2);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; }
.menu-title { font-size: 16px; font-weight: 800; color: var(--qp-paper); letter-spacing: -0.02em; }
.menu-sub { font-size: 11px; font-weight: 600; color: var(--qp-mint); margin-top: 2px; }
.menu-close {
  width: 32px; height: 32px;
  border: 1px solid var(--qp-line-menu-2);
  border-radius: var(--qp-radius-sm);
  background: rgba(23, 28, 34, 0.55);
  color: var(--qp-paper);
  font-size: 20px;
  cursor: pointer;
  transition: background 0.2s;
}
.menu-close:hover { background: rgba(255, 107, 107, 0.2); }

.menu-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.menu-body::-webkit-scrollbar { width: 6px; }
.menu-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }

.menu-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--qp-mute);
  margin-bottom: 10px;
  font-weight: 700;
}
.section-hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--qp-mute);
  margin-top: 8px;
}
.section-hint code {
  font-size: 11px;
  color: var(--qp-mint);
}

.shape-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.style-btn, .map-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: var(--qp-radius-sm);
  border: 1px solid var(--qp-line-menu);
  background: rgba(23, 28, 34, 0.35);
  color: var(--qp-paper);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.style-btn:hover, .map-btn:hover { border-color: rgba(0, 215, 189, 0.3); }
.style-btn.active, .map-btn.active {
  background: rgba(0, 215, 189, 0.12);
  border-color: var(--qp-mint);
  box-shadow: inset 0 0 0 1px rgba(0, 215, 189, 0.35);
}

.style-preview { display: flex; align-items: center; gap: 6px; height: 36px; }
.prev-icon-sq { width: 14px; height: 14px; border-radius: 4px; background: rgba(255,255,255,0.25); }
.prev-bar-line { width: 34px; height: 7px; border-radius: 999px; background: linear-gradient(90deg, var(--qp-mint), transparent); }
.prev-circle-ring { width: 30px; height: 30px; border-radius: 50%; border: 4px solid var(--qp-mint); }

.toggle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--qp-radius-sm);
  border: 1px solid var(--qp-line-menu);
  background: rgba(23, 28, 34, 0.35);
  font-size: 12px;
  font-weight: 600;
  color: var(--qp-paper);
  cursor: pointer;
}
.toggle-row input { accent-color: var(--qp-mint); }

.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--qp-radius-sm);
  border: 1px solid var(--qp-line-menu);
  background: rgba(23, 28, 34, 0.35);
}
.color-row label { font-size: 12px; font-weight: 600; color: var(--qp-paper); }
.color-row input[type="color"] {
  width: 34px; height: 26px;
  border: none; background: transparent; cursor: pointer;
}

.scale-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--qp-radius-sm);
  border: 1px solid var(--qp-line);
  background: rgba(255,255,255,0.03);
}
.scale-icon { font-size: 11px; font-weight: 700; color: var(--qp-mute); }
.scale-icon-lg { font-size: 17px; color: var(--qp-paper); }
.scale-value { min-width: 40px; text-align: right; font-size: 12px; font-weight: 700; color: var(--qp-mint); }
input[type="range"] {
  flex: 1; height: 4px;
  appearance: none;
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--qp-mint);
  box-shadow: 0 0 8px rgba(0, 215, 189, 0.45);
}

.menu-footer {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--qp-line-menu);
  background: var(--qp-panel-bg-2);
}
.btn {
  flex: 1;
  padding: 11px 14px;
  border-radius: var(--qp-radius-sm);
  border: 1px solid var(--qp-line);
  background: rgba(255,255,255,0.04);
  color: var(--qp-paper);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { background: rgba(255,255,255,0.08); }
.btn.primary { background: var(--qp-mint); border-color: var(--qp-mint); color: #04110e; }
.btn.primary:hover { background: var(--qp-mint-hi); }
.btn.danger:hover { background: rgba(255, 107, 107, 0.18); border-color: #ff6b6b; }
.btn.full-width { width: 100%; flex: none; }

.section-hint--sm { margin-top: 4px; font-size: 11px; opacity: 0.85; }
.resize-handle {
  display: none;
  position: absolute;
  width: 11px;
  height: 11px;
  background: var(--qp-mint);
  border: 2px solid var(--qp-ink);
  border-radius: 2px;
  z-index: 1002;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(0, 215, 189, 0.5);
}
body.edit-mode .resize-handle {
  display: block;
  pointer-events: auto !important;
}
.resize-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
