:root {
  color-scheme: light;
  --ink: #163340;
  --muted: #52646a;
  --sun: #ffd84d;
  --sun-deep: #f5a623;
  --coral: #ff7b6e;
  --green: #67b86b;
  --blue: #5cc6e8;
  --violet: #6c62c7;
  --paper: #fff9e6;
  --white: #ffffff;
  --shadow: rgba(22, 51, 64, 0.18);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: ui-rounded, "Avenir Next", "Segoe UI", system-ui, sans-serif;
  background: #86dff5;
}

button,
a {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.reward-page {
  min-height: 100svh;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.78) 0 88px, transparent 89px),
    linear-gradient(180deg, #7bdaf4 0%, #c5f1fb 58%, #a8da78 59%, #7bc66a 100%);
}

.sky-stage {
  position: relative;
  display: grid;
  min-height: 100svh;
  padding: 28px 16px;
  overflow: hidden;
}

.sun-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sun-field span {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 12px rgba(255, 216, 77, 0.28);
  animation: float 5.5s ease-in-out infinite alternate;
}

.sun-field span:nth-child(1) { left: 8%; top: 18%; }
.sun-field span:nth-child(2) { left: 78%; top: 12%; animation-delay: 500ms; }
.sun-field span:nth-child(3) { left: 54%; top: 78%; animation-delay: 900ms; }
.sun-field span:nth-child(4) { left: 18%; top: 72%; animation-delay: 1300ms; }
.sun-field span:nth-child(5) { left: 88%; top: 62%; animation-delay: 1700ms; }
.sun-field span:nth-child(6) { left: 42%; top: 20%; animation-delay: 2100ms; }

.reward-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: 24px;
  width: min(1180px, 100%);
  margin: auto;
  align-items: stretch;
}

.reward-card,
.certificate {
  min-width: 0;
  border: 5px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 24px 48px var(--shadow);
}

.reward-card {
  display: flex;
  flex-direction: column;
  min-height: 640px;
  padding: 36px;
  background: rgba(255, 249, 230, 0.96);
}

.eyebrow {
  margin: 0 0 10px;
  color: #356270;
  font-size: 0.95rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 9em;
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: 0.9;
}

.reward-card p {
  max-width: 38em;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.gate-panel,
.keepsake-panel {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 2px dashed rgba(22, 51, 64, 0.18);
}

.panel-label {
  margin: 0 0 10px !important;
  color: var(--ink) !important;
  font-size: 0.92rem !important;
  font-weight: 900;
  text-transform: uppercase;
}

.status-line {
  min-height: 54px;
  font-weight: 900;
}

.code-display {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 12px 0 14px;
}

.code-display span {
  display: block;
  height: 46px;
  border: 3px solid rgba(22, 51, 64, 0.18);
  border-radius: 8px;
  background: var(--white);
}

.code-display span.filled {
  background: var(--sun);
  border-color: var(--sun-deep);
  box-shadow: inset 0 -7px 0 rgba(160, 94, 8, 0.12);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.keypad button,
.button {
  display: inline-grid;
  place-items: center;
  min-height: 52px;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 6px 0 rgba(22, 51, 64, 0.15);
  cursor: pointer;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.keypad button[data-action="submit"] {
  color: var(--white);
  background: var(--violet);
}

.button:hover,
.button:focus-visible,
.keypad button:hover,
.keypad button:focus-visible {
  transform: translateY(-2px);
}

.button:focus-visible,
.keypad button:focus-visible {
  outline: 4px solid rgba(108, 98, 199, 0.36);
  outline-offset: 3px;
}

.button:active,
.keypad button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(22, 51, 64, 0.16);
}

.play-link {
  width: min(280px, 100%);
  margin-top: 20px;
}

.video-stage {
  display: grid;
  place-items: center;
  min-height: 320px;
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.86);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 216, 77, 0.26) 0 150px, transparent 151px),
    #1d3c4a;
  box-shadow: inset 0 0 0 1px rgba(22, 51, 64, 0.18);
}

