/*
 * Тайный Санта — «Почта Деда Мороза».
 * Анонимный подарок как посылка: бирки на шпагате, марки, штемпель, сургуч, письмо.
 * Из Telegram берём только схему (data-scheme), цвета свои. Бумажные предметы
 * (бирки, марки, конверт, письмо) остаются светлыми и в тёмной схеме.
 */

@font-face {
  font-family: "Golos Text";
  src: url("fonts/golos-cyrillic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Golos Text";
  src: url("fonts/golos-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Caveat";
  src: url("fonts/caveat-cyrillic.woff2") format("woff2");
  font-weight: 500 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Caveat";
  src: url("fonts/caveat-latin.woff2") format("woff2");
  font-weight: 500 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- Цвета --- */

:root {
  /* Светлая: почтовое отделение днём — крафт, синие чернила, сургуч. */
  --page: #ece3d2;
  --sheet: #fbf7ee;
  --ink: #1d2840;
  --hint: #5c6274;
  --rule: rgba(29, 40, 64, 0.14);
  --rule-strong: rgba(29, 40, 64, 0.32);
  --wax: #a8232e;
  --wax-ink: #fff5ea;
  --wax-text: #a8232e;
  --pine: #2d5e4c;
  --amber: #94590f;
  --chip: #efe6d5;
  --field: #fffdf8;
  --postmark: rgba(29, 40, 64, 0.6);
  --twine: #9c7a48;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.25 0 0 0 0 0.12 0 0 0 0.1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23n%29'/%3E%3C/svg%3E");

  /* Бумага предметов — одинаковая в обеих схемах. */
  --kraft: #d9c19a;
  --kraft-deep: #c4a87b;
  --kraft-flap: #cdb388;
  --cream: #f7efe0;
  --letter: #fffaf0;
  --paper-ink: #1d2840;
  --paper-hint: #555b6c;
  --stamp-edge: #fbf7ee;

  /* Для главной кнопки Telegram и шапки (читает app.js). */
  --button: var(--wax);
  --button-text: var(--wax-ink);

  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --hand: "Caveat", "Segoe Print", cursive;

  color-scheme: light;
}

/* Тёмная: та же почта ночью — чернильная синева, свет лампы на бумаге. */
html[data-scheme="dark"] {
  --page: #0f1626;
  --sheet: #182238;
  --ink: #ece3d2;
  --hint: #a4adc0;
  --rule: rgba(236, 227, 210, 0.12);
  --rule-strong: rgba(236, 227, 210, 0.3);
  --wax: #c23b46;
  --wax-text: #f29099;
  --pine: #7cc4a2;
  --amber: #e3b061;
  --chip: #222e49;
  --field: #121b2f;
  --postmark: rgba(236, 227, 210, 0.5);
  --twine: #c9a46b;
  --stamp-edge: #efe6d4;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url%28%23n%29'/%3E%3C/svg%3E");

  color-scheme: dark;
}

/* Бумажный предмет: свои чернила независимо от схемы. */
.tag,
.ward-card,
.stamp {
  --ink: var(--paper-ink);
  --hint: var(--paper-hint);
  --rule: rgba(29, 40, 64, 0.16);
  --pine: #2d5e4c;
  --amber: #94590f;
  --wax-text: #a8232e;
}

/* --- База --- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: var(--tg-viewport-stable-height, 100vh);
  background-color: var(--page);
  background-image: var(--noise);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--wax);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Полоса авиапочты сверху: клюква и хвоя вместо красного и синего. */
.airmail {
  height: 7px;
  background: repeating-linear-gradient(-45deg, var(--wax) 0 12px, transparent 12px 20px, var(--pine) 20px 32px, transparent 32px 40px);
  opacity: 0.85;
}

/* --- Каркас --- */

.app {
  max-width: 600px;
  margin: 0 auto;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.hint {
  color: var(--hint);
  font-size: 0.9rem;
}

.center {
  text-align: center;
}

.back-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 0;
  background: none;
  color: var(--ink);
  padding: 4px 0;
  font-weight: 500;
  cursor: pointer;
}

.back-link .icon {
  width: 18px;
  height: 18px;
}

/* Подпись-графа как на почтовом бланке. */
.kicker,
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.kicker {
  color: var(--wax-text);
  margin-bottom: 6px;
}

.section-title {
  color: var(--hint);
  margin-bottom: 12px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule-strong);
}

/* Лист бумаги: почти без скругления, с тонкой кромкой и мягкой тенью снизу. */
.section {
  background: var(--sheet);
  border-radius: 3px;
  padding: 16px;
  box-shadow: 0 0 0 1px var(--rule), 0 14px 22px -20px rgba(15, 20, 40, 0.55);
}

/* --- Шапка: марка с Сёмой и штемпель --- */

.post-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
  padding-top: 4px;
}

.post-head-sub {
  margin-top: 8px;
  color: var(--hint);
  font-size: 0.93rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.franking {
  position: relative;
  width: 118px;
  height: 108px;
}

.franking .stamp {
  position: absolute;
  top: 0;
  right: 4px;
  transform: rotate(4deg);
}

.postmark {
  position: absolute;
  left: -34px;
  bottom: -2px;
  width: 128px;
  height: auto;
  color: var(--postmark);
  transform: rotate(-9deg);
  pointer-events: none;
}

.postmark circle,
.postmark-wave {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.postmark text {
  fill: currentColor;
  font-family: var(--font);
}

.postmark-ring {
  font-size: 7.4px;
  font-weight: 700;
  letter-spacing: 1.4px;
}

.postmark-day {
  font-size: 21px;
  font-weight: 700;
}

.postmark-month {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

/* --- Марка --- */

/* Зубцы: полукруглые выемки по краю, центры отверстий ровно на кромке. */
.stamp {
  display: inline-block;
  padding: 6px;
  background: radial-gradient(circle, transparent 2.6px, var(--stamp-edge) 3px) -4.5px -4.5px / 9px 9px;
  filter: drop-shadow(0 1px 1.5px rgba(15, 20, 40, 0.25));
  line-height: 1;
}

.stamp-face {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  outline: 1px solid rgba(255, 255, 255, 0.45);
  outline-offset: -4px;
}

.stamp-picture .stamp-face {
  width: 76px;
  height: 88px;
  background: #f1e2c2;
  outline-color: rgba(29, 40, 64, 0.25);
}

.stamp-sema {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
}

.stamp-large .stamp-face {
  width: 140px;
  height: 162px;
}

.sema {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* --- Бирки (список команд) --- */

.team-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0 0 0 10px;
  display: grid;
  gap: 14px;
}

.team-list li {
  position: relative;
  filter: drop-shadow(0 6px 8px rgba(15, 20, 40, 0.18));
}

/* Шпагат уходит из люверса за край экрана. */
.team-list li::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: -12px;
  top: calc(50% - 8px);
  width: 46px;
  height: 2px;
  border-radius: 2px;
  background: var(--twine);
  transform: rotate(18deg);
  transform-origin: right center;
}

.tag {
  position: relative;
  width: 100%;
  display: flex;
  text-align: left;
  border: 0;
  padding: 14px 16px 14px 46px;
  background: var(--kraft);
  color: var(--ink);
  clip-path: polygon(22px 0, 100% 0, 100% 100%, 22px 100%, 0 50%);
  cursor: pointer;
}

.team-list li:nth-child(even) .tag {
  background: var(--cream);
}

.tag:active {
  transform: translateX(2px);
}

.tag-eyelet {
  position: absolute;
  left: 20px;
  top: calc(50% - 7px);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--page);
  box-shadow: 0 0 0 3px #b39a6d, inset 0 1px 2px rgba(0, 0, 0, 0.35);
}

.tag-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tag-title {
  font-family: var(--hand);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  overflow-wrap: anywhere;
}

.tag-date {
  color: var(--hint);
  font-size: 0.85rem;
}

.tag-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 4px;
}

.tag-role {
  color: var(--hint);
  font-size: 0.8rem;
}

/* --- Штамп статуса --- */

.mark {
  display: inline-block;
  padding: 2px 8px 1px;
  border: 2px solid currentColor;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(-3deg);
  opacity: 0.9;
}

.mark-open {
  color: var(--pine);
}

.mark-closed {
  color: var(--amber);
}

.mark-drawn {
  color: var(--wax-text);
}

/* --- Карточка: марки обратного отсчёта --- */

.countdown-block .section-title {
  margin-bottom: 14px;
}

.countdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stamp-count {
  display: block;
}

.stamp-count .stamp-face {
  aspect-ratio: 4 / 4.6;
  align-content: center;
  gap: 4px;
  color: #fff5ea;
  outline-color: rgba(255, 245, 234, 0.45);
}

.stamp-count-1 {
  transform: rotate(-2deg);
}

.stamp-count-1 .stamp-face {
  background: #a8232e;
}

.stamp-count-2 {
  transform: rotate(1.5deg) translateY(3px);
}

.stamp-count-2 .stamp-face {
  background: #2d5e4c;
}

.stamp-count-3 {
  transform: rotate(-1deg);
}

.stamp-count-3 .stamp-face {
  background: #2a3d68;
}

.stamp-motif {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 18px;
  height: 18px;
  opacity: 0.45;
}

.countdown-num {
  font-size: 2.3rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.countdown-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.countdown-done {
  grid-column: 1 / -1;
  font-family: var(--hand);
  font-size: 2rem;
  font-weight: 700;
  color: var(--wax-text);
  text-align: center;
}

.countdown-date {
  margin-top: 12px;
  color: var(--hint);
  font-size: 0.88rem;
  text-align: center;
}

/* Накладная: подпись, точечная линия, значение. */
.facts {
  margin: 0;
  display: grid;
  gap: 10px;
}

.facts > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.facts dt {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: 8px;
  color: var(--hint);
  font-size: 0.92rem;
}

.facts dt::after {
  content: "";
  flex: 1;
  border-bottom: 1.5px dotted var(--rule-strong);
  transform: translateY(-3px);
}

.facts dd {
  margin: 0;
  text-align: right;
  font-weight: 500;
}

.facts dd.is-done {
  color: var(--pine);
}

.facts dd.is-pending {
  color: var(--amber);
}

/* --- Действия --- */

.actions {
  display: flex;
  flex-direction: column;
}

.action {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px dashed var(--rule-strong);
  background: none;
  text-align: left;
  cursor: pointer;
}

.action:last-child {
  border-bottom: 0;
}

.action:disabled {
  opacity: 0.5;
}

.action-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--chip);
  color: var(--ink);
}

