/* Reset e Estilos Globais */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1e293b;
  user-select: none;
  -webkit-user-select: none;
}

/* Canvas Fullscreen */
#board {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  display: block;
  background-color: #ffffff;
  cursor: crosshair;
}

#board.eraser-mode {
  cursor: cell;
}

/* Barra de Ferramentas Flutuante */
.toolbar-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 9999px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.session-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2563eb;
}

.code-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  letter-spacing: 0.5px;
}

.icon-btn-small {
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background-color 0.15s;
}

.icon-btn-small:hover {
  color: #0f172a;
  background-color: #e2e8f0;
}

.user-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  padding: 4px 8px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #94a3b8;
  transition: background-color 0.2s, box-shadow 0.2s;
}

.status-dot.online {
  background-color: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.status-dot.reconnecting {
  background-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
  animation: pulseDot 1.2s infinite ease-in-out;
}

.status-dot.offline {
  background-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

@keyframes pulseDot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.3;
    transform: scale(0.75);
  }
}

.color-picker-container {
  position: relative;
  display: flex;
  align-items: center;
}

.color-picker-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  padding: 3px 6px 3px 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.color-picker-btn:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.color-picker-btn .chevron-icon {
  color: #64748b;
  transition: transform 0.2s ease;
}

.color-picker-container.open .chevron-icon {
  transform: rotate(180deg);
}

.color-dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #1e293b;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #cbd5e1;
  transition: transform 0.15s;
}

/* Dropdown da Paleta de 24 Cores */
.palette-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  width: 250px;
  z-index: 150;
  opacity: 1;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.palette-dropdown.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.palette-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}

.palette-header span {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}

.palette-hint {
  font-size: 11px;
  color: #64748b;
}

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

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #cbd5e1;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.color-swatch:hover:not(.disabled) {
  transform: scale(1.15);
  z-index: 2;
  box-shadow: 0 0 0 2px #2563eb;
}

.color-swatch.active {
  box-shadow: 0 0 0 2px #0f172a, 0 2px 4px rgba(0, 0, 0, 0.2);
  transform: scale(1.1);
}

.color-swatch.active::after {
  content: '✓';
  color: #ffffff;
  font-size: 13px;
  font-weight: bold;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.color-swatch.disabled {
  opacity: 0.25;
  cursor: not-allowed;
  filter: grayscale(40%);
}

.color-swatch.disabled::after {
  content: '✕';
  color: #ef4444;
  font-size: 14px;
  font-weight: 900;
  text-shadow: 0 0 2px #ffffff;
}

/* Seletor de Espessura do Traço */
.stroke-width-wrapper {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  padding: 4px 8px;
  transition: all 0.15s ease;
}

.stroke-width-wrapper:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.stroke-icon {
  color: #64748b;
  flex-shrink: 0;
}

.stroke-width-select {
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  outline: none;
  cursor: pointer;
  padding-right: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 22px;
  background-color: #e2e8f0;
  margin: 0 2px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background-color: transparent;
  width: 34px;
  height: 34px;
  border-radius: 9999px;
  color: #334155;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.tool-btn:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.tool-btn.active {
  background-color: #0f172a;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.15);
}

.tool-btn.active-fill {
  background-color: #eff6ff;
  color: #2563eb;
  border-color: #93c5fd;
}

/* Seletor de Formas */
.shapes-dropdown-container {
  position: relative;
}

.shape-trigger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: auto;
  min-width: 42px;
  padding: 0 6px;
}

.chevron-mini {
  color: #64748b;
  margin-left: 1px;
}

.tool-btn.active .chevron-mini {
  color: #cbd5e1;
}

.shapes-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 135px;
  z-index: 150;
}

.shapes-dropdown.hidden {
  display: none;
}

.shape-opt-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #334155;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s;
  width: 100%;
  text-align: left;
}

.shape-opt-btn:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.shape-opt-btn.active {
  background-color: #eff6ff;
  color: #2563eb;
  font-weight: 600;
}