.video-stage video {
  display: block;
  width: 100%;
  max-height: 460px;
  background: #0f2530;
}

.video-fallback {
  display: grid;
  place-items: center;
  gap: 10px;
  width: 100%;
  min-height: 320px;
  padding: 28px;
  color: var(--white);
  text-align: center;
}

.video-fallback img {
  width: 150px;
  height: 150px;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.24));
}

.video-fallback p {
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
}

.video-fallback code {
  color: var(--white);
  font-weight: 900;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.reward-action {
  color: var(--white);
  background: var(--violet);
}

.sunshine-action {
  background: var(--sun);
}

.replay-action {
  background: var(--blue);
}

.print-action {
  color: var(--white);
  background: var(--green);
}

.certificate {
  display: grid;
  min-height: 640px;
  padding: 18px;
  background: var(--paper);
}

.certificate-border {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  border: 3px dashed rgba(22, 51, 64, 0.22);
  border-radius: 8px;
  text-align: center;
}

.certificate-kicker,
.certificate-note {
  margin: 0;
  color: #356270;
  font-size: 0.88rem;
  font-weight: 900;
  text-transform: uppercase;
}

.certificate h2 {
  margin: 18px 0 0;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 0.98;
}

.certificate p {
  max-width: 28em;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.5;
}

.seal {
  display: grid;
  place-items: center;
  width: 116px;
  height: 116px;
  margin: 34px 0;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 14px rgba(255, 216, 77, 0.25), inset 0 -10px 0 rgba(160, 94, 8, 0.1);
}

.seal span {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 68%, var(--ink) 0 5px, transparent 6px),
    radial-gradient(circle at 36% 44%, var(--ink) 0 4px, transparent 5px),
    radial-gradient(circle at 64% 44%, var(--ink) 0 4px, transparent 5px),
    var(--sun-deep);
}

.certificate-name {
  color: var(--ink) !important;
  font-size: 1.55rem !important;
  font-weight: 900;
}

.reward-page[data-state="unlocked"] .primary-reward {
  background:
    radial-gradient(circle at 82% 18%, rgba(255, 216, 77, 0.42) 0 120px, transparent 121px),
    rgba(255, 249, 230, 0.97);
}

.spark {
  position: fixed;
  z-index: 10;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  pointer-events: none;
  animation: pop 900ms ease-out forwards;
}

.parade-spark:nth-child(3n) { background: var(--coral); }
.parade-spark:nth-child(3n + 1) { background: var(--sun); }
.parade-spark:nth-child(3n + 2) { background: var(--blue); }

.sun-confetti {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--sun);
}

.sun-confetti:nth-child(2n) {
  background: var(--green);
}

.shake {
  animation: shake 280ms linear;
}

@keyframes float {
  from { transform: translateY(-8px) scale(0.94); }
  to { transform: translateY(14px) scale(1.08); }
}

@keyframes pop {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--spark-x), var(--spark-y)) scale(0.2);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

@media (max-width: 980px) {
  .reward-layout {
    grid-template-columns: 1fr;
  }

  .reward-card,
  .certificate {
    min-height: auto;
  }

  .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .sky-stage {
    padding: 10px;
  }

  .reward-card,
  .certificate {
    border-width: 4px;
  }

  .reward-card {
    padding: 24px;
  }

  h1 {
    font-size: 3rem;
  }

  .reward-card p {
    font-size: 1rem;
  }

  .video-stage,
  .video-fallback {
    min-height: 260px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .certificate-border {
    padding: 22px;
  }
}

@media print {
  body {
    background: var(--white);
  }

  .reward-card,
  .sun-field {
    display: none;
  }

  .sky-stage,
  .reward-page {
    min-height: auto;
    padding: 0;
    background: var(--white);
  }

  .reward-layout {
    display: block;
    width: 100%;
  }

  .certificate {
    min-height: 95vh;
    border-color: var(--ink);
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
