/* Таємний Санта — у мові ClassConnect: сталевий градієнт, графітова темна
   тема, Кеппі. Святковий журавлиновий колір лише на подарунку й акцентах. */
:root {
  --bg: #f3f5f8; --card: #fff; --line: #e2e7ee; --field: #f7f9fb;
  --ink: #141922; --ink2: #4a5872; --mute: #5b6b82;
  --pri: #566273; --pri-a: #7d9cc0; --pri-ink: #4a5872; --pri-soft: #eaf0f7;
  --accent: #b4434d; --accent-soft: #f8e9ea;
  --ok: #0b7a52; --ok-soft: #e3f4ec; --warn: #9a5a06; --warn-soft: #fcf1df; --danger: #be123c; --danger-soft: #fdecef;
  --shadow: 0 1px 2px rgba(20, 25, 34, .05), 0 8px 24px rgba(20, 25, 34, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014; --card: #15171c; --line: rgba(255, 255, 255, .08); --field: rgba(255, 255, 255, .04);
    --ink: #e9eef5; --ink2: #c3cfdd; --mute: #9aa7b8;
    --pri-ink: #9bb6d4; --pri-soft: rgba(155, 182, 212, .1);
    --accent: #e07a83; --accent-soft: rgba(224, 122, 131, .12);
    --ok: #34d399; --ok-soft: rgba(52, 211, 153, .1); --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .1);
    --danger: #fb7185; --danger-soft: rgba(251, 113, 133, .1);
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
.wrap { position: relative; z-index: 1; max-width: 600px; margin: 0 auto; padding: 16px 16px 48px; }
.loading { color: var(--mute); text-align: center; padding: 64px 0; }

/* Сніг: кілька тихих сніжинок. Без руху для тих, хто попросив менше анімації. */
.snow { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.snow i { position: absolute; top: -12px; width: 6px; height: 6px; border-radius: 50%; background: var(--pri-a); opacity: .18; animation: fall linear infinite; }
@keyframes fall { to { transform: translate3d(var(--dx, 20px), 105vh, 0); } }
@media (prefers-reduced-motion: reduce) { .snow { display: none; } }

/* Верх */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; }
.brand img { width: 32px; height: 32px; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--mute); line-height: 1.2; }
.back { color: var(--pri-ink); text-decoration: none; font-weight: 600; font-size: 15px; }

/* Типографіка */
h1 { font-size: 30px; line-height: 1.12; margin: 0 0 10px; letter-spacing: -.01em; }
h2 { font-size: 22px; line-height: 1.2; margin: 0 0 12px; }
h3 { font-size: 17px; margin: 0 0 10px; }
p { margin: 0 0 12px; }
.eyebrow { font-size: 13px; font-weight: 700; color: var(--pri-ink); letter-spacing: .02em; margin-bottom: 6px; }
.lead { font-size: 17px; color: var(--ink2); }
.muted { color: var(--mute); }
.small { font-size: 14px; }

/* Картки */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.soft { background: var(--pri-soft); border-color: transparent; box-shadow: none; }
.card.festive { background: var(--accent-soft); border-color: transparent; box-shadow: none; }

/* Герой */
.hero { text-align: center; padding: 8px 0 18px; }
.hero .cappy { width: 148px; height: 148px; display: block; margin: 0 auto 6px; }
.hero .lead { max-width: 30em; margin: 0 auto 18px; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none; transition: transform .15s, background-color .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--pri-a); outline-offset: 2px; }
.btn.primary { background: linear-gradient(135deg, #7d9cc0, #566273); color: #fff; border-color: transparent; }
.btn.danger { color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn.sm { min-height: 38px; padding: 7px 12px; font-size: 14px; border-radius: 11px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; }

/* Поля */
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
label.f > em { display: block; font-style: normal; color: var(--mute); font-size: 13px; margin-top: 5px; }
input[type=text], input[type=date], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px;
}
textarea { min-height: 88px; resize: vertical; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 14px; background: var(--pri-soft); margin-bottom: 14px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: #566273; flex: none; }
.check b { display: block; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }

/* Ярлички */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; background: var(--pri-soft); color: var(--pri-ink); font-size: 14px; font-weight: 600; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--pri-soft); color: var(--pri-ink); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

/* Кроки */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { position: relative; padding: 0 0 16px 48px; counter-increment: s; }
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #7d9cc0, #566273);
}
.steps b { display: block; }

/* Учасники */
.people { list-style: none; margin: 0 0 12px; padding: 0; }
.people li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.people li:first-child { border-top: 0; }
.ava { width: 36px; height: 36px; border-radius: 12px; flex: none; display: grid; place-items: center; font-weight: 800; color: #fff; background: linear-gradient(135deg, #9bb6d4, #566273); }
.people .who { flex: 1; min-width: 0; }
.people .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .who .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.icon-btn { display: grid; place-items: center; line-height: 1; width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--line); background: transparent; color: var(--mute); font-size: 18px; cursor: pointer; flex: none; }
details.more { position: relative; }
details.more > summary { list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more .menu { position: absolute; right: 0; top: 44px; z-index: 5; min-width: 230px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, .18); }
details.more .menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 15px; border-radius: 10px; cursor: pointer; }
details.more .menu button:hover { background: var(--pri-soft); }
details.more .menu button.danger { color: var(--danger); }

