:root {
  color-scheme: light;
  background: #ffffff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  place-items: center;
  min-height: 100svh;
  overflow: hidden;
}

.stage {
  position: relative;
  width: min(100vw, 540px);
  aspect-ratio: 1;
  overflow: hidden;
  background: #ffffff;
  isolation: isolate;
  touch-action: manipulation;
}

.background-video,
#snowflake-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.background-video {
  z-index: 1;
  object-fit: cover;
  object-position: center;
  background: #ffffff;
  opacity: 0;
  transition: opacity 120ms linear;
  pointer-events: none;
}

.background-video.visible {
  opacity: 1;
}

#snowflake-canvas {
  z-index: 2;
  opacity: 0;
  transition: opacity 120ms linear;
  pointer-events: none;
}

#snowflake-canvas.ready {
  opacity: 1;
}

#snowflake-canvas.finished {
  opacity: 0;
}

.loading {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #6aaed5;
  background:
    radial-gradient(circle at 50% 45%, rgba(210, 239, 255, 0.8), rgba(255, 255, 255, 0) 34%),
    #ffffff;
  opacity: 1;
  transition: opacity 180ms ease;
}

.loading[hidden] {
  display: none;
}

.loading.leaving {
  opacity: 0;
}

.loading-snowflake {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  color: #69b9e6;
  font-size: 50px;
  line-height: 1;
  filter: drop-shadow(0 5px 12px rgba(61, 163, 218, 0.22));
  animation: loading-snowflake-spin 2.8s linear infinite;
}

.loading strong {
  color: #3d85ad;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.08em;
}

#loading-text {
  color: #88abc0;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.checkin-button {
  min-width: 154px;
  margin-top: 13px;
  padding: 14px 28px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(135deg, #55b7e9, #348fc6);
  box-shadow: 0 10px 24px rgba(47, 143, 197, 0.28);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.checkin-button:disabled {
  color: #8aaaba;
  background: #e4f0f6;
  box-shadow: none;
  cursor: default;
}

.checkin-button:not(:disabled):active {
  transform: scale(0.96);
  box-shadow: 0 5px 14px rgba(47, 143, 197, 0.24);
}

@keyframes loading-snowflake-spin {
  to {
    transform: rotate(360deg);
  }
}

.success-message {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 168px;
  padding: 24px 30px;
  border: 1px solid rgba(160, 214, 242, 0.72);
  border-radius: 22px;
  color: #176a9e;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 16px 42px rgba(29, 94, 135, 0.2);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.86);
  transition: opacity 220ms ease, transform 260ms cubic-bezier(0.2, 0.9, 0.2, 1.2);
  pointer-events: none;
}

.success-message[hidden] {
  display: none;
}

.success-message.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.success-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: #49a9dd;
  font-size: 30px;
  line-height: 1;
}

.success-message strong {
  font-size: 22px;
  letter-spacing: 0.08em;
}

.celebration {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 255, 255, 0.95), transparent 32%),
    linear-gradient(155deg, #dff5ff 0%, #bfe8fb 48%, #8fcfeb 100%);
  opacity: 0;
  transition: opacity 280ms ease;
}

.celebration[hidden] {
  display: none;
}

.celebration.visible {
  opacity: 1;
}

.celebration-card {
  position: relative;
  z-index: 2;
  width: min(100%, 410px);
  padding: 24px 22px 18px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 70px rgba(31, 113, 157, 0.28);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translateY(18px) scale(0.94);
  transition: transform 380ms cubic-bezier(0.2, 0.9, 0.2, 1.15);
}

@media (max-height: 720px) {
  .celebration {
    place-items: start center;
  }

  .celebration-card {
    margin-block: 8px;
  }
}

.celebration.visible .celebration-card {
  transform: translateY(0) scale(1);
}

.celebration-medal {
  display: grid;
  width: 52px;
  height: 52px;
  margin: -6px auto 7px;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: linear-gradient(135deg, #64c5ef, #2b91c8);
  box-shadow: 0 8px 20px rgba(42, 145, 200, 0.28);
  font-size: 31px;
}

.celebration-eyebrow {
  margin: 0 0 5px;
  color: #5795b7;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.celebration h1 {
  margin: 0 0 14px;
  color: #17658f;
  font-size: 27px;
  line-height: 1.22;
  letter-spacing: 0.06em;
}

.qr-shell {
  width: 190px;
  height: 190px;
  margin: 0 auto 10px;
  padding: 10px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #d5edf8, 0 8px 22px rgba(45, 127, 170, 0.12);
}

#identity-qr {
  display: block;
  width: 100%;
  height: 100%;
}

.identity-label {
  margin: 0 0 3px;
  color: #78a3ba;
  font-size: 11px;
  letter-spacing: 0.16em;
}

#identity-code {
  display: block;
  margin: 0 auto 13px;
  color: #236b92;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
}

.save-image-button {
  width: 100%;
  padding: 13px 18px;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(135deg, #58bce8, #2f91c7);
  box-shadow: 0 9px 22px rgba(45, 145, 199, 0.26);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.save-hint {
  margin: 9px 0 0;
  color: #8ba9b9;
  font-size: 11px;
}

.confetti i {
  position: absolute;
  z-index: 1;
  top: -12%;
  width: 9px;
  height: 18px;
  border-radius: 3px;
  background: #ffffff;
  animation: confetti-fall 3.2s linear infinite;
}

.confetti i:nth-child(1) { left: 7%; background: #4cb9e9; animation-delay: -0.4s; }
.confetti i:nth-child(2) { left: 17%; background: #ffe36f; animation-delay: -1.8s; }
.confetti i:nth-child(3) { left: 29%; background: #78d8bf; animation-delay: -2.4s; }
.confetti i:nth-child(4) { left: 40%; background: #ff9fb1; animation-delay: -0.9s; }
.confetti i:nth-child(5) { left: 51%; background: #ffffff; animation-delay: -2.8s; }
.confetti i:nth-child(6) { left: 62%; background: #ffe36f; animation-delay: -1.3s; }
.confetti i:nth-child(7) { left: 72%; background: #62c8ef; animation-delay: -2.1s; }
.confetti i:nth-child(8) { left: 82%; background: #ff9fb1; animation-delay: -0.2s; }
.confetti i:nth-child(9) { left: 91%; background: #78d8bf; animation-delay: -1.6s; }
.confetti i:nth-child(10) { left: 96%; background: #ffffff; animation-delay: -2.7s; }

@keyframes confetti-fall {
  to {
    transform: translate3d(-25px, 660px, 0) rotate(620deg);
  }
}

@media (min-width: 541px) {
  .stage {
    box-shadow: 0 12px 40px rgba(59, 103, 137, 0.12);
  }
}
