/* ============================================================
   CRICSCORE PRO — PREMIUM DESIGN SYSTEM
   ============================================================ */

:root,
[data-theme="dark"] {
  --primary: #009270;
  --primary-dark: #006b52;
  --primary-light: #00b388;
  --primary-glow: rgba(0, 146, 112, 0.25);
  --bg: #0a0e17;
  --bg-secondary: #111827;
  --surface: rgba(17, 24, 39, 0.85);
  --surface-glass: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);
  --text: #f1f5f9;
  --text-light: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --red: #ef4444;
  --red-dark: #dc2626;
  --gold: #f59e0b;
  --six-color: #8b5cf6;
  --four-color: #3b82f6;
  --gradient-primary: linear-gradient(135deg, #006b52 0%, #009270 50%, #00b388 100%);
  --gradient-fire: linear-gradient(135deg, #f97316, #ef4444, #ec4899);
  --gradient-gold: linear-gradient(135deg, #f59e0b, #fbbf24, #f97316);
  --gradient-blue: linear-gradient(135deg, #3b82f6, #60a5fa, #1d4ed8);
  --gradient-purple: linear-gradient(135deg, #8b5cf6, #a78bfa, #6d28d9);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px var(--primary-glow);
  --nav-bg: rgba(0, 0, 0, 0.5);
  --nav-text: #fff;
  --modal-bg: linear-gradient(145deg, #1e293b, #0f172a);
  --input-bg: rgba(255, 255, 255, 0.04);
  --select-option-bg: #1e293b;
}

[data-theme="light"] {
  --primary: #009270;
  --primary-dark: #006b52;
  --primary-light: #00b388;
  --primary-glow: rgba(0, 146, 112, 0.15);
  --bg: #f0f4f8;
  --bg-secondary: #e2e8f0;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-glass: rgba(255, 255, 255, 0.6);
  --surface-hover: rgba(0, 0, 0, 0.03);
  --text: #1e293b;
  --text-light: #475569;
  --text-muted: #64748b;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  --red: #dc2626;
  --red-dark: #b91c1c;
  --gold: #d97706;
  --six-color: #7c3aed;
  --four-color: #2563eb;
  --gradient-primary: linear-gradient(135deg, #006b52 0%, #009270 50%, #00b388 100%);
  --gradient-fire: linear-gradient(135deg, #f97316, #ef4444, #ec4899);
  --gradient-gold: linear-gradient(135deg, #f59e0b, #fbbf24, #f97316);
  --gradient-blue: linear-gradient(135deg, #3b82f6, #60a5fa, #1d4ed8);
  --gradient-purple: linear-gradient(135deg, #8b5cf6, #a78bfa, #6d28d9);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 40px var(--primary-glow);
  --nav-bg: rgba(255, 255, 255, 0.8);
  --nav-text: #1e293b;
  --modal-bg: linear-gradient(145deg, #ffffff, #f8fafc);
  --input-bg: rgba(0, 0, 0, 0.03);
  --select-option-bg: #ffffff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', 'Roboto', sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  padding-bottom: 60px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========== ANIMATED BACKGROUND ========== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 30%, rgba(0, 146, 112, 0.08), transparent),
    radial-gradient(ellipse 500px 500px at 80% 70%, rgba(139, 92, 246, 0.06), transparent),
    radial-gradient(ellipse 400px 300px at 60% 20%, rgba(59, 130, 246, 0.05), transparent);
  z-index: -1;
  animation: bgShift 20s ease infinite;
}

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

/* Floating particles background */
.bg-particles {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-particles .particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: rgba(0, 146, 112, 0.3);
  border-radius: 50%;
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% { transform: translateY(100vh) scale(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* ========== SPLASH SCREEN ========== */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #030712;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

.splash-screen.hide {
  opacity: 0;
  visibility: hidden;
}

.splash-bg-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(100px);
  animation: splashGlow 3s ease-in-out infinite alternate;
}

.splash-bg-glow.g1 {
  top: 20%;
  left: 30%;
  background: rgba(0, 146, 112, 0.15);
}

.splash-bg-glow.g2 {
  bottom: 20%;
  right: 20%;
  background: rgba(139, 92, 246, 0.1);
  animation-delay: 1s;
}

@keyframes splashGlow {
  0% { transform: scale(1); }
  100% { transform: scale(1.3); }
}

/* 3D Cricket ball */
.cricket-ball-3d {
  width: 120px;
  height: 120px;
  position: relative;
  perspective: 600px;
  margin-bottom: 30px;
}

.ball-sphere {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e74c3c, #c0392b 40%, #922b21 70%, #641e16 100%);
  position: relative;
  animation: ballSpin 2s ease-in-out infinite;
  box-shadow:
    inset -20px -15px 30px rgba(0, 0, 0, 0.4),
    inset 8px 8px 20px rgba(255, 255, 255, 0.15),
    0 0 60px rgba(231, 76, 60, 0.4),
    0 20px 40px rgba(0, 0, 0, 0.5);
}

.ball-sphere::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 5%;
  right: 5%;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, #f5f5f5 20%, #f5f5f5 80%, transparent 100%);
  transform: translateY(-50%);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.ball-sphere::after {
  content: '';
  position: absolute;
  top: 15%;
  left: 25%;
  width: 30px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  filter: blur(4px);
}

@keyframes ballSpin {
  0% { transform: rotateY(0deg) rotateX(-5deg); }
  50% { transform: rotateY(180deg) rotateX(5deg) scale(1.05); }
  100% { transform: rotateY(360deg) rotateX(-5deg); }
}

/* Ball stitching detail */
.ball-stitch {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 50%;
  animation: ballSpin 2s ease-in-out infinite;
}

.ball-stitch::before,
.ball-stitch::after {
  content: '';
  position: absolute;
  border: 1.5px dashed rgba(255, 255, 255, 0.35);
  border-radius: 50%;
}

.ball-stitch::before {
  top: 12%;
  left: 20%;
  width: 30%;
  height: 76%;
  transform: rotate(-15deg);
}

.ball-stitch::after {
  top: 12%;
  right: 20%;
  width: 30%;
  height: 76%;
  transform: rotate(15deg);
}

.splash-title {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -2px;
  background: linear-gradient(135deg, #00b388, #009270, #60a5fa, #8b5cf6);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientText 3s ease infinite, splashTitleIn 1s ease 0.3s both;
  text-shadow: none;
}

@keyframes gradientText {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes splashTitleIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.splash-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  animation: splashSubIn 0.8s ease 0.6s both;
}

@keyframes splashSubIn {
  from { opacity: 0; transform: translateY(10px); letter-spacing: 10px; }
  to { opacity: 1; transform: translateY(0); letter-spacing: 3px; }
}

.splash-loader {
  margin-top: 40px;
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
  animation: splashSubIn 0.8s ease 0.8s both;
}

.splash-loader-bar {
  height: 100%;
  width: 0%;
  background: var(--gradient-primary);
  border-radius: 4px;
  animation: loaderFill 2.5s ease 1s forwards;
  box-shadow: 0 0 15px var(--primary-glow);
}

@keyframes loaderFill {
  to { width: 100%; }
}

/* Splash stadium light effects */
.splash-light-beams {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.splash-light-beams .beam {
  position: absolute;
  bottom: 0;
  width: 2px;
  height: 0;
  background: linear-gradient(to top, transparent, rgba(0, 146, 112, 0.3));
  animation: lightBeam 2s ease forwards;
}

@keyframes lightBeam {
  to { height: 100%; }
}


/* ========== NAVBAR ========== */
.nav {
  background: var(--nav-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--nav-text);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  transition: all 0.4s ease;
}

.nav::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.5;
}

.nav-brand {
  font-size: 1.4rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: -0.5px;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

.nav-tabs span {
  cursor: pointer;
  opacity: 0.6;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.nav-tabs span::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 8px;
  z-index: -1;
}

.nav-tabs span:hover {
  opacity: 1;
}

.nav-tabs span.active {
  opacity: 1;
  color: #fff;
}

.nav-tabs span.active::before {
  opacity: 1;
}

.admin-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 8px 18px;
  border-radius: 24px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(4px);
  position: relative;
  overflow: hidden;
}

.admin-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.admin-btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.admin-btn:hover::before {
  opacity: 0.15;
}

/* Live dot pulse */
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  animation: live-pulse 1.4s ease-in-out infinite;
}

/* ========== LAYOUT ========== */
.container {
  max-width: 1000px;
  margin: 24px auto;
  padding: 0 16px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: viewSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes viewSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

h3 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff, var(--text-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
  padding-bottom: 12px;
}

h3::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 40px;
  height: 3px;
  background: var(--gradient-primary);
  border-radius: 3px;
}

/* ========== GLASS CARD ========== */
.card {
  background: var(--surface);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ========== TABLES ========== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  text-align: left;
  padding: 10px 8px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

td {
  padding: 12px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.2s ease;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--surface-hover);
}

.text-right { text-align: right; }
.text-center { text-align: center; }

/* ========== MATCH CARDS ========== */
.match-card {
  cursor: pointer;
  border-left: 4px solid var(--primary);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
}

.match-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-glow), transparent);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.match-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 12px 40px rgba(0, 146, 112, 0.2);
  border-left-color: var(--primary-light);
}

.match-card:hover::after {
  opacity: 1;
}

.match-card:active {
  transform: translateY(-2px) scale(0.99);
}

.match-card-header {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  letter-spacing: 0.3px;
  position: relative;
  z-index: 1;
}

.match-team {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  position: relative;
  z-index: 1;
}

.match-status {
  font-size: 0.85rem;
  color: var(--primary-light);
  margin-top: 10px;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

.status-red { color: var(--red); }

/* ========== SCORECARD ========== */
.score-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 16px;
}

.team-score {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.team-overs {
  font-size: 1rem;
  color: var(--text-light);
  font-weight: 400;
}

.crr {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-top: 4px;
  font-weight: 500;
}

.batsman-row.active { background: rgba(0, 146, 112, 0.08); }
.strike-icon { color: var(--primary); font-size: 13px; margin-left: 4px; vertical-align: middle; }

/* ========== BALL TIMELINE ========== */
.timeline {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-top: 10px;
}

@keyframes ballPop {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.ball-badge {
  min-width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-light);
  animation: ballPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex-shrink: 0;
  border: 1px solid var(--border);
  transition: transform 0.2s ease;
}

.ball-badge:hover {
  transform: scale(1.2);
}

.ball-W {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 2px 12px rgba(239, 68, 68, 0.5);
  border: none;
}

.ball-4 {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.5);
  border: none;
}

.ball-6 {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  box-shadow: 0 2px 12px rgba(139, 92, 246, 0.5);
  border: none;
}

.ball-WD, .ball-NB {
  border: 1.5px solid var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-light);
}

/* Scrollbar styling for timeline */
.timeline::-webkit-scrollbar { height: 4px; }
.timeline::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); border-radius: 4px; }
.timeline::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }

/* ========== MODALS ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-overlay.open {
  display: flex;
  animation: overlayFadeIn 0.3s ease;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border-radius: 20px;
  width: 420px;
  max-width: 92%;
  padding: 28px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(30px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, select {
  width: 100%;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), var(--shadow-glow);
  background: rgba(255, 255, 255, 0.06);
}

input::placeholder {
  color: var(--text-muted);
}

select option {
  background: #1e293b;
  color: var(--text);
}

.btn {
  padding: 11px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.1), transparent);
  pointer-events: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
  box-shadow: 0 8px 30px var(--primary-glow);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--primary);
  background: rgba(0, 146, 112, 0.08);
}

.btn-cancel {
  background: linear-gradient(135deg, #475569, #334155);
  color: #fff;
}

.w-100 { width: 100%; }

/* ========== EXTRAS MODAL (in-screen prompt) ========== */
.extras-modal-content { text-align: center; }
.extras-modal-content .extras-title { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.extras-modal-content .extras-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; }
.extras-modal-content .extras-emoji { font-size: 3rem; margin-bottom: 8px; }

.extras-run-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.extras-run-btn {
  padding: 16px 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid var(--border);
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.extras-run-btn:hover {
  border-color: var(--primary);
  background: rgba(0, 146, 112, 0.1);
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.extras-run-btn.selected {
  border-color: var(--primary);
  background: rgba(0, 146, 112, 0.15);
  box-shadow: 0 4px 20px var(--primary-glow);
  transform: scale(1.05);
}

.modal-btn-row { display: flex; gap: 10px; justify-content: center; }
.modal-btn-row .btn { min-width: 120px; }

/* ========== UNDO BUTTON ========== */
.undo-btn {
  background: var(--gradient-gold);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.undo-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.5);
}

.undo-btn:active { transform: translateY(0); }

/* ========== ADMIN PANEL ========== */
.admin-panel { display: none; }
.admin-panel.active { display: block; }

.admin-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  gap: 4px;
}

.admin-tab {
  padding: 12px 18px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 8px 8px 0 0;
  transition: all 0.3s ease;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.admin-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.admin-tab.active {
  border-color: var(--primary);
  color: var(--primary-light);
  background: rgba(0, 146, 112, 0.08);
}

.squad-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.squad-pill {
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 14px;
  border-radius: 24px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.squad-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.squad-pill span {
  cursor: pointer;
  color: var(--red);
  font-weight: 700;
  transition: transform 0.2s ease;
}

.squad-pill span:hover {
  transform: scale(1.2);
}

.scoring-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.ctrl-btn {
  padding: 16px;
  font-size: 1.15rem;
  font-weight: 800;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text);
  position: relative;
  overflow: hidden;
}

.ctrl-btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transition: all 0.5s ease;
  transform: translate(-50%, -50%);
}

.ctrl-btn:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  border-color: var(--primary);
}

.ctrl-btn:hover::before {
  width: 200px;
  height: 200px;
}

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

.ctrl-W {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.1));
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.ctrl-extra {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(217, 119, 6, 0.08));
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.25);
}

/* ========== SCORING BOARD ENHANCEMENTS ========== */
.score-big {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: -2px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  padding: 4px 12px;
  border-radius: 24px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 2px 12px rgba(239, 68, 68, 0.5);
  animation: badgePulse 2s ease infinite;
}

@keyframes badgePulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 2px 20px rgba(239, 68, 68, 0.8); }
}