.action-icon .icon {
  width: 20px;
  height: 20px;
}

.action-label {
  flex: 1;
  font-weight: 500;
}

.action-chevron {
  width: 18px;
  height: 18px;
  color: var(--hint);
}

/* Главное действие — сургучная печать. */
.action-festive .action-icon {
  background: radial-gradient(circle at 38% 35%, #d9535c, var(--wax) 62%, #7d1620);
  color: #fff5ea;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.12);
}

.action-festive .action-label {
  color: var(--wax-text);
  font-weight: 700;
}

/* --- Кнопки и сообщения --- */

.btn {
  border: 0;
  border-radius: 8px;
  padding: 12px 20px;
  font-weight: 600;
  min-height: 46px;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: var(--wax);
  color: var(--wax-ink);
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--rule-strong);
}

.notice {
  background: var(--sheet);
  border-left: 3px solid var(--pine);
  border-radius: 0 3px 3px 0;
  padding: 10px 14px;
  font-size: 0.93rem;
  overflow-wrap: anywhere;
  box-shadow: 0 0 0 1px var(--rule);
}

.notice-warning {
  border-left-color: var(--amber);
}

.notice-error {
  border-left-color: var(--wax);
}

.result-slot:empty {
  display: none;
}

/* --- Пустые состояния: открытка с маркой --- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 28px 8px;
}

.empty .stamp {
  transform: rotate(-3deg);
  margin-bottom: 10px;
}

.empty .hint {
  max-width: 26em;
}

.empty .btn {
  margin-top: 8px;
}

/* --- Анкета: бланк и разлинованный лист --- */

