:root {
  color-scheme: dark;
  --ink: #17202a;
  --paper: #fff8e8;
  --panel: rgba(18, 31, 36, 0.78);
  --line: rgba(255, 255, 255, 0.22);
  --gold: #ffd05a;
  --teal: #25c6b2;
  --red: #ff574d;
  --night: #152127;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #20343a;
}

button {
  appearance: none;
  border: 0;
  font: inherit;
  color: var(--paper);
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 240px;
  background: #20343a;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  top: max(14px, var(--safe-area-inset-top, env(safe-area-inset-top)));
  left: max(14px, var(--safe-area-inset-left, env(safe-area-inset-left)));
  right: max(14px, var(--safe-area-inset-right, env(safe-area-inset-right)));
  display: grid;
  grid-template-columns: 1.05fr repeat(4, minmax(74px, 0.72fr)) auto auto;
  gap: 8px;
  align-items: stretch;
  pointer-events: none;
}

.hud div,
.hud button,
.status {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.18);
}

.hud div {
  min-height: 58px;
  padding: 8px 10px;
  border-radius: var(--radius);
}

.hud .brand {
  background: linear-gradient(135deg, rgba(26, 54, 54, 0.9), rgba(151, 78, 48, 0.82));
}

.hud span {
  display: block;
  color: rgba(255, 248, 232, 0.72);
  font-size: 12px;
  line-height: 1.15;
}

.hud strong {
  display: block;
  margin-top: 4px;
  color: var(--paper);
  font-size: 22px;
  line-height: 1;
}

.brand strong {
  color: var(--gold);
}

.hud button {
  min-width: 82px;
  border-radius: var(--radius);
  padding: 0 14px;
  background: rgba(23, 32, 42, 0.78);
  pointer-events: auto;
  font-weight: 800;
}

#restart {
  background: rgba(239, 86, 70, 0.86);
}

#audio {
  background: rgba(37, 198, 178, 0.78);
}

#pause {
  background: rgba(96, 78, 186, 0.82);
}

#optionsButton {
  background: rgba(225, 143, 47, 0.9);
}

.paint-select,
.car-select,
.level-select,
.language-select {
  min-width: 0;
  padding: 7px 9px;
  border-radius: var(--radius);
  pointer-events: auto;
}

.options-panel[hidden] {
  display: none;
}

.options-panel {
  position: absolute;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding:
    max(18px, var(--safe-area-inset-top, env(safe-area-inset-top)))
    max(18px, var(--safe-area-inset-right, env(safe-area-inset-right)))
    max(18px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom)))
    max(18px, var(--safe-area-inset-left, env(safe-area-inset-left)));
  background: rgba(8, 17, 22, 0.58);
  backdrop-filter: blur(10px);
}

.options-card {
  width: min(720px, 100%);
  max-height: min(620px, 100%);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 24px;
  color: var(--paper);
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 208, 90, 0.16), transparent 32%),
    linear-gradient(155deg, rgba(30, 49, 55, 0.98), rgba(13, 24, 30, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

.options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.options-header h2 {
  margin: 3px 0 0;
  font-size: clamp(24px, 4vw, 34px);
}

.options-eyebrow {
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#optionsClose {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-size: 30px;
  line-height: 1;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 22px 24px;
}

.options-grid label,
.option-best {
  min-height: 74px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.075);
}

.options-grid span {
  display: block;
  margin-bottom: 7px;
  color: rgba(255, 248, 232, 0.66);
  font-size: 12px;
  font-weight: 800;
}

.option-best strong {
  color: var(--gold);
  font-size: 24px;
}

.options-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0 24px 24px;
}

.player-services {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 18px;
  background: rgba(11, 18, 28, 0.5);
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 11px;
}

.service-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
}

.service-card > div:first-child {
  min-width: 0;
}

.service-card strong,
.service-card small {
  display: block;
}

.service-card strong {
  color: #fff6e1;
  font-size: 0.92rem;
}

.service-card small {
  margin-top: 3px;
  color: #aee4d4;
  font-size: 0.67rem;
}