/* ========== MATCH SUB-TABS ========== */
.match-subtabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.match-subtab {
  flex: 1;
  padding: 14px 16px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text-muted);
  position: relative;
  border-right: 1px solid var(--border);
  background: transparent;
}

.match-subtab:last-child { border-right: none; }

.match-subtab:hover {
  background: rgba(0, 146, 112, 0.08);
  color: var(--primary-light);
}

.match-subtab.active {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 4px 20px var(--primary-glow);
}

.match-subtab-content {
  display: none;
}

.match-subtab-content.active {
  display: block;
  animation: tabContentIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes tabContentIn {
  from {
    opacity: 0;
    transform: translateX(15px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========== CELEBRATION OVERLAY ========== */
@keyframes celebZoom {
  0% { opacity: 0; transform: scale(0.1) rotate(-10deg); }
  30% { opacity: 1; transform: scale(1.15) rotate(2deg); }
  70% { opacity: 1; transform: scale(0.95) rotate(-1deg); }
  100% { opacity: 0; transform: scale(2.5) rotate(0deg); }
}

@keyframes wicketShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}

@keyframes wicketFlash {
  0% { opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

.celeb-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.celeb-text {
  font-weight: 900;
  letter-spacing: -3px;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
  animation: celebZoom 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.celeb-text-four {
  font-size: 7rem;
  background: var(--gradient-blue);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 30px rgba(59, 130, 246, 0.7));
}

.celeb-text-six {
  font-size: 9rem;
  background: var(--gradient-gold);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 30px rgba(245, 158, 11, 0.7));
}

.celeb-text-wicket {
  font-size: 7rem;
  color: #fff;
  filter: drop-shadow(0 6px 30px rgba(239, 68, 68, 0.8));
}

/* ========== SQUAD GRID ========== */
.squad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.squad-player-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.squad-player-card:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  border-color: var(--primary);
  background: rgba(0, 146, 112, 0.08);
}

/* ========== LIVE MINI CARD ========== */
.live-batter-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  transition: all 0.3s ease;
}

.live-batter-card.on-strike {
  border-color: var(--primary);
  background: rgba(0, 146, 112, 0.08);
  box-shadow: 0 2px 20px var(--primary-glow);
}

.live-bowler-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(37, 99, 235, 0.04));
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 14px;
  padding: 16px 18px;
  margin-top: 12px;
}

