:root {
  --red: #ce0107;
  --red-d: #a00106;
  --green: #6e0b10;
  --green-l: #8f1218;
  --gold: #d4a63a;
  --bg: #f6f1e8;
  --card: #ffffff;
  --ink: #2a2622;
  --muted: #7d7466;
  --line: #e7dfd1;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 "Noto Sans Armenian", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background-image: radial-gradient(circle at 10% 0%, rgba(206,1,7,.06), transparent 40%), radial-gradient(circle at 100% 20%, rgba(212,166,58,.10), transparent 45%);
  min-height: 100vh;
}
a { color: var(--red); }
h1, h2 { font-family: "Noto Serif Armenian", Georgia, serif; line-height: 1.25; }
h1 { font-size: 1.8rem; margin: .4em 0 .5em; }
h2 { font-size: 1.25rem; margin: 0 0 .7em; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 18px; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
.center { text-align: center; }

/* top bar */
.topbar { background: var(--green); color: #fff; box-shadow: 0 2px 0 var(--gold); position: relative; z-index: 2; }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { height: 44px; width: 44px; border-radius: 8px; background: #fff; padding: 3px; object-fit: contain; border: 1px solid rgba(255,255,255,.4); }
.brand-text { font-weight: 700; font-size: 1.15rem; letter-spacing: .03em; }
.brand-sub { font-family: "Noto Serif Armenian", serif; font-size: 1.05rem; opacity: .95; border-left: 1px solid rgba(255,255,255,.35); padding-left: 12px; }
.usernav { display: flex; align-items: center; gap: 14px; font-size: .92rem; }
.usernav a { color: #fff; }
.who { display: flex; align-items: center; gap: 8px; }
.who img { width: 28px; height: 28px; border-radius: 50%; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.topbar button.link { color: #fff; }
button.link.danger, .danger { color: var(--red); }

/* snow */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: radial-gradient(2px 2px at 20px 30px, #fff, transparent), radial-gradient(2px 2px at 80px 120px, #fff, transparent), radial-gradient(1.5px 1.5px at 150px 60px, #fff, transparent), radial-gradient(2px 2px at 220px 180px, #fff, transparent);
  background-size: 260px 220px; animation: snow 18s linear infinite; }
@keyframes snow { to { background-position: 0 220px; } }
@media (prefers-reduced-motion: reduce) { .snow { animation: none; } }
main { position: relative; z-index: 1; padding-bottom: 30px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin: 0 0 18px; box-shadow: 0 1px 2px rgba(0,0,0,.03), 0 6px 20px rgba(60,40,10,.04); }
.card.narrow { max-width: 560px; margin: 24px auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 24px; }
.tile { display: block; text-decoration: none; color: var(--ink); transition: transform .12s, box-shadow .12s; border-top: 4px solid var(--red); }
.tile:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(60,40,10,.09); }
.tile-elf { border-top-color: var(--green); }
.tile-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 8px; }
.badge { display: inline-block; font-size: .78rem; padding: 3px 10px; border-radius: 999px; font-weight: 600; margin-bottom: 6px; }
.b-green { background: #f8e6e7; color: var(--green); }
.b-gold { background: #fbf1d8; color: #8a6510; }
.b-gray { background: #eee; color: #666; }
.empty { text-align: center; }
.empty form { justify-content: center; }

/* forms */
input, select, textarea { font: inherit; color: inherit; padding: 10px 12px; border: 1px solid #d8cfbf; border-radius: 10px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(206,1,7,.25); border-color: var(--red); }
textarea { resize: vertical; }
select.mini { padding: 4px 6px; width: auto; font-size: .9rem; }
.lbl { display: block; font-weight: 600; margin: 14px 0 6px; font-size: .95rem; }
.readonly { padding: 10px 12px; background: #faf7f1; border-radius: 10px; border: 1px dashed var(--line); }
.choice { display: flex; gap: 10px; flex-wrap: wrap; }
.choice label { flex: 1; min-width: 140px; display: flex; gap: 8px; align-items: center; padding: 12px 14px; border: 1px solid #d8cfbf; border-radius: 10px; cursor: pointer; background: #fff; }
.choice label:has(input:checked) { border-color: var(--red); background: #fdf3f3; }
.choice input { width: auto; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; flex: none; accent-color: var(--red); }
.rules { display: grid; gap: 4px; background: #faf7f1; border-radius: 12px; padding: 6px 14px; margin-bottom: 14px; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.row input, .row select { flex: 1; min-width: 150px; }
.small-form input { padding: 6px 10px; }

.btn { display: inline-block; background: var(--red); color: #fff; border: 0; border-radius: 10px; padding: 11px 20px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; margin-top: 14px; }
.row .btn, .row form .btn { margin-top: 0; }
.btn:hover { background: var(--red-d); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-big { font-size: 1.08rem; padding: 14px 26px; }
.btn-full { display: block; width: 100%; }
.btn-green { background: var(--green); }
.btn-green:hover { background: var(--green-l); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid #d8cfbf; }
.btn-ghost:hover { background: #f5efe5; }
.btn-danger { background: #6d0f17; }
.btn-sm { padding: 6px 12px; font-size: .88rem; }
.pill { background: var(--gold); color: #2a1d00; border-radius: 999px; padding: 1px 8px; font-size: .82rem; margin-left: 6px; }

/* flash */
.flash { margin: 18px 0 0; padding: 12px 16px; border-radius: 10px; border: 1px solid; }
.flash + .flash { margin-top: 8px; }
.flash-ok { background: #e7f4ec; border-color: #b7dcc6; color: #1c5236; }
.flash-err { background: #fdecec; border-color: #f2bcbc; color: #8e1822; }
.flash-warn { background: #fdf5e1; border-color: #efd99a; color: #6e5108; }
main > .flash:last-of-type { margin-bottom: 8px; }

/* login */
.hero { text-align: center; max-width: 620px; margin: 40px auto 24px; padding: 36px 26px; }
.hero h1 { font-size: 2.3rem; margin: .2em 0; color: var(--green); }
.hero-emoji { font-size: 3rem; }
.hero-logo { width: 220px; max-width: 80%; height: auto; display: block; margin: 0 auto 6px; }
.lead { font-size: 1.1rem; }
.gbtn { display: flex; justify-content: center; margin: 22px 0 6px; min-height: 44px; }
.devlogin { margin-top: 26px; border-top: 1px dashed var(--line); padding-top: 14px; display: grid; gap: 8px; max-width: 320px; margin-left: auto; margin-right: auto; }
.devlogin .btn { margin-top: 0; }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; max-width: 820px; margin: 0 auto 30px; }
.step { background: rgba(255,255,255,.75); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.step span { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 700; margin-right: 8px; }
.step p { margin: 8px 0 0; color: var(--muted); font-size: .95rem; }

/* participant */
.facts { list-style: none; padding: 0; margin: 10px 0 16px; }
.facts li { margin: 4px 0; }
.inline-facts { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.inline-facts li { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; margin: 0; font-size: .93rem; }
.note { background: #fffaf0; border-color: #f0dfb5; }
.note-title { font-weight: 700; margin-bottom: 6px; }
.waiting { text-align: center; padding: 36px 22px; }
.big-emoji { font-size: 3rem; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 18px; }
.two .card { display: flex; flex-direction: column; }
.two .card .btn-full { margin-top: auto; }
.card-kicker { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
.reveal { border-top: 4px solid var(--red); }
.giftbox { border-radius: 12px; background: linear-gradient(135deg, #fbeaea, #fff6e6); padding: 20px; text-align: center; cursor: pointer; margin-bottom: 14px; min-height: 180px; display: grid; place-items: center; }
.giftbox .gb-open { display: none; }
.giftbox.open { cursor: default; background: #fff; border: 1px dashed var(--line); }
.giftbox.open .gb-closed { display: none; }
.giftbox.open .gb-open { display: block; animation: pop .45s ease-out; }
.gb-emoji { font-size: 4rem; animation: wiggle 2.2s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(-8deg); } 20% { transform: rotate(8deg); } 30% { transform: rotate(0); } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.avatar-lg { width: 76px; height: 76px; border-radius: 50%; border: 3px solid var(--gold); }
.child-name { font-family: "Noto Serif Armenian", serif; font-size: 1.6rem; font-weight: 700; color: var(--green); margin: 6px 0 10px; }
.wish { text-align: left; background: #faf7f1; padding: 12px 14px; border-radius: 10px; font-size: .95rem; }
.mystery { font-size: 4rem; text-align: center; margin: 10px 0; }
.santa-revealed { text-align: center; margin-bottom: 12px; }
.leave { margin-top: 18px; text-align: right; }

/* chat */
.chat { padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: #fbf8f2; }
.chat-title { font-weight: 700; font-size: 1.08rem; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center; }
.avatar-santa { background: #fdecec; font-size: 1.4rem; }
.msgs { padding: 18px; display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow-y: auto; background: #fffdf9; }
.chat-empty { padding: 30px 10px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 16px; }
.msg.mine { align-self: flex-end; background: #fbe4e4; border-bottom-right-radius: 4px; }
.msg.theirs { align-self: flex-start; background: #f5ecd9; border-bottom-left-radius: 4px; }
.msg img { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; margin-bottom: 6px; }
.msg-body { white-space: normal; word-wrap: break-word; }
.msg-time { font-size: .75rem; color: var(--muted); margin-top: 4px; }
.composer { padding: 14px 18px; border-top: 1px solid var(--line); }
.composer-row { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 10px; }
.composer-row .btn { margin: 0; }
.filebtn { cursor: pointer; padding: 9px 14px; border: 1px dashed #c9bda8; border-radius: 10px; font-size: .93rem; }
.filebtn.has { border-style: solid; border-color: var(--green); background: #fbeaea; }

/* elf */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 1.45rem; color: var(--green); }
.stat span { font-size: .85rem; color: var(--muted); }
.invite { border-left: 5px solid var(--gold); }
.copyrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.copyrow code { background: #faf7f1; border: 1px solid var(--line); padding: 9px 12px; border-radius: 8px; font-size: .95rem; word-break: break-all; flex: 1; min-width: 200px; }
.copyrow.small code { padding: 4px 8px; font-size: .82rem; }
.copyrow .btn { margin: 0; }
.rules-summary { list-style: none; padding: 0; margin: 0 0 10px; }
.danger-zone { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 10px; }
.danger-zone summary { cursor: pointer; color: var(--muted); }
.excl { list-style: none; padding: 0; margin: 14px 0 0; }
.excl li { padding: 6px 0; border-bottom: 1px solid #f1ebe0; display: flex; justify-content: space-between; }
.tablewrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: 9px 8px; border-bottom: 1px solid #f1ebe0; text-align: left; vertical-align: middle; }
.tbl th { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* admin */
.dept-row { display: grid; grid-template-columns: 1.3fr 1fr auto; gap: 16px; padding: 14px 0; border-bottom: 1px solid #f1ebe0; align-items: start; }
.dept-name { font-weight: 700; font-size: 1.08rem; display: block; margin-bottom: 2px; }
.dept-main .copyrow { margin-top: 6px; }
.dept-elves .lbl { margin-top: 0; }
.dept-elves .row { margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #f8e6e7; border-radius: 999px; padding: 3px 10px; margin: 0 4px 4px 0; font-size: .87rem; }
@media (max-width: 720px) { .dept-row { grid-template-columns: 1fr; } }

.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 18px; position: relative; z-index: 1; }

@media (max-width: 560px) {
  h1 { font-size: 1.5rem; }
  .card { padding: 16px; }
  .brand-sub { display: none; }
  .msg { max-width: 90%; }
}
.credit { margin-top: 6px; font-size: .9rem; color: var(--green); }
.credit b { font-weight: 700; }
