:root {
  color-scheme: dark;
  --bg: #081018;
  --panel: rgba(12, 25, 39, 0.84);
  --panel-strong: rgba(11, 20, 31, 0.94);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f7fb;
  --muted: #95a6b8;
  --accent: #f4b73b;
  --accent-2: #ff5c5c;
  --good: #35cf95;
  --silver: #c6d3de;
  --bronze: #b88453;
  --shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
  --radius: 24px;
  --safe: max(20px, env(safe-area-inset-top));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Helvetica Neue", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(244, 183, 59, 0.15), transparent 28%),
    radial-gradient(circle at top right, rgba(52, 122, 255, 0.22), transparent 30%),
    linear-gradient(180deg, #0f1b2a 0%, #081018 100%);
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  padding: var(--safe) 20px 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.topbar h1,
.villa-copy h2,
.garage-entry h2,
.garage-header h2,
.panel-head h3,
.modal-head h3 {
  margin: 4px 0 0;
}

.eyebrow,
.section-tag {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 0.95fr);
  gap: 18px;
}

.scene-card,
.panel-card,
.modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.scene-card {
  min-height: 760px;
}

.scene-stage {
  height: 100%;
  min-height: 760px;
}

.status-strip {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 12px 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(190, 23, 23, 0.92), rgba(255, 96, 96, 0.92));
  color: #fff6f6;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 16px 30px rgba(190, 23, 23, 0.4);
}

.status-icon {
  margin-right: 8px;
}

.villa-screen,
.drive-screen,
.race-screen {
  position: relative;
  width: 100%;
  height: 100%;
}

.villa-screen {
  display: grid;
  align-items: center;
  min-height: 760px;
  padding: 34px;
  background:
    linear-gradient(140deg, rgba(3, 9, 18, 0.2), rgba(7, 15, 25, 0.84)),
    url("./assets/generated/villa-hero.png") center/cover no-repeat;
}

