:root {
  --ink: #1a1428;
  --cream: #f3ebdd;
  --amber: #f6c445;
  --cherry: #e23d4a;
  --dusk: #070814;
  --muted: #5c5348;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--dusk);
  overflow: hidden;
  overscroll-behavior: none;
  font-family: Manrope, "Segoe UI", sans-serif;
  color: var(--cream);
}

button, p, h1 { font: inherit; }

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

#hud[hidden] { display: none; }

.meter {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meter.xp { left: 22px; align-items: flex-start; }
.meter.spd { right: 22px; align-items: flex-end; }

.meter span {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  line-height: 1;
  color: #fff4e4;
  text-shadow: 0 0 14px rgba(246, 196, 69, 0.75);
}

.meter.spd span {
  color: #ff4d63;
  text-shadow: 0 0 14px rgba(255, 77, 99, 0.7);
}

#xp,
#spd {
  font-family: Unbounded, Manrope, sans-serif;
  font-weight: 700;
  font-size: clamp(40px, 6.4vw, 68px);
  letter-spacing: -0.05em;
  line-height: 1;
  color: #fff4e4;
  text-shadow: 0 0 22px rgba(246, 196, 69, 0.7);
}

#spd {
  color: #ff4d63;
  text-shadow: 0 0 22px rgba(255, 77, 99, 0.65);
}

#toast {
  position: absolute;
  left: 50%;
  bottom: calc(118px + env(safe-area-inset-bottom));
  transform: translate(-50%, 6px);
  opacity: 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--amber);
  color: var(--ink);
  font-family: Unbounded, Manrope, sans-serif;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

#toast.show { animation: pop 1.45s ease forwards; }

#count {
  position: fixed;
  left: 50%;
  top: 38%;
  z-index: 4;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-family: Unbounded, Manrope, sans-serif;
  font-weight: 700;
  font-size: clamp(96px, 18vw, 180px);
  line-height: 1;
  color: #ff4058;
}

#count.yel { color: #ffe14a; }
#count.go { color: #3dff7a; }
#count[hidden] { display: none; }

@keyframes pop {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  14% { opacity: 1; transform: translate(-50%, 0); }
  72% { opacity: 1; }
  100% { opacity: 0; }
}

#spd.bump { animation: bump 0.35s ease; }

@keyframes bump {
  40% { transform: scale(1.08); }
}

#vol {
  position: absolute;
  right: 14px;
  top: calc(14px + env(safe-area-inset-top));
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#mute {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(243, 235, 221, 0.92);
  color: var(--ink);
  font-family: Unbounded, Manrope, sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.vol-panel {
  display: grid;
  place-items: center;
  width: 40px;
  height: 0;
  margin-top: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  border-radius: 12px;
  transition: height 0.18s ease, opacity 0.18s ease, margin 0.18s ease, padding 0.18s ease;
}

#vol:hover .vol-panel,
#vol:focus-within .vol-panel,
#vol.open .vol-panel {
  height: 112px;
  margin-top: 8px;
  padding: 10px 0;
  opacity: 1;
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 12, 22, 0.88);
}

.vol-panel input {
  appearance: slider-vertical;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 18px;
  height: 88px;
  margin: 0;
  accent-color: #2ee6c5;
  cursor: pointer;
}

#pick {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: calc(14px + env(safe-area-inset-top)) 18px calc(16px + env(safe-area-inset-bottom));
  background:
    radial-gradient(90% 62% at 50% 40%, rgba(62, 232, 255, 0.12) 0%, transparent 62%),
    radial-gradient(70% 50% at 50% 104%, rgba(255, 94, 200, 0.16) 0%, transparent 70%),
    rgba(5, 6, 16, 0.9);
  backdrop-filter: blur(14px) saturate(1.1);
}

#pick[hidden] { display: none; }

#bays {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pick-top {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 104px;
}

#pickBack {
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  background: rgba(243, 235, 221, 0.12);
  color: var(--cream);
  font-family: Unbounded, Manrope, sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

#pickGarage {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  color: #8de6ff;
}

#stage {
  position: relative;
  width: min(1000px, 100%);
  justify-self: center;
}

#pickPrev,
#pickNext {
  position: absolute;
  z-index: 3;
  top: 46%;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: rgba(243, 235, 221, 0.1);
  color: var(--cream);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

#pickPrev { left: 16px; }
#pickNext { right: 16px; }

#pickPrev:hover,
#pickNext:hover { background: rgba(243, 235, 221, 0.2); }

#pickInfo {
  position: relative;
  z-index: 3;
  text-align: center;
  padding-bottom: 6px;
}

