:root {
  --bg-dark: #0f141c;
  --panel-bg: rgba(20, 26, 38, 0.78);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent-green: #2ecc71;
  --accent-green-glow: rgba(46, 204, 113, 0.4);
  --electric-cyan: #00d2d3;
  --electric-glow: rgba(0, 210, 211, 0.45);
  --warning-amber: #f39c12;
  --danger-red: #e74c3c;
  --text-main: #f5f6fa;
  --text-muted: #95afc0;
  --road-color: #2f3542;
  --glass-blur: blur(14px);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: 'Rubik', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-main);
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #1e272e;
}

/* Main Canvas */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Glass Card common styling */
.hud-card {
  background: var(--panel-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  pointer-events: auto;
  transition: all 0.25s ease;
}

/* Top HUD bar */
.hud-top {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

/* Mack Electric Brand Card */
.brand-card {
  padding: 8px 16px;
  gap: 10px;
}

.brand-bolt {
  font-size: 22px;
  color: var(--electric-cyan);
  filter: drop-shadow(0 0 8px var(--electric-glow));
  animation: pulseBolt 2s infinite ease-in-out;
}

@keyframes pulseBolt {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 1; }
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #fff;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-green);
  letter-spacing: 1.5px;
}

/* Task / Objective card */
.task-card {
  padding: 8px 18px;
  gap: 14px;
  flex: 1;
  max-width: 520px;
  border-left: 3px solid var(--electric-cyan);
}

.task-icon {
  font-size: 26px;
  flex-shrink: 0;
  animation: bounceSlow 2.5s infinite;
}

@keyframes bounceSlow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.task-details {
  flex: 1;
}

.task-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.task-text {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* GPS Pointer */
.gps-pointer {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 210, 211, 0.12);
  border: 1px solid rgba(0, 210, 211, 0.3);
  padding: 6px 12px;
  border-radius: 20px;
  flex-shrink: 0;
}

.gps-arrow {
  color: var(--electric-cyan);
  font-size: 14px;
  display: inline-block;
  transition: transform 0.15s ease-out;
  transform-origin: center center;
}

.gps-distance {
  font-size: 12px;
  font-weight: 700;
  color: var(--electric-cyan);
  font-family: 'Outfit', monospace;
}

/* Stats / Capacity Card */
.stats-card {
  padding: 8px 16px;
  gap: 14px;
  min-width: 240px;
}

.stat-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Two-line shift/hopper readout (label + value per row) */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.stat-label {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.stat-value {
  color: #fff;
  font-family: 'Outfit', monospace;
  font-weight: 800;
  white-space: nowrap;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-green), var(--electric-cyan));
  box-shadow: 0 0 10px var(--accent-green-glow);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Overall shift progress bar — cyan accent to distinguish it from the
   hopper-load bar below it. */
.progress-bar-fill.shift-fill {
  background: linear-gradient(90deg, #3498db, var(--electric-cyan));
  box-shadow: 0 0 10px rgba(0, 210, 211, 0.4);
}

.hud-badge-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.eco-score-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(46, 204, 113, 0.14);
  border: 1px solid rgba(46, 204, 113, 0.3);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-green);
  white-space: nowrap;
}

/* Personal best route time shown in the persistent HUD */
.best-time-badge {
  background: rgba(241, 196, 15, 0.14);
  border-color: rgba(241, 196, 15, 0.35);
  color: #f1c40f;
}