/* QR і код */
.invite { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: center; }
@media (min-width: 520px) { .invite { grid-template-columns: 184px 1fr; } }
.qr { background: #fff; border-radius: 16px; padding: 10px; width: 184px; height: 184px; margin: 0 auto; }
.qr svg { display: block; width: 100%; height: 100%; }
.code { font: 800 26px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .08em; margin: 2px 0 8px; }
.link { font-size: 14px; color: var(--mute); word-break: break-all; margin-bottom: 10px; }

/* Великий QR для проєктора */
.overlay { position: fixed; inset: 0; z-index: 50; background: #fff; color: #141922; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; }
.overlay .qr { width: min(70vh, 82vw); height: min(70vh, 82vw); padding: 0; }
.overlay .code { font-size: clamp(28px, 6vh, 56px); }
.overlay .close { position: absolute; top: 14px; right: 14px; width: 48px; height: 48px; border-radius: 14px; border: 1px solid #d6dde6; background: #fff; font-size: 24px; cursor: pointer; color: #141922; }

/* Подарунок */
.gift-wrap { text-align: center; padding: 10px 0 4px; }
.gift { position: relative; width: 190px; height: 180px; margin: 6px auto 14px; border: 0; background: none; cursor: pointer; padding: 0; display: block; }
.gift .box { position: absolute; left: 20px; right: 20px; bottom: 0; height: 112px; border-radius: 14px; background: linear-gradient(135deg, #9bb6d4, #566273); }
.gift .lid { position: absolute; left: 8px; right: 8px; top: 44px; height: 34px; border-radius: 10px; background: #566273; transform-origin: 20% 100%; transition: transform .5s cubic-bezier(.3, 1.6, .5, 1); }
.gift .ribbon-v { position: absolute; left: 50%; width: 22px; margin-left: -11px; top: 44px; bottom: 0; background: var(--accent); }
.gift .bow { position: absolute; left: 50%; top: 12px; width: 76px; height: 40px; margin-left: -38px; transition: transform .5s; }
.gift .bow::before, .gift .bow::after { content: ""; position: absolute; top: 4px; width: 34px; height: 30px; border: 8px solid var(--accent); border-radius: 50% 50% 10% 50%; }
.gift .bow::before { left: 0; transform: rotate(-20deg); }
.gift .bow::after { right: 0; transform: rotate(20deg) scaleX(-1); }
.gift:not([disabled]) { animation: wiggle 2.6s ease-in-out infinite; }
.gift.open .lid { transform: translateY(-46px) rotate(-24deg); }
.gift.open .bow { transform: translateY(-46px) translateX(-14px) rotate(-24deg); }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 84% { transform: rotate(-4deg); } 88% { transform: rotate(4deg); } 92% { transform: rotate(-2deg); } }
@media (prefers-reduced-motion: reduce) { .gift, .gift .lid, .gift .bow { animation: none !important; transition: none !important; } }

.reveal { text-align: center; }
.reveal .to { font-size: clamp(30px, 9vw, 44px); font-weight: 800; line-height: 1.1; margin: 4px 0 14px; color: var(--accent); overflow-wrap: anywhere; }
.reveal.pop { animation: pop .45s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
.wish { text-align: left; background: var(--card); border-radius: 14px; padding: 12px 14px; border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Повідомлення */
.note { padding: 12px 14px; border-radius: 14px; font-size: 15px; margin-bottom: 14px; }
.note.err { background: var(--danger-soft); color: var(--danger); }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: #141922; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100vw - 32px); }

dialog { border: 0; border-radius: 20px; padding: 20px; max-width: min(420px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(10, 12, 16, .55); }
dialog p { color: var(--ink2); }

.list-games { list-style: none; padding: 0; margin: 0; }
.list-games a { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.list-games li:first-child a { border-top: 0; }
.list-games b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

footer.foot { text-align: center; color: var(--mute); font-size: 14px; margin-top: 28px; }
footer.foot a { color: var(--pri-ink); font-weight: 700; text-decoration: none; }

/* Друк карток для учнів без телефона */
.print-sheet { display: none; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  .wrap, .snow, .toast, dialog { display: none !important; }
  .print-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; color: #141922; }
  .pcard { border: 1.5px dashed #9aa7b8; border-radius: 6mm; padding: 6mm; text-align: center; break-inside: avoid; font-size: 11pt; }
  .pcard .qr { width: 42mm; height: 42mm; padding: 0; margin: 3mm auto; }
  .pcard b { display: block; font-size: 15pt; }
}

/* Вибір способу входу */
fieldset.modes { border: 0; padding: 0; margin: 0 0 14px; }
fieldset.modes legend { font-weight: 700; font-size: 15px; margin-bottom: 6px; padding: 0; }
label.mode { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; cursor: pointer; }
label.mode:has(input:checked) { border-color: var(--pri-a); background: var(--pri-soft); }
label.mode input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: #566273; flex: none; }
label.mode b { display: block; }
[hidden] { display: none !important; }

/* Список імен на вході */
.pick { list-style: none; margin: 0; padding: 0; }
.pick button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 6px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; min-height: 56px; }
.pick li:first-child button { border-top: 0; }
.pick button:active { background: var(--pri-soft); }
.pick b { flex: 1; }
.pick .go { color: var(--mute); font-size: 22px; }
.me-pick { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--pri-soft); margin-bottom: 14px; }
.me-pick .who { flex: 1; min-width: 0; }
.me-pick .who b { display: block; font-size: 18px; }

/* Стан гри */
.checklist { list-style: none; padding: 0; margin: 0 0 14px; }
.checklist li { display: flex; gap: 10px; padding: 6px 0; color: var(--ink2); }
.checklist li span { width: 22px; height: 22px; flex: none; border-radius: 7px; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--warn-soft); color: var(--warn); }
.checklist li.yes span { background: var(--ok-soft); color: var(--ok); }
.status.open { border-color: transparent; background: var(--ok-soft); box-shadow: none; }
.status.open .eyebrow { color: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-size: 26px; line-height: 1.1; }
.stats b small { font-size: 15px; color: var(--mute); font-weight: 600; }
.stats span { font-size: 13px; color: var(--mute); }

@media print {
  .poster { grid-column: 1 / -1; text-align: center; padding: 6mm 4mm; color: #141922; font-size: 14pt; }
  .poster .p-top { display: flex; align-items: center; justify-content: center; gap: 3mm; font-weight: 800; font-size: 16pt; color: #4a5872; }
  .poster .p-top img { width: 10mm; height: 10mm; }
  .poster h1 { font-size: 34pt; margin: 4mm 0 2mm; }
  .poster .p-terms { font-size: 15pt; color: #4a5872; font-weight: 700; }
  .poster .qr { width: 120mm; height: 120mm; padding: 0; margin: 8mm auto; }
  .poster ol { text-align: left; max-width: 150mm; margin: 0 auto 6mm; padding-left: 8mm; line-height: 1.6; }
  .poster .p-url { font-size: 13pt; color: #4a5872; }
  .poster .p-foot { margin-top: 4mm; font-size: 12pt; color: #5b6b82; }
}
