/* ===== Шрифтове (локално хостнати, OFL) ===== */
@font-face { font-family: 'Lobster'; font-weight: 400; font-display: swap; src: url('/assets/fonts/lobster-cyrillic-400-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Lobster'; font-weight: 400; font-display: swap; src: url('/assets/fonts/lobster-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Nunito'; font-weight: 400; font-display: swap; src: url('/assets/fonts/nunito-cyrillic-400-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Nunito'; font-weight: 700; font-display: swap; src: url('/assets/fonts/nunito-cyrillic-700-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: swap; src: url('/assets/fonts/nunito-cyrillic-800-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Nunito'; font-weight: 400; font-display: swap; src: url('/assets/fonts/nunito-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: 'Nunito'; font-weight: 700; font-display: swap; src: url('/assets/fonts/nunito-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: swap; src: url('/assets/fonts/nunito-latin-800-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }

:root {
  --pine-900: #0c2a20;
  --pine-800: #12382b;
  --pine-700: #1a4a39;
  --pine-500: #2f6e55;
  --berry-700: #8f1d22;
  --berry-600: #b0262c;
  --berry-500: #c9373c;
  --gold-500: #e9b54c;
  --gold-300: #f6d78e;
  --cream-50: #fffaf0;
  --cream-100: #fbf2df;
  --cream-200: #f1e2c3;
  --ink-900: #2a1d14;
  --ink-700: #4f3b2c;
  --ink-500: #7a6352;
  --ok: #24724f;
  --radius: 18px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, .55), 0 2px 0 rgba(255, 255, 255, .6) inset;
  --focus: 0 0 0 3px var(--cream-50), 0 0 0 6px var(--gold-500);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--pine-900); min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink-900);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(233, 181, 76, .22), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(176, 38, 44, .25), transparent 60%),
    linear-gradient(180deg, var(--pine-800), var(--pine-900));
  background-repeat: no-repeat;
  overflow-x: hidden;
}

/* ===== Сняг ===== */
.snow, .snow::before, .snow::after {
  position: fixed; inset: -100px 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 120px 80px, rgba(255,255,255,.8), transparent 60%),
    radial-gradient(4px 4px at 200px 150px, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(2px 2px at 300px 20px, rgba(255,255,255,.9), transparent 60%),
    radial-gradient(3px 3px at 360px 200px, rgba(255,255,255,.6), transparent 60%);
  background-size: 400px 260px;
  animation: snowfall 18s linear infinite;
  opacity: .55;
}
.snow::before { content: ''; background-size: 300px 200px; animation-duration: 26s; opacity: .7; }
.snow::after { content: ''; background-size: 520px 340px; animation-duration: 38s; opacity: .5; }
@keyframes snowfall { from { background-position: 0 0; } to { background-position: 60px 520px; } }

/* ===== Гирлянд ===== */
.garland { position: relative; z-index: 1; height: 54px; overflow: hidden; }
.garland svg { display: block; width: 100%; height: 54px; }
.garland .bulb { animation: twinkle 3.2s ease-in-out infinite; transform-origin: center; }
.garland .bulb:nth-child(3n) { animation-delay: .8s; }
.garland .bulb:nth-child(3n+1) { animation-delay: 1.6s; }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ===== Оформление ===== */
.wrap { position: relative; z-index: 1; width: min(100% - 2rem, 760px); margin: 0 auto; padding: 1rem 0 4rem; }
.wrap.wide { width: min(100% - 2rem, 1080px); }
.brand { text-align: center; color: var(--cream-50); margin: .5rem 0 1.75rem; }
.brand h1 {
  font-family: 'Lobster', Georgia, serif; font-weight: 400;
  font-size: clamp(2.3rem, 7vw, 3.6rem); line-height: 1.1; margin: .25rem 0;
  color: var(--gold-300); text-shadow: 0 3px 0 rgba(0,0,0,.25), 0 0 30px rgba(233,181,76,.35);
}
.brand p { margin: 0; color: var(--cream-200); font-size: 1.05rem; }
.brand .star { width: 54px; height: 54px; }

.card {
  position: relative;
  background: linear-gradient(180deg, var(--cream-50), var(--cream-100));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 4vw, 2rem);
  margin-bottom: 1.25rem;
  border: 1px solid rgba(255,255,255,.7);
}
.card.ribbon::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 8px; border-radius: var(--radius) var(--radius) 0 0;
  background: repeating-linear-gradient(135deg, var(--berry-600) 0 14px, var(--cream-50) 14px 22px);
}
.card h2 { font-family: 'Lobster', Georgia, serif; font-weight: 400; color: var(--berry-700); font-size: 1.85rem; margin: .2rem 0 .75rem; line-height: 1.2; }
.card h3 { margin: 1.25rem 0 .5rem; font-size: 1.1rem; color: var(--pine-700); }
.muted { color: var(--ink-500); }
.center { text-align: center; }
.small { font-size: .92rem; }

