/* =========================================================================
   Mafia Game - Design System & Modern Theme
   Inspired by Faisal Kahoot (Mobile-first, Cairo typography, Dark Glass UI)
   ========================================================================= */

/* Self-hosted Cairo font for instant 0-latency loading */
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/fonts/cairo-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1,
    U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF,
    U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/fonts/cairo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Cairo';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('/fonts/cairo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --font-arabic: 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;

  /* Primary Theme Palette (Faisal Kahoot tokens) */
  --color-red: #E21B3C;
  --color-red-dark: #B5122C;
  --color-blue: #1368CE;
  --color-blue-dark: #0D4E9E;
  --color-yellow: #D89E00;
  --color-yellow-dark: #A57800;
  --color-green: #26890C;
  --color-green-dark: #1C6708;

  /* Neutrals & Surfaces */
  --bg-dark: #0E1322;
  --bg-card: rgba(26, 34, 56, 0.85);
  --bg-card-hover: rgba(36, 48, 78, 0.95);
  --border-color: rgba(255, 255, 255, 0.12);
  --text-main: #FFFFFF;
  --text-muted: #94A3B8;
  --accent-gold: #FBBF24;
  --accent-purple: #8B5CF6;

  /* Role Colors */
  --role-mafia: #E21B3C;
  --role-doctor: #10B981;
  --role-detective: #3B82F6;
  --role-citizen: #94A3B8;

  /* Radii & Shadows */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --focus-ring: 0 0 0 3px #0E1322, 0 0 0 6px var(--accent-gold);
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-arabic);
  touch-action: manipulation;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(15, 23, 42, 0.5);
}

[hidden] {
  display: none !important;
}

body {
  direction: rtl;
  text-align: right;
  background: radial-gradient(circle at top, #1E293B, var(--bg-dark));
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  transition: background 0.4s ease;
}

/* Atmospheric Phase Backgrounds */
body.phase-night {
  background: radial-gradient(circle at top, #1e1b4b, #080c16);
}

body.phase-day {
  background: radial-gradient(circle at top, #3b220c, #0d121f);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-full);
}

/* Visible Focus */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* =========================================================================
   App Header
   ========================================================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(14, 19, 34, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  user-select: none;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon {
  font-size: 1.4rem;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #FFF, var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

.icon-btn:active {
  transform: scale(0.92);
}

/* =========================================================================
   Layout & Screens
   ========================================================================= */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: screenFadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active {
  display: flex;
}

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

/* =========================================================================
   Cards & Surfaces
   ========================================================================= */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text-main);
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-header-flex .card-title {
  margin-bottom: 0;
}

.card-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

/* =========================================================================
   Typography & Hero
   ========================================================================= */
.hero-brand {
  text-align: center;
  padding: 16px 0 8px;
}

.hero-badge {
  display: inline-block;
  background: rgba(226, 27, 60, 0.15);
  border: 1px solid rgba(226, 27, 60, 0.35);
  color: #FFA5B4;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}

.hero-title {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--color-red);
  text-shadow: 0 0 20px rgba(226, 27, 60, 0.6), 0 4px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: 2px;
  line-height: 1.1;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
}

.hero-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* =========================================================================
   Buttons & Inputs
   ========================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-arabic);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  user-select: none;
  box-shadow: var(--shadow-sm);
}

.btn:active:not(:disabled) {
  transform: translateY(2px);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 16px 24px;
  font-size: 1.15rem;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-red), var(--color-red-dark));
  color: #FFF;
  box-shadow: 0 4px 15px rgba(226, 27, 60, 0.35);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(226, 27, 60, 0.5);
  filter: brightness(1.08);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: #FFF;
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-danger {
  background: linear-gradient(135deg, #DC2626, #991B1B);
  color: #FFF;
}

.btn-warning {
  background: linear-gradient(135deg, #D97706, #B45309);
  color: #FFF;
}

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

.form-group {
  margin-bottom: 14px;
}

.input-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-main);
}

.input-label .required {
  color: var(--color-red);
}

.text-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.7);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #FFF;
  font-size: 1rem;
  font-family: var(--font-arabic);
  transition: var(--transition);
}

.text-input:focus {
  outline: none;
  border-color: var(--accent-gold);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.2);
}

.pin-input {
  text-align: center;
  font-size: 1.4rem;
  letter-spacing: 4px;
  font-weight: 800;
  text-transform: uppercase;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.divider span {
  padding: 0 12px;
}

/* =========================================================================
   Avatar Selector Grid (Faisal Kahoot Implementation)
   ========================================================================= */
.avatar-fieldset {
  border: none;
  padding: 0;
  margin: 0 0 14px 0;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.avatar-item {
  font-size: 1.75rem;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 8px 0;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  color: inherit;
  line-height: 1.2;
}

.avatar-item:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.avatar-item.selected {
  border-color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.18);
  transform: scale(1.1);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.35);
}

