/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Maintenance banner */
.maintenance-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: linear-gradient(135deg, #e65100, #ff8f00);
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  animation: maintenancePulse 3s ease-in-out infinite;
}

@keyframes maintenancePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* Notification modal */
.notification-modal-content {
  text-align: center;
  max-width: 360px;
}

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

.notification-title {
  color: #4caf50;
  margin-bottom: 12px;
}

.notification-text {
  color: #b0bec5;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Modern toast notifications */
.app-toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(92vw, 380px);
  pointer-events: none;
}

.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(79, 195, 247, 0.32);
  background: linear-gradient(145deg, rgba(10, 28, 49, 0.96), rgba(12, 37, 64, 0.96));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.4);
  color: #d8ecff;
  font-size: 0.92rem;
  animation: appToastIn 220ms ease-out;
}

.app-toast-error {
  border-color: rgba(239, 83, 80, 0.5);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(239, 83, 80, 0.18) inset;
}

.app-toast-success {
  border-color: rgba(76, 175, 80, 0.5);
}

.app-toast-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.app-toast-text {
  flex: 1;
  line-height: 1.35;
}

.app-toast-close {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: rgba(79, 195, 247, 0.14);
  color: #b9def8;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.app-toast-close:hover {
  background: rgba(79, 195, 247, 0.24);
}

.app-toast-out {
  animation: appToastOut 220ms ease-in forwards;
}

@keyframes appToastIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes appToastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-5px) scale(0.98); }
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #0a1628, #0d2137, #0a1628);
  color: #fff;
  overflow: hidden;
  height: 100vh;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  width: 100%;
  height: 100vh;
  justify-content: center;
  align-items: center;
}

.screen.active {
  display: flex;
}

/* ===== MENU SCREEN ===== */
.menu-container {
  background: linear-gradient(145deg, #ffffff, #e8f4fd);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(79, 195, 247, 0.1);
  min-width: 380px;
}

.menu-header h1 {
  font-size: 2.4rem;
  color: #1a73e8;
  margin-bottom: 4px;
  text-shadow: 0 2px 10px rgba(26, 115, 232, 0.2);
}

.subtitle {
  color: #5a7a9a;
  font-size: 0.95rem;
  margin-bottom: 32px;
}

.menu-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #b0d4f1;
  border-radius: 10px;
  background: #fff;
  color: #1a2a3a;
  font-size: 1rem;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.menu-input:focus {
  border-color: #4FC3F7;
  box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.2);
}