.service-card p {
  grid-column: 1 / -1;
  margin: 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.72rem;
  line-height: 1.35;
}

.service-card > button,
.service-actions button {
  min-width: 0;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: white;
  background: rgba(255, 255, 255, 0.09);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.service-card > button {
  align-self: start;
}

.service-actions {
  display: flex;
  grid-column: 1 / -1;
  gap: 7px;
}

.service-actions button {
  flex: 1;
}

.service-modal {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding:
    max(14px, var(--safe-area-inset-top))
    max(14px, var(--safe-area-inset-right))
    max(14px, var(--safe-area-inset-bottom))
    max(14px, var(--safe-area-inset-left));
  background: rgba(5, 9, 16, 0.76);
  backdrop-filter: blur(14px);
}

.service-modal[hidden] {
  display: none;
}

.service-modal-card {
  width: min(620px, 100%);
  max-height: min(82dvh, 720px);
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(36, 49, 63, 0.98), rgba(12, 20, 31, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
}

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

.service-modal-card h2 {
  margin: 0;
  font-size: clamp(1.2rem, 3vw, 1.7rem);
}

.service-modal-card [data-close-service] {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.4rem;
}

.achievement-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 14px;
}

.achievement-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
}

.achievement-item.is-complete {
  border-color: rgba(255, 202, 84, 0.4);
  background: rgba(255, 185, 55, 0.095);
}

.achievement-medal {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  font-size: 1.2rem;
}

.achievement-item.is-complete .achievement-medal {
  color: #3e2a00;
  background: linear-gradient(145deg, #ffe28b, #f6a928);
}

.achievement-item strong,
.achievement-item small {
  display: block;
}

.achievement-item small {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.62);
  line-height: 1.28;
}

.store-product {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px;
  border: 1px solid rgba(255, 205, 88, 0.34);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(251, 182, 53, 0.16), rgba(255, 255, 255, 0.045));
}

.store-product p,
.store-note {
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.4;
}

.store-product p {
  margin: 5px 0 0;
}

.store-product button,
#platformAchievements {
  min-width: 92px;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  color: #2c1a00;
  background: linear-gradient(145deg, #ffe17a, #f0a92d);
  font-weight: 900;
}

.store-note {
  margin: 13px 2px 0;
  font-size: 0.78rem;
}

html[dir="rtl"] .options-card,
html[dir="rtl"] .service-modal-card,
html[dir="rtl"] .run-summary-card {
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .map-track,
html[dir="rtl"] canvas {
  direction: ltr;
}

html[dir="rtl"] .brand {
  direction: rtl;
}

@media (max-width: 720px) {
  .player-services {
    padding: 10px;
  }

  .achievement-list {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .player-services {
    margin-top: 9px;
  }

  .service-card {
    display: flex;
    min-height: 58px;
    flex-direction: column;
    justify-content: center;
    padding: 7px;
  }

  .service-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-top: 6px;
  }

  .player-services .garage-header,
  .service-card p,
  .service-card small {
    display: none;
  }

  .service-card strong {
    font-size: 0.73rem;
  }

  .service-actions {
    gap: 4px;
  }

  .service-card > button,
  .service-actions button {
    min-height: 27px;
    padding: 4px 5px;
    font-size: 0.62rem;
  }

  .service-modal-card {
    max-height: calc(100dvh - 20px);
    padding: 13px;
  }
}

.options-actions button {
  min-height: 54px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 900;
}

.garage-tuning {
  margin: 0 24px 18px;
  padding: 16px;
  border: 1px solid rgba(255, 208, 90, 0.2);
  border-radius: 18px;
  background:
    radial-gradient(circle at 90% 0%, rgba(255, 208, 90, 0.11), transparent 38%),
    rgba(255, 255, 255, 0.055);
}

.garage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.garage-header span,
.garage-wallet span {
  display: block;
  color: rgba(255, 248, 232, 0.64);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.garage-header h3 {
  margin: 3px 0 0;
  color: var(--paper);
  font-size: 19px;
}

.garage-wallet {
  flex: 0 0 auto;
  min-width: 94px;
  padding: 8px 11px;
  border-radius: 13px;
  text-align: right;
  background: rgba(255, 208, 90, 0.12);
}

.garage-wallet strong {
  display: block;
  margin-top: 2px;
  color: var(--gold);
  font-size: 22px;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.upgrade-button {
  min-height: 76px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  text-align: left;
  background: rgba(13, 24, 30, 0.64);
}

.upgrade-button span,
.upgrade-button strong,
.upgrade-button small {
  display: block;
}

.upgrade-button span {
  color: rgba(255, 248, 232, 0.67);
  font-size: 11px;
  font-weight: 800;
}

.upgrade-button strong {
  margin: 4px 0 3px;
  color: var(--paper);
  font-size: 16px;
}

.upgrade-button small {
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
}

.upgrade-button:disabled {
  cursor: default;
  opacity: 0.52;
}

#upgradeDescription {
  margin: 10px 2px 0;
  color: rgba(255, 248, 232, 0.64);
  font-size: 11px;
  line-height: 1.35;
}

#mapButton {
  background: rgba(225, 143, 47, 0.9);
}

#audio {
  background: rgba(37, 198, 178, 0.78);
}

