:root {
    --primary-gradient:
      radial-gradient(circle at top left, rgba(0, 209, 255, 0.18), transparent 28%),
      radial-gradient(circle at top right, rgba(111, 76, 255, 0.12), transparent 30%),
      linear-gradient(180deg, #f7fbff 0%, #ecf3ff 48%, #e6eefc 100%);
    --glass-bg: rgba(255, 255, 255, 0.68);
    --glass-border: rgba(255, 255, 255, 0.55);
    --text-white: #0f172a;
    --accent-green: #12c48b;
    --accent-orange: #ff8a00;
    --accent-red: #ff4d6d;
    --highlight-color: #00cfff;
    --bg-color: #eef4ff;
    --text-color: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.72);
    --border-color: rgba(80, 111, 170, 0.18);
    --input-bg: rgba(255, 255, 255, 0.7);
    --input-text: #0f172a;
    --modal-bg: rgba(244, 248, 255, 0.92);
    --modal-text: #0f172a;
}

[data-theme="dark"] {
    --primary-gradient:
      radial-gradient(circle at top left, rgba(0, 209, 255, 0.18), transparent 24%),
      radial-gradient(circle at top right, rgba(111, 76, 255, 0.16), transparent 28%),
      linear-gradient(180deg, #07111f 0%, #0b1426 55%, #111827 100%);
    --glass-bg: rgba(9, 16, 31, 0.72);
    --glass-border: rgba(97, 218, 251, 0.16);
    --text-white: #f4f7ff;
    --accent-green: #19d3a2;
    --accent-orange: #ff9b2f;
    --accent-red: #ff5678;
    --highlight-color: #42d9ff;
    --bg-color: #08111e;
    --text-color: #f4f7ff;
    --card-bg: rgba(11, 18, 34, 0.78);
    --border-color: rgba(97, 218, 251, 0.14);
    --input-bg: rgba(15, 24, 44, 0.78);
    --input-text: #f4f7ff;
    --modal-bg: rgba(10, 18, 33, 0.94);
    --modal-text: #f4f7ff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

html {
    min-height: 100vh;
    min-width: 100vw;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--primary-gradient);
    background-color: var(--bg-color);
    background-attachment: fixed;
    background-size: cover;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    height: 100vh;
    width: 100vw;
    color: var(--text-white);
    overflow: hidden;
    overscroll-behavior-y: contain;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

body::before,
body::after {
    content: "";
    position: fixed;
    inset: auto;
    border-radius: 999px;
    pointer-events: none;
    filter: blur(80px);
    z-index: 0;
}

body::before {
    width: 34vw;
    height: 34vw;
    top: -10vw;
    left: -8vw;
    background: rgba(66, 217, 255, 0.22);
}

body::after {
    width: 28vw;
    height: 28vw;
    right: -6vw;
    bottom: 8vh;
    background: rgba(111, 76, 255, 0.18);
}

.container {
    position: relative;
    z-index: 1;
    max-width: 100%;
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

header {
    text-align: center;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.header-actions {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    z-index: 100;
    background: linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.1));
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    padding: 8px 20px;
    backdrop-filter: blur(18px);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18), inset 0 1px 0 rgba(255,255,255,0.45);
}

.logo-link {
    display: flex;
    align-items: center;
    transition: transform 0.2s;
    margin: 0 8px;
}

.logo-link:hover {
    transform: scale(1.1);
}

.club-logo {
    width: 40px; /* Match icon button size roughly */
    height: 40px;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    transition: all 0.3s ease;
}

[data-theme="dark"] .club-logo {
    background: white; /* White background in dark mode */
    padding: 2px;
}

.icon-btn {
    background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.04));
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    font-size: 1.4rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}

.icon-btn .material-icons {
    font-size: 24px;
}

.icon-btn:hover {
    transform: translateY(-2px) scale(1.08);
    background: rgba(255,255,255,0.18);
    box-shadow: 0 0 18px rgba(66, 217, 255, 0.22);
}

