@font-face {
  font-family: 'Bryndan Write';
  src: url('/fonts/BryndanWrite.woff2') format('woff2');
  font-display: swap;
}

:root { --blue: #1B2AE0; --blue-dark: #0f1a9c; --cream: #FDF2E0; --pad-x: clamp(18px, 6vw, 30px); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--blue); }
body {
  min-height: 100dvh;
  padding: 16px;
  font-family: 'Bryndan Write', system-ui, sans-serif;
  font-synthesis: none;
  color: var(--blue);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

@keyframes wobble { 0%,100% { transform: rotate(-2.5deg) } 50% { transform: rotate(2.5deg) } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0 } 60% { transform: scale(1.06) } 100% { transform: scale(1); opacity: 1 } }
@keyframes fadeUp { 0% { transform: translateY(14px); opacity: 0 } 100% { transform: translateY(0); opacity: 1 } }

/* Ticket frame with scalloped edges */
.panel {
  position: relative;
  min-height: calc(100dvh - 32px);
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 5dvh, 54px) var(--pad-x);
  text-align: center;
  overflow: hidden;
}
.edge { position: absolute; pointer-events: none; z-index: 1; }
.edge-top, .edge-bottom { left: 0; right: 0; height: 22px; background-repeat: repeat-x; background-size: 40px 22px; }
.edge-left, .edge-right { top: 0; bottom: 0; width: 22px; background-repeat: repeat-y; background-size: 22px 40px; }
.edge-top { top: -11px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='22' viewBox='0 0 40 22'%3E%3Cpath d='M0 11 Q10 0 20 11 T40 11 V0 H0 Z' fill='%231B2AE0'/%3E%3C/svg%3E"); }
.edge-bottom { bottom: -11px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='22' viewBox='0 0 40 22'%3E%3Cpath d='M0 11 Q10 0 20 11 T40 11 V22 H0 Z' fill='%231B2AE0'/%3E%3C/svg%3E"); }
.edge-left { left: -11px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='40' viewBox='0 0 22 40'%3E%3Cpath d='M11 0 Q0 10 11 20 T11 40 H0 V0 Z' fill='%231B2AE0'/%3E%3C/svg%3E"); }
.edge-right { right: -11px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='40' viewBox='0 0 22 40'%3E%3Cpath d='M11 0 Q22 10 11 20 T11 40 H22 V0 Z' fill='%231B2AE0'/%3E%3C/svg%3E"); }

.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 2.4dvh, 22px);
  width: 100%;
  max-width: 420px;
  animation: fadeUp .45s ease-out both;
}

/* Type */
.title {
  margin: 0;
  max-width: 100%;
  font-size: clamp(40px, 14vw, 64px);
  font-weight: normal;
  line-height: .92;
  letter-spacing: 1px;
  text-transform: uppercase;
  overflow-wrap: break-word;
  text-wrap: balance;
  color: transparent;
  -webkit-text-stroke: 2px var(--blue);
}
.title.pop { animation: pop .5s ease-out both; }
.kicker { font-size: 22px; letter-spacing: 3px; text-transform: uppercase; }
.lead { margin: 0; font-size: clamp(19px, 5.8vw, 23px); line-height: 1.3; text-transform: uppercase; text-wrap: balance; }
.aside { margin: 0; font-size: 19px; line-height: 1.35; text-transform: uppercase; opacity: .8; text-wrap: balance; }
.meta { margin: 0; font-size: 17px; text-transform: uppercase; opacity: .75; }
.divider { height: 2px; width: 90px; flex: none; background: var(--blue); opacity: .5; }
.error { margin: 0; font-size: 18px; text-transform: uppercase; }
.who { margin: 0; font-size: 18px; text-transform: uppercase; overflow-wrap: anywhere; }
.note { margin: -8px 0 0; font-size: 16px; text-transform: uppercase; opacity: .7; }
.text-link { color: var(--blue); font-size: 17px; text-transform: uppercase; opacity: .7; }
.text-link:hover { opacity: 1; }

/* Form controls */
.stack-form { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.field-label { font-size: 19px; letter-spacing: 2px; text-transform: uppercase; }
.hand-input {
  width: 100%;
  appearance: none;
  background: transparent;
  border: 2px solid var(--blue);
  border-radius: 4px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: clamp(26px, 8vw, 32px);
  line-height: 1.2;
  color: var(--blue);
  caret-color: var(--blue);
  text-align: center;
  outline: none;
  transform: rotate(-1deg);
  transition: box-shadow .15s ease, transform .15s ease;
}
.hand-input::placeholder { color: var(--blue); opacity: .38; }
.hand-input:focus { box-shadow: 5px 5px 0 var(--blue); transform: rotate(0deg) translate(-2px, -2px); }

.btn-primary {
  margin-top: clamp(6px, 1.6dvh, 16px);
  max-width: 100%;
  min-height: clamp(64px, 10dvh, 96px);
  appearance: none;
  border: 0;
  border-radius: 4px;
  padding: clamp(14px, 2.4dvh, 24px) clamp(22px, 8vw, 44px);
  background: var(--blue);
  color: var(--cream);
  font-family: inherit;
  font-size: clamp(26px, 8vw, 34px);
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity .2s ease, background .2s ease;
}
.btn-primary.wobble { animation: wobble 2.6s ease-in-out infinite; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; animation: none; }
.btn-primary.busy { opacity: 1; cursor: progress; }

.btn-outline {
  appearance: none;
  flex: none;
  min-height: 52px;
  padding: 14px 30px;
  background: none;
  border: 2px solid var(--blue);
  border-radius: 4px;
  color: var(--blue);
  font-family: inherit;
  font-size: 22px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.btn-outline:hover { background: var(--blue); color: var(--cream); }

.prize-card { flex: none; background: var(--blue); color: var(--cream); padding: 22px 26px; border-radius: 4px; transform: rotate(-1.5deg); max-width: 100%; }
.prize-caption { font-size: 16px; letter-spacing: 2px; text-transform: uppercase; opacity: .85; }
.prize-name { margin-top: 4px; font-size: clamp(24px, 7.5vw, 32px); line-height: 1.1; text-transform: uppercase; overflow-wrap: break-word; text-wrap: balance; }

/* Result screens fill exactly one screen height and never scroll:
   text sits at the top and scales with the viewport, the couple photo takes all remaining space. */
.panel:has(> .result:not([hidden])) {
  height: calc(100dvh - 32px);
  min-height: 0;
  align-items: stretch;
  padding-top: clamp(18px, 3.6dvh, 40px);
  padding-bottom: 0;
}
.result { gap: clamp(7px, 1.4dvh, 14px); min-height: 0; container-type: inline-size; }
.result .kicker { font-size: clamp(16px, 2.6dvh, 22px); }
.result .title { font-size: clamp(34px, min(12vw, 7.2dvh), 60px); }
.result .lead { font-size: clamp(16px, min(5.4vw, 2.9dvh), 23px); }
.result .aside { font-size: clamp(14px, min(4.7vw, 2.4dvh), 19px); }
.result .who { font-size: clamp(14px, 2.2dvh, 18px); }
.result .note { margin-top: -3px; font-size: clamp(13px, 1.9dvh, 16px); }
.result .prize-card { padding: clamp(9px, 1.7dvh, 22px) 24px; }
.result .prize-caption { font-size: clamp(13px, 1.9dvh, 16px); }
.result .prize-name { font-size: clamp(20px, min(7vw, 3.8dvh), 32px); }
@keyframes popTilted {
  0% { transform: rotate(-1.5deg) scale(.7); opacity: 0 }
  60% { transform: rotate(-1.5deg) scale(1.06) }
  100% { transform: rotate(-1.5deg) scale(1); opacity: 1 }
}
.win-badge {
  flex: none;
  max-width: 100%;
  margin: 4px 0;
  padding: clamp(10px, 1.8dvh, 18px) clamp(18px, 5vw, 28px);
  background: var(--blue);
  border-radius: 4px;
  transform: rotate(-1.5deg);
  animation: popTilted .5s ease-out both;
}
.win-badge .title {
  font-size: clamp(30px, min(10.5vw, 6.4dvh), 54px);
  color: var(--cream);
  -webkit-text-stroke: 0;
}
.result .btn-outline { min-height: 0; padding: clamp(7px, 1.3dvh, 14px) 26px; font-size: clamp(17px, 2.6dvh, 22px); }

/* Height comes from the free space, width follows the photo's aspect ratio. On tall phones the photo may
   grow wider than the ticket and gets trimmed at the sides by the panel, capped at roughly 20 %. */
.couple {
  display: block;
  flex: 1 1 0;
  align-self: center;
  width: auto;
  max-width: none;
  height: auto;
  min-height: 0;
  max-height: calc((100cqw + 2 * var(--pad-x)) * 1.2);
  margin-top: auto;
  aspect-ratio: 900 / 854;
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

@media (prefers-reduced-motion: reduce) {
  .screen, .title.pop, .win-badge, .btn-primary.wobble { animation: none; }
}
