/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg: #FFF5F7;
  --accent: #FF85A1;
  --primary: #F62459;
  --primary-dark: #c91b47;
  --text: #2d1b26;
  --text-muted: #9b7086;
  --card: #ffffff;
  --shadow: 0 4px 24px rgba(246, 36, 89, 0.12);
  --radius: 20px;
  --winner-gold: #F9D423;
  --winner-hot: #FF3D6B;
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  transition: background 0.4s ease;
}

/* ── Floating background blobs (normal state) ─────────────────────────────── */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.5s ease;
}

body::before {
  width: 400px; height: 400px;
  background: var(--accent);
  top: -100px; right: -100px;
  animation: blobFloat1 8s ease-in-out infinite;
}

body::after {
  width: 300px; height: 300px;
  background: var(--primary);
  bottom: -80px; left: -80px;
  animation: blobFloat2 10s ease-in-out infinite;
}

@keyframes blobFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(-30px, 30px) scale(1.1); }
}
@keyframes blobFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%       { transform: translate(20px, -20px) scale(0.9); }
}

/* ── Screens ───────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  position: relative;
  z-index: 1;
  animation: fadeSlideUp 0.5s ease forwards;
}

.screen.active { display: flex; }

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

/* ── Logo / App Name ──────────────────────────────────────────────────────── */
.app-logo {
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 900;
  letter-spacing: -2px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 32px;
  letter-spacing: 0.02em;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 440px;
}

/* ── Form Elements ─────────────────────────────────────────────────────────── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid #ffe0eb;
  border-radius: 12px;
  font-size: 1.05rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(246, 36, 89, 0.1);
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  width: 100%;
  letter-spacing: 0.02em;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #ff5580 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(246, 36, 89, 0.35);
}

.btn-primary:hover { box-shadow: 0 6px 24px rgba(246, 36, 89, 0.45); transform: translateY(-1px); }

.btn-secondary {
  background: #fff0f4;
  color: var(--primary);
  border: 2px solid #ffd6e3;
}

.btn-secondary:hover { background: #ffe0ea; }

.btn-danger {
  background: #fff0f0;
  color: #c0392b;
  border: 2px solid #ffd0d0;
}

.btn-danger:hover { background: #ffd6d6; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
  width: auto;
}

/* ── Waiting Screen ─────────────────────────────────────────────────────────── */
.guest-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff0f4;
  border: 2px solid var(--accent);
  border-radius: 99px;
  padding: 8px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 24px;
  animation: countPop 0.3s ease;
}

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

.dot-live {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

.prize-display {
  text-align: center;
  padding: 28px 24px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  width: 100%;
  max-width: 440px;
}

.prize-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.prize-name {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
  transition: all 0.4s ease;
}

.prize-name.waiting {
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 500;
}

/* ── Winner Banner (non-winner guests) ─────────────────────────────────────── */
.winner-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--primary), #ff5580);
  color: white;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(246, 36, 89, 0.4);
  animation: bannerSlideDown 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.winner-banner.show { display: block; }

@keyframes bannerSlideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ── YOU WON — Full Screen Celebration ─────────────────────────────────────── */
#winner-screen {
  background: var(--primary);
  color: white;
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}

#winner-screen.active { display: flex; }

/* Screen flash cycle */
.winner-active #winner-screen {
  animation: winnerBgFlash 0.6s ease 0s 4;
}

@keyframes winnerBgFlash {
  0%, 100% { background: var(--primary); }
  50%       { background: var(--winner-gold); }
}

/* Screen shake */
.winner-active #winner-screen {
  animation: winnerBgFlash 0.6s ease 0s 4, screenShake 0.5s ease 0s 3;
}

@keyframes screenShake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px) rotate(-1deg); }
  20%, 40%, 60%, 80% { transform: translateX(8px) rotate(1deg); }
}

.you-won-text {
  font-size: clamp(3rem, 15vw, 7rem);
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--winner-gold);
  text-shadow:
    0 0 40px rgba(249, 212, 35, 0.8),
    0 4px 0 rgba(0,0,0,0.2);
  line-height: 1;
  animation: slamIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

.you-won-name {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 800;
  color: white;
  margin-top: 12px;
  animation: slamIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.25s both;
}

.you-won-prize {
  font-size: clamp(1rem, 3.5vw, 1.5rem);
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  margin-top: 8px;
  animation: slamIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.4s both;
}