/* ========== STAGGERED ANIMATIONS ========== */
@keyframes staggerFadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Apply to lists of cards */
.card:nth-child(1) { animation: staggerFadeUp 0.4s ease 0.05s both; }
.card:nth-child(2) { animation: staggerFadeUp 0.4s ease 0.1s both; }
.card:nth-child(3) { animation: staggerFadeUp 0.4s ease 0.15s both; }
.card:nth-child(4) { animation: staggerFadeUp 0.4s ease 0.2s both; }
.card:nth-child(5) { animation: staggerFadeUp 0.4s ease 0.25s both; }
.card:nth-child(6) { animation: staggerFadeUp 0.4s ease 0.3s both; }

/* ========== SCORE NUMBER GLOW EFFECT ========== */
@keyframes scoreGlow {
  0%, 100% { text-shadow: 0 0 20px var(--primary-glow); }
  50% { text-shadow: 0 0 40px var(--primary-glow), 0 0 60px rgba(0, 146, 112, 0.1); }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .nav {
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-tabs {
    font-size: 0.8rem;
    gap: 2px;
    order: 3;
    width: 100%;
    justify-content: space-around;
  }

  .nav-tabs span {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .splash-title {
    font-size: 2rem;
  }

  .cricket-ball-3d {
    width: 80px;
    height: 80px;
  }

  .ball-sphere {
    width: 80px;
    height: 80px;
  }

  h3 {
    font-size: 1.3rem;
  }

  .match-subtab {
    padding: 10px 8px;
    font-size: 0.8rem;
  }

  .celeb-text-four { font-size: 5rem; }
  .celeb-text-six { font-size: 6rem; }
  .celeb-text-wicket { font-size: 5rem; }
}

/* ========== CUSTOM SCROLLBAR ========== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ========== SELECTION ========== */
::selection {
  background: rgba(0, 146, 112, 0.3);
  color: #fff;
}

/* ========== RIPPLE EFFECT ========== */
@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  animation: ripple 0.6s ease-out;
  pointer-events: none;
}

/* ========== h4 HEADINGS ========== */
h4 {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 6px;
}

/* ========== THEME TOGGLE SWITCH ========== */
.theme-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  position: relative;
  width: 52px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  padding: 3px;
}

