@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@700&family=Russo+One&family=Roboto:wght@700&display=swap');

@import url('https://fonts.googleapis.com/css2?family=Aldrich&family=Barlow+Condensed:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Big+Shoulders:opsz,wght@10..72,100..900&family=League+Gothic&family=Montserrat:ital,wght@0,100..900;1,100..900&family=Rubik:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Science+Gothic:wdth@90.6&family=Teko:wght@300..700&family=Tektur:wght@400..900&display=swap');

:root {
    /* Define base font size for rem units */
    font-size: 16px;

    /* Color Palette */
    --bg-color: #050505;
    --panel-bg: #111;
    --border-color: #333;
    --text-light: #f0f0f0;
    --text-medium: #aaa;
    --text-dark: #555;
    --score-blue: #3498db;
    --score-blue-bg: #05101a;
    --stat-yellow: #f1c40f;
    --stat-yellow-bg: #292203;
    --timeout-orange: #e67e22;
    --timeout-orange-bg: #2a1a0a;
    --clock-red: #e74c3c;
    --clock-red-bg: #2a0e0a;
    --clock-white: #ffffff;
    --clock-white-bg: #222;
}

body {
    background-color: var(--bg-color);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    margin: 0;
    font-family: 'Roboto', sans-serif;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
}

.scoreboard {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* Distribute space evenly */
    align-items: center;
    background-color: #050505;
    border: 10px solid #333;
    border-radius: 20px;
    padding: 1rem 2rem;
    width: 98vw;
    height: 98vh;
    max-width: none;
    max-height: none;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    box-sizing: border-box;
    margin: auto;
    overflow: hidden;
    position: relative;
}

/* --- Header Section (Clock & Quarter) --- */
.header-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 2;
    /* Take up significant space */
    position: relative;

}

.game-clock {
    display: inline-flex;
    justify-content: center;
    align-items: center;

    font-family: 'Orbitron', monospace;
    font-size: clamp(18rem, 40vh, 35rem);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    font-kerning: none;
    /* stop auto spacing changes */

    color: #e74c3c;
    background-color: #1a0505;
    padding: 0 1.5rem;
    border-radius: 20px;
    border: 2px solid #333;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(231, 76, 60, 0.2);
    text-shadow: 0 0 30px rgba(231, 76, 60, 0.6);
    line-height: 1;
    white-space: nowrap;
}

/* Each character has its own fixed-width cell */
.clock-char {
    display: inline-block;
    width: 1ch;
    /* width of one digit */
    text-align: center;
}

/* Optional: colon a bit narrower / spaced */
.clock-char.colon {
    width: 0.7ch;
}


/* --- Logo Section --- */
.logo-section {
    position: absolute;
    top: 55%;
    /* Position from top - moved down further */
    left: 50%;
    transform: translateX(-50%);
    /* Center horizontally */
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    z-index: 10;
    /* Keep above other elements */
}

/* --- Quarter Section --- */
.quarter-section {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 0 0 0.5rem 0;
}

.quarter-logo {
    width: 300px;
    /* Increased size */
    height: auto;
    margin-bottom: 0.5rem;
    opacity: 0.9;
    margin-bottom: 3rem;
}

.quarter-display {
    display: block;
    font-family: 'Orbitron', monospace;
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    color: #ffffff;
    background-color: #222;
    padding: 0.5rem 1.5rem;
    border-radius: 10px;
    border: 2px solid #444;
    text-align: center;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    min-width: 3em;
}

/* --- Names Section --- */
.names-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 4rem;
    flex: 1;
    box-sizing: border-box;
    margin-top: 1rem;
    /* Move names down */
    margin-bottom: -2rem;
    /* Move up without affecting scores */
}

.team-name {
    font-family: 'Roboto', sans-serif;
    font-size: clamp(6rem, 12vw, 12rem);
    font-weight: 900;
    color: #ffffff;
    text-transform: uppercase;
    width: 40%;
    text-align: center;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    position: relative;
    /* For arrow positioning */
}

.team-name.home {
    text-align: center;
}

