/* ============================================================
   BADSHAH WAZIR — Complete Responsive CSS
   Breakpoints: Mobile-first → Tablet (600px) → Desktop (1024px)
   ============================================================ */

/* ── Design Tokens ─────────────────────────────────────── */
:root {
  --navy:          #070714;
  --navy-2:        #0E0E24;
  --navy-3:        #151532;
  --crimson:       #7A0000;
  --crimson-light: #C8102E;
  --crimson-glow:  rgba(200, 16, 46, 0.4);
  --gold:          #FCD34D;
  --gold-light:    #FEF3C7;
  --gold-glow:     rgba(252, 211, 77, 0.4);
  --purple:        #8B5CF6;
  --purple-glow:   rgba(139, 92, 246, 0.4);
  --glass:         rgba(255, 255, 255, 0.08);
  --glass-border:  rgba(255, 255, 255, 0.15);
  --glass-highlight: rgba(255, 255, 255, 0.25);
  --success:       #10B981;
  --danger:        #EF4444;
  --text:          #F8FAFC;
  --text-muted:    #94A3B8;
  --radius:        20px;

  /* Safe-area insets (iOS notch support) */
  --sat: env(safe-area-inset-top,    0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left,   0px);
  --sar: env(safe-area-inset-right,  0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

@keyframes gradient-breath {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--navy);
  color: var(--text);
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Animated deep mesh background */
  background: linear-gradient(-45deg, #070714, #15051a, #1a0505, #0a0a1f);
  background-size: 400% 400%;
  animation: gradient-breath 15s ease infinite;
}

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6, .cinzel { 
  font-family: 'Cinzel', serif; 
  font-weight: 700; 
  letter-spacing: 0.05em;
}

/* ── Utility Classes ────────────────────────────────────── */
.gold-text    { color: var(--gold); }
.crimson-text { color: var(--crimson-light); }
.text-muted   { color: var(--text-muted); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-sm      { font-size: 0.8rem; }
.w-100        { width: 100%; }
.d-flex       { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.flex-grow    { flex: 1 1 0; min-height: 0; min-width: 0; }
.space-between{ justify-content: space-between; }
.align-center { align-items: center; }
.center-content { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.relative     { position: relative; }
.hidden       { display: none !important; }
.mx-auto      { margin-left: auto; margin-right: auto; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem;  }
.mb-3 { margin-bottom: 1rem;    }
.mb-4 { margin-bottom: 1.5rem;  }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem;  }
.mt-3 { margin-top: 1rem;    }
.mt-4 { margin-top: 1.5rem;  }
.p-2  { padding: 0.5rem;  }
.p-4  { padding: 1.5rem;  }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem;  }
.gap-3 { gap: 1rem;    }

/* ============================================================
   LAYOUT — App Shell
   The #app-shell is the actual viewport container.
   On mobile: full screen.
   On tablet/desktop: centred card with shadow.
   ============================================================ */

#particles-container {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* The shell wraps all screens and is the single positioned ancestor */
#app-shell {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

/* ── Mobile: full viewport ─────────────────────────────── */
.screen {
  /* Each screen fills the shell completely */
  position: absolute;
  inset: 0;

  display: flex;
  flex-direction: column;

  padding:
    calc(0.75rem + var(--sat))
    calc(0.75rem + var(--sar))
    calc(0.75rem + var(--sab))
    calc(0.75rem + var(--sal));

  overflow: hidden;

  /* Hidden by default */
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  z-index: 10;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Screens that need internal vertical centring */
.screen.center-content {
  align-items: center;
  justify-content: center;
}

/* ── Tablet (600 px) ──────────────────────────────────── */
@media (min-width: 600px) {
  #app-shell {
    align-items: center;
    justify-content: center;
    background-image:
      radial-gradient(ellipse 90% 60% at 20% 20%, rgba(139,0,0,0.12) 0%, transparent 65%),
      radial-gradient(ellipse 70% 50% at 80% 80%, rgba(124,58,237,0.12) 0%, transparent 65%);
  }

  /* Create the "phone card" wrapper */
  #app-shell::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--navy);
  }

  .screen {
    /* No longer full viewport — become a contained card */
    position: relative;
    inset: auto;
    width: 460px;
    max-height: min(90vh, 860px);
    height: 90vh;
    border-radius: 24px;
    overflow: hidden;
    box-shadow:
      0 0 0 1px var(--glass-border),
      0 25px 60px rgba(0, 0, 0, 0.6),
      0 0 80px rgba(139, 0, 0, 0.08);
    background: var(--navy);

    /* Still stacked absolutely inside the shell */
    position: absolute;

    padding:
      calc(1rem + var(--sat))
      1rem
      calc(1rem + var(--sab))
      1rem;
  }
}

/* ── Desktop (1024 px) ─────────────────────────────────── */
@media (min-width: 1024px) {
  .screen {
    width: 500px;
    max-height: min(92vh, 900px);
    height: 92vh;
  }
}

/* ── Large Desktop (1440 px) ───────────────────────────── */
@media (min-width: 1440px) {
  .screen {
    width: 520px;
    max-height: 900px;
    height: 88vh;
  }
}

/* ============================================================
   GLASSMORPHISM CARD
   ============================================================ */
.glass-card {
  background: var(--glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--glass-highlight);
  border-left: 1px solid var(--glass-highlight);
  border-right: 1px solid rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px var(--glass-border);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.85rem 1.5rem;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 52px;
  color: white;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-transform: uppercase;
}
.btn:active   { transform: scale(0.95); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; filter: grayscale(1); }

.btn-primary {
  background: linear-gradient(135deg, var(--crimson) 0%, var(--crimson-light) 100%);
  box-shadow: 0 8px 24px var(--crimson-glow), inset 0 1px 1px rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 12px 30px rgba(185, 28, 28, 0.6), inset 0 1px 1px rgba(255,255,255,0.3);
  filter: brightness(1.15);
  transform: translateY(-2px);
}

.btn-secondary {
  background: linear-gradient(135deg, #4C1D95 0%, var(--purple) 100%);
  box-shadow: 0 8px 24px var(--purple-glow), inset 0 1px 1px rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-secondary:hover:not(:disabled) {
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.6), inset 0 1px 1px rgba(255,255,255,0.3);
  filter: brightness(1.15);
  transform: translateY(-2px);
}

.btn-ghost {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  color: var(--text);
  backdrop-filter: blur(8px);
}
.btn-ghost:hover:not(:disabled) { 
  background: rgba(255,255,255,0.1); 
  transform: translateY(-1px);
}

.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.82rem; min-height: 38px; border-radius: 10px; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background 0.2s;
}
.btn-icon:hover { background: var(--glass); }

.btn-group { display: flex; flex-direction: column; gap: 0.75rem; }

/* ============================================================
   FORMS
   ============================================================ */
.form-card { overflow-y: auto; max-height: 100%; }
.form-group { margin-bottom: 0.9rem; }
.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input[type="text"], select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: rgba(10, 10, 26, 0.7);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394A3B8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}
input[type="text"]:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.btn-back {
  padding: 0;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

/* ============================================================
   SCROLLABLE
   ============================================================ */
.scrollable {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}
.scrollable::-webkit-scrollbar { width: 5px; }
.scrollable::-webkit-scrollbar-track { background: transparent; }
.scrollable::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }

/* ============================================================
   AVATARS
   ============================================================ */
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: white;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.avatar-sm { width: 34px; height: 34px; font-size: 0.75rem; }
.avatar-md { width: 48px; height: 48px; font-size: 1rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.4rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 1.8rem; }

.status-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--navy-2);
}
.status-dot.offline { background: #475569; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 600;
  background: var(--navy-3);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  white-space: nowrap;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(0,0,0,0.5);
  border: 1px solid currentColor;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.06); opacity: 0.85; }
}
.pulse { animation: pulse 2s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 2s linear infinite; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}
.animate-float { animation: float 3s ease-in-out infinite; }