/* Control buttons (Sound, Help) */
.hud-controls-group {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.hud-btn {
  width: 44px;
  height: 44px;
  background: var(--panel-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all 0.2s ease;
}

.hud-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

.hud-btn:active {
  transform: translateY(0);
}

/* Unstuck Rescue Button */
.unstuck-btn {
  position: relative;
  border-color: rgba(243, 156, 18, 0.35);
}

.unstuck-btn:hover {
  border-color: var(--warning-amber);
  background: rgba(243, 156, 18, 0.18);
  box-shadow: 0 0 16px rgba(243, 156, 18, 0.45);
}

.unstuck-key-hint {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 8px;
  font-family: 'Outfit', sans-serif;
  font-weight: 900;
  color: #ffbe76;
  background: rgba(0, 0, 0, 0.65);
  padding: 0 3px;
  border-radius: 3px;
  border: 1px solid rgba(243, 156, 18, 0.4);
  line-height: 1.1;
  pointer-events: none;
}

/* Pulsing effect when truck is detected as stuck */
.unstuck-btn.stuck-pulsing,
.touch-quick-btn.btn-unstuck.stuck-pulsing {
  border-color: var(--warning-amber) !important;
  background: rgba(243, 156, 18, 0.35) !important;
  animation: unstuckGlow 1.2s infinite ease-in-out !important;
}

@keyframes unstuckGlow {
  0% {
    box-shadow: 0 0 4px rgba(243, 156, 18, 0.4);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 18px rgba(243, 156, 18, 0.9), inset 0 0 8px rgba(243, 156, 18, 0.5);
    transform: scale(1.08);
  }
  100% {
    box-shadow: 0 0 4px rgba(243, 156, 18, 0.4);
    transform: scale(1);
  }
}

/* Toast Notification Banner */
.toast-notification {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(-25px);
  background: rgba(18, 24, 36, 0.92);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1.5px solid rgba(243, 156, 18, 0.5);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 24px rgba(243, 156, 18, 0.25);
  z-index: 140;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast-notification.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.toast-notification.stuck-alert {
  border-color: #ff9f43;
  animation: toastAlertPulse 1.8s infinite alternate ease-in-out;
}

@keyframes toastAlertPulse {
  0% { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 15px rgba(255, 159, 67, 0.3); }
  100% { box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 28px rgba(255, 159, 67, 0.65); }
}

.toast-notification .toast-icon {
  font-size: 24px;
  line-height: 1;
  filter: drop-shadow(0 0 6px rgba(243, 156, 18, 0.4));
}

.toast-notification .toast-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast-notification .toast-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.6px;
  color: #fff;
}

.toast-notification .toast-desc {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Minimap Radar */
.minimap-container {
  position: absolute;
  top: 76px;
  right: 16px;
  width: 170px;
  height: 195px;
  background: var(--panel-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 9;
  display: flex;
  flex-direction: column;
}

#minimapCanvas {
  width: 170px;
  height: 170px;
  display: block;
}

.minimap-legend {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.35);
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.minimap-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.truck-dot { background: #3498db; box-shadow: 0 0 6px #3498db; }
.bin-dot { background: #2ecc71; box-shadow: 0 0 6px #2ecc71; }
.plant-dot { background: #e67e22; box-shadow: 0 0 6px #e67e22; }
.charge-dot { background: #00d2d3; box-shadow: 0 0 8px #00d2d3; }

/* Interactive Prompt (Center Bottom) */
.action-prompt {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: rgba(18, 24, 38, 0.92);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 2px solid var(--electric-cyan);
  box-shadow: 0 10px 40px rgba(0, 210, 211, 0.35);
  border-radius: var(--radius-lg);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 15;
  transition: all 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.action-prompt.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.prompt-icon {
  font-size: 28px;
  animation: pulseBolt 1s infinite alternate;
}

.prompt-content {
  display: flex;
  flex-direction: column;
}

.prompt-title {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
}

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

.prompt-desc kbd, .hud-controls-hint kbd {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.prompt-action-btn {
  background: linear-gradient(135deg, var(--accent-green), #27ae60);
  color: #fff;
  border: none;
  font-family: 'Rubik', sans-serif;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
  transition: all 0.2s ease;
}

.prompt-action-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(46, 204, 113, 0.6);
}

/* Speedometer & Hydraulic status (Bottom Left) */
.hud-bottom-left {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
}

.speedometer-card {
  background: var(--panel-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  /* Клипуем вылезание внутренних полос/плашек за скруглённую карточку */
  overflow: hidden;
  box-sizing: border-box;
}

.speed-cluster {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.speed-value {
  font-family: 'Outfit', monospace;
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  min-width: 44px;
}

.speed-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.speed-unit {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1;
}

.gear-tag {
  background: rgba(0, 210, 211, 0.2);
  color: var(--electric-cyan);
  border: 1px solid var(--electric-cyan);
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 800;
  font-size: 11px;
  line-height: 1.1;
  text-align: center;
}

.ev-telemetry-divider {
  width: 1px;
  height: 42px;
  background: rgba(255, 255, 255, 0.12);
}

.ev-energy-cluster {
  flex: 1;
  /* Гарантированное сжатие flex-элемента внутри карточки */
  min-width: 0;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.battery-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
}

.battery-label-group {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}

.battery-icon {
  font-size: 13px;
}

.battery-percent {
  color: var(--accent-green);
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
}

.battery-percent.low {
  color: var(--warning-amber);
}

.battery-percent.critical {
  color: var(--danger-red);
  animation: pulseCritical 0.6s infinite alternate;
}

@keyframes pulseCritical {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

.battery-progress-bg {
  width: 100%;
  max-width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  box-sizing: border-box;
  overflow: hidden;
}

.battery-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-green), var(--electric-cyan));
  border-radius: 3px;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--accent-green-glow);
}

.battery-progress-fill.low {
  background: linear-gradient(90deg, #e67e22, var(--warning-amber));
}

.battery-progress-fill.critical {
  background: var(--danger-red);
  box-shadow: 0 0 10px rgba(231, 76, 60, 0.7);
}

/* Dynamic Power / Charge Flow Meter */
.power-meter-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
}

.power-meter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.meter-charge-tag {
  color: var(--accent-green);
}

.meter-power-tag {
  color: var(--electric-cyan);
}

.meter-flow-val {
  color: #fff;
  font-family: 'Outfit', monospace;
  font-size: 10px;
}

.power-track {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  box-sizing: border-box;
  overflow: hidden;
}

.power-center-tick {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.3);
  transform: translateX(-50%);
  z-index: 2;
}

.power-flow-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0%;
  transition: width 0.08s ease, left 0.08s ease, background 0.15s ease;
  border-radius: 2px;
}

.power-flow-bar.charge {
  background: linear-gradient(90deg, #27ae60, var(--accent-green));
  box-shadow: 0 0 8px var(--accent-green-glow);
}

.power-flow-bar.power {
  background: linear-gradient(90deg, var(--electric-cyan), #3498db);
  box-shadow: 0 0 8px var(--electric-glow);
}

/* Live charging-pad status readout (visible only while charging) */
.charging-status {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(46, 204, 113, 0.14);
  border: 1px solid var(--accent-green);
  box-shadow: 0 0 12px var(--accent-green-glow);
  font-family: 'Outfit', monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent-green);
  /* Плашка не должна вылезать за пределы энергетического кластера */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  /* Длинный текст переносится внутри плашки, а не вылезает наружу */
  white-space: normal;
  line-height: 1.2;
  overflow: hidden;
  text-align: center;
}

.charging-status.show {
  display: flex;
  animation: chargingPulse 1.2s infinite ease-in-out;
}

.charging-status-icon {
  font-size: 12px;
  filter: drop-shadow(0 0 6px var(--accent-green-glow));
}

@keyframes chargingPulse {
  0%, 100% { box-shadow: 0 0 12px var(--accent-green-glow); }
  50% { box-shadow: 0 0 22px var(--accent-green); }
}

.dashboard-secondary-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cargo-mass-card {
  background: var(--panel-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.cargo-icon {
  font-size: 12px;
}

.cargo-text {
  color: var(--text-main);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
}

.hydraulic-status {
  background: var(--panel-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-indicator.busy {
  background: var(--warning-amber);
  box-shadow: 0 0 8px var(--warning-amber);
  animation: pulseIndicator 0.8s infinite alternate;
}

@keyframes pulseIndicator {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Controls Hint (Bottom Bar) */
.hud-controls-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  background: rgba(15, 20, 28, 0.85);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--panel-border);
  border-radius: 30px;
  padding: 8px 22px;
  font-size: 12px;
  color: var(--text-muted);
  z-index: 8;
  pointer-events: none;
}

.hint-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   TABLET & MOBILE ERGONOMIC TOUCH CONTROLS
   ========================================================================== */
.mobile-controls {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  /* Notch / home-indicator aware side gutters */
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  pointer-events: none;
  z-index: 35;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.mobile-controls.active {
  display: flex !important;
}

body.touch-mode-active .brand-card {
  display: none !important;
}

body.touch-mode-active .hud-controls-hint,
body.touch-mode-active .action-prompt,
body.touch-mode-active .hydraulic-status,
body.touch-mode-active .touch-cluster-title,
body.touch-mode-active .minimap-legend {
  display: none !important;
}

body.touch-mode-active .hud-bottom-left {
  bottom: 92px;
  left: 14px;
}

body.touch-mode-active .speedometer-card {
  padding: 4px 10px;
  gap: 8px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  /* Снимаем жёсткие ограничения: карточка сжимается по контенту,
     но не вылезает за кластер и клипует внутренние полосы/плашки */
  width: auto;
  min-width: 200px;
  max-width: 260px;
  overflow: hidden;
  box-sizing: border-box;
}

body.touch-mode-active .speed-value {
  font-size: 20px;
  min-width: 26px;
}

body.touch-mode-active .speed-unit {
  font-size: 8px;
}

body.touch-mode-active .gear-tag {
  font-size: 9px;
  padding: 1px 4px;
}

body.touch-mode-active .ev-telemetry-divider {
  height: 28px;
}

body.touch-mode-active .battery-status-row {
  font-size: 9px;
}

body.touch-mode-active .power-meter-header {
  font-size: 8px;
}

body.touch-mode-active .cargo-mass-card {
  font-size: 9px;
  padding: 3px 8px;
}

.hud-btn.active {
  background: rgba(0, 210, 211, 0.35) !important;
  border-color: var(--electric-cyan) !important;
  box-shadow: 0 0 14px rgba(0, 210, 211, 0.6) !important;
}

/* Left Zone: Steering Cluster (Left Thumb) */
.touch-steer-zone {
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: auto;
}

.touch-cluster-title {
  display: none;
}

.touch-steer-buttons {
  display: flex;
  gap: 8px;
}

.touch-steer-btn {
  width: 72px;
  height: 66px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(0, 210, 211, 0.32);
  border-radius: 18px;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: none;
  opacity: 0.82;
  transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease, opacity 0.08s ease;
  user-select: none;
  -webkit-user-select: none;
}

.touch-steer-btn .steer-arrow {
  font-size: 22px;
  line-height: 1;
  color: var(--electric-cyan);
  transition: transform 0.08s ease;
}

.touch-steer-btn .steer-label {
  font-family: 'Rubik', sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.6);
}

.touch-steer-btn:active,
.touch-steer-btn.pressed {
  background: rgba(0, 210, 211, 0.32);
  border-color: var(--electric-cyan);
  box-shadow: 0 2px 10px rgba(0, 210, 211, 0.5), inset 0 0 12px rgba(0, 210, 211, 0.4);
  transform: translateY(2px) scale(0.96);
  opacity: 1;
}

.touch-steer-btn:active .steer-arrow,
.touch-steer-btn.pressed .steer-arrow {
  transform: scale(1.15);
}

/* Right Zone: Pedals & Quick Actions (Right Thumb) */
.touch-pedal-zone {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
}

.touch-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.touch-quick-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: none;
  opacity: 0.82;
  transition: transform 0.1s ease, border-color 0.1s ease, opacity 0.1s ease;
}

.touch-quick-btn:active,
.touch-quick-btn.pressed {
  transform: scale(0.92);
  border-color: var(--electric-cyan);
  background: rgba(0, 210, 211, 0.35);
  opacity: 1;
}

.touch-quick-btn.btn-unstuck {
  border-color: rgba(243, 156, 18, 0.4);
}

.touch-quick-btn.btn-unstuck:active,
.touch-quick-btn.btn-unstuck.pressed {
  border-color: var(--warning-amber);
  background: rgba(243, 156, 18, 0.38);
}

.touch-primary-action-btn {
  height: 42px;
  padding: 0 16px;
  border-radius: 21px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-family: 'Rubik', sans-serif;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: none;
  opacity: 0.85;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.touch-primary-action-btn .btn-icon {
  font-size: 16px;
}

.touch-primary-action-btn.ready-grab {
  background: linear-gradient(135deg, rgba(46, 204, 113, 0.9), rgba(39, 174, 96, 0.95));
  border-color: #2ecc71;
  box-shadow: 0 0 20px rgba(46, 204, 113, 0.7);
  opacity: 1;
  animation: pulseTouchAction 0.9s infinite alternate;
}

.touch-primary-action-btn.ready-unload {
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.9), rgba(211, 84, 0, 0.95));
  border-color: #f39c12;
  box-shadow: 0 0 20px rgba(243, 156, 18, 0.7);
  opacity: 1;
  animation: pulseTouchAction 0.9s infinite alternate;
}

.touch-primary-action-btn.busy {
  background: rgba(44, 62, 80, 0.75);
  border-color: rgba(255, 255, 255, 0.15);
  opacity: 0.8;
}

.touch-primary-action-btn:active,
.touch-primary-action-btn.pressed {
  transform: scale(0.94);
  opacity: 1;
}

@keyframes pulseTouchAction {
  0% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(46, 204, 113, 0.4)); }
  100% { transform: scale(1.04); filter: drop-shadow(0 0 16px rgba(46, 204, 113, 0.9)); }
}

/* Vehicle Pedals Cluster */
.touch-pedals-cluster {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.touch-pedal-btn {
  border-radius: 18px;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  transition: transform 0.08s ease, background 0.08s ease, border-color 0.08s ease;
}

.pedal-ribs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 58%;
  margin-top: 4px;
}

.pedal-ribs span {
  height: 3px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 2px;
}

.touch-pedal-btn.btn-gas {
  width: 86px;
  height: 104px;
  padding: 10px 6px;
  background: linear-gradient(180deg, rgba(24, 38, 52, 0.92), rgba(12, 20, 30, 0.98));
  border: 2.5px solid rgba(46, 204, 113, 0.55);
}

.touch-pedal-btn.btn-gas .pedal-icon {
  font-size: 24px;
  color: var(--accent-green);
  line-height: 1;
}

.touch-pedal-btn.btn-gas .pedal-name {
  font-family: 'Rubik', sans-serif;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: var(--accent-green);
}

.touch-pedal-btn.btn-gas:active,
.touch-pedal-btn.btn-gas.pressed {
  background: linear-gradient(180deg, rgba(46, 204, 113, 0.35), rgba(16, 32, 24, 0.98));
  border-color: var(--accent-green);
  box-shadow: 0 2px 14px rgba(46, 204, 113, 0.65), inset 0 0 14px rgba(46, 204, 113, 0.3);
  transform: translateY(4px) scale(0.97);
}

.touch-pedal-btn.btn-brake {
  width: 78px;
  height: 88px;
  padding: 8px 6px;
  background: linear-gradient(180deg, rgba(38, 24, 30, 0.92), rgba(20, 12, 16, 0.98));
  border: 2.5px solid rgba(231, 76, 60, 0.5);
}

.touch-pedal-btn.btn-brake .pedal-icon {
  font-size: 20px;
  line-height: 1;
}

.touch-pedal-btn.btn-brake .pedal-name {
  font-family: 'Rubik', sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #ff7675;
  text-align: center;
  line-height: 1.1;
}

.touch-pedal-btn.btn-brake:active,
.touch-pedal-btn.btn-brake.pressed {
  background: linear-gradient(180deg, rgba(231, 76, 60, 0.35), rgba(28, 12, 16, 0.98));
  border-color: #e74c3c;
  box-shadow: 0 2px 14px rgba(231, 76, 60, 0.65), inset 0 0 14px rgba(231, 76, 60, 0.3);
  transform: translateY(4px) scale(0.97);
}

/* Modals */
.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 10, 18, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.show {
  display: flex;
}

.modal-card {
  background: #151c28;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  max-width: 540px;
  width: 90%;
  /* Keep long content (breakdown + history) reachable on short screens */
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
}

@keyframes modalPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.trophy-badge {
  font-size: 54px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 20px rgba(241, 196, 15, 0.5));
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #fff;
  margin-bottom: 8px;
}

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

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}

.result-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 14px;
}

.result-number {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.result-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.result-box.eco-box .result-number {
  color: var(--accent-green);
}

.modal-footer {
  display: flex;
  gap: 14px;
  justify-content: center;
}

/* --- Map Select --- */
.map-select-card {
  max-width: 920px;
}

.map-select-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
  text-align: left;
}

.map-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  color: var(--text-main);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  font: inherit;
  text-align: left;
}

.map-card:hover {
  border-color: rgba(0, 210, 211, 0.45);
  transform: translateY(-2px);
}

.map-card.selected {
  border-color: var(--electric-cyan);
  box-shadow: 0 0 0 1px rgba(0, 210, 211, 0.35), 0 10px 28px rgba(0, 210, 211, 0.18);
  background: rgba(0, 210, 211, 0.08);
}

.map-card-icon {
  font-size: 32px;
  margin-bottom: 8px;
  line-height: 1;
}

.map-card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
}

.map-card-blurb {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
  min-height: 34px;
}

.map-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--electric-cyan);
}

