/* Вёрстка. Цвета, шрифты и картинки здесь не задаются: только переменные из theme.css. */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.page { max-width: var(--max-width); margin: 0 auto; padding: var(--page-pad); padding-bottom: 48px; position: relative; z-index: 1; }

/* ---------- Снег ---------- */
#snow { display: var(--snow-display); position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

/* ---------- Шапка ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--gap); }
.logo {
  width: 112px; height: 40px; border-radius: var(--radius-sm);
  background: var(--logo-url) center / 84px auto no-repeat, var(--logo-plate);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.me { font-size: var(--fs-sm); color: var(--text-muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me b { color: var(--text); font-weight: 600; }

/* ---------- Приветствие ---------- */
.hero {
  position: relative; overflow: hidden;
  min-height: var(--hero-min-height);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--hero-overlay), var(--hero-url) right center / cover no-repeat, var(--brand);
  color: var(--hero-text);
  padding: 48px 22px 22px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: flex-end;
}
.garland { display: var(--garland-display); position: absolute; top: 0; left: 0; right: 0; justify-content: space-around; padding: 0 8px; }
.garland::before { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 1px; background: var(--gold-soft); }
.garland i {
  width: 8px; height: 12px; margin-top: 4px; border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  background: var(--garland-1); box-shadow: 0 0 10px 2px var(--garland-1);
  animation: twinkle 2.4s ease-in-out infinite;
}
.garland i:nth-child(3n+2) { background: var(--garland-2); box-shadow: 0 0 10px 2px var(--garland-2); animation-delay: .8s; }
.garland i:nth-child(3n+3) { background: var(--garland-3); box-shadow: 0 0 10px 2px var(--garland-3); animation-delay: 1.6s; }
@keyframes twinkle { 50% { opacity: .35; } }

.hero__kicker { font-size: var(--fs-xs); letter-spacing: .18em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.hero__date { font-size: var(--fs-date); line-height: 1.05; font-weight: 800; margin: 6px 0 10px; letter-spacing: -.02em; }
.hero__title { font-size: var(--fs-lg); font-weight: 700; margin: 0 0 8px; }
.hero__text { color: var(--hero-muted); margin: 0; max-width: 460px; white-space: pre-line; }
.hero__facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.hero__facts span { font-size: var(--fs-sm); padding: 4px 10px; border-radius: 999px; border: 1px solid var(--gold-soft); }

/* ---------- Навигация по конкурсам ---------- */
.jump { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: var(--gap) 0 calc(var(--gap) * 1.5); }
.jump a {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 12px 6px; border-radius: var(--radius); text-decoration: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  font-size: var(--fs-xs); font-weight: 600; box-shadow: var(--shadow);
}
.jump a svg { width: 28px; height: 28px; color: var(--gold); }
.jump small { color: var(--text-muted); font-weight: 500; }

/* ---------- Блок конкурса (общая часть) ---------- */
.game {
  position: relative; overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 22px 18px 18px;
  margin-bottom: calc(var(--gap) * 1.5);
  box-shadow: var(--shadow);
  scroll-margin-top: 12px;
}
.game__head { display: flex; gap: 14px; align-items: center; }
.game__icon { width: 56px; height: 56px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--radius); }
.game__icon svg { width: 34px; height: 34px; }
.game__title { margin: 0; line-height: 1.2; }
.game__tagline { margin: 4px 0 0; font-size: var(--fs-sm); }
.game__meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 12px; font-size: var(--fs-sm); }
.game__meta span { padding: 4px 10px; border-radius: 999px; }
.game__desc { margin: 0 0 12px; }
.game h3 { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .12em; margin: 20px 0 10px; }
.rules { margin: 0; padding-left: 20px; font-size: var(--fs-sm); }
.rules li { margin-bottom: 4px; }
.empty { font-size: var(--fs-sm); margin: 0; }

.people { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; list-style: none; }
.people li { font-size: var(--fs-sm); padding: 5px 10px; border-radius: var(--radius-sm); }
.people small { opacity: .7; margin-left: 4px; }

.cta {
  display: block; width: 100%; margin-top: 20px; padding: 16px;
  font: inherit; font-weight: 700; font-size: var(--fs-md);
  border: 0; border-radius: var(--radius); cursor: pointer;
  transition: transform .1s, opacity .2s;
}
.cta:active:not(:disabled) { transform: scale(.98); }
.cta:disabled { cursor: default; opacity: .55; }
.cta.is-busy { opacity: .6; pointer-events: none; }

