:root {
  --bg-deep: #060912;
  --bg-mid: #0d1524;
  --road: #1a1f2a;
  --accent: #e82127;
  --accent-soft: #ff4d55;
  --electric: #7ee8ff;
  --sand: #c8b89a;
  --text: #f2f4f8;
  --muted: #9aa6b8;
  --success: #5ee4a8;
  --fail: #ff6b6b;
  --font-display: "Bebas Neue", Impact, sans-serif;
  --font-body: "Space Grotesk", "Segoe UI", sans-serif;
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
}

.mute-btn {
  position: absolute;
  top: calc(0.75rem + env(safe-area-inset-top));
  right: 0.75rem;
  z-index: 8;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(4, 8, 16, 0.55);
  color: var(--electric);
  font-size: 1.05rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.mute-btn[aria-pressed="true"] {
  color: var(--muted);
  opacity: 0.7;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.screen.hidden,
.hud.hidden,
.touch.hidden,
.result.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

.title-atmosphere {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 110%, rgba(232, 33, 39, 0.28), transparent 55%),
    radial-gradient(ellipse 60% 40% at 70% 20%, rgba(126, 232, 255, 0.12), transparent 50%),
    linear-gradient(180deg, #04060c 0%, #0a1220 55%, #101828 100%);
  animation: sky-breathe 8s ease-in-out infinite alternate;
}

@keyframes sky-breathe {
  from { filter: brightness(1); }
  to { filter: brightness(1.08); }
}

.title-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem 1.25rem 5rem;
  max-width: 36rem;
  animation: title-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes title-rise {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.title-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--electric);
  opacity: 0.85;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(4.8rem, 18vw, 9.5rem);
  letter-spacing: 0.06em;
  line-height: 0.9;
  color: var(--text);
  text-shadow:
    0 0 40px rgba(232, 33, 39, 0.45),
    0 12px 40px rgba(0, 0, 0, 0.55);
}

.title-tagline {
  margin: 1rem auto 1.75rem;
  max-width: 22rem;
  font-size: clamp(0.95rem, 2.6vw, 1.15rem);
  line-height: 1.45;
  color: var(--muted);
  font-weight: 500;
}

.cta {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.95rem 2.4rem;
  border-radius: 2px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent) 0%, #a81419 100%);
  box-shadow: 0 10px 30px rgba(232, 33, 39, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.cta:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 14px 36px rgba(232, 33, 39, 0.45);
}

.cta:active {
  transform: translateY(1px) scale(0.98);
}

.cta.secondary {
  background: linear-gradient(135deg, #1e2a3d 0%, #121a28 100%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(126, 232, 255, 0.25);
}

.title-hint {
  margin: 1.25rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 4;
  padding: calc(0.85rem + env(safe-area-inset-top)) 1rem 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  max-width: 720px;
  margin: 0 auto;
}

.phase {
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: 0.12em;
  color: var(--electric);
}

.speed {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--sand);
}

.speed-gauge {
  max-width: 720px;
  margin: 0.65rem auto 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.speed-gauge-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 2.2rem;
}

.speed-gauge-track {
  position: relative;
  flex: 1;
  height: 12px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.speed-gauge-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 0.06s linear, background 0.15s ease;
}

.speed-gauge-fill.ok {
  background: var(--success);
}

.speed-gauge-ideal {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 52%;
  width: 22%;
  border-left: 1px solid rgba(126, 232, 255, 0.85);
  border-right: 1px solid rgba(126, 232, 255, 0.85);
  background: rgba(126, 232, 255, 0.12);
  pointer-events: none;
}

.fuel-gauge {
  margin-top: 0.4rem;
}

.speed-gauge-fill.fuel {
  background: linear-gradient(90deg, #3d8bfd, #7ee8ff);
  transition: width 0.05s linear;
}

.speed-gauge-fill.fuel.low {
  background: #e82127;
}

.fuel-sec {
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--electric);
  min-width: 2.6rem;
  text-align: right;
}

.hint {
  max-width: 720px;
  margin: 0.55rem auto 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: left;
}

.result {
  background: rgba(4, 6, 12, 0.55);
  backdrop-filter: blur(6px);
}

.result-card {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 22rem;
  animation: title-rise 0.5s ease both;
}

.result-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 10vw, 3.4rem);
  letter-spacing: 0.06em;
  line-height: 1;
}

.result-card.success h2 {
  color: var(--success);
}

.result-card.fail h2 {
  color: var(--fail);
}

.result-card p {
  margin: 0.85rem 0 1.5rem;
  color: var(--muted);
  line-height: 1.4;
}

.linkish {
  display: block;
  margin: 0.9rem auto 0;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.touch {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  padding: 0.75rem calc(0.75rem + env(safe-area-inset-right)) calc(0.75rem + env(safe-area-inset-bottom)) calc(0.75rem + env(safe-area-inset-left));
  transition: opacity 0.3s ease;
}

.touch-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(12, 18, 30, 0.72);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 52px;
  border-radius: 4px;
  cursor: pointer;
}

.touch-btn.gas {
  border-color: rgba(232, 33, 39, 0.5);
  background: rgba(232, 33, 39, 0.22);
}

.touch-btn:active {
  filter: brightness(1.25);
}

.back-line {
  margin-top: 1.1rem;
  text-align: center;
}

.back-line a {
  color: rgba(232, 236, 244, 0.65);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}

.back-line a:hover {
  color: #fff;
}

@media (min-width: 820px) {
  .touch {
    display: none;
  }
}

@media (max-width: 819px) {
  .hint {
    font-size: 0.75rem;
  }

  .title-content {
    padding-bottom: 6rem;
  }
}