.villa-copy,
.garage-entry {
  max-width: 520px;
  padding: 28px;
  background: rgba(9, 17, 27, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 26px;
}

.villa-copy p,
.garage-entry p,
.notes,
.service-summary,
.upgrade-block p {
  color: var(--muted);
  line-height: 1.6;
}

.villa-actions,
.service-actions,
.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.transport-card {
  margin-top: 20px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.transport-card h3 {
  margin: 8px 0 6px;
}

.transport-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.primary-btn,
.ghost-btn,
.chip,
.mode-btn,
.touch-btn {
  border-radius: 16px;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.primary-btn:hover,
.ghost-btn:hover,
.chip:hover,
.mode-btn:hover,
.touch-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  padding: 13px 18px;
  background: linear-gradient(135deg, #f8c55b, #d88d15);
  color: #101316;
  font-weight: 700;
}

.ghost-btn,
.chip {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.garage-room {
  width: 100%;
  padding: 28px;
  min-height: 760px;
  background:
    linear-gradient(160deg, rgba(5, 10, 16, 0.55), rgba(5, 10, 16, 0.82)),
    url("./assets/generated/garage-luxury.png") center/cover no-repeat;
}

.garage-header,
.panel-head,
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.garage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.car-card {
  position: relative;
  padding: 22px;
  min-height: 280px;
  background: linear-gradient(180deg, rgba(21, 34, 47, 0.82), rgba(9, 19, 29, 0.9));
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.car-swatch {
  width: 100%;
  height: 120px;
  border-radius: 18px;
  margin: 16px 0;
  position: relative;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02));
}

.car-photo {
  width: 100%;
  height: 148px;
  object-fit: cover;
  display: block;
  margin: 16px 0;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.28);
}

.car-swatch::before {
  content: "";
  position: absolute;
  inset: 18px 24px 22px;
  border-radius: 24px 36px 24px 24px;
  background: var(--car-color, #f97316);
  box-shadow: inset 0 -12px 28px rgba(0, 0, 0, 0.22);
}

.car-dot {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
}

.car-dot::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6bf5c4, #06c076);
  box-shadow: 0 0 0 6px rgba(107, 245, 196, 0.12);
}

.car-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.drive-btn {
  margin-top: 16px;
  width: 100%;
}

#driveCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: linear-gradient(180deg, #0d1720 0%, #152738 100%);
}

#raceCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background:
    radial-gradient(circle at top, rgba(255, 200, 87, 0.16), transparent 24%),
    linear-gradient(180deg, #081018 0%, #132332 100%);
}

.hud {
  position: absolute;
  inset: 20px;
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

.view-switch,
.drive-meta {
  position: absolute;
  top: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.view-switch {
  left: 0;
  padding: 10px 14px;
  border-radius: 18px;
  background: rgba(7, 16, 26, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.drive-meta {
  right: 0;
}

.badge {
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(244, 183, 59, 0.14);
  border: 1px solid rgba(244, 183, 59, 0.28);
  color: #ffe0a5;
  font-weight: 700;
}

.badge.neutral {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

.chip.active,
.mode-btn.active {
  background: rgba(244, 183, 59, 0.18);
  border-color: rgba(244, 183, 59, 0.42);
  color: #ffe0a5;
}

.map-card {
  position: absolute;
  left: 0;
  bottom: 0;
  display: grid;
  gap: 10px;
  padding: 14px;
  background: rgba(7, 16, 26, 0.78);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.race-panel {
  width: min(360px, 100%);
}

.race-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.race-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

#miniMap {
  width: 220px;
  height: 220px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
}

.cluster {
  position: absolute;
  right: 0;
  width: 310px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(7, 16, 26, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.gauges {
  bottom: 0;
}

.condition {
  bottom: 168px;
}

.objective {
  bottom: 332px;
}

.panel-title {
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.gauge-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 12px;
}

.gauge-row strong {
  font-size: 34px;
}

.gauge-row span {
  color: var(--muted);
}

.meter {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.meter > i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #3ccf98, #f5a623, #ff6464);
}

.health-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.health-segment {
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.health-segment.active {
  background: linear-gradient(90deg, #36cf93, #9df19d);
}

.health-segment.damaged {
  background: rgba(255, 99, 99, 0.24);
}

.side-panel {
  display: grid;
  gap: 18px;
}

.panel-card {
  padding: 22px;
}

.wallet {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.coin-pill {
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.coin-pill.gold {
  background: rgba(244, 183, 59, 0.16);
  color: #ffd375;
}

.coin-pill.silver {
  background: rgba(198, 211, 222, 0.14);
  color: #edf3f9;
}

.coin-pill.copper {
  background: rgba(184, 132, 83, 0.18);
  color: #f4c7a3;
}

.mode-grid,
.map-grid,
.shop-tabs,
.shop-list,
.upgrade-groups {
  display: grid;
  gap: 12px;
}

.map-card-select {
  position: relative;
  overflow: hidden;
  min-height: 150px;
  padding: 18px;
  display: flex;
  align-items: flex-end;
  border-radius: 20px;
  text-align: left;
  color: var(--text);
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 -90px 120px rgba(5, 10, 16, 0.55);
}

.map-card-select.active {
  outline: 2px solid rgba(244, 183, 59, 0.72);
}

.map-card-select::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 16, 26, 0.02), rgba(7, 16, 26, 0.86));
}

.map-copy {
  position: relative;
  z-index: 1;
}

.map-copy strong,
.map-copy span {
  display: block;
}

.map-copy span {
  margin-top: 8px;
  color: #d9e3ed;
  line-height: 1.45;
}

.mode-btn {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 16px;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.mode-btn span {
  color: var(--muted);
  line-height: 1.5;
}

.shop-tabs {
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  margin-bottom: 12px;
}

.shop-feature {
  margin-bottom: 14px;
}

.shop-feature-card {
  position: relative;
  overflow: hidden;
  min-height: 210px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 -120px 130px rgba(7, 16, 26, 0.72);
}

.shop-feature-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 16, 26, 0.08), rgba(7, 16, 26, 0.88));
}

.shop-feature-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  align-content: end;
  min-height: 174px;
}

.shop-feature-copy p,
.shop-feature-copy small {
  color: #dbe5ef;
}

.spec-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.spec-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
}

.shop-tab {
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.shop-tab.active {
  background: rgba(244, 183, 59, 0.18);
  color: #ffe0a5;
  border-color: rgba(244, 183, 59, 0.38);
}

.shop-item {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.shop-item.active {
  border-color: rgba(244, 183, 59, 0.4);
  background: rgba(244, 183, 59, 0.08);
}

.shop-item p,
.shop-item small {
  color: var(--muted);
}

.shop-item footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

#enterRaceBtn {
  margin-top: 14px;
  width: 100%;
}

.notes {
  padding-left: 18px;
  margin: 10px 0 0;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 10, 16, 0.72);
  z-index: 20;
}

.modal-card {
  width: min(640px, 100%);
  padding: 24px;
  background: var(--panel-strong);
}

.modal-card.large {
  width: min(980px, 100%);
}

#fullMap {
  width: 100%;
  height: auto;
  margin-top: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
}

.upgrade-block {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.touch-controls {
  position: absolute;
  inset: auto 20px 20px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.steer-pad,
.pedal-pad {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.pedal-pad {
  align-items: flex-end;
}

.touch-btn {
  min-width: 88px;
  padding: 16px 18px;
  color: var(--text);
  background: rgba(7, 16, 26, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.touch-btn.accel {
  background: rgba(53, 207, 149, 0.14);
}

.touch-btn.accel.active,
.touch-btn.mode-toggle.active {
  border-color: rgba(244, 183, 59, 0.55);
  background: rgba(244, 183, 59, 0.2);
  color: #ffe0a5;
}

.touch-btn.brake {
  background: rgba(255, 92, 92, 0.12);
}

.touch-btn.handbrake {
  background: rgba(96, 166, 255, 0.16);
}

@media (max-width: 1280px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .scene-card,
  .scene-stage,
  .villa-screen {
    min-height: 680px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding-inline: 12px;
  }

  .topbar,
  .garage-grid,
  .shop-tabs {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar {
    gap: 14px;
  }

  .wallet {
    justify-content: flex-start;
  }

  .hud {
    inset: 12px;
  }

  .view-switch,
  .drive-meta {
    position: static;
    margin-bottom: 10px;
  }

  .map-card,
  .cluster {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

  .touch-controls {
    position: static;
    margin: 12px;
  }
}