#restart {
  background: rgba(239, 86, 70, 0.86);
}

.paint-select span,
.car-select span,
.level-select span,
.language-select span {
  margin-bottom: 4px;
}

.paint-select select,
.car-select select,
.level-select select,
.language-select select {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--paper);
  background: transparent;
  font: 800 15px/1.1 inherit;
  cursor: pointer;
}

.paint-select select option,
.car-select select option,
.level-select select option,
.language-select select option {
  color: var(--ink);
  background: var(--paper);
}

.controls {
  position: absolute;
  left: max(16px, var(--safe-area-inset-left, env(safe-area-inset-left)));
  right: max(16px, var(--safe-area-inset-right, env(safe-area-inset-right)));
  bottom: max(18px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));
  display: flex;
  justify-content: space-between;
  gap: clamp(28px, 18vw, 260px);
  pointer-events: none;
}

.control-cluster {
  display: grid;
  grid-template-columns: minmax(104px, 1.25fr) minmax(76px, 0.82fr);
  gap: 10px;
  width: min(39vw, 420px);
  pointer-events: none;
}

.control-cluster-right {
  grid-template-columns: minmax(76px, 0.82fr) minmax(104px, 1.25fr);
}

.controls button {
  min-height: 60px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(23, 32, 42, 0.72);
  backdrop-filter: blur(10px);
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto auto;
  place-content: center;
  align-items: center;
  gap: 8px;
  transition: transform 80ms ease, background 80ms ease, box-shadow 80ms ease;
}

.controls button:active,
.controls button.is-down {
  transform: translateY(1px);
  background: rgba(37, 198, 178, 0.84);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.2), inset 0 0 0 2px rgba(255,255,255,0.2);
}

#gas {
  background: rgba(37, 198, 178, 0.82);
}

#brake {
  background: rgba(255, 87, 77, 0.78);
}

.control-glyph {
  font-size: 25px;
  font-weight: 950;
  line-height: 1;
  pointer-events: none;
}

.control-label {
  font-weight: 850;
  pointer-events: none;
}

html[data-native-controls="true"] .controls {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.status {
  position: absolute;
  left: 50%;
  top: 86px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 28px));
  border-radius: 999px;
  padding: 9px 12px;
  color: var(--paper);
  font-size: 14px;
  text-align: center;
}

.status > span,
.status > small {
  display: block;
}

.status > small {
  max-width: 100%;
  margin-top: 3px;
  overflow: hidden;
  color: rgba(255, 208, 90, 0.9);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-callout {
  position: absolute;
  z-index: 18;
  left: 50%;
  top: 43%;
  min-width: 150px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  color: #17202a;
  text-align: center;
  font-size: 16px;
  font-weight: 950;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 12px) scale(0.92);
  background: linear-gradient(135deg, #fff4bd, #ffd05a);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  transition: opacity 160ms ease, transform 180ms ease;
}

.skill-callout.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.key-hint {
  position: absolute;
  right: max(18px, var(--safe-area-inset-right, env(safe-area-inset-right)));
  bottom: calc(max(18px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom))) + 72px);
  color: rgba(255, 248, 232, 0.72);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(22, 24, 24, 0.82);
  pointer-events: none;
}

