:root {
  --bg-top: #90c7ff;
  --bg-mid: #d8efff;
  --bg-bottom: #143219;
  --glass: rgba(8, 20, 28, 0.62);
  --glass-border: rgba(255, 255, 255, 0.16);
  --text-main: #f3f7fb;
  --text-soft: rgba(243, 247, 251, 0.72);
  --accent: #ffb703;
  --accent-soft: rgba(255, 183, 3, 0.18);
  --accent-2: #72ffb4;
  --danger: #ff5c5c;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.24), transparent 34%),
    linear-gradient(180deg, var(--bg-top), var(--bg-mid) 42%, #6fb7ff 56%, var(--bg-bottom) 100%);
  color: var(--text-main);
  font-family: "Rajdhani", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  inset: 0;
  padding: 18px;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(240px, 1.1fr) minmax(260px, 1fr) minmax(300px, 0.95fr);
  grid-template-rows: auto auto 1fr;
  pointer-events: none;
}

.glass {
  backdrop-filter: blur(18px);
  background: linear-gradient(180deg, rgba(11, 24, 35, 0.72), rgba(7, 17, 24, 0.58));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  border-radius: 24px;
}

.brand-panel,
.status-panel,
.garage,
.telemetry,
.message-banner {
  pointer-events: auto;
}

.brand-panel {
  grid-column: 1 / 2;
  padding: 18px 20px;
}

.brand-panel h1,
.garage h2 {
  margin: 0;
  font-family: "Oxanium", sans-serif;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.subtle,
.tips p,
.card p,
.mini-stats span,
.status-item .label {
  color: var(--text-soft);
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
  font-size: 0.78rem;
}

.status-panel {
  grid-column: 2 / 4;
  padding: 14px 18px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.status-item {
  padding: 8px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.status-item strong {
  display: block;
  font-size: 1.18rem;
}

.garage {
  grid-column: 3 / 4;
  grid-row: 2 / 4;
  padding: 16px;
  overflow: auto;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 10px;
}

.shop-head {
  margin-top: 18px;
}

.card-list {
  display: grid;
  gap: 12px;
}

.card {
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.card.active {
  border-color: rgba(255, 183, 3, 0.8);
  box-shadow: inset 0 0 0 1px rgba(255, 183, 3, 0.4);
}

.card-header,
.card-stats,
.card-footer,
.upgrade-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-header strong,
.card-footer strong {
  font-size: 1.02rem;
}

.card p {
  margin: 4px 0 8px;
  font-size: 0.95rem;
}

.card-stats span,
.upgrade-meta span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.92rem;
}

.card button {
  width: 100%;
  margin-top: 10px;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--accent), #ff7b00);
  color: #101820;
  font-weight: 700;
  cursor: pointer;
}

.card button.alt {
  background: linear-gradient(135deg, #7cffb4, #4ec9ff);
}

.card button[disabled] {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.42);
  cursor: not-allowed;
}

.telemetry {
  grid-column: 1 / 2;
  grid-row: 2 / 4;
  align-self: end;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(320px, 100%);
}

.speed-ring {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 28px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.12) 0, rgba(255, 255, 255, 0.04) 52%, transparent 53%),
    conic-gradient(from 210deg, rgba(114, 255, 180, 0.2), rgba(255, 183, 3, 0.95), rgba(255, 92, 92, 0.55), rgba(114, 255, 180, 0.2));
  padding: 22px;
}

.speed-ring > div {
  width: 100%;
  height: 100%;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: rgba(5, 15, 24, 0.88);
  text-align: center;
}

.speed-ring strong {
  display: block;
  font-family: "Oxanium", sans-serif;
  font-size: clamp(2.8rem, 5vw, 4.8rem);
}

.speed-ring span {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-soft);
  font-size: 0.78rem;
}

.mini-stats {
  display: grid;
  gap: 10px;
}

.mini-stats p {
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.mini-stats strong {
  font-size: 1.1rem;
}

.tips {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tips p {
  margin: 8px 0;
  font-size: 0.95rem;
}

.tips span {
  color: var(--accent-2);
  font-weight: 700;
}

.message-banner {
  position: absolute;
  left: 50%;
  bottom: 146px;
  transform: translateX(-50%);
  padding: 14px 18px;
  min-width: min(88vw, 420px);
  text-align: center;
  font-size: 1.05rem;
  z-index: 3;
}

.message-banner.hidden {
  display: none;
}

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

.control-pad {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  width: 74px;
  height: 74px;
  border: 0;
  border-radius: 22px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  background: linear-gradient(180deg, rgba(8, 20, 28, 0.86), rgba(11, 24, 35, 0.66));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  touch-action: manipulation;
}

.touch-btn.primary {
  width: 94px;
  background: linear-gradient(135deg, rgba(114, 255, 180, 0.94), rgba(49, 172, 255, 0.92));
  color: #03121d;
}

.touch-btn.secondary {
  width: 88px;
}

.touch-btn:active,
.touch-btn.active {
  transform: translateY(2px) scale(0.98);
  filter: brightness(1.08);
}

@media (max-width: 1150px) {
  .hud {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .brand-panel {
    grid-column: 1 / 2;
  }

  .status-panel {
    grid-column: 1 / 3;
    grid-row: 2 / 3;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .telemetry {
    grid-column: 1 / 2;
    grid-row: 3 / 4;
    width: auto;
  }

  .garage {
    grid-column: 2 / 3;
    grid-row: 1 / 4;
  }
}

@media (max-width: 900px) {
  .hud {
    display: flex;
    flex-direction: column;
    padding: 12px;
    gap: 12px;
  }

  .brand-panel,
  .status-panel,
  .telemetry {
    width: 100%;
  }

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

  .telemetry {
    max-width: none;
    flex-direction: row;
    align-items: stretch;
  }

  .speed-ring {
    width: 170px;
    flex: 0 0 170px;
  }

  .mini-stats {
    flex: 1;
  }

  .garage {
    max-height: 42vh;
  }

  .message-banner {
    bottom: 108px;
  }

  .touch-btn {
    width: 66px;
    height: 66px;
  }

  .touch-btn.primary {
    width: 82px;
  }

  .touch-btn.secondary {
    width: 76px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls {
    opacity: 0.3;
    transition: opacity 200ms ease;
  }

  .touch-controls:hover {
    opacity: 1;
  }
}
