:root {
  --cream: #fff4df;
  --cream-2: #f4d7a8;
  --red: #e10600;
  --red-deep: #9d0b16;
  --ink: #1c120e;
  --chrome: #f4f6f8;
  --good: #1c7a3a;
  --app-h: 100dvh;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: #140e0c;
  color: var(--ink);
  font-family: "Lilita One", "Arial Rounded MT Bold", "Arial Black", sans-serif;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button, a { font-family: inherit; }

img { -webkit-user-drag: none; max-width: 100%; }

.shell {
  height: var(--app-h);
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #2a211c;
  overflow: hidden;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #ff7a3c;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(28, 18, 14, 0.55), rgba(28, 18, 14, 0));
}

#hud[hidden] { display: none !important; }

.hud-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hud-head {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  object-position: center 18%;
  background: #1c120e;
  border: 2px solid var(--cream);
  box-shadow: 0 0 0 2px var(--red);
}

.score {
  font-family: Bungee, Impact, sans-serif;
  font-size: 26px;
  line-height: 1;
  color: var(--cream);
  text-shadow: 0 2px 0 #1c120e, 0 0 12px rgba(255, 40, 30, 0.85);
}

.best {
  margin-top: 3px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #ffe08a;
  text-shadow: 0 1px 0 #1c120e;
}

.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: var(--cream);
  color: var(--ink);
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: 0 3px 0 var(--red-deep);
  cursor: pointer;
}

.icon-btn:active { transform: translateY(2px); box-shadow: none; }

.icon-btn svg { width: 24px; height: 24px; display: block; }

#nitroBar {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(64px + env(safe-area-inset-top));
  z-index: 3;
  height: 14px;
  border-radius: 99px;
  border: 2px solid var(--ink);
  background: rgba(28, 18, 14, 0.45);
  overflow: hidden;
  pointer-events: none;
}

#nitroBar[hidden] { display: none !important; }

#nitroBar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffe08a, #ff5a1f 40%, #e10600);
}

#hint {
  position: absolute;
  left: 50%;
  top: calc(64px + env(safe-area-inset-top));
  transform: translateX(-50%);
  z-index: 3;
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(28, 18, 14, 0.78);
  border: 2px solid rgba(255, 244, 223, 0.35);
  text-align: center;
  color: var(--cream);
  font-size: 13px;
  line-height: 1.25;
  pointer-events: none;
}

#countdown {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  font-family: Bungee, Impact, sans-serif;
  font-size: min(30vw, 148px);
  color: var(--cream);
  text-shadow: 0 6px 0 #1c120e, 0 0 24px rgba(255, 40, 30, 0.9);
  pointer-events: none;
}

#banner {
  position: absolute;
  top: 24%;
  left: 0;
  right: 0;
  z-index: 4;
  margin: 0;
  text-align: center;
  font-family: Bungee, Impact, sans-serif;
  font-size: min(12vw, 52px);
  color: #ffe08a;
  text-shadow: 0 3px 0 #1c120e, 0 0 18px var(--red);
  pointer-events: none;
  opacity: 0;
}

#banner.show { animation: pop 0.85s ease; }

@keyframes pop {
  0% { opacity: 0; transform: scale(0.7); }
  18% { opacity: 1; transform: scale(1.06); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}

#controls {
  display: flex;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #1c120e;
}

.pad {
  flex: 1;
  height: 76px;
  border-radius: 18px;
  border: 3px solid var(--ink);
  font-size: 26px;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.pad span { display: block; font-size: 14px; letter-spacing: 0.14em; }

#laneBtn {
  background: var(--cream);
  color: var(--red);
  box-shadow: 0 5px 0 #8a6a3a, 0 0 16px rgba(255, 220, 160, 0.25);
}

#jumpBtn {
  background: radial-gradient(circle at 50% 0%, #ff5148, var(--red) 46%, #a30812);
  color: var(--cream);
  box-shadow: 0 5px 0 var(--red-deep), 0 0 18px rgba(255, 40, 30, 0.45);
}

.pad:active { transform: translateY(3px); box-shadow: none; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(20, 12, 10, 0.42);
}