.custom-photo-details {
  margin-top: 8px;
  font-size: 0.85rem;
}

.custom-photo-summary {
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 0;
}

.custom-photo-summary:hover {
  color: var(--accent-gold);
}

.custom-photo-content {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-input {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.preview-container img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid var(--accent-gold);
  object-fit: cover;
}

/* =========================================================================
   Lobby & QR Code (Faisal Kahoot Implementation)
   ========================================================================= */
.pin-display-box {
  background: linear-gradient(135deg, rgba(19, 104, 206, 0.25), rgba(226, 27, 60, 0.25));
  border: 2px dashed var(--accent-gold);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.pin-display-label {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
}

.pin-display-code {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: 5px;
  color: var(--accent-gold);
  margin: 4px 0 12px;
  user-select: all;
  text-shadow: 0 0 15px rgba(251, 191, 36, 0.4);
}

.lobby-share-row {
  margin-bottom: 12px;
}

.share-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.qr-code-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px auto 4px;
  padding: 10px;
  background: #FFF;
  border-radius: var(--radius-md);
  width: fit-content;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.qr-code-wrapper img,
.qr-code-wrapper canvas {
  display: block;
}

.qr-code-wrapper:empty {
  display: none;
}

.qr-caption {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Lobby Players Grid */
.lobby-players-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.player-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  min-width: 0;
  transition: var(--transition);
}

.player-pill.is-host {
  border-color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.14);
}

.player-avatar-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.player-avatar-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.player-pill-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.host-badge-tag {
  background: var(--accent-gold);
  color: #000;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.count-badge {
  background: rgba(255, 255, 255, 0.15);
  color: #FFF;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

/* =========================================================================
   Organizer Role Balancer
   ========================================================================= */
.roles-balancer-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.role-control-item {
  background: rgba(15, 23, 42, 0.6);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition);
}

.role-control-item.role-mafia { border-color: rgba(226, 27, 60, 0.4); }
.role-control-item.role-doctor { border-color: rgba(16, 185, 129, 0.4); }
.role-control-item.role-detective { border-color: rgba(59, 130, 246, 0.4); }

.role-info {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
  font-weight: 700;
}

.role-icon {
  font-size: 1.2rem;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stepper-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  color: #FFF;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.stepper-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.stepper input {
  width: 32px;
  background: transparent;
  border: none;
  color: #FFF;
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
}

.roles-summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.status-valid { color: #10B981; font-weight: 700; }
.status-invalid { color: #EF4444; font-weight: 700; }

/* Waiting Pulse Indicator */
.waiting-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.25);
}

.pulse-indicator {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(251, 191, 36, 0.3);
  animation: pulseAnim 2s infinite ease-out;
}

@keyframes pulseAnim {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.pulse-core {
  font-size: 1.4rem;
  z-index: 1;
}

.waiting-text strong {
  display: block;
  font-size: 0.95rem;
  color: var(--accent-gold);
}

.waiting-text p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* =========================================================================
   Game Screen & Gameplay
   ========================================================================= */
.game-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
}

.phase-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 800;
}

.timer-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1.3rem;
  font-weight: 900;
  font-family: monospace;
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.timer-box.urgent {
  color: #EF4444;
  border-color: #EF4444;
  animation: timerPulse 0.5s infinite alternate;
}

@keyframes timerPulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

/* Secret Role Card */
.my-role-card {
  text-align: center;
  border-width: 2px;
}

.role-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.role-icon-large {
  font-size: 2.2rem;
}

.role-subtitle {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.role-name {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.1;
}

.role-instruction {
  font-size: 0.92rem;
  color: #E2E8F0;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
}

/* Role Color Themes */
.role-card-mafia {
  border-color: var(--role-mafia);
  background: linear-gradient(135deg, rgba(226, 27, 60, 0.2), rgba(15, 23, 42, 0.9));
}
.role-card-mafia .role-name { color: var(--role-mafia); }

.role-card-doctor {
  border-color: var(--role-doctor);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(15, 23, 42, 0.9));
}
.role-card-doctor .role-name { color: var(--role-doctor); }

.role-card-detective {
  border-color: var(--role-detective);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(15, 23, 42, 0.9));
}
.role-card-detective .role-name { color: var(--role-detective); }

.role-card-citizen {
  border-color: var(--border-color);
  background: linear-gradient(135deg, rgba(148, 163, 184, 0.15), rgba(15, 23, 42, 0.9));
}
.role-card-citizen .role-name { color: #E2E8F0; }

/* Mafia Teammates & Detective Result Boxes */
.mafia-partners-box,
.detective-result-box {
  margin-top: 12px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.partners-title,
.detective-title {
  font-weight: 800;
  margin-bottom: 6px;
}

.partners-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.detective-content {
  font-weight: 700;
  font-size: 1.05rem;
}

/* Action Panels & Player Action Cards */
.panel-header {
  margin-bottom: 12px;
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 800;
}

.panel-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.action-players-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
  max-height: 280px;
  overflow-y: auto;
}

.action-player-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.action-player-card:hover {
  background: rgba(30, 41, 59, 0.8);
  border-color: rgba(255, 255, 255, 0.3);
}

.action-player-card.selected {
  border-color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.16);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.25);
  transform: scale(1.02);
}

