:root {
  --night: #0b1f33;
  --night-2: #12324f;
  --red: #c8202f;
  --red-dark: #9e1622;
  --green: #1d6b45;
  --gold: #f2c14e;
  --cream: #fff8ec;
  --ink: #2a1d14;
  --muted: #6b5a4b;
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% -10%, #1f4d75 0%, transparent 60%),
    linear-gradient(180deg, var(--night) 0%, var(--night-2) 100%) fixed;
  background-color: var(--night);
  display: flex;
  flex-direction: column;
}

#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

main, footer { position: relative; z-index: 1; }

main {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding: 3.25rem 1rem 1rem;
  flex: 1;
}

/* ---- String of lights ---- */
.lights {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2;
  height: 2.4rem;
  display: flex; justify-content: space-around; align-items: flex-start;
  pointer-events: none;
}
.lights::before {
  content: ""; position: absolute; left: -2%; right: -2%; top: -1.2rem; height: 2.2rem;
  border-bottom: 2px solid #2b3d2f; border-radius: 0 0 50% 50% / 0 0 100% 100%;
}
.bulb {
  position: relative; top: 0.75rem;
  width: 0.7rem; height: 1.05rem; border-radius: 50% 50% 45% 45%;
  animation: twinkle 2.2s ease-in-out infinite; animation-delay: var(--delay);
}
.bulb::before {
  content: ""; position: absolute; top: -0.3rem; left: 0.18rem; width: 0.34rem; height: 0.35rem;
  background: #3b4a3c; border-radius: 2px;
}
.bulb.c0 { background: #ff4d5e; color: #ff4d5e; }
.bulb.c1 { background: var(--gold); color: var(--gold); }
.bulb.c2 { background: #3fd38a; color: #3fd38a; }
.bulb.c3 { background: #58b4ff; color: #58b4ff; }
@keyframes twinkle {
  0%, 100% { opacity: 1; box-shadow: 0 0 10px 2px currentColor; }
  50% { opacity: 0.45; box-shadow: 0 0 2px 0 currentColor; }
}

/* ---- Title ---- */
.title { text-align: center; color: var(--cream); margin-bottom: 1.25rem; }
.title h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.3rem, 11vw, 3.4rem);
  line-height: 1.05;
  color: var(--cream);
  text-shadow: 0 2px 0 var(--red-dark), 0 0 22px rgba(242, 193, 78, 0.45);
}
.eyebrow {
  margin: 0 0 0.3rem;
  text-transform: uppercase; letter-spacing: 0.18em; font-size: 0.78rem; font-weight: 600;
  color: var(--gold);
}
.stars { margin: 0.4rem 0 0; color: var(--gold); letter-spacing: 0.5em; }

/* ---- Cards ---- */
.card {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 1.4rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  border-top: 6px solid var(--red);
  position: relative;
}
.card h2 {
  margin: 0 0 1rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem; line-height: 1.25;
  color: var(--green);
}
.center { text-align: center; }
.small { font-size: 0.9rem; color: var(--muted); }
[hidden] { display: none !important; }

/* ---- Form ---- */
label { display: block; font-weight: 600; margin: 0.6rem 0 0.3rem; }
input {
  width: 100%;
  font: inherit; font-size: 1.05rem; /* >= 16px: no zoom on iPhone */
  padding: 0.8rem 0.9rem;
  border: 2px solid #d9c9b0; border-radius: 12px;
  background: #fff; color: var(--ink);
}
input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(29, 107, 69, 0.2); }
.hint { font-size: 0.85rem; color: var(--muted); margin: 0.5rem 0 1rem; }
.error {
  margin: 0.9rem 0 0; padding: 0.7rem 0.8rem; border-radius: 10px;
  background: #fde8ea; color: var(--red-dark); font-weight: 600;
}

/* ---- Buttons ---- */
.btn {
  display: inline-block; width: 100%;
  font: inherit; font-weight: 700; font-size: 1.1rem;
  padding: 0.95rem 1.2rem;
  border: 0; border-radius: 999px;
  color: #fff; background: linear-gradient(180deg, #e0303f, var(--red));
  box-shadow: 0 4px 0 var(--red-dark), 0 8px 18px rgba(200, 32, 47, 0.35);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--red-dark); }
.btn:disabled { opacity: 0.6; }
.btn.big { font-size: 1.2rem; padding: 1.1rem 1.2rem; margin-top: 0.5rem; }
.btn.ghost {
  background: transparent; color: var(--green); box-shadow: none;
  border: 2px solid var(--green); font-size: 1rem; padding: 0.7rem 1rem;
}
.row { display: flex; gap: 0.75rem; margin-top: 1rem; }

/* ---- Busy ---- */
.gift { font-size: 3.5rem; animation: wobble 1s ease-in-out infinite; }
@keyframes wobble {
  0%, 100% { transform: rotate(-8deg) scale(1); }
  50% { transform: rotate(8deg) scale(1.08); }
}

/* ---- The reel ---- */
.reels {
  --gap: 0.3rem;
  /* Cell width: fit the longest word into the card. */
  --cell: min(3.3rem, calc((min(100vw, 32rem) - 4.5rem) / var(--n) - var(--gap)));
  --h: calc(var(--cell) * 1.3);
  margin: 0.6rem 0 1rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.55rem;
}
.reel-row { display: flex; gap: var(--gap); }
.reel {
  width: var(--cell); height: var(--h);
  overflow: hidden;
  border-radius: calc(var(--cell) * 0.18);
  background: linear-gradient(180deg, #e9dcc5 0%, #fff 22%, #fff 78%, #e9dcc5 100%);
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.25);
}
.strip {
  display: flex; flex-direction: column;
  transform: translateY(0);
}
.strip span {
  height: var(--h); line-height: var(--h);
  text-align: center;
  font-family: Georgia, "Times New Roman", serif; font-weight: 700;
  font-size: calc(var(--cell) * 0.78);
  color: var(--red);
}
.strip.stopped {
  transform: translateY(calc(var(--k) * var(--h) * -1));
  transition: transform var(--d) cubic-bezier(0.12, 0.72, 0.18, 1);
}
.strip.instant { transition: none; }
.strip span.filler { color: #8fb8d8; font-size: calc(var(--cell) * 0.55); }
.reels.done .reel.unused { opacity: 0.55; border-color: var(--gold); box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.2); }
.reels.done .reel { border-color: var(--green); box-shadow: 0 0 12px rgba(242, 193, 78, 0.8); }

.result {
  margin: 0;
  min-height: 1.6em;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem; font-weight: 700; color: var(--green);
}
.after { margin-top: 0.5rem; }

/* ---- Rules ---- */
.rules { border-top-color: var(--green); }
.rules ol { margin: 0; padding-left: 1.3rem; }
.rules li { margin-bottom: 0.55rem; line-height: 1.4; }

footer { text-align: center; color: var(--cream); opacity: 0.8; padding: 1rem 0 1.5rem; }

/* ---- Admin ---- */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.admin-table th, .admin-table td { text-align: left; padding: 0.5rem 0.35rem; border-bottom: 1px solid #e6d8c0; }
.admin-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.yes { color: var(--green); font-weight: 700; }
.no { color: var(--muted); }
.summary { font-size: 1.1rem; font-weight: 600; margin: 0 0 1rem; }

@media (prefers-reduced-motion: reduce) {
  .bulb, .gift { animation: none; }
  .bulb { box-shadow: 0 0 6px 1px currentColor; }
  .strip.stopped { transition: none; }
}