.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label,
.choice legend {
  font-weight: 600;
}

input[type="text"],
textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--field);
  border: 0;
  border-bottom: 1.5px solid var(--rule-strong);
  border-radius: 0;
  padding: 10px 4px;
}

textarea {
  resize: vertical;
  min-height: 150px;
  padding: 4px 10px;
  line-height: 28px;
  border: 1px solid var(--rule);
  border-left: 2px solid var(--wax);
  background: var(--field) repeating-linear-gradient(transparent 0 27px, var(--rule) 27px 28px) local;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-bottom-color: var(--wax);
}

[aria-invalid="true"] {
  border-bottom-color: var(--wax) !important;
}

.field-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 1.2em;
}

.field-error {
  color: var(--wax-text);
  font-size: 0.85rem;
}

.counter {
  margin-left: auto;
  white-space: nowrap;
  color: var(--hint);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.choice {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice legend {
  padding: 0;
  margin-bottom: 8px;
}

.choice-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px var(--rule-strong);
  cursor: pointer;
}

.choice-option:has(input:checked) {
  box-shadow: inset 0 0 0 2px var(--wax);
}

.choice-option input {
  accent-color: var(--wax);
  width: 18px;
  height: 18px;
  margin: 0;
}

/* --- Вскрытие: конверт с сургучом --- */

.reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.stage {
  width: 100%;
  display: grid;
  place-items: center;
  min-height: 220px;
}

.envelope {
  position: relative;
  width: min(300px, 100%);
  aspect-ratio: 5 / 3.2;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
  filter: drop-shadow(0 14px 16px rgba(15, 20, 40, 0.28));
}

.envelope:focus-visible {
  outline-offset: 8px;
}

.env-back,
.env-pocket {
  position: absolute;
  inset: 0;
  border-radius: 4px;
}

.env-back {
  background: var(--kraft-deep);
}

.env-letter {
  position: absolute;
  z-index: 1;
  left: 7%;
  right: 7%;
  top: 7%;
  height: 86%;
  display: flex;
  flex-direction: column;
  gap: 12%;
  padding: 16% 12% 0;
  background: var(--letter);
  border-radius: 2px;
  transition: transform 0.6s 0.65s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.env-letter span {
  height: 3px;
  border-radius: 2px;
  background: rgba(29, 40, 64, 0.2);
}

.env-letter span:last-child {
  width: 55%;
}

.env-pocket {
  z-index: 2;
  background:
    linear-gradient(to top right, transparent calc(50% - 1px), rgba(0, 0, 0, 0.1) 50%, transparent calc(50% + 1px)),
    linear-gradient(to top left, transparent calc(50% - 1px), rgba(0, 0, 0, 0.1) 50%, transparent calc(50% + 1px)),
    var(--kraft);
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
}

.env-flap {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  top: 0;
  height: 60%;
  background: var(--kraft-flap);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.5s 0.25s ease-in-out, z-index 0s 0.5s;
}

.seal {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 60%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  display: grid;
  place-items: center;
  border-radius: 47% 53% 50% 50% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 38% 34%, #dc5a63, #a8232e 58%, #73131c);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35), inset 0 0 0 5px rgba(0, 0, 0, 0.12), inset 0 0 0 7px rgba(255, 255, 255, 0.08);
  color: rgba(70, 6, 12, 0.6);
  transition: transform 0.15s;
}

.seal .icon {
  width: 26px;
  height: 26px;
  fill: currentColor;
  stroke: none;
}

.envelope:active .seal {
  transform: scale(0.94);
}

.envelope.is-opening .seal {
  animation: seal-off 0.35s ease-in forwards;
}

.envelope.is-opening .env-flap {
  transform: rotateX(180deg);
  z-index: 0;
}

.envelope.is-opening .env-letter {
  transform: translateY(-58%);
}

@keyframes seal-off {
  to {
    transform: scale(1.3) rotate(-24deg);
    opacity: 0;
  }
}

/* Письмо с именем подопечного. */
.ward-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 20px 20px;
  background: var(--letter) repeating-linear-gradient(transparent 0 31px, rgba(29, 40, 64, 0.06) 31px 32px);
  color: var(--ink);
  border-radius: 2px;
  box-shadow: 0 1px 0 rgba(29, 40, 64, 0.1), 0 18px 26px -18px rgba(15, 20, 40, 0.55);
  transform: rotate(-0.6deg);
}

.ward-card:focus {
  outline: none;
}

.ward-card.is-shown {
  animation: letter-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.ward-kicker {
  color: var(--hint);
  font-size: 0.85rem;
  padding-right: 80px;
}

.ward-name {
  font-family: var(--hand);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1;
  color: var(--wax-text);
  padding-right: 72px;
  overflow-wrap: anywhere;
}

.ward-label {
  margin-top: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hint);
}

.ward-wishes {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 32px;
}

.ward-santa-choice {
  font-family: var(--hand);
  font-size: 1.6rem;
  font-weight: 600;
}

.ward-secret {
  margin-top: 8px;
  color: var(--hint);
  font-size: 0.85rem;
  font-style: italic;
}

.ward-stamp {
  position: absolute;
  top: 14px;
  right: 14px;
  transform: rotate(6deg);
}

.ward-stamp .stamp-face {
  width: 58px;
  height: 68px;
}

@keyframes letter-in {
  from {
    opacity: 0;
    transform: translateY(24px) rotate(-3deg);
  }
  to {
    opacity: 1;
    transform: rotate(-0.6deg);
  }
}

/* --- Снежки --- */

.targets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.target {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.target .icon {
  width: 18px;
  height: 18px;
  color: var(--pine);
}

.target span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 500;
  line-height: 1.2;
}

.target:disabled {
  opacity: 0.5;
  cursor: default;
}

.target.is-aiming {
  box-shadow: inset 0 0 0 2px var(--wax);
}

.throw-result {
  margin-top: 12px;
}

.throw-result:empty {
  display: none;
}

.throw-stage {
  position: relative;
  height: 56px;
  overflow: hidden;
}

.snowball {
  position: absolute;
  left: 0;
  bottom: 4px;
  width: 100%;
  height: 22px;
  opacity: 0;
}

.snowball::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff, #e4ebf3 70%, #b9c7d8);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.snowball-hit {
  animation: throw-hit 0.6s ease-out forwards;
}