@keyframes popIn {
  from { transform: scale(0.75); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

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

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

/* Floating particles background */
@keyframes particleFloat {
  0%   { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
  10%  { opacity: 0.6; }
  90%  { opacity: 0.3; }
  100% { transform: translateY(-100vh) translateX(30px) scale(0.5); opacity: 0; }
}

/* ============================================================
   SCREEN: WAKEUP
   ============================================================ */
#screen-wakeup .glass-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
  padding: 2.5rem 2rem;
}
.spinning-crown {
  font-size: 4rem;
  animation: float 3s ease-in-out infinite, pulse 2s ease-in-out infinite;
  margin-bottom: 1rem;
  display: block;
}
#screen-wakeup h2 { margin-bottom: 0.5rem; font-size: 1.3rem; }
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--glass-border);
  border-radius: 3px;
  margin-top: 1.25rem;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--crimson), var(--gold));
  border-radius: 3px;
  animation: shimmer 1.8s ease-in-out infinite;
  background-size: 200% auto;
}

/* ============================================================
   SCREEN: HOME
   ============================================================ */
#screen-home {
  align-items: center;
  justify-content: center;
}
.home-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  padding: 2rem 1.5rem;
}
.logo-text {
  font-size: clamp(2.2rem, 8vw, 3.2rem);
  line-height: 1.1;
  margin-bottom: 0.4rem;
  text-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.tagline {
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 2rem;
}
.role-icons-footer {
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  margin-top: 1.5rem;
  font-size: 1.6rem;
  opacity: 0.75;
}
.role-icon { transition: transform 0.2s; cursor: default; }
.role-icon:hover { transform: scale(1.2); }

/* ============================================================
   SCREEN: CREATE / JOIN
   ============================================================ */
#screen-create, #screen-join {
  align-items: center;
  justify-content: center;
}
#screen-create .glass-card,
#screen-join   .glass-card {
  width: 100%;
  max-width: 400px;
  max-height: calc(100% - 1rem);
  overflow-y: auto;
}