.map-card-record {
  color: var(--warning-amber);
  font-variant-numeric: tabular-nums;
}

.tod-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: -6px 0 22px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}

.tod-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  white-space: nowrap;
}

.tod-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1;
  max-width: 320px;
  margin-left: auto;
}

.tod-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-main);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.tod-btn:hover {
  border-color: rgba(0, 210, 211, 0.4);
}

.tod-btn.selected[data-tod="day"] {
  border-color: #f1c40f;
  background: rgba(241, 196, 15, 0.14);
  box-shadow: 0 0 0 1px rgba(241, 196, 15, 0.25);
}

.tod-btn.selected[data-tod="night"] {
  border-color: #7aa2ff;
  background: rgba(74, 108, 196, 0.22);
  box-shadow: 0 0 0 1px rgba(122, 162, 255, 0.3);
}

.tod-btn.selected[data-weather="clear"] {
  border-color: #5dade2;
  background: rgba(93, 173, 226, 0.14);
  box-shadow: 0 0 0 1px rgba(93, 173, 226, 0.28);
}

.tod-btn.selected[data-weather="rain"] {
  border-color: #7f8c8d;
  background: rgba(127, 140, 141, 0.2);
  box-shadow: 0 0 0 1px rgba(149, 165, 166, 0.35);
}