.snowball-miss {
  animation: throw-miss 0.7s ease-in forwards;
}

.throw-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  animation: fade-up 0.35s 0.5s both;
}

.throw-text strong {
  font-family: var(--hand);
  font-size: 2.2rem;
  line-height: 1;
}

.throw-text.is-hit strong {
  color: var(--pine);
}

.throw-text.is-miss strong {
  color: var(--hint);
}

.throw-text b {
  overflow-wrap: anywhere;
}

@keyframes throw-hit {
  0% { transform: translate(0, 0); opacity: 1; }
  50% { transform: translate(38%, -28px); opacity: 1; }
  85% { transform: translate(calc(80% - 11px), 0); opacity: 1; }
  100% { transform: translate(calc(80% - 11px), 0) scale(1.4); opacity: 0; }
}

@keyframes throw-miss {
  0% { transform: translate(0, 0); opacity: 1; }
  50% { transform: translate(45%, -30px); opacity: 1; }
  100% { transform: translate(100%, -40px); opacity: 0; }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Таблица меткости — ведомость. */
.board {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
  font-variant-numeric: tabular-nums;
}

.board th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hint);
  padding: 0 6px 8px;
  border-bottom: 1.5px solid var(--rule-strong);
}

.board td {
  padding: 9px 6px;
  border-bottom: 1px dotted var(--rule-strong);
}

