:root {
    --bg-gradient: linear-gradient(135deg, #0d1117 0%, #1a237e 100%);
    --primary-color: #1a237e;
    --primary-hover: #151b6a;
    --secondary-color: #2b3a55;
    --accent-color: #ffd700;
    --danger-color: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(13, 17, 23, 0.7);
    --glass-border: rgba(255, 215, 0, 0.2);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.8);

    --font-family: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Utilities */
.hidden {
    display: none !important;
}

.view {
    animation: fadeIn 0.4s ease-in-out;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(26, 35, 126, 0.4);
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-family: 'Montserrat', sans-serif;
    margin-bottom: 0.5em;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Forms & Inputs */
.input-group {
    margin-bottom: 1rem;
    width: 100%;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input,
select {
    width: 100%;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 1rem;
}

.primary-btn {
    background: linear-gradient(45deg, var(--primary-color), #3949ab);
    color: white;
    box-shadow: 0 4px 15px rgba(26, 35, 126, 0.3);
}

.primary-btn:hover {
    background: linear-gradient(45deg, #151b6a, var(--primary-color));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 35, 126, 0.5);
}

.secondary-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.accent-btn {
    background: linear-gradient(45deg, var(--accent-color), #ffc107);
    color: #0d1117;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.accent-btn:hover {
    background: linear-gradient(45deg, #ffc107, var(--accent-color));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.text-btn {
    background: transparent;
    color: var(--text-muted);
}

.text-btn:hover {
    color: var(--text-main);
}

.auth-link span {
    color: var(--accent-color);
    cursor: pointer;
    text-decoration: underline;
    font-weight: 600;
}

.auth-link span:hover {
    color: white;
}

.small-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.large-btn {
    width: 100%;
    font-size: 1.1rem;
    padding: 16px;
    margin-top: 20px;
}

/* Views Specifics */

/* Login */
#login-view {
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-card {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

/* Dashboard */
/* Logo */
.app-logo {
    max-width: 150px;
    height: auto;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.3));
}

.small-logo {
    max-width: 50px;
    margin-bottom: 0;
    margin-right: 15px;
}

.header-branding {
    display: flex;
    align-items: center;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
}

@media(max-width: 768px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

.teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.team-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.team-card:hover {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.06);
}

.team-card h4 {
    margin-bottom: 5px;
}

.team-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.player-list,
.selection-list {
    margin-top: 15px;
    list-style: none;
}

.player-list li {
    padding: 8px 10px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
}

.player-list li:last-child {
    border-bottom: none;
}

.selection-item {
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
}

.selection-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Match Setup */
.setup-container {
    max-width: 900px;
    margin: 0 auto;
}

.select-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.select-group {
    flex: 1;
}

.vs-badge {
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 50%;
}

.players-selection-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.checkbox-list {
    max-height: 400px;
    overflow-y: auto;
    text-align: left;
}

.player-checkbox-item {
    display: block;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.1s;
}

.player-checkbox-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.player-checkbox-item input {
    width: auto;
    margin-right: 10px;
}

/* Toss */
.center-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
}

.toss-card {
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.toss-buttons,
.decision-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* --- Scoreboard Styles --- */
.scoreboard-container {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.main-score-card {
    text-align: center;
    padding: 30px;
}

.score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.batting-team-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
}

.main-score {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--accent-color);
    line-height: 1;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    letter-spacing: -2px;
}

.stats-row {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 10px;
    border-top: 1px solid var(--glass-border);
    padding-top: 10px;
}

.player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--glass-border);
}

.player-row:last-child {
    border-bottom: none;
}

.role-icon {
    margin-right: 8px;
    font-size: 1.2rem;
}

.player-name {
    font-weight: 600;
}

.on-strike-indicator {
    color: var(--accent-color);
    margin-left: 5px;
    font-weight: bold;
}

.player-score {
    font-family: monospace;
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.sr-display,
.econ-display {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Controls Grid */
.controls-area {
    margin-top: 20px;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.extras-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    padding: 20px 0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.1s;
}

.control-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.run-btn[data-value="4"] {
    background: rgba(59, 130, 246, 0.3);
    border-color: var(--primary-color);
}

.run-btn[data-value="6"] {
    background: rgba(16, 185, 129, 0.3);
    border-color: var(--accent-color);
}

.extra-btn {
    font-size: 0.9rem;
    padding: 12px 0;
    background: rgba(255, 255, 255, 0.05);
}

.wicket-btn {
    background: rgba(239, 68, 68, 0.3);
    border-color: var(--danger-color);
    color: #fca5a5;
    font-size: 0.9rem;
}

.accent-card {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid var(--accent-color);
    text-align: center;
}

/* Data Table */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.report-table th,
.report-table td {
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.text-right {
    text-align: right !important;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.action-cell {
    display: flex;
    gap: 10px;
}

/* User Badge */
#user-badge {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--accent-color);
    padding: 12px 18px;
    border-radius: 12px;
    color: var(--text-main);
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    transition: opacity 0.3s;
    text-align: center;
}

.badge-branding {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    padding-bottom: 8px;
    width: 100%;
}

.badge-logo {
    height: 55px;
    width: auto;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.4));
}

.powered-by {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent-color);
    letter-spacing: 0.5px;
}

.user-info {
    font-size: 0.8rem;
}

#user-badge.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.badge-label {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#current-user-display {
    font-weight: 700;
}

/* Player Selection Limit Styles */
.selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.selection-count {
    font-size: 0.85rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    font-weight: 500;
}

.selection-count.valid {
    background: rgba(0, 255, 127, 0.2);
    color: #00ff7f;
}

.selection-count.invalid {
    background: rgba(255, 69, 58, 0.2);
    color: #ff453a;
}

.instruction-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Export Action Styles */
.export-actions-card {
    margin-top: 20px;
    background: rgba(16, 185, 129, 0.05);
    border: 1px dashed var(--accent-color);
}

.export-buttons-row {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.export-buttons-row .btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
}

.report-export-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.match-meta {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.match-meta p {
    margin: 8px 0;
}

.score-summary {
    margin: 20px 0;
}

.score-cards {
    display: flex;
    gap: 20px;
    margin-top: 15px;
}

.score-card {
    flex: 1;
    padding: 20px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--accent-color);
    border-radius: 10px;
    text-align: center;
}

.score-card h4 {
    margin: 0 0 10px 0;
    color: var(--accent-color);
}

.score-card .score {
    font-size: 2rem;
    font-weight: 700;
    margin: 10px 0;
    color: var(--text-main);
}

.score-card .overs {
    color: var(--text-muted);
    margin: 5px 0;
}

.match-result {
    margin-top: 20px;
    padding: 20px;
    background: rgba(16, 185, 129, 0.2);
    border-radius: 10px;
    text-align: center;
}

.match-result h3 {
    margin: 0;
    color: var(--accent-color);
    font-size: 1.5rem;
}

/* --- Analytics & Prediction Styles --- */
.analytics-card {
    margin-top: 20px;
    padding: 20px;
}

.prediction-header h4 {
    font-size: 1.1rem;
    color: var(--accent-color);
    margin-bottom: 15px;
}

.prediction-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 10px;
}

.prediction-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.prediction-item .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.prediction-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.win-prob-bar-container {
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 10px;
    position: relative;
}

.win-prob-bar {
    height: 100%;
    width: 100%;
    display: flex;
    transition: all 0.5s ease;
}

#win-prob-bar::before {
    content: '';
    position: absolute;
    left: var(--prob-a, 50%);
    top: 0;
    bottom: 0;
    width: 2px;
    background: white;
    z-index: 2;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.team-prob {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: white;
    transition: width 0.5s ease;
}

#win-prob-a {
    background: linear-gradient(90deg, var(--primary-color), #4dabf7);
    width: 50%;
}

#win-prob-b {
    background: linear-gradient(90deg, #ff6b6b, var(--danger-color));
    width: 50%;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

@media (max-width: 480px) {
    .app-container {
        padding: 10px;
    }

    .app-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
        margin-bottom: 20px;
    }

    .main-score {
        font-size: 2.2rem;
    }

    .batting-team-name {
        font-size: 1rem;
    }

    .control-grid {
        gap: 8px;
    }

    .control-btn {
        padding: 15px 0;
        font-size: 1.2rem;
    }

    .extras-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .extra-btn {
        padding: 10px 0;
        font-size: 0.8rem;
    }

    .prediction-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .prediction-item .value {
        font-size: 1.2rem;
    }

    .modal-content {
        width: 95%;
        padding: 15px;
    }

    .teams-grid {
        grid-template-columns: 1fr;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
        font-size: 0.85rem;
    }

    #user-badge {
        padding: 8px 12px;
        font-size: 0.8rem;
        bottom: 10px;
        right: 10px;
    }

    .tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    #scorer-notification {
        padding: 15px;
    }
}