:root {
  --vh: 1vh;
  --gold: #ffcf4d;
  --gold2: #ffa826;
  --amber-dark: #9a5c0e;
  --teal: #37e0c4;
  --coral: #ff6b6b;
  --ink: #0a2015;
  --panel: rgba(10, 28, 20, 0.5);
  --panel-b: rgba(255, 255, 255, 0.16);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  touch-action: none;
  background:
    linear-gradient(rgba(28, 19, 82, 0.10), rgba(28, 19, 82, 0.10)),
    url('bg.png') center center / cover no-repeat;

}

#gameWrap {
  position: relative;
  width: 100vw;
  height: calc(var(--vh, 1vh)*100);
  overflow: hidden;
  background: #0e2417;
}

#three-canvas {
  position: absolute;
  inset: 0;
  display: block;
}

#uiLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.glass {
  background: linear-gradient(180deg, #4b4833 0%, #35331f 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 236, 170, 0.22);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.42), 0 2px 0 rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 -2px 6px rgba(0, 0, 0, 0.25);
}

/* floating ambient particles behind UI */
#ambientFx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.mote {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6d0, rgba(255, 246, 208, 0));
  opacity: 0.55;
  animation: floatMote linear infinite;
}

@keyframes floatMote {
  0% {
    transform: translateY(10vh) translateX(0) scale(0.6);
    opacity: 0;
  }

  10% {
    opacity: 0.6;
  }

  90% {
    opacity: 0.5;
  }

  100% {
    transform: translateY(-40vh) translateX(20px) scale(1);
    opacity: 0;
  }
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 0 14px;
  pointer-events: none;
  z-index: 6;
}

.hudPill {
  border-radius: 999px;
  padding: 9px 16px 9px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #fff8e6;
  font-size: 15px;
}

.hudPill .ic {
  width: 20px;
  height: 20px;
  flex: none;
}

.hudPill .val {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  color: var(--gold);
  font-size: 17px;
  letter-spacing: 0.3px;
  min-width: 16px;
  text-align: left;
}

#hudLeft {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

#topRight {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
}

#iconBtns {
  display: flex;
  gap: 9px;
  pointer-events: all;
}

.iconBtn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid rgba(255, 236, 170, 0.28);
  background: linear-gradient(180deg, rgba(75, 72, 51, 0.92), rgba(40, 38, 24, 0.92));
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(14px);
  transition: transform .15s ease, box-shadow .15s ease;
}

.iconBtn:active {
  transform: scale(0.86);
}

.iconBtn svg {
  width: 20px;
  height: 20px;
  fill: #fff8e6;
}

#heartsRow {
  display: flex;
  gap: 5px;
  align-items: center;
}

.heart {
  width: 20px;
  height: 18px;
}

.heart svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

#speedBadge {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--teal);
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity .3s ease;
}

#speedBadge.show {
  opacity: 1;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  text-align: center;
  padding: 24px;
  z-index: 5;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.97);
  transition: opacity .4s cubic-bezier(.2, .8, .2, 1), transform .4s cubic-bezier(.2, .8, .2, 1), visibility .4s;
  background: radial-gradient(ellipse at 50% 20%, rgba(30, 80, 55, 0.28), rgba(4, 14, 9, 0.72) 65%);
}

.screen.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.logoWrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
}