.run-summary[hidden] {
  display: none;
}

.run-summary {
  position: absolute;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding:
    max(18px, var(--safe-area-inset-top, env(safe-area-inset-top)))
    max(18px, var(--safe-area-inset-right, env(safe-area-inset-right)))
    max(18px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom)))
    max(18px, var(--safe-area-inset-left, env(safe-area-inset-left)));
  background: rgba(7, 15, 20, 0.56);
  backdrop-filter: blur(10px);
}

.run-summary-card {
  width: min(560px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 25px;
  color: var(--paper);
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 208, 90, 0.2), transparent 34%),
    linear-gradient(155deg, rgba(30, 49, 55, 0.99), rgba(13, 24, 30, 0.99));
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.48);
}

.run-summary-eyebrow {
  color: var(--gold);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.run-summary-card h2 {
  margin: 4px 0 6px;
  font-size: clamp(28px, 5vw, 42px);
}

.run-summary-card > p {
  margin: 0 0 18px;
  color: rgba(255, 248, 232, 0.72);
}

.run-summary-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.run-summary-stats div {
  min-width: 0;
  padding: 11px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.075);
}

.run-summary-stats span,
.run-summary-stats strong {
  display: block;
}

.run-summary-stats span {
  color: rgba(255, 248, 232, 0.58);
  font-size: 10px;
  font-weight: 800;
}

.run-summary-stats strong {
  margin-top: 4px;
  overflow: hidden;
  color: var(--paper);
  font-size: 19px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#summaryStars {
  color: var(--gold);
  letter-spacing: 0.06em;
}

.run-summary-actions {
  display: grid;
  grid-template-columns: 0.82fr 1.18fr;
  gap: 10px;
  margin-top: 18px;
}

.run-summary-actions button {
  min-height: 54px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 900;
}

#summaryPrimary {
  color: #17202a;
  background: linear-gradient(135deg, #ffe894, #ffd05a);
}

.world-map[hidden] {
  display: none;
}

.world-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: var(--paper);
  background:
    radial-gradient(circle at 50% 10%, rgba(255, 208, 90, 0.17), transparent 38%),
    linear-gradient(180deg, #182c35 0%, #111c24 100%);
}

.map-header,
.map-footer {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding:
    max(16px, var(--safe-area-inset-top, env(safe-area-inset-top)))
    max(22px, var(--safe-area-inset-right, env(safe-area-inset-right)))
    15px
    max(22px, var(--safe-area-inset-left, env(safe-area-inset-left)));
  background: rgba(13, 24, 30, 0.88);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(18px);
}

.map-header > div,
.map-footer > div {
  min-width: 0;
}

.map-header h1 {
  margin: 2px 0 4px;
  color: #fff7dd;
  font-size: clamp(20px, 2.5vw, 34px);
  line-height: 1.05;
}

.map-header p {
  margin: 0;
  color: rgba(255, 248, 232, 0.7);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-eyebrow {
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#mapClose {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-size: 30px;
  line-height: 1;
}

.map-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  scrollbar-color: rgba(255, 208, 90, 0.7) rgba(0, 0, 0, 0.22);
}

.map-track {
  position: relative;
  width: 7502px;
  height: var(--map-visible-height, 100%);
  min-height: 0;
  overflow: hidden;
}

.map-biome {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 640px;
  background-position: center;
  background-size: cover;
}

.map-biome::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(9, 20, 25, 0.05), rgba(10, 17, 22, 0.42)),
    linear-gradient(90deg, rgba(16, 26, 31, 0.18), transparent 16%, transparent 84%, rgba(16, 26, 31, 0.22));
}