.theme-toggle:hover {
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

.theme-toggle-knob {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.theme-toggle.light .theme-toggle-knob {
  transform: translateX(24px);
  background: var(--primary);
}

.theme-toggle.light {
  background: rgba(0, 146, 112, 0.15);
  border-color: var(--primary);
}

.theme-icon {
  font-size: 14px;
  line-height: 1;
}

/* ========== LIGHT MODE SPECIFIC OVERRIDES ========== */
[data-theme="light"] body {
  background: var(--bg);
}

[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 600px 400px at 20% 30%, rgba(0, 146, 112, 0.04), transparent),
    radial-gradient(ellipse 500px 500px at 80% 70%, rgba(139, 92, 246, 0.03), transparent),
    radial-gradient(ellipse 400px 300px at 60% 20%, rgba(59, 130, 246, 0.03), transparent);
}

[data-theme="light"] .bg-particles .particle {
  opacity: 0.3;
}

[data-theme="light"] .nav {
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .nav-tabs span {
  color: var(--text-muted);
}

[data-theme="light"] .nav-tabs span:hover {
  color: var(--text);
}

[data-theme="light"] .nav-tabs span.active {
  color: #fff;
}

[data-theme="light"] .admin-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--text);
}

[data-theme="light"] .card {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  border-color: var(--border);
}

