/* Тайный Санта - mobile-first styles */

:root {
  --night: #12203a;
  --night-2: #1d3157;
  --paper: #fffaf0;
  --ink: #2a2420;
  --muted: #7a6f66;
  --red: #c0262d;
  --red-dark: #8f1a20;
  --green: #1f6b45;
  --gold: #e3a92b;
  --gold-dark: #b9811a;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
html { background-color: var(--night); }
body {
  min-height: 100vh;
  background-color: var(--night);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  /* not "fixed": iOS Safari ignores fixed backgrounds */
  background-image: radial-gradient(ellipse 120% 600px at top, var(--night-2), var(--night));
  background-repeat: no-repeat;
  -webkit-tap-highlight-color: transparent;
}

/* ----- snow */
.snow { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.flake {
  position: absolute; top: -2em; color: #fff; opacity: .7;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translate3d(var(--drift, 20px), 110vh, 0) rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) { .flake { display: none; } }

/* ----- layout */
.top { position: relative; z-index: 1; text-align: center; padding: 22px 16px 8px; }
.logo {
  color: #fff; text-decoration: none; font-weight: 800; font-size: 26px;
  letter-spacing: .3px; text-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.wrap { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: 8px 14px 40px; }

.panel {
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 18px; margin: 14px 0;
}
.center { text-align: center; }
h1 { font-size: 24px; margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 19px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
.lead { margin: 0 0 14px; color: #4a413a; }
.muted { color: var(--muted); margin: 6px 0; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 14px; }
.big-emoji { font-size: 48px; line-height: 1; margin-bottom: 8px; }
.ok-text { color: var(--green); font-weight: 700; }
.error-text { color: var(--red); font-weight: 600; }
.link { color: #fff; opacity: .85; }

.hello {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  color: #fff; padding: 4px 4px 0;
}
.hello form { margin: 0; }
.link-btn {
  background: none; border: 1px solid rgba(255, 255, 255, .45); color: #fff;
  border-radius: 999px; padding: 6px 14px; font-size: 14px; cursor: pointer;
}

/* ----- flash */
.flash { border-radius: 12px; padding: 12px 14px; margin: 10px 0; font-weight: 600; box-shadow: var(--shadow); }
.flash-error { background: #ffe3e1; color: var(--red-dark); }
.flash-ok { background: #e2f5e9; color: var(--green); }

/* ----- forms */
.form { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; }
input, select {
  font: inherit; font-size: 17px; width: 100%;
  padding: 13px 14px; border: 2px solid #e5d9c6; border-radius: 12px; background: #fff; color: var(--ink);
  appearance: none; -webkit-appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px;
}
input:focus, select:focus { outline: none; border-color: var(--gold); }

.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 15px 18px;
  font: inherit; font-weight: 700; font-size: 17px; cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-dark); }
.btn-gold { background: var(--gold); color: #3a2a05; box-shadow: 0 4px 0 var(--gold-dark); }
.btn-secondary { background: #efe5d4; color: var(--ink); }
.btn-danger { background: #fff; color: var(--red); border: 2px solid var(--red); }
.btn-small {
  border: 0; border-radius: 10px; padding: 8px 12px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-small.btn-danger { border: 1.5px solid var(--red); }

/* ----- tabs */
.tabs { display: flex; background: #f1e7d6; border-radius: 12px; padding: 4px; margin: 6px 0 16px; }
.tab {
  flex: 1; border: 0; background: none; padding: 10px; border-radius: 9px;
  font: inherit; font-weight: 700; color: var(--muted); cursor: pointer;
}
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); }

/* ----- player chips */
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { background: #f3e9d8; border-radius: 999px; padding: 6px 12px; font-size: 15px; }

/* ----- cards */
.cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin: 18px 0 4px; perspective: 900px;
}
@media (min-width: 420px) { .cards { grid-template-columns: repeat(4, 1fr); } }
.card {
  position: relative; aspect-ratio: 3 / 4; border: 0; padding: 0; border-radius: 14px; cursor: pointer;
  background: none; animation: deal .5s cubic-bezier(.2, .8, .3, 1.2) backwards;
  transition: opacity .35s ease, transform .35s ease;
}
.card-back {
  position: absolute; inset: 0; border-radius: 14px; display: grid; place-items: center;
  font-size: 30px; color: rgba(255, 255, 255, .9);
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .18) 0 22%, transparent 23%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .08) 0 6px, transparent 6px 12px),
    linear-gradient(160deg, var(--red), var(--red-dark));
  border: 3px solid var(--gold); box-shadow: 0 6px 14px rgba(0, 0, 0, .25);
}
.card:active .card-back { transform: scale(.96); }
.card.fade-out { opacity: 0; transform: scale(.7) rotate(-6deg); pointer-events: none; }
.card.chosen { transform: scale(1.08); z-index: 2; }
.card.vanish { opacity: 0; transform: translateY(-20px) scale(.5); }
@keyframes deal {
  from { opacity: 0; transform: translateY(-40px) rotate(-12deg) scale(.6); }
}

/* ----- big result card */
.result { width: min(78vw, 300px); aspect-ratio: 3 / 4; margin: 6px auto 16px; perspective: 1200px; }
.result-inner {
  position: relative; width: 100%; height: 100%; transform-style: preserve-3d;
  transition: transform 1s cubic-bezier(.3, .7, .3, 1);
}
.result.flipped .result-inner { transform: rotateY(180deg); }
.result-face {
  position: absolute; inset: 0; border-radius: 20px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .3);
}
.result-back {
  font-size: 64px; color: rgba(255, 255, 255, .9); border: 4px solid var(--gold);
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .18) 0 22%, transparent 23%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .08) 0 8px, transparent 8px 16px),
    linear-gradient(160deg, var(--red), var(--red-dark));
}
.result-front {
  transform: rotateY(180deg); background: linear-gradient(170deg, #fffdf6, #f7ecd6);
  border: 4px solid var(--gold); gap: 10px;
}
.result-label { font-size: 15px; color: var(--muted); }
.result-name {
  font-size: clamp(26px, 9vw, 38px); font-weight: 800; color: var(--red);
  line-height: 1.15; word-break: break-word;
}
.result-gift { font-size: 44px; }
.result-hint { margin-top: 4px; }

/* ----- reveal */
.reveal h2 { margin-bottom: 6px; }
.progress { margin: 12px 0 0; color: var(--muted); }
.reveal-table table { width: 100%; border-collapse: collapse; font-size: 16px; }
.reveal-table th { text-align: left; color: var(--muted); font-size: 13px; font-weight: 600; padding: 4px 6px; }
.reveal-table td { padding: 10px 6px; border-top: 1px solid #efe3cf; }
.reveal-table .arrow { color: var(--gold-dark); text-align: center; width: 24px; }
.reveal-table tr.me td { background: #fff2cf; font-weight: 700; }

/* ----- admin */
.phase { display: flex; gap: 8px; }
.phase-step {
  flex: 1; text-align: center; padding: 10px 6px; border-radius: 12px;
  background: #f1e7d6; color: var(--muted); font-weight: 700; font-size: 15px;
}
.phase-step.current { background: var(--green); color: #fff; }
.admin-list { list-style: none; padding: 0; margin: 0; }
.admin-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-top: 1px solid #efe3cf;
}
.admin-list li:first-child { border-top: 0; }
.admin-list form { margin: 0; }
.admin-name { font-weight: 600; word-break: break-word; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: 12px; padding: 4px 8px; border-radius: 999px; background: #f1e7d6; color: var(--muted); white-space: nowrap; }
.badge.on { background: #e2f5e9; color: var(--green); font-weight: 700; }
.modes { display: flex; flex-direction: column; gap: 10px; }
.mode {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 2px solid #eadfcc;
  border-radius: 14px; cursor: pointer;
}
.mode:has(input:checked) { border-color: var(--green); background: #f0faf3; }
.mode input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; appearance: auto; -webkit-appearance: radio; accent-color: var(--green); padding: 0; }
.mode small { color: var(--muted); }
.exclusion-form { margin-top: 12px; }
.pair { display: flex; align-items: center; gap: 8px; }
.pair select { flex: 1; min-width: 0; }
