@property --a {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

:root {
  --red-900: #3d0309;
  --red-800: #5c0610;
  --red-600: #a10f1d;
  --red-500: #d41f2c;
  --gold-300: #ffe7a3;
  --gold-400: #ffd46b;
  --gold-500: #f5b42f;
  --gold-700: #b8770c;
  --cream: #fff6e0;
}

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

html,
body {
  height: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #4a0710, #1c0205 75%);
  color: var(--cream);
  font-family: 'Baloo 2', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  position: relative;
  width: min(100vw, 480px);
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 200, 90, 0.28), transparent 60%),
    radial-gradient(90% 60% at 50% 100%, rgba(255, 120, 60, 0.22), transparent 70%),
    linear-gradient(180deg, var(--red-600) 0%, var(--red-800) 55%, var(--red-900) 100%);
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.6);
}

.app::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 215, 120, 0.12) 1.2px, transparent 1.6px);
  background-size: 22px 22px;
  pointer-events: none;
}

.rays {
  position: absolute;
  left: 50%;
  top: 34%;
  width: 180%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from var(--a), rgba(255, 220, 140, 0.09) 0 8deg, transparent 8deg 20deg);
  -webkit-mask: radial-gradient(circle, #000 10%, transparent 62%);
  mask: radial-gradient(circle, #000 10%, transparent 62%);
  animation: spin 40s linear infinite;
  pointer-events: none;
}

.lantern {
  position: absolute;
  top: -6px;
  width: 44px;
  height: 92px;
  transform-origin: 50% 0;
  animation: sway 3.6s ease-in-out infinite;
  z-index: 2;
  pointer-events: none;
}

.lantern::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 22px;
  background: var(--gold-500);
  transform: translateX(-50%);
}

.lantern i {
  position: absolute;
  left: 0;
  top: 20px;
  width: 44px;
  height: 52px;
  border-radius: 46% / 50%;
  background:
    repeating-linear-gradient(90deg, transparent 0 9px, rgba(120, 0, 0, 0.35) 9px 11px),
    radial-gradient(circle at 50% 45%, #ff6a4a, #d4141f 60%, #8f0610);
  border-top: 5px solid var(--gold-500);
  border-bottom: 5px solid var(--gold-500);
  box-shadow: 0 0 26px rgba(255, 90, 50, 0.65);
}

.lantern i::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -26px;
  width: 6px;
  height: 20px;
  border-radius: 3px;
  background: linear-gradient(var(--gold-400), var(--gold-700));
  transform: translateX(-50%);
}

.lantern-l {
  left: 14px;
}

.lantern-r {
  right: 14px;
  animation-delay: -1.8s;
}

.hud {
  position: relative;
  z-index: 3;
  padding: max(18px, env(safe-area-inset-top)) 70px 10px;
  text-align: center;
}

.brand {
  font-size: clamp(26px, 8vw, 36px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.5px;
  background: linear-gradient(180deg, #fff9df 10%, var(--gold-400) 55%, var(--gold-700) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 #6b0000) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45));
}

.brand span {
  display: block;
  font-size: 0.82em;
}

.goal {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 600;
  color: rgba(255, 238, 200, 0.85);
}

.goal b {
  color: var(--gold-400);
}

.slots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  list-style: none;
}

.slots li {
  position: relative;
  width: 30px;
  height: 38px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  border: 1.5px dashed rgba(255, 210, 120, 0.4);
  transition: transform 0.25s;
}

.slots li.on {
  border: 0;
  background: linear-gradient(160deg, #ff4a3d, #b10f1a);
  box-shadow: 0 0 0 1.5px var(--gold-400), 0 0 16px rgba(255, 190, 70, 0.75);
  animation: pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.slots li.on::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 42%;
  border-radius: 6px 6px 50% 50% / 6px 6px 70% 70%;
  background: linear-gradient(#d61d2a, #9a0a15);
  border-bottom: 1.5px solid var(--gold-400);
}

.slots li.on::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 34%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle at 35% 35%, #fff4c2, var(--gold-500) 60%, var(--gold-700));
}

.slots.shake {
  animation: shake 0.4s;
}

.stage {
  position: relative;
  z-index: 1;
  touch-action: none;
  overflow: hidden;
}

.cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.stage.flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 60, 30, 0.35), transparent 70%);
  animation: fade 0.45s forwards;
  pointer-events: none;
}

.toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

.toast.show {
  animation: toast 1.1s ease forwards;
}

.sheet {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(30, 2, 6, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s, visibility 0.35s;
}

.sheet.is-open {
  opacity: 1;
  visibility: visible;
}

.card {
  position: relative;
  width: min(100%, 340px);
  padding: 30px 22px 24px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #fff8e6, #ffe9b8);
  color: #5a0a0f;
  box-shadow: 0 0 0 3px var(--gold-500), 0 0 0 7px rgba(255, 210, 110, 0.35), 0 24px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(16px) scale(0.96);
  transition: transform 0.45s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.sheet.is-open .card {
  transform: none;
}

.card h2 {
  font-size: 23px;
  font-weight: 800;
  line-height: 1.2;
  color: #a30d18;
}

.card p {
  margin-top: 8px;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.45;
  color: #6b2a1a;
}

.card .hot {
  color: #d4141f;
}

.env-hero {
  position: relative;
  width: 86px;
  height: 108px;
  margin: -64px auto 14px;
  border-radius: 12px;
  background: linear-gradient(160deg, #ff4a3d, #b10f1a);
  box-shadow: 0 0 0 3px var(--gold-400), 0 14px 30px rgba(120, 0, 0, 0.45);
  animation: float 2.4s ease-in-out infinite;
}

.env-hero::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 44%;
  border-radius: 12px 12px 50% 50% / 12px 12px 70% 70%;
  background: linear-gradient(#e0232f, #8f0812);
  border-bottom: 3px solid var(--gold-400);
}

.env-hero i {
  position: absolute;
  left: 50%;
  top: 32%;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle at 35% 30%, #fff6cc, var(--gold-400) 45%, var(--gold-700));
  box-shadow: 0 0 0 3px rgba(255, 240, 190, 0.6), 0 0 18px rgba(255, 210, 90, 0.9);
}

.check {
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, #fff6cc, var(--gold-400) 50%, var(--gold-700));
  box-shadow: 0 0 0 5px rgba(255, 210, 110, 0.35), 0 0 30px rgba(255, 190, 60, 0.8);
  animation: pop 0.6s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.check i {
  width: 30px;
  height: 16px;
  margin-top: -6px;
  border-left: 6px solid #a30d18;
  border-bottom: 6px solid #a30d18;
  transform: rotate(-45deg);
}

.btn {
  position: relative;
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 13px 18px 11px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff8e0;
  background: linear-gradient(180deg, #ff5a3c, #d4141f 55%, #9c0a14);
  box-shadow: 0 0 0 3px var(--gold-500), 0 6px 0 #6d0710, 0 12px 24px rgba(120, 0, 0, 0.45);
  text-shadow: 0 2px 0 rgba(90, 0, 0, 0.6);
  animation: breathe 1.6s ease-in-out infinite;
}

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

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 3px var(--gold-500), 0 3px 0 #6d0710, 0 8px 18px rgba(120, 0, 0, 0.45);
}

.btn[aria-busy='true'] {
  cursor: progress;
  filter: saturate(0.7) brightness(0.9);
}

.status-note {
  min-height: 0;
  color: #c0121d !important;
  font-size: 14px !important;
}

.status-note:empty {
  display: none;
}

.dots::after {
  content: '';
  animation: dots 1.2s steps(4) infinite;
}

@keyframes spin {
  to {
    --a: 360deg;
  }
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-6deg);
  }
  50% {
    transform: rotate(6deg);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg);
  }
  50% {
    transform: translateY(-8px) rotate(3deg);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.4);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-7px);
  }
  40%,
  80% {
    transform: translateX(7px);
  }
}

@keyframes fade {
  to {
    opacity: 0;
  }
}

@keyframes toast {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  15%,
  70% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -14px);
  }
}

@keyframes breathe {
  0%,
  100% {
    scale: 1;
  }
  50% {
    scale: 1.04;
  }
}

@keyframes shine {
  0%,
  45% {
    left: -40%;
  }
  85%,
  100% {
    left: 130%;
  }
}

@keyframes dots {
  0% {
    content: '';
  }
  25% {
    content: '.';
  }
  50% {
    content: '..';
  }
  75% {
    content: '...';
  }
}

@media (prefers-reduced-motion: reduce) {
  .rays,
  .lantern,
  .env-hero,
  .btn,
  .btn::after {
    animation: none;
  }
}
