:root {
  --sky1: #0b1d3a;
  --sky2: #183b6e;
  --card: #fffaf3;
  --ink: #2b1d14;
  --muted: #7a6656;
  --red: #d7263d;
  --red-d: #a8172b;
  --green: #1f7a4d;
  --green-l: #e3f4ea;
  --gold: #f5b82e;
  --line: #ecdcc8;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: Rubik, system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% -10%, #2c5a9c 0%, var(--sky2) 35%, var(--sky1) 80%) fixed;
  background-color: var(--sky1);
  overflow-x: hidden;
}
#snow, #confetti { position: fixed; inset: 0; pointer-events: none; }
#snow { z-index: 0; }
#confetti { z-index: 60; }
main { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 34px 16px 80px; }
.loading { text-align: center; font-size: 60px; margin-top: 30vh; animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Гирлянда */
.garland { position: relative; z-index: 2; height: 26px; display: flex; justify-content: space-around;
  border-top: 2px solid #2d4a2d; margin: 0 -10px; overflow: hidden; }
.garland i { width: 12px; height: 18px; border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%; margin-top: 4px;
  animation: blink 1.6s infinite alternate; box-shadow: 0 0 12px currentColor; background: currentColor; }
.garland i:nth-child(4n+1) { color: #ff4d6d; }
.garland i:nth-child(4n+2) { color: #ffd166; animation-delay: .4s; }
.garland i:nth-child(4n+3) { color: #06d6a0; animation-delay: .8s; }
.garland i:nth-child(4n) { color: #4cc9f0; animation-delay: 1.2s; }
@keyframes blink { from { opacity: 1; } to { opacity: .25; box-shadow: none; } }

/* Шапка */
.hero { text-align: center; color: #fff; margin-bottom: 22px; }
.hero h1 { font-family: Lobster, cursive; font-weight: 400; font-size: clamp(40px, 9vw, 64px); margin: 0;
  text-shadow: 0 4px 0 var(--red-d), 0 8px 24px rgba(0,0,0,.4); letter-spacing: .5px; }
.hero p { margin: 6px 0 0; opacity: .85; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #fff; margin-bottom: 18px; }
.topbar .brand { font-family: Lobster, cursive; font-size: 28px; color: #fff; text-decoration: none; }
.me-chip { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  color: #fff; border-radius: 999px; padding: 6px 14px 6px 6px; cursor: pointer; font: inherit; }
.me-chip .av { width: 32px; height: 32px; font-size: 20px; background: rgba(255,255,255,.9); }

/* Карточки */
.card { background: var(--card); border-radius: var(--radius); padding: 22px; margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); position: relative; }
.card.ribbon { overflow: hidden; }
.card.ribbon::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: repeating-linear-gradient(45deg, var(--red) 0 14px, #fff 14px 28px, var(--green) 28px 42px, #fff 42px 56px); }
.card h2 { margin: 0 0 12px; font-size: 22px; }
.card h3 { margin: 18px 0 8px; font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* Формы */
label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 15px; }
label .hint { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 2px; }
input, textarea, select { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 2px solid var(--line);
  border-radius: 12px; padding: 11px 13px; outline: none; transition: border-color .15s; }
textarea { min-height: 92px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--green); }
.field + .field { margin-top: 14px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 400; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 500;
  border: 0; border-radius: 12px; padding: 12px 18px; cursor: pointer; background: var(--red); color: #fff;
  text-decoration: none; transition: transform .1s, background .15s; box-shadow: 0 3px 0 var(--red-d); }
.btn:hover { background: #e23a50; }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.green { background: var(--green); box-shadow: 0 3px 0 #135436; }
.btn.green:hover { background: #26905b; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: none; border: 2px solid var(--line); }
.btn.ghost:hover { background: #fff; }
.btn.light { background: rgba(255,255,255,.14); box-shadow: none; border: 1px solid rgba(255,255,255,.25); }
.btn.big { font-size: 18px; padding: 15px 24px; }
.btn.wide { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.link { background: none; border: 0; color: var(--red); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
.err { color: var(--red); font-size: 14px; min-height: 18px; margin-top: 8px; }

/* Переключатели */
.tabs { display: flex; gap: 6px; background: rgba(255,255,255,.1); padding: 5px; border-radius: 14px; margin-bottom: 16px;
  overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 0 auto; font: inherit; font-size: 15px; border: 0; background: transparent; color: #fff;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; white-space: nowrap; position: relative; }
.tabs button.on { background: var(--card); color: var(--ink); font-weight: 500; }
.seg { display: flex; background: #f1e6d6; padding: 4px; border-radius: 12px; margin-bottom: 18px; }
.seg button { flex: 1; font: inherit; border: 0; background: none; padding: 9px; border-radius: 9px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); font-weight: 500; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.badge { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red);
  color: #fff; font-size: 12px; font-weight: 700; align-items: center; justify-content: center; margin-left: 4px; }

/* Аватары и списки */
.av { display: inline-flex; width: 44px; height: 44px; border-radius: 50%; align-items: center; justify-content: center;
  font-size: 26px; background: #fff0dc; flex: none; }
.av.xl { width: 96px; height: 96px; font-size: 58px; background: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.person { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; min-width: 0; }
.person .nm { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .st { font-size: 12px; color: var(--muted); }
.person .x { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; }

.game-item { display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit; cursor: pointer; transition: transform .15s; }
.game-item:hover { transform: translateY(-2px); }
.game-item .ico { font-size: 38px; }
.game-item .t { font-weight: 700; font-size: 18px; }
.pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 999px; background: #f1e6d6; color: var(--muted); }
.pill.open { background: #fff3cd; color: #8a6100; }
.pill.drawn { background: var(--green-l); color: var(--green); }
.pill.revealed { background: #fde2e6; color: var(--red-d); }

/* Инфо-полоса игры */
.facts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.fact { background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.2); color: #fff; border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.count-big { font-family: Lobster, cursive; font-size: 30px; color: var(--gold); }

/* Коробка */
.box-wrap { display: flex; flex-direction: column; align-items: center; padding: 18px 0 8px; }
.giftbox { width: 170px; height: 170px; position: relative; cursor: pointer; animation: wobble 2.2s ease-in-out infinite; border: 0; background: none; padding: 0; }
.giftbox .base { position: absolute; bottom: 0; left: 10px; right: 10px; height: 110px; background: var(--red); border-radius: 10px;
  box-shadow: inset 0 -14px 0 rgba(0,0,0,.12); }
.giftbox .lid { position: absolute; top: 34px; left: 0; right: 0; height: 36px; background: #e8384f; border-radius: 10px;
  box-shadow: 0 6px 0 rgba(0,0,0,.12); transition: transform .6s cubic-bezier(.5,-0.5,.5,1.5), opacity .6s; z-index: 2; }
.giftbox .rib-v { position: absolute; left: 50%; width: 26px; margin-left: -13px; top: 34px; bottom: 0; background: var(--gold); z-index: 3; }
.giftbox .bow { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); font-size: 46px; z-index: 4; transition: transform .6s, opacity .6s; }
.giftbox.open { animation: none; }
.giftbox.open .lid { transform: translateY(-120px) rotate(-25deg); opacity: 0; }
.giftbox.open .bow { transform: translate(-50%, -140px) rotate(40deg); opacity: 0; }
.giftbox.open .rib-v { opacity: 0; transition: opacity .3s; }
@keyframes wobble { 0%,70%,100% { transform: rotate(0); } 75% { transform: rotate(-7deg); } 80% { transform: rotate(7deg); } 85% { transform: rotate(-5deg); } 90% { transform: rotate(4deg); } }
.reveal-name { font-family: Lobster, cursive; font-size: 40px; color: var(--red); margin: 8px 0 0; animation: pop .6s cubic-bezier(.2,1.6,.4,1) both; text-align: center; }
@keyframes pop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.spinner-name { font-family: Lobster, cursive; font-size: 34px; color: var(--muted); min-height: 50px; text-align: center; }

.wish { background: #fff; border: 1px dashed var(--line); border-radius: 14px; padding: 12px 14px; }
.wish .k { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.steps button { font: inherit; font-size: 14px; border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 6px; cursor: pointer; }
.steps button.on { border-color: var(--green); background: var(--green-l); color: var(--green); font-weight: 500; }

/* Прогресс */
.bar { height: 10px; background: #f1e6d6; border-radius: 999px; overflow: hidden; margin: 4px 0 12px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), #3fbf7f); border-radius: 999px; transition: width .5s; }

/* Чат */
.chat { display: flex; flex-direction: column; height: min(60vh, 520px); }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px 10px; }
.msg { max-width: 80%; padding: 9px 13px; border-radius: 16px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg.mine { align-self: flex-end; background: var(--green); color: #fff; border-color: var(--green); border-bottom-right-radius: 5px; }
.msg:not(.mine) { border-bottom-left-radius: 5px; }
.msg .tm { font-size: 11px; opacity: .65; margin-top: 3px; text-align: right; }
.composer { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 46px; height: 46px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 20px; }

/* Итоги */
.chain-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.chain-row:last-child { border: 0; }
.chain-row .who { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.chain-row .who span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chain-row .who.r { justify-content: flex-end; text-align: right; }
.chain-row .av { width: 36px; height: 36px; font-size: 21px; }

/* Модалка и тост */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(5,12,28,.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal .card { width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; animation: pop .25s ease-out; }
.hidden { display: none !important; }
.toast { position: fixed; z-index: 70; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.3); max-width: calc(100% - 32px); }
.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.avatars button { font-size: 26px; border: 2px solid transparent; background: #fff; border-radius: 12px; padding: 6px 0; cursor: pointer; }
.avatars button.on { border-color: var(--green); background: var(--green-l); }
.invite { display: flex; gap: 8px; }
.invite input { font-size: 14px; background: #fff; }
.footer { text-align: center; color: rgba(255,255,255,.5); font-size: 13px; margin-top: 30px; }

@media (max-width: 520px) {
  .card { padding: 18px 16px; }
  .steps button { font-size: 13px; }
  .avatars { grid-template-columns: repeat(6, 1fr); }
  .chain-row { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .giftbox, .garland i, .loading { animation: none; }
}