.overlay[hidden] { display: none !important; }

#title.overlay {
  background:
    linear-gradient(180deg, rgba(255, 244, 223, 0.78) 0%, rgba(255, 228, 196, 0.9) 42%, rgba(255, 214, 176, 0.94) 100%),
    url("../assets/dragway.jpg") center 18% / cover no-repeat;
  align-items: stretch;
  padding: 0;
}

.title-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: calc(22px + env(safe-area-inset-top)) 16px calc(22px + env(safe-area-inset-bottom));
  text-align: center;
}

#title .checkers {
  position: absolute;
  left: 0;
  right: 0;
  width: auto;
}

#title .checkers:first-child { top: 0; }
#title .checkers:last-child { bottom: 0; }

.checkers {
  height: 16px;
  width: 100%;
  flex: none;
  background: repeating-conic-gradient(#161616 0% 25%, #f6f3ec 0% 50%) 0 0 / 16px 16px;
  border-top: 2px solid #161616;
  border-bottom: 2px solid #161616;
}

.logo-wrap {
  background: #fff;
  border-radius: 18px;
  border: 3px solid var(--ink);
  box-shadow: 0 0 0 3px var(--chrome), 0 0 0 6px var(--red), 0 12px 28px rgba(90, 20, 10, 0.28);
  padding: 4px 8px 0;
  line-height: 0;
}

.logo-wrap img {
  width: min(78vw, 380px);
  max-height: 30vh;
  object-fit: contain;
  display: block;
}

.game-name {
  margin: 2px 0 0;
  font-family: Pacifico, "Segoe Script", cursive;
  font-size: clamp(26px, 7vw, 40px);
  color: var(--red);
  text-shadow: 0 2px 0 #fff, 0 0 14px rgba(255, 40, 30, 0.45);
  font-weight: 400;
}

.chrome-word {
  margin: 0;
  font-family: Bungee, Impact, sans-serif;
  font-size: clamp(22px, 6.4vw, 36px);
  letter-spacing: 0.04em;
  color: #f7f8fa;
  text-shadow:
    0 1px 0 #fff,
    0 2px 0 #c5c9d1,
    0 3px 0 #8e949c,
    0 5px 0 #3a1214,
    0 0 16px rgba(255, 40, 30, 0.55);
}

.tagline {
  margin: 0;
  font-size: 16px;
  color: var(--ink);
}

.weekly {
  margin: 0;
  background: var(--ink);
  color: #ffe08a;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  letter-spacing: 0.02em;
}

.play {
  appearance: none;
  margin-top: 4px;
  min-width: min(86vw, 300px);
  min-height: 68px;
  padding: 12px 28px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: radial-gradient(circle at 50% 0%, #ff5a4f, var(--red) 48%, #9d0b16);
  color: var(--cream);
  font-size: 30px;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-shadow: 0 2px 0 #6e0a10;
  box-shadow:
    0 0 0 4px var(--chrome),
    0 0 0 7px var(--ink),
    0 7px 0 #6e0a10,
    0 0 22px rgba(255, 40, 30, 0.6);
}

.play:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 4px var(--chrome), 0 0 0 7px var(--ink), 0 3px 0 #6e0a10;
}

.title-best { margin: 0; font-size: 16px; letter-spacing: 0.04em; }

.how {
  margin: 0;
  max-width: 36rem;
  font-size: 14px;
  line-height: 1.35;
  color: #3a271c;
}

.title-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.text-link {
  color: var(--red-deep);
  font-size: 16px;
}

.card {
  width: min(440px, 100%);
  max-height: calc(var(--app-h) - 24px);
  overflow: auto;
  background: var(--cream);
  color: var(--ink);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 0 0 4px var(--red), 0 18px 40px rgba(0, 0, 0, 0.35);
  text-align: center;
  touch-action: pan-y;
}

.card .checkers { border-radius: 16px 16px 0 0; }

.card-body { padding: 12px 16px 16px; }

.eyebrow {
  margin: 8px 0 0;
  letter-spacing: 0.16em;
  font-size: 14px;
  color: var(--red);
}

.end-score {
  margin: 4px 0;
  font-family: Bungee, Impact, sans-serif;
  font-size: clamp(36px, 10vw, 52px);
  line-height: 1;
  color: var(--ink);
  text-shadow: 0 2px 0 #fff, 0 0 12px rgba(255, 40, 30, 0.35);
}

.break, .best-line, .fine {
  margin: 4px 0;
  font-size: 15px;
}

.record {
  display: inline-block;
  margin: 4px 0;
  background: var(--red);
  color: var(--cream);
  border-radius: 999px;
  padding: 3px 10px;
  letter-spacing: 0.08em;
  font-size: 14px;
}

.bar {
  height: 14px;
  margin: 10px 0 6px;
  border-radius: 99px;
  border: 2px solid var(--ink);
  background: #ead7b4;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffb703, var(--red));
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  text-decoration: none;
  font-size: 20px;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 8px 12px;
}

.btn.solid {
  background: var(--red);
  color: var(--cream);
  box-shadow: 0 4px 0 var(--red-deep);
}

.btn.ghost {
  background: #fff;
  color: var(--ink);
}

.btn.texty {
  background: transparent;
  border-color: transparent;
  color: var(--red-deep);
  min-height: 40px;
  box-shadow: none;
}

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

.reward-head {
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin-top: 8px;
  filter: drop-shadow(0 6px 0 rgba(28, 18, 14, 0.15));
}

.reward h2 {
  margin: 6px 0;
  font-family: Bungee, Impact, sans-serif;
  font-size: clamp(18px, 4.8vw, 24px);
  line-height: 1.25;
  font-weight: 400;
}

.ticket {
  margin: 10px auto 0;
  padding: 8px 12px 10px;
  border: 2px dashed var(--ink);
  border-radius: 14px;
  background: #fff;
}

.ticket-brand {
  letter-spacing: 0.14em;
  font-size: 13px;
}

.ticket-off {
  font-family: Pacifico, cursive;
  color: var(--red);
  font-size: 26px;
}

button.code {
  background: none;
  border: 0;
  color: var(--red);
  font-family: Bungee, Impact, sans-serif;
  font-size: clamp(22px, 6vw, 30px);
  letter-spacing: 0.08em;
  cursor: pointer;
  user-select: all;
  -webkit-user-select: all;
  padding: 2px 4px;
}

button.code[data-copied="1"] { color: var(--good); }

.tap-copy { margin: 0; font-size: 12px; color: #6b5344; }

.placeholder-flag {
  display: inline-block;
  margin: 6px 0 0;
  background: var(--ink);
  color: #ffe08a;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  letter-spacing: 0.04em;
}

button:focus-visible, a:focus-visible, .play:focus-visible {
  outline: 3px solid #ffe08a;
  outline-offset: 3px;
}

body[data-mode="title"] #controls,
body[data-mode="over"] #controls,
body[data-mode="crash"] #controls,
body[data-mode="title"] #hud,
body[data-mode="over"] #hud,
body[data-mode="title"] #hint,
body[data-mode="over"] #hint,
body[data-mode="paused"] #hint {
  display: none !important;
}

body[data-mode="paused"] #controls { visibility: hidden; }

@media (max-height: 520px) {
  .shell { display: block; }
  .stage { position: absolute; inset: 0; }
  #controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    background: linear-gradient(transparent, rgba(20, 12, 8, 0.62));
    pointer-events: none;
  }
  #controls .pad {
    pointer-events: auto;
    height: 58px;
    max-width: 210px;
    font-size: 20px;
  }
  #hint { top: calc(56px + env(safe-area-inset-top)); font-size: 12px; }
  .logo-wrap img { max-height: 22vh; }
  .tagline, .how { display: none; }
  .play { min-height: 52px; font-size: 24px; }
  .reward-head { width: 64px; height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  #banner.show { animation: none; opacity: 1; }
  .play, .pad, .btn { transition: none; }
}

@media (min-width: 900px) {
  .score { font-size: 32px; }
  .pad { height: 84px; font-size: 28px; }
}