[data-theme="dark"] .icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .icon-btn .material-icons {
    color: white;
}

h1 {
    font-size: 1.3rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.scoreboard {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 15px;
    flex: 1;
    min-height: 0;
    margin-bottom: 80px; /* Space for bottom action bar */
}

/* Team Containers */
.team {
    flex: 1;
    background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.08));
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    transition: all 0.3s ease;
    min-width: 0;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(18px);
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.14), inset 0 1px 0 rgba(255,255,255,0.35);
    overflow: visible;
}

.team:active {
    transform: scale(0.98); /* Subtle feedback on click */
}

.team.serving {
    background: linear-gradient(180deg, rgba(66,217,255,0.16), rgba(255,255,255,0.08));
    box-shadow: 0 0 0 1px rgba(66,217,255,0.16), 0 0 28px rgba(66,217,255,0.18), 0 24px 48px rgba(15, 23, 42, 0.16);
    border-color: rgba(66, 217, 255, 0.4);
}

[data-theme="dark"] .team.serving {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

.team-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
    justify-content: space-between;
}

.server-marker {
    position: absolute;
    top: -10px;
    z-index: 2;
    font-size: 1.8rem;
    animation: bounce 1s infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-5px); }
}

.team-name {
    background: transparent;
    border: none;
    border-bottom: 2px solid rgba(66, 217, 255, 0.18);
    color: var(--text-color);
    font-size: 1.5rem;
    text-align: center;
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 5px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.score-display {
    margin: 0;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    /* Ensure it takes up remaining vertical space */
    height: 100%; 
}

.score {
    font-size: min(35vw, 60vh);
    font-weight: 800;
    line-height: 0.9;
    user-select: none;
    letter-spacing: -0.05em;
    text-shadow: 0 0 22px rgba(66, 217, 255, 0.18);
}

/* Position Indicators */
.position-display {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.pos-box {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
    opacity: 0.5;
    color: var(--text-color);
}

.pos-box.active {
    background: linear-gradient(135deg, var(--highlight-color), #7b61ff);
    color: #06111d;
    opacity: 1;
    border-color: transparent;
    box-shadow: 0 0 18px rgba(66,217,255,0.32);
}

/* Controls - REMOVED */

/* Center Info */
.center-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    min-width: 160px;
    padding: 20px;
}

.logo-link {
    display: block;
    transition: transform 0.2s;
}

.logo-link:hover {
    transform: scale(1.05);
}

.club-logo {
    max-width: 120px;
    height: auto;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.score-readout {
    background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.06));
    padding: 15px 30px;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255,255,255,0.28);
    backdrop-filter: blur(16px);
}

#full-score-display {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.serving-details {
    text-align: center;
}

#serving-text {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 3px;
}

#server-number-text {
    font-size: 0.9rem;
    opacity: 0.8;
}

.game-options label {
    font-size: 0.9rem;
}

.game-options select {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 5px 10px;
    border-radius: 8px;
    margin-left: 5px;
    font-size: 0.9rem;
}

.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.btn-undo, .btn-reset, .btn-manual, .btn-toggle-server, .btn-switch-sides {
    padding: 10px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.14);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14), inset 0 1px 0 rgba(255,255,255,0.18);
}

.btn-undo:hover, .btn-reset:hover, .btn-toggle-server:hover, .btn-switch-sides:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn-manual:hover {
    background: var(--glass-bg);
}

.btn-undo:active, .btn-reset:active, .btn-manual:active, .btn-toggle-server:active, .btn-switch-sides:active {
    transform: translateY(0);
}