.board tr:last-child td {
  border-bottom: 0;
}

.board-rank {
  width: 2em;
  color: var(--hint);
  font-weight: 600;
}

.board-rank.is-top {
  color: var(--wax-text);
  font-weight: 700;
}

.board-name {
  overflow-wrap: anywhere;
  font-weight: 500;
}

/* --- Участники --- */

.members {
  list-style: none;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.member {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px dotted var(--rule-strong);
}

.member:last-child {
  border-bottom: 0;
}

.member-name {
  overflow-wrap: anywhere;
  font-weight: 500;
}

.member-status {
  flex: none;
  font-size: 0.8rem;
  font-weight: 600;
}

.member-status.is-ready {
  color: var(--pine);
}

.member-status.is-pending {
  color: var(--amber);
}

/* --- Жеребьёвка и распределение --- */

.draw-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.draw-count {
  font-size: 1.2rem;
  font-weight: 700;
}

.circle-wrap {
  margin: 0;
  background: var(--sheet);
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--rule), 0 14px 22px -20px rgba(15, 20, 40, 0.55);
  padding: 8px 8px 16px;
}

.circle {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: 0 auto;
  overflow: visible;
}

.circle-ring {
  fill: none;
  stroke: var(--rule-strong);
  stroke-width: 1.5;
  stroke-dasharray: 2 7;
  stroke-linecap: round;
}

