/**
 * ============================================================================
 * CỜ CARO (GOMOKU) MULTIPLAYER: MODERN / PREMIUM / MINIMAL GAME STYLING
 * Tác giả: Huỳnh Nguyễn Thành Đạt
 * Phong cách: Dark Slate Cyber-Gomoku, 3D Glass Pieces, Retina Responsive Board
 * ============================================================================
 */

:root {
  --caro-bg-dark: #090d16;
  --caro-card-bg: rgba(17, 24, 39, 0.85);
  --caro-border-glass: rgba(255, 255, 255, 0.1);
  --caro-accent-x: #38bdf8;
  --caro-accent-o: #f43f5e;
  --caro-gold: #f59e0b;
  --caro-emerald: #10b981;
  --caro-purple: #a855f7;
  --caro-font: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.caro-wrapper {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0.5rem 1rem 3.5rem;
  font-family: var(--caro-font);
  color: #f8fafc;
}

/* ==========================================================================
   1. RECONNECT & REMATCH BANNERS
   ========================================================================== */
.caro-banner-reconnect {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.88rem;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.45);
  animation: caroPulseWarning 1.5s infinite;
}

@keyframes caroPulseWarning {
  0% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.02); }
  100% { transform: translateX(-50%) scale(1); }
}

.caro-banner-rematch {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.5);
  border-radius: 14px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.2);
  animation: fadeIn 0.3s ease;
}

/* ==========================================================================
   2. LOBBY SCREEN (SẢNH CHÍNH & CHỌN CHẾ ĐỘ)
   ========================================================================== */
.caro-lobby-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.caro-lobby-container.is-hidden,
.caro-lobby-container[style*="display: none"] {
  display: none !important;
}

/* Hero Profile Card */
.caro-profile-hero {
  background: radial-gradient(circle at 100% 0%, rgba(56, 189, 248, 0.12), transparent 50%),
              radial-gradient(circle at 0% 100%, rgba(244, 63, 94, 0.12), transparent 50%),
              var(--caro-card-bg);
  border: 1px solid var(--caro-border-glass);
  border-radius: 16px;
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  flex-wrap: wrap;
}

.profile-hero-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar-frame {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--caro-accent-x);
  overflow: hidden;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: #1e293b;
}

.user-avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-hero-info h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.rank-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  border: 1.5px solid #10b981;
  color: #10b981;
  letter-spacing: 0.5px;
}

.profile-hero-stats {
  font-size: 0.85rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.profile-hero-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.elo-stat-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  border-radius: 14px;
  padding: 0.75rem 1.4rem;
  text-align: center;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.15);
}

.elo-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 1px;
}

.elo-value {
  font-size: 1.75rem;
  font-weight: 900;
  color: #fbbf24;
  line-height: 1.1;
  font-family: 'Inter', monospace;
}

/* Quick Action Modes Grid */
.caro-modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
}

.caro-mode-card {
  background: var(--caro-card-bg);
  border: 1.5px solid var(--caro-border-glass);
  border-radius: 18px;
  padding: 1.6rem 1.4rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
  overflow: hidden;
}

.caro-mode-card:hover {
  transform: translateY(-5px);
  border-color: var(--caro-accent-x);
  box-shadow: 0 12px 30px rgba(56, 189, 248, 0.2);
}

.caro-mode-card.primary {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(59, 130, 246, 0.15)), var(--caro-card-bg);
  border-color: rgba(6, 182, 212, 0.4);
}

.caro-mode-card.primary:hover {
  box-shadow: 0 12px 35px rgba(6, 182, 212, 0.3);
  border-color: #38bdf8;
}

.caro-mode-card.bot-card {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.18), rgba(99, 102, 241, 0.18)), var(--caro-card-bg);
  border-color: rgba(168, 85, 247, 0.45);
}

.caro-mode-card.bot-card:hover {
  box-shadow: 0 12px 35px rgba(168, 85, 247, 0.35);
  border-color: #c084fc;
}

