/* Google Fonts - Inter & Outfit */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800;900&display=swap');

/* Color Variables and Theme Tokens */
:root {
  --bg-primary: #0A0A0C;
  --bg-secondary: #121216;
  --bg-tertiary: #191922;
  --text-primary: #F5F5F7;
  --text-secondary: #A1A1A6;
  --accent: #E91E63;
  --accent-rgb: 233, 30, 99;
  --accent-gradient: linear-gradient(135deg, #F43F5E 0%, #BE123C 100%);
  --border: #22222B;
  --card-bg: rgba(18, 18, 22, 0.85);
  --shadow: rgba(0, 0, 0, 0.7);
  --glass-bg: rgba(10, 10, 12, 0.75);
  --glass-border: rgba(233, 30, 99, 0.15);
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --gold: #F59E0B;
  --font-body: 'Inter', sans-serif;
  --font-title: 'Outfit', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 12px;
}

[data-theme="light"] {
  --bg-primary: #F3F4F6;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #E5E7EB;
  --text-primary: #111827;
  --text-secondary: #6B7280;
  --accent: #D0114C;
  --accent-rgb: 208, 17, 76;
  --accent-gradient: linear-gradient(135deg, #E11D48 0%, #9F1239 100%);
  --border: #E5E7EB;
  --card-bg: rgba(255, 255, 255, 0.9);
  --shadow: rgba(0, 0, 0, 0.05);
  --glass-bg: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(208, 17, 76, 0.1);
  --success: #059669;
  --warning: #D97706;
  --error: #DC2626;
  --gold: #D97706;
}

/* Base Resets */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-body);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  transition: var(--transition);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: -0.02em;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  filter: brightness(1.2);
}

img {
  max-width: 100%;
}

/* Layout Wrappers */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  flex: 1;
}

.section {
  padding: 40px 0;
}

/* Premium Header Navigation */
.main-header {
  background-color: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: var(--transition);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  padding: 0 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  height: 45px;
  width: 45px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.3);
}

.logo-text {
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 24px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--border-radius);
  transition: var(--transition);
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

.nav-link.active {
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Theme Toggle Slider */
.theme-switch {
  background: none;
  border: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
  transition: var(--transition);
  border: 1px solid var(--border);
}

.theme-switch:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.2);
}

/* Common UI Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  border-radius: var(--border-radius);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #FFFFFF !important;
  box-shadow: 0 4px 15px rgba(var(--accent-rgb), 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.4);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary) !important;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--border);
}

.btn-danger {
  background-color: var(--error);
  color: #FFFFFF !important;
}

.btn-danger:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

/* Dashboard Cards and Layout Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}

.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: 0 10px 30px var(--shadow);
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(var(--accent-rgb), 0.3);
  transform: translateY(-4px);
}

.card-title {
  font-size: 18px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  outline: none;
  font-size: 14px;
  transition: var(--transition);
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.25);
  background-color: var(--bg-primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Live Score Timeline on Viewer Home */
.timeline-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 40px;
}

.match-card {
  background: linear-gradient(145deg, var(--bg-secondary), var(--bg-tertiary));
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 30px var(--shadow);
  position: relative;
  transition: var(--transition);
}

.match-card.live-pinned {
  border: 2px solid var(--accent);
  box-shadow: 0 0 25px rgba(var(--accent-rgb), 0.25);
}

.match-card.live-pinned::before {
  content: 'LIVE MATCH';
  position: absolute;
  top: 12px;
  left: 12px;
  background-color: var(--error);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.1em;
  animation: pulse 1.5s infinite;
}

.match-card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.match-card-body {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.team-score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 40%;
}

.team-score-logo {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--border);
  background-color: var(--bg-primary);
}

.team-score-name {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.team-score-runs {
  font-family: var(--font-title);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
}

.team-score-overs {
  font-size: 13px;
  color: var(--text-secondary);
}

.match-vs {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.2);
  width: 10%;
  text-align: center;
}

.match-card-footer {
  padding: 16px 24px;
  background-color: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
  text-align: center;
}

/* Live Scorecard Viewer Layout */
.live-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 30px;
  margin-bottom: 40px;
}

.scorecard-main {
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px;
}