.menu-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.menu-btn.primary {
  background: linear-gradient(135deg, #4FC3F7, #1a73e8);
  color: white;
}

.menu-btn.primary:hover {
  background: linear-gradient(135deg, #6dd5fa, #4FC3F7);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 195, 247, 0.4);
}

.menu-btn.secondary {
  background: linear-gradient(135deg, #0d47a1, #1565c0);
  color: white;
}

.menu-btn.secondary:hover {
  background: linear-gradient(135deg, #1565c0, #1976d2);
  transform: translateY(-2px);
}

.menu-btn.cancel {
  background: #cfd8dc;
  color: #455a64;
  width: auto;
  padding: 10px 32px;
}

.menu-footer {
  margin-top: 24px;
  color: #90a4ae;
  font-size: 0.85rem;
}

.menu-footer .copyright {
  margin-top: 8px;
  font-size: 0.75rem;
  color: #607d8b;
}

/* ===== ACTIVE TABLE BANNER ===== */
.active-table-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1b5e20, #2e7d32);
  border: 1px solid #43a047;
  border-radius: 12px;
  padding: 12px 16px;
  margin-top: 12px;
  animation: atb-pulse 2s ease-in-out infinite;
}

@keyframes atb-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
  50% { box-shadow: 0 0 12px 4px rgba(76, 175, 80, 0.2); }
}

.atb-icon {
  font-size: 14px;
  animation: atb-blink 1.5s ease-in-out infinite;
}

@keyframes atb-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.atb-text {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #e8f5e9;
}

.atb-cancel {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.atb-cancel:hover {
  background: rgba(244, 67, 54, 0.5);
}

/* ===== LOBBY SCREEN ===== */
.lobby-container {
  width: 100%;
  max-width: 650px;
  margin: 0 auto;
  padding: 32px 24px 16px 24px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.lobby-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-bottom: 16px;
  gap: 10px;
}

.lobby-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lobby-header h2 {
  color: #4FC3F7;
  margin: 0;
  font-size: 1.4rem;
}

.online-badge {
  background: rgba(76, 175, 80, 0.15);
  color: #66BB6A;
  border: 1px solid rgba(76, 175, 80, 0.3);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

#lobby-screen.active {
  align-items: flex-start;
}

.lobby-actions {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.lobby-actions .menu-btn {
  flex: 1;
  padding: 0 16px;
  font-size: 0.9rem;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  margin: 0 !important;
}

/* ===== LOBBY TABS ===== */
.lobby-tabs {
  display: flex;
  gap: 0;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
}

.lobby-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  color: #78909c;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  border-radius: 8px;
  white-space: nowrap;
  text-align: center;
}

.lobby-tab:hover {
  color: #b0bec5;
  background: rgba(255, 255, 255, 0.05);
}

.lobby-tab.active {
  color: #fff;
  background: rgba(79, 195, 247, 0.2);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.lobby-tab.active[data-lobby-tab="jogos"] {
  background: rgba(255, 167, 38, 0.2);
}

.lobby-tab-count {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  margin-left: 4px;
  vertical-align: middle;
}

.lobby-tab-count:empty {
  display: none;
}

.lobby-tab.active .lobby-tab-count {
  background: rgba(79, 195, 247, 0.3);
  color: #fff;
}

.lobby-tab.active[data-lobby-tab="jogos"] .lobby-tab-count {
  background: rgba(255, 167, 38, 0.3);
  color: #fff;
}

.lobby-tab:not(.active) .lobby-tab-count {
  background: rgba(255, 255, 255, 0.1);
  color: #90a4ae;
}

/* Lobby tab content */
.lobby-tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.lobby-tab-content.active {
  display: flex;
  flex-direction: column;
}

.tables-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}

.tables-empty {
  text-align: center;
  padding: 48px 16px;
  color: #607d8b;
}

.tables-empty p {
  margin: 4px 0;
}

.tables-empty .sub {
  font-size: 0.85rem;
  color: #546e7a;
}

.table-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(79, 195, 247, 0.06);
  border: 1px solid rgba(79, 195, 247, 0.15);
  border-radius: 12px;
  padding: 14px 18px;
  transition: all 0.2s;
}

.table-card:hover {
  background: rgba(79, 195, 247, 0.1);
  border-color: rgba(79, 195, 247, 0.3);
}

.table-card.my-table {
  background: rgba(76, 175, 80, 0.08);
  border-color: rgba(76, 175, 80, 0.35);
  animation: pulseTable 2s ease-in-out infinite;
}

.table-card.my-table:hover {
  background: rgba(76, 175, 80, 0.12);
}

@keyframes pulseTable {
  0%, 100% { border-color: rgba(76, 175, 80, 0.35); }
  50% { border-color: rgba(76, 175, 80, 0.7); }
}

.btn-cancel-my-table {
  padding: 8px 20px;
  background: rgba(233, 69, 96, 0.15);
  color: #e94560;
  border: 1px solid rgba(233, 69, 96, 0.3);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-cancel-my-table:hover {
  background: rgba(233, 69, 96, 0.25);
  border-color: rgba(233, 69, 96, 0.5);
}

.table-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.table-host {
  font-size: 1rem;
  font-weight: 600;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-card-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: #90a4ae;
}

.table-time {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.table-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
}

.badge-ranked {
  background: rgba(76, 175, 80, 0.15);
  color: #66bb6a;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.badge-casual {
  background: rgba(255, 152, 0, 0.15);
  color: #ffa726;
  border: 1px solid rgba(255, 152, 0, 0.3);
}

.badge-tablita {
  background: rgba(156, 39, 176, 0.15);
  color: #ce93d8;
  border: 1px solid rgba(156, 39, 176, 0.3);
}

.badge-mesa {
  background: rgba(33, 150, 243, 0.15);
  color: #64b5f6;
  border: 1px solid rgba(33, 150, 243, 0.3);
}

.table-card-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.table-card-mesa {
  font-size: 0.65rem;
  font-weight: 600;
  color: #64b5f6;
}

.btn-join-table {
  padding: 8px 20px;
  background: linear-gradient(135deg, #1a73e8, #4FC3F7);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-join-table:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 195, 247, 0.3);
}

/* ===== ACTIVE GAMES (SPECTATOR LOBBY) ===== */
.active-games-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.active-games-empty {
  text-align: center;
  padding: 16px;
  color: #607d8b;
  font-size: 0.85rem;
}

.active-game-card {
  background: rgba(255, 167, 38, 0.06);
  border: 1px solid rgba(255, 167, 38, 0.15);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s;
}

.active-game-card:hover {
  border-color: rgba(255, 167, 38, 0.35);
}

.active-game-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.active-game-players {
  font-size: 0.9rem;
  color: #e0e0e0;
  font-weight: 500;
}

.active-game-vs {
  color: #ffa726;
  font-weight: 700;
  margin: 0 6px;
}

.btn-watch-game {
  padding: 6px 16px;
  background: linear-gradient(135deg, #ff9800, #ffa726);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.btn-watch-game:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.active-game-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: #90a4ae;
}

.spectator-badge {
  color: #ffa726;
  font-size: 0.75rem;
}

/* ===== SPECTATOR BAR (in-game) ===== */
.spectator-bar {
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.15), rgba(255, 167, 38, 0.1));
  border: 1px solid rgba(255, 152, 0, 0.3);
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ffa726;
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 8px;
}

.btn-stop-watching {
  padding: 4px 14px;
  background: rgba(244, 67, 54, 0.15);
  color: #ef5350;
  border: 1px solid rgba(244, 67, 54, 0.3);
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.btn-stop-watching:hover {
  background: rgba(244, 67, 54, 0.25);
}

.spectator-count {
  text-align: center;
  color: #90a4ae;
  font-size: 0.75rem;
  margin-top: 4px;
}

.mesa-number-bar {
  text-align: center;
  color: #81c784;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 4px;
  padding: 3px 0;
  letter-spacing: 0.5px;
}

/* ===== CREATE TABLE MODAL ===== */
.create-table-form {
  margin: 20px 0;
}

.form-label {
  display: block;
  color: #90a4ae;
  font-size: 0.85rem;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.time-options {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.time-btn {
  flex: 1;
  padding: 12px;
  background: rgba(79, 195, 247, 0.08);
  border: 2px solid rgba(79, 195, 247, 0.15);
  border-radius: 10px;
  color: #b0d4f1;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.time-btn:hover {
  background: rgba(79, 195, 247, 0.12);
  border-color: rgba(79, 195, 247, 0.3);
}

.time-btn.active {
  background: rgba(79, 195, 247, 0.2);
  border-color: #4FC3F7;
  color: #4FC3F7;
}

/* Three-column selects row */
.create-table-selects-inline {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.create-table-selects-inline .create-table-select-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.create-table-selects-inline .create-table-select-group .form-label {
  margin-bottom: 6px;
}
.create-table-selects-inline .modal-select {
  font-size: 0.82rem;
  padding: 9px 22px 9px 8px;
  background-position: right 6px center;
  background-size: 8px 5px;
}

/* Shared select style */
.modal-select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(79, 195, 247, 0.08);
  border: 2px solid rgba(79, 195, 247, 0.2);
  border-radius: 10px;
  color: #b0d4f1;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%234FC3F7' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.modal-select:focus {
  outline: none;
  border-color: #4FC3F7;
}
.modal-select option {
  background: #0d2137;
  color: #b0d4f1;
}

/* Row with checkbox */
.create-table-row-checks {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.create-table-row-checks .checkbox-label {
  flex: 1;
  margin-bottom: 0 !important;
}

/* Player search */
.modal-input {
  width: 100%;
  padding: 10px 12px;
  background: rgba(79, 195, 247, 0.06);
  border: 2px solid rgba(79, 195, 247, 0.2);
  border-radius: 10px;
  color: #b0d4f1;
  font-size: 0.9rem;
  box-sizing: border-box;
}
.modal-input::placeholder { color: #546e7a; }
.modal-input:focus { outline: none; border-color: #4FC3F7; }

.player-search-container {
  position: relative;
  margin-bottom: 6px;
}
.player-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #0d2137;
  border: 1.5px solid rgba(79, 195, 247, 0.3);
  border-radius: 10px;
  max-height: 160px;
  overflow-y: auto;
  z-index: 200;
}
.player-search-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: #b0d4f1;
  border-bottom: 1px solid rgba(79, 195, 247, 0.08);
}
.player-search-item:last-child { border-bottom: none; }
.player-search-item:hover { background: rgba(79, 195, 247, 0.12); color: #4FC3F7; }
.player-search-item .psi-elo { font-size: 0.78rem; color: #607d8b; }

.selected-invite-player {
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(79, 195, 247, 0.1);
  border: 1.5px solid rgba(79, 195, 247, 0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  color: #4FC3F7;
}
.btn-clear-invite {
  background: none;
  border: none;
  color: #ef5350;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 2px;
}

/* Badge for min-rank on table card */
.badge-min-rank {
  background: rgba(255, 183, 77, 0.15);
  border: 1px solid rgba(255, 183, 77, 0.4);
  color: #ffb74d;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-invite-only {
  background: rgba(255, 152, 0, 0.15);
  border: 1px solid rgba(255, 152, 0, 0.5);
  color: #ffb74d;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 0 6px rgba(255, 152, 0, 0.2);
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: #b0d4f1 !important;
  font-size: 1rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #4FC3F7;
  cursor: pointer;
}

.checkbox-label small {
  color: #607d8b;
  font-size: 0.75rem;
}

.waiting-info {
  color: #90a4ae;
  font-size: 0.9rem;
  margin-top: 8px;
}

/* ===== GAME TIMER ===== */
.player-timer {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: #4FC3F7;
  margin-top: 4px;
}

.player-timer.low-time {
  color: #ef5350;
  animation: pulse-timer 1s infinite;
}

@keyframes pulse-timer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== WAITING SCREEN ===== */
.waiting-container {
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #1a3a5c;
  border-top: 4px solid #4FC3F7;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 24px;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* ===== GAME LAYOUT ===== */
.game-layout {
  display: flex;
  height: 100vh;
  width: 100%;
  gap: 0;
}

/* ===== SIDE PANELS ===== */
.side-panel {
  width: 220px;
  background: linear-gradient(180deg, #0d2137, #0a1a2e);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid #1a3a5c;
}

.right-panel {
  border-right: none;
  border-left: 1px solid #1a3a5c;
}

/* Player Info */
.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: rgba(79, 195, 247, 0.08);
  border: 1px solid rgba(79, 195, 247, 0.15);
  border-radius: 10px;
  position: relative;
}

.player-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
}

.white-avatar {
  background: radial-gradient(circle at 35% 35%, #fff, #d4d4d4);
  border: 2px solid #aaa;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.2);
}

.black-avatar {
  background: radial-gradient(circle at 35% 35%, #555, #1a1a1a);
  border: 2px solid #444;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,0.5);
}

.player-details {
  display: flex;
  flex-direction: column;
}

.player-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.player-pieces {
  font-size: 0.75rem;
  color: #888;
}

.turn-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #333;
  flex-shrink: 0;
  margin-left: auto;
}

.turn-indicator.active {
  background: #4FC3F7;
  box-shadow: 0 0 8px rgba(79, 195, 247, 0.6);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(79, 195, 247, 0.6); }
  50% { box-shadow: 0 0 16px rgba(79, 195, 247, 0.9); }
}

/* Game Log */
.game-log {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.game-log h3 {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 8px;
}

.log-entries {
  flex: 1;
  overflow-y: auto;
  font-size: 0.8rem;
  color: #aaa;
}

.log-entries .log-entry {
  padding: 4px 0;
  border-bottom: 1px solid #1a3a5c;
}

/* Controls */
.ctrl-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  background: rgba(79, 195, 247, 0.12);
  color: #b0d4f1;
  border: 1px solid rgba(79, 195, 247, 0.2);
  transition: all 0.2s;
}

.ctrl-btn:hover {
  background: rgba(79, 195, 247, 0.2);
}

.ctrl-btn.danger {
  background: rgba(239, 83, 80, 0.12);
  color: #ef5350;
  border-color: rgba(239, 83, 80, 0.2);
}

.ctrl-btn.danger:hover {
  background: rgba(239, 83, 80, 0.2);
}

.draw-offer-area {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.ctrl-btn.draw-btn {
  background: rgba(255, 167, 38, 0.1);
  color: #ffa726;
  border-color: rgba(255, 167, 38, 0.2);
  width: 100%;
}

.ctrl-btn.draw-btn:hover {
  background: rgba(255, 167, 38, 0.2);
}

.ctrl-btn.draw-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Captured Pieces */
.captured-area h3 {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 8px;
}

.captured-pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.captured-piece {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

/* ===== BOARD AREA ===== */
.board-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: linear-gradient(135deg, #0b1929, #0d2540, #0b1929);
  padding: 28px 8px 16px 8px;
}

.board-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: auto;
  margin-top: 8px;
}

.board-labels {
  display: flex;
  justify-content: space-around;
  width: 480px;
  padding: 4px 0;
}

.board-labels span {
  width: 60px;
  text-align: center;
  font-size: 0.8rem;
  color: #666;
  font-weight: 600;
}

.board-labels.left,
.board-labels.right {
  flex-direction: column;
  width: 20px;
  height: 480px;
  justify-content: space-around;
  padding: 0 4px;
}

.board-labels.left span,
.board-labels.right span {
  width: auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-with-numbers {
  display: flex;
  align-items: center;
}

/* ===== THE BOARD (PlayOK Style) ===== */
.board {
  width: 480px;
  height: 480px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 3px solid #1a4a7a;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 40px rgba(79, 195, 247, 0.08);
  border-radius: 6px;
  overflow: hidden;
  transform: translateZ(0);
  contain: layout style;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Casas do tabuleiro */
.cell {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: default;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  contain: layout style;
}

.cell.light {
  background: #dce8f5;
}

.cell.dark {
  background: #1565c0;
}

.cell.dark:hover {
  background: #1976d2;
}

/* Highlight de casas válidas */
.cell.valid-move {
  cursor: pointer;
}

.cell.valid-move::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: rgba(79, 195, 247, 0.6);
  border-radius: 50%;
  z-index: 1;
}

.cell.valid-capture {
  cursor: pointer;
}

.cell.valid-capture::after {
  content: '';
  position: absolute;
  width: 50px;
  height: 50px;
  border: 3px solid rgba(244, 67, 54, 0.7);
  border-radius: 50%;
  z-index: 1;
}

.cell.last-move {
  box-shadow: inset 0 0 0 2px rgba(79, 195, 247, 0.5);
}

/* ===== PEÇAS (PlayOK Style) ===== */
.piece {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  cursor: grab;
  position: relative;
  z-index: 2;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
  contain: layout style paint;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.piece:active {
  cursor: grabbing;
  transform: scale(1.1);
}

.piece::before,
.piece::after {
  pointer-events: none;
}

/* Peça branca - estilo PlayOK */
.piece.white {
  background: radial-gradient(circle at 38% 35%, #ffffff, #e0d8c8 40%, #c8bca8 70%, #b0a490);
  border: 2px solid #a09080;
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.3),
    inset 0 1px 3px rgba(255, 255, 255, 0.6),
    inset 0 -2px 4px rgba(0, 0, 0, 0.15);
}

.piece.white::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 10px;
  width: 16px;
  height: 8px;
  background: radial-gradient(ellipse, rgba(255,255,255,0.7), transparent);
  border-radius: 50%;
}

/* Peça preta - estilo PlayOK */
.piece.black {
  background: radial-gradient(circle at 38% 35%, #5a5a5a, #2a2a2a 40%, #1a1a1a 70%, #0a0a0a);
  border: 2px solid #444;
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.5),
    inset 0 1px 3px rgba(255, 255, 255, 0.15),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4);
}

.piece.black::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 10px;
  width: 16px;
  height: 8px;
  background: radial-gradient(ellipse, rgba(255,255,255,0.2), transparent);
  border-radius: 50%;
}

/* Peça selecionada */
.piece.selected {
  transform: scale(1.08);
  box-shadow:
    0 0 0 3px rgba(79, 195, 247, 0.8),
    0 5px 15px rgba(0, 0, 0, 0.4);
}

/* Dama (King) */
.piece.king::before {
  content: '♛';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 22px;
  z-index: 3;
}

.piece.white.king::before {
  color: #8B6914;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.piece.black.king::before {
  color: #FFD700;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Animações de peças */
@keyframes pieceSlideIn {
  from { transform: scale(0.4); opacity: 0.2; }
  to   { transform: scale(1);   opacity: 1; }
}
@keyframes pieceFadeOut {
  from { transform: scale(1);   opacity: 1; }
  to   { transform: scale(0.2); opacity: 0; }
}
.piece-slide-in {
  animation: pieceSlideIn 0.18s ease-out;
}
.piece-fade-out {
  animation: pieceFadeOut 0.18s ease-out forwards;
  pointer-events: none;
}

/* ===== STATUS BAR ===== */
.status-bar {
  margin-top: 12px;
  padding: 10px 24px;
  background: rgba(79, 195, 247, 0.1);
  border: 1px solid rgba(79, 195, 247, 0.2);
  border-radius: 8px;
  font-size: 0.95rem;
  color: #b0d4f1;
  text-align: center;
  min-width: 300px;
}

.tablita-bar {
  margin-top: 6px;
  padding: 6px 16px;
  background: rgba(156, 39, 176, 0.12);
  border: 1px solid rgba(156, 39, 176, 0.3);
  border-radius: 8px;
  font-size: 0.82rem;
  color: #ce93d8;
  text-align: center;
  font-weight: 600;
}

.pe-de-galo-bar {
  margin-top: 6px;
  padding: 6px 16px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 8px;
  font-size: 0.82rem;
  color: #fbbf24;
  text-align: center;
  font-weight: 600;
}

/* Desktop chat toggle */
.desktop-chat-toggle {
  margin-top: auto;
}

.chat-desktop-btn {
  background: rgba(79, 195, 247, 0.1) !important;
  border: 1px solid rgba(79, 195, 247, 0.25) !important;
  color: #4FC3F7 !important;
  font-size: 0.85rem;
}

.chat-desktop-btn:hover {
  background: rgba(79, 195, 247, 0.2) !important;
}

/* ===== CONFIRM MODAL ===== */
.confirm-modal-content {
  max-width: 380px;
  animation: confirmSlideIn 0.25s ease-out;
}

.confirm-icon {
  font-size: 2.8rem;
  margin-bottom: 8px;
}

.confirm-modal-content h2 {
  font-size: 1.4rem;
  color: #2c3e50;
  margin-bottom: 8px;
}

.confirm-modal-content p {
  color: #5a7a9a;
  font-size: 0.95rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.confirm-modal-content .modal-buttons {
  gap: 10px;
}

.confirm-modal-content .menu-btn.secondary {
  background: #e0e0e0;
  color: #555;
}

.confirm-modal-content .menu-btn.secondary:hover {
  background: #d0d0d0;
}

.confirm-modal-content .menu-btn.danger {
  background: linear-gradient(145deg, #e74c3c, #c0392b);
  color: #fff;
}

.confirm-modal-content .menu-btn.danger:hover {
  background: linear-gradient(145deg, #c0392b, #a93226);
}

.confirm-modal-content .menu-btn.warning {
  background: linear-gradient(145deg, #f39c12, #e67e22);
  color: #fff;
}

.confirm-modal-content .menu-btn.warning:hover {
  background: linear-gradient(145deg, #e67e22, #d35400);
}

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

/* ===== GAME OVER MODAL ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  touch-action: manipulation;
}

.modal-content {
  background: linear-gradient(145deg, #ffffff, #e8f4fd);
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  min-width: 340px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 {
  font-size: 1.8rem;
  margin-bottom: 12px;
  color: #1a73e8;
}

.modal-content p {
  color: #5a7a9a;
  margin-bottom: 24px;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-buttons .menu-btn {
  width: auto;
  padding: 12px 24px;
}

/* ===== GAME OVER STATS ===== */
/* Motivo do fim de jogo */
.game-over-motivo {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 2px auto 12px;
  padding: 0;
  font-size: 0.88em;
  font-weight: 600;
  letter-spacing: 0.2px;
  animation: motivoFadeIn 0.4s ease;
  background: none;
  border: none;
}

.game-over-motivo .motivo-icon {
  font-size: 1.1em;
}

.motivo-normal {
  color: #81c784;
}

.motivo-timeout {
  color: #ffb74d;
}

.motivo-resign {
  color: #b0bec5;
}

.motivo-abandon {
  color: #ef9a9a;
}

.motivo-draw {
  color: #ffb74d;
}

.motivo-pedegalo {
  color: #fff176;
}

@keyframes motivoFadeIn {
  0% { opacity: 0; transform: translateY(-8px); }
  100% { opacity: 1; transform: translateY(0); }
}

.game-over-stats {
  margin: 12px auto 4px;
}

.gos-elo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.gos-elo {
  font-size: 2.8em;
  font-weight: 900;
  color: #fff;
  letter-spacing: 2px;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.gos-elo-badge {
  font-size: 1.1em;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 20px;
  opacity: 0;
  transform: scale(0);
}

.gos-elo-badge.animate {
  animation: eloBadgePop 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards;
}

.gos-elo-badge.up {
  color: #fff;
  background: #4caf50;
}

.gos-elo-badge.down {
  color: #fff;
  background: #e94560;
}

.gos-elo-badge.same {
  display: none;
}

@keyframes eloBadgePop {
  0% { opacity: 0; transform: scale(0); }
  60% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 1; transform: scale(1); }
}

.gos-elo.counting {
  animation: eloPulse 0.2s ease-in-out;
}

@keyframes eloPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ===== ANIMAÇÕES ===== */
.piece-move {
  transition: all 0.3s ease;
}

.piece-capture {
  animation: capture 0.3s ease-out forwards;
}

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

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  body {
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
  }

  .screen {
    height: auto;
    min-height: 100vh;
  }

  .game-layout {
    height: auto;
    min-height: 100vh;
  }

  .board-area {
    justify-content: flex-start;
    padding-top: 36px;
    padding-bottom: 16px;
    align-items: center;
  }

  .side-panel {
    display: none;
  }

  /* Esconder labels (letras/números) no mobile para ganhar espaço */
  .board-labels {
    display: none !important;
  }

  .board {
    width: min(92vw, 400px);
    height: min(92vw, 400px);
  }

  .cell {
    width: auto;
    height: auto;
  }

  .piece {
    width: 80%;
    height: 80%;
  }
}

/* ===== AUTH SCREEN ===== */
.auth-container {
  min-width: 400px;
  max-width: 440px;
}

/* Tela de versão bloqueada */
.blocked-content {
  text-align: center;
  padding: 24px 16px;
}
.blocked-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.blocked-content h2 {
  color: #ff6b6b;
  margin-bottom: 12px;
  font-size: 1.3rem;
}
.blocked-content p {
  color: #b0bec5;
  margin-bottom: 8px;
  font-size: 0.95rem;
  line-height: 1.5;
}
.blocked-version {
  margin-top: 16px;
  color: #78909c;
  font-size: 0.85rem;
}
.blocked-version strong {
  color: #ff6b6b;
}

.logo-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  display: block;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.phone-group {
  display: flex;
  gap: 8px;
}

.country-select {
  width: 120px !important;
  flex-shrink: 0;
  padding: 12px 8px !important;
  font-size: 0.9rem !important;
}

.phone-input {
  flex: 1;
}

.auth-error {
  color: #ef5350;
  font-size: 0.85rem;
  min-height: 20px;
  text-align: center;
}

.auth-switch {
  text-align: center;
  color: #5a7a9a;
  font-size: 0.9rem;
  margin-top: 12px;
}

.auth-switch a {
  color: #4FC3F7;
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ===== MENU PROFILE HEADER ===== */
.menu-profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: rgba(79, 195, 247, 0.06);
  border: 1px solid rgba(79, 195, 247, 0.12);
  border-radius: 14px;
}

.profile-avatar-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4FC3F7, #1a73e8);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-avatar-circle span {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
}

.profile-header-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 1;
}

.logout-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(100, 116, 139, 0.25);
  background: rgba(100, 116, 139, 0.08);
  color: #64748b;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.logout-icon-btn:hover {
  background: rgba(100, 116, 139, 0.18);
  border-color: rgba(100, 116, 139, 0.4);
}

.profile-header-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a3a5c;
}

.profile-header-elo {
  font-size: 0.85rem;
  color: #4FC3F7;
  font-weight: 600;
}

/* ===== PLAYER STATS BOX ===== */
.player-stats-box {
  display: flex;
  justify-content: space-around;
  background: rgba(79, 195, 247, 0.08);
  border: 1px solid rgba(79, 195, 247, 0.15);
  border-radius: 12px;
  padding: 16px 8px;
  margin-bottom: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #4FC3F7;
}

.stat-label {
  font-size: 0.7rem;
  color: #90a4ae;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== LEADERBOARD BTN ===== */
.menu-btn.leaderboard {
  background: linear-gradient(135deg, #0d47a1, #1565c0);
  color: white;
}

.menu-btn.leaderboard:hover {
  background: linear-gradient(135deg, #1565c0, #1976d2);
  transform: translateY(-2px);
}

.menu-btn.cancel-btn {
  background: transparent;
  color: #90a4ae;
  border: 1px solid #90a4ae;
  margin-top: 8px;

}

/* ===== SETTINGS / PROFILE ===== */
.settings-scroll-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.settings-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1a5276;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.settings-section-title {
  font-size: 0.95rem;
  color: #1a73e8;
  margin-bottom: 8px;
  margin-top: 4px;
}

.settings-section-title-left {
  text-align: left;
}

.settings-hint {
  font-size: 0.75rem;
  color: #90a4ae;
  line-height: 1.3;
  margin-top: 2px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cfd8dc;
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, #4FC3F7, #1a73e8);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

.settings-form .menu-input {
  background: #f5f9fc;
  border: 1px solid #d0dce5;
  color: #1a1a1a;
}

.settings-section {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-form .menu-input:disabled {
  background: #e8eef3;
  color: #90a4ae;
  cursor: not-allowed;
}

.auth-success {
  color: #2e7d32;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 20px;
}

.menu-btn.cancel-btn:hover {
  background: rgba(144, 164, 174, 0.1);
}

/* ===== MODAL WIDE ===== */
.modal-wide {
  min-width: 340px;
  max-width: 650px;
  width: 95%;
  height: 92vh;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-wide .leaderboard-list,
.modal-wide .leaderboard-table-wrap {
  flex: 1;
  max-height: none;
  overflow-y: auto;
  min-height: 0;
}

.modal-wide .modal-buttons,
.modal-wide > button {
  flex-shrink: 0;
}

/* ===== LEADERBOARD TABLE ===== */
.leaderboard-table-wrap {
  max-height: 400px;
  overflow-y: auto;
  margin-top: 16px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.leaderboard-table th {
  background: rgba(26, 115, 232, 0.1);
  color: #000000;
  padding: 8px 6px;
  text-align: center;
  font-weight: 600;
  position: sticky;
  top: 0;
  white-space: nowrap;
}

.leaderboard-table th:nth-child(1) { text-align: center; width: 30px; }
.leaderboard-table th:nth-child(2) { text-align: left; }

.leaderboard-table td {
  padding: 7px 6px;
  border-bottom: 1px solid rgba(26, 115, 232, 0.1);
  color: #000000 !important;
  white-space: nowrap;
  text-align: center;
}

.leaderboard-table td:nth-child(1) { text-align: center; width: 30px; }
.leaderboard-table td:nth-child(2) { text-align: left; }

.leaderboard-table tr:hover td {
  background: rgba(26, 115, 232, 0.06);
}

.leaderboard-table .rank-1 td { color: #1a1a1a !important; font-weight: 700; }
.leaderboard-table .rank-2 td { color: #1a1a1a !important; font-weight: 700; }
.leaderboard-table .rank-3 td { color: #1a1a1a !important; font-weight: 700; }

.highlight-row td { background: rgba(26, 115, 232, 0.1) !important; font-weight: 600; color: #000000 !important; }

/* ===== LEADERBOARD CARDS ===== */
.leaderboard-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding-right: 4px;
  min-height: 0;
}

.lb-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(26, 115, 232, 0.04);
  border: 1px solid rgba(26, 115, 232, 0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.lb-card:hover {
  background: rgba(26, 115, 232, 0.09);
  border-color: rgba(26, 115, 232, 0.25);
}

.lb-card-top {
  background: rgba(26, 115, 232, 0.08);
  border-color: rgba(26, 115, 232, 0.2);
}

.lb-card-gold {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.12), rgba(255, 193, 7, 0.08));
  border-color: rgba(255, 193, 7, 0.4);
}
.lb-card-gold .lb-rank { color: #d4a017; }
.lb-card-gold .lb-elo { color: #c8960c; }

.lb-card-silver {
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.15), rgba(158, 158, 158, 0.08));
  border-color: rgba(158, 158, 158, 0.4);
}
.lb-card-silver .lb-rank { color: #757575; }
.lb-card-silver .lb-elo { color: #616161; }

.lb-card-bronze {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.12), rgba(191, 109, 38, 0.08));
  border-color: rgba(191, 109, 38, 0.35);
}
.lb-card-bronze .lb-rank { color: #a86523; }
.lb-card-bronze .lb-elo { color: #955b1e; }

.lb-card-highlight {
  background: rgba(26, 115, 232, 0.12) !important;
  border-color: #1a73e8 !important;
}

.lb-rank {
  width: 32px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a73e8;
  flex-shrink: 0;
}

.lb-info {
  flex: 1;
  min-width: 0;
}

.lb-name {
  font-size: 1rem;
  font-weight: 700;
  color: #1a3a5c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-stats-line {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 2px;
  font-weight: 500;
}

.lb-elo {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1a73e8;
  flex-shrink: 0;
  text-align: right;
  line-height: 1;
}

.lb-elo-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lb-empty {
  text-align: center;
  padding: 24px;
  color: #64748b;
  font-size: 0.95rem;
}

.result-win { color: #2e7d32 !important; font-weight: 600; }
.result-loss { color: #c62828 !important; font-weight: 600; }
.result-draw { color: #e65100 !important; font-weight: 600; }

/* ===== BOARD PLAYER LABELS ===== */
.board-player-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(79, 195, 247, 0.08);
  border: 1px solid rgba(79, 195, 247, 0.15);
  border-radius: 10px;
  min-width: 300px;
  margin: 6px 0;
}

.board-player-label span {
  font-weight: 600;
  font-size: 0.95rem;
  color: #e0e0e0;
}

.player-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-avatar-sm.white-avatar {
  background: radial-gradient(circle at 35% 35%, #fff, #d4d4d4);
  border: 2px solid #aaa;
}

.player-avatar-sm.black-avatar {
  background: radial-gradient(circle at 35% 35%, #555, #1a1a1a);
  border: 2px solid #444;
}

.board-player-label .player-timer {
  margin-left: auto;
}

/* ===== CHAT ===== */
.chat-container {
  width: 100%;
  max-width: 520px;
  margin-top: 10px;
  background: rgba(13, 33, 55, 0.95);
  border: 1px solid rgba(79, 195, 247, 0.2);
  border-radius: 10px;
  overflow: hidden;
}

.chat-toggle {
  background: rgba(79, 195, 247, 0.08);
  border: none;
  border-left: 1px solid rgba(79, 195, 247, 0.15);
  color: #4FC3F7;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 10px 12px;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.3s ease, background 0.2s;
}

.chat-toggle:hover {
  background: rgba(79, 195, 247, 0.15);
}

.chat-toggle.collapsed {
  transform: rotate(-90deg);
}

.chat-toggle .chat-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: #4caf50;
  border-radius: 50%;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chat-body {
  display: flex;
  flex-direction: column;
}

.chat-messages {
  height: 150px;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: max-height 0.3s ease, padding 0.3s ease, height 0.3s ease;
}

.chat-messages.collapsed {
  height: 0;
  max-height: 0;
  padding: 0 12px;
  overflow: hidden;
}

.chat-msg {
  font-size: 0.85rem;
  color: #b0d4f1;
  padding: 4px 0;
  border-bottom: 1px solid rgba(79, 195, 247, 0.06);
  word-break: break-word;
}

.chat-msg .chat-author {
  font-weight: 600;
  color: #4FC3F7;
  margin-right: 6px;
}

.chat-msg.chat-system {
  color: #666;
  font-style: italic;
  font-size: 0.8rem;
}

.chat-msg.chat-self .chat-author {
  color: #81c784;
}

.chat-input-area {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(79, 195, 247, 0.15);
}

.chat-input {
  flex: 1;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  color: #e0e0e0;
  font-size: 0.85rem;
  outline: none;
}

.chat-input::placeholder {
  color: #5a7a9a;
}

.chat-send-btn {
  padding: 10px 16px;
  background: #1565c0;
  border: none;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-send-btn:hover {
  background: #1976d2;
}

@media (max-width: 900px) {
  .chat-container {
    max-width: 360px;
  }
  .board-player-label {
    min-width: auto;
    width: 360px;
  }
  .status-bar {
    min-width: auto;
    width: 360px;
    box-sizing: border-box;
  }
}

/* ===== GAME ACTION BAR (mobile) ===== */
.game-action-bar {
  display: none;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 520px;
  margin: 4px auto;
  padding: 4px 0;
  gap: 8px;
  position: relative;
  z-index: 10;
  box-sizing: border-box;
}

/* Barra de treino (bot/local) */
.training-bar {
  display: none;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  max-width: 520px;
  margin: 6px auto;
  padding: 0;
  gap: 10px;
  box-sizing: border-box;
}
.training-bar.active {
  display: flex;
}
.training-btn {
  flex: 1;
  padding: 10px 12px !important;
  font-size: 0.85rem !important;
  border-radius: 10px !important;
  max-width: 220px;
  margin-bottom: 0 !important;
}
.training-btn-icon {
  flex: 0 0 auto;
  width: 44px;
  padding: 0 !important;
  font-size: 1.1rem !important;
  border-radius: 10px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0 !important;
}

.action-icon-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  border: 1px solid rgba(79, 195, 247, 0.2);
  border-radius: 8px;
  background: rgba(13, 33, 55, 0.8);
  color: #c0d8f0;
  font-size: 1.3rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  position: relative;
}

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

.action-icon-btn.danger {
  border-color: rgba(239, 83, 80, 0.3);
  color: #ef5350;
}

.action-icon-btn.danger:hover {
  background: rgba(239, 83, 80, 0.15);
}

.action-icon-btn.draw {
  border-color: rgba(255, 167, 38, 0.3);
  color: #ffa726;
}

.action-icon-btn.draw:hover {
  background: rgba(255, 167, 38, 0.15);
}

.action-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Draw pending animation (pulsing) */
.draw-pending {
  animation: drawPulse 1s ease-in-out infinite;
  border-color: #ffa726 !important;
  box-shadow: 0 0 8px rgba(255, 167, 38, 0.5);
}

@keyframes drawPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 4px rgba(255, 167, 38, 0.3); }
  50% { transform: scale(1.08); box-shadow: 0 0 12px rgba(255, 167, 38, 0.7); }
}

/* Desktop draw button pending */
button.draw-pending {
  background: rgba(255, 167, 38, 0.15);
  border-color: #ffa726;
  color: #ffa726;
}

/* Chat notification badge (mobile icon) */
.chat-badge {
  position: absolute;
  top: 4px;
  right: 25%;
  width: 10px;
  height: 10px;
  background: #4caf50;
  border-radius: 50%;
  border: 2px solid rgba(13, 33, 55, 0.8);
  animation: badge-pulse 1.5s infinite;
}

/* Chat notification dot (header) */
.chat-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #4caf50;
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
  animation: badge-pulse 1.5s infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

@media (max-width: 900px) {
  .game-action-bar {
    display: flex;
    max-width: 360px;
  }
}

/* ===== REPLAY MODAL ===== */
.modal-replay {
  max-width: 560px;
  width: 98%;
  padding: 24px 16px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  background: linear-gradient(145deg, #0f2740, #0a1929) !important;
  color: #c0d8f0;
}

.modal-replay h2 {
  color: #e8f0fa !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.replay-player-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(79, 195, 247, 0.08);
  border: 1px solid rgba(79, 195, 247, 0.15);
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  box-sizing: border-box;
  margin: 6px 0;
}

.replay-player-label span {
  font-weight: 600;
  font-size: 0.95rem;
  color: #e0e0e0;
}
  background: rgba(79, 195, 247, 0.1);
  border-color: rgba(79, 195, 247, 0.3);
  color: #4FC3F7;
}

.replay-result-badge {
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.replay-result-badge.win {
  background: rgba(76, 175, 80, 0.2);
  color: #81c784;
}

.replay-result-badge.loss {
  background: rgba(233, 69, 96, 0.2);
  color: #e94560;
}

.replay-result-badge.draw {
  background: rgba(255, 193, 7, 0.2);
  color: #ffc107;
}

.replay-board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin: 0 auto 12px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.replay-board {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  height: auto;
  border: 3px solid #1a4a7a;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 40px rgba(79, 195, 247, 0.08);
  border-radius: 6px;
  pointer-events: none;
}

.replay-board .cell {
  width: 100%;
  height: 100%;
}

.replay-board .piece {
  width: 76%;
  height: 76%;
}

.replay-board .cell.replay-highlight-from {
  box-shadow: inset 0 0 0 3px rgba(255, 193, 7, 0.7);
}

.replay-board .cell.replay-highlight-to {
  box-shadow: inset 0 0 0 3px rgba(76, 175, 80, 0.7);
}

.replay-board .cell.replay-highlight-capture {
  box-shadow: inset 0 0 0 3px rgba(233, 69, 96, 0.7);
}

.replay-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
  touch-action: manipulation;
}

.replay-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(79, 195, 247, 0.3);
  border-radius: 10px;
  background: rgba(79, 195, 247, 0.08);
  color: #4FC3F7;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.replay-btn:hover {
  background: rgba(79, 195, 247, 0.2);
  border-color: #4FC3F7;
}

.replay-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.replay-btn-play {
  width: 52px;
  height: 52px;
  font-size: 1.3rem;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(79, 195, 247, 0.15), rgba(26, 115, 232, 0.15));
  border-color: #4FC3F7;
}

.replay-btn-play.playing {
  color: #e94560;
  border-color: #e94560;
  background: rgba(233, 69, 96, 0.1);
}

.replay-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 4px 0 8px;
}

#replay-move-info {
  font-size: 0.88rem;
  color: #c0d8f0;
  font-weight: 600;
}

.replay-slider {
  width: 90%;
  accent-color: #4FC3F7;
  height: 6px;
  cursor: pointer;
  touch-action: manipulation;
}

.replay-moves-list {
  max-height: 140px;
  overflow-y: auto;
  background: #1a2a3a;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  color: #c0d8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  border: 1px solid rgba(79, 195, 247, 0.15);
}

.replay-move-item {
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
  transition: all 0.15s;
  white-space: nowrap;
  font-size: 0.9rem;
}

.replay-move-item:hover {
  background: rgba(79, 195, 247, 0.2);
  color: #4FC3F7;
}

.replay-move-item.active {
  background: rgba(79, 195, 247, 0.25);
  color: #4FC3F7;
  font-weight: bold;
}

.replay-move-item.white-move {
  color: #ffffff;
  text-shadow: 0 0 2px rgba(255,255,255,0.15);
}

.replay-move-item.black-move {
  color: #f0c040;
}

.btn-replay-game {
  padding: 4px 10px;
  font-size: 0.75rem;
  background: rgba(79, 195, 247, 0.15);
  border: 1px solid rgba(79, 195, 247, 0.3);
  color: #4FC3F7;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-replay-game:hover {
  background: rgba(79, 195, 247, 0.3);
  border-color: #4FC3F7;
}

/* ===== SEARCH BAR ===== */
.search-bar {
  margin-bottom: 14px;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #b0d4f1;
  border-radius: 10px;
  background: #fff;
  color: #1a2a3a;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: #4FC3F7;
  box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.2);
}

.search-input::placeholder {
  color: #90a4ae;
}

/* Leaderboard rows clickable */
.leaderboard-table tbody tr.clickable-row {
  cursor: pointer;
  transition: background 0.15s;
}

.leaderboard-table tbody tr.clickable-row:hover {
  background: rgba(79, 195, 247, 0.12) !important;
}

/* ===== PLAYER PROFILE REDESIGN ===== */
.modal-profile {
  max-width: 480px;
  width: 95%;
  padding: 0 !important;
  overflow: hidden;
  border-radius: 20px;
}

.profile-header {
  background: linear-gradient(135deg, #1a73e8 0%, #1259c4 50%, #0d47a1 100%);
  padding: 24px 20px 0;
  position: relative;
}

.profile-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.08));
  pointer-events: none;
}

.profile-header-top {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 20px;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  font-weight: 800;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
  margin-right: -4px;
}

.profile-name-points {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.profile-name {
  color: #ffffff !important;
  font-size: 1.4rem;
  margin: 0 !important;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.05;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
  flex: 0 1 auto;
  text-align: left;
}

/* PTS badge top-right */
.profile-pts-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 18px;
  padding: 10px 22px;
  flex-shrink: 0;
  margin-left: 0;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
  min-width: 80px;
}

.profile-pts-value {
  font-size: 3.4em;
  font-weight: 900;
  color: #fff;
  letter-spacing: 2px;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.profile-pts-label {
  font-size: 0.5rem;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* Stats strip */
.profile-stats-strip {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  border-radius: 14px 14px 0 0;
  padding: 12px 8px;
  position: relative;
  z-index: 1;
}

.pss-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.pss-val {
  font-size: 1.15rem;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}

.pss-lbl {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.65);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.pss-sep {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}

/* Color variations for stats */
.pss-wins .pss-val, .pss-wins .pss-lbl { color: #86efac; text-shadow: 0 0 10px rgba(74, 222, 128, 0.3); }
.pss-losses .pss-val, .pss-losses .pss-lbl { color: #fda4af; text-shadow: 0 0 10px rgba(244, 63, 94, 0.3); }
.pss-draws .pss-val, .pss-draws .pss-lbl { color: #fcd34d; text-shadow: 0 0 10px rgba(251, 191, 36, 0.3); }
.pss-games .pss-val, .pss-games .pss-lbl { color: #e0f2fe; }

/* Profile search */
.profile-search-bar {
  margin-bottom: 10px;
}

.profile-search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e0eaf4;
  border-radius: 12px;
  background: #fff;
  color: #1a2a3a;
  font-size: 0.82rem;
  outline: none;
  transition: all 0.25s;
  box-sizing: border-box;
}

.profile-search-input:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.1);
}

.profile-search-input::placeholder {
  color: #90a4ae;
}

/* Stats bar - hidden, using mini */
.profile-stats-bar {
  display: none;
}

/* Winrate bar */
.profile-winrate-bar-wrap {
  padding: 12px 20px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #eef3f8;
}

.profile-winrate-label {
  font-size: 0.72rem;
  color: #7a8fa5;
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.profile-winrate-right {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-winrate-bar {
  flex: 1;
  height: 6px;
  background: #e8eef4;
  border-radius: 3px;
  overflow: hidden;
}

.profile-winrate-fill {
  height: 100%;
  background: linear-gradient(90deg, #34a853, #4caf50);
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(.4,0,.2,1);
}

.profile-winrate-text {
  font-size: 0.82rem;
  color: #34a853;
  font-weight: 800;
  white-space: nowrap;
  min-width: 32px;
  text-align: right;
}

/* Tabs */
.profile-tabs {
  display: flex;
  background: #fff;
  padding: 0 16px;
  gap: 4px;
}

.profile-tab {
  flex: 1;
  padding: 12px 4px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  border-bottom: 3px solid transparent;
  position: relative;
  white-space: nowrap;
}

.profile-tab:hover {
  color: #1a73e8;
}

.profile-tab.active {
  color: #1a73e8;
  border-bottom-color: #1a73e8;
}

/* Tab content */
.profile-tab-content {
  display: none;
  padding: 16px;
  background: #fafcff;
  max-height: 55vh;
  overflow-y: auto;
}

.profile-tab-content.active {
  display: block;
}

/* Profile games table */
.profile-games-table {
  font-size: 0.78rem;
}

.profile-games-table th {
  font-size: 0.7rem;
  padding: 6px 5px;
  color: #5a7a9a;
  border-bottom: 1px solid #e0eaf4;
}

.profile-games-table td {
  padding: 6px 5px;
  color: #1a2a3a;
  border-bottom: 1px solid #f0f4f8;
}

.col-datetime {
  font-size: 0.72rem;
  color: #7a9ab5;
  white-space: nowrap;
}

.col-date {
  font-size: 0.72rem;
  color: #7a9ab5;
  white-space: nowrap;
}

/* ===== EXPANDABLE ROWS ===== */
.history-expandable-table {
  table-layout: auto;
}

.history-expandable-table th:last-child,
.history-expandable-table td.col-expand {
  width: 36px;
  text-align: center;
  padding: 4px 2px;
}

.btn-expand-row {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: #4FC3F7;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.btn-expand-row:hover {
  background: rgba(79, 195, 247, 0.15);
}

.btn-expand-row.expanded {
  color: #1e88e5;
}

.expandable-row {
  cursor: pointer;
}

.expandable-row:hover td {
  background: rgba(79, 195, 247, 0.06);
}

.expandable-detail > td {
  padding: 0 !important;
  border-bottom: 2px solid #e0eaf4;
  background: #f4f8fc;
}

.game-detail-grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px 10px;
  padding: 8px 8px;
  align-items: center;
  justify-content: space-between;
}

.detail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.detail-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  color: #7a9ab5;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.detail-value {
  font-size: 0.72rem;
  color: #1a2a3a;
  font-weight: 600;
  white-space: nowrap;
}

.detail-replay-cell {
  vertical-align: middle;
  text-align: center;
  padding: 4px 2px;
  background: #f4f8fc;
}

.detail-replay-cell .btn-replay-game {
  padding: 4px 6px;
  font-size: 0.75rem;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.result-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
}

.result-badge.result-white {
  background: #e8f5e9;
  color: #2e7d32;
}

.result-badge.result-black {
  background: #f3e5f5;
  color: #7b1fa2;
}

.result-badge.result-win {
  background: #e8f5e9;
  color: #2e7d32;
}

.result-badge.result-loss {
  background: #ffebee;
  color: #c62828;
}

.result-badge.result-draw {
  background: #fff3e0;
  color: #e65100;
}

/* Statistics tab */
.profile-detailed-stats {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stats-section-title {
  font-size: 0.85rem;
  color: #1a73e8;
  margin: 0 0 10px;
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-card {
  background: #f5faff;
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
  border: 1px solid #e0eaf4;
  transition: transform 0.15s;
}

.stat-card:hover {
  transform: translateY(-1px);
}

.stat-card-icon {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.stat-card-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-card-label {
  display: block;
  font-size: 0.65rem;
  color: #5a7a9a;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

.stat-card-win .stat-card-value { color: #4caf50; }
.stat-card-win { border-color: rgba(76,175,80,0.3); }
.stat-card-loss .stat-card-value { color: #e94560; }
.stat-card-loss { border-color: rgba(233,69,96,0.3); }
.stat-card-draw .stat-card-value { color: #ffc107; }
.stat-card-draw { border-color: rgba(255,193,7,0.3); }
.stat-card-current .stat-card-value { color: #1a73e8; }
.stat-card-current { border-color: rgba(26,115,232,0.3); }

.streak-win { color: #4caf50; }
.streak-loss { color: #e94560; }
.streak-draw { color: #ffc107; }

/* Color performance */
.stats-color-row {
  display: flex;
  gap: 10px;
}

.stats-color-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: #f5faff;
  border: 1px solid #e0eaf4;
}

.white-card { border-color: #d0dce8; }
.black-card { border-color: #c0c8d0; }

.stats-color-piece {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

.white-piece-icon {
  background: radial-gradient(circle at 35% 35%, #ffffff, #c0c0c0);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.black-piece-icon {
  background: radial-gradient(circle at 35% 35%, #555, #1a1a1a);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.stats-color-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats-color-games {
  font-size: 0.85rem;
  color: #1a2a3a;
  font-weight: 600;
}

.stats-color-wins {
  font-size: 0.75rem;
  color: #4caf50;
}

/* Detail list */
.stats-detail-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.stats-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid #f0f4f8;
}

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

.stats-detail-label {
  font-size: 0.82rem;
  color: #5a7a9a;
}

.stats-detail-value {
  font-size: 0.88rem;
  color: #1a2a3a;
  font-weight: 700;
}

/* Profile close btn */
.modal-profile .menu-btn.secondary {
  margin: 0 16px 16px;
  width: calc(100% - 32px);
}

.no-results-msg {
  text-align: center;
  color: #90a4ae;
  padding: 20px;
  font-size: 0.9rem;
}

/* ===== CONFRONTOS TAB ===== */
.confrontos-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.confrontos-loading {
  text-align: center;
  color: #90a4ae;
  padding: 20px;
  font-size: 0.85rem;
}

.confronto-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #e8eef4;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.confronto-card:hover {
  background: #f0f7ff;
  border-color: #1a73e8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(26,115,232,0.12);
}

.confronto-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a73e8, #0d47a1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.confronto-info {
  flex: 1;
  min-width: 0;
}

.confronto-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #1a2a3a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.confronto-meta {
  font-size: 0.72rem;
  color: #7a9ab5;
  margin-top: 2px;
}

.confronto-stats {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.confronto-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 28px;
}

.confronto-stat-val {
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}

.confronto-stat-val.cs-win { color: #2e7d32; }
.confronto-stat-val.cs-loss { color: #c62828; }
.confronto-stat-val.cs-draw { color: #e65100; }

.confronto-stat-lbl {
  font-size: 0.55rem;
  color: #90a4ae;
  text-transform: uppercase;
  font-weight: 600;
}

.confronto-arrow {
  color: #b0bec5;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.confrontos-back-btn {
  background: none;
  border: none;
  color: #1a73e8;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 8px;
}

.confrontos-back-btn:hover {
  text-decoration: underline;
}

.confrontos-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #f0f7ff, #e8f0fe);
  border-radius: 10px;
  border: 1px solid #d4e4f7;
}

.confrontos-summary .cs-player {
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #1a2a3a;
}

.confrontos-summary .cs-score {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.3rem;
  font-weight: 800;
}

.confrontos-summary .cs-score-win { color: #2e7d32; }
.confrontos-summary .cs-score-draw { color: #e65100; font-size: 0.85rem; }
.confrontos-summary .cs-score-loss { color: #c62828; }
.confrontos-summary .cs-vs { color: #90a4ae; font-size: 0.75rem; font-weight: 600; }

/* ===== HISTORY HEADER (profile-style) ===== */
.history-header {
  background: linear-gradient(135deg, #1a73e8 0%, #1259c4 50%, #0d47a1 100%);
  padding: 24px 20px 0;
  position: relative;
  margin: 0 -12px;
  border-radius: 20px 20px 0 0;
}

.history-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to bottom, transparent, rgba(0,0,0,0.08));
  pointer-events: none;
}

.history-header-top {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 20px;
}

.history-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
  font-weight: 800;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
  margin-right: 8px;
}

.history-name-points {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.history-name {
  color: #ffffff !important;
  font-size: 1.4rem;
  margin: 0 !important;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.05;
  text-shadow: 0 2px 8px rgba(0,0,0,0.35);
  flex: 0 1 auto;
  text-align: left;
}

.history-pts-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 18px;
  padding: 10px 22px;
  flex-shrink: 0;
  margin-left: 0;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
  min-width: 80px;
}

.history-pts-value {
  font-size: 1.7em;
  font-weight: 900;
  color: #fff;
  letter-spacing: 2px;
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.history-pts-label {
  font-size: 0.5rem;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.history-stats-strip {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  border-radius: 14px 14px 0 0;
  padding: 12px 8px;
  position: relative;
  z-index: 1;
}

.hss-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.hss-val {
  font-size: 1.15rem;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}

.hss-lbl {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.65);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.hss-sep {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}

/* Color variations for history stats */
.hss-wins .hss-val, .hss-wins .hss-lbl { color: #86efac; text-shadow: 0 0 10px rgba(74, 222, 128, 0.3); }
.hss-losses .hss-val, .hss-losses .hss-lbl { color: #fda4af; text-shadow: 0 0 10px rgba(244, 63, 94, 0.3); }
.hss-draws .hss-val, .hss-draws .hss-lbl { color: #fcd34d; text-shadow: 0 0 10px rgba(251, 191, 36, 0.3); }
.hss-games .hss-val, .hss-games .hss-lbl { color: #e0f2fe; }

.history-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.history-header-row h2.history-title {
  margin: 0;
  font-size: 1.3rem;
  white-space: nowrap;
}

.history-total {
  padding: 6px 14px;
  background: linear-gradient(135deg, rgba(26, 115, 232, 0.1), rgba(79, 195, 247, 0.08));
  border: 1px solid rgba(26, 115, 232, 0.15);
  border-radius: 10px;
  color: #1a3a5c;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.history-total strong {
  color: #1a73e8;
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  .modal-content {
    padding: 24px 16px;
    min-width: 0;
    width: 95%;
  }
  .modal-wide {
    min-width: 0;
    width: 95%;
    padding: 20px 12px;
  }
  .leaderboard-table {
    font-size: 0.75rem;
  }
  .leaderboard-table th,
  .leaderboard-table td {
    padding: 6px 4px;
  }
  .leaderboard-table .col-date {
    font-size: 0.65rem;
  }
  .modal-content h2 {
    font-size: 1.3rem;
  }
  .modal-replay {
    max-width: 100%;
    padding: 16px 12px;
  }
  .replay-board {
    width: 100%;
    height: auto;
  }
  .modal-profile {
    width: 98%;
  }
  .profile-header {
    padding: 18px 16px 0;
  }
  .profile-header-top {
    gap: 12px;
    margin-bottom: 16px;
  }
  .profile-name-points {
    gap: 6px;
  }
  .profile-avatar {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }
  .profile-name {
    font-size: 1.1rem;
  }
  .profile-pts-badge {
    padding: 4px 10px;
  }
  .profile-pts-value {
    font-size: 1rem;
  }
  .profile-elo-inline {
    font-size: 0.95rem;
  }
  .pss-val {
    font-size: 1rem;
  }
  .pss-lbl {
    font-size: 0.52rem;
  }
  .pss-sep {
    height: 22px;
  }
  .profile-stat-num {
    font-size: 1.1rem;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .stat-card {
    padding: 10px 8px;
  }
  .stat-card-value {
    font-size: 1.2rem;
  }
  .stats-color-row {
    flex-direction: column;
    gap: 6px;
  }
  .profile-tab-content {
    padding: 12px 10px;
    max-height: 50vh;
  }
  .profile-games-table {
    font-size: 0.72rem;
  }
  .col-datetime {
    font-size: 0.65rem;
  }
  .game-detail-grid {
    gap: 4px 10px;
    padding: 8px 8px;
  }
  .detail-item {
    min-width: 50px;
  }
  .detail-label {
    font-size: 0.58rem;
  }
  .detail-value {
    font-size: 0.75rem;
  }
}

/* ===== OFFLINE MENU ===== */
.offline-container {
  padding: 32px 40px;
}
.offline-title {
  color: #1a73e8;
  font-size: 1.6rem;
  margin-bottom: 4px;
}
.offline-subtitle {
  color: #78909c;
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* ===== BOARD EDITOR ===== */
#editor-screen {
  display: none;
  height: auto !important;
  min-height: 100vh;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 16px 8px;
  box-sizing: border-box;
}
#editor-screen.active {
  display: flex;
}
.editor-layout {
  background: linear-gradient(145deg, #1a2a3a, #0d1b2a);
  border-radius: 16px;
  padding: 12px;
  max-width: 540px;
  width: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-sizing: border-box;
}
.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.editor-back-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  color: #b0bec5;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.2s;
}
.editor-back-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.editor-title {
  color: #4FC3F7;
  font-size: 0.95rem;
  flex: 1;
  text-align: center;
}
.editor-header-actions {
  display: flex;
  gap: 6px;
}
.editor-action-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #b0bec5;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.editor-action-btn:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* Toolbar de peças */
.editor-toolbar {
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 5px 10px;
}
.editor-toolbar-label {
  color: #78909c;
  font-size: 0.75rem;
  display: block;
  margin-bottom: 4px;
}
.editor-pieces {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.editor-piece-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}
.editor-piece-btn:hover {
  background: rgba(255,255,255,0.15);
}
.editor-piece-btn.selected {
  border-color: #4FC3F7;
  background: rgba(79, 195, 247, 0.15);
  box-shadow: 0 0 12px rgba(79, 195, 247, 0.3);
}
.editor-piece-btn .piece {
  width: 24px;
  height: 24px;
  pointer-events: none;
}

/* Board wrapper */
.editor-board-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.editor-board-row {
  display: flex;
  align-items: stretch;
  width: 100%;
}
.editor-board-wrapper .col-labels {
  display: flex;
  width: 100%;
  padding-left: 20px;
  box-sizing: border-box;
}
.editor-board-wrapper .col-labels span {
  flex: 1;
  text-align: center;
  color: #4FC3F7;
  font-size: 0.72rem;
  font-weight: 600;
}
.editor-board-wrapper .row-labels {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  width: 20px;
  flex-shrink: 0;
  padding-right: 3px;
}
.editor-board-wrapper .row-labels span {
  color: #4FC3F7;
  font-size: 0.72rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

#editor-board {
  flex: 1;
  aspect-ratio: 1 / 1;
  height: auto;
  width: auto;
  min-width: 0;
  contain: none;
}
#editor-board .cell {
  width: 100%;
  height: 100%;
  cursor: pointer;
  contain: none;
}
#editor-board .cell.dark:hover {
  outline: 2px solid rgba(79, 195, 247, 0.6);
  outline-offset: -2px;
  z-index: 1;
}
#editor-board .piece {
  width: 76%;
  height: 76%;
}

/* Info contagem */
.editor-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.editor-count {
  font-size: 0.95rem;
  font-weight: 700;
  color: #e0e0e0;
}
.editor-vs {
  color: #546e7a;
  font-size: 0.85rem;
}

/* Quem inicia */
.editor-start-options {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.editor-start-label {
  color: #78909c;
  font-size: 0.82rem;
}
.editor-start-btns {
  display: flex;
  gap: 6px;
}
.editor-start-btn {
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.05);
  color: #b0bec5;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.2s;
}
.editor-start-btn.active {
  border-color: #4FC3F7;
  background: rgba(79, 195, 247, 0.15);
  color: #4FC3F7;
}

/* Acções */
.editor-actions {
  text-align: center;
}
.editor-actions .menu-btn {
  max-width: 280px;
  margin: 0 auto;
  padding: 8px 16px;
  font-size: 0.9rem;
}

/* Responsivo editor */
@media (max-width: 480px) {
  .editor-layout {
    padding: 8px;
    gap: 4px;
    border-radius: 0;
  }
  .editor-piece-btn {
    width: 36px;
    height: 36px;
  }
  .editor-piece-btn .piece {
    width: 24px;
    height: 24px;
  }
}