@keyframes slamIn {
  0%   { transform: scale(4) rotate(-8deg); opacity: 0; }
  60%  { transform: scale(0.88) rotate(2deg); opacity: 1; }
  80%  { transform: scale(1.05) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Pulse ring */
.pulse-ring {
  position: absolute;
  width: 200px; height: 200px;
  border: 4px solid var(--winner-gold);
  border-radius: 50%;
  opacity: 0;
  animation: pulseRing 1.5s ease-out 0.3s infinite;
}

.pulse-ring:nth-child(2) { animation-delay: 0.8s; }
.pulse-ring:nth-child(3) { animation-delay: 1.3s; }

@keyframes pulseRing {
  0%   { transform: scale(0.5); opacity: 0.9; }
  100% { transform: scale(3.5); opacity: 0; }
}

/* Star burst */
.star-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.star-burst::before,
.star-burst::after {
  content: '★ ✦ ★ ✦ ★ ✦ ★ ✦';
  position: absolute;
  font-size: 1.5rem;
  color: var(--winner-gold);
  white-space: nowrap;
  animation: starScroll 3s linear infinite;
  opacity: 0.6;
}

.star-burst::before { top: 10%; left: 0; }
.star-burst::after  { bottom: 10%; right: 0; animation-direction: reverse; }

@keyframes starScroll {
  from { transform: translateX(100vw); }
  to   { transform: translateX(-100vw); }
}

/* Canvas confetti sits on top */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
  display: none;
}

#confetti-canvas.active { display: block; }

/* ── Connecting / Error toasts ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 400;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show { opacity: 1; }

/* ── Admin styles ───────────────────────────────────────────────────────────── */
.admin-wrap {
  min-height: 100dvh;
  background: var(--bg);
  display: none;
  flex-direction: column;
}

.admin-wrap.active { display: flex; }

.admin-header {
  background: white;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header .logo {
  font-size: 1.4rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.admin-header .stats {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-pill {
  background: #fff0f4;
  border: 1.5px solid var(--accent);
  border-radius: 99px;
  padding: 4px 12px;
  color: var(--primary);
}

.admin-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 24px;
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 700px) {
  .admin-body { grid-template-columns: 1fr; }
}

.admin-panel {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding-bottom: 8px;
  border-bottom: 2px solid #ffeef4;
}

/* Prize list */
.prize-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.prize-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #ffeef4;
  cursor: pointer;
  transition: all 0.2s;
  gap: 8px;
}

.prize-item:hover { border-color: var(--accent); background: #fff5f8; }

.prize-item.selected {
  border-color: var(--primary);
  background: #fff0f4;
}

.prize-item.used {
  opacity: 0.45;
  text-decoration: line-through;
  cursor: default;
}

.prize-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
}

.prize-actions { display: flex; gap: 6px; }

.btn-icon {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s;
  line-height: 1;
}

.btn-icon:hover { background: #ffd6e3; }

/* Guest list */
.guest-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.guest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s;
}

.guest-item:hover { background: #fff5f8; }

.guest-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.guest-dot.connected { background: #22c55e; }
.guest-dot.disconnected { background: #d1d5db; }

.guest-name { flex: 1; }
.guest-name.won { color: var(--text-muted); text-decoration: line-through; }
.guest-name.won::after { content: ' 🏆'; font-size: 0.8em; }

/* Admin action bar */
.admin-actions {
  background: white;
  border-top: 2px solid #ffeef4;
  padding: 20px 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.admin-actions .btn { width: auto; min-width: 160px; }

/* Current prize display in admin */
.current-prize-display {
  text-align: center;
  padding: 16px;
  background: linear-gradient(135deg, #fff0f4, #fff5f8);
  border-radius: 12px;
  border: 2px solid var(--accent);
}

.current-prize-display .label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.current-prize-display .name {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
}

/* Winner display in admin */
.winner-display {
  display: none;
  text-align: center;
  padding: 16px;
  background: linear-gradient(135deg, #fffbec, #fff9e0);
  border-radius: 12px;
  border: 2px solid var(--winner-gold);
  animation: slamIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.winner-display.show { display: block; }

.winner-display .label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #b8920a;
  margin-bottom: 4px;
}

.winner-display .name {
  font-size: 1.5rem;
  font-weight: 900;
  color: #9a7400;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 27, 38, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 32px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: fadeSlideUp 0.3s ease;
}

.modal h3 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.modal p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.modal-actions .btn { flex: 1; }

/* Add prize inline */
.add-prize-row {
  display: flex;
  gap: 8px;
}

.add-prize-row input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid #ffe0eb;
  border-radius: 10px;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.add-prize-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(246, 36, 89, 0.1);
}

/* Error message */
.error-msg {
  color: #c0392b;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  min-height: 1.2em;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #fff5f7; border-radius: 99px; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 99px; }