.live-score-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent-gradient);
  padding: 24px;
  border-radius: 12px;
  color: #FFFFFF;
  margin-bottom: 30px;
  box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.25);
}

.live-score-left h2 {
  font-size: 36px;
  font-weight: 800;
}

.live-score-left p {
  font-size: 14px;
  opacity: 0.8;
}

.live-score-right {
  text-align: right;
}

.live-score-right h4 {
  font-size: 20px;
  font-weight: 700;
}

.balls-timeline {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  align-items: center;
}

.ball-indicator {
  min-width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--border);
}

.ball-indicator.four {
  background-color: #3b82f6;
  color: #FFFFFF;
  border-color: #2563eb;
  animation: pop 0.4s ease;
}

.ball-indicator.six {
  background-color: #a855f7;
  color: #FFFFFF;
  border-color: #9333ea;
  animation: pop 0.4s ease;
}

.ball-indicator.wicket {
  background-color: var(--error);
  color: #FFFFFF;
  border-color: #b91c1c;
  animation: pop 0.4s ease;
}

.ball-indicator.extra {
  background-color: var(--warning);
  color: #000000;
  border-color: #d97706;
}

/* Premium Table Designs */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 30px;
}

.data-table th {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  text-align: left;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.data-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.text-right {
  text-align: right !important;
}

/* Flash alerts overlay styling (when boundary/wicket happens) */
.flash-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.flash-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.flash-content {
  font-family: var(--font-title);
  font-size: 72px;
  font-weight: 900;
  color: #FFFFFF;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transform: scale(0.5);
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-align: center;
}

.flash-overlay.active .flash-content {
  transform: scale(1);
}

.flash-overlay.four-flash {
  background: radial-gradient(circle, rgba(59, 130, 246, 0.95) 0%, rgba(0, 0, 0, 0.95) 100%);
}

.flash-overlay.six-flash {
  background: radial-gradient(circle, rgba(168, 85, 247, 0.95) 0%, rgba(0, 0, 0, 0.95) 100%);
}

.flash-overlay.wicket-flash {
  background: radial-gradient(circle, rgba(239, 68, 68, 0.95) 0%, rgba(0, 0, 0, 0.95) 100%);
}

/* Login Page Wrapper */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 140px);
  padding: 40px 0;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px var(--shadow);
  border-radius: 16px;
  padding: 40px;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  padding: 4px;
  margin-bottom: 16px;
  box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.3);
}

.login-header h2 {
  font-size: 26px;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* KPI Scoreboard Badge Metrics */
.kpi-wrapper {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.kpi-val {
  font-family: var(--font-title);
  font-size: 32px;
  font-weight: 800;
  color: var(--accent);
}

/* Footer layout */
.main-footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.powered-by {
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 11px;
}

/* Global Mobile Form Tweak */
.form-control {
  font-size: 16px !important; /* Prevents iOS auto-zoom */
  min-height: 46px; /* Great tap target */
}
.btn {
  min-height: 44px; /* Accessible touch target */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Nav Drawer (Off-canvas) */
.nav-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.nav-drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}
.nav-drawer {
  position: fixed;
  top: 0;
  right: -300px; /* Slide in from right */
  width: 300px;
  max-width: 85%;
  height: 100%;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border);
  box-shadow: -5px 0 25px rgba(0,0,0,0.5);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-drawer.active {
  right: 0;
}
.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-title {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 18px;
  text-transform: uppercase;
  color: var(--accent);
}
.drawer-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}
.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 16px;
  border-radius: var(--border-radius);
  transition: var(--transition);
  min-height: 48px;
}
.drawer-link:hover, .drawer-link.active {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}
.drawer-link.active {
  border-left: 4px solid var(--accent);
}
.drawer-divider {
  height: 1px;
  background-color: var(--border);
  margin: 15px 0;
}

/* Hamburger button for mobile */
.hamburger-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  cursor: pointer;
  display: none;
  padding: 8px;
  align-items: center;
  justify-content: center;
}

.mobile-header-actions {
  display: none;
}