.team-name.away {
    text-align: center;
}

/* Ball Possession Arrow */
.possession-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Home Arrow (Left of name, pointing right) */
.team-name.home .possession-arrow {
    left: -40px;
    border-width: 15px 0 15px 25px;
    border-color: transparent transparent transparent #ffffff;
    /* White pointing right */
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8));
}

/* Away Arrow (Right of name, pointing left) */
.team-name.away .possession-arrow {
    right: -40px;
    border-width: 15px 25px 15px 0;
    border-color: transparent #ffffff transparent transparent;
    /* White pointing left */
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.8));
}

.possession-arrow.active {
    opacity: 1;
}

/* Swap layout helper (used by scoreboard-swapped.html) */
body.swap-layout .names-section .team-name.away {
    order: 1;
}

body.swap-layout .names-section .team-name.home {
    order: 2;
}

body.swap-layout .main-section .score-container.away {
    order: 1;
}

body.swap-layout .main-section .fouls-section {
    order: 2;
}

body.swap-layout .main-section .score-container.home {
    order: 3;
}

body.swap-layout .team-name.home .possession-arrow {
    left: auto;
    right: -40px;
    border-width: 15px 25px 15px 0;
    border-color: transparent #ffffff transparent transparent;
}

body.swap-layout .team-name.away .possession-arrow {
    right: auto;
    left: -40px;
    border-width: 15px 0 15px 25px;
    border-color: transparent transparent transparent #ffffff;
}

body.swap-layout .fouls-section {
    display: flex;
    flex-direction: row;
}

body.swap-layout .fouls-section .foul-box.home {
    order: 2;
}

body.swap-layout .fouls-section .foul-box.away {
    order: 1;
}

/* --- Main Section (Scores & Fouls) --- */
.main-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Center vertically */
    width: 100%;
    flex: 3;
    /* Largest section */
    padding: 0 2rem;
    box-sizing: border-box;
    margin-top: 2rem;
    /* Move scores down */
}

.score-container {
    width: 38%;
    /* Increased to accommodate 3 digits */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

.score {
    font-family: 'Roboto', sans-serif;
    font-size: clamp(14rem, 30vh, 24rem);
    /* Bigger numbers */
    font-weight: 900;
    /* Same as team names */
    line-height: 0.95;
    padding: 0.5rem 0.5rem;
    /* Reduced padding to keep box size similar */
    border-radius: 20px;
    min-width: 1.5em;
    /* Reduced width to make box narrower */
    text-align: center;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
    border: 2px solid #333;
    letter-spacing: 0.02em;
}

/* Home Score - Blue */
.score-container.home .score {
    color: #f1c40f;
    background-color: #292203;
    text-shadow: 0 0 30px rgba(241, 196, 15, 0.6);
    border-color: #4a3b0a;
}

/* Away Score - Yellow */
.score-container.away .score {
    color: #f1c40f;
    background-color: #292203;
    text-shadow: 0 0 30px rgba(241, 196, 15, 0.6);
    border-color: #4a3b0a;
}

.fouls-section {
    display: flex;
    justify-content: center;
    gap: 2rem;
    /* Reduced gap for less clutter */
    width: 30%;
    align-items: center;
    margin-top: 3rem;
    /* Move fouls down */
}

.foul-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #111;
    padding: 1.5rem 3rem;
    /* Larger box */
    border-radius: 15px;
    border: 1px solid #333;
}

.foul-label {
    font-family: 'Roboto', sans-serif;
    font-size: 1.8rem;
    /* Larger label */
    font-weight: 700;
    color: #aaa;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

.foul-value {
    font-family: 'Orbitron', monospace;
    font-size: clamp(5rem, 10vw, 8rem);
    /* Larger numbers */
    color: #ffffff;
    /* Green LED */
    text-shadow: 0 0 20px rgba(46, 204, 113, 0.6);
    line-height: 1;
}

/* Penalty styling for 5+ fouls */
.foul-box.penalty {
    background-color: #2a0505;
    border: 2px solid #e74c3c;
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.6), inset 0 0 10px rgba(231, 76, 60, 0.3);
    animation: penaltyPulse 2s infinite;
}

