*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0c1218;
  font-family: "Outfit", system-ui, sans-serif;
  color: #f4f7fb;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#ui-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 140, 60, 0.28), transparent 42%),
    radial-gradient(ellipse at 80% 90%, rgba(40, 120, 200, 0.22), transparent 48%),
    linear-gradient(160deg, #0a1018 0%, #152030 48%, #0c141c 100%);
  pointer-events: auto;
  transition: opacity 0.45s ease, visibility 0.45s;
}

.panel.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.card {
  width: min(440px, 92vw);
  text-align: center;
}

.card h1 {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(3rem, 12vw, 5.2rem);
  letter-spacing: 0.06em;
  line-height: 0.92;
  background: linear-gradient(180deg, #fff6e8 0%, #ffb454 55%, #ff7a2e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.35rem;
}

.card .tag {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 200, 120, 0.28);
  background: rgba(255, 160, 60, 0.1);
  color: #ffd9a8;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.card p {
  color: #a8b8c8;
  font-size: 1.02rem;
  line-height: 1.5;
  margin-bottom: 1.35rem;
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.95rem;
  padding: 0.95rem 1.8rem;
  border-radius: 14px;
  color: #1a1208;
  background: linear-gradient(180deg, #ffd27a 0%, #ff9a2e 100%);
  box-shadow:
    0 10px 30px rgba(255, 140, 40, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.stats-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin: 1rem 0 1.4rem;
}

.stat-pill {
  min-width: 110px;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-pill small {
  display: block;
  color: #8ea0b0;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-pill b {
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffe7c2;
}

#loader .bar {
  width: min(320px, 78vw);
  height: 5px;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

#loader .bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff9a2e, #ffe08a);
  transition: width 0.2s ease;
}

#load-status {
  margin-top: 0.7rem;
  color: #7f93a6;
  font-size: 0.88rem;
}

#hud {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease;
}

#hud.show {
  opacity: 1;
  visibility: visible;
}

.hud-top {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.55rem;
}

.hud-chip {
  min-width: 96px;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  background: rgba(8, 14, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  text-align: center;
}

.hud-chip small {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8ea2b4;
}

.hud-chip b {
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.55rem;
  letter-spacing: 0.04em;
  color: #fff4e4;
}

.speedo {
  position: absolute;
  right: 20px;
  bottom: 20px;
  text-align: right;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}

.speedo .val {
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(2.6rem, 8vw, 4rem);
  line-height: 0.9;
  color: #ffc56e;
}

.speedo .unit {
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  color: #9eb0c0;
}

.hint {
  position: absolute;
  left: 18px;
  bottom: 18px;
  max-width: 260px;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: rgba(8, 14, 22, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  color: #c5d4e2;
  font-size: 0.88rem;
  line-height: 1.45;
}

.hint kbd {
  display: inline-block;
  min-width: 1.35em;
  padding: 1px 5px;
  margin: 0 1px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 0.75rem;
}

#touch {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
}

@media (pointer: coarse) {
  #touch {
    display: block;
  }
  .hint {
    display: none;
  }
}

.drive-btn {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #eef6ff;
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  pointer-events: auto;
}

#btn-left {
  left: 22px;
  bottom: 28px;
}
#btn-right {
  left: 98px;
  bottom: 28px;
}
#btn-gas {
  right: 22px;
  bottom: 98px;
}
#btn-brake {
  right: 22px;
  bottom: 28px;
}

@media (orientation: landscape) and (max-height: 600px) {
  .speedo {
    bottom: 180px;
  }
}

.drive-btn.active {
  background: rgba(255, 160, 60, 0.35);
  border-color: rgba(255, 200, 120, 0.45);
}

#rotate-prompt {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(6, 10, 16, 0.96);
  pointer-events: auto;
  text-align: center;
  padding: 1.5rem;
  z-index: 40;
}

#rotate-prompt h2 {
  font-family: "Bebas Neue", sans-serif;
  font-size: 2rem;
  letter-spacing: 0.08em;
  color: #ffc56e;
}

#rotate-prompt p {
  color: #9eb0c0;
  max-width: 280px;
}

@media (orientation: portrait) and (max-width: 900px) {
  #rotate-prompt {
    display: flex;
  }
}