.btn-undo { background: linear-gradient(135deg, #20344d, #304e73); color: white; }
.btn-reset { background: linear-gradient(135deg, #ff8a00, #ffb347); color: white; }
.btn-toggle-server { background: linear-gradient(135deg, #0fb8ff, #4763ff); color: white; }
.btn-manual { 
    background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03)); 
    border: 1px solid var(--border-color); 
    color: var(--text-color);
}
.btn-switch-sides { 
    background: linear-gradient(135deg, #7b61ff, #b64cff); 
    color: white; 
}

/* --- Desktop --- */
@media (min-width: 1024px) {
    .score {
        font-size: min(40vw, 65vh);
    }

    .team-name {
        font-size: 2rem;
    }

    .center-info {
        min-width: 200px;
    }

    #full-score-display {
        font-size: 2.2rem;
    }
}

/* --- Tablet --- */
@media (min-width: 768px) and (max-width: 1023px) {
    .score {
        font-size: min(45vw, 55vh);
    }

    .team {
        padding: 20px;
    }
}

/* --- Mobile Portrait --- */
@media (max-width: 600px) and (orientation: portrait) {
    .container {
        padding: 8px;
    }
    
    header {
        margin-bottom: 5px;
    }
    
    h1 {
        font-size: 1.1rem;
        margin-bottom: 3px;
    }
    
    .scoreboard {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 90px;
    }
    
    .team {
        flex-direction: column;
        padding: 15px;
        min-height: auto;
        position: relative;
        border-radius: 15px;
        flex: 1;
    }

    .team-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        width: 100%;
        align-items: center;
    }

    .team-name {
        text-align: center;
        margin: 0 0 10px 0;
        font-size: 1.1rem;
        padding: 4px;
    }

    .position-display {
        margin: 10px 0 0 0;
        justify-content: center;
        gap: 8px;
    }

    .pos-box {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .score-display {
        flex: 1;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
    }

    .score {
        font-size: min(50vw, 35vh); /* Adjust for mobile portrait */
        line-height: 0.85;
    }

    .server-marker {
        top: -8px;
        font-size: 1.4rem;
        left: 50%;
        transform: translateX(-50%);
    }

    .center-info {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 10px;
        background: var(--card-bg);
        border-radius: 12px;
        width: 100%;
        min-width: unset;
        gap: 6px;
        justify-content: space-between;
        align-items: center;
    }

    .score-readout {
        order: 1;
        flex: 1;
        text-align: center;
        padding: 6px 12px;
    }

    .serving-details {
        order: 2;
        flex: 1;
        text-align: center;
    }

    .game-options {
        order: 3;
        flex: 1;
        text-align: center;
    }

    .control-buttons {
        order: 4;
        width: 100%;
        flex-direction: row;
        justify-content: space-around;
        gap: 4px;
        margin-top: 4px;
    }

    .btn-undo, .btn-reset, .btn-manual, .btn-toggle-server, .btn-switch-sides {
        flex: 1;
        padding: 10px 4px;
        font-size: 0.75rem;
        min-height: 40px;
        border-radius: 8px;
    }

    #full-score-display {
        font-size: 1.2rem;
    }
    
    #serving-text {
        font-size: 0.85rem;
    }
    
    #server-number-text {
        font-size: 0.75rem;
    }
    
    .header-actions {
        bottom: 15px;
        padding: 8px 15px;
        gap: 8px;
    }
    
    .icon-btn {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
}

/* --- Mobile Landscape --- */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        padding: 5px;
    }

    header {
        margin-bottom: 3px;
    }

    h1 { font-size: 0.9rem; }

    .scoreboard {
        gap: 8px;
        margin-bottom: 60px;
    }

    .team {
        padding: 8px;
        border-radius: 10px;
    }

    .score {
        font-size: 55vh; /* Very large for landscape */
        line-height: 0.85;
    }

    .team-name {
        font-size: 0.9rem;
        margin-bottom: 2px;
    }

    .position-display {
        margin-top: 5px;
        gap: 5px;
    }

    .pos-box {
        width: 26px;
        height: 26px;
        font-size: 0.65rem;
    }

    /* .btn-rally removed */

    .center-info {
        min-width: 100px;
        gap: 6px;
        padding: 8px;
    }

    #full-score-display {
        font-size: 1.1rem;
        padding: 6px 12px;
    }

    .serving-details {
        font-size: 0.8rem;
    }

    #serving-text {
        font-size: 0.75rem;
        margin-bottom: 1px;
    }

    #server-number-text {
        font-size: 0.65rem;
    }

    .control-buttons {
        flex-direction: column;
        gap: 3px;
    }

    .btn-undo, .btn-reset, .btn-manual, .btn-toggle-server, .btn-switch-sides {
        padding: 5px 6px;
        font-size: 0.65rem;
        min-height: 28px;
    }

    .server-marker {
        font-size: 1.2rem;
        top: -6px;
    }

    .header-actions {
        bottom: 8px;
        padding: 5px 10px;
        gap: 5px;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}

