:root {
  --navy: #0b1020;
  --card: #171e36;
  --gold: #e8c47a;
  --gold-2: #c9a24a;
  --cream: #f4efe4;
  --muted: #9aa3c2;
  --soft: #d7dcf0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--navy); color: var(--cream); font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif; }
body { overflow: hidden; }
button, input { font: inherit; color: inherit; }

#sky {
  position: relative;
  min-height: 100%;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 50% 38%, #1a2244 0%, var(--navy) 62%);
  display: flex;
  flex-direction: column;
}

.stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff8, transparent),
    radial-gradient(1px 1px at 28% 72%, #fff6, transparent),
    radial-gradient(1.5px 1.5px at 67% 22%, #fff9, transparent),
    radial-gradient(1px 1px at 81% 64%, #fff5, transparent),
    radial-gradient(1px 1px at 44% 12%, #fff7, transparent),
    radial-gradient(1.2px 1.2px at 90% 40%, #fff6, transparent),
    radial-gradient(1px 1px at 8% 88%, #fff5, transparent),
    radial-gradient(1px 1px at 55% 80%, #fff6, transparent);
  pointer-events: none;
}

.weather { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.weather.aurora {
  box-shadow: inset 0 -45vh 120px #7eb8a888, inset 0 20vh 80px #e8c47a33;
  animation: auroraPulse 3s ease-in-out infinite alternate;
}
.weather.aurora .flake {
  position: absolute; width: 6px; height: 6px; background: #b7f0d8; border-radius: 50%;
  box-shadow: 0 0 10px #7eb8a8;
  animation: fall 3.2s linear forwards;
}
@keyframes auroraPulse {
  from { filter: saturate(1); }
  to { filter: saturate(1.6) brightness(1.15); }
}
.weather.stars-burst .flake {
  position: absolute; width: 3px; height: 3px; background: var(--gold); border-radius: 50%;
  animation: fall 2.4s linear forwards;
}
.weather.rain .flake {
  position: absolute; width: 1px; height: 18px; background: #9aa3c2aa;
  animation: fall 1.1s linear forwards;
}
@keyframes fall { to { transform: translateY(110vh); opacity: 0; } }

.top {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(16px + env(safe-area-inset-top)) 22px 0;
}
.wordmark {
  letter-spacing: 0.38em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--gold);
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.glow-pill {
  position: relative;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid #e8c47a44;
  border-radius: 999px;
  padding: 6px 12px 6px 14px;
  overflow: hidden;
  display: flex;
  gap: 8px;
  align-items: center;
}
.glow-pill i {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 8%;
  background: linear-gradient(90deg, #e8c47a22, #e8c47a55);
  z-index: -1;
  transition: width 0.8s ease;
}

.stage {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
}
.bug {
  position: relative;
  width: 96px; height: 96px;
  border: 0; background: none; cursor: pointer;
  animation: drift 7s ease-in-out infinite;
}
.bug.dance { animation: dance 0.38s ease-in-out 14; }
.bug.asleep { animation: none; filter: grayscale(0.45) brightness(0.45); }
.bug.asleep .wing { animation: none; }
.bug.hot .halo { inset: -34px; opacity: 1; }
.bug.lit .core { box-shadow: 0 0 48px 22px #e8c47aee; }
.bug.trail::after {
  content: "";
  position: absolute; inset: 20px;
  border-radius: 50%;
  background: #e8c47a55;
  filter: blur(10px);
  animation: drift 1.6s ease-in-out infinite reverse;
}
.halo {
  position: absolute; inset: -26px;
  border-radius: 50%;
  background: radial-gradient(circle, #e8c47acc 0%, transparent 68%);
  animation: pulse 2.2s ease-in-out infinite;
}
.core {
  position: absolute; inset: 30px;
  border-radius: 50%;
  background: #fff6d4;
  box-shadow: 0 0 32px 14px #e8c47add;
}
.wing {
  position: absolute; top: 22px; width: 22px; height: 28px;
  background: #e8c47a33;
  border: 1px solid #e8c47a55;
  border-radius: 70% 70% 40% 40%;
  filter: blur(0.2px);
}
.wing.left { left: 8px; transform: rotate(-28deg); animation: flap 0.7s ease-in-out infinite; }
.wing.right { right: 8px; transform: rotate(28deg); animation: flap 0.7s ease-in-out infinite reverse; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(10px, -16px); }
}
@keyframes pulse {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
@keyframes flap {
  50% { transform: rotate(0deg) scaleY(0.85); }
}
@keyframes dance {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(18px, -22px) rotate(12deg); }
  50% { transform: translate(-10px, -8px) rotate(-8deg); }
  75% { transform: translate(8px, -28px) rotate(6deg); }
}

.fx { position: absolute; inset: 0; pointer-events: none; }
.spark {
  position: absolute; left: 50%; top: 50%;
  width: 7px; height: 7px; margin: -3px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px #e8c47a;
  animation: spark 0.9s ease-out forwards;
}
.spark.big { width: 11px; height: 11px; margin: -5px; background: #fff6d4; }
.ring {
  position: absolute; left: 50%; top: 50%;
  width: 20px; height: 20px; margin: -10px;
  border: 2px solid #e8c47aaa;
  border-radius: 50%;
  animation: ring 1.1s ease-out forwards;
}
@keyframes spark {
  to { transform: translate(var(--x), var(--y)) scale(0.2); opacity: 0; }
}
@keyframes ring {
  to { transform: scale(9); opacity: 0; }
}
#sky.dawn {
  background:
    radial-gradient(ellipse at 50% 70%, #c9a24a66 0%, #1a2244 45%, var(--navy) 70%);
}

.bubble {
  position: absolute;
  top: calc(50% + 58px);
  max-width: 240px;
  padding: 8px 12px;
  border-radius: 14px;
  background: #171e36ee;
  border: 1px solid #e8c47a33;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  color: var(--cream);
  text-align: center;
}
.bubble.hidden { display: none; }
.status {
  position: absolute;
  top: calc(50% + 78px);
  width: min(280px, 86vw);
  text-align: center;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.status.combo { color: var(--gold); }
.status.sleep { color: #7d86a3; }
.plaque, .tender, .book, .toast {
  font-family: ui-sans-serif, system-ui, sans-serif;
  text-align: center;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.plaque {
  position: absolute;
  top: calc(50% - 92px);
  font-size: 10px;
  color: var(--gold);
}
.tender {
  position: absolute;
  top: calc(50% + 58px);
  font-size: 11px;
  color: var(--gold);
}
.book {
  position: absolute;
  top: calc(50% + 102px);
  max-width: 280px;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--cream);
  opacity: 0.9;
}
.toast {
  position: relative;
  z-index: 4;
  font-size: 11px;
  color: var(--gold);
  padding: 0 16px 8px;
}
.plaque.hidden, .tender.hidden, .book.hidden, .toast.hidden { display: none; }
.pill.heat { border-color: var(--gold); }

.pills {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 16px 12px;
  min-height: 36px;
}
.pill {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: var(--soft);
  border: 1px solid #e8c47a33;
  background: #0b1020aa;
  border-radius: 999px;
  padding: 6px 10px;
}
.pill b { color: var(--gold); font-weight: 600; }

.dock {
  position: relative;
  z-index: 3;
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
}
.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  border: 1px solid #e8c47a28;
  background: #0d1326cc;
  border-radius: 22px;
  padding: 10px;
  backdrop-filter: blur(12px);
}
.actions button {
  background: none; border: 0; cursor: pointer;
  color: var(--gold);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  padding: 10px 0 6px;
}
.actions button span {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #c9a24a;
}
.more {
  display: block;
  width: 100%;
  margin-top: 8px;
  background: none; border: 0; cursor: pointer;
  color: var(--gold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 10px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  padding: 8px;
}

.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: #05070fcc;
  display: grid;
  align-items: end;
  justify-items: center;
}
.overlay.hidden { display: none; }
.sheet {
  width: min(440px, 100%);
  background: #12182c;
  border-top: 1px solid #e8c47a33;
  border-radius: 24px 24px 0 0;
  padding: 10px 20px 28px;
}
.sheet-handle {
  width: 42px; height: 4px; border-radius: 4px;
  background: #2a3354; margin: 6px auto 16px;
}
.sheet h2 {
  font-weight: 500;
  font-size: 26px;
  margin-bottom: 14px;
}
.field {
  display: flex; flex-direction: column; gap: 6px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.field input {
  background: #0b1020;
  border: 1px solid #2a3354;
  border-radius: 12px;
  padding: 12px 14px;
  letter-spacing: 0;
  text-transform: none;
  font-size: 16px;
  color: var(--cream);
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 16px;
}
.grid button {
  background: #0b1020;
  border: 1px solid #e8c47a33;
  border-radius: 14px;
  padding: 14px 10px;
  cursor: pointer;
  color: var(--gold);
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.grid button small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 11px;
}
.ghost, .primary {
  width: 100%;
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  font-family: ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  text-align: center;
  text-decoration: none;
  display: block;
  margin-top: 8px;
}
.ghost { background: none; border: 1px solid #2a3354; color: var(--muted); }
.primary { background: var(--gold); border: 0; color: #0b1020; font-weight: 700; }
.primary.hidden { display: none; }
.pay-sheet { text-align: center; }
.pay-kicker {
  font-family: ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.2em;
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 6px;
}
#qr {
  width: 220px; height: 220px;
  border-radius: 16px;
  margin: 8px auto 10px;
  background: var(--cream);
  display: grid;
  place-items: center;
  overflow: hidden;
}
#qr canvas { display: block; }
.hint, .timer {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  color: var(--muted);
}
.pay-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-row .ghost { margin-top: 0; }
.timer { margin-top: 10px; }
