:root {
    /* Dark Theme (Default) */
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --primary: #00a25b;
    --secondary: #ffaf3c;
    --accent: var(--primary);
    --header-gradient: linear-gradient(135deg, #008148, #00a25b);
    --nav-bg: rgba(15, 23, 42, 0.9);
}

body {
    overflow-x: hidden;
    width: 100%;
}

body.light-theme,
html.light-theme {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --primary: #00a25b;
    --secondary: #ffaf3c;
    --accent: var(--primary);
    --header-gradient: linear-gradient(135deg, #00a25b, #00c36e);
    --nav-bg: rgba(255, 255, 255, 0.95);
}

/* Modal/Alert Layout Shift Fix */
body.modal-open,
body.swal2-shown {
    padding-right: 0 !important;
    overflow-x: hidden;
}

/* Global Overrides for Light Theme */
body.light-theme .text-white:not(.dashboard-header *):not(.badge):not(.btn-premium):not(.nav-link.active),
html.light-theme .text-white:not(.dashboard-header *):not(.badge):not(.btn-premium):not(.nav-link.active) {
    color: var(--text-primary) !important;
}

body.light-theme .text-white-50:not(.dashboard-header *):not(.badge),
html.light-theme .text-white-50:not(.dashboard-header *):not(.badge) {
    color: var(--text-secondary) !important;
}

body.light-theme .bg-dark:not(.dashboard-header *),
html.light-theme .bg-dark:not(.dashboard-header *) {
    background-color: var(--card-bg) !important;
}

body.light-theme .border-secondary,
body.light-theme .border-white-50,
body.light-theme .border-opacity-10,
html.light-theme .border-secondary,
html.light-theme .border-white-50,
html.light-theme .border-opacity-10 {
    border-color: var(--card-border) !important;
}

body.light-theme hr,
html.light-theme hr {
    background-color: var(--card-border);
    opacity: 0.1;
}

.border-theme-light {
    border: 1px solid var(--card-border) !important;
}

.bg-theme {
    background: var(--bg-color) !important;
}

/* Light Theme Scoring Button Fixes */
body.light-theme .run-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

body.light-theme .extra-btn {
    background: #e2e8f0;
    color: #1e293b !important;
    border: 1px solid #cbd5e1;
}

body.light-theme #undoBtn {
    background: #64748b !important;
    color: white !important;
}

body.light-theme .btn-outline-light {
    color: #1e293b !important;
    border-color: #cbd5e1 !important;
}

body.light-theme .btn-close-white {
    filter: none;
    /* Make X dark in light mode */
}

/* Toss Modal Active states */
.btn-accent.text-white.shadow {
    background-color: var(--accent) !important;
    color: white !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.4) !important;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    margin: 0;
    padding-bottom: 70px;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 20px;
    margin: 15px 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.dashboard-header {
    background: var(--header-gradient);
    padding: 15px 20px;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    text-align: left;
    color: white !important;
    margin-bottom: 5px;
}

/* Cric Hit Brand Logo */
.brand-logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 2.2rem;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    letter-spacing: -1px;
    margin: 0;
    line-height: 1;
}

/* New Branding Container & Typography */
.brand-logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.brand-name-svg {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 2rem;
    color: white;
    line-height: 1;
    margin-top: 5px;
    letter-spacing: -1px;
}

.brand-name-svg span,
.brand-name-svg .text-accent {
    color: #ffaf3c !important;
}

.slogan-text {
    color: #ffaf3c;
    font-weight: 600;
    letter-spacing: 1px;
}

.brand-logo .kit-text {
    color: var(--secondary);
    margin-left: 6px;
    position: relative;
    padding-left: 4px;
}