/* --- Small Mobile Portrait --- */
@media (max-width: 380px) and (orientation: portrait) {
    .score {
        font-size: 32vw;
    }

    .team-name {
        font-size: 1rem;
    }

    .btn-rally {
        padding: 12px;
        font-size: 0.9rem;
    }

    #full-score-display {
        font-size: 1.1rem;
    }
}

/* Rotation Container Styles */
.rotation-container {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 0;
}

.rotation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.rotation-header h2 {
    font-size: 1.1rem;
}

/* Missing Rotation Styles Restored */
.add-player-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.btn-toggle-add-player {
    align-self: flex-start;
    background: linear-gradient(135deg, rgba(66,217,255,0.18), rgba(123,97,255,0.18));
    color: var(--text-color);
    border: 1px solid rgba(66,217,255,0.22);
    padding: 8px 14px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.add-player-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.add-player-controls.is-hidden {
    display: none;
}

.add-player-form,
.bulk-add-form {
    display: flex;
    gap: 8px;
    flex: 1;
}

.add-player-form input,
.bulk-add-form textarea {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--input-text);
    padding: 10px 15px;
    border-radius: 10px;
    outline: none;
    font-size: 1rem;
    flex: 1;
}

.bulk-add-form textarea {
    min-height: 96px;
    resize: vertical;
    font-family: inherit;
}

.add-player-form input::placeholder,
.bulk-add-form textarea::placeholder {
    color: rgba(120, 138, 170, 0.8);
}

.btn-add-player {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.95rem;
}

.rotation-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 600px) {
    .rotation-content {
        grid-template-columns: 1fr;
    }
}

.roster-panel, .match-generator-panel {
    background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
    padding: 15px;
    border-radius: 18px;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 32px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255,255,255,0.2);
}

.roster-panel h3, .match-generator-panel h3 {
    margin-bottom: 12px;
    font-size: 1rem;
    opacity: 0.9;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.player-count {
    font-weight: normal;
    opacity: 0.7;
    font-size: 0.85rem;
}

.roster-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 0.8rem;
    opacity: 0.8;
    flex-wrap: wrap;
}

.roster-stat {
    background: rgba(255,255,255,0.1);
    padding: 4px 10px;
    border-radius: 12px;
}

.roster-stat.playing {
    background: rgba(76, 175, 80, 0.3);
}

.roster-stat.resting {
    background: rgba(255, 152, 0, 0.3);
}

.roster-stat.bench {
    background: rgba(255,255,255,0.15);
}

#player-roster-list {
    list-style: none;
    margin-bottom: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.roster-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    margin-bottom: 6px;
    border-radius: 12px;
    font-size: 0.95rem;
    border: 1px solid rgba(255,255,255,0.08);
}

.roster-item .games-count {
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
}