/* Mobile Bottom Tab Bar */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: none;
  justify-content: space-around;
  align-items: center;
  z-index: 999;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
}
.mobile-bottom-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  padding: 8px 12px;
  text-decoration: none;
  flex: 1;
  transition: var(--transition);
}
.mobile-bottom-item i {
  font-size: 20px;
  margin-bottom: 3px;
}
.mobile-bottom-item:hover, .mobile-bottom-item.active {
  color: var(--accent);
}

/* Responsive Table Card Layout (Mobile) */
@media (max-width: 768px) {
  .data-table:not(.data-table-nocard) {
    display: block !important;
    width: 100% !important;
    border: none !important;
  }
  .data-table:not(.data-table-nocard) thead {
    display: none !important;
  }
  .data-table:not(.data-table-nocard) tbody {
    display: block !important;
    width: 100% !important;
  }
  .data-table:not(.data-table-nocard) tr {
    display: block !important;
    margin-bottom: 16px !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--border-radius) !important;
    background-color: var(--card-bg) !important;
    padding: 12px 16px !important;
    box-shadow: 0 4px 10px var(--shadow) !important;
  }
  .data-table:not(.data-table-nocard) tr:hover {
    background-color: var(--card-bg) !important;
  }
  .data-table:not(.data-table-nocard) td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 10px 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    text-align: right !important;
    font-size: 14px !important;
  }
  .data-table:not(.data-table-nocard) td:last-child {
    border-bottom: none !important;
  }
  .data-table:not(.data-table-nocard) td[data-label]::before {
    content: attr(data-label);
    font-weight: 700 !important;
    color: var(--text-secondary) !important;
    text-transform: uppercase !important;
    font-size: 11px !important;
    text-align: left !important;
    flex: 1 !important;
    margin-right: 15px !important;
  }

  /* Compact layout for standard tables on mobile (to keep tabular format) */
  .data-table-nocard th,
  .data-table-nocard td {
    padding: 6px 8px !important;
    font-size: 11px !important;
    white-space: nowrap !important;
  }
}

/* Breakpoint 768px to 1023px (Tablet/Drawer activation) */
@media (max-width: 1023px) {
  .main-nav {
    display: none !important;
  }
  .header-actions {
    display: none !important;
  }
  .mobile-header-actions {
    display: flex !important;
    align-items: center;
    gap: 8px;
  }
  .mobile-header-actions .theme-switch,
  .mobile-header-actions .hamburger-btn {
    width: 44px;
    height: 44px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
  }
  .mobile-bottom-nav {
    display: flex !important;
  }
  body {
    padding-bottom: 60px; /* offset for sticky bottom nav */
  }
}


/* Breakpoint < 768px (Phone Stack) */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  .form-row {
    grid-template-columns: 1fr !important;
    gap: 0;
  }
  .match-card-body {
    flex-direction: column !important;
    gap: 20px;
    padding: 16px;
  }
  .team-score-block {
    width: 100% !important;
  }
  .match-vs {
    width: 100% !important;
    margin: 10px 0;
  }
  .live-layout {
    grid-template-columns: 1fr !important;
  }
  .live-score-strip {
    flex-direction: column !important;
    text-align: center !important;
    gap: 12px;
  }
  .live-score-right {
    text-align: center !important;
  }
  
  /* Canvas preview stack above controls on mobile */
  .canvas-grid, .generator-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 20px;
  }
  .canvas-preview-container {
    order: -1 !important; /* Shows canvas first */
    width: 100% !important;
    overflow-x: auto;
  }
  .generator-controls {
    width: 100% !important;
  }
}

/* Breakpoint < 400px (Small Phone) */
@media (max-width: 400px) {
  .container {
    padding: 0 12px;
  }
  .card {
    padding: 16px;
  }
  .btn {
    padding: 8px 14px;
    font-size: 13px;
  }
  .logo-text {
    font-size: 20px;
  }
}

/* Animation Keyframes */
@keyframes pulse {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    opacity: 0.7;
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.6);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Custom Scoring, Graphics and Lineup layouts */
.scoring-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}

.graphics-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.lineup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

.sticky-score-header {
  transition: all 0.2s ease;
}