h1.title {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 44px;
  background: linear-gradient(100deg, #fff7d6 0%, var(--gold) 25%, #fff7d6 50%, var(--gold2) 75%, #fff7d6 100%);
  background-size: 240% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 1px;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  animation: shine 4.5s linear infinite;
}

@keyframes shine {
  0% {
    background-position: 0% 50%;
  }

  100% {
    background-position: -240% 50%;
  }
}

.subtitle {
  color: #ffffff;
  font-size: 16.5px;
  margin-top: 6px;
  letter-spacing: 2.5px;
  opacity: 0.8;
  text-transform: uppercase;
  font-weight: 600;
  font-weight: bold;
}

.btn {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: #12300e;
  border: none;
  border-radius: 30px;
  padding: 16px 40px;
  cursor: pointer;
  background: linear-gradient(180deg, #fff6c4, var(--gold) 52%, var(--gold2));
  box-shadow: 0 5px 0 var(--amber-dark), 0 12px 26px rgba(0, 0, 0, 0.45), 0 0 22px rgba(255, 190, 60, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.7), inset 0 -3px 6px rgba(190, 110, 10, 0.35);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  margin: 7px 6px;
  transition: transform .12s ease, box-shadow .12s ease;
  min-width: 210px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  animation: btnShine 3.2s ease-in-out infinite;
}

@keyframes btnShine {

  0%,
  60% {
    left: -60%;
  }

  100% {
    left: 140%;
  }
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--amber-dark), 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn.secondary {
  background: linear-gradient(180deg, #55523a, #35331f);
  color: #fff8e6;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.4), 0 10px 20px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.22);
  min-width: 205px;
  font-size: 15px;
  padding: 13px 26px;
  margin-top: 5%;
  margin-bottom: 5%;
}

.btn.secondary::after {
  display: none;
}

.btn.secondary:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.btnRow {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.statsRow {
  display: flex;
  gap: 12px;
  margin: 12px 0 20px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.statCard {
  border-radius: 18px;
  padding: 13px 22px;
  min-width: 98px;
  position: relative;
}

.statCard .label {
  font-size: 10.5px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #a9d4b3;
  margin-bottom: 5px;
  font-weight: 600;
}

.statCard .num {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 23px;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(255, 201, 60, 0.25);
}

.newBest {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  background: linear-gradient(90deg, #ff9f6b, #ffd76b);
  color: #3a1a00;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 6px 16px;
  border-radius: 999px;
  text-transform: uppercase;
  animation: pulseBadge 1s ease infinite;
  box-shadow: 0 4px 14px rgba(255, 180, 60, 0.4);
}

@keyframes pulseBadge {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.08);
  }
}

h2.screenTitle {
  font-family: 'Baloo 2', sans-serif;
  color: #fff8e6;
  font-size: 27px;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
}

#htpVisual {
  width: min(230px, 62vw);
  height: 130px;
  border-radius: 18px;
  overflow: hidden;
  margin: 10px 0 16px 0;
  position: relative;
  border: 1px solid var(--panel-b);
  background: linear-gradient(180deg, #2c6b3a, #123018);
  display: flex;
  align-items: center;
  justify-content: center;
}

#htpVisual .arrow {
  position: absolute;
  font-size: 34px;
  animation: hop 1s ease-in-out infinite;
}

@keyframes hop {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-18px);
  }
}

.htpTips {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 16px;
  max-width: 320px;
}

.htpTip {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border-radius: 15px;
  padding: 11px 15px;
}

.htpTip .htpIcon {
  width: 32px;
  height: 32px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.htpTip .htpIcon svg {
  width: 100%;
  height: 100%;
}

.htpTip .txt {
  font-size: 13.5px;
  color: #e9f6ea;
  line-height: 1.35;
}

.htpTip .txt b {
  color: var(--gold);
}

#loadBarOuter {
  width: min(240px, 60vw);
  height: 11px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
  margin-top: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  position: relative;
}

#loadBarInner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold2), var(--gold), #fff2c2);
  border-radius: 999px;
  transition: width .25s ease;
  position: relative;
  overflow: hidden;
}

#loadBarInner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  width: 50%;
  animation: btnShine 1.4s ease-in-out infinite;
}

#loadLabel {
  margin-top: 13px;
  font-size: 13px;
  color: #cfe9d4;
  letter-spacing: 0.5px;
}

#flashOverlay {
  position: absolute;
  inset: 0;
  background: var(--coral);
  opacity: 0;
  pointer-events: none;
  z-index: 4;
  mix-blend-mode: screen;
}

.footNote {
  margin-top: 15px;
  font-size: 11.5px;
  color: #8fb99a;
  letter-spacing: 0.5px;
}

@media (min-width:700px) {
  #gameWrap {
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.65);
    border-radius: 18px;
    overflow: hidden;
  }

}

.logo {
  height: 160px;
  border-radius: 30px;
  margin-bottom: 20px;
  margin-top: 20px;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 18px rgba(255, 210, 90, 0.25));
  animation: logoFloat 3.2s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-7px) rotate(1deg); }
}

/* cinematic vignette over the 3D scene (under all UI) */
#gameWrap::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(0, 0, 0, 0) 52%, rgba(6, 24, 12, 0.38) 100%),
    linear-gradient(180deg, rgba(255, 236, 190, 0.08), rgba(255, 236, 190, 0) 35%);
}

/* radial speed streaks that fade in as the run gets faster */
#speedLines {
  position: absolute;
  inset: -10%;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity .4s linear;
  background: repeating-conic-gradient(from 0deg at 50% 46%, rgba(255, 255, 255, 0) 0deg 5deg, rgba(255, 255, 255, 0.16) 5.4deg 5.8deg, rgba(255, 255, 255, 0) 6.2deg 9deg);
  -webkit-mask-image: radial-gradient(ellipse at 50% 46%, transparent 52%, #000 96%);
  mask-image: radial-gradient(ellipse at 50% 46%, transparent 52%, #000 96%);
}