/* Editor de Texto Flutuante no Canvas */
.text-editor-container {
  position: absolute;
  z-index: 100;
  pointer-events: auto;
}

.text-editor-container.hidden {
  display: none;
}

#textEditorInput {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 600;
  border: 1.5px dashed #2563eb;
  outline: none;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  border-radius: 6px;
  padding: 4px 8px;
  resize: none;
  overflow: hidden;
  line-height: 1.25;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  min-width: 130px;
  min-height: 32px;
}

.tool-btn.secondary {
  color: #475569;
}

.tool-btn.secondary:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.tool-btn.donate-btn:hover {
  color: #d97706;
  background-color: #fef3c7;
}

#langToggleBtn:hover {
  color: #2563eb;
  background-color: #eff6ff;
}

/* Modais e Overlays */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.modal-card h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #0f172a;
}

.modal-card p {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 16px;
  line-height: 1.4;
}

.modal-card input {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.modal-card input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

/* QR Code Modal */
.qr-modal-card {
  text-align: center;
  max-width: 360px;
}

.qr-canvas-wrapper {
  background: #ffffff;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin: 4px auto 14px auto;
}

#qrCanvas {
  display: block;
  width: 190px !important;
  height: 190px !important;
}

.qr-url-box {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  width: 100%;
}

.qr-url-box input {
  font-size: 12px;
  padding: 8px 10px;
  text-transform: none;
  letter-spacing: normal;
  color: #334155;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
}

.qr-url-box .btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.qr-hint {
  font-size: 11px !important;
  color: #64748b;
  margin-bottom: 12px !important;
}

.qr-hint.hidden {
  display: none;
}

/* Toast Notificações */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #0f172a;
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 300;
  opacity: 1;
  transition: transform 0.2s ease, opacity 0.2s ease;
  pointer-events: none;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
}

/* Modal de Boas-Vindas */
.welcome-modal-card {
  max-width: 500px;
  width: 92%;
  padding: 22px 24px;
}

.welcome-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.welcome-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #eff6ff;
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.welcome-header h3 {
  font-size: 18px;
  margin: 0 0 2px 0;
  color: #0f172a;
}

.welcome-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #059669;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 1px 8px;
  border-radius: 9999px;
}

.welcome-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}

.welcome-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 6px 0;
}

.welcome-list {
  margin: 0;
  padding-left: 20px;
  font-size: 12.5px;
  color: #475569;
  line-height: 1.5;
}

.welcome-list li {
  margin-bottom: 4px;
}

.welcome-section.privacy-alert {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.welcome-section.privacy-alert .alert-icon {
  color: #d97706;
  flex-shrink: 0;
  margin-top: 2px;
}

.welcome-section.privacy-alert h4 {
  color: #b45309;
  margin: 0 0 4px 0;
}

.welcome-section.privacy-alert p {
  font-size: 12px;
  color: #92400e;
  line-height: 1.45;
  margin: 0;
}

.welcome-section.support-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
}

.welcome-section.support-section p {
  font-size: 12px;
  color: #475569;
  line-height: 1.45;
  margin: 0 0 10px 0;
}

.welcome-donate-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffdd00;
  color: #000000;
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.welcome-donate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.welcome-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  gap: 10px;
}

.welcome-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  user-select: none;
}

.welcome-checkbox-label input {
  width: auto !important;
  margin: 0;
  cursor: pointer;
}

/* Botões exclusivos para telas menores (ocultos em desktop) */
.mobile-collapse-btn,
.mobile-fab-btn {
  display: none !important;
}