@media (max-width: 1023px) {
  .scoring-layout {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  .lineup-grid {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  
  .sticky-score-header {
    position: sticky !important;
    top: 69px !important;
    z-index: 99 !important;
    background: var(--bg-secondary) !important;
    border-bottom: 2px solid var(--accent) !important;
    margin-left: -20px !important;
    margin-right: -20px !important;
    border-radius: 0 !important;
    padding: 12px 20px !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3) !important;
  }

  .mobile-bottom-sheet {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    background: var(--bg-secondary) !important;
    border-top: 3px solid var(--accent) !important;
    border-radius: var(--border-radius) var(--border-radius) 0 0 !important;
    padding: 20px !important;
    z-index: 1050 !important;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.6) !important;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
  }
  
  /* Ensure backdrop for bottom sheet */
  .sheet-active-body {
    overflow: hidden !important;
  }

  .graphics-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
  }
  .graphics-layout > div:last-child {
    order: -1 !important;
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Auto-scale canvases on mobile */
#cardCanvas, canvas {
  max-width: 100% !important;
  height: auto !important;
}

/* Floating WhatsApp Button */
.whatsapp-float {
  position: fixed;
  bottom: 85px; /* Above the mobile bottom navigation which is 60px + safe area padding */
  right: 20px;
  width: 56px;
  height: 56px;
  background-color: #25D366;
  color: #FFF !important;
  border-radius: 50%;
  text-align: center;
  font-size: 30px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background-color 0.2s;
  cursor: pointer;
}

.whatsapp-float:hover {
  background-color: #128C7E;
  transform: scale(1.08);
}

@media (min-width: 1024px) {
  .whatsapp-float {
    bottom: 30px; /* On desktop, we don't have mobile bottom navigation, so 30px is fine */
  }
}

/* Responsive display helpers */
@media (max-width: 768px) {
  .mobile-only {
    display: inline !important;
  }
  .desktop-only {
    display: none !important;
  }
  .live-layout {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  .stat-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
}
@media (min-width: 769px) {
  .mobile-only {
    display: none !important;
  }
  .desktop-only {
    display: inline !important;
  }
}

/* ==========================================================================
   Smooth Page Preloader (Premium Cricket Loading Animation)
   ========================================================================== */
#preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #0F0F14 0%, #060608 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
  visibility: visible;
  opacity: 1;
}

#preloader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.preloader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.cricket-scene {
  position: relative;
  width: 180px;
  height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* Wickets */
.wickets {
  position: absolute;
  bottom: 12px;
  left: 110px;
  width: 42px;
  height: 70px;
  animation: wicketsShake 1.0s infinite ease-in-out;
  transform-origin: bottom center;
}

