:root {
  --bg-primary: #090916;      /* Sleek deep space dark */
  --bg-secondary: #11112b;    /* Synthwave dashboard dark */
  --bg-card: #18183c;         /* Card background */
  --text-primary: #f8fafc;    /* Clean slate white */
  --text-secondary: #cbd5e1;  /* Slate gray-white */
  --text-muted: #64748b;      /* Slate muted gray */
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --accent-purple: #a78bfa;   /* Vibrant neon violet */
  --accent-rose: #f43f5e;     /* High-energy rose */
  --border-color: rgba(167, 139, 250, 0.2); /* Neon outline */
  --radius: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-primary);
}

.app-container.multiplayer {
  flex-direction: column;
}

/* ─── Top Navbar ─────────────────────────────── */
.navbar {
  height: 60px;
  width: 100%;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 20;
  box-shadow: 0 4px 20px rgba(167, 139, 250, 0.08);
}

.navbar-logo {
  font-family: 'Fredoka', cursive;
  font-size: 24px;
  font-weight: 900;
  color: var(--accent-purple);
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 0 0 10px rgba(167, 139, 250, 0.4);
}

.navbar-room {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
}

.room-id-badge {
  background: rgba(167, 139, 250, 0.15);
  color: var(--accent-purple);
  border: 1px solid var(--border-color);
  padding: 4px 12px;
  border-radius: 8px;
  font-weight: 800;
  font-family: monospace;
  letter-spacing: 1px;
}

.main-content {
  display: flex;
  flex: 1;
  width: 100%;
  overflow: hidden;
}

/* ─── Left Panel (Leaderboard & Info) ────────── */
.left-panel {
  width: 320px;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-right: 2px solid var(--border-color);
  padding: 24px;
  gap: 20px;
  z-index: 10;
}

/* ─── Info Card ──────────────────────────────── */
.info-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 2px solid var(--border-color) !important;
  padding: 20px;
  box-shadow: 0 4px 25px rgba(167, 139, 250, 0.05) !important;
  text-align: center;
  width: 100%;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.info-card:hover {
  box-shadow: 0 8px 30px rgba(167, 139, 250, 0.12) !important;
  border-color: rgba(167, 139, 250, 0.4) !important;
}

.category-badge {
  display: inline-block;
  background: var(--accent-purple);
  color: var(--bg-primary);
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.2);
}

.word-blanks {
  font-weight: 800;
  letter-spacing: 4px;
  text-align: center;
  color: var(--text-primary);
  font-family: 'Fredoka', sans-serif;
  margin: 10px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

/* ─── Leaderboard ────────────────────────────── */
.leaderboard {
  flex: 1;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 2px solid var(--border-color) !important;
  padding: 20px;
  overflow-y: auto;
  box-shadow: 0 4px 25px rgba(167, 139, 250, 0.05) !important;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.leaderboard:hover {
  box-shadow: 0 8px 30px rgba(167, 139, 250, 0.12) !important;
  border-color: rgba(167, 139, 250, 0.4) !important;
}

.leaderboard-title {
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 14px;
  letter-spacing: 1.5px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.user-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(167, 139, 250, 0.06);
  border: 1px solid rgba(167, 139, 250, 0.1);
  border-radius: 12px;
  font-weight: 700;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.user-item:hover {
  transform: translateY(-2px);
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.25);
}

.user-name {
  color: var(--text-primary);
}

.user-score {
  color: var(--accent-green);
  font-weight: 900;
  text-shadow: 0 0 5px rgba(16, 185, 129, 0.2);
}

/* ─── Center: Canvas Panel ───────────────────── */
.canvas-panel {
  flex: 1;
  height: 100%;
  background: #ffffff;
  position: relative;
  min-width: 0;
}

.canvas-wrapper {
  width: 100%;
  height: 100%;
}

/* Hide Excalidraw chrome */
.excalidraw .layer-ui__wrapper__top-right,
.excalidraw .layer-ui__wrapper__bottom,
.excalidraw .disable-zen-mode,
.excalidraw .App-menu_top,
.excalidraw .Island,
.excalidraw .Stack {
  display: none !important;
}

/* ─── Start Game Canvas Overlay ──────────────── */
.start-game-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 40;
  animation: popIn 0.4s ease-out;
}

.start-game-btn {
  font-size: 36px !important;
  padding: 24px 48px !important;
  border-radius: 24px !important;
  font-family: 'Fredoka', cursive;
  font-weight: 900;
  letter-spacing: 2px;
  animation: pulse 2s ease-in-out infinite;
  width: auto !important;
}

.start-game-tip {
  font-size: 15px;
  color: var(--text-muted);
  font-weight: 600;
  font-style: italic;
  background: rgba(167, 139, 250, 0.1);
  padding: 8px 20px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3); }
  50% { box-shadow: 0 4px 30px rgba(16, 185, 129, 0.6), 0 0 40px rgba(16, 185, 129, 0.2); }
}

.streaming-indicator {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(167, 139, 250, 0.15);
  border: 2px solid var(--border-color);
  color: var(--accent-purple);
  padding: 8px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 800;
  z-index: 20;
  box-shadow: 0 0 15px rgba(167, 139, 250, 0.2);
}

.streaming-dot {
  width: 10px;
  height: 10px;
  background: var(--accent-purple);
  border-radius: 50%;
  animation: blink 1s step-start infinite;
  box-shadow: 0 0 8px var(--accent-purple);
}

