/* Общие стили: палитра, фон, аватары, таймер, переходы, конфетти. */
:root {
  --bg-1: #2a0a5e;
  --bg-2: #6a1b9a;
  --bg-3: #d6336c;
  --ink: #1d1033;
  --paper: #fffaf0;
  --yellow: #ffd60a;
  --pink: #ff4d6d;
  --mint: #06d6a0;
  --sky: #4cc9f0;
  --violet: #9b5de5;
  --white-soft: rgba(255, 255, 255, 0.14);
  --shadow: 0 0.35em 0 rgba(0, 0, 0, 0.25);
  --radius: 1.2em;
  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: #fff;
  background: var(--bg-1);
  background-image: radial-gradient(circle at 15% 20%, rgba(255, 214, 10, 0.25), transparent 35%),
    radial-gradient(circle at 85% 80%, rgba(76, 201, 240, 0.3), transparent 40%),
    linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 55%, var(--bg-3) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  border: 0;
  border-radius: 999px;
  padding: 0.8em 1.6em;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: var(--yellow);
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s;
  touch-action: manipulation;
}

.btn:active:not(:disabled) {
  transform: translateY(0.25em);
  box-shadow: 0 0.1em 0 rgba(0, 0, 0, 0.25);
}

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

.btn.secondary {
  background: rgba(255, 255, 255, 0.9);
}

.btn.ghost {
  background: transparent;
  color: #fff;
  box-shadow: none;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.btn:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 3px;
}

/* --- аватары --- */
.avatar {
  --c: var(--violet);
  display: grid;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  border-radius: 50%;
  background: var(--c);
  border: 0.12em solid #fff;
  box-shadow: 0 0.15em 0 rgba(0, 0, 0, 0.25);
  font-size: 1em;
  line-height: 1;
  flex-shrink: 0;
}

/* --- таймер-кольцо --- */
.timer {
  --p: 1;
  position: relative;
  display: grid;
  place-items: center;
  width: 4em;
  height: 4em;
  border-radius: 50%;
  background: conic-gradient(var(--yellow) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.18) 0);
  font-weight: 900;
  flex-shrink: 0;
}

.timer::before {
  content: '';
  position: absolute;
  inset: 0.35em;
  border-radius: 50%;
  background: var(--bg-1);
}

.timer-value {
  position: relative;
  font-size: 1.4em;
  font-variant-numeric: tabular-nums;
}

.timer.urgent {
  background: conic-gradient(var(--pink) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.18) 0);
  animation: pulse 0.6s ease-in-out infinite alternate;
}

/* --- смена экранов --- */
.stage {
  position: relative;
}

.screen {
  animation: screen-in 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.screen-leave {
  position: absolute;
  inset: 0;
  pointer-events: none;
  animation: screen-out 0.3s ease-in both;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
}

@keyframes screen-out {
  to {
    opacity: 0;
    transform: translateY(-16px) scale(0.98);
  }
}

@keyframes pulse {
  to {
    transform: scale(1.08);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.3) rotate(-8deg);
    opacity: 0;
  }
  70% {
    transform: scale(1.12) rotate(3deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

@keyframes float {
  50% {
    transform: translateY(-8px) rotate(-2deg);
  }
}

@keyframes wiggle {
  25% {
    transform: rotate(-4deg);
  }
  75% {
    transform: rotate(4deg);
  }
}

.pop {
  animation: pop 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

.float {
  animation: float 3s ease-in-out infinite;
}

/* --- конфетти --- */
.confetti {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 5;
}

.confetti i {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: fall linear infinite;
}

@keyframes fall {
  to {
    top: 110%;
    transform: translateX(60px) rotate(720deg);
  }
}

/* --- уведомления --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  padding: 0.8em 1.2em;
  border-radius: 1em;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  z-index: 20;
  animation: screen-in 0.3s both;
}

.toast.error {
  background: #c9184a;
}

.offline {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 5, 45, 0.75);
  backdrop-filter: blur(4px);
  z-index: 30;
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  padding: 1rem;
}

.offline[hidden] {
  display: none;
}

.spinner {
  width: 2.4rem;
  height: 2.4rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  border: 0.3rem solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--yellow);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }
  .confetti {
    display: none;
  }
}

/* ================= тема «Смертельного квиза» ================= */
body[data-game='deadly'] {
  --bg-1: #12060f;
  --bg-2: #3b0a1e;
  --bg-3: #7a0f24;
  background-image: radial-gradient(circle at 50% -10%, rgba(255, 77, 109, 0.35), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(106, 27, 154, 0.35), transparent 45%),
    linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 60%, var(--bg-3) 100%);
}

.face {
  position: relative;
  display: inline-flex;
}

.face.ghost .avatar {
  filter: grayscale(1) brightness(1.4);
  opacity: 0.6;
}

.ghost-badge {
  position: absolute;
  right: -0.35em;
  bottom: -0.25em;
  font-style: normal;
  font-size: 0.75em;
}

.faces {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25em;
}

@keyframes shake {
  20%, 60% { transform: translateX(-4px) rotate(-3deg); }
  40%, 80% { transform: translateX(4px) rotate(3deg); }
}