.stump {
  position: absolute;
  bottom: 0;
  width: 4px;
  height: 70px;
  background: linear-gradient(to bottom, #FFD700 0%, #FF8F00 80%, #CC5200 100%);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255, 143, 0, 0.4);
}

.stump-1 { left: 0; }
.stump-2 { left: 18px; }
.stump-3 { left: 36px; }

.bail {
  position: absolute;
  top: -3px;
  left: -2px;
  width: 46px;
  height: 4px;
  background: linear-gradient(to right, #FF8F00, #FFD700, #FF8F00);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(255, 143, 0, 0.5);
  animation: bailFly 1.0s infinite ease-in-out;
  transform-origin: center;
}

/* Bouncing Ball */
.ball-container {
  position: absolute;
  bottom: 12px;
  left: 10px;
  width: 160px;
  height: 100px;
  pointer-events: none;
}

.bouncing-cricket-ball {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FF3E6C 0%, #9E0024 70%, #5C0011 100%);
  box-shadow: inset -3px -3px 8px rgba(0, 0, 0, 0.6), 
              0 0 12px rgba(255, 62, 108, 0.4);
  position: absolute;
  bottom: 0;
  left: 0;
  animation: ballTrajectory 1.0s infinite cubic-bezier(0.2, 0.6, 0.4, 1);
  transform-origin: center;
}

.ball-seam {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  background: repeating-linear-gradient(
    to bottom,
    #FFFFFF 0px,
    #FFFFFF 2px,
    #A0A0A0 2px,
    #A0A0A0 4px
  );
  transform: translateX(-50%) rotate(25deg);
  border-radius: 1px;
  box-shadow: 0.5px 0 1px rgba(0,0,0,0.3);
}

/* Pitch Glow / Ripple */
.pitch-glow {
  position: absolute;
  bottom: 10px;
  left: 50px;
  width: 40px;
  height: 6px;
  background: rgba(233, 30, 99, 0.4);
  border-radius: 50%;
  filter: blur(2px);
  animation: pitchRipple 1.0s infinite ease-out;
  transform-origin: center;
  opacity: 0;
}

/* Loading Bar Progress */
.loading-bar-wrapper {
  width: 140px;
  height: 3px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.02);
}

.loading-bar {
  width: 0%;
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 10px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.preloader-text {
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.25em;
  color: var(--text-primary);
  text-transform: uppercase;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: textGlow 1.8s infinite ease-in-out;
}

/* Ball Trajectory Keyframes */
@keyframes ballTrajectory {
  0% {
    transform: translate3d(0, -70px, 0) rotate(0deg) scale(1, 1);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  24% {
    transform: translate3d(42px, -2px, 0) rotate(160deg) scale(1.1, 0.9);
  }
  25% {
    transform: translate3d(45px, 0px, 0) rotate(170deg) scale(1.2, 0.8); /* Bounce Ground */
  }
  26% {
    transform: translate3d(48px, -2px, 0) rotate(180deg) scale(0.9, 1.1);
  }
  48% {
    transform: translate3d(95px, -35px, 0) rotate(320deg) scale(1, 1);
    opacity: 1;
  }
  49% {
    transform: translate3d(102px, -35px, 0) rotate(330deg) scale(1.05, 0.95); /* Hits wickets */
  }
  53% {
    transform: translate3d(108px, -32px, 0) rotate(350deg);
  }
  70% {
    transform: translate3d(130px, 0px, 0) rotate(420deg);
    opacity: 1;
  }
  85% {
    transform: translate3d(145px, 10px, 0) rotate(450deg);
    opacity: 0;
  }
  100% {
    transform: translate3d(0, -70px, 0) rotate(0deg) scale(1, 1);
    opacity: 0;
  }
}

/* Wickets Shake Keyframes */
@keyframes wicketsShake {
  0%, 48%, 100% {
    transform: rotate(0deg);
    filter: drop-shadow(0 0 4px rgba(255, 143, 0, 0.4));
  }
  49% {
    transform: rotate(4deg) translate3d(2px, -1px, 0);
    filter: drop-shadow(0 0 12px #FF0055) brightness(1.4);
  }
  53% {
    transform: rotate(-3deg) translate3d(-1px, 0, 0);
    filter: drop-shadow(0 0 8px rgba(255, 143, 0, 0.8));
  }
  58% {
    transform: rotate(2deg);
  }
  63% {
    transform: rotate(-1deg);
  }
  68% {
    transform: rotate(0deg);
  }
}

/* Bail flying off Keyframes */
@keyframes bailFly {
  0%, 48%, 100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 1;
  }
  49% {
    transform: translate3d(4px, -18px, 0) rotate(15deg);
    opacity: 1;
    filter: brightness(1.5);
  }
  65% {
    transform: translate3d(12px, -8px, 0) rotate(45deg);
    opacity: 0.8;
  }
  80% {
    transform: translate3d(20px, 20px, 0) rotate(80deg);
    opacity: 0;
  }
}

/* Pitch Ripple Keyframes */
@keyframes pitchRipple {
  0%, 23%, 100% {
    transform: scale(0.4);
    opacity: 0;
  }
  25% {
    transform: scale(0.6);
    opacity: 0.8;
  }
  38% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* Loading Progress Bar Keyframes */
@keyframes loadingProgress {
  0% {
    transform: scaleX(0);
    opacity: 0.8;
  }
  50% {
    transform: scaleX(0.7);
    opacity: 1;
  }
  80%, 100% {
    transform: scaleX(1);
    opacity: 0;
  }
}

/* Glowing text pulse keyframes */
@keyframes textGlow {
  0%, 100% {
    opacity: 0.65;
    filter: drop-shadow(0 0 2px rgba(233, 30, 99, 0.15));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 8px rgba(233, 30, 99, 0.45));
  }
}