@keyframes pickRise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

@keyframes pickOpen {
  from { opacity: 0; transform: scale(1.04); }
  to { opacity: 1; transform: none; }
}

#pick.opening { animation: pickOpen 0.34s ease both; }

#pickInfo.in > * { animation: pickRise 0.44s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
#pickInfo.in #pickName { animation-delay: 0.05s; }
#pickInfo.in #pickSpeed { animation-delay: 0.1s; }
#pickInfo.in #pickSpecs { animation-delay: 0.15s; }
#pickInfo.in #pickNote { animation-delay: 0.2s; }

#pickEyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: lowercase;
  color: var(--cherry);
}

#pickName {
  margin: 2px 0 0;
  font-family: Unbounded, Manrope, sans-serif;
  font-size: clamp(34px, 6vw, 56px);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--cream);
}

#pickSpeed[hidden],
#pickSpecs[hidden] { display: none; }

#pickSpeed {
  margin: 4px 0 0;
  font-family: Unbounded, Manrope, sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--tint, #f6c445);
}

#pickSpecs {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 132px));
  justify-content: center;
  gap: 14px;
  margin: 14px 0 0;
}

#pickSpecs .line {
  display: grid;
  gap: 5px;
  text-align: left;
}

#pickSpecs em {
  display: flex;
  justify-content: space-between;
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #98a0b8;
}

#pickSpecs em i {
  font-style: normal;
  color: var(--cream);
}

#pickSpecs .bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(243, 235, 221, 0.14);
  overflow: hidden;
}

#pickSpecs .bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#pickNote {
  margin: 10px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: #9aa0b4;
}

#pickNote.lock { color: #ffd9a0; }

#paints {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 14px;
  padding: 2px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

#paints::-webkit-scrollbar { display: none; }

.carpick {
  position: relative;
  flex: 0 0 auto;
  width: 96px;
  border: 2px solid rgba(243, 235, 221, 0.14);
  border-radius: 14px;
  padding: 0 0 7px;
  overflow: hidden;
  color: var(--cream);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
  background:
    radial-gradient(120% 52% at 50% 58%, color-mix(in srgb, var(--tint) 40%, transparent) 0%, transparent 66%),
    linear-gradient(180deg, #080a16 0%, #131b2c 74%, #0b0e1a 100%);
}

.carpick .bay {
  position: relative;
  display: block;
  height: 54px;
}

.carpick .q {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 4;
  height: 54px;
  display: grid;
  place-items: center;
  color: #f4f1ea;
  font-family: Unbounded, Manrope, sans-serif;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

.stage-q {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 4;
  color: rgba(244, 241, 234, 0.94);
  font-family: Unbounded, Manrope, sans-serif;
  font-size: clamp(84px, 14vw, 140px);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 10px 36px rgba(0, 0, 0, 0.75);
  transform: translate(-50%, -58%);
  pointer-events: none;
}

.stage-q[hidden] { display: none; }

.carpick b {
  display: block;
  margin-top: 6px;
  font-family: Unbounded, Manrope, sans-serif;
  font-size: 12px;
  letter-spacing: -0.01em;
}

.carpick.on {
  border-color: var(--tint);
  margin-top: -4px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.carpick.locked {
  cursor: not-allowed;
  background:
    radial-gradient(120% 52% at 50% 58%, rgba(255, 255, 255, 0.05) 0%, transparent 66%),
    linear-gradient(180deg, #080a16 0%, #12141c 74%, #0b0e1a 100%);
}

.carpick.locked.on { border-color: rgba(243, 235, 221, 0.72); }

#pickGo {
  position: relative;
  z-index: 3;
  justify-self: center;
  width: min(360px, 100%);
  border: 0;
  border-radius: 999px;
  padding: 15px 20px;
  background: var(--cream);
  color: var(--ink);
  font-family: Unbounded, Manrope, sans-serif;
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
}

#pickGo:disabled {
  background: rgba(243, 235, 221, 0.22);
  color: rgba(243, 235, 221, 0.6);
  cursor: not-allowed;
  box-shadow: none;
}

#pick.firing #pickPrev,
#pick.firing #pickNext,
#pick.firing #pickBack,
#pick.firing #paints,
#pick.firing #pickGo {
  pointer-events: none;
}

#pick.firing #pickGo {
  opacity: 0.72;
}

@media (max-width: 560px) {
  #pickSpecs { grid-template-columns: repeat(2, minmax(80px, 140px)); }
  #pickPrev, #pickNext { top: 40%; }
}

button:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  #toast.show, #spd.bump, #notice.show { animation: none; opacity: 1; }
}
