/* Secret Santa: festive, phone-first, TV-readable. */
:root {
  --pine: #0d3b2e;
  --pine-deep: #07261d;
  --red: #c8102e;
  --red-dark: #9b0c23;
  --gold: #f2c14e;
  --cream: #fff8ee;
  --ink: #1f1a17;
  --muted: #6b5f57;
  --green-ok: #1f8a4c;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .28);
  font-size: 18px;
}

* { box-sizing: border-box; }

html { background: var(--pine-deep); }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--cream);
  background: var(--pine-deep) radial-gradient(ellipse 140% 900px at top, #15573f 0%, var(--pine) 45%, var(--pine-deep) 100%) no-repeat;
  min-height: 100vh;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

/* Gentle falling snow (pure CSS). */
body::before {
  content: "";
  position: fixed;
  inset: -200px 0 0 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(3px 3px at 20px 30px, rgba(255,255,255,.9), transparent 60%),
    radial-gradient(2px 2px at 90px 120px, rgba(255,255,255,.8), transparent 60%),
    radial-gradient(4px 4px at 160px 60px, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(2px 2px at 240px 170px, rgba(255,255,255,.85), transparent 60%),
    radial-gradient(3px 3px at 300px 20px, rgba(255,255,255,.6), transparent 60%);
  background-size: 320px 200px;
  animation: snow 14s linear infinite;
  opacity: .55;
}
@keyframes snow { to { transform: translateY(200px); } }

/* Christmas-light garland across the top. */
.lights {
  position: relative; z-index: 1;
  height: 14px;
  background:
    radial-gradient(circle at 12px 7px, var(--red) 5px, transparent 6px) 0 0 / 96px 14px repeat-x,
    radial-gradient(circle at 36px 7px, var(--gold) 5px, transparent 6px) 0 0 / 96px 14px repeat-x,
    radial-gradient(circle at 60px 7px, #4fc3f7 5px, transparent 6px) 0 0 / 96px 14px repeat-x,
    radial-gradient(circle at 84px 7px, #7ee081 5px, transparent 6px) 0 0 / 96px 14px repeat-x;
  animation: twinkle 2.4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .65; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  body::before, .lights { animation: none; }
}

.wrap {
  position: relative; z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}
.wrap.wide { max-width: 1280px; }

a { color: var(--gold); }

h1, h2, h3 { line-height: 1.15; margin: .2em 0 .4em; }
h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); }
h2 { font-size: clamp(1.3rem, 4.5vw, 1.8rem); }

.hero { text-align: center; padding: 18px 0 8px; }
.hero-emoji { font-size: 4rem; line-height: 1; }
.lead { font-size: 1.1rem; opacity: .92; margin-top: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 10px;
}
.topbar a { text-decoration: none; font-weight: 600; }

/* Cards */
.card {
  background: var(--cream);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
  box-shadow: var(--shadow);
  border-top: 6px solid var(--red);
}
.card.gold { border-top-color: var(--gold); }
.card.green { border-top-color: var(--green-ok); }
.card a { color: var(--red-dark); }
.card p:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* Home tiles */
.tiles { display: grid; gap: 14px; grid-template-columns: 1fr; margin-top: 16px; }
@media (min-width: 560px) { .tiles { grid-template-columns: 1fr 1fr; } }
.tile {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--cream); color: var(--ink);
  border-radius: var(--radius); padding: 20px;
  text-decoration: none; box-shadow: var(--shadow);
  border-left: 8px solid var(--red);
  transition: transform .12s ease;
}
.tile:nth-child(2n) { border-left-color: var(--gold); }
.tile:hover, .tile:focus-visible { transform: translateY(-2px) rotate(-.4deg); }
.tile-emoji { font-size: 2rem; }
.tile-title { font-size: 1.25rem; font-weight: 800; }
.tile-sub { color: var(--muted); }

/* Forms */
label { display: block; font-weight: 700; margin: 14px 0 6px; }
.hint { font-weight: 400; color: var(--muted); font-size: .9rem; }
select, textarea, input[type="text"], input[type="password"] {
  width: 100%;
  font: inherit;
  font-size: 1.05rem; /* >=16px stops iOS zoom-on-focus */
  padding: 12px 14px;
  border: 2px solid #d8cfc4;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
select:focus, textarea:focus, input:focus { outline: 3px solid var(--gold); border-color: var(--red); }
textarea { min-height: 84px; resize: vertical; }
.counter { text-align: right; font-size: .85rem; color: var(--muted); margin-top: 4px; }
.counter.near { color: var(--red); font-weight: 700; }
.code-input { text-transform: uppercase; letter-spacing: .2em; font-size: 1.4rem !important; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 56px; padding: 12px 22px;
  font: inherit; font-size: 1.1rem; font-weight: 800;
  border: none; border-radius: 999px;
  background: var(--red); color: #fff;
  cursor: pointer; box-shadow: 0 4px 0 var(--red-dark);
  text-decoration: none;
  touch-action: manipulation;
  transition: transform .06s ease, filter .1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-dark); }
.btn[disabled] { opacity: .5; cursor: not-allowed; filter: grayscale(.4); }
.btn.block { display: flex; width: 100%; margin-top: 18px; }
.btn.gold { background: var(--gold); color: var(--ink); box-shadow: 0 4px 0 #b88a1f; }
.btn.green { background: var(--green-ok); box-shadow: 0 4px 0 #13603a; }
.btn.ghost { background: transparent; color: var(--red-dark); box-shadow: inset 0 0 0 2px var(--red-dark); }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: .9rem; }
.btn.armed { background: #ff6b00; box-shadow: 0 4px 0 #b34a00; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* Messages */
.msg { border-radius: 12px; padding: 12px 14px; margin: 12px 0; font-weight: 600; }
.msg.error { background: #ffe1e4; color: #8a0a1e; }
.msg.ok { background: #ddf5e5; color: #145c33; }
.msg.info { background: #fff1c9; color: #6b4e00; }

/* Edit code display */
.code-display {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(2rem, 10vw, 3.2rem);
  font-weight: 800; letter-spacing: .12em;
  text-align: center;
  background: #fff; border: 3px dashed var(--red);
  border-radius: 14px; padding: 14px; margin: 12px 0;
  user-select: all;
}

/* Status list */
.progress { height: 18px; background: rgba(0,0,0,.12); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); border-radius: 999px; transition: width .4s; }
.people { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.people li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #fff; border-radius: 12px; border: 2px solid #eee3d6; font-weight: 600; }
.people li.done { border-color: #a8dcb9; }
.people .mark { font-size: 1.3rem; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: .9rem; }
.pill.locked { background: #ffe1e4; color: #8a0a1e; }
.pill.unlocked { background: #ddf5e5; color: #145c33; }
.activity { list-style: none; padding: 0; margin: 0; font-size: .92rem; }
.activity li { padding: 6px 0; border-bottom: 1px solid #eee3d6; }
.activity time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }

.danger { border-top-color: #000; }

/* ---------------- Reveal (TV) ---------------- */
.page-reveal { font-size: clamp(16px, min(1.5vw, 2.6vh), 30px); }
.page-reveal .wrap { max-width: 1400px; padding-top: 8px; padding-bottom: 14px; }
.reveal-title { text-align: center; font-size: clamp(2rem, 4.5vw, 4.2rem); margin: .3em 0; text-shadow: 0 4px 16px rgba(0,0,0,.4); }
.locked-screen { text-align: center; padding: 8vh 0; }
.locked-screen .big-emoji { font-size: clamp(5rem, 14vw, 11rem); }

.picker { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.pick {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 130px; padding: 16px;
  font: inherit; font-size: 1.5rem; font-weight: 800;
  background: var(--cream); color: var(--ink);
  border: 4px solid transparent; border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer;
}
.pick:hover, .pick:focus-visible { border-color: var(--gold); }
.pick .sub { font-size: .8rem; font-weight: 600; color: var(--muted); }
.pick.solved { background: #ddf5e5; }
.pick[disabled] { opacity: .45; cursor: not-allowed; }

.game-head { text-align: center; }
.game-head h1 { font-size: clamp(1.8rem, min(4.2vw, 7vh), 4rem); margin: 0 0 .1em; }
.game-head .who { color: var(--gold); }

.tamper { background: #ffe9a8; color: #5c4300; border-radius: 14px; padding: 8px 16px; font-size: .85em; font-weight: 700; margin: 10px auto; max-width: 1100px; text-align: center; }

.clues { display: grid; gap: 14px; margin: 16px auto; max-width: 1200px; }
.clue {
  display: flex; gap: 20px; align-items: center;
  background: var(--cream); color: var(--ink);
  border-radius: var(--radius); padding: 12px 24px;
  box-shadow: var(--shadow); min-height: 80px;
  border-left: 12px solid var(--gold);
}
.clue .num { flex: 0 0 auto; width: 2em; height: 2em; border-radius: 50%; display: grid; place-items: center; background: var(--red); color: #fff; font-weight: 900; font-size: 1.3em; }
.clue .text { font-size: clamp(1.15rem, min(2.2vw, 3.9vh), 2.3rem); font-weight: 700; white-space: pre-wrap; overflow-wrap: anywhere; }
.clue.hidden-clue { background: rgba(255,255,255,.12); color: rgba(255,255,255,.75); border-left-color: rgba(255,255,255,.3); box-shadow: none; border: 3px dashed rgba(255,255,255,.35); border-left-width: 12px; }
.clue.hidden-clue .num { background: rgba(255,255,255,.25); }
.clue.fresh { animation: pop .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.scoreboard { display: flex; justify-content: center; gap: 18px; flex-wrap: wrap; margin: 6px 0 10px; }
.score { background: rgba(0,0,0,.3); border-radius: 16px; padding: 4px 24px; text-align: center; }
.score .n { display: block; font-size: clamp(2rem, min(4vw, 7vh), 4rem); font-weight: 900; color: var(--gold); line-height: 1.05; font-variant-numeric: tabular-nums; }
.score .l { font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; }
.score.bump .n { animation: bump .5s ease; }
@keyframes bump { 40% { transform: scale(1.35); color: #ff6b6b; } }

/* Sticky so the buttons are always on screen, even with very long clues. */
.game-actions { display: grid; gap: 18px; grid-template-columns: 1fr; max-width: 1200px; margin: 0 auto; position: sticky; bottom: 10px; z-index: 5; }
@media (min-width: 800px) { .game-actions { grid-template-columns: 2fr 1fr; } }
.game-actions .btn { min-height: clamp(72px, 11vh, 120px); font-size: clamp(1.3rem, min(2.3vw, 4vh), 2.4rem); border-radius: 26px; }
.game-actions #start-btn { grid-column: 1 / -1; }

.solved-banner { text-align: center; background: var(--green-ok); color: #fff; border-radius: 22px; padding: 18px; font-size: clamp(1.4rem, 3vw, 2.6rem); font-weight: 900; max-width: 1200px; margin: 0 auto; }

/* Celebration overlay */
.celebrate {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(7, 38, 29, .82);
  text-align: center; padding: 20px;
  cursor: pointer;
}
.celebrate .big { font-size: clamp(3rem, 10vw, 8rem); font-weight: 900; color: var(--gold); text-shadow: 0 6px 30px rgba(0,0,0,.5); animation: pop .8s cubic-bezier(.2, 1.6, .4, 1); }
.celebrate .sub { font-size: clamp(1.4rem, 3.5vw, 3rem); font-weight: 800; }
.confetti { position: fixed; top: -40px; z-index: 60; pointer-events: none; font-size: 28px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 70; max-width: 92vw;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 700; box-shadow: var(--shadow);
}
.toast.error { background: #8a0a1e; }

footer.foot { text-align: center; margin-top: 36px; opacity: .8; font-size: .9rem; }
.btn-row.centered { justify-content: center; }
.btn-row.spaced { margin-top: 14px; }
.btn.ghost.light { color: var(--cream); box-shadow: inset 0 0 0 2px var(--cream); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.admin-list { list-style: none; padding: 0; margin: 0; }
.admin-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid #eee3d6; }
.admin-list .btn-row { gap: 6px; }