.foul-box.penalty .foul-label {
    color: #ffffff;
    /* White label */
}

.foul-box.penalty .foul-value {
    color: #e74c3c;
    /* Red count */
    text-shadow: 0 0 20px rgba(231, 76, 60, 0.8);
}

@keyframes penaltyPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(231, 76, 60, 0.6), inset 0 0 10px rgba(231, 76, 60, 0.3);
    }

    50% {
        box-shadow: 0 0 30px rgba(231, 76, 60, 0.9), inset 0 0 15px rgba(231, 76, 60, 0.5);
    }
}

/* --- Help Modal --- */
/* Modal styles remain largely the same, adjust if needed */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    /* Ensure it's on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    /* Darker overlay */
}

.modal-content {
    background-color: #282828;
    /* Slightly lighter modal bg */
    color: var(--text-light);
    margin: 10% auto;
    padding: clamp(1.5rem, 5vw, 3rem);
    /* Responsive padding */
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 550px;
    /* Slightly wider max */
    border-radius: 10px;
    position: relative;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
}

.modal-content h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--clock-red);
    font-size: clamp(1.5rem, 4vw, 2rem);
}

.modal-content ul {
    list-style: none;
    padding: 0;
}

.modal-content li {
    margin-bottom: 0.8rem;
    line-height: 1.5;
    font-size: clamp(0.9rem, 2vw, 1rem);
}

.modal-content hr {
    border: 0;
    height: 1px;
    background-color: #444;
    margin: 1.5rem 0;
}

.modal-content strong {
    color: var(--stat-yellow);
    display: inline-block;
    min-width: 90px;
    margin-right: 10px;
}

.close-button {
    color: var(--text-medium);
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-button:hover,
.close-button:focus {
    color: var(--text-light);
    transform: scale(1.1);
}

/* Control Panel Styles */
.control-panel {
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
}

.control-section {
    margin-bottom: 2rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.02);
}

.control-section h3 {
    margin: 0 0 1rem 0;
    color: var(--stat-yellow);
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-group {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.input-group:last-child {
    margin-bottom: 0;
}

.input-group label {
    min-width: 120px;
    font-weight: bold;
    color: var(--text-light);
}

.input-group input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--panel-bg);
    color: var(--text-light);
    font-family: 'Orbitron', monospace;
    font-size: 1rem;
}

.input-group input:focus {
    outline: none;
    border-color: var(--stat-yellow);
    box-shadow: 0 0 5px rgba(241, 196, 15, 0.3);
}

.input-group select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--panel-bg);
    color: var(--text-light);
    font-family: 'Roboto', sans-serif;
    font-size: 1rem;
    cursor: pointer;
}

.input-group select:focus {
    outline: none;
    border-color: var(--stat-yellow);
    box-shadow: 0 0 5px rgba(241, 196, 15, 0.3);
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.button-group button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-family: 'Roboto', sans-serif;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

.button-group button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#start-game-clock,
#start-shot-clock {
    background-color: #27ae60;
    color: white;
}

#start-game-clock:hover,
#start-shot-clock:hover {
    background-color: #2ecc71;
}

#stop-game-clock,
#stop-shot-clock {
    background-color: #e74c3c;
    color: white;
}

#stop-game-clock:hover,
#stop-shot-clock:hover {
    background-color: #c0392b;
}

.primary-button {
    background-color: var(--score-blue);
    color: white;
}

.primary-button:hover {
    background-color: #2980b9;
}

.danger-button {
    background-color: #e74c3c;
    color: white;
}

.danger-button:hover {
    background-color: #c0392b;
}

.secondary-button {
    background-color: var(--stat-yellow);
    color: #000;
}

.secondary-button:hover {
    background-color: #f39c12;
}