/* ============================================================
   SCREEN: LOBBY
   ============================================================ */
#screen-lobby { gap: 0.6rem; }

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  padding: 0.75rem 1rem;
}
.room-code-display {
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 5px;
  cursor: pointer;
  text-shadow: 0 0 14px var(--gold-glow);
  transition: text-shadow 0.2s;
  line-height: 1;
}
.room-code-display:hover { text-shadow: 0 0 24px var(--gold-glow); }

.settings-badges {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-end;
}

.player-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 0.25rem;
}

@media (min-width: 600px) {
  .player-grid { grid-template-columns: 1fr 1fr; }
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.025);
  border: 1px solid transparent;
  transition: all 0.25s;
  min-height: 56px;
}
.player-slot.is-me {
  border-color: rgba(255, 215, 0, 0.3);
  background: rgba(255, 215, 0, 0.05);
}
.player-slot-empty {
  opacity: 0.28;
  border: 1px dashed var(--glass-border) !important;
  background: transparent !important;
}
.player-info { display: flex; flex-direction: column; overflow: hidden; flex: 1; }
.player-name {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.1rem;
}

.lobby-players-wrap { flex: 1 1 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.lobby-players-inner { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 0.1rem; }

.lobby-footer { flex-shrink: 0; }
.waiting-text { color: var(--text-muted); font-size: 0.88rem; padding: 0.5rem; }

/* ============================================================
   SCREEN: ROLE REVEAL
   ============================================================ */
#screen-role-reveal { gap: 1rem; }

.round-badge {
  display: inline-block;
  background: var(--crimson-glow);
  border: 1px solid rgba(185,28,28,0.5);
  padding: 0.4rem 1.4rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.5px;
}
.flip-card-container {
  width: min(260px, 80vw);
  height: min(360px, 55vh);
  perspective: 1000px;
  flex-shrink: 0;
}
.flip-card {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.85s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}
.flip-card.flipped { transform: rotateY(180deg); }
.flip-card-front, .flip-card-back {
  width: 100%; height: 100%;
  position: absolute;
  backface-visibility: hidden;
  border-radius: 24px;
  border: 2px solid var(--glass-highlight);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.flip-card-front {
  background: linear-gradient(135deg, #1A0B2E 0%, #0F0518 100%);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.ornate-pattern {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(var(--gold-glow) 2px, transparent 2px),
    radial-gradient(var(--gold-glow) 2px, transparent 2px);
  background-size: 30px 30px;
  background-position: 0 0, 15px 15px;
  opacity: 0.35;
}
.flip-card-back {
  transform: rotateY(180deg);
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 2rem;
  text-align: center;
  background: rgba(20,20,40, 0.95);
  backdrop-filter: blur(10px);
}
.role-icon-huge {
  font-size: clamp(4rem, 12vh, 6rem);
  margin-bottom: 1rem;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5)) drop-shadow(0 0 30px currentColor);
}
.role-name-huge {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  margin-bottom: 0.5rem;
}
.role-desc { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }

.special-info {
  width: 100%;
  max-width: 320px;
  text-align: center;
  font-size: 0.88rem;
  border-color: rgba(255,215,0,0.3);
  background: rgba(255,215,0,0.05);
  padding: 0.75rem 1rem;
}
.countdown-dots { display: flex; gap: 0.5rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--glass-border); transition: background 0.3s; }
.dot.active { background: var(--gold); }