.map-select-card.tod-night .modal-subtitle {
  color: #9bb0d4;
}

@media (max-width: 640px) {
  .tod-picker {
    flex-direction: column;
    align-items: stretch;
  }

  .tod-toggle {
    max-width: none;
    margin-left: 0;
  }
}

.history-map {
  font-size: 11px;
  font-weight: 700;
  color: var(--electric-cyan);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

@media (max-width: 900px) {
  .map-select-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .map-select-grid {
    grid-template-columns: 1fr;
  }
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-green), #27ae60);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  padding: 14px 26px;
  font-family: 'Rubik', sans-serif;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 24px rgba(46, 204, 113, 0.4);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(46, 204, 113, 0.6);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  color: #fff;
  padding: 14px 24px;
  font-family: 'Rubik', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

/* Help Modal Specifics */
.help-card {
  text-align: left;
}

.help-card h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 20px;
  color: #fff;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}

.help-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.help-section {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.help-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--electric-cyan);
  color: #0f141c;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.help-section strong {
  display: block;
  font-size: 14px;
  color: #fff;
  margin-bottom: 3px;
}

.help-section p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.full-width {
  width: 100%;
}

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE HUD OPTIMIZATION (УСТРАНЕНИЕ ПЕРЕГРУЗКИ ЭКРАНА)
   ========================================================================== */