.badge-mode-tag {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #a855f7, #6366f1);
  color: #fff;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.4);
}

.badge-mode-tag.online {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.4);
}

.mode-card-icon {
  font-size: 2.4rem;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

.mode-card-info h3 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
  color: #fff;
}

.mode-card-info p {
  font-size: 0.82rem;
  color: #94a3b8;
  margin: 0;
  line-height: 1.45;
}

.btn-card-action {
  width: 100%;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

/* ==========================================================================
   3. IN-GAME ARENA (KHU VỰC THI ĐẤU)
   ========================================================================== */
.caro-game-arena {
  display: none;
}

.caro-game-arena.is-active {
  display: block !important;
}

.caro-game-arena.is-hidden {
  display: none !important;
}

/* Top Match Bar */
.caro-match-topbar {
  background: var(--caro-card-bg);
  border: 1px solid var(--caro-border-glass);
  border-radius: 16px;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.match-room-code-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #94a3b8;
}

.room-code-tag {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-family: monospace;
  font-weight: 800;
  letter-spacing: 1.5px;
}

.btn-copy-room {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.btn-copy-room:hover { color: #38bdf8; }

.status-pill {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.status-pill.my-turn {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #34d399;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.status-pill.their-turn {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}

.status-pill.waiting {
  background: rgba(148, 163, 184, 0.15);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #cbd5e1;
}

.status-pill.finished {
  background: rgba(244, 63, 94, 0.2);
  border: 1px solid rgba(244, 63, 94, 0.5);
  color: #fb7185;
}

/* Central Stage: Players & Canvas */
.caro-battle-stage {
  display: grid;
  grid-template-columns: 240px 1fr 240px;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

/* Player Profile Card in Match */
.caro-player-card {
  background: var(--caro-card-bg);
  border: 1.5px solid var(--caro-border-glass);
  border-radius: 18px;
  padding: 1.25rem 1rem;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
}

.caro-player-card.active-turn {
  border-color: #38bdf8;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.25);
  transform: scale(1.02);
}

.caro-player-card.player-o.active-turn {
  border-color: #f43f5e;
  box-shadow: 0 0 25px rgba(244, 63, 94, 0.25);
}

.player-piece-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 1.3rem;
  font-weight: 900;
  margin-bottom: 0.65rem;
}

.player-piece-badge.badge-x {
  background: rgba(56, 189, 248, 0.2);
  border: 1.5px solid #38bdf8;
  color: #38bdf8;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.player-piece-badge.badge-o {
  background: rgba(244, 63, 94, 0.2);
  border: 1.5px solid #f43f5e;
  color: #f43f5e;
  box-shadow: 0 0 15px rgba(244, 63, 94, 0.3);
}

.card-avatar-wrap {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin: 0 auto 0.65rem;
  border: 2px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}

.card-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.caro-player-card.active-turn .card-avatar-wrap {
  border-color: #38bdf8;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.4);
}

.caro-player-card.player-o.active-turn .card-avatar-wrap {
  border-color: #f43f5e;
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.4);
}

.card-player-name {
  font-size: 1rem;
  font-weight: 800;
  margin: 0 0 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-player-rating {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.card-timer-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.45rem;
  font-family: 'Inter', monospace;
  font-size: 1.25rem;
  font-weight: 800;
  color: #e2e8f0;
}

.card-timer-box.timer-warning {
  border-color: #ef4444;
  color: #ef4444;
  animation: timerPulse 1s infinite;
}

@keyframes timerPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Canvas Board Center */
.caro-canvas-center-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 100%;
}

#caroCanvas {
  border-radius: 16px;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.55);
  touch-action: none !important;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
  display: block;
  margin: 0 auto;
  max-width: 100%;
}

/* Bottom Controls & Chat Deck */
.caro-arena-bottom-deck {
  background: var(--caro-card-bg);
  border: 1px solid var(--caro-border-glass);
  border-radius: 18px;
  padding: 1rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.caro-chat-box {
  display: flex;
  flex-direction: column;
  height: 200px;
}

.caro-chat-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.chat-bubble {
  font-size: 0.82rem;
  line-height: 1.4;
  display: flex;
  gap: 0.4rem;
}

.chat-bubble.system {
  color: #38bdf8;
  font-style: italic;
}

.chat-sender {
  font-weight: 700;
  color: #94a3b8;
  white-space: nowrap;
}

.caro-quick-chips-row {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 0.5rem;
}

.caro-quick-chips-row::-webkit-scrollbar { display: none; }

.caro-quick-chip {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.caro-quick-chip:hover {
  color: #fff;
  border-color: #38bdf8;
}

.caro-chat-input-row {
  display: flex;
  gap: 0.5rem;
}

.caro-chat-input-row input {
  flex: 1;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
}

.caro-chat-input-row input:focus { border-color: #38bdf8; }

.arena-actions-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
}

.arena-actions-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   4. MODAL SYSTEM (FIXED VIEWPORT OVERLAY - ZERO SCROLL DOWN NEEDED)
   ========================================================================== */
.modal {
  position: fixed !important;
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(4, 7, 16, 0.82) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  z-index: 99999 !important;
  display: none;
  align-items: center !important;
  justify-content: center !important;
  padding: 1.25rem !important;
  box-sizing: border-box !important;
  overflow-y: auto !important;
}

.modal.active,
.modal[style*="display: flex"] {
  display: flex !important;
}

.modal-dialog {
  position: relative !important;
  width: 100% !important;
  max-width: 520px !important;
  background: #0f172a !important;
  border: 1.5px solid rgba(56, 189, 248, 0.35) !important;
  border-radius: 20px !important;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(56, 189, 248, 0.25) !important;
  margin: auto !important;
  overflow: hidden !important;
  animation: modalScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
  z-index: 100000 !important;
  color: #f8fafc !important;
}

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

.modal-backdrop {
  position: absolute !important;
  inset: 0 !important;
  background: transparent !important;
  z-index: 0 !important;
}

.modal-content {
  position: relative !important;
  z-index: 1 !important;
  background: transparent !important;
}

.modal-header {
  padding: 1.15rem 1.4rem 0.9rem !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

.modal-title {
  font-size: 1.15rem !important;
  font-weight: 800 !important;
  color: #fff !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
}

.modal-close {
  background: none !important;
  border: none !important;
  color: #94a3b8 !important;
  font-size: 1.6rem !important;
  cursor: pointer !important;
  line-height: 1 !important;
  padding: 0 !important;
  transition: color 0.2s ease !important;
}

.modal-close:hover {
  color: #fff !important;
}

.modal-body {
  padding: 1.25rem 1.4rem !important;
}

.modal-footer {
  padding: 1rem 1.4rem 1.25rem !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 0.75rem !important;
}

.modal-result-content {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.result-icon-huge {
  font-size: 4rem;
  display: block;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 6px 15px rgba(0, 0, 0, 0.4));
}

.result-title-huge {
  font-size: 1.8rem;
  font-weight: 900;
  margin: 0 0 0.5rem;
}

.result-desc-text {
  color: #94a3b8;
  font-size: 0.95rem;
  max-width: 360px;
  margin: 0 auto 1.5rem;
}

/* Radio button option cards */
.caro-options-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.caro-options-row-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.55rem;
}

.caro-radio-card {
  cursor: pointer;
}

.caro-radio-card input { display: none; }

.radio-card-body {
  background: rgba(30, 41, 59, 0.6);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.75rem;
  text-align: center;
  transition: all 0.2s ease;
}

.caro-radio-card input:checked + .radio-card-body {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.radio-card-body strong {
  display: block;
  font-size: 0.95rem;
  color: #fff;
}

.radio-card-body span {
  font-size: 0.72rem;
  color: #94a3b8;
}

/* Bot Difficulty Themes */
.caro-radio-card.diff-easy input:checked + .radio-card-body {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.16);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.3);
}

.caro-radio-card.diff-medium input:checked + .radio-card-body {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.16);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.3);
}

.caro-radio-card.diff-hard input:checked + .radio-card-body {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.16);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.3);
}