/* Responsividade Mobile */
@media (max-width: 640px) {
  .toolbar-container {
    top: auto;
    bottom: 14px;
    padding: 6px 8px;
    gap: 4px;
    width: calc(100% - 16px);
    max-width: 560px;
    justify-content: space-between;
    overflow-x: auto;
    scrollbar-width: none;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  }

  .toolbar-container.mobile-collapsed {
    transform: translateY(140%) scale(0.96);
    opacity: 0;
    pointer-events: none;
  }

  .mobile-collapse-btn {
    display: inline-flex !important;
    color: #64748b;
    flex-shrink: 0;
  }

  .mobile-collapse-btn:hover {
    color: #0f172a;
    background: #e2e8f0;
  }

  .mobile-fab-btn {
    display: flex !important;
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
    color: #1e293b;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 990;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  }

  .mobile-fab-btn.hidden {
    display: none !important;
  }

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

  .mobile-fab-color-dot {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  }

  .mobile-fab-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 9px;
    height: 9px;
    background-color: #ef4444;
    border-radius: 50%;
    border: 1.5px solid #ffffff;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.7);
    pointer-events: none;
    animation: pulseBadge 1.8s infinite;
  }

  .mobile-fab-badge.hidden {
    display: none !important;
  }

  .toolbar-container::-webkit-scrollbar {
    display: none;
  }

  .palette-dropdown {
    top: auto;
    bottom: calc(100% + 10px);
  }

  .shapes-dropdown {
    top: auto;
    bottom: calc(100% + 10px);
  }

  .tool-btn {
    width: 32px;
    height: 32px;
  }

  .stroke-width-wrapper {
    padding: 3px 5px;
  }

  .code-wrapper {
    font-size: 11px;
    padding: 2px 4px;
  }
}

/* ==========================================================================
   Chat da Sessão & Participantes (Drawer)
   ========================================================================== */

.chat-toggle-btn {
  position: relative;
}

.chat-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  background-color: #ef4444;
  border-radius: 50%;
  border: 1.5px solid #ffffff;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.7);
  pointer-events: none;
  animation: pulseBadge 1.8s infinite;
}

.chat-badge.hidden,
.hidden {
  display: none !important;
}

@keyframes pulseBadge {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.chat-drawer {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 340px;
  max-width: calc(100vw - 32px);
  z-index: 999;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.chat-drawer.hidden {
  transform: translateX(110%);
  opacity: 0;
  pointer-events: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
}

.chat-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: #0f172a;
}

.chat-close-btn {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.chat-close-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.chat-user-profile {
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.user-name-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.user-name-field label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.user-name-input-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}

.user-name-input-wrap input {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.user-name-input-wrap input:focus {
  border-color: #2563eb;
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.user-name-save-btn {
  padding: 6px 10px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.user-name-save-btn:hover {
  background: #1d4ed8;
}

.chat-participants-section {
  padding: 8px 16px;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
}

.participants-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 6px;
}

.participants-count-tag {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  color: #475569;
}

.participants-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 75px;
  overflow-y: auto;
}

.participant-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 11px;
  color: #334155;
  font-weight: 500;
}

.participant-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.participant-tag.is-you {
  border-color: #93c5fd;
  background: #eff6ff;
  font-weight: 600;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-empty-state {
  margin: auto;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  padding: 20px;
}

.chat-message-bubble {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 88%;
}

.chat-message-bubble.is-mine {
  align-self: flex-end;
}

.chat-message-bubble.is-other {
  align-self: flex-start;
}

.msg-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
}

.chat-message-bubble.is-mine .msg-header {
  justify-content: flex-end;
}

.msg-author {
  font-weight: 600;
}

.msg-time {
  color: #94a3b8;
  font-size: 10px;
}

.msg-body {
  background: #f1f5f9;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13px;
  color: #1e293b;
  line-height: 1.4;
  word-break: break-word;
}

.chat-message-bubble.is-mine .msg-body {
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 3px;
}

.chat-message-bubble.is-other .msg-body {
  border-bottom-left-radius: 3px;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
}

.chat-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  background: #f8fafc;
  color: #0f172a;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chat-input:focus {
  border-color: #2563eb;
  background: #ffffff;
  outline: none;
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}

.chat-send-btn:hover {
  background: #1d4ed8;
}

.chat-send-btn:active {
  transform: scale(0.95);
}

@media (max-width: 640px) {
  .chat-drawer {
    top: 12px;
    right: 12px;
    left: 12px;
    bottom: 74px;
    width: auto;
    max-width: none;
  }
}

/* ==========================================================================
   Modo Game (Milestone Modo Game - Etapa 1)
   ========================================================================== */

/* Barra Superior Flutuante do Jogo em Andamento */
.game-bar {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 95;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  padding: 6px 14px;
  animation: slideDownFade 0.25s ease-out;
}

.game-bar.hidden {
  display: none !important;
}

.game-bar-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.game-bar-info-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-bar-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
}

