
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #10131c;
  color: white;
  font-family: Arial, sans-serif;
}

.race-game {
  max-width: 850px;
  min-height: 100vh;
  margin: auto;
  padding-bottom: 30px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 17px;
  background: #1c2432;
  border-bottom: 1px solid #354154;
}

.brand {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 1px;
}

.cash {
  background: #293747;
  color: #64e5a1;
  padding: 11px 15px;
  border-radius: 10px;
  font-weight: bold;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #1c2432;
  position: sticky;
  top: 0;
  z-index: 5;
}

.tabs button {
  flex: 1;
  padding: 13px 5px;
  background: #303d51;
  color: white;
  border: none;
  border-radius: 9px;
  font-weight: bold;
  cursor: pointer;
}

.tabs button:hover {
  background: #465a76;
}

.screen {
  display: none;
  padding: 15px;
}

.screen.active {
  display: block;
}

.game-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.game-stats div {
  padding: 12px 5px;
  background: #202b3b;
  border-radius: 10px;
  text-align: center;
  color: #aebbd0;
  font-size: 12px;
}

.game-stats strong {
  display: block;
  margin-top: 5px;
  color: #65e6a2;
  font-size: 17px;
}

.track-wrap {
  width: 100%;
  max-width: 420px;
  margin: auto;
  position: relative;
  overflow: hidden;
  border: 3px solid #536078;
  border-radius: 13px;
  background: #333943;
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 420 / 650;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: #090e19cc;
  z-index: 2;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: 100%;
  max-width: 310px;
  padding: 25px 18px;
  border: 1px solid #52617b;
  border-radius: 17px;
  background: #1d293a;
  text-align: center;
}

.overlay-card h2 {
  font-size: 23px;
}

.overlay-card p {
  color: #b8c5d7;
  line-height: 1.5;
}

.big-icon {
  font-size: 65px;
}

.primary {
  width: 100%;
  padding: 15px;
  margin-top: 12px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #52e59b, #18b879);
  color: #082014;
  font-weight: 900;
  font-size: 17px;
  cursor: pointer;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 35px;
  margin: 17px auto 5px;
  max-width: 420px;
}

.steer {
  flex: 1;
  max-width: 160px;
  height: 75px;
  border: 2px solid #485b75;
  border-radius: 15px;
  background: #253348;
  color: white;
  font-size: 32px;
  font-weight: bold;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.steer:active {
  background: #3c5577;
  transform: scale(0.97);
}

.hint {
  text-align: center;
  color: #8f9db1;
  font-size: 12px;
  line-height: 1.5;
}

.section-heading {
  margin: 5px 0 20px;
}

.section-heading h2 {
  font-size: 26px;
  margin-bottom: 5px;
}

.section-heading p {
  color: #aebbd0;
}

.car-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.car-card,
.upgrade-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border: 1px solid #354154;
  border-radius: 13px;
  background: #1c2635;
}

.car-preview {
  width: 65px;
  font-size: 43px;
  text-align: center;
}

.car-details {
  flex: 1;
  min-width: 0;
}

.car-details h3,
.upgrade-card h3 {
  margin: 0 0 7px;
}

.car-details p,
.upgrade-card p {
  color: #aebbd0;
  margin: 4px 0;
  font-size: 13px;
}

.car-details small,
.upgrade-card small {
  color: #64e5a1;
}

.car-card button,
.upgrade-card button {
  padding: 11px 12px;
  border: none;
  border-radius: 9px;
  background: #37d18b;
  color: #082014;
  font-weight: bold;
  cursor: pointer;
}

.car-card button:disabled {
  background: #485568;
  color: #d2d9e3;
  cursor: default;
}

.upgrade-card {
  justify-content: space-between;
  margin-bottom: 12px;
}

.upgrade-card > div {
  flex: 1;
  min-width: 0;
}

.message {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  padding: 13px 20px;
  background: #304057;
  border: 1px solid #61748f;
  border-radius: 12px;
  color: white;
  font-weight: bold;
  text-align: center;
  max-width: 90%;
  transition: 0.2s;
}

.message.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 480px) {
  .brand {
    font-size: 17px;
  }

  .screen {
    padding: 10px;
  }

  .tabs button {
    font-size: 12px;
  }

  .car-card,
  .upgrade-card {
    padding: 11px;
    gap: 7px;
  }

  .car-preview {
    width: 48px;
    font-size: 34px;
  }

  .car-card button,
  .upgrade-card button {
    font-size: 11px;
    padding: 10px 8px;
  }

  .steer {
    height: 70px;
  }
}