[data-theme="light"] .card::before {
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.03), transparent);
}

[data-theme="light"] .card:hover {
  box-shadow: var(--shadow-md);
}

[data-theme="light"] .modal {
  background: var(--modal-bg);
  border-color: var(--border);
}

[data-theme="light"] .modal::before {
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.3;
}

[data-theme="light"] input,
[data-theme="light"] select {
  background: var(--input-bg);
  color: var(--text);
  border-color: var(--border);
}

[data-theme="light"] select option {
  background: var(--select-option-bg);
  color: var(--text);
}

[data-theme="light"] h3 {
  background: linear-gradient(135deg, var(--text), var(--text-light));
  -webkit-background-clip: text;
  background-clip: text;
}

[data-theme="light"] .match-card::after {
  background: linear-gradient(135deg, rgba(0, 146, 112, 0.05), transparent);
}

[data-theme="light"] .ball-badge {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text);
  border-color: var(--border);
}

[data-theme="light"] .ball-WD,
[data-theme="light"] .ball-NB {
  border-color: #9ca3af;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-light);
}

[data-theme="light"] .ctrl-btn {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="light"] .ctrl-W {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
  border-color: #f87171;
}

[data-theme="light"] .ctrl-extra {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  border-color: #fbbf24;
}

[data-theme="light"] .extras-run-btn {
  background: rgba(0, 0, 0, 0.02);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="light"] .live-batter-card {
  background: rgba(255, 255, 255, 0.7);
  border-color: var(--border);
}