/* Login Panel Styles */
.login-panel {
    max-width: 400px;
    padding: 2rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-status {
    text-align: center;
    padding: 0.5rem;
    border-radius: 4px;
    font-weight: bold;
    min-height: 1.5rem;
}

.login-status.success {
    background-color: rgba(39, 174, 96, 0.2);
    color: #27ae60;
    border: 1px solid #27ae60;
}

.login-status.error {
    background-color: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: 1px solid #e74c3c;
}

.login-status.info {
    background-color: rgba(52, 152, 219, 0.2);
    color: #3498db;
    border: 1px solid #3498db;
}

/* Authentication overlay removed - scoreboard is now viewable by all users */


/* --- RESPONSIVENESS --- */

@media (max-width: 900px) {
    .scoreboard {
        /* Reduce gap on medium screens */
        gap: clamp(1rem, 2vw, 2rem);
    }

    /* Adjust font sizes slightly if needed */
    .score {
        font-size: clamp(5rem, 30vw, 15rem);
    }

    .game-clock {
        font-size: clamp(4rem, 10vw, 8rem);
    }

    .shot-clock {
        font-size: clamp(3.5rem, 9vw, 7rem);
    }

    .quarter-display {
        font-size: clamp(2rem, 5vw, 3rem);
    }

}


@media (max-width: 768px) {
    body {
        padding: 0.15rem;
        align-items: center;
        height: 100vh;
        width: 100vw;
    }

    .scoreboard {
        flex-direction: column;
        align-items: center;
        width: 100%;
        max-width: 100%;
        margin: 0 auto;
        gap: 0.5rem;
        padding: 0.25rem;
        height: 100vh;
    }

    .team,
    .center-console {
        width: 100%;
        /* Take full width */
        flex-basis: auto;
        /* Reset flex basis */
        align-self: center;
        padding: 0.5rem;
    }

    .center-console {
        order: -1;
        /* Move clocks above scores on mobile */
        padding-bottom: 1rem;
        /* Add padding below clocks */
        gap: 1rem;
        /* Reduce gap in center console */
    }

    .team {
        justify-content: center;
        /* Center content vertically in team section */
        padding-bottom: 1rem;
    }

    .score {
        font-size: clamp(6rem, 22vw, 13rem);
        margin: 0.3rem auto 1.2rem;
    }

    .game-clock {
        font-size: clamp(6rem, 20vw, 11rem);
        /* Larger font size for mobile */
        margin-bottom: 0.25rem;
        /* Smaller gap when stacked */
        padding: 0.2rem 0.6rem;
    }

    .shot-clock {
        font-size: clamp(6rem, 20vw, 12rem);
        /* Larger font size for mobile */
        width: 85%;
        /* Wider on mobile */
        padding: 0.15em 0.05em;
        /* Taller shot clock */
    }

    .quarter-display {
        font-size: clamp(3rem, 12vw, 5rem);
        /* Larger font size for mobile */
        padding: 0.2em 0.4em;
    }

    .stats {
        margin-top: 1rem;
        /* Add space above stats */
    }

    .value {
        font-size: clamp(1.8rem, 6vw, 3rem);
    }

    .possession-arrow {
        font-size: clamp(1rem, 2.5vw, 2rem);
    }

    .team.home .possession-arrow {
        right: -1.5rem;
    }

    .team.away .possession-arrow {
        left: -1.5rem;
    }

    .modal-content {
        margin: 5% auto;
        /* Less top margin for modal */
        width: 95%;
    }
}

@media (max-width: 480px) {

    /* Further adjustments for very small screens if needed */
    .score {
        font-size: clamp(4.5rem, 18vw, 8rem);
        margin-bottom: 1rem;
    }

    .game-clock {
        font-size: clamp(4rem, 16vw, 7rem);
    }

    .shot-clock {
        font-size: clamp(3.5rem, 14vw, 6rem);
    }

    .quarter-display {
        font-size: clamp(2.5rem, 10vw, 4rem);
    }

    .team-name {
        font-size: clamp(1.2rem, 4vw, 2rem);
    }

    .value {
        font-size: clamp(1.2rem, 4vw, 2rem);
    }

    .label {
        font-size: clamp(0.5rem, 1.5vw, 0.7rem);
    }
}