.roster-item .remove-player {
    color: var(--accent-red);
    cursor: pointer;
    margin-left: 10px;
    font-weight: bold;
    font-size: 1.2rem;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.btn-reset-stats {
    background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset-stats:hover {
    background: rgba(255,255,255,0.1);
}

/* Match Generator Card */
.next-match-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.14), rgba(255,255,255,0.06));
    padding: 15px;
    border-radius: 18px;
    text-align: center;
    border: 1px solid rgba(66,217,255,0.16);
    box-shadow: 0 18px 32px rgba(15, 23, 42, 0.12), 0 0 24px rgba(66,217,255,0.08);
}

.match-teams {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.match-team {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.04));
    padding: 10px;
    border-radius: 10px;
    min-width: 100px;
}

.match-team strong {
    color: var(--highlight-color);
    font-size: 0.85rem;
}

.vs-divider {
    font-weight: bold;
    opacity: 0.5;
    font-size: 0.8rem;
}

.bench-info {
    font-size: 0.85rem;
    margin-bottom: 12px;
    opacity: 0.8;
}

.btn-generate, .btn-start-match {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    margin-top: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.btn-generate { background: linear-gradient(135deg, #11c5ff, #5b6dff); color: white; box-shadow: 0 0 22px rgba(17,197,255,0.18); }
.btn-generate:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-start-match { background: linear-gradient(135deg, #19d3a2, #0fb8ff); color: white; box-shadow: 0 0 22px rgba(25,211,162,0.18); }
.btn-start-match:hover { filter: brightness(1.06); transform: translateY(-1px); }

.match-controls {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.match-controls .btn-generate {
    flex: 2;
}

.match-controls .btn-secondary {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(66,217,255,0.2);
    background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.05));
    color: var(--text-color);
    font-weight: 700;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.match-controls .btn-secondary:hover {
    background: rgba(255,255,255,0.2);
}

.match-controls .btn-primary {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #ff8a00, #ff5f6d);
    color: white;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    box-shadow: 0 0 20px rgba(255,138,0,0.18);
}

.match-controls .btn-primary:hover {
    background: #e68900;
}

.match-mode-info {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-color);
    margin-bottom: 12px;
    padding: 8px;
    background: linear-gradient(135deg, rgba(66,217,255,0.12), rgba(123,97,255,0.08));
    border-radius: 12px;
    font-style: italic;
    border: 1px solid rgba(66,217,255,0.12);
}

#next-match-placeholder {
    text-align: center;
    padding: 20px;
    opacity: 0.5;
    font-style: italic;
    font-size: 0.9rem;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 10, 24, 0.72);
    backdrop-filter: blur(14px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--modal-bg);
    color: var(--modal-text);
    padding: 25px;
    border-radius: 24px;
    text-align: center;
    max-width: 90%;
    width: 350px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
    border: 1px solid var(--glass-border);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(20px);
}

.winner-content {
    border: 4px solid var(--highlight-color);
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
    color: var(--accent-orange);
    margin-bottom: 15px;
    font-size: 1.6rem;
}

.modal-content p {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: #555;
}

.modal-content button {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    transition: transform 0.2s;
}

.modal-content button:hover {
    transform: scale(1.05);
}

.winner-message {
    font-size: 1.4rem;
    font-weight: bold;
    color: #333;
    margin: 20px 0;
}

.winner-score {
    font-size: 3rem;
    font-weight: bold;
    color: var(--accent-green);
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.btn-close {
    background: #999 !important;
}

/* Rotation Modal */
.rotation-modal {
    display: none;
}

.rotation-modal.active {
    display: flex;
}

.rotation-modal-content {
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    background: var(--modal-bg);
    border: 1px solid var(--glass-border);
    box-shadow: 0 28px 60px rgba(0,0,0,0.32), 0 0 28px rgba(66,217,255,0.08);
}

.rotation-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.02);
}

.rotation-modal-header h2 {
    margin: 0;
    color: var(--modal-text);
    font-size: 1.3rem;
}

.rotation-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
}

[data-theme="dark"] .rotation-modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

/* History Modal */
.history-modal {
    display: none;
}

.history-modal.active {
    display: flex;
}

