/* SUV ROAD RUSH — landscape highway racer. Self-contained, no external fonts. */
:root {
  --ink: #1b2a3a;
  --card: rgba(255, 255, 255, 0.94);
  --accent: #ff6a3d;
  --accent-d: #d8481f;
  --shadow: 0 12px 40px rgba(10, 25, 45, 0.35);
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP",
    "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #1b2a3a; color: var(--ink);
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#app { position: fixed; inset: 0; }
#game { display: block; width: 100%; height: 100%; }

/* ---------------- HUD ---------------- */
.hud {
  position: absolute; inset: 0; pointer-events: none;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
}
.hud-left { position: absolute; top: 10px; left: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.stat.lives .stat-val { font-size: 15px; letter-spacing: 1px; }
.hud-right { position: absolute; top: 10px; right: 14px; display: flex; gap: 8px; }
.stat {
  background: var(--card); border-radius: 12px; padding: 5px 12px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; line-height: 1.1;
}
.stat-label { font-size: 9px; letter-spacing: 0.08em; opacity: 0.6; }
.stat-val { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-val small { font-size: 10px; font-weight: 600; opacity: 0.7; margin-left: 1px; }
.stat.time .stat-val b { font-size: 22px; }
.stat.time.low { animation: pulseRed 0.6s ease-in-out infinite; }
.stat.time.low .stat-val { color: #e0341f; }
@keyframes pulseRed { 50% { transform: scale(1.08); } }

.progress {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: min(46vw, 420px);
}

/* combo multiplier popup (center) */
.combo {
  position: absolute; top: 30%; left: 50%; transform: translateX(-50%);
  display: flex; align-items: baseline; gap: 4px; pointer-events: none;
  font-weight: 900; color: #ffd23c;
  text-shadow: 0 2px 0 #b4600e, 0 0 18px rgba(255,180,40,0.7);
  font-size: 30px; font-style: italic;
}
.combo b { font-size: 52px; line-height: 1; }
.combo span { font-size: 15px; letter-spacing: 2px; align-self: center; }
.combo.bump { animation: comboBump 0.22s ease-out; }
@keyframes comboBump { 0% { transform: translateX(-50%) scale(1.35); } 100% { transform: translateX(-50%) scale(1); } }

/* active power-up chips (top-center under progress) */
.powerups {
  position: absolute; top: 30px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; pointer-events: none;
}
.pu-chip {
  display: flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,0.92); border-radius: 999px; padding: 3px 10px 3px 8px;
  box-shadow: var(--shadow); font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums;
}
.pu-chip .pu-ico { font-size: 16px; }
.pu-chip.magnet { color: #b5340e; } .pu-chip.shield { color: #1f6fd8; } .pu-chip.boost { color: #1f9e4a; }
.progress-bar {
  position: relative; height: 10px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.35); box-shadow: var(--shadow);
  border: 1.5px solid rgba(255, 255, 255, 0.6);
}
.progress-bar i {
  position: absolute; left: 0; top: 0; height: 100%; width: 0%;
  background: linear-gradient(90deg, #4fd06a, #ffd34d); border-radius: 8px;
}
#progress-car {
  position: absolute; top: -11px; left: 0; transform: translateX(-50%);
  font-size: 18px; transition: left 0.1s linear;
}

/* ---------------- Controls (landscape) ---------------- */
.controls { position: absolute; inset: 0; pointer-events: none; }
.ctrl-left {
  position: absolute; left: max(16px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
}
.ctrl-right {
  position: absolute; right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; align-items: flex-end;
}
.pad {
  pointer-events: auto; border: none; color: #fff; font: inherit;
  box-shadow: var(--shadow); opacity: 0.92;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform 0.06s, opacity 0.1s; touch-action: none;
}
.pad:active { transform: scale(0.93); opacity: 1; }
.pad-ico { font-size: 26px; line-height: 1; }
.pad-txt { font-size: 11px; font-weight: 800; margin-top: 2px; }
.pad.gas { width: 118px; height: 118px; border-radius: 50%;
  background: linear-gradient(180deg, #35c463, #1f9e4a); }
.pad.brake { width: 92px; height: 92px; border-radius: 22px;
  background: linear-gradient(180deg, #ff8a5c, #e35528); }
.pad.jump { width: 92px; height: 92px; border-radius: 22px;
  background: linear-gradient(180deg, #4aa3ff, #2f6fd8); }

/* steering wheel indicator (bottom-center) */
.tiltwrap {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom)); pointer-events: none; opacity: 0.85;
}
.wheel {
  width: 54px; height: 54px; border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.85);
  background: rgba(20, 30, 45, 0.4); position: relative;
  box-shadow: var(--shadow);
}
.wheel i {
  position: absolute; left: 50%; top: 50%; width: 4px; height: 24px;
  background: #fff; border-radius: 3px; transform-origin: bottom center;
  transform: translate(-50%, -100%); transition: transform 0.08s;
}
@media (hover: hover) and (pointer: fine) {
  .controls, .tiltwrap { display: none !important; }
}

/* ---------------- Screens ---------------- */
.screen {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 20;
  background: radial-gradient(120% 120% at 50% 20%, rgba(30, 60, 95, 0.25), rgba(8, 18, 32, 0.72));
  backdrop-filter: blur(2px);
}
.screen.paused { background: rgba(8, 18, 32, 0.6); }
.screen-card {
  background: var(--card); border-radius: 22px; padding: 22px 26px;
  box-shadow: var(--shadow); text-align: center; max-width: 440px; width: 100%;
  max-height: 94vh; overflow-y: auto;
  animation: pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.badge {
  display: inline-block; font-size: 11px; letter-spacing: 0.1em; font-weight: 800;
  color: var(--accent-d); background: rgba(255, 106, 61, 0.14);
  padding: 5px 12px; border-radius: 999px; margin-bottom: 10px;
}
.over-badge { color: #b33; background: rgba(220, 50, 50, 0.14); }
.screen-card h1 { margin: 2px 0 6px; font-size: 34px; line-height: 1; letter-spacing: -0.01em; }
.screen-card h1 span { color: var(--accent); }
.over-title { font-size: 28px; }
.tag { margin: 4px 0 16px; opacity: 0.75; font-size: 14px; line-height: 1.45; }
.tag b { color: var(--accent-d); }

.btn-primary {
  border: none; cursor: pointer; font: inherit; font-weight: 800; font-size: 18px; color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-d));
  padding: 13px 44px; border-radius: 14px;
  box-shadow: 0 8px 20px rgba(216, 72, 31, 0.4); transition: transform 0.08s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(1px) scale(0.98); }

.best { margin-top: 14px; font-size: 13px; opacity: 0.75; }
.best b { font-size: 17px; color: var(--ink); }

.howto {
  margin-top: 16px; display: flex; flex-direction: column; gap: 7px;
  font-size: 12px; opacity: 0.85; text-align: left;
  background: rgba(20, 40, 65, 0.05); border-radius: 12px; padding: 12px 14px;
}
.howto-row { line-height: 1.4; }
.howto .k {
  font-weight: 800; color: var(--accent-d);
  background: rgba(255, 106, 61, 0.12); padding: 1px 7px; border-radius: 6px;
  white-space: nowrap;
}
kbd {
  background: #eef2f5; border: 1px solid #cfd8de; border-bottom-width: 2px;
  border-radius: 5px; padding: 0 5px; font-family: inherit; font-size: 11px;
}
.desktop-only { display: none; }
@media (hover: hover) and (pointer: fine) { .desktop-only { display: block; } }

.disclaimer { margin: 14px 0 0; font-size: 10px; opacity: 0.5; line-height: 1.4; }

.result { display: flex; justify-content: center; gap: 24px; margin: 6px 0 4px; }
.result > div { display: flex; flex-direction: column; }
.result span { font-size: 11px; opacity: 0.6; }
.result b { font-size: 26px; font-variant-numeric: tabular-nums; }
.new-best {
  margin: 12px 0 4px; font-weight: 800; color: #d8481f;
  animation: glow 1s ease-in-out infinite alternate;
}
@keyframes glow { from { opacity: 0.7; } to { opacity: 1; transform: scale(1.04); } }

/* ---------------- Rotate gate ---------------- */
.rotate {
  position: absolute; inset: 0; z-index: 40;
  background: #12203300; background: rgba(12, 22, 36, 0.96);
  display: flex; align-items: center; justify-content: center; color: #fff; text-align: center;
}
.rotate-inner p { font-size: 20px; font-weight: 800; margin: 14px 0 4px; }
.rotate-inner small { opacity: 0.6; font-size: 12px; }
.rotate-ico { font-size: 62px; animation: rot 1.6s ease-in-out infinite; }
@keyframes rot { 0%, 40% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

@media (max-width: 500px) {
  .screen-card h1 { font-size: 28px; }
  .pad.gas { width: 96px; height: 96px; }
  .pad.brake, .pad.jump { width: 78px; height: 78px; }
}
@media (max-height: 380px) {
  .screen-card { padding: 14px 20px; }
  .screen-card h1 { font-size: 24px; }
  .tag { margin-bottom: 10px; font-size: 12px; }
  .howto { margin-top: 10px; }
}