/* ===== Форми ===== */
label { display: block; font-weight: 700; margin: .9rem 0 .35rem; color: var(--ink-700); }
input[type=text], input[type=password], input[type=number], input[type=date], select {
  width: 100%; font: inherit; font-size: 1.1rem; color: var(--ink-900);
  padding: .8rem 1rem; min-height: 52px;
  background: #fff; border: 2px solid var(--cream-200); border-radius: 12px;
  transition: border-color .15s;
}
input:hover, select:hover { border-color: #e2cfa6; }
input:focus-visible, select:focus-visible { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 4px rgba(233,181,76,.35); }
input.code-input { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; letter-spacing: .14em; text-transform: uppercase; font-size: 1.25rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.row > .shrink { flex: 0 0 auto; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .4rem .75rem; margin: .5rem 0; }
.check { display: flex; gap: .55rem; align-items: center; font-weight: 600; margin: 0; padding: .45rem .6rem; border-radius: 10px; background: #fff; border: 1px solid var(--cream-200); cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--berry-600); }

/* ===== Бутони ===== */
.btn {
  --bg: var(--berry-600); --fg: #fff; --bd: var(--berry-700);
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 800; font-size: 1.08rem; letter-spacing: .01em;
  min-height: 52px; padding: .75rem 1.4rem; border-radius: 999px;
  color: var(--fg); background: var(--bg); border: 2px solid var(--bd);
  box-shadow: 0 6px 0 var(--bd), 0 10px 20px -8px rgba(0,0,0,.5);
  cursor: pointer; text-decoration: none; transition: transform .08s, box-shadow .08s, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--bd), 0 4px 10px -6px rgba(0,0,0,.5); }
.btn:focus-visible, a:focus-visible, button:focus-visible, summary:focus-visible, .check:focus-within { outline: none; box-shadow: var(--focus); }
.btn[disabled], .btn[aria-busy=true] { opacity: .6; cursor: not-allowed; transform: none; }
.btn.green { --bg: var(--pine-500); --bd: var(--pine-700); }
.btn.gold { --bg: var(--gold-500); --fg: var(--ink-900); --bd: #b8862c; }
.btn.ghost { --bg: #fff; --fg: var(--ink-700); --bd: var(--cream-200); box-shadow: 0 3px 0 var(--cream-200); }
.btn.danger { --bg: #fff; --fg: var(--berry-700); --bd: var(--berry-500); box-shadow: 0 3px 0 var(--berry-500); }
.btn.small { min-height: 40px; padding: .4rem .9rem; font-size: .95rem; box-shadow: 0 3px 0 var(--bd); }
.btn.block { width: 100%; }
.btn.huge { font-size: 1.35rem; min-height: 68px; padding: 1rem 2.2rem; }
.linklike { background: none; border: 0; padding: .25rem; font: inherit; color: var(--cream-200); text-decoration: underline; cursor: pointer; border-radius: 6px; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

.spinner { width: 1.1em; height: 1.1em; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Съобщения ===== */
.alert { border-radius: 12px; padding: .85rem 1rem; margin: .9rem 0; font-weight: 600; border: 2px solid; }
.alert.error { background: #fdecec; border-color: #f0b4b4; color: var(--berry-700); }
.alert.ok { background: #e8f5ee; border-color: #a8d6bf; color: var(--ok); }
.alert.info { background: #fff6dc; border-color: var(--gold-300); color: var(--ink-700); }
.alert:empty { display: none; }

.badge { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .85rem; font-weight: 800; }
.badge.draft { background: #fff1c9; color: #7a5300; }
.badge.started { background: #dff3e8; color: var(--ok); }
.badge.muted { background: #efe6d6; color: var(--ink-500); }

.info-list { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin: 1rem 0 0; padding: 0; list-style: none; }
.info-list li { background: #fff; border: 2px dashed var(--gold-300); border-radius: 12px; padding: .45rem .9rem; font-weight: 700; }

/* ===== Списъци в админ панела ===== */
.list { list-style: none; margin: .5rem 0 0; padding: 0; }
.list li { display: flex; flex-wrap: wrap; gap: .5rem .75rem; align-items: center; justify-content: space-between; padding: .7rem .2rem; border-bottom: 1px dashed var(--cream-200); }
.list li:last-child { border-bottom: 0; }
.list .who { font-weight: 800; flex: 1 1 140px; }
.list .meta { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.list .btns { display: flex; gap: .4rem; flex-wrap: wrap; }
.empty { text-align: center; color: var(--ink-500); padding: 1rem; border: 2px dashed var(--cream-200); border-radius: 12px; margin: .5rem 0; }
.grid2 { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid2 .card { margin-bottom: 0; } }
.games { display: grid; gap: .75rem; }
.game-link { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.1rem; background: #fff; border: 2px solid var(--cream-200); border-radius: 14px; color: inherit; text-decoration: none; font-weight: 700; cursor: pointer; width: 100%; font: inherit; text-align: left; }
.game-link:hover { border-color: var(--gold-500); }
.copybox { display: flex; gap: .5rem; align-items: stretch; flex-wrap: wrap; }
.copybox code { flex: 1 1 260px; background: #fff; border: 2px solid var(--cream-200); border-radius: 12px; padding: .7rem .9rem; font-size: .98rem; word-break: break-all; }
.codes { font-family: ui-monospace, Menlo, Consolas, monospace; }
.progress { height: 14px; background: var(--cream-200); border-radius: 999px; overflow: hidden; margin: .5rem 0; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--pine-500), var(--gold-500)); }
details > summary { cursor: pointer; font-weight: 800; color: var(--pine-700); padding: .35rem 0; border-radius: 6px; }

/* ===== Диалог ===== */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(100% - 2rem, 560px); background: var(--cream-50); color: var(--ink-900); box-shadow: 0 30px 80px -20px rgba(0,0,0,.7); }
dialog::backdrop { background: rgba(6, 22, 16, .72); }
dialog .dlg { padding: 1.5rem; max-height: 85vh; overflow: auto; }
dialog h2 { font-family: 'Lobster', Georgia, serif; font-weight: 400; color: var(--berry-700); margin: 0 0 .5rem; font-size: 1.7rem; }

/* ===== Тост ===== */
.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 50; background: var(--pine-900); color: var(--cream-50); padding: .8rem 1.2rem; border-radius: 999px; font-weight: 700; box-shadow: 0 10px 30px rgba(0,0,0,.4); border: 2px solid var(--gold-500); max-width: calc(100% - 2rem); }
.toast[hidden] { display: none; }

/* ===== Зар ===== */
.dice-stage { perspective: 900px; display: grid; place-items: center; height: 190px; margin: 1rem 0 .5rem; }
.dice { width: 110px; height: 110px; position: relative; transform-style: preserve-3d; transform: rotateX(-24deg) rotateY(32deg); transition: transform .6s ease; }
.dice.idle { animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: rotateX(-24deg) rotateY(32deg) translateY(0); } 50% { transform: rotateX(-18deg) rotateY(42deg) translateY(-8px); } }
.dice.rolling { animation: roll 1.8s cubic-bezier(.2,.7,.25,1) forwards; }
@keyframes roll {
  0%   { transform: translateY(0) rotateX(-24deg) rotateY(32deg); }
  20%  { transform: translateY(-70px) rotateX(260deg) rotateY(180deg) rotateZ(60deg); }
  45%  { transform: translateY(0) rotateX(520deg) rotateY(390deg) rotateZ(120deg); }
  62%  { transform: translateY(-26px) rotateX(640deg) rotateY(520deg) rotateZ(160deg); }
  80%  { transform: translateY(0) rotateX(700deg) rotateY(700deg) rotateZ(180deg); }
  100% { transform: translateY(0) rotateX(720deg) rotateY(720deg) rotateZ(180deg); }
}
.face {
  position: absolute; inset: 0; border-radius: 20px;
  background: radial-gradient(circle at 30% 25%, #fff, var(--cream-100) 60%, var(--cream-200));
  border: 3px solid var(--berry-600);
  box-shadow: inset 0 0 18px rgba(143,29,34,.18);
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 14px;
}
.face i { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--berry-500), var(--berry-700)); place-self: center; }
.f1 { transform: translateZ(55px); }
.f2 { transform: rotateY(90deg) translateZ(55px); }
.f3 { transform: rotateY(180deg) translateZ(55px); }
.f4 { transform: rotateY(-90deg) translateZ(55px); }
.f5 { transform: rotateX(90deg) translateZ(55px); }
.f6 { transform: rotateX(-90deg) translateZ(55px); }
.f1 i:nth-child(1) { grid-area: 2 / 2; }
.f2 i:nth-child(1) { grid-area: 1 / 1; } .f2 i:nth-child(2) { grid-area: 3 / 3; }
.f3 i:nth-child(1) { grid-area: 1 / 1; } .f3 i:nth-child(2) { grid-area: 2 / 2; } .f3 i:nth-child(3) { grid-area: 3 / 3; }
.f4 i:nth-child(1) { grid-area: 1 / 1; } .f4 i:nth-child(2) { grid-area: 1 / 3; } .f4 i:nth-child(3) { grid-area: 3 / 1; } .f4 i:nth-child(4) { grid-area: 3 / 3; }
.f5 i:nth-child(1) { grid-area: 1 / 1; } .f5 i:nth-child(2) { grid-area: 1 / 3; } .f5 i:nth-child(3) { grid-area: 2 / 2; } .f5 i:nth-child(4) { grid-area: 3 / 1; } .f5 i:nth-child(5) { grid-area: 3 / 3; }
.f6 i:nth-child(odd) { grid-column: 1; } .f6 i:nth-child(even) { grid-column: 3; }
.dice-shadow { width: 110px; height: 18px; border-radius: 50%; background: radial-gradient(rgba(0,0,0,.28), transparent 70%); margin: -14px auto 0; }

/* ===== Разкриване ===== */
.reveal { text-align: center; }
.tag {
  position: relative; display: inline-block; margin: .75rem auto 0; padding: 1.4rem 2rem 1.5rem;
  background: linear-gradient(180deg, #fff, var(--cream-100)); border: 3px solid var(--gold-500); border-radius: 18px;
  box-shadow: 0 16px 30px -16px rgba(0,0,0,.45);
}
.tag::before { content: ''; position: absolute; top: -14px; left: 50%; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: var(--pine-800); border: 4px solid var(--gold-500); }
.tag .to { display: block; color: var(--ink-500); font-weight: 700; }
.tag .name { display: block; font-family: 'Lobster', Georgia, serif; color: var(--berry-700); font-size: clamp(2.2rem, 9vw, 3.4rem); line-height: 1.15; word-break: break-word; }
.reveal.pop .tag { animation: pop .7s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop { from { transform: scale(.4) rotate(-8deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.confetti { position: fixed; top: -20px; z-index: 40; pointer-events: none; font-size: 22px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

.footer { text-align: center; color: var(--cream-200); font-size: .9rem; margin-top: 2rem; opacity: .85; }
.footer a { color: var(--gold-300); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

.tree { display: block; margin: .5rem auto 1rem; width: 120px; height: auto; }

@media (max-width: 520px) {
  body { font-size: 1rem; }
  .list li { align-items: flex-start; }
  .btn.huge { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .snow, .snow::before, .snow::after { animation: none !important; }
  .dice.idle { animation: none; }
}
.actions.centered { justify-content: center; }
.spaced { margin-top: 1.5rem; }