.caro-radio-card.diff-master input:checked + .radio-card-body {
  border-color: #a855f7;
  background: rgba(168, 85, 247, 0.2);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

body.page-caro .portal-content {
  padding: 0.5rem 0.85rem 2rem !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Matchmaking radar spinner */
.radar-spinner {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: #38bdf8;
  margin: 1.5rem auto;
  animation: radarSpin 1.2s linear infinite;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.3);
}

@keyframes radarSpin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   5. FLOATING CONFIRMATION BAR & MOBILE CHAT
   ========================================================================== */
.caro-canvas-center-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Floating Move Confirmation Bar (Touch / Precision Mode) - Placed cleanly below board */
.caro-confirm-move-bar {
  margin-top: 0.65rem;
  background: rgba(15, 23, 42, 0.95);
  border: 1.5px solid #38bdf8;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 20px rgba(56, 189, 248, 0.35);
  backdrop-filter: blur(12px);
  animation: slideUpFadeIn 0.22s ease-out;
  white-space: nowrap;
}

@keyframes slideUpFadeIn {
  0% { transform: translateY(10px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.confirm-cell-tag {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-family: monospace;
  letter-spacing: 1px;
}

.btn-confirm-action {
  background: linear-gradient(135deg, #10b981, #059669);
  border: none;
  color: #fff;
  font-weight: 800;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s ease;
}

.btn-confirm-action:hover {
  transform: scale(1.03);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.5);
}

.btn-cancel-action {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel-action:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ef4444;
  border-color: #ef4444;
}

/* Chat bubble enhancements */
.chat-bubble.chat-me {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.35);
  margin-left: auto;
}

.chat-bubble.chat-me .chat-sender {
  color: #38bdf8;
}

.unread-badge-pill {
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  margin-left: 0.35rem;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.caro-mobile-quickbar {
  display: none;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.5rem 0;
  scrollbar-width: none;
}

.caro-mobile-quickbar::-webkit-scrollbar {
  display: none;
}

/* Matchmaking elapsed timer */
.matchmaking-timer-box {
  font-family: 'Inter', monospace;
  font-size: 1.6rem;
  font-weight: 900;
  color: #38bdf8;
  margin: 0.8rem 0;
  letter-spacing: 2px;
}

/* ==========================================================================
   6. RESPONSIVE DESIGN (TABLET & MOBILE)
   ========================================================================== */
@media (max-width: 992px) {
  /* Side-by-side players directly above board on mobile */
  .caro-battle-stage {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "playerX playerO"
      "board board";
    gap: 0.65rem;
    align-items: stretch;
    width: 100%;
    max-width: 580px;
    margin: 0 auto 0.85rem;
  }

  #playerXCard {
    grid-area: playerX;
  }

  #playerOCard {
    grid-area: playerO;
  }

  .caro-canvas-center-wrapper {
    grid-area: board;
    width: 100%;
  }

  .caro-player-card {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 0.75rem;
    border-radius: 14px;
    text-align: left;
    justify-content: flex-start;
  }

  .player-piece-badge {
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 1rem;
    margin-bottom: 0;
    border-radius: 8px;
  }

  .card-avatar-wrap {
    width: 38px;
    height: 38px;
    min-width: 38px;
    margin: 0;
    font-size: 1.15rem;
  }

  .player-card-meta {
    flex: 1;
    min-width: 0;
  }

  .card-player-name {
    font-size: 0.85rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .card-timer-box {
    font-size: 0.92rem;
    padding: 0.15rem 0.45rem;
    margin-top: 0.2rem;
    display: inline-block;
  }

  .caro-arena-bottom-deck {
    grid-template-columns: 1fr;
  }

  .caro-mobile-quickbar {
    display: flex;
  }
}

@media (max-width: 768px) {
  /* Center modal in viewport on mobile */
  .modal-dialog {
    margin: auto !important;
    width: calc(100% - 1.5rem) !important;
    max-width: 480px !important;
    border-radius: 20px !important;
    max-height: calc(100vh - 2.5rem) !important;
    overflow-y: auto !important;
    animation: modalScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .caro-modes-grid {
    grid-template-columns: 1fr;
  }

  .hide-mobile-mini {
    display: none;
  }

  .caro-match-topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "badge actions"
      "turn turn";
    padding: 0.5rem 0.75rem;
    gap: 0.5rem 0.6rem;
    align-items: center;
  }

  .match-room-code-badge {
    grid-area: badge;
  }

  .caro-topbar-actions {
    grid-area: actions;
    justify-content: flex-end;
  }

  #caroTurnIndicator {
    grid-area: turn;
    width: 100%;
    text-align: center;
  }

  #caroTurnIndicator .status-pill {
    display: inline-block;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    font-size: 0.76rem;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .room-code-tag {
    padding: 0.12rem 0.4rem;
    font-size: 0.75rem;
    letter-spacing: 0.8px;
  }
}

@media (max-width: 480px) {
  .caro-wrapper {
    padding: 0.35rem 0.5rem 3rem;
  }

  #caroCanvas {
    max-width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
  }

  .caro-topbar-actions .btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
  }

  .profile-hero-stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .caro-player-card {
    padding: 0.45rem 0.55rem;
    gap: 0.35rem;
  }

  .card-avatar-wrap {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .card-player-name {
    font-size: 0.78rem;
  }

  .card-timer-box {
    font-size: 0.85rem;
    padding: 0.1rem 0.35rem;
  }

  .caro-confirm-move-bar {
    padding: 0.25rem 0.55rem;
    gap: 0.35rem;
    max-width: calc(100% - 1rem);
  }

  .confirm-cell-tag {
    font-size: 0.75rem;
    padding: 0.15rem 0.45rem;
  }

  .btn-confirm-action {
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
  }
}

/* ================= LOBBY & ONLINE CHALLENGE STYLES ================= */
.caro-online-users-list {
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 4px;
}
.caro-online-users-list::-webkit-scrollbar {
  width: 5px;
}
.caro-online-users-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}
.online-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  transition: all 0.2s ease;
}
.online-player-row:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(56, 189, 248, 0.3);
  transform: translateY(-1px);
}
.online-player-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.online-player-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-weight: 700;
  color: #f1f5f9;
  border: 2px solid rgba(255, 255, 255, 0.1);
}
.online-player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.online-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #0f172a;
}
.status-idle { background: #10b981; }
.status-in-game { background: #f59e0b; }
.status-offline { background: #64748b; }
.online-player-details h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0 0 2px 0;
}
.online-player-meta {
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.online-player-meta .rating-tag {
  color: #38bdf8;
  font-weight: 600;
}
.radar-spinner {
  width: 60px;
  height: 60px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(56, 189, 248, 0.15);
  border-top-color: #38bdf8;
  animation: radarSpin 1s linear infinite;
}
@keyframes radarSpin {
  to { transform: rotate(360deg); }
}
.incoming-invite-avatar-pulse {
  width: 70px;
  height: 70px;
  margin: 0 auto;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  border: 3px solid #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  animation: invitePulse 1.5s infinite;
}
@keyframes invitePulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.5); }
  70% { box-shadow: 0 0 0 15px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.invite-settings-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.invite-countdown-bar {
  background: rgba(244, 63, 94, 0.1);
  border: 1px dashed rgba(244, 63, 94, 0.35);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  display: inline-block;
}