.game-bar-status {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #334155;
  white-space: nowrap;
}

.game-bar-status.my-turn {
  background: #dbeafe;
  color: #1d4ed8;
  animation: pulseLight 1.8s infinite ease-in-out;
}

.game-bar-status.win {
  background: #dcfce7;
  color: #15803d;
}

.game-bar-status.tie {
  background: #fef3c7;
  color: #b45309;
}

.game-bar-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-bar-score {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  padding: 3px 10px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.game-bar-spectators {
  font-size: 11px;
  color: #64748b;
  font-style: italic;
  white-space: nowrap;
}

.game-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.game-btn-rules {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

.game-btn-rules:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.game-btn-rematch {
  background: #2563eb;
  color: #ffffff;
}

.game-btn-rematch:hover {
  background: #1d4ed8;
}

.game-btn-rematch.hidden {
  display: none !important;
}

.game-btn-leave {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

.game-btn-leave:hover {
  background: #fca5a5;
  color: #991b1b;
}

/* Modal do Catálogo de Jogos */
.games-modal-card {
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.games-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.games-modal-header h3 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.games-modal-header p {
  margin: 0;
  font-size: 13px;
  color: #64748b;
}

.games-catalog-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
}

.game-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.game-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.05);
}

.game-card.playable {
  border-color: #93c5fd;
  background: #f8faff;
}

.game-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.game-card-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-card-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.game-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  white-space: nowrap;
}

.badge-players {
  background: #f1f5f9;
  color: #475569;
}

.badge-duration {
  background: #fef3c7;
  color: #92400e;
}

.badge-available {
  background: #dcfce7;
  color: #166534;
}

.badge-soon {
  background: #f1f5f9;
  color: #94a3b8;
}

.game-card-desc {
  font-size: 13px;
  color: #475569;
  line-height: 1.45;
  margin: 0 0 10px 0;
}

.game-card-rules-details {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.game-card-rules-details summary {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  cursor: pointer;
  user-select: none;
}

.game-card-rules-details summary:hover {
  text-decoration: underline;
}

.game-card-rules-content {
  margin-top: 8px;
  font-size: 12px;
  color: #334155;
  line-height: 1.5;
  padding-left: 14px;
}

.game-card-actions {
  display: flex;
  justify-content: flex-end;
}

.game-start-btn {
  background: #2563eb;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.game-start-btn:hover {
  background: #1d4ed8;
}

.game-start-btn:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
}

/* Modal de Regras do Jogo */
.game-rules-card {
  max-width: 540px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.game-rules-body {
  overflow-y: auto;
  font-size: 13px;
  color: #334155;
  line-height: 1.6;
  padding-right: 4px;
  margin-bottom: 16px;
}

.game-rules-body h4 {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin: 12px 0 6px 0;
}

.game-rules-body ul {
  margin: 0 0 10px 0;
  padding-left: 18px;
}

.game-rules-body li {
  margin-bottom: 4px;
}

@media (max-width: 640px) {
  .game-bar {
    top: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    border-radius: 14px;
    padding: 8px 10px;
  }

  .game-bar-content {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
  }

  .game-bar-center {
    width: 100%;
    justify-content: space-between;
  }

  .game-bar-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