.action-player-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.action-check {
  font-size: 1rem;
  opacity: 0;
  transition: var(--transition);
}

.action-player-card.selected .action-check {
  opacity: 1;
  color: var(--accent-gold);
}

.organizer-in-game {
  text-align: center;
}

/* Summary Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background: #141C2E;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.summary-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent-gold);
  margin-bottom: 12px;
}

.modal-message {
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 20px;
  color: #E2E8F0;
}

/* =========================================================================
   End Game Screen
   ========================================================================= */
.victory-header {
  text-align: center;
  padding: 16px 0;
}

.trophy-wrapper {
  font-size: 4rem;
  filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.6));
  animation: trophyFloat 2s infinite ease-in-out;
}

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

.victory-title {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--text-main);
  margin: 6px 0 10px;
}

.winner-pill {
  display: inline-block;
  background: rgba(251, 191, 36, 0.15);
  border: 1.5px solid var(--accent-gold);
  color: var(--accent-gold);
  padding: 6px 18px;
  border-radius: var(--radius-full);
  font-size: 1.15rem;
  font-weight: 700;
}

.end-players-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.end-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.end-player-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.end-player-role-tag {
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* =========================================================================
   Admin Screen & Dashboard
   ========================================================================= */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn.active {
  background: var(--color-red);
  color: #FFF;
  border-color: var(--color-red);
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.tab-content.active {
  display: flex;
}

.stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-icon {
  font-size: 1.8rem;
}

.stat-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text-main);
  line-height: 1;
  margin-top: 4px;
}

.stat-mafia .stat-value { color: var(--color-red); }
.stat-citizens .stat-value { color: #10B981; }

.admin-users-grid,
.admin-history-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.admin-user-row,
.admin-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
}

/* =========================================================================
   Toast Notifications
   ========================================================================= */
.toast-region {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}

.toast-msg {
  background: rgba(14, 19, 34, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  color: #FFF;
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  text-align: right;
}

.toast-success {
  border-color: #10B981;
  background: rgba(6, 78, 59, 0.92);
}

.toast-error {
  border-color: var(--color-red);
  background: rgba(127, 29, 29, 0.92);
}

.toast-info {
  border-color: var(--accent-gold);
  background: rgba(30, 41, 59, 0.95);
}

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

.toast-msg.leaving {
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.25s ease;
}

/* Custom Timer Settings in Lobby */
.timer-settings-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.timer-setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.time-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0;
}

.time-select {
  background: rgba(26, 34, 56, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #FFF;
  padding: 8px 12px;
  font-family: var(--font-arabic);
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
}

.time-select:focus {
  border-color: var(--accent-gold);
}

.secret-admin-trigger {
  background: transparent;
  border: none;
  color: var(--text-muted);
  opacity: 0.2;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 8px;
  transition: var(--transition);
  display: block;
  margin: 14px auto 0;
}

.secret-admin-trigger:hover {
  opacity: 0.8;
  color: var(--accent-gold);
}

.admin-auth-box {
  max-width: 380px;
}

/* Doctor Notice */
.doctor-notice {
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  color: #A7F3D0;
  text-align: center;
}

/* Mafia Night Chat */
.mafia-chat-box {
  margin-top: 14px;
  background: rgba(14, 19, 34, 0.95);
  border: 1.5px solid rgba(226, 27, 60, 0.4);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(226, 27, 60, 0.15);
}

.chat-header {
  background: rgba(226, 27, 60, 0.18);
  padding: 8px 12px;
  border-bottom: 1px solid rgba(226, 27, 60, 0.3);
  font-size: 0.85rem;
  font-weight: 800;
  color: #FFA5B4;
}

.chat-messages {
  height: 125px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
}

.chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.85rem;
  max-width: 90%;
  animation: fadeIn 0.15s ease;
}

.chat-msg.self {
  align-self: flex-start;
}

.chat-msg-bubble {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  line-height: 1.3;
}

.chat-msg.self .chat-msg-bubble {
  background: rgba(226, 27, 60, 0.25);
  border-color: rgba(226, 27, 60, 0.4);
}

.chat-msg-sender {
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--accent-gold);
  margin-bottom: 2px;
  display: block;
}

.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: rgba(15, 23, 42, 0.8);
  border-top: 1px solid var(--border-color);
}

.chat-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #FFF;
  padding: 6px 10px;
  font-family: var(--font-arabic);
  font-size: 0.85rem;
  outline: none;
}

.chat-input:focus {
  border-color: var(--color-red);
}