/* Tablets, iPads, and touch laptops / mobile devices */
@media (max-width: 1024px), (pointer: coarse) {
  .mobile-controls {
    display: flex;
  }
  .brand-card {
    display: none !important;
  }
  .hud-top {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 8px;
    align-items: center;
  }
  .task-card {
    order: 1;
    padding: 6px 12px;
    gap: 8px;
    max-width: none;
    flex: 1;
    background: rgba(15, 23, 42, 0.65);
    border-radius: 20px;
    border-left: 2px solid var(--electric-cyan);
  }
  .task-label {
    display: none;
  }
  .task-icon {
    font-size: 18px;
  }
  .task-text {
    font-size: 12px;
    max-width: 220px;
  }
  .gps-pointer {
    padding: 3px 8px;
    gap: 4px;
    border-radius: 12px;
  }
  .gps-distance {
    font-size: 11px;
  }
  .stats-card {
    padding: 6px 10px;
    gap: 8px;
    background: rgba(15, 23, 42, 0.65);
    border-radius: 20px;
  }
  .stat-group {
    gap: 2px;
  }
  .stat-row {
    font-size: 10px;
    gap: 6px;
  }
  .stat-label {
    font-size: 9px;
    letter-spacing: 0.2px;
  }
  .progress-bar-bg {
    display: none; /* Keep clean numerical readout */
  }
  .stat-value {
    font-size: 12px;
    font-weight: 800;
  }
  .eco-score-badge {
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 10px;
  }
  .hud-controls-group {
    gap: 5px;
  }
  .hud-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
    border-radius: 17px;
    background: rgba(15, 23, 42, 0.65);
  }
  #helpBtn {
    display: none; /* Self-explanatory controls on touch */
  }
  .unstuck-key-hint {
    display: none !important;
  }
  .hud-controls-hint {
    display: none !important;
  }
  .action-prompt {
    display: none !important; /* Right thumb button handles actions seamlessly */
  }
  .hydraulic-status {
    display: none !important;
  }
  .touch-cluster-title {
    display: none !important;
  }
  .minimap-legend {
    display: none !important;
  }
  .minimap-container {
    top: 54px;
    right: 8px;
    width: 72px;
    height: 72px;
    padding: 2px;
    border-radius: 50%;
    border: 1.5px solid rgba(0, 210, 211, 0.4);
    background: rgba(15, 23, 42, 0.65);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  }
  #minimapCanvas {
    width: 68px;
    height: 68px;
    border-radius: 50%;
  }
  .hud-bottom-left {
    bottom: 92px;
    left: 10px;
  }
  .speedometer-card {
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.5);
    gap: 5px;
    /* Никаких жёстких лимитов — сжимаемся по контенту и клипуем нутро */
    width: auto;
    min-width: 200px;
    max-width: 260px;
    overflow: hidden;
    box-sizing: border-box;
  }
  .ev-energy-cluster {
    min-width: 0;
    width: 100%;
    overflow: hidden;
  }
  .battery-progress-bg,
  .power-track,
  .charging-status {
    width: 100%;
    box-sizing: border-box;
  }
  .speed-value {
    font-size: 18px;
  }
  .speed-unit {
    font-size: 8px;
  }
  .gear-tag {
    font-size: 10px;
    padding: 1px 4px;
  }
}

