:root {
  --bg: #111827;
  --panel: rgba(255, 255, 255, 0.1);
  --text: #f9fafb;
  --muted: #cbd5e1;
  --gold: #f7c948;
  --green: #34d399;
  --red: #fb7185;
  --blue: #60a5fa;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 18%, rgba(96, 165, 250, 0.28), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(52, 211, 153, 0.22), transparent 26%),
    linear-gradient(145deg, #111827 0%, #172033 52%, #0f172a 100%);
}

button {
  font: inherit;
}

.app {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
}

.topbar {
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 76px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 8vw, 38px);
  line-height: 1.02;
  letter-spacing: 0;
}

.counter {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: center;
  min-width: 82px;
  height: 56px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.78);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
  font-weight: 800;
}

.counter span:first-child {
  font-size: 28px;
}

.counter span:last-child {
  color: var(--muted);
  font-size: 16px;
}

.stage {
  position: relative;
  overflow: hidden;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  touch-action: manipulation;
}

.hint {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 1;
  width: min(290px, calc(100% - 32px));
  transform: translate(-50%, -50%);
  color: rgba(249, 250, 251, 0.78);
  font-size: 17px;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
}

.progress {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.progress div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 180ms ease;
}

.wish {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: min(78vw, 330px);
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  color: #07111f;
  background: var(--gold);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transform: translate3d(0, -64px, 0);
  animation: fall var(--fall-duration, 5200ms) linear forwards;
}

.wish:nth-child(3n) {
  background: var(--green);
}

.wish:nth-child(4n) {
  background: var(--blue);
}

.wish:nth-child(5n) {
  background: #fda4af;
}

.wish.caught {
  animation: pop 220ms ease forwards;
  pointer-events: none;
}

.burst {
  position: absolute;
  z-index: 4;
  color: var(--text);
  font-weight: 900;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  animation: burst 680ms ease-out forwards;
}

.certificate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 17, 31, 0.82);
  backdrop-filter: blur(12px);
}

.certificate[hidden] {
  display: none;
}

.certificate-inner {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  color: #111827;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.98)),
    repeating-linear-gradient(-45deg, rgba(247, 201, 72, 0.34) 0 12px, transparent 12px 24px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  text-align: center;
}

.certificate-label {
  margin: 0 0 10px;
  color: #475569;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.certificate h2 {
  margin: 0;
  font-size: clamp(54px, 18vw, 86px);
  line-height: 0.95;
  letter-spacing: 0;
}

.certificate-text {
  margin: 18px 0;
  color: #334155;
  font-size: 17px;
  line-height: 1.35;
}

.certificate-code {
  margin: 0 0 18px;
  padding: 12px;
  border: 1px dashed #64748b;
  border-radius: 8px;
  color: #0f172a;
  background: rgba(255, 255, 255, 0.72);
  font-weight: 900;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: #2563eb;
  font-weight: 900;
  cursor: pointer;
}

@keyframes fall {
  from {
    transform: translate3d(0, -64px, 0) rotate(var(--rotate-start, -4deg));
  }
  to {
    transform: translate3d(0, calc(100vh + 96px), 0) rotate(var(--rotate-end, 5deg));
  }
}

@keyframes pop {
  to {
    opacity: 0;
    transform: scale(1.28) rotate(0deg);
  }
}

@keyframes burst {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.9);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -110%) scale(1.18);
  }
}

@media (max-width: 360px) {
  .app {
    padding-left: 10px;
    padding-right: 10px;
  }

  .counter {
    min-width: 72px;
  }
}