/* ---------- Сетка (общая часть) ---------- */
.bracket-hint { font-size: var(--fs-xs); margin: 0 0 8px; opacity: .7; }
.bracket-wrap {
  overflow-x: auto; margin: 0 -18px; padding: 4px 18px 14px;
  scrollbar-width: thin; scrollbar-color: var(--bracket-line) var(--bracket-track);
}
.bracket-wrap::-webkit-scrollbar { height: 8px; }
.bracket-wrap::-webkit-scrollbar-track { background: var(--bracket-track); border-radius: 4px; }
.bracket-wrap::-webkit-scrollbar-thumb { background: var(--bracket-line); border-radius: 4px; }
.bracket { display: flex; gap: var(--bracket-gap); width: max-content; }
.round { display: flex; flex-direction: column; width: var(--bracket-col); flex-shrink: 0; }
.round__name { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 10px; white-space: nowrap; }
.round__matches { display: flex; flex-direction: column; flex: 1; }
.pair { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: space-around; }
.match { position: relative; margin: 6px 0; border-radius: var(--radius-sm); font-size: var(--fs-sm); }

/* Соединительные линии: от матча вправо, вертикаль между парой, в следующий раунд слева */
.round:not(.round--champion) .match::after,
.round:not(.round--first) .match::before,
.champion::before {
  content: ""; position: absolute; top: 50%; width: calc(var(--bracket-gap) / 2 + 2px);
  border-top: var(--bracket-line-width) solid var(--bracket-line);
}
.round:not(.round--champion) .match::after { left: 100%; }
.round:not(.round--first) .match::before, .champion::before { right: 100%; }
.pair--two::after {
  content: ""; position: absolute; top: 25%; bottom: 25%; right: calc(var(--bracket-gap) / -2);
  border-right: var(--bracket-line-width) solid var(--bracket-line);
}
.slot { display: flex; align-items: center; gap: 6px; padding: 7px 9px; min-height: 34px; }
.slot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.slot.is-lost span { opacity: .45; text-decoration: line-through; }
.slot.is-win { font-weight: 700; }
.slot.is-bye { font-style: italic; opacity: .55; }
.champion {
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 14px 10px; border: var(--bracket-line-width) solid var(--bracket-line); border-radius: var(--radius-sm);
}
.champion:not(.is-decided) { opacity: .5; }
.champion svg { width: 44px; height: 44px; }
.champion b { font-size: var(--fs-md); overflow-wrap: anywhere; }
.bracket--empty .match { opacity: .45; }
.bracket-note { font-size: var(--fs-sm); margin: 0 0 10px; }

/* ===================== Mortal Kombat ===================== */
.game--mortal_kombat { background: var(--mk-scanlines), var(--mk-bg); color: var(--mk-text); font-family: var(--mk-font); border: 3px solid var(--mk-border); border-radius: var(--radius-sm); image-rendering: pixelated; }
.game--mortal_kombat { --bracket-line: var(--mk-bracket-line); --bracket-track: var(--mk-bracket-track); }
.game--mortal_kombat .game__icon { background: var(--mk-card); color: var(--mk-accent); border: 2px solid var(--mk-accent); border-radius: 0; }
.game--mortal_kombat .game__title { font-family: var(--mk-font-title); font-size: 17px; line-height: 1.5; color: var(--mk-accent); text-shadow: 3px 3px 0 var(--mk-accent-2), 0 0 18px var(--mk-accent-2); text-transform: uppercase; }
.game--mortal_kombat .game__tagline, .game--mortal_kombat .empty, .game--mortal_kombat .bracket-note { color: var(--mk-muted); }
.game--mortal_kombat .game__meta span { background: var(--mk-card); border: 1px solid var(--mk-accent-2); border-radius: 0; }
.game--mortal_kombat h3, .game--mortal_kombat .round__name { font-family: var(--mk-font-title); font-size: 9px; color: var(--mk-accent); letter-spacing: .05em; }
.game--mortal_kombat .people li { background: var(--mk-card); border: 1px solid var(--mk-muted); border-radius: 0; }
.game--mortal_kombat .match { background: var(--mk-card); border: 2px solid var(--mk-accent-2); border-radius: 0; }
.game--mortal_kombat .slot + .slot { border-top: 1px dashed var(--mk-accent-2); }
.game--mortal_kombat .slot.is-win { color: var(--mk-win); }
.game--mortal_kombat .slot.is-win::after { content: "WINS"; font-family: var(--mk-font-title); font-size: 7px; color: var(--mk-accent-2); }
.game--mortal_kombat .champion { color: var(--mk-win); font-family: var(--mk-font-title); font-size: 9px; }
.game--mortal_kombat .champion b { font-size: 11px; line-height: 1.6; text-shadow: 2px 2px 0 var(--mk-accent-2); }
.game--mortal_kombat .cta { font-family: var(--mk-font-title); font-size: 12px; background: var(--mk-accent); color: var(--mk-cta-text); border-radius: 0; box-shadow: 4px 4px 0 var(--mk-accent-2); text-transform: uppercase; line-height: 1.6; }
.game--mortal_kombat .cta.is-joined { background: transparent; color: var(--mk-accent); border: 2px solid var(--mk-accent); box-shadow: none; }