.map-biome-desert { left: 0; background-image: url("./assets/desert-background.png"); }
.map-biome-highlands { left: 640px; background-image: url("./assets/rainy-highlands.png"); }
.map-biome-savanna { left: 1280px; background-image: url("./assets/sunset-savanna.png"); }
.map-biome-frost { left: 1920px; background-image: url("./assets/frost-aurora.png"); }
.map-biome-moonlit { left: 2560px; background-image: url("./assets/moonlit-canyon.png"); }
.map-biome-volcanic { background-image: url("./assets/ember-caldera.png"); }
.map-biome-coast { background-image: url("./assets/azure-coast.png"); }
.map-biome-redwood { background-image: url("./assets/redwood-wilds.png"); }
.map-biome-neon { background-image: url("./assets/neon-metropolis.png"); }
.map-biome-skytemple { background-image: url("./assets/sky-temples.png"); }
.map-biome-crystal { background-image: url("./assets/crystal-frontier.png"); }

.map-region-label {
  position: absolute;
  z-index: 2;
  top: 22px;
  left: 28px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  color: #fff7df;
  background: rgba(15, 25, 31, 0.7);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
}

.map-route {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map-route-shadow {
  fill: none;
  stroke: rgba(21, 17, 14, 0.46);
  stroke-width: 18;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-route-line {
  fill: none;
  stroke: #ffe08a;
  stroke-width: 8;
  stroke-dasharray: 4 16;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-node {
  position: absolute;
  z-index: 5;
  width: 74px;
  min-height: 74px;
  transform: translate(-50%, -50%);
  border: 4px solid #fff2bd;
  border-radius: 50%;
  color: #1e2427;
  background: linear-gradient(145deg, #fff0a4, #e89a2e);
  box-shadow: 0 8px 0 rgba(67, 45, 26, 0.44), 0 15px 28px rgba(0, 0, 0, 0.35);
  font-size: 22px;
  font-weight: 950;
}

.map-node::after {
  content: attr(data-name);
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  width: 130px;
  transform: translateX(-50%);
  color: #fff8e8;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  text-shadow: 0 2px 7px rgba(0, 0, 0, 0.88);
}

.map-node.is-complete {
  border-color: #9ff1c9;
  background: linear-gradient(145deg, #bff9dd, #36bd89);
}

.map-node.is-active {
  outline: 5px solid rgba(255, 255, 255, 0.38);
  animation: mapPulse 1.5s ease-in-out infinite;
}

.map-node.is-locked {
  border-color: rgba(255, 255, 255, 0.38);
  color: rgba(255, 255, 255, 0.72);
  background: rgba(31, 38, 43, 0.86);
  filter: saturate(0.35);
  box-shadow: 0 7px 0 rgba(8, 12, 14, 0.48), 0 14px 24px rgba(0, 0, 0, 0.3);
}

.map-node.is-premium {
  border-color: rgba(255, 214, 91, 0.72);
  color: #ffe69c;
  background: linear-gradient(145deg, rgba(79, 63, 105, 0.96), rgba(31, 38, 58, 0.96));
}

.map-node.is-premium::before {
  content: "PASS";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  transform: translateX(-50%);
  padding: 2px 6px;
  border-radius: 999px;
  color: #32261a;
  background: #ffe08a;
  font-size: 8px;
  font-weight: 950;
  letter-spacing: 0.08em;
}

[dir="rtl"] .map-node.is-premium::before {
  content: "بطاقة";
  letter-spacing: 0;
}

.map-node.is-locked::after {
  color: rgba(255, 255, 255, 0.62);
}

.map-stars {
  position: absolute;
  left: 50%;
  bottom: -2px;
  transform: translateX(-50%);
  color: #fff5b8;
  font-size: 10px;
  letter-spacing: -1px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.map-car {
  position: absolute;
  z-index: 8;
  width: 104px;
  height: 70px;
  transform: translate(-50%, -88%);
  transition: left 700ms cubic-bezier(0.18, 0.78, 0.22, 1), top 700ms cubic-bezier(0.18, 0.78, 0.22, 1);
  pointer-events: none;
  filter: drop-shadow(0 10px 8px rgba(0, 0, 0, 0.42));
}

.map-car img {
  position: absolute;
  left: 0;
  top: 0;
  width: 104px;
  height: 69px;
  object-fit: contain;
}

.map-car-wheel {
  position: absolute;
  z-index: 2;
  bottom: var(--map-wheel-bottom, 7px);
  width: var(--map-wheel-size, 24px);
  height: var(--map-wheel-size, 24px);
  box-sizing: border-box;
  border: 4px solid #171412;
  border-radius: 50%;
  background: #d79b43;
  animation: mapWheelSpin 1.1s linear infinite;
}

.map-car-wheel-left {
  left: var(--map-rear-wheel-x, 25px);
  transform: translateX(-50%);
}

.map-car-wheel-right {
  left: var(--map-front-wheel-x, 77px);
  transform: translateX(-50%);
}

.map-footer {
  padding-top: 12px;
  padding-bottom: max(12px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 0;
}

.map-footer span {
  display: block;
  margin-bottom: 2px;
  color: rgba(255, 248, 232, 0.66);
  font-size: 11px;
}

.map-footer strong {
  font-size: 18px;
}

#mapPlay {
  min-height: 48px;
  padding: 0 22px;
  border-radius: 14px;
  color: #17202a;
  background: linear-gradient(135deg, #ffe08a, #ff9f43);
  box-shadow: 0 9px 22px rgba(0, 0, 0, 0.28);
  font-weight: 950;
}

#mapPlay:disabled {
  cursor: not-allowed;
  filter: grayscale(0.8);
  opacity: 0.55;
}

.world-map.is-compact .map-node {
  width: 54px;
  min-height: 54px;
  border-width: 3px;
  box-shadow: 0 5px 0 rgba(67, 45, 26, 0.44), 0 9px 18px rgba(0, 0, 0, 0.34);
  font-size: 17px;
}

.world-map.is-compact .map-node::after {
  display: none;
}

.world-map.is-compact .map-node.is-active {
  animation: none;
  outline-width: 3px;
}

.world-map.is-compact .map-stars {
  bottom: -1px;
  font-size: 8px;
}

.world-map.is-compact .map-car {
  transform: translate(-50%, -88%) scale(0.76);
  transform-origin: 50% 100%;
}

.world-map.is-compact .map-region-label {
  top: 9px;
  left: 14px;
  padding: 5px 9px;
  font-size: 10px;
}

@keyframes mapPulse {
  50% { outline-color: rgba(255, 255, 255, 0.08); transform: translate(-50%, -50%) scale(1.06); }
}

@keyframes mapWheelSpin {
  from { transform: translateX(-50%) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg); }
}

@media (max-width: 720px) {
  .shell {
    min-height: 100svh;
  }

  .hud {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    top: max(10px, var(--safe-area-inset-top, env(safe-area-inset-top)));
    gap: 8px;
  }

  .hud button {
    min-height: 40px;
    padding: 0 10px;
  }

  .hud .brand,
  .hud .hud-metric:nth-of-type(4) {
    display: none;
  }

  .hud div {
    min-height: 50px;
    padding: 7px 8px;
  }

  .hud strong {
    font-size: 18px;
  }

  .status {
    top: 136px;
    font-size: 13px;
    line-height: 1.2;
    max-width: min(330px, calc(100vw - 28px));
  }

  .key-hint {
    display: none;
  }

  .paint-select select,
  .car-select select,
  .level-select select,
  .language-select select {
    font-size: 14px;
  }

  .controls {
    left: max(16px, var(--safe-area-inset-left, env(safe-area-inset-left)));
    right: max(16px, var(--safe-area-inset-right, env(safe-area-inset-right)));
    bottom: max(18px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));
    gap: 8px;
  }

  .control-cluster {
    width: calc(50% - 4px);
    grid-template-columns: minmax(78px, 1fr) minmax(62px, 0.72fr);
    gap: 8px;
  }

  .control-cluster-right {
    grid-template-columns: minmax(62px, 0.72fr) minmax(78px, 1fr);
  }

  .controls button {
    min-height: 58px;
    font-size: 14px;
    padding: 0 6px;
    grid-template-columns: 1fr;
    gap: 1px;
  }

  .control-glyph {
    font-size: 22px;
  }

  .control-label {
    font-size: 12px;
  }

  .options-panel {
    place-items: end center;
    padding: 10px;
  }

  .options-card {
    border-radius: 22px;
  }

  .options-header {
    padding: 16px 17px 13px;
  }

  .options-grid {
    grid-template-columns: 1fr;
    gap: 9px;
    padding: 14px 17px;
  }

  .options-grid label,
  .option-best {
    min-height: 60px;
    padding: 9px 11px;
  }

  .options-actions {
    gap: 8px;
    padding: 0 17px 17px;
  }

  .options-actions button {
    min-height: 48px;
    font-size: 13px;
  }

  .map-header {
    padding-top: max(10px, var(--safe-area-inset-top, env(safe-area-inset-top)));
    padding-bottom: 9px;
  }

  .map-header h1 {
    font-size: 20px;
  }

  .map-track {
    min-height: 0;
  }

  .map-footer {
    padding-top: 8px;
  }

  .map-footer strong {
    font-size: 15px;
  }

  #mapPlay {
    min-height: 44px;
    padding: 0 15px;
  }
}

@media (max-height: 540px) {
  .map-header {
    min-height: 54px;
    padding:
      max(6px, var(--safe-area-inset-top, env(safe-area-inset-top)))
      max(12px, var(--safe-area-inset-right, env(safe-area-inset-right)))
      6px
      max(12px, var(--safe-area-inset-left, env(safe-area-inset-left)));
    gap: 10px;
  }

  .map-header h1 {
    margin: 0 0 2px;
    max-width: min(64vw, 560px);
    overflow: hidden;
    font-size: clamp(15px, 2.5vw, 20px);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .map-header p {
    max-width: min(64vw, 560px);
    font-size: 10px;
  }

  .map-eyebrow {
    display: none;
  }

  #mapClose {
    width: 38px;
    height: 38px;
    font-size: 25px;
  }

  .map-footer {
    min-height: 52px;
    padding:
      6px
      max(12px, var(--safe-area-inset-right, env(safe-area-inset-right)))
      max(6px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom)))
      max(12px, var(--safe-area-inset-left, env(safe-area-inset-left)));
    gap: 10px;
  }

  .map-footer span {
    display: none;
  }

  .map-footer strong {
    display: block;
    max-width: min(64vw, 560px);
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #mapPlay {
    min-height: 38px;
    padding: 0 13px;
    border-radius: 11px;
    font-size: 12px;
    white-space: nowrap;
  }

  .options-panel {
    padding:
      max(7px, var(--safe-area-inset-top, env(safe-area-inset-top)))
      max(10px, var(--safe-area-inset-right, env(safe-area-inset-right)))
      max(7px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom)))
      max(10px, var(--safe-area-inset-left, env(safe-area-inset-left)));
  }

  .options-card {
    width: min(760px, 100%);
    max-height: 100%;
    border-radius: 18px;
  }

  .options-header {
    padding: 10px 14px 8px;
  }

  .options-header h2 {
    margin: 0;
    font-size: 20px;
  }

  .options-eyebrow {
    display: none;
  }

  #optionsClose {
    width: 38px;
    height: 38px;
    font-size: 25px;
  }

  .options-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 14px;
  }

  .options-grid label,
  .option-best {
    min-height: 56px;
    padding: 8px 9px;
  }

  .options-grid span {
    margin-bottom: 4px;
    font-size: 10px;
  }

  .option-best strong {
    font-size: 18px;
  }

  .options-actions {
    gap: 8px;
    padding: 0 14px 12px;
  }

  .options-actions button {
    min-height: 40px;
    font-size: 12px;
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  .hud {
    right: auto;
    width: min(390px, calc(100vw - 20px));
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hud div,
  .hud button {
    min-height: 50px;
  }

  #optionsButton {
    grid-column: auto;
  }

  .status {
    top: 136px;
  }

  .controls {
    gap: 8px;
  }

  .controls button {
    min-height: 58px;
    border-radius: var(--radius);
  }
}