[data-theme="light"] .live-batter-card.on-strike {
  background: rgba(0, 146, 112, 0.06);
  border-color: var(--primary);
}

[data-theme="light"] .live-bowler-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.06), rgba(37, 99, 235, 0.03));
  border-color: rgba(59, 130, 246, 0.15);
}

[data-theme="light"] .squad-pill {
  background: rgba(0, 0, 0, 0.04);
  border-color: #d1d5db;
  color: var(--text);
}

[data-theme="light"] .squad-player-card {
  background: rgba(0, 0, 0, 0.02);
  border-color: var(--border);
}

[data-theme="light"] tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .btn-outline {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="light"] .btn-cancel {
  background: linear-gradient(135deg, #9ca3af, #6b7280);
}

[data-theme="light"] .match-subtabs {
  background: rgba(255, 255, 255, 0.6);
}

[data-theme="light"] .admin-tab {
  color: var(--text-muted);
}

[data-theme="light"] .admin-tab:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text);
}

[data-theme="light"] .admin-tab.active {
  color: var(--primary);
  background: rgba(0, 146, 112, 0.06);
}

[data-theme="light"] .ripple-effect {
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .theme-toggle {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .nav::after {
  opacity: 0.3;
}

/* Smooth transition for theme change on all elements */
body,
body *,
body *::before,
body *::after {
  transition-property: background-color, background, color, border-color, box-shadow, fill, stroke;
  transition-duration: 0.4s;
  transition-timing-function: ease;
}
/* ============================================================
   NEW FEATURES CSS — THEME TOGGLE, VOICE, AI, TOURNAMENTS
   ============================================================ */

/* ===== NAV ACTIONS ===== */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-icon-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  color: var(--nav-text);
  transition: all 0.2s ease;
}

.nav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}

.theme-icon {
  font-size: 1rem;
  line-height: 1;
}

/* Light theme nav icon overrides */
[data-theme="light"] .nav-icon-btn {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--text);
}

/* ===== VOICE CONTROL ===== */
#voice-control-btn.voice-listening {
  animation: voicePulse 1s ease infinite;
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--red);
}

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ===== AI ASSISTANT ===== */
.ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  z-index: 500;
  box-shadow: 0 4px 20px rgba(0, 146, 112, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(0, 146, 112, 0.55);
}

.ai-panel {
  position: fixed;
  bottom: 96px;
  right: 16px;
  width: 350px;
  max-width: calc(100vw - 32px);
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  z-index: 499;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(20px);
}

.ai-panel.ai-panel-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--gradient-primary);
  color: #fff;
}

.ai-avatar {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 360px;
  min-height: 200px;
}

.ai-msg {
  display: flex;
  animation: msgSlide 0.25s ease;
}

@keyframes msgSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg-user {
  justify-content: flex-end;
}

.ai-msg-assistant {
  justify-content: flex-start;
}

.ai-msg-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.ai-msg-user .ai-msg-bubble {
  background: var(--gradient-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg-assistant .ai-msg-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ai-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: typingDot 1.2s ease infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.ai-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.ai-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
}

.ai-input:focus {
  border-color: var(--primary);
}

.ai-send-btn {
  background: var(--gradient-primary);
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  font-size: 0.9rem;
  transition: opacity 0.2s;
}

.ai-send-btn:hover { opacity: 0.85; }

/* ===== TOURNAMENTS PAGE ===== */
.tournament-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tournament-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 20px var(--primary-glow);
  transform: translateY(-2px);
}