/* ============================================================
   SCREEN: QUESTIONING (CHAT)
   ============================================================ */
#screen-questioning { gap: 0.5rem; }

.questioning-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.9rem;
  gap: 0.5rem;
}
.my-role-badge {
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--glass-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.phase-title {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  color: var(--gold);
  font-size: 0.88rem;
  flex: 1;
  text-align: center;
}

/* Circular Timer */
.timer-container { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
.circular-timer  { transform: rotate(-90deg); }
.timer-bg        { fill: none; stroke: var(--glass-border); stroke-width: 4; }
.timer-progress  {
  fill: none; stroke: var(--gold); stroke-width: 4;
  stroke-dasharray: 100.5; stroke-dashoffset: 0;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.timer-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700;
}
.timer-urgent .timer-progress { stroke: var(--danger); animation: pulse 0.8s infinite; }
.timer-urgent .timer-text     { color: var(--danger); }

/* Player avatar row */
.player-row {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}
.player-row::-webkit-scrollbar { display: none; }
.chat-avatar-wrapper {
  display: flex; flex-direction: column;
  align-items: center; gap: 0.2rem;
  flex-shrink: 0;
}
.chat-avatar-name {
  font-size: 0.65rem;
  max-width: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  text-align: center;
}

/* Chat messages */
.chat-area {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 0.4rem;
  max-width: 82%;
  animation: popIn 0.22s ease;
}
.msg-mine  { align-self: flex-end;  flex-direction: row-reverse; }
.msg-other { align-self: flex-start; }

.msg-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 18px;
  font-size: 0.88rem;
  line-height: 1.45;
}
.msg-mine  .msg-bubble {
  background: linear-gradient(135deg, var(--crimson-light), var(--crimson));
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 12px var(--crimson-glow);
}
.msg-other .msg-bubble {
  background: var(--navy-3);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 5px;
}
.msg-sender { font-size: 0.68rem; color: var(--text-muted); margin-bottom: 0.2rem; display: block; }

/* Chat input bar */
.chat-input-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: var(--navy-2);
  border-radius: 24px;
  border: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.chat-input-bar input {
  border: none;
  background: transparent;
  padding: 0 0.75rem;
  box-shadow: none;
  min-height: 38px;
  font-size: 0.9rem;
  flex: 1;
}
.send-btn {
  width: 42px; height: 42px; min-width: 42px; min-height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), #B8860B);
  color: var(--navy);
  font-size: 1rem;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.send-btn:hover { transform: scale(1.08); box-shadow: 0 4px 12px var(--gold-glow); }

/* ============================================================
   SCREEN: GUESSING
   ============================================================ */
#screen-guessing { gap: 0.6rem; }

.urgency-bar {
  position: fixed; top: 0; left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--crimson), var(--gold));
  transition: width 1s linear;
  z-index: 200;
  box-shadow: 0 0 8px var(--crimson-glow);
}

