@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
  /* Colors - Dark Fire Theme */
  --bg-dark: #0d0d14;
  --bg-darker: #070710;
  --bg-card: #1a1a2e;
  --bg-card-hover: #222240;
  
  /* Glassmorphism */
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.1);
  
  /* Brand Colors */
  --fire-orange: #ff6b35;
  --fire-red: #ef4444;
  --fire-gradient: linear-gradient(135deg, var(--fire-orange), var(--fire-red));
  
  /* Status Colors */
  --safe-green: #22c55e;
  --info-blue: #3b82f6;
  --correct: #22c55e;
  --incorrect: #ef4444;
  
  /* Team Colors */
  --team-blue: #3b82f6;
  --team-yellow: #f59e0b;
  --team-red: #ef4444;
  --team-green: #22c55e;
  --team-purple: #8b5cf6;
  --team-purple-light: #a78bfa;
  
  /* Text */
  --text-primary: #f1f1f1;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow-fire: 0 0 15px rgba(255, 107, 53, 0.5);
  --shadow-glow-green: 0 0 15px rgba(34, 197, 94, 0.5);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: 'Prompt', sans-serif;
  font-size: 1.2rem;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  word-break: keep-all; /* Prevent Thai words from tearing in the middle */
  line-break: strict;
  overflow-wrap: break-word;
}

/* Base Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition-normal);
  text-decoration: none;
  outline: none;
  height: auto;
  white-space: normal;
  line-height: 1.3;
  text-align: center;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary {
  background: var(--fire-gradient);
  color: white;
}

.btn-primary:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-glow-fire);
}

.btn-secondary {
  background: var(--glass);
  color: white;
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background-color: var(--fire-red);
  color: white;
}

.btn-success {
  background-color: var(--safe-green);
  color: white;
}

.btn-large {
  padding: var(--space-md) var(--space-xl);
  font-size: 1.4rem;
  min-height: 60px;
}

.btn-choice-a {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
}

.btn-choice-b {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
}

.card-glass {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.card-role {
  position: relative;
  overflow: hidden;
}

.card-role::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  background-color: currentColor;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
}

.badge-commander { background-color: rgba(139, 92, 246, 0.2); color: var(--team-purple); }
.badge-vice-commander { background-color: rgba(167, 139, 250, 0.2); color: var(--team-purple-light); }
.badge-evacuator { background-color: rgba(59, 130, 246, 0.2); color: var(--team-blue); }
.badge-firefighter { background-color: rgba(239, 68, 68, 0.2); color: var(--team-red); }
.badge-medic { background-color: rgba(34, 197, 94, 0.2); color: var(--team-green); }
.badge-alert { background-color: rgba(245, 158, 11, 0.2); color: var(--team-yellow); }

/* Evacuation Phase Tracker (Based on 5 Phases) */
.phase-tracker-container {
  width: 100%;
  padding: var(--space-md) 0;
  margin-bottom: var(--space-lg);
  overflow-x: auto;
}

.phase-tracker {
  display: flex;
  justify-content: space-between;
  position: relative;
  min-width: 600px;
}

.phase-tracker::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 30px;
  right: 30px;
  height: 3px;
  background-color: var(--glass-border);
  z-index: 0;
}

.phase-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
  width: 20%;
  text-align: center;
}

.phase-step-dot {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--bg-card);
  border: 2px solid var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--text-muted);
  transition: all var(--transition-normal);
  margin-bottom: var(--space-sm);
}

.phase-step.active .phase-step-dot {
  border-color: var(--fire-orange);
  background: var(--fire-gradient);
  color: white;
  box-shadow: var(--shadow-glow-fire);
  transform: scale(1.1);
}

.phase-step.completed .phase-step-dot {
  border-color: var(--safe-green);
  background-color: var(--safe-green);
  color: white;
  box-shadow: var(--shadow-glow-green);
}

.phase-step-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--transition-normal);
  white-space: pre-line;
  line-height: 1.3;
}

.phase-step.active .phase-step-label {
  color: var(--fire-orange);
  text-shadow: 0 0 10px rgba(255, 107, 53, 0.3);
}

.phase-step.completed .phase-step-label {
  color: var(--text-primary);
}

/* Avatars */
.avatar-circle {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  background-color: var(--bg-card);
  border: 4px solid var(--glass-border);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-full);
  z-index: 50;
  animation: slideInUp 0.3s ease-out forwards;
}

/* Typography Utilities */
.text-fire { color: var(--fire-orange); }
.text-safe { color: var(--safe-green); }
.text-danger { color: var(--fire-red); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.font-inter { font-family: 'Inter', sans-serif; }

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg);
  min-height: 100vh;
}

.screen.active {
  display: flex;
}

/* Specific UI Elements */
.room-code {
  font-family: 'Inter', monospace;
  font-size: 4rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-primary);
  text-shadow: var(--shadow-glow-fire);
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: 100%;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
}

.scenario-text {
  font-size: 1.5rem;
  line-height: 1.6;
  font-weight: 500;
  text-align: center;
  margin: var(--space-lg) 0;
}

.explanation-box {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border-left: 4px solid var(--glass-border);
}

.explanation-box.correct { border-left-color: var(--safe-green); }
.explanation-box.incorrect { border-left-color: var(--fire-red); }

.result-icon {
  font-size: 5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: var(--space-md);
}

.result-correct { color: var(--safe-green); text-shadow: var(--shadow-glow-green); }
.result-incorrect { color: var(--fire-red); text-shadow: var(--shadow-glow-fire); }

/* Layout Utilities */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Margin/Padding Utilities */
.mt-1 { margin-top: var(--space-xs); }
.mt-2 { margin-top: var(--space-sm); }
.mt-3 { margin-top: var(--space-md); }
.mt-4 { margin-top: var(--space-lg); }
.mb-1 { margin-bottom: var(--space-xs); }
.mb-2 { margin-bottom: var(--space-sm); }
.mb-3 { margin-bottom: var(--space-md); }
.mb-4 { margin-bottom: var(--space-lg); }
.gap-1 { gap: var(--space-xs); }
.gap-2 { gap: var(--space-sm); }
.gap-3 { gap: var(--space-md); }