.tournament-card-active {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(0, 146, 112, 0.08), var(--surface));
}

.tournament-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.tournament-card-icon {
  font-size: 1.8rem;
  width: 48px;
  height: 48px;
  background: var(--gradient-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tournament-card-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

.tournament-active-badge {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.tournament-card-arrow {
  font-size: 1.5rem;
  color: var(--text-muted);
  margin-left: auto;
}

.tournament-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.tournament-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface-glass);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 4px;
}

.tournament-stat-val {
  font-weight: 800;
  font-size: 1.2rem;
}

.tournament-stat-lbl {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Light theme specific */
[data-theme="light"] .tournament-card {
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

[data-theme="light"] .tournament-card:hover {
  box-shadow: 0 8px 30px rgba(0, 146, 112, 0.2);
}

[data-theme="light"] .tournament-card-active {
  background: linear-gradient(135deg, rgba(0, 146, 112, 0.05), #fff);
}

[data-theme="light"] .tournament-stat {
  background: #f8fafb;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
  z-index: 1;
}

.search-input {
  width: 100%;
  padding: 11px 16px 11px 42px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(10px);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-input::placeholder {
  color: var(--text-muted);
}

[data-theme="light"] .search-input {
  background: #fff;
  border-color: #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

[data-theme="light"] .search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,146,112,0.12);
}

/* ============================================================
   LIGHT THEME — ENHANCED VISUAL RICHNESS
   ============================================================ */

[data-theme="light"] {
  --bg: #f0f5f3;
  --bg-secondary: #e4eee9;
}

[data-theme="light"] body {
  background: linear-gradient(135deg, #eef7f4 0%, #f0f5f3 40%, #edf2f7 100%);
}

[data-theme="light"] .nav {
  background: rgba(255,255,255,0.9);
  border-bottom-color: rgba(0,146,112,0.12);
  box-shadow: 0 2px 16px rgba(0,0,0,0.07);
}

[data-theme="light"] .nav-brand {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .card {
  background: #ffffff;
  border-color: rgba(0,0,0,0.07);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.03);
}

[data-theme="light"] .card:hover {
  box-shadow: 0 8px 28px rgba(0,0,0,0.1), 0 0 0 1px rgba(0,146,112,0.08);
}

[data-theme="light"] h3 {
  color: #1a2e2a;
  -webkit-text-fill-color: #1a2e2a;
}

[data-theme="light"] .match-card-header {
  color: var(--text-muted);
}

[data-theme="light"] .match-team {
  color: var(--text);
}

[data-theme="light"] .btn-primary {
  box-shadow: 0 4px 14px rgba(0,146,112,0.3);
}

[data-theme="light"] .btn-outline {
  background: #fff;
  border-color: rgba(0,0,0,0.15);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

[data-theme="light"] .ctrl-btn {
  background: #fff;
  border: 1.5px solid #e2e8f0;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

[data-theme="light"] .ctrl-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(0,146,112,0.15);
}

[data-theme="light"] .tournament-stat {
  background: #f8fdf9;
  border-color: rgba(0,0,0,0.06);
}

[data-theme="light"] .match-subtabs {
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(0,0,0,0.07);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

[data-theme="light"] .modal-overlay {
  background: rgba(15, 25, 20, 0.4);
}

[data-theme="light"] .modal {
  box-shadow: 0 24px 64px rgba(0,0,0,0.16);
}

[data-theme="light"] .ai-panel {
  box-shadow: 0 20px 60px rgba(0,0,0,0.14);
}

[data-theme="light"] .admin-tabs {
  background: #f4faf7;
  border-color: rgba(0,0,0,0.08);
}

[data-theme="light"] table thead th {
  background: linear-gradient(135deg, #e8f5f0, #f0faf6);
  color: var(--primary-dark);
}

/* ============================================================
   MOBILE-FIRST RESPONSIVE — BOTTOM NAV
   ============================================================ */

/* Mobile bottom navigation bar */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  /* Hide nav tabs in header on mobile */
  .nav-tabs {
    display: none !important;
  }

  /* Tighter nav on mobile */
  .nav {
    padding: 10px 14px;
  }

  .nav-brand {
    font-size: 1.1rem;
  }

  /* Show mobile bottom nav */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--nav-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border);
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
    justify-content: space-around;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  }

  .mobile-bottom-nav .mnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 10px;
    transition: all 0.2s ease;
    min-width: 52px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-family: inherit;
  }

  .mobile-bottom-nav .mnav-item .mnav-icon {
    font-size: 1.3rem;
    line-height: 1;
  }

  .mobile-bottom-nav .mnav-item .mnav-label {
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
  }

  .mobile-bottom-nav .mnav-item.active {
    color: var(--primary);
  }

  .mobile-bottom-nav .mnav-item.active .mnav-icon {
    filter: drop-shadow(0 2px 6px rgba(0,146,112,0.4));
  }

  /* Main container — leave room for bottom nav */
  #main-container {
    padding-bottom: 80px !important;
  }

  /* Cards — better mobile padding */
  .card {
    padding: 14px;
    border-radius: 14px;
  }

  /* Match cards — slightly more compact */
  .match-team {
    font-size: 0.95rem;
  }

  /* Scoring board — mobile layout */
  .scoring-controls {
    gap: 8px !important;
  }

  .ctrl-btn {
    padding: 14px 6px !important;
    font-size: 1rem !important;
    border-radius: 12px !important;
    min-height: 52px;
  }

  /* Score display larger on mobile */
  .team-score {
    font-size: 2rem !important;
  }

  /* Points table scroll */
  #points-table {
    font-size: 0.8rem;
  }

  /* AI panel full width on mobile */
  .ai-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 88px;
    max-height: 65vh;
  }

  .ai-chat-messages {
    max-height: 220px;
  }

  /* AI fab + voice lower on mobile (above bottom nav) */
  .ai-fab {
    bottom: 76px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
  }

  /* Admin tabs — scrollable row */
  .admin-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    flex-wrap: nowrap !important;
  }

  .admin-tab {
    white-space: nowrap;
    font-size: 0.8rem;
    padding: 8px 12px !important;
  }

  /* Scorecard sub-tabs */
  .match-subtabs {
    gap: 4px;
  }

  .match-subtab {
    font-size: 0.78rem !important;
    padding: 8px 10px !important;
  }

  /* Forms in admin */
  .form-group label {
    font-size: 0.82rem;
  }

  /* Modal narrower on mobile */
  .modal {
    margin: 16px;
    border-radius: 18px;
  }

  /* Scorecard table scroll */
  .scorecard-table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: unset;
  }

  /* Squad grid 2 columns on mobile */
  .squad-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Tournament stats 2x2 on small screens */
  .tournament-stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Voice status bar below file warning if present */
  #voice-status {
    top: 56px;
  }

  h3 {
    font-size: 1.2rem;
  }

  /* Extras grid bigger buttons on mobile */
  .extras-run-grid {
    gap: 10px !important;
  }

  .extras-run-btn {
    min-height: 54px !important;
    font-size: 1.1rem !important;
  }
}

/* Extra small (old phones) */
@media (max-width: 380px) {
  .mobile-bottom-nav .mnav-item {
    min-width: 44px;
    padding: 6px 6px;
  }

  .mobile-bottom-nav .mnav-item .mnav-label {
    font-size: 0.58rem;
  }

  .ctrl-btn {
    font-size: 0.9rem !important;
    padding: 12px 4px !important;
  }
}

/* Light theme bottom nav */
[data-theme="light"] .mobile-bottom-nav {
  background: rgba(255,255,255,0.95);
  border-top-color: rgba(0,0,0,0.08);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

[data-theme="light"] .mobile-bottom-nav .mnav-item {
  color: #94a3b8;
}

[data-theme="light"] .mobile-bottom-nav .mnav-item.active {
  color: var(--primary);
}


/* ===== Public Speaker Button ===== */
#public-speaker-btn {
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
#public-speaker-btn[style*="primary"] {
  color: var(--primary) !important;
}