/* Narrow viewports (<= 900px): drop the duplicated cargo-weight badge from the
   stats card — the very same value already lives in the "В кузове" row, and the
   mirrored mass card under the speedometer. Removing both keeps mobile HUD quiet. */
@media (max-width: 900px) {
  .stats-card .eco-score-badge:not(.best-time-badge) {
    display: none;
  }
  .cargo-mass-card {
    display: none;
  }
}

/* Same de-duplication whenever the on-screen touch pad is enabled (wide tablets). */
body.touch-mode-active .stats-card .eco-score-badge:not(.best-time-badge) {
  display: none;
}
body.touch-mode-active .cargo-mass-card {
  display: none;
}

/* Mobile Landscape Orientation (Smartphones held horizontally) */
@media (max-height: 520px) {
  .hud-top {
    top: 5px;
    /* Notch-aware gutters */
    left: max(6px, env(safe-area-inset-left));
    right: max(6px, env(safe-area-inset-right));
    gap: 6px;
  }
  .task-card, .stats-card {
    padding: 3px 8px;
  }

  /* --- Top bar: objective card must never overflow into the minimap --- */
  .task-card {
    min-width: 0;          /* allow the flex child to actually shrink */
    max-width: 240px;
    font-size: 11px;
    gap: 6px;
    /* keep a clear 10px gap before the minimap radar (60px + 6px gutters) */
    margin-right: 76px;
  }
  .task-text {
    font-size: 11px;
    line-height: 1.15;
    /* wrap instead of spilling past the viewport edge */
    white-space: normal;
    overflow: hidden;
    text-overflow: clip;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    max-width: none;
  }
  .task-icon {
    font-size: 15px;
  }
  .gps-pointer {
    padding: 2px 6px;
    gap: 3px;
  }
  .gps-distance {
    font-size: 10px;
  }
  .gps-arrow {
    font-size: 12px;
  }

  /* Stats card: shrink to content and drop the duplicated weight badge
     (the same figure is already shown in the "В кузове" row above). */
  .stats-card {
    flex-shrink: 0;
    min-width: 0;
  }
  .stats-card .eco-score-badge:not(.best-time-badge) {
    display: none;
  }

  /* --- System buttons: compact 32px pills, tighter gap --- */
  .hud-controls-group {
    gap: 4px;
    flex-shrink: 0;
  }
  .hud-btn {
    width: 32px;
    height: 32px;
    font-size: 13px;
    border-radius: 16px;
  }

  /* --- Left EV cluster: shrink to free vertical room --- */
  .hud-bottom-left {
    bottom: 74px;
    left: max(8px, env(safe-area-inset-left));
    transform: scale(0.82);
    transform-origin: bottom left;
  }
  .speedometer-card {
    width: auto;
    min-width: 200px;
    max-width: 260px;
    overflow: hidden;
    box-sizing: border-box;
  }
  .ev-energy-cluster {
    min-width: 0;
    width: 100%;
    overflow: hidden;
  }
  .battery-progress-bg,
  .power-track {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }
  .charging-status {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* Компактнее, чтобы «ИДЕТ ЗАРЯДКА MACK EV ⚡ (+150 kW)» помещалось в строку */
    font-size: 9px;
    letter-spacing: 0.2px;
    padding: 3px 6px;
    margin-top: 4px;
  }
  .charging-status-icon {
    font-size: 10px;
  }
  /* Weight is duplicated in the status card — drop the mirrored badge */
  .cargo-mass-card {
    display: none;
  }

  /* --- Right thumb cluster: lift the action row clear of the pedals --- */
  .mobile-controls {
    bottom: 6px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  .touch-pedal-zone {
    gap: 6px;
  }
  .touch-actions-row {
    margin-bottom: 0;
    gap: 6px;
  }
  .touch-primary-action-btn {
    max-height: 48px;
    height: 44px;
    padding: 8px 14px;
    font-size: 12px;
    border-radius: 22px;
  }
  .touch-primary-action-btn .btn-icon {
    font-size: 15px;
  }
  .touch-quick-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }
  .touch-pedal-btn.btn-gas {
    width: 68px;
    height: 76px;
  }
  .touch-pedal-btn.btn-brake {
    width: 62px;
    height: 66px;
  }
  .touch-steer-btn {
    width: 62px;
    height: 56px;
  }
  .minimap-container {
    top: 44px;
    right: max(6px, env(safe-area-inset-right));
    width: 60px;
    height: 60px;
  }
  #minimapCanvas {
    width: 56px;
    height: 56px;
  }
}

/* Small portrait screens (Smartphones held vertically) */
@media (max-width: 540px) and (min-height: 521px) {
  .hud-top {
    flex-wrap: wrap;
    gap: 6px;
  }
  .task-card {
    width: 100%;
    order: 2;
  }
  .stats-card {
    order: 1;
    flex: 1;
  }
  .hud-controls-group {
    order: 1;
  }
  .minimap-container {
    top: 92px;
  }
  .touch-steer-btn {
    width: 64px;
    height: 60px;
  }
  .touch-pedal-btn.btn-gas {
    width: 66px;
    height: 80px;
  }
  .touch-pedal-btn.btn-brake {
    width: 60px;
    height: 70px;
  }
}