@media (max-width: 380px) and (orientation: portrait) {
  .hud {
    left: max(7px, var(--safe-area-inset-left, env(safe-area-inset-left)));
    width: calc(100vw - 14px);
    gap: 5px;
  }

  .hud div,
  .hud button {
    min-height: 46px;
  }

  .hud button {
    min-width: 0;
    padding: 0 7px;
    font-size: 12px;
  }

  .hud span {
    font-size: 10px;
  }

  .hud strong {
    font-size: 16px;
  }

  .status {
    top: 125px;
  }

  .controls {
    left: max(8px, var(--safe-area-inset-left, env(safe-area-inset-left)));
    right: max(8px, var(--safe-area-inset-right, env(safe-area-inset-right)));
    gap: 5px;
  }

  .control-cluster {
    width: calc(50% - 3px);
    grid-template-columns: minmax(64px, 1fr) minmax(48px, 0.68fr);
    gap: 5px;
  }

  .control-cluster-right {
    grid-template-columns: minmax(48px, 0.68fr) minmax(64px, 1fr);
  }

  .controls button {
    min-height: 52px;
    padding: 0 3px;
  }

  .control-label {
    font-size: 10px;
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  .shell {
    min-height: 100svh;
  }

  .hud {
    top: max(8px, var(--safe-area-inset-top, env(safe-area-inset-top)));
    left: max(10px, var(--safe-area-inset-left, env(safe-area-inset-left)));
    right: max(10px, var(--safe-area-inset-right, env(safe-area-inset-right)));
    grid-template-columns: repeat(4, minmax(54px, 0.72fr)) auto auto;
    gap: 6px;
  }

  .hud .brand {
    display: none;
  }

  .hud div {
    min-height: 44px;
    padding: 6px 8px;
  }

  .hud span {
    font-size: 11px;
  }

  .hud strong {
    font-size: 18px;
  }

  .hud button {
    min-width: 72px;
    min-height: 44px;
    padding: 0 10px;
  }

  .status {
    top: 66px;
    max-width: min(430px, calc(100vw - 24px));
    padding: 7px 10px;
    font-size: 13px;
  }

  .controls {
    left: max(12px, var(--safe-area-inset-left, env(safe-area-inset-left)));
    right: max(12px, var(--safe-area-inset-right, env(safe-area-inset-right)));
    bottom: max(10px, var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));
    gap: 8px;
  }

  .control-cluster {
    width: min(39vw, 330px);
  }

  .controls button {
    min-height: 50px;
    font-size: 14px;
  }
}

