:root{
  --bg:#0b1220;
  --road:#2d2f36;
  --lane:#1f2226;
  --line:#e6e6e6;
  --accent:#ff4d4f;
  --car:#ffd166;
  --sizeWidth: min(420px, 92vw);
}

*{box-sizing:border-box}
html,body{height:100%;margin:0;font-family:Inter,system-ui,Segoe UI,Roboto,Arial}
body{
  display:flex;align-items:center;justify-content:center;
  background:linear-gradient(180deg,#071122,#0b1220);
  color:#eaf2ff;padding:18px;
}

.game-wrap{
  width:var(--sizeWidth);
  max-width:95vw;
  text-align:center;
}

header{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}
h1{font-size:1.15rem;margin:0}
.info{display:flex;gap:8px;align-items:center}
#restartBtn{padding:6px 10px;border-radius:8px;border:none;background:#fff;color:#0b1220;font-weight:600;cursor:pointer}

.game-area{
  position:relative;
  width:100%;
  height:66vh;
  max-height:720px;
  min-height:320px;
  border-radius:12px;
  overflow:hidden;
  background:linear-gradient(#173046,#0f1a28 60%);
  box-shadow: 0 8px 30px rgba(2,6,23,.6);
  touch-action:none;
  outline: none;
}

/* Road centered */
.road{
  position:absolute;
  left:50%;
  transform:translateX(-50%);
  width:58%;            /* road width (changeable) */
  height:200%;
  top:-50%;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.06) 0 6px,
      transparent 6px 20px
    );
  box-shadow: inset 0 0 0 8px rgba(0,0,0,0.6), inset 0 0 40px rgba(0,0,0,0.4);
  border-left: 6px solid rgba(255,255,255,0.06);
  border-right:6px solid rgba(255,255,255,0.06);
  display:block;
}

/* dashed center line (visual) */
.road::after{
  content:"";
  position:absolute;left:50%;transform:translateX(-50%);
  width:6px;height:100%;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.8) 0 22px,
      rgba(255,255,255,0.0) 22px 44px
    );
  opacity:.8;
}

/* car */
.car{
  position:absolute;
  width:10%;
  max-width:80px;
  aspect-ratio: 1/1.6;
  bottom:8%;
  left:50%;
  transform:translateX(-50%);
  z-index:20;
  display:flex;align-items:center;justify-content:center;
  transition: transform 0.06s linear;
  pointer-events:none;
}

/* a simple car look */
.car-top{
  width:100%;
  height:100%;
  background: linear-gradient(180deg, #ffd166 0%, #f7b733 60%);
  border-radius:12% 12% 12% 12% / 18% 18% 12% 12%;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45), inset 0 6px 10px rgba(255,255,255,.12);
  position:relative;
}
.car-top::before{
  content:"";
  position:absolute;left:10%;top:20%;
  width:80%;height:35%;
  background:linear-gradient(180deg,#ffffffcc,#ffffff66);
  border-radius:6px;
  opacity:.95;
}

/* explosion effect (created dynamically) */
.explosion{
  position:absolute;
  width:32%;
  aspect-ratio:1/1;
  left:50%; transform:translateX(-50%);
  bottom:8%;
  z-index:30;
  pointer-events:none;
  display:flex;align-items:center;justify-content:center;
  animation: explode 700ms ease-out forwards;
}
.explosion::before{
  content:"";
  width:100%;height:100%;
  background: radial-gradient(circle at 30% 30%, #fff 0 12%, #ffb86b 12% 28%, #ff4d4f 28% 55%, rgba(0,0,0,0) 56%);
  border-radius:50%;
  filter: drop-shadow(0 6px 12px rgba(255,80,50,0.45));
  transform: scale(.3);
}

/* explode animation: grow + fade */
@keyframes explode{
  0%{opacity:1; transform:translateX(-50%) scale(.3) translateY(0)}
  60%{transform:translateX(-50%) scale(1.15) translateY(-10px)}
  100%{opacity:0; transform:translateX(-50%) scale(1.5) translateY(-30px)}
}

/* controls below the game area */
.controls