:root {
  --bg: #0e1621;
  --surface: #17212b;
  --card: #1f2c3a;
  --card-border: #2b3a4a;
  --text: #ffffff;
  --secondary: #8b9aab;
  --accent: #4da3e0;
  --accent-btn: #2b7bb9;
  --green: #4dcd5e;
  --red: #ff5b5b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--secondary); }

.screen {
  height: 100dvh;
  display: flex; flex-direction: column;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom));
}
.screen[hidden] { display: none; }
.screen.center { align-items: center; justify-content: center; }

.logo { width: 140px; height: 140px; }
.hero { text-align: center; margin: auto 0; }
.hero .logo { margin-bottom: 12px; }
.hero h1 { font-size: 26px; font-weight: 700; margin-bottom: 10px; }
.hero h2 { font-size: 24px; margin-bottom: 10px; }
.hero p { color: var(--secondary); font-size: 15px; line-height: 1.5; }
.hero.small { margin: 28px 0 24px; }
.emoji-lg { font-size: 48px; margin-bottom: 12px; }
.bottom { text-align: center; }
.bottom .hint { font-size: 12px; margin-top: 12px; }

.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 15px; border: none; border-radius: 14px;
  background: var(--accent-btn); color: #fff;
  font-size: 16px; font-weight: 600;
}
.btn:active { filter: brightness(1.15); }
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--card); color: var(--text); }

/* Знакомство */
#welcome-form label { display: block; font-size: 14px; color: var(--secondary); margin-bottom: 8px; }
#name-input {
  width: 100%; padding: 15px 16px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 14px; color: var(--text);
  font-size: 17px; outline: none; margin-bottom: 14px;
}
.form-error { color: var(--red); font-size: 14px; margin-top: 10px; text-align: center; }

/* Колода */
.deck-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 14px; }
.deck-progress { height: 4px; background: var(--card); border-radius: 2px; overflow: hidden; margin-bottom: 18px; }
.deck-progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .25s; }
.cards { position: relative; flex: 1; min-height: 0; margin-bottom: 16px; }
.wish-card {
  position: absolute; inset: 0;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 26px; text-align: center;
}
.wish-card.behind { transform: scale(.94) translateY(14px); opacity: .5; }
.wish-card.front { touch-action: none; user-select: none; will-change: transform; }
.wish-card .emoji { font-size: 52px; margin-bottom: 22px; }
.wish-card .text { font-size: 22px; font-weight: 600; line-height: 1.4; }
.stamp {
  position: absolute; top: 36px; opacity: 0;
  padding: 6px 14px; border: 3px solid; border-radius: 10px;
  font-size: 20px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
}
.stamp.like { left: 22px; color: var(--green); border-color: var(--green); transform: rotate(-14deg); }
.stamp.nope { right: 22px; color: var(--red); border-color: var(--red); transform: rotate(14deg); }
@keyframes fly-right { to { transform: translate(150%, 0) rotate(20deg); opacity: 0; } }
@keyframes fly-left { to { transform: translate(-150%, 0) rotate(-20deg); opacity: 0; } }
.wish-card.fly-right { animation: fly-right .25s ease-in forwards; }
.wish-card.fly-left { animation: fly-left .25s ease-in forwards; }

/* Нижняя панель V1: сегмент строкой, кнопки 50/50 */
.mode-switch {
  display: flex; gap: 4px; width: 100%; height: 48px;
  background: #1a2633; border: 1px solid var(--card-border);
  border-radius: 16px; padding: 4px; margin-bottom: 10px;
}
.mode-switch button {
  flex: 1 1 0; min-width: 0; padding: 0 6px; border: none; background: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 500; white-space: nowrap;
  border-radius: 12px; color: var(--secondary);
}
.mode-switch button.active {
  flex: 1.45 1 0;
  background: var(--accent-btn); color: #fff; font-weight: 600;
  box-shadow: 0 2px 10px rgba(43,123,185,.45);
}
.deck-actions { display: flex; gap: 10px; }
.vote-btn {
  flex: 1; height: 56px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; border: 1px solid;
}
.vote-btn:active { filter: brightness(1.4); }
.vote-btn.nope { background: rgba(255,91,91,.12); color: var(--red); border-color: rgba(255,91,91,.35); }
.vote-btn.like { background: rgba(77,205,94,.12); color: var(--green); border-color: rgba(77,205,94,.35); }
.deck-hint { text-align: center; color: var(--secondary); font-size: 12px; margin-top: 14px; }

/* Ожидание */
.members { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.member-row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; }
.member-row .count { color: var(--secondary); font-variant-numeric: tabular-nums; }
.member-row .done { color: var(--green); font-weight: 600; }
.member-bar { height: 4px; background: var(--card); border-radius: 2px; overflow: hidden; }
.member-bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.member-bar i.full { background: var(--green); }

/* Рандомайзер */
.approved { color: var(--green); font-weight: 700; }
@keyframes hat-shake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-12deg) translateY(-6px); }
  40% { transform: rotate(10deg); }
  60% { transform: rotate(-8deg) translateY(-4px); }
  80% { transform: rotate(6deg); }
}
#draw-logo.shaking { animation: hat-shake .3s linear 4; }

/* Результат */
.result-label { color: var(--secondary); font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; }
.result-card {
  margin-top: 22px;
  background: var(--card); border: 1px solid var(--accent);
  border-radius: 24px; padding: 36px 26px;
  display: flex; flex-direction: column; align-items: center;
}
.result-card .emoji { font-size: 52px; margin-bottom: 20px; }
.result-card .text { font-size: 24px; font-weight: 700; line-height: 1.4; }
.result-meta { font-size: 13px; margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