/* ===================== Настольный футбол ===================== */
.game--foosball { background: var(--fb-bg); color: var(--fb-text); font-family: var(--fb-font); border: 4px solid var(--fb-line); }
.game--foosball::before { /* центральный круг и линия поля */
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--fb-line); opacity: .35; pointer-events: none;
}
.game--foosball::after {
  content: ""; position: absolute; left: 50%; top: 120px; width: 140px; height: 140px; margin-left: -70px; border: 2px solid var(--fb-line); border-radius: 50%; opacity: .35; pointer-events: none;
}
.game--foosball > * { position: relative; z-index: 1; }
.game--foosball { --bracket-line: var(--fb-bracket-line); --bracket-track: var(--fb-bracket-track); }
.game--foosball .game__icon { background: var(--fb-card); color: var(--fb-text); border: 2px solid var(--fb-line); border-radius: 50%; }
.game--foosball .game__title { font-family: var(--fb-font-title); font-size: 26px; text-transform: uppercase; letter-spacing: .02em; }
.game--foosball .game__tagline, .game--foosball .empty, .game--foosball .bracket-note { color: var(--fb-muted); }
.game--foosball .game__meta span { background: var(--fb-card); border: 1px solid var(--fb-line); }
.game--foosball h3, .game--foosball .round__name { font-family: var(--fb-font-title); color: var(--fb-text); font-weight: 400; }
.game--foosball .people li { background: var(--fb-card); border: 1px solid var(--fb-line); }
.game--foosball .match { background: var(--fb-card); border: 1px solid var(--fb-line); }
.game--foosball .slot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.game--foosball .slot:first-child::before { background: var(--fb-red); }
.game--foosball .slot:last-child::before { background: var(--fb-blue); }
.game--foosball .slot + .slot { border-top: 1px solid var(--fb-line); }
.game--foosball .slot.is-win { color: var(--fb-win); }
.game--foosball .champion { color: var(--fb-win); font-family: var(--fb-font-title); }
.game--foosball .cta { font-family: var(--fb-font-title); font-weight: 400; text-transform: uppercase; letter-spacing: .04em; background: var(--fb-text); color: var(--fb-red); }
.game--foosball .cta.is-joined { background: transparent; color: var(--fb-text); border: 2px solid var(--fb-line); }

/* ===================== Мафия ===================== */
.game--mafia { background: var(--mf-bg); color: var(--mf-text); font-family: var(--mf-font); border: 1px solid var(--mf-border); }
.game--mafia .game__icon { background: var(--mf-card); color: var(--mf-text); border: 1px solid var(--mf-border); border-radius: 50%; }
.game--mafia .game__title { font-family: var(--mf-font-title); font-weight: 800; font-size: 34px; font-style: italic; letter-spacing: .01em; }
.game--mafia .game__title::after { content: ""; display: block; width: 48px; height: 3px; background: var(--mf-accent); margin-top: 6px; }
.game--mafia .game__tagline, .game--mafia .empty { color: var(--mf-muted); }
.game--mafia .game__meta span { border: 1px solid var(--mf-border); }
.game--mafia h3 { font-family: var(--mf-font-title); font-style: italic; text-transform: none; letter-spacing: 0; font-size: var(--fs-lg); }
.seats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; list-style: none; padding: 0; margin: 0; counter-reset: seat; }
.seats li {
  counter-increment: seat; display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 10px; background: var(--mf-card); border: 1px solid var(--mf-border); border-radius: var(--radius-sm); font-size: var(--fs-sm);
}
.seats li::before { content: counter(seat); font-family: var(--mf-font-title); font-style: italic; font-size: var(--fs-lg); color: var(--mf-accent); width: 22px; text-align: center; flex-shrink: 0; }
.seats li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seats li.is-free { color: var(--mf-muted); border-style: dashed; }
.game--mafia .cta { background: var(--mf-accent); color: var(--mf-text); font-family: var(--mf-font-title); font-size: var(--fs-lg); font-style: italic; }
.game--mafia .cta.is-joined { background: transparent; border: 1px solid var(--mf-border); }

/* ---------- Уведомление ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: var(--fs-sm); z-index: 10; transition: .25s; pointer-events: none;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: var(--danger); }

.loading { text-align: center; color: var(--text-muted); padding: 60px 0; }

@media (min-width: 560px) {
  .hero { padding: 60px 36px 32px; }
  .game { padding: 28px 26px 24px; }
  .bracket-wrap { margin: 0 -26px; padding: 4px 26px 14px; }
  .seats { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .garland i { animation: none; }
}