#guessing-wazir { gap: 0.6rem; }

.guess-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.7rem;
  padding: 0.25rem;
}
.guess-card {
  background: var(--navy-3);
  border: 2px solid var(--glass-border);
  border-radius: 14px;
  padding: 0.9rem 0.5rem;
  display: flex; flex-direction: column;
  align-items: center; gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 90px;
}
.guess-card:hover:not(.immune) {
  transform: translateY(-3px);
  border-color: rgba(255,255,255,0.35);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.guess-card.selected {
  border-color: var(--crimson-light);
  background: rgba(185, 28, 28, 0.12);
  box-shadow: 0 0 18px var(--crimson-glow);
  transform: scale(1.04);
}
.guess-card.immune {
  opacity: 0.4; cursor: not-allowed; filter: grayscale(0.8);
}
.guess-name { font-size: 0.8rem; font-weight: 600; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guess-label { font-size: 0.68rem; color: var(--text-muted); }

.wazir-thinking-wrap {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1rem; text-align: center;
}
.wazir-thinking-avatar {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4C1D95, var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
  box-shadow: 0 0 30px var(--purple-glow);
  border: 3px solid var(--gold);
}

/* ============================================================
   SCREEN: RESULTS
   ============================================================ */
#screen-results { gap: 0.75rem; }

.result-banner {
  flex-shrink: 0;
  text-align: center;
  padding: 1.1rem;
  border-width: 2px;
  transition: all 0.5s;
}
.result-banner.success { background: rgba(34,197,94,0.08); border-color: var(--success); }
.result-banner.fail    { background: rgba(239,68,68,0.08);  border-color: var(--danger); }
.result-banner h1 { font-size: clamp(1.2rem, 4vw, 1.6rem); margin-bottom: 0.25rem; }

.reveal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  padding: 0.25rem;
}
.reveal-card {
  background: var(--navy-3);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 0.9rem 0.5rem;
  text-align: center;
  position: relative;
  animation: popIn 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
}
.reveal-card.caught { border-color: var(--danger); background: rgba(239,68,68,0.08); }
.reveal-card .reveal-name { font-size: 0.8rem; font-weight: 600; margin-top: 0.4rem; }
.reveal-card .reveal-role { font-size: 0.72rem; color: var(--text-muted); }

.score-badge {
  position: absolute; top: -10px; right: -8px;
  font-weight: 700; font-size: 0.78rem;
  padding: 0.2rem 0.45rem;
  border-radius: 10px;
  background: var(--navy);
  border: 2px solid;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

/* Confetti */
#confetti-container {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9998;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 10px; height: 12px;
  top: -20px;
  animation: confettiFall linear forwards;
  border-radius: 2px;
}
@keyframes confettiFall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0.2; }
}

/* ============================================================
   SCREEN: LEADERBOARD
   ============================================================ */
#screen-leaderboard { gap: 0.6rem; }

