/* ===== CSS RESET & VARIABLES ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-dark: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #252542;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-success: #10b981;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;
  --accent-timer: #22c55e;
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --gradient-card: linear-gradient(135deg, #1a1a2e 0%, #252542 100%);
  --gradient-accent: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);
  --shadow-card: 0 10px 40px rgba(0, 0, 0, 0.4);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
}

/* ===== BASE STYLES ===== */
html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ===== CONTAINER ===== */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
.header {
  text-align: center;
  padding: 0.5rem 0 1rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.tagline {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ===== SCOREBOARD ===== */
.scoreboard {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.team-card {
  flex: 1;
  background: var(--gradient-card);
  border-radius: var(--radius-lg);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-card);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.team-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-accent);
}

.team-card.active {
  transform: scale(1.02);
  box-shadow: var(--shadow-glow);
}

.team-alpha::before {
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

.team-bravo::before {
  background: linear-gradient(90deg, #10b981, #22c55e);
}

.team-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.team-score {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.team-alpha .team-score {
  color: var(--accent-primary);
}

.team-bravo .team-score {
  color: var(--accent-success);
}

/* ===== SPEAKER INFO ===== */
.speaker-info {
  text-align: center;
  margin-bottom: 1rem;
}

.speaker-name {
  font-size: 1rem;
  color: var(--text-secondary);
}

.speaker-name span {
  font-weight: 700;
  color: var(--accent-warning);
}

/* ===== STATS BAR ===== */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.stat {
  text-align: center;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== TIMER ===== */
.timer-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.timer {
  font-size: 5rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent-timer);
  text-shadow: 0 0 30px rgba(34, 197, 94, 0.4);
  transition: all 0.3s ease;
}

.timer.warning {
  color: var(--accent-warning);
  text-shadow: 0 0 30px rgba(245, 158, 11, 0.4);
}

.timer.danger {
  color: var(--accent-danger);
  text-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
  animation: pulse-danger 0.5s ease infinite;
}

@keyframes pulse-danger {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.timer-progress {
  width: 200px;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.timer-progress-bar {
  height: 100%;
  background: var(--gradient-accent);
  border-radius: 3px;
  transition: width 1s linear;
}

/* ===== CARD ===== */
.card-container {
  perspective: 1000px;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--gradient-card);
  border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  animation: card-appear 0.5s ease;
}

@keyframes card-appear {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-accent);
}

.card-glow {
  position: absolute;
  inset: -50%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.card-word {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  line-height: 1.2;
  position: relative;
  z-index: 1;
}

.card-landmines {
  font-size: 0.9rem;
  color: var(--accent-danger);
  line-height: 1.8;
  position: relative;
  z-index: 1;
}

.card-landmines span {
  opacity: 0.8;
}

.card-landmines strong {
  color: var(--accent-danger);
  font-weight: 700;
}

/* ===== CONTROLS ===== */
.controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.controls-row {
  display: flex;
  gap: 0.75rem;
}

.controls-row button {
  flex: 1;
}

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

button:active {
  transform: scale(0.98);
}

.btn-correct {
  background: var(--gradient-accent);
  color: white;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-correct:hover {
  box-shadow: 0 6px 30px rgba(99, 102, 241, 0.5);
}

.btn-skip {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid var(--bg-card-hover);
}

.btn-skip:hover {
  background: var(--bg-card-hover);
}

.btn-mine {
  background: var(--bg-card);
  color: var(--accent-danger);
  border: 2px solid var(--accent-danger);
}

.btn-mine:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-new-game {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.75rem;
}

.btn-new-game:hover {
  color: var(--text-secondary);
}

/* ===== OVERLAY SCREENS ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 26, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 0.3s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
  padding: 2rem;
  max-width: 360px;
}

.overlay-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.overlay-subtitle {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.overlay button {
  width: 100%;
}

/* ===== SETTINGS PANEL ===== */
.settings-panel {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.settings-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-align: center;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--bg-card-hover);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.setting-input {
  width: 80px;
  padding: 0.5rem;
  border: 2px solid var(--bg-card-hover);
  border-radius: var(--radius-sm);
  background: var(--bg-dark);
  color: var(--text-primary);
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
}

.setting-input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* ===== STATISTICS PANEL ===== */
.stats-panel {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.stat-item {
  text-align: center;
  padding: 1rem;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
}

.stat-item-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.stat-item-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ===== EXPLOSION EFFECT ===== */
.explosion {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle, rgba(239, 68, 68, 0.9) 0%, rgba(245, 158, 11, 0.6) 50%, transparent 70%);
  animation: explosion-burst 0.6s ease-out forwards;
  z-index: 9999;
  pointer-events: none;
}

@keyframes explosion-burst {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

.shake {
  animation: screen-shake 0.4s ease;
}

@keyframes screen-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-1deg); }
  40% { transform: translateX(10px) rotate(1deg); }
  60% { transform: translateX(-8px) rotate(-0.5deg); }
  80% { transform: translateX(5px) rotate(0.5deg); }
}

/* ===== CORRECT EFFECT ===== */
.correct-flash {
  position: fixed;
  inset: 0;
  background: rgba(16, 185, 129, 0.3);
  animation: correct-burst 0.5s ease-out forwards;
  z-index: 9998;
  pointer-events: none;
}

@keyframes correct-burst {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* ===== TOGGLE SWITCH ===== */
.toggle {
  position: relative;
  width: 50px;
  height: 28px;
  background: var(--bg-dark);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.toggle.active {
  background: var(--accent-primary);
}

.toggle::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.toggle.active::before {
  transform: translateX(22px);
}

/* ===== SOUND TOGGLE ===== */
.sound-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
}

.sound-toggle svg {
  width: 24px;
  height: 24px;
  fill: var(--text-secondary);
}

.sound-toggle.muted svg {
  fill: var(--accent-danger);
}

/* ===== PROGRESS BAR ===== */
.progress-container {
  margin-bottom: 1rem;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
}

.progress-bar {
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ===== SWIPE INDICATORS ===== */
.swipe-indicators {
  display: none;
  justify-content: space-between;
  padding: 0.5rem 2rem;
  opacity: 0.5;
}

.swipe-indicators.visible {
  display: flex;
}

.swipe-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 400px) {
  .card-word {
    font-size: 2rem;
  }
  
  .timer {
    font-size: 4rem;
  }
  
  .team-score {
    font-size: 1.5rem;
  }
}

@media (min-width: 768px) {
  .container {
    max-width: 600px;
  }
  
  .controls-row {
    max-width: 400px;
    margin: 0 auto;
  }
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  z-index: 1001;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-left: 4px solid var(--accent-success);
}

.toast.error {
  border-left: 4px solid var(--accent-danger);
}

.toast.warning {
  border-left: 4px solid var(--accent-warning);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* MENU SCREEN */
/* ═══════════════════════════════════════════════════════════════════════════ */
#menu-screen {
  padding: 1rem;
}

.menu-section {
  background: var(--gradient-card);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.menu-section h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  text-align: center;
}

.input-group {
  margin-bottom: 0.75rem;
}

.input-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--bg-card-hover);
  border-radius: var(--radius-md);
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 1rem;
  text-align: center;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.rooms-list {
  max-height: 200px;
  overflow-y: auto;
}

.rooms-list .loading,
.rooms-list .empty {
  text-align: center;
  color: var(--text-muted);
  padding: 1rem;
}

.room-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.room-item:hover {
  background: var(--bg-card-hover);
}

.room-item span:first-child {
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* ROOM INFO */
/* ═══════════════════════════════════════════════════════════════════════════ */
.room-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
}

.room-info span {
  font-family: monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* TEAM PLAYERS */
/* ═══════════════════════════════════════════════════════════════════════════ */
.team-players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
  justify-content: center;
}

.player-tag {
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.player-tag.speaker {
  background: var(--accent-warning);
  color: var(--bg-dark);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* SPEAKER STATUS */
/* ═══════════════════════════════════════════════════════════════════════════ */
.speaker-status {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.speaker-status.is-speaker {
  color: var(--accent-warning);
  font-weight: 600;
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* HIDDEN STATE */
/* ═══════════════════════════════════════════════════════════════════════════ */
#game-screen.hidden {
  display: none;
}

#menu-screen.hidden {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* HELP OVERLAY */
/* ═══════════════════════════════════════════════════════════════════════════ */
.help-section {
  text-align: left;
  margin-bottom: 1.5rem;
}

.help-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}

.help-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.help-text {
  flex: 1;
}

.help-text strong {
  display: block;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.help-text p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.4;
}

.help-controls {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bg-card-hover);
}

.help-controls h3 {
  text-align: center;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.control-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
}

.control-item .key {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: var(--accent-primary);
  color: white;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.control-item span:last-child {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* SCROLLABLE OVERLAY */
.overlay-content.scrollable {
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: 1rem;
}