@media (max-width: 720px) {
  .garage-tuning {
    margin: 0 17px 14px;
    padding: 13px;
  }

  .upgrade-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upgrade-button {
    min-height: 68px;
  }

  .run-summary-card {
    padding: 19px;
  }

  .run-summary-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  .options-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-height: 540px) {
  .garage-tuning {
    margin: 0 14px 10px;
    padding: 10px;
  }

  .garage-header {
    margin-bottom: 8px;
  }

  .garage-header h3 {
    font-size: 15px;
  }

  .garage-wallet {
    padding: 5px 8px;
  }

  .garage-wallet strong {
    font-size: 17px;
  }

  .upgrade-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  .upgrade-button {
    min-height: 54px;
    padding: 7px;
  }

  .upgrade-button strong {
    margin: 2px 0;
    font-size: 13px;
  }

  #upgradeDescription {
    display: none;
  }

  .run-summary-card {
    width: min(680px, 100%);
    padding: 15px 18px;
  }

  .run-summary-card h2 {
    margin: 2px 0 3px;
    font-size: 25px;
  }

  .run-summary-card > p {
    margin-bottom: 10px;
    font-size: 12px;
  }

  .run-summary-stats {
    gap: 7px;
  }

  .run-summary-stats div {
    padding: 8px;
  }

  .run-summary-stats strong {
    font-size: 16px;
  }

  .run-summary-actions {
    margin-top: 10px;
  }

  .run-summary-actions button {
    min-height: 42px;
  }
}

@media (max-width: 380px) and (orientation: portrait) {
  .status > small {
    font-size: 9px;
  }

  .skill-callout {
    min-width: 128px;
    padding: 8px 12px;
    font-size: 14px;
  }
}