.history-modal-content {
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.history-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.02);
}

.history-modal-header h2 {
    margin: 0;
    color: var(--modal-text);
}

[data-theme="dark"] .history-modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.history-modal-actions {
    display: flex;
    gap: 10px;
}

.btn-close-modal {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    color: var(--modal-text);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close-modal:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .btn-close-modal:hover {
    background: rgba(255, 255, 255, 0.1);
}

.history-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
}

.history-modal-body .history-table {
    font-size: 1rem;
}

.history-modal-body .history-table th,
.history-modal-body .history-table td {
    padding: 12px;
}

.history-modal-body .no-history {
    padding: 40px;
    font-size: 1.1rem;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.history-table th {
    text-align: left;
    padding: 10px;
    color: rgba(255,255,255,0.6);
    font-weight: normal;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.history-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.history-winner {
    color: var(--highlight-color);
    font-weight: bold;
}

.btn-clear-history {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-clear-history:hover {
    opacity: 1;
    background: rgba(244, 67, 54, 0.1);
}

.no-history {
    text-align: center;
    padding: 20px;
    color: rgba(255,255,255,0.4);
    font-style: italic;
    font-size: 1rem;
}

/* Statistics Modal Styles */
.stats-modal {
    display: none;
}

.stats-modal.active {
    display: flex;
}

.stats-modal-content {
    width: 95%;
    max-width: 750px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.stats-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.02);
}

.stats-modal-header h2 {
    margin: 0;
    color: var(--modal-text);
}

[data-theme="dark"] .stats-modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.stats-modal-actions {
    display: flex;
    gap: 10px;
}

.btn-clear-stats {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-clear-stats:hover {
    opacity: 1;
    background: rgba(244, 67, 54, 0.1);
}

.stats-modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.stats-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

[data-theme="dark"] .stat-card {
    background: rgba(255, 255, 255, 0.05);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.stat-card.wide {
    grid-column: span 2;
}

.stat-label {
    font-size: 0.95rem;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 3rem;
    font-weight: bold;
    color: var(--text-color);
    line-height: 1;
}

.stat-sublabel {
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.6;
    margin-top: 8px;
}

.stat-bars {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.stat-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-bar-label {
    width: 80px;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    text-align: left;
}

.stat-bar {
    flex: 1;
    height: 28px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 14px;
    overflow: hidden;
    position: relative;
}

[data-theme="dark"] .stat-bar {
    background: rgba(255, 255, 255, 0.1);
}

.stat-bar-fill {
    height: 100%;
    border-radius: 14px;
    transition: width 0.5s ease;
}

.stat-bar-fill.team1 {
    background: linear-gradient(90deg, #4CAF50, #81C784);
}

.stat-bar-fill.team2 {
    background: linear-gradient(90deg, #2196F3, #64B5F6);
}

.stat-bar-value {
    width: 45px;
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-color);
    text-align: right;
}

.score-timeline {
    margin-top: 15px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

[data-theme="dark"] .score-timeline {
    background: rgba(255, 255, 255, 0.03);
}

.timeline-placeholder {
    color: var(--text-color);
    opacity: 0.5;
    font-style: italic;
}

.timeline-graph {
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 100px;
    gap: 4px;
}

.timeline-point {
    flex: 1;
    min-width: 8px;
    border-radius: 4px 4px 0 0;
    transition: all 0.3s;
}

.timeline-point.team1 {
    background: #4CAF50;
}

.timeline-point.team2 {
    background: #2196F3;
}

@media (max-width: 600px) {
    .stats-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card.wide {
        grid-column: span 1;
    }
    
    .stat-value {
        font-size: 2.5rem;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stats-modal-content,
    .history-modal-content,
    .rotation-modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .stats-modal-body .history-table {
        font-size: 0.9rem;
    }
    
    .stats-modal-body .history-table th,
    .stats-modal-body .history-table td {
        padding: 10px 8px;
    }
}