.brand-logo .kit-text::before {
    content: '';
    position: absolute;
    left: -7px;
    bottom: 6px;
    width: 14px;
    height: 14px;
    background-color: #ef4444;
    /* Cricket Ball Red */
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

/* Ball Seam */
.brand-logo .kit-text::after {
    content: '||';
    position: absolute;
    left: -7px;
    bottom: 6px;
    width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 8px;
    font-weight: 800;
    transform: rotate(90deg);
    z-index: 2;
    pointer-events: none;
}

.brand-logo-green {
    color: var(--primary) !important;
}

.brand-logo-green .kit-text {
    color: var(--primary) !important;
}

.team-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.team-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.team-logo-small {
    width: 25px;
    height: 18px;
    object-fit: cover;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
}

.team-name-small {
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    color: white !important;
}

.team-score-large {
    font-size: 1.3rem;
    font-weight: 800;
    color: white !important;
}

.yet-to-bat {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6) !important;
    font-weight: 600;
}

.match-meta-small {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7) !important;
    margin-top: 8px;
    padding-top: 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.dashboard-header * {
    color: white !important;
}

/* Dashboard header icon fixes */
.dashboard-header .btn-outline-theme {
    color: white !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

body.light-theme .dashboard-header .btn-outline-theme {
    color: white !important;
    /* Keep white on blue gradient background */
    border-color: rgba(255, 255, 255, 0.3) !important;
}

/* Run buttons specific types */
.run-btn[data-run="6"] {
    background: var(--accent) !important;
    color: white !important;
}

.run-btn[data-run="4"] {
    background: #fbbf24 !important;
    /* Yellow */
    color: #000 !important;
}

/* Over History Styles */
.over-history-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 5px 0 15px 0;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE and Edge */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
    user-select: none;
}

.over-history-scroll.active {
    cursor: grabbing;
}

.over-history-scroll::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

.over-hist-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    /* Slightly sharper for carousel look */
    padding: 8px 12px;
    min-width: 220px;
    /* Wider to accommodate larger balls */
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.over-hist-num {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
    font-weight: 800;
}

.over-hist-runs {
    font-weight: 800;
    font-size: 0.9rem;
    border-right: 1px solid var(--card-border);
    padding-right: 8px;
}

.over-hist-balls {
    display: flex;
    gap: 4px;
}

.ball-circle {
    width: 32px;
    height: 40px;
    border-radius: 10%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.ball-norm {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.ball-4 {
    background: #10b981;
    color: white;
    font-size: 18px;
}

.ball-6 {
    background: #3b82f6;
    color: white;
    font-size: 18px;
}

.ball-w {
    background: #ef4444;
    color: white;
}

.text-accent {
    color: var(--accent) !important;
}

.text-white-50,
.text-muted,
.small.text-white-50 {
    color: var(--text-secondary) !important;
}

.text-theme {
    color: var(--text-primary) !important;
}

/* Ensure global headings and text adapt to theme */
h1:not(.dashboard-header *),
h2:not(.dashboard-header *),
h3:not(.dashboard-header *),
h4:not(.dashboard-header *),
h5:not(.dashboard-header *),
h6:not(.dashboard-header *),
p:not(.dashboard-header *),
span:not(.dashboard-header *),
label {
    transition: color 0.3s;
}

.dashboard-header h1,
.dashboard-header h2,
.dashboard-header p,
.dashboard-header span {
    color: white !important;
}

.btn-premium {
    background: var(--secondary);
    border: 0px !important;
    color: white !important;
    font-weight: 700;
    border-radius: 12px;
    padding: 12px 24px;
    transition: 0.3s;
    box-shadow: none !important;
}

.btn-premium:hover {
    transform: translateY(-2px);
    border: 1px solid #dee2e6 !important;
    color: #1e293b !important;
    filter: brightness(1.1);
    box-shadow: none !important;
}

.nav-link.active {
    border: 0px !important;
    box-shadow: none !important;
}

.nav-link.active:hover {
    border: 1px solid #dee2e6 !important;
}

.btn-accent {
    background: var(--secondary) !important;
    border: none !important;
    color: #1e293b !important;
}

.btn-accent:hover {
    filter: brightness(1.1);
}

.stat-value {
    color: var(--accent);
    font-size: 2rem;
    font-weight: 800;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    border-top: 1px solid var(--card-border);
    z-index: 1000;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.05);
}

.btn-outline-theme {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-primary) !important;
    border-radius: 12px;
    transition: 0.3s;
}