.podium-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 185px;
  gap: 0.75rem;
  flex-shrink: 0;
  padding-top: 1.5rem;
}
.podium-place {
  display: flex; flex-direction: column;
  align-items: center;
  flex: 1; max-width: 90px;
}
.podium-avatar {
  border-radius: 50%;
  border: 3px solid;
  background: var(--navy);
  margin-bottom: 0.3rem;
  flex-shrink: 0;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  color: white; font-family: 'Inter', sans-serif;
}
.podium-1 .podium-avatar { width: 58px; height: 58px; font-size: 1.3rem; border-color: #FFD700; }
.podium-2 .podium-avatar { width: 48px; height: 48px; font-size: 1.1rem; border-color: #C0C0C0; }
.podium-3 .podium-avatar { width: 44px; height: 44px; font-size: 1rem;   border-color: #CD7F32; }
.podium-name { font-size: 0.72rem; font-weight: 600; text-align: center; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 0.2rem; }
.podium-score { font-size: 0.68rem; color: var(--text-muted); text-align: center; }

.podium-bar {
  width: 100%;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 0.35rem;
  font-weight: 800; font-size: 1.1rem;
}
.podium-1 .podium-bar { height: 110px; background: linear-gradient(to bottom, #FFD700, #B8860B); color: #3D2B00; }
.podium-2 .podium-bar { height: 80px;  background: linear-gradient(to bottom, #E0E0E0, #9E9E9E); color: #1a1a1a; }
.podium-3 .podium-bar { height: 60px;  background: linear-gradient(to bottom, #CD7F32, #8B4513); color: #1a1a1a; }

.rank-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--glass-border);
}
.rank-row:last-child { border-bottom: none; }
.rank-num  { width: 24px; font-weight: 700; color: var(--text-muted); font-size: 0.88rem; flex-shrink: 0; }
.rank-name { flex: 1; font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-score { font-weight: 700; font-family: 'Cinzel', serif; font-size: 0.95rem; color: var(--gold); }
.rank-change { font-size: 0.72rem; font-weight: 700; padding: 0.1rem 0.35rem; border-radius: 8px; flex-shrink: 0; }
.rank-change.positive { color: var(--success); background: rgba(34,197,94,0.1); }
.rank-change.zero     { color: var(--text-muted); }

/* ============================================================
   SCREEN: GAME OVER
   ============================================================ */
#screen-gameover { gap: 1rem; align-items: center; }
#screen-gameover h1 { font-size: clamp(2rem, 7vw, 2.8rem); }

.winner-card {
  text-align: center;
  padding: 1.5rem 2rem;
  width: 100%;
  max-width: 300px;
  border-color: rgba(255,215,0,0.3);
  background: rgba(255,215,0,0.05);
}
.winner-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700;
  border: 3px solid var(--gold);
  box-shadow: 0 0 24px var(--gold-glow);
  margin: 0 auto;
  color: white;
}
.winner-score { font-family: 'Cinzel', serif; font-size: 1.4rem; }

/* ============================================================
   TOASTS
   ============================================================ */
#toast-container {
  position: fixed;
  top: max(1rem, var(--sat));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex; flex-direction: column; gap: 0.5rem;
  width: min(92vw, 380px);
  pointer-events: none;
}
.toast {
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: rgba(18, 18, 42, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  color: white;
  display: flex; align-items: center; gap: 0.6rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  font-size: 0.88rem;
  animation: slideUp 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.info    { border-left: 4px solid var(--gold); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.success { border-left: 4px solid var(--success); }
.toast.warning { border-left: 4px solid #F97316; }

/* ============================================================
   AVATAR PICKER
   ============================================================ */
.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.avatar-option {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all 0.2s;
}
.avatar-option:hover { background: rgba(255,255,255,0.1); transform: scale(1.1); }
.avatar-option.selected {
  background: var(--gold-glow);
  border-color: var(--gold);
  box-shadow: 0 0 15px var(--gold-glow);
  transform: scale(1.15);
}

/* ============================================================
   NIGHT PHASE SUSPENSE
   ============================================================ */
body.night-phase {
  background: #000 !important;
  animation: none !important;
}
#app-shell.night-phase::before {
  background: #000 !important;
}
.night-phase .glass-card {
  background: rgba(0, 0, 0, 0.8) !important;
  border-color: rgba(255, 0, 0, 0.2);
  box-shadow: 0 0 30px rgba(255, 0, 0, 0.1);
}
.night-phase #guessing-wait {
  color: var(--crimson-light);
  text-shadow: 0 0 10px rgba(200, 16, 46, 0.5);
}
@keyframes pulse-intense {
  0% { transform: scale(1); filter: drop-shadow(0 0 10px red); }
  50% { transform: scale(1.1); filter: drop-shadow(0 0 30px red); }
  100% { transform: scale(1); filter: drop-shadow(0 0 10px red); }
}
.night-phase .wazir-thinking-avatar {
  font-size: 5rem;
  animation: pulse-intense 1.5s infinite ease-in-out;
}
