/* ===== Phase cinematic transitions ===== */

.phase-cinematic {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.phase-cinematic.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.phase-cinematic__backdrop {
  position: absolute;
  inset: 0;
  background: #050508;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 0.55s ease, transform 1.2s ease;
}

.phase-cinematic.is-active .phase-cinematic__backdrop {
  opacity: 1;
  transform: scale(1);
}

.phase-cinematic--night .phase-cinematic__backdrop {
  background: radial-gradient(ellipse at 50% 20%, #1a0a2e 0%, #050508 55%, #000 100%);
}

.phase-cinematic--morning .phase-cinematic__backdrop {
  background: radial-gradient(ellipse at 50% 85%, rgba(251, 191, 36, 0.35) 0%, #1a1208 45%, #050508 100%);
}

.phase-cinematic--day .phase-cinematic__backdrop {
  background: radial-gradient(ellipse at 50% 15%, rgba(253, 224, 71, 0.28) 0%, #1a1608 50%, #080808 100%);
}

.phase-cinematic--voting .phase-cinematic__backdrop {
  background: radial-gradient(ellipse at center, rgba(220, 38, 38, 0.22) 0%, #120808 50%, #050508 100%);
}

.phase-cinematic--victory-mafia .phase-cinematic__backdrop {
  background: radial-gradient(ellipse at center, rgba(225, 29, 72, 0.35) 0%, #0a0508 60%, #000 100%);
}

.phase-cinematic--victory-town .phase-cinematic__backdrop {
  background: radial-gradient(ellipse at center, rgba(74, 222, 128, 0.2) 0%, #081208 60%, #000 100%);
}

.phase-cinematic__curtain {
  position: absolute;
  left: 0;
  width: 100%;
  height: 52%;
  background: linear-gradient(180deg, #030305 0%, #0a0812 100%);
  z-index: 2;
  transform: translateY(0);
  transition: transform 1.1s cubic-bezier(0.65, 0, 0.35, 1);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.8);
}

.phase-cinematic__curtain--top {
  top: 0;
  border-bottom: 1px solid rgba(126, 34, 206, 0.25);
}

.phase-cinematic__curtain--bottom {
  bottom: 0;
  border-top: 1px solid rgba(126, 34, 206, 0.25);
  transform: translateY(0);
}

.phase-cinematic.is-revealing .phase-cinematic__curtain--top {
  transform: translateY(-100%);
}

.phase-cinematic.is-revealing .phase-cinematic__curtain--bottom {
  transform: translateY(100%);
}

.phase-cinematic__fx {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.phase-cinematic__stars {
  position: absolute;
  inset: 0;
}

.phase-cinematic__star {
  position: absolute;
  width: 2px;
  height: 2px;
  background: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: starTwinkle 2s ease-in-out infinite;
}

.phase-cinematic__sun {
  position: absolute;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, #fef08a 0%, #fbbf24 40%, transparent 70%);
  opacity: 0;
  filter: blur(2px);
  animation: sunRise 2.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.phase-cinematic__sun-rays {
  position: absolute;
  bottom: 20px;
  left: 50%;
  width: 320px;
  height: 320px;
  transform: translateX(-50%);
  background: conic-gradient(from 0deg, transparent, rgba(251, 191, 36, 0.12), transparent, rgba(251, 191, 36, 0.08), transparent);
  opacity: 0;
  animation: raysSpin 8s linear infinite, raysFadeIn 1.5s ease forwards;
}

.phase-cinematic__content {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 24px;
  max-width: 520px;
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  transition: opacity 0.6s ease 0.25s, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
}

.phase-cinematic.is-active .phase-cinematic__content {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.phase-cinematic.is-exiting .phase-cinematic__content {
  opacity: 0;
  transform: translateY(-12px) scale(0.98);
  transition-duration: 0.35s;
  transition-delay: 0s;
}

.phase-cinematic__icon {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 24px rgba(255, 255, 255, 0.15));
  animation: iconFloat 2.5s ease-in-out infinite;
}

.phase-cinematic__title {
  font-family: var(--f-display, 'Unbounded', sans-serif);
  font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

.phase-cinematic__subtitle {
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.55;
  margin-bottom: 22px;
}

.phase-cinematic__progress-track {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  margin: 0 auto;
  overflow: hidden;
}

.phase-cinematic__progress-bar {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(255,255,255,0.5), #fff);
  border-radius: 999px;
  transition: width linear;
}

.phase-cinematic--night .phase-cinematic__progress-bar { background: linear-gradient(90deg, #7e22ce, #c084fc); }
.phase-cinematic--morning .phase-cinematic__progress-bar { background: linear-gradient(90deg, #d97706, #fde68a); }
.phase-cinematic--day .phase-cinematic__progress-bar { background: linear-gradient(90deg, #ca8a04, #fef08a); }
.phase-cinematic--voting .phase-cinematic__progress-bar { background: linear-gradient(90deg, #dc2626, #fca5a5); }

/* ===== In-game UI micro-animations ===== */

.game-phase-banner {
  animation: bannerSlideIn 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.game-phase-banner.phase-changed {
  animation: bannerPulse 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.phase-banner-icon {
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.game-phase-banner.phase-changed .phase-banner-icon {
  animation: iconPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.room-phase-pill {
  transition: background 0.45s ease, color 0.45s ease, border-color 0.45s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.room-phase-pill.phase-pill-pop {
  animation: pillPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.phase-ambient-badge {
  animation: badgeFadeDown 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.phase-ambient-badge.badge-changed {
  animation: badgePop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.online-table-arena {
  transition: background 0.9s ease, box-shadow 0.9s ease, border-color 0.9s ease;
}

.table-center-hub {
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.table-center-hub.hub-updated {
  animation: hubFade 0.55s ease;
}

.player-seat-card {
  animation: seatEnter 0.55s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--seat-index, 0) * 0.055s);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, opacity 0.35s ease;
}

.player-seat-card.is-nominated {
  animation: nominatePulse 1.8s ease-in-out infinite;
}

.player-seat-card.is-dead {
  animation: seatEliminated 0.7s ease forwards;
}

.night-curtain-overlay {
  animation: nightCurtainIn 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.night-curtain-overlay .night-action-prompt-box {
  animation: boxRise 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.15s backwards;
}

.night-prompt-title {
  font-family: var(--f-display);
  font-size: 1.4rem;
  color: #ffffff;
  margin-bottom: 12px;
  animation: sleepPulse 2.8s ease-in-out infinite;
}

.morning-overlay,
.day-discussion-overlay {
  display: none !important;
}

.host-inline-panel {
  transition: box-shadow 0.4s ease;
}

.host-control-box--phase.host-phase-glow {
  animation: hostGlow 0.8s ease;
}

.host-night-summary,
.host-morning-summary,
.host-day-summary {
  animation: panelSlideUp 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.log-item-row {
  animation: logRowIn 0.35s ease backwards;
}

@keyframes starTwinkle {
  0%, 100% { opacity: 0.15; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.3); }
}

@keyframes sunRise {
  0% { opacity: 0; bottom: -120px; transform: translateX(-50%) scale(0.6); }
  100% { opacity: 1; bottom: 15%; transform: translateX(-50%) scale(1); }
}

@keyframes raysSpin {
  to { transform: translateX(-50%) rotate(360deg); }
}

@keyframes raysFadeIn {
  from { opacity: 0; }
  to { opacity: 0.7; }
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes bannerSlideIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bannerPulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.015); }
  100% { transform: scale(1); }
}

@keyframes iconPop {
  0% { transform: scale(0.5) rotate(-8deg); opacity: 0.5; }
  60% { transform: scale(1.15) rotate(4deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

@keyframes pillPop {
  0% { transform: scale(0.92); }
  55% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

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

@keyframes badgePop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes seatEnter {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes seatEliminated {
  to { opacity: 0.35; filter: grayscale(1); transform: scale(0.97); }
}

@keyframes nominatePulse {
  0%, 100% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); border-color: rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 18px rgba(239, 68, 68, 0.25); border-color: rgba(239, 68, 68, 0.85); }
}

@keyframes nightCurtainIn {
  from { opacity: 0; backdrop-filter: blur(0); }
  to { opacity: 1; backdrop-filter: blur(10px); }
}

@keyframes boxRise {
  from { opacity: 0; transform: translateY(28px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sleepPulse {
  0%, 100% { opacity: 0.85; text-shadow: 0 0 12px rgba(192, 132, 252, 0.2); }
  50% { opacity: 1; text-shadow: 0 0 22px rgba(192, 132, 252, 0.45); }
}

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

@keyframes hubFade {
  0% { opacity: 0.4; transform: scale(0.98); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes hostGlow {
  0% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
  40% { box-shadow: 0 0 28px rgba(239, 68, 68, 0.2); }
  100% { box-shadow: none; }
}

@keyframes panelSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes logRowIn {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .phase-cinematic,
  .phase-cinematic * {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }

  .player-seat-card,
  .game-phase-banner,
  .night-curtain-overlay,
  .morning-overlay,
  .day-discussion-overlay {
    animation: none !important;
  }
}