.btn-outline-theme:hover {
    background: var(--accent);
    color: #fff !important;
    border-color: var(--accent);
}

.nav-item {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

.nav-item.active {
    color: var(--accent);
}

.x-small {
    font-size: 0.75rem;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.border-theme {
    border: 1px solid var(--card-border) !important;
}

.animate {
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Styles */
.form-control {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 12px;
}

.form-control:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: none;
}

.form-control,
.form-select {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-primary);
    padding: 12px;
}

.form-control:focus,
.form-select:focus {
    background: var(--card-bg);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: none;
}

body.light-theme .form-control,
body.light-theme .form-select {
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    color: #1e293b !important;
}

body.light-theme .form-control::placeholder {
    color: #94a3b8;
}

/* ═══════════════════════════════════════════════════════════
   TEXT CAPITALIZE — Player & Team Names
   ═══════════════════════════════════════════════════════════ */

/* Any element with a data-name attribute or known player/team classes */
.player-name,
.team-name,
[class*="player-name"],
[class*="team-name"] {
    text-transform: capitalize;
}

/* Dashboard leaderboard / rankings dynamic content */
#topBatsmenList .fw-bold,
#topBowlersList .fw-bold,
#teamRankingsList .fw-bold,
#recentMatches .fw-bold,
#comparisonStats .stat-value {
    text-transform: capitalize;
}

/* ═══════════════════════════════════════════════════════════
   THEME TOGGLE BUTTON — Icon & Hover Fix
   ═══════════════════════════════════════════════════════════ */

/* Default dark theme: icon is white/light */
.theme-icon {
    color: #f1f5f9;
    transition: color 0.3s;
}

/* Light theme: icon should be dark so it's visible */
html.light-theme .theme-icon,
body.light-theme .theme-icon {
    color: #1e293b;
}

/* The button wrapper — hover should NOT clash */
.btn-outline-light.border-0:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: inherit !important;
}

html.light-theme .btn-outline-light.border-0,
body.light-theme .btn-outline-light.border-0 {
    color: #1e293b !important;
}

html.light-theme .btn-outline-light.border-0:hover,
body.light-theme .btn-outline-light.border-0:hover {
    background: rgba(0, 0, 0, 0.07) !important;
    color: #1e293b !important;
}

/* User Custom Overrides */
.text-primary {
    color: #00a25b !important;
}

/* ═══════════════════════════════════════════════════════════
   GLOBAL PRELOADER
   ═══════════════════════════════════════════════════════════ */
.cric-preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #008148 0%, #00a25b 100%);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease-out, visibility 0.4s ease-out;
}

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

.brand-logo-preloader {
    font-size: 4rem;
    color: #ffffff !important;
}

.preloader-dev-text {
    margin-top: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 300;
}

.preloader-dev-text strong,
.preloader-dev-text .fw-bold {
    color: #ffffff;
    font-weight: 700;
}

.brand-logo-preloader .preloader-kit {
    color: #ffffff !important;
}

.brand-logo-preloader .preloader-kit::before {
    background-color: var(--secondary);
    width: 12px;
    height: 12px;
    left: -6px;
    bottom: 10px;
}

/* Shine effect */
.animate-pulse {
    animation: pulseShine 1.2s infinite alternate ease-in-out;
}

@keyframes pulseShine {
    0% {
        opacity: 0.8;
        transform: scale(0.95);
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    }

    100% {
        opacity: 1;
        transform: scale(1.05);
        text-shadow: 0 0 30px rgba(255, 255, 255, 0.9), 0 0 50px var(--secondary);
    }
}