/* ============ TURBO RACER — style ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #070b16;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;   /* fallback: 100vh sudah di html,body */
}

/* ukuran #wrap diset oleh JS (resize) — menyesuaikan orientasi & device */
#wrap {
  position: relative;
  width: 1024px;
  height: 768px;
  touch-action: none;
  container-type: size;   /* aktifkan unit cqw/cqh untuk tombol & teks */
  box-shadow: 0 0 60px rgba(0, 150, 255, 0.15);
  border-radius: 8px;
  overflow: hidden;
}

canvas#game {
  width: 100%;
  height: 100%;
  display: block;
  background: #2f9fe3;
}

.hidden { display: none !important; }

/* ============ HUD ============ */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px;
}

#score-box, #best-box {
  background: rgba(5, 10, 25, 0.55);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 6px 14px;
  text-align: center;
  backdrop-filter: blur(3px);
}

#score-box .label, #best-box .label {
  display: block;
  font-size: 11px;
  letter-spacing: 2px;
  color: #9adcff;
}

#score-value, #best-value {
  font-size: 19px;
  font-weight: 700;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

#hearts {
  align-self: center;
  font-size: 24px;
  letter-spacing: 3px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  margin-top: 10px;
}

#speed-box {
  position: absolute;
  right: 22px;
  bottom: 18px;
  text-align: right;
}

#speed-value {
  font-size: 58px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 18px rgba(0, 210, 255, 0.8), 0 3px 8px rgba(0,0,0,0.6);
  font-variant-numeric: tabular-nums;
}

#speed-unit {
  font-size: 13px;
  letter-spacing: 2px;
  color: #bfeaff;
  display: block;
  margin-top: 2px;
}

/* ============ OVERLAY ============ */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(4, 10, 24, 0.72);
  backdrop-filter: blur(5px);
  text-align: center;
  padding: 24px;
  overflow: auto;
}

.title {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 6px;
  line-height: 1;
  background: linear-gradient(180deg, #7ff3ff 0%, #2aa9ff 55%, #0a3fd6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(42, 169, 255, 0.45);
}

.title span {
  background: linear-gradient(180deg, #ffd54f 0%, #ff6d00 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline { color: #cfe6ff; font-size: 15px; max-width: 480px; }

.controls {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 14px 22px;
  font-size: 14px;
  color: #dbeaff;
  line-height: 2;
}

kbd {
  display: inline-block;
  background: #1b2740;
  border: 1px solid #3c4f73;
  border-bottom-width: 3px;
  border-radius: 5px;
  padding: 1px 7px;
  font-family: inherit;
  font-size: 12px;
  color: #bfeaff;
  min-width: 22px;
  text-align: center;
}

.best { color: #ffd54f; font-weight: 700; font-size: 16px; }

button {
  font-family: inherit;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #04263f;
  background: linear-gradient(180deg, #5ef2ff 0%, #22b8ff 100%);
  border: none;
  border-radius: 14px;
  padding: 14px 38px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(34, 184, 255, 0.5), 0 5px 0 #0a5a94;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

button:hover  { transform: translateY(-2px); box-shadow: 0 0 34px rgba(34,184,255,0.7), 0 7px 0 #0a5a94; }
button:active { transform: translateY(3px);  box-shadow: 0 0 14px rgba(34,184,255,0.4), 0 2px 0 #0a5a94; }

/* countdown */
#countdown-text {
  font-size: clamp(60px, 20cqw, 110px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 40px rgba(255, 210, 60, 0.9), 0 6px 14px rgba(0,0,0,0.6);
}

/* pause */
#paused h2 { font-size: clamp(28px, 9cqw, 46px); letter-spacing: 4px; }
#paused p  { color: #cfe6ff; }

/* game over */
.crash-title {
  font-size: clamp(30px, 10cqw, 52px);
  font-weight: 900;
  letter-spacing: 3px;
  color: #ff5252;
  text-shadow: 0 0 30px rgba(255, 60, 60, 0.7);
}

.big-score { font-size: 26px; font-weight: 700; }

/* ============ TOUCH CONTROLS (jempol-friendly, di bawah) ============ */
#touch {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.t-btn {
  pointer-events: auto;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.28);
  border-radius: 18px;
  background: rgba(10, 20, 40, 0.45);
  backdrop-filter: blur(4px);
  color: #fff;
  font-weight: 800;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
  transition: background 0.06s ease, border-color 0.06s ease;
}

.t-btn:active {
  background: rgba(94, 242, 255, 0.4);
  border-color: rgba(94, 242, 255, 0.75);
  transform: none;
}

/* kluster kiri bawah: belok (◀ ▶) */
.t-left, .t-right {
  width: clamp(64px, 19cqw, 120px);
  height: clamp(64px, 19cqw, 120px);
  font-size: clamp(24px, 7cqw, 42px);
  bottom: calc(3% + env(safe-area-inset-bottom, 0px));
}
.t-left  { left: 3%; }
.t-right { left: calc(3% + 19cqw + 12px); }

/* kluster kanan bawah: GAS (besar) + REM (di sampingnya, sebaris) */
.t-gas {
  width: clamp(84px, 25cqw, 160px);
  height: clamp(84px, 25cqw, 160px);
  right: 3%;
  bottom: calc(3% + env(safe-area-inset-bottom, 0px));
  font-size: clamp(17px, 5.5cqw, 26px);
  letter-spacing: 1px;
  border-color: rgba(94, 242, 255, 0.55);
  background: rgba(0, 140, 255, 0.35);
}

.t-rem {
  width: clamp(60px, 16cqw, 100px);
  height: clamp(60px, 16cqw, 100px);
  right: calc(3% + 25cqw + 12px);
  bottom: calc(3% + env(safe-area-inset-bottom, 0px));
  font-size: clamp(13px, 4.5cqw, 20px);
}

/* ============ RESPONSIF (portrait / layar kecil) ============ */
@media (orientation: portrait) {
  /* speed pindah ke atas-tengah biar nggak ketutup tombol GAS */
  #speed-box {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: auto;
    top: 66px;
    text-align: center;
  }
  #speed-value { font-size: 38px; }
  #speed-unit  { font-size: 11px; }

  #hud-top { padding: 10px 12px; }
  #score-value, #best-value { font-size: 15px; }
  #hearts { font-size: 20px; margin-top: 8px; }

  .title { font-size: clamp(30px, 11cqw, 64px); letter-spacing: 3px; }
  .tagline { font-size: 13px; max-width: 90%; }
  .controls { padding: 10px 16px; font-size: 12px; line-height: 1.9; }
  .controls kbd { font-size: 10px; padding: 0 5px; min-width: 18px; }
}

@media (max-width: 520px) {
  #score-box, #best-box { padding: 4px 9px; }
  #score-box .label, #best-box .label { font-size: 9px; letter-spacing: 1px; }
  .big-score { font-size: 20px; }
  .overlay { padding: 14px; gap: 10px; }
}
