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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #131926;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: #f8fafc;
}

#game-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}

#game-container canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hidden {
  display: none !important;
}

/* --- HUD Panels --- */
.hud-panel {
  position: fixed;
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  z-index: 20;
}

#hud-left {
  top: 12px;
  left: 12px;
  width: 288px;
  padding: 10px 12px;
}

.hud-top-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.clock-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.clock-sub {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  background: rgba(245, 158, 11, 0.22);
  color: #fcd34d;
  white-space: nowrap;
}

.rush-badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 99px;
  background: linear-gradient(135deg, #ef4444, #f97316);
  color: #fff;
  white-space: nowrap;
  animation: pulseBadge 1s infinite alternate;
}

@keyframes pulseBadge {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.hud-stats {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr 0.85fr;
  gap: 6px;
  margin-bottom: 8px;
}

.stat-box {
  background: rgba(30, 41, 59, 0.85);
  border-radius: 8px;
  padding: 5px 7px;
  display: flex;
  flex-direction: column;
}

.stat-lbl {
  font-size: 10px;
  color: #94a3b8;
}

.stat-val {
  font-size: 13px;
  font-weight: 800;
  margin-top: 1px;
}

.cash-pos { color: #4ade80; }
.cash-neg { color: #f87171; }
.star-val { color: #fbbf24; }

.gauge-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.gauge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.gauge-lbl {
  width: 56px;
  color: #cbd5e1;
  font-weight: 700;
}

.gauge-track {
  flex: 1;
  height: 9px;
  background: #1e293b;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.gauge-fill {
  height: 100%;
  background: #22c55e;
  transition: width 0.15s ease;
}

.fuel-fill {
  background: #38bdf8;
}

.gauge-num {
  width: 34px;
  text-align: right;
  font-weight: 700;
  font-size: 11px;
}

.hud-bottom-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.speedo {
  display: flex;
  align-items: baseline;
  gap: 3px;
  background: #0f172a;
  padding: 3px 9px;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.speedo strong {
  font-size: 18px;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
}

.speedo span {
  font-size: 10px;
  color: #94a3b8;
}

.mini-btn {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.mini-btn:hover {
  background: #334155;
}

/* --- Top-Center Turn-by-Turn Nav --- */
#nav-wrap {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
}

.nav-banner {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 310px;
  max-width: 440px;
  padding: 9px 14px;
  border-radius: 13px;
  background: rgba(15, 23, 42, 0.92);
  border: 2px solid #38bdf8;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

.nav-banner[data-mode="pickup"] {
  border-color: #fbbf24;
}

.nav-banner[data-mode="deliver"] {
  border-color: #34d399;
}

.nav-banner.nav-idle {
  border-color: rgba(148, 163, 184, 0.45);
}

.nav-arrow {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  flex-shrink: 0;
}

.nav-banner[data-mode="pickup"] .nav-arrow {
  background: rgba(251, 191, 36, 0.22);
  color: #fde047;
}

.nav-banner[data-mode="deliver"] .nav-arrow {
  background: rgba(52, 211, 153, 0.22);
  color: #6ee7b7;
}

.nav-line1 {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.nav-dist {
  font-size: 16px;
  font-weight: 900;
  color: #ffffff;
}

.nav-text {
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
}

.nav-target {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

.wrong-way {
  background: #dc2626;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 99px;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.5);
  animation: pulseBadge 0.45s infinite alternate;
}

/* --- Top-Right Minimap --- */
#minimap-panel {
  top: 12px;
  right: 12px;
  padding: 7px 8px 8px;
}

.mm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 5px;
  color: #cbd5e1;
}

.mm-legend {
  font-size: 10px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 5px;
}

.dot-rep, .dot-gas {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.dot-rep { background: #38bdf8; }
.dot-gas { background: #fb923c; }

#minimap-canvas {
  display: block;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

/* --- Smartphone Delivery App (Bottom-Right) --- */
#phone-frame {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: 268px;
  max-height: calc(100vh - 246px);
  display: flex;
  flex-direction: column;
  background: #0b1120;
  border: 3px solid #334155;
  border-radius: 22px;
  padding: 8px 10px 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65);
  z-index: 25;
  overflow: hidden;
}

.phone-notch {
  width: 58px;
  height: 5px;
  background: #334155;
  border-radius: 99px;
  margin: 0 auto 6px;
}

.phone-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.phone-app-name {
  font-size: 13px;
  font-weight: 900;
  color: #38bdf8;
}

.phone-bag {
  font-size: 11px;
  color: #cbd5e1;
  background: #1e293b;
  padding: 2px 7px;
  border-radius: 99px;
}

.phone-sec-title {
  font-size: 10px;
  font-weight: 800;
  color: #94a3b8;
  margin: 6px 0 4px;
  letter-spacing: 0.3px;
}

.phone-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
}

.phone-empty {
  text-align: center;
  font-size: 11px;
  color: #64748b;
  padding: 7px 4px;
  background: rgba(30, 41, 59, 0.45);
  border-radius: 8px;
}

.active-card {
  background: #1e293b;
  border: 1.5px solid #334155;
  border-radius: 9px;
  padding: 6px 8px;
  cursor: pointer;
}

.active-card.focused {
  border-color: #34d399;
  background: rgba(20, 83, 45, 0.3);
}

.ac-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  gap: 4px;
}

.stage-badge {
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 5px;
  white-space: nowrap;
}
.stage-pick { background: #f59e0b; color: #0f172a; }
.stage-deliv { background: #10b981; color: #052e16; }

.ac-sub {
  font-size: 10px;
  color: #94a3b8;
  margin: 2px 0 4px;
}

.ac-meters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
}

.meter-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 5px;
}

.mini-bar {
  flex: 1;
  height: 6px;
  background: #0f172a;
  border-radius: 99px;
  overflow: hidden;
}

.mini-bar > div {
  height: 100%;
}

.ac-time {
  font-weight: 800;
  color: #e2e8f0;
  white-space: nowrap;
}
.ac-time.t-warn { color: #fbbf24; }
.ac-time.t-late { color: #f87171; }

.call-card {
  background: #172033;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 9px;
  padding: 6px 7px;
  position: relative;
  overflow: hidden;
}

.call-card.call-rush {
  border-color: #f97316;
  background: rgba(124, 45, 18, 0.26);
}

.call-ttl {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2.5px;
  background: rgba(255, 255, 255, 0.08);
}

.call-ttl > div {
  height: 100%;
  background: #38bdf8;
}

.call-head {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}

.key-pill {
  background: #38bdf8;
  color: #082f49;
  font-size: 10px;
  font-weight: 900;
  width: 17px;
  height: 17px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.food-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
}
.tag-soup { background: rgba(239, 68, 68, 0.25); color: #fca5a5; }
.tag-pizza { background: rgba(234, 179, 8, 0.25); color: #fde047; }
.tag-dessert { background: rgba(56, 189, 248, 0.25); color: #7dd3fc; }
.tag-normal { background: rgba(148, 163, 184, 0.25); color: #e2e8f0; }

.call-fare {
  margin-left: auto;
  font-size: 12px;
  font-weight: 900;
  color: #4ade80;
}

.btn-reject {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  padding: 0 3px;
}
.btn-reject:hover { color: #f87171; }

.call-route {
  font-size: 11px;
  color: #e2e8f0;
  margin-bottom: 5px;
}

.call-meta {
  font-size: 9.5px;
  color: #94a3b8;
  margin-top: 1px;
}

.btn-accept {
  width: 100%;
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.btn-accept:hover:not(:disabled) { background: #0ea5e9; }
.btn-accept:disabled {
  background: #334155;
  color: #94a3b8;
  cursor: not-allowed;
}

/* --- Toasts --- */
#toast-stack {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 40;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  padding: 7px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 700;
  border-left: 4px solid #38bdf8;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s, transform 0.25s;
}
.toast-good { border-left-color: #22c55e; }
.toast-warn { border-left-color: #f59e0b; }
.toast-danger { border-left-color: #ef4444; background: rgba(69, 10, 10, 0.94); }
.toast-rush { border-left-color: #f97316; background: rgba(124, 45, 18, 0.95); }
.toast-out { opacity: 0; transform: translateY(-8px); }

/* --- Police Stop Overlay --- */
.police-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(127, 29, 29, 0.32);
  z-index: 45;
  pointer-events: none;
}

.police-card {
  background: rgba(15, 23, 42, 0.95);
  border: 2.5px solid #ef4444;
  border-radius: 16px;
  padding: 18px 26px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
}

.police-siren {
  font-size: 18px;
  font-weight: 900;
  color: #f87171;
  margin-bottom: 6px;
}

.police-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 12px;
}

.police-stats span {
  display: block;
  font-size: 11px;
  color: #94a3b8;
}

.police-stats strong {
  font-size: 20px;
  color: #fef08a;
}

/* --- Key Hints & Touch --- */
#key-hints {
  position: fixed;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(15, 23, 42, 0.78);
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 11px;
  color: #cbd5e1;
  z-index: 18;
}

#key-hints kbd {
  background: #334155;
  color: #f8fafc;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
  font-family: inherit;
  font-weight: 800;
}

#touch-controls {
  display: none;
  position: fixed;
  left: 14px;
  right: 290px;
  bottom: 14px;
  justify-content: space-between;
  z-index: 30;
  pointer-events: none;
}

.tc-left, .tc-right {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.tc-btn {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}
.tc-gas { background: rgba(34, 197, 94, 0.75); }
.tc-brk { background: rgba(239, 68, 68, 0.75); width: 68px; }

@media (pointer: coarse) {
  #touch-controls { display: flex; }
  #key-hints { display: none; }
}

/* --- Modals (Start & Settlement) --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  background: #0f172a;
  border: 2px solid rgba(56, 189, 248, 0.45);
  border-radius: 18px;
  padding: 24px 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

.story-tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  padding: 4px 10px;
  border-radius: 99px;
  margin-bottom: 10px;
}

.start-card h1 {
  font-size: 24px;
  margin-bottom: 10px;
}

.story-lead {
  font-size: 13.5px;
  line-height: 1.6;
  color: #cbd5e1;
  margin-bottom: 16px;
}

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

.rules-grid > div {
  background: #1e293b;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #cbd5e1;
}

.primary-btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.45);
}

.primary-btn:hover {
  filter: brightness(1.08);
}

/* Settlement Modal */
.settle-title {
  font-size: 21px;
  margin-bottom: 4px;
}

.settle-sub {
  font-size: 12.5px;
  color: #94a3b8;
  margin-bottom: 14px;
}

.settle-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.settle-kpis > div {
  background: #1e293b;
  border-radius: 10px;
  padding: 8px;
  text-align: center;
}

.settle-kpis span {
  display: block;
  font-size: 10.5px;
  color: #94a3b8;
}

.settle-kpis strong {
  font-size: 15px;
  color: #f8fafc;
}

.settle-ledger {
  background: #172033;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.ledger-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
}

.ledger-row .pos { color: #4ade80; font-weight: 800; }
.ledger-row .neg { color: #f87171; font-weight: 700; }

.ledger-divider {
  height: 1px;
  background: rgba(148, 163, 184, 0.2);
  margin: 7px 0;
}

.ledger-total {
  display: flex;
  justify-content: space-between;
  font-size: 17px;
  font-weight: 900;
  padding-top: 2px;
}

.settle-pos { color: #4ade80; }
.settle-neg { color: #f87171; }

.goal-box {
  background: #1e293b;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.goal-head {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  margin-bottom: 6px;
}

.goal-track {
  height: 11px;
  background: #0f172a;
  border-radius: 99px;
  overflow: hidden;
}

.goal-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #22c55e);
  transition: width 0.5s ease;
}