/* ==========================================================================
   TRASH PICKUP CUTSCENE OVERLAY (ЗАГЛУШКА ЗАБОРА МУСОРА)
   ========================================================================== */
.pickup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(6, 10, 18, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 10px;
  box-sizing: border-box;
  animation: fadeIn 0.2s ease-out;
}

.pickup-overlay.show {
  display: flex;
}

.pickup-window {
  width: min(94vw, 680px, calc((92vh - 78px) * (16 / 9)));
  max-width: 680px;
  max-height: 94vh;
  margin: auto;
  background: #111722;
  border: 2px solid var(--electric-cyan);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0, 210, 211, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: windowPop 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes windowPop {
  0% { transform: scale(0.88); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.pickup-header {
  padding: 10px 16px;
  background: rgba(20, 28, 42, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Outfit', sans-serif;
  gap: 8px;
  flex-shrink: 0;
}

.rec-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e74c3c;
  box-shadow: 0 0 10px #e74c3c;
  animation: recBlink 1s infinite alternate;
  flex-shrink: 0;
}

@keyframes recBlink {
  0% { opacity: 0.25; }
  100% { opacity: 1; }
}

.pickup-telemetry {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-green);
  letter-spacing: 0.8px;
  font-family: 'Outfit', monospace;
  white-space: nowrap;
  flex-shrink: 0;
}

.pickup-canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: calc(92vh - 78px);
  background: #0f1622;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pickupCanvas,
#unloadCanvas,
#pickupVideo {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  display: block;
}

.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  opacity: 0.65;
}