.node {
  stroke: var(--sheet);
  stroke-width: 3;
}

.node-red {
  fill: var(--wax);
}

.node-green {
  fill: var(--pine);
}

.label {
  fill: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
}

.label-small {
  font-size: 13px;
}

.arrow-line {
  fill: none;
  stroke: var(--wax-text);
  stroke-width: 2;
  stroke-linecap: round;
}

.arrow-head {
  fill: var(--wax-text);
}

.is-animated .arrow-line {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  animation: draw-line 0.45s ease-out forwards;
  animation-delay: calc(var(--i) * 0.5s + 0.3s);
}

.is-animated .arrow-head {
  opacity: 0;
  animation: fade-in 0.15s forwards;
  animation-delay: calc(var(--i) * 0.5s + 0.7s);
}

.is-animated .node,
.is-animated .label {
  animation: fade-in 0.4s both;
}

@keyframes draw-line {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.pairs {
  margin: 12px 0 0;
  padding: 0 8px 0 2.2em;
  display: grid;
  gap: 6px;
  font-size: 0.93rem;
}

.pairs li {
  overflow-wrap: anywhere;
}

.pairs-arrow {
  color: var(--wax-text);
}

.confirm-inline,
.confirm-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.delivery {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.delivery-count {
  font-size: 1.15rem;
  font-weight: 700;
}

.undelivered {
  margin: 4px 0;
  padding-left: 1.2em;
}

.undelivered li {
  overflow-wrap: anywhere;
}

.after-arrows {
  animation: fade-in 0.4s both;
  animation-delay: calc(var(--arrows) * 0.5s + 0.6s);
}

/* --- Подтверждение без Telegram --- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: end center;
  background: rgba(10, 14, 26, 0.45);
  padding: 16px;
}

.sheet-body {
  width: 100%;
  max-width: 420px;
  background: var(--sheet);
  border-radius: 6px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* --- Ширина --- */

@media (max-width: 360px) {
  .franking {
    width: 96px;
    transform: scale(0.85);
    transform-origin: top right;
  }

  .countdown-num {
    font-size: 1.9rem;
  }
}

@media (min-width: 720px) {
  .app {
    padding-top: 28px;
  }

  .team-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Без анимаций --- */

@media (prefers-reduced-motion: reduce) {
  .ward-card.is-shown,
  .throw-text,
  .after-arrows,
  .is-animated .arrow-line,
  .is-animated .arrow-head,
  .is-animated .node,
  .is-animated .label {
    animation: none;
  }

  .is-animated .arrow-line {
    stroke-dashoffset: 0;
  }

  .is-animated .arrow-head {
    opacity: 1;
  }

  .env-letter,
  .env-flap,
  .seal {
    transition: none;
  }

  .snowball {
    display: none;
  }
}