@keyframes blink { 50% { opacity: 0; } }

/* ─── Web Player Bordered Countdown (Legibility Fix) ─── */
@keyframes popInOverlay {
  0% { transform: translate(-50%, -50%) scale(0.85); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.countdown-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 140px;
  font-family: 'Fredoka', cursive;
  font-weight: 900;
  color: var(--accent-purple);
  z-index: 50;
  animation: popInOverlay 0.5s ease-out;
  
  /* Thick white border outline around purple numbers for camouflage protection */
  -webkit-text-stroke: 6px #ffffff;
  text-stroke: 6px #ffffff;
  paint-order: stroke fill;
  
  /* Glowing purple drop-shadow matrix */
  text-shadow: 
    0 0 20px rgba(255, 255, 255, 0.8),
    0 4px 30px rgba(167, 139, 250, 0.6);
}

/* ─── Right Panel: Chat ──────────────────────── */
.chat-panel {
  width: 350px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-left: 2px solid var(--border-color);
  padding: 24px;
  gap: 20px;
  z-index: 10;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 2px solid var(--border-color) !important;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(167, 139, 250, 0.04) !important;
}

.chat-message {
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-username {
  font-weight: 800;
  color: var(--accent-purple);
}

.chat-text {
  color: var(--text-primary);
}

.chat-system {
  font-style: italic;
  font-weight: 500;
  color: var(--accent-amber);
  font-size: 12px;
  display: block;
  text-align: center;
  margin: 6px 0;
  background: rgba(245, 158, 11, 0.1);
  padding: 6px 12px;
  border-radius: 8px;
  white-space: pre-line;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.chat-input-form {
  display: flex;
  gap: 10px;
}

.guess-input {
  flex: 1;
  background: rgba(167, 139, 250, 0.05);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.guess-input:focus {
  background: var(--bg-secondary);
  border-color: var(--accent-purple);
  box-shadow: 0 0 15px rgba(167, 139, 250, 0.2);
}

.guess-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mic-btn {
  font-size: 20px;
  width: 48px;
  height: 48px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(167, 139, 250, 0.1);
  color: var(--text-muted);
  transition: all 0.2s ease;
  flex-shrink: 0;
  border: 2px solid transparent;
}

.send-btn {
  font-size: 18px;
  width: 48px;
  height: 48px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  flex-shrink: 0;
}

.mic-btn.mic-off {
  opacity: 0.4;
}

.mic-btn.mic-active {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  opacity: 1;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
  animation: micPulse 1.2s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(239, 68, 68, 0.2); }
  50% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.5); }
}

/* ─── Buttons (Sleek Micro-interactions) ─────── */
.btn {
  border: none;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  padding: 12px 24px;
}

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

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

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: white;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #6d28d9, #8b5cf6);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(167, 139, 250, 0.15);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  width: 100%;
  font-size: 16px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(:disabled) {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-sm {
  padding: 6px 16px !important;
  font-size: 13px !important;
  border-radius: 8px !important;
}

/* ─── Modals (Glassmorphic Dark) ─────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10, 10, 22, 0.7);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  padding: 40px;
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(167, 139, 250, 0.15);
  text-align: center;
  width: 100%;
  max-width: 400px;
  animation: popIn 0.4s ease-out;
  color: var(--text-primary);
}

.modal-title {
  font-family: 'Fredoka', cursive;
  font-size: 28px;
  font-weight: 900;
  color: var(--accent-purple);
  margin-bottom: 8px;
  text-shadow: 0 0 10px rgba(167, 139, 250, 0.3);
}

.modal-subtitle {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-weight: 600;
}

@keyframes popIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ─── Mobile Responsiveness ──────────────────── */
@media (max-width: 900px) {
  .main-content {
    flex-direction: column;
    overflow-y: auto;
    height: calc(100vh - 50px);
  }

  .left-panel {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 12px;
    gap: 12px;
    border-right: none;
    border-bottom: 2px solid var(--border-color);
  }

  .info-card {
    flex: 1.2;
    padding: 12px;
  }

  .word-blanks {
    font-size: 22px;
    letter-spacing: 2px;
  }

  .leaderboard {
    flex: 0.8;
    padding: 12px;
    max-height: 140px;
    height: auto;
  }

  .leaderboard-title {
    font-size: 11px;
    margin-bottom: 6px;
    text-align: center;
    padding-bottom: 4px;
  }

  .user-list {
    gap: 4px;
  }

  .user-item {
    padding: 6px 10px;
    font-size: 12px;
  }

  .canvas-panel {
    min-height: 360px;
    height: 45vh;
    border-bottom: 2px solid var(--border-color);
  }

  .chat-panel {
    width: 100%;
    height: 300px;
    border-left: none;
    padding: 12px;
    gap: 12px;
  }

  .chat-history {
    padding: 10px;
  }

  .navbar {
    padding: 0 16px;
    height: 50px;
  }

  .navbar-logo {
    font-size: 18px;
  }

  .navbar-room {
    font-size: 12px;
  }

  .room-id-badge {
    padding: 2px 6px;
  }

  .btn-sm {
    padding: 4px 10px !important;
    font-size: 11px !important;
  }
  
  .countdown-overlay {
    font-size: 90px;
    -webkit-text-stroke: 4px #ffffff;
    text-stroke: 4px #ffffff;
  }
}