.pickup-status-overlay {
  position: absolute;
  bottom: 12px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.pickup-status-text {
  background: rgba(15, 20, 28, 0.88);
  border: 1px solid var(--electric-cyan);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 800;
  color: var(--electric-cyan);
  letter-spacing: 0.5px;
  box-shadow: 0 4px 15px rgba(0, 210, 211, 0.3);
}

.pickup-footer {
  padding: 10px 16px;
  background: rgba(20, 28, 42, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pickup-gauge {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.gauge-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.gauge-val {
  font-size: 15px;
  font-weight: 900;
  color: var(--accent-green);
  font-family: 'Outfit', sans-serif;
}

.pickup-skip-hint {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.pickup-skip-hint kbd {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
}

.mobile-hint {
  display: none;
}
.desktop-hint {
  display: inline;
}

@media (hover: none) and (pointer: coarse), (max-width: 768px) {
  .mobile-hint {
    display: inline;
  }
  .desktop-hint {
    display: none;
  }
}

/* ==========================================================================
   FACTORY UNLOAD CUTSCENE OVERLAY (ВЫГРУЗКА ВТОРСЫРЬЯ НА ЗАВОДЕ)
   ========================================================================== */
.unload-window {
  border-color: #2ecc71;
  box-shadow: 0 20px 60px rgba(46, 204, 113, 0.45);
}

.unload-header {
  background: rgba(14, 30, 22, 0.96);
  border-bottom: 1px solid rgba(46, 204, 113, 0.25);
}

.green-dot {
  background: #2ecc71;
  box-shadow: 0 0 12px #2ecc71;
  animation: recBlinkGreen 1s infinite alternate;
}

@keyframes recBlinkGreen {
  0% { opacity: 0.25; }
  100% { opacity: 1; }
}

.green-telemetry {
  color: #2ecc71;
  font-weight: 800;
  text-shadow: 0 0 8px rgba(46, 204, 113, 0.4);
}

.unload-status-badge {
  border-color: #2ecc71;
  color: #2ecc71;
  box-shadow: 0 4px 18px rgba(46, 204, 113, 0.4);
}

.unload-footer {
  background: rgba(14, 30, 22, 0.96);
  border-top: 1px solid rgba(46, 204, 113, 0.25);
}

.green-val {
  color: #2ecc71;
  text-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

/* Landscape Phones & Short Screens (max-height: 520px) */
@media (max-height: 520px) {
  .pickup-overlay {
    padding: 6px;
  }
  .pickup-window {
    width: min(94vw, 560px, calc((92vh - 56px) * (16 / 9)));
    border-radius: var(--radius-md);
  }
  .pickup-canvas-wrapper {
    max-height: calc(92vh - 56px);
  }
  .pickup-header {
    padding: 5px 10px;
  }
  .rec-indicator {
    font-size: 11px;
    gap: 6px;
  }
  .rec-dot {
    width: 8px;
    height: 8px;
  }
  .pickup-telemetry {
    font-size: 10px;
  }
  .pickup-footer {
    padding: 5px 10px;
  }
  .gauge-label {
    font-size: 10px;
  }
  .gauge-val {
    font-size: 13px;
  }
  .pickup-skip-hint {
    font-size: 10px;
  }
  .pickup-status-overlay {
    bottom: 6px;
    left: 8px;
  }
  .pickup-status-text {
    padding: 3px 8px;
    font-size: 10px;
  }
}

/* Portrait Phones & Narrow Screens (max-width: 540px) */
@media (max-width: 540px) {
  .pickup-overlay {
    padding: 8px;
  }
  .pickup-window {
    width: 95vw;
    border-radius: var(--radius-md);
  }
  .pickup-header {
    padding: 7px 10px;
    gap: 4px;
  }
  .rec-indicator {
    font-size: 10px;
    max-width: 56%;
  }
  .rec-dot {
    width: 7px;
    height: 7px;
  }
  .pickup-telemetry {
    font-size: 9px;
  }
  .pickup-footer {
    padding: 7px 10px;
    gap: 6px;
  }
  .gauge-label {
    font-size: 9px;
  }
  .gauge-val {
    font-size: 12px;
  }
  .pickup-skip-hint {
    font-size: 10px;
  }
  .pickup-status-overlay {
    bottom: 6px;
    left: 8px;
  }
  .pickup-status-text {
    padding: 3px 8px;
    font-size: 10px;
  }
}

/* ==========================================================================
   Modernized Systems: Waste Sorting Badges & Career Meta-Progression
   ========================================================================== */

/* Pickup Camera Waste Recognition Badge */
.pickup-category-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  transition: all 0.2s ease;
}

.pickup-category-badge.cat-yellow {
  border-color: #f1c40f;
  background: rgba(241, 196, 15, 0.16);
  box-shadow: 0 0 10px rgba(241, 196, 15, 0.35);
}

.pickup-category-badge.cat-blue {
  border-color: #3498db;
  background: rgba(52, 152, 219, 0.16);
  box-shadow: 0 0 10px rgba(52, 152, 219, 0.35);
}

.pickup-category-badge.cat-green {
  border-color: #2ecc71;
  background: rgba(46, 204, 113, 0.16);
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.35);
}

/* Modal Sections */
.modal-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 14px;
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.new-record-pill {
  background: linear-gradient(135deg, #f1c40f, #e67e22);
  color: #1a1a1a;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 0 12px rgba(241, 196, 15, 0.6);
  animation: pulsePill 0.8s infinite alternate;
}

@keyframes pulsePill {
  0% { transform: scale(0.95); }
  100% { transform: scale(1.05); }
}

.sorting-breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.sort-badge-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: left;
}

.sort-badge-card.sort-yellow { border-left: 3px solid #f1c40f; }
.sort-badge-card.sort-blue { border-left: 3px solid #3498db; }
.sort-badge-card.sort-green { border-left: 3px solid #2ecc71; }

.sort-badge-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.sort-badge-info {
  display: flex;
  flex-direction: column;
}

.sort-badge-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.2;
}

.sort-badge-val {
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
}

.records-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.record-box {
  background: rgba(0, 210, 211, 0.05);
  border: 1px solid rgba(0, 210, 211, 0.15);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  text-align: center;
}

.record-val {
  font-family: 'Outfit', monospace;
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 2px;
}

.record-val.highlight {
  color: var(--electric-cyan);
  text-shadow: 0 0 10px var(--electric-glow);
}

.record-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Route History Log (LocalStorage) */
.history-hint {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
  margin-bottom: 20px;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.history-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 18px 10px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}

.history-row {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--electric-cyan);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
}

.history-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.history-index {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 900;
  color: var(--electric-cyan);
}

.history-date {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.history-time {
  font-family: 'Outfit', monospace;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
}

.history-row-body {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.history-mat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
}

.mat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.mat-yellow { background: #f1c40f; box-shadow: 0 0 6px rgba(241, 196, 15, 0.7); }
.mat-blue { background: #3498db; box-shadow: 0 0 6px rgba(52, 152, 219, 0.7); }
.mat-green { background: #2ecc71; box-shadow: 0 0 6px rgba(46, 204, 113, 0.7); }

@media (max-width: 640px) {
  .sorting-breakdown-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .records-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .speedometer-card {
    min-width: 200px;
    padding: 6px 10px;
    gap: 8px;
  }
  .ev-energy-cluster {
    min-width: 120px;
  }
}

/* ==========================================================================
   Battery Depletion Blackout — Эвакуация при 0% заряда
   ========================================================================== */
.battery-blackout {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 130;
  opacity: 0;
  pointer-events: none;
  /* Smooth fade-to-black: 0.8s as required by the evacuation spec. */
  transition: opacity 0.8s ease;
}

.battery-blackout.show {
  opacity: 1;
  pointer-events: auto;
}

.battery-blackout-inner {
  text-align: center;
  font-family: 'Outfit', monospace;
  color: #f5f6fa;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.55s ease 0.2s, transform 0.55s ease 0.2s;
}

.battery-blackout.show .battery-blackout-inner {
  opacity: 1;
  transform: translateY(0);
}

.battery-blackout-icon {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 14px;
  filter: drop-shadow(0 0 18px rgba(231, 76, 60, 0.6));
}

.battery-blackout-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #e74c3c;
  text-shadow: 0 0 18px rgba(231, 76, 60, 0.5);
}

.battery-blackout-sub {
  margin-top: 8px;
  font-size: 14px;
  letter-spacing: 1px;
  color: #95a5a6;
}

.battery-blackout-progress {
  margin: 22px auto 0;
  width: 220px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.battery-blackout-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #e74c3c, #f39c12, #2ecc71);
  transition: width 2.5s linear;
}

.battery-blackout.show .battery-blackout-progress span {
  width: 100%;
}

/* ==========================================================================
   Low Battery Alert — пульсация критического заряда (≤15%)
   ========================================================================== */
@keyframes criticalPulse {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 6px rgba(231, 76, 60, 0.8)); }
  50% { opacity: 0.45; }
}

.battery-critical-pulse {
  animation: criticalPulse 0.9s infinite ease-in-out;
  color: #e74c3c !important;
}
