/* =================================================================================
   SECTION 1: ROOT & GLOBAL STYLES
================================================================================= */
:root {
    /* Fonts */
    --font-sans: 'Roboto', sans-serif;
    --font-header: 'Oswald', sans-serif;
    --font-mono: 'Roboto Mono', monospace;

    /* Colors */
    --bg-color: #F4F7F6;
    --panel-bg: #FFFFFF;
    --border-color: #DDE1E3;
    --text-primary: #1A1A1A;
    --text-secondary: #5C5C5C;
    --text-light: #9A9A9A;

    --color-home: #004A99;
    --color-away: #D50032;
    --color-accent: #FFC72C; /* A neutral accent for buttons etc */

    --star-color: #E6A800;
}

/* FIX 1: Set base font size to 12px (75% of 16px).
  This scales all `rem` units down globally.
*/
html {
    font-size: 12px;
    height: 100%;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    /* MODIFIED: Disable text selection globally */
    user-select: none;
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE10+/Edge */
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100%;
    padding: 1.25rem;
}

/* =================================================================================
   SECTION 2: LAYOUT & PANELS
================================================================================= */
.console-grid {
    display: grid;
    grid-template-columns: minmax(210px, 240px) minmax(375px, 525px) minmax(210px, 240px);
    gap: 1.25rem;
    width: 100%;
    max-width: 1020px; 
    justify-content: center; 
    margin-left: auto;   /* <-- ADD THIS */
    margin-right: auto;  /* <-- ADD THIS */
}

.console-column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0; /* Prevents flex/grid items from overflowing */
}

.center-column {
    max-width: 100%; /* Ensure it doesn't overflow grid cell */
}

.panel {
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    position: relative;
}

.panel-header {
    padding: 1rem 1.25rem;
    font-family: var(--font-header);
    font-size: 1.15rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center; /* MODIFICATION: Center all headers */
    position: relative; /* MODIFICATION: For absolute close button */
}

.panel-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Responsive Layout */

/* FIX 1: Scaled breakpoint by 75% (was 992px) */
@media (max-width: 900px) {
    .console-grid {
        /* This breakpoint is good. It stacks the center column. */
        grid-template-columns: 1fr 1fr;
        max-width: 100%;
    }
    .center-column {
        grid-column: 1 / -1;
        order: 1;
        /* min-width: 0 is still needed here for flex/grid children */
        min-width: 0; 
    }
    .left-column { order: 2; }
    .right-column { order: 3; }
}

@media (max-width: 450px) {
    body { padding: 0.5rem; }
    .console-grid {
        /* This breakpoint is also good. It stacks all columns. */
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .panel-content { padding: 1rem; }
    .panel-header { padding: 0.75rem 1rem; }
    .center-column {
         /* The order properties from 744px will carry over */
         min-width: 0;
     }

    .scoreboard-score {
        font-size: 2.5rem !important;
    }

}

/* =================================================================================
   SECTION 3: SCOREBOARD & BOX SCORE (CENTER)
================================================================================= */

.combined-scoreboard-panel {
    padding: 0;
}

/* Rebuilt scoreboard styles for new HTML structure */
.scoreboard-main {
    display: grid; 

    grid-template-columns: minmax(0, 1fr) auto auto auto minmax(0, 1fr); 
    align-items: center;
    padding: 1.25rem 1.5rem;
    gap: 1rem; 
}

.scoreboard-name {
    font-family: var(--font-header);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%; 
}
#scoreboard-home-name {
    text-align: left;
    color: var(--color-home);
}
#scoreboard-away-name {
    text-align: right;
    color: var(--color-away);
}

.scoreboard-score {
    font-family: var(--font-header);
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1.1;
    /* FIX 1: Scaled by 75% (was 90px) */
    min-width: 68px;
    text-align: center;
}

.scoreboard-info {
    text-align: center;
    margin-top: 0; 
    justify-self: center; 
    display: flex; /* NEW */
    flex-direction: column; /* NEW */
    align-items: center; /* NEW */
    gap: 0.5rem; /* NEW */
}
.base-tracker {
    position: relative;
    width: 50px;
    height: 50px;
    margin-top: -0.25rem; /* Pull it a bit closer to the top */
}

.base {
    position: absolute;
    width: 15px;
    height: 15px;
    background-color: var(--border-color);
    transform: rotate(45deg);
    transition: background-color 0.2s ease;
}

.base.active {
    background-color: var(--color-accent); /* Use yellow accent color */
}

.base-2b {
    top: 5px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
}
.base-3b {
    top: 50%;
    left: 5px;
    transform: translateY(-50%) rotate(45deg);
}
.base-1b {
    top: 50%;
    right: 5px;
    transform: translateY(-50%) rotate(45deg);
}
.quarter-display {
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    background-color: var(--bg-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    text-transform: uppercase;
    white-space: nowrap;
    min-width: 105px; 
    text-align: center;
    display: inline-block;
}

.quarter-score-table {
    padding: 0.75rem 1.25rem 1rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-color);
}
.q-score-row {
    display: grid;
    grid-template-columns: 2fr repeat(5, 1fr) 1.2fr;
    text-align: center;
    padding: 0.35rem 0;
    font-family: var(--font-mono);
    font-size: 0.95rem;
}
.q-score-row.header {
    font-family: var(--font-header);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
}
.q-score-row span:first-child {
    text-align: left;
    font-weight: 700;
    font-family: var(--font-header);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.q-score-row span:last-child {
    font-weight: 700;
}
.q-score-row .ot-col {
    display: none;
}
.q-score-row.show-ot .ot-col {
    display: block;
}
#home-q-score-row span:first-child { color: var(--color-home); }
#away-q-score-row span:first-child { color: var(--color-away); }


.box-score-panel {
    flex-grow: 1;
}
.box-score-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 1.25rem 1.25rem;
}

.box-score-row {
    display: grid;
    grid-template-columns: 1fr 120px 1fr;
    text-align: center;
    align-items: center;
}
.box-score-row.header {
    font-family: var(--font-header);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-secondary);
    grid-template-columns: 1fr 120px 1fr;
}

.box-score-row .team-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.box-score-row .team-name:first-child { text-align: left; }
.box-score-row .team-name:last-child { text-align: right; }

/* === Font Improvement for Box Score Acronyms === */
.box-score-row.header .team-name {
    font-family: var(--font-mono);
    font-weight: 700;
}

.box-score-row .stat-name {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.9rem; /* Made slightly larger */
    white-space: nowrap;
    color: var(--text-secondary);
}

/* === Font Improvement for Box Score Numbers === */
.box-score-row span:not(.stat-name) {
    font-family: var(--font-mono);
    font-size: 1.15rem;  /* Was 1.1rem */
    font-weight: 700;    /* Was 500 */
    white-space: nowrap; /* Prevents wrapping */
    overflow: hidden; /* Prevents horizontal overflow */
    text-overflow: ellipsis; /* Adds "..." if too small */
}
.box-score-row span:first-child { text-align: left; }
.box-score-row span:last-child { text-align: right; }

/* === NEW: Box Score Period Toggle === */
.box-score-period-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.period-arrow {
    background: none;
    border: none;
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0 0.25rem;
}
.period-arrow:hover { color: var(--text-primary); }
#box-period-display {
    font-family: var(--font-header); /* 'Oswald' */
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    /* FIX 1: Scaled by 75% (was 60px) */
    width: 45px; 
    text-align: center;
    text-transform: uppercase;
}


/* === Sim Controls Panel === */
.sim-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
}

.sim-speed-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.75rem;
}

.sim-sub-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.btn-sim {
    font-family: var(--font-header);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background-color: var(--color-home);
    color: #FFF;
    transition: all 0.2s ease;
}
.btn-sim:hover:not(:disabled) {
    background-color: #00336A;
}
.btn-sim:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
}

.btn-sim.secondary {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    background-color: var(--panel-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}
.btn-sim.secondary:hover:not(:disabled) {
    background-color: var(--bg-color);
    border-color: var(--text-secondary);
}

.btn-speed {
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--panel-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-speed:hover {
    background: var(--bg-color);
    border-color: var(--text-secondary);
}
.btn-speed.active {
    background: var(--text-primary);
    color: var(--panel-bg);
    border-color: var(--text-primary);
}


/* =================================================================================
   SECTION 4: STRATEGY PANELS (LEFT & RIGHT)
================================================================================= */
.team-logo {
    font-family: var(--font-header);
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 0;
    background-color: var(--bg-color);
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
}
#home-logo { color: var(--color-home); }
#away-logo { color: var(--color-away); }

.team-select {
    font-family: var(--font-header);
    font-size: 1.15rem;
    font-weight: 700;
    text-transform: uppercase;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    cursor: pointer;
    max-width: 100%;
    width: 100%;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}
#home-team-select { color: var(--color-home); }
#away-team-select { color: var(--color-away); }
.team-select:focus { outline: none; }
.team-select:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    opacity: 0.7;
}


.ratings-display {
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.ratings-table {
    margin: 0 auto;
    border-collapse: collapse;
    max-width: 300px;
}
.rating-item .rating-label {
    font-family: var(--font-header);
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-align: left;
    padding: 0.25rem 0;
    padding-right: 1rem;
}
.rating-item .rating-value {
    text-align: left;
    height: 1.2rem;
}
.star-rating {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--star-color);
}
#home-ratings-display .star-rating { color: var(--color-home); }
#away-ratings-display .star-rating { color: var(--color-away); }

.ai-toggle-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}
.ai-toggle-group label {
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.ai-toggle {
    width: 20px;
    height: 20px;
    cursor: pointer;
}
.ai-toggle:disabled + label,
.ai-toggle:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.gameplan-header {
    font-family: var(--font-header);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.05em;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
}


.slider-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.slider-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 700;
}
.slider-label span:not(.slider-value) {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: var(--font-header);
    flex-grow: 1;
}
.slider-value {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1rem;
    background-color: var(--bg-color);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 10px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: var(--bg-color);
    border-radius: 5px;
    outline: none;
    border: 1px solid var(--border-color);
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text-primary);
    border: 2px solid var(--panel-bg);
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--text-primary);
    border: 2px solid var(--panel-bg);
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
    cursor: pointer;
}

/* Active Slider Thumbs */
#home-controls input[type="range"]::-webkit-slider-thumb { background: var(--color-home); }
#home-controls input[type="range"]::-moz-range-thumb { background: var(--color-home); }
#away-controls input[type="range"]::-webkit-slider-thumb { background: var(--color-away); }
#away-controls input[type="range"]::-moz-range-thumb { background: var(--color-away); }

/* Disabled Sliders */
input[type="range"]:disabled::-webkit-slider-thumb {
    background: var(--text-light);
    cursor: not-allowed;
}
input[typeA="range"]:disabled::-moz-range-thumb {
    background: var(--text-light);
    cursor: not-allowed;
}
input[type="range"]:disabled {
    background: var(--border-color);
    opacity: 0.7;
}


.slider-description {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

/* =================================================================================
   SECTION 5: TOOLTIPS
================================================================================= */
.tooltip {
    position: relative;
    display: inline-block;
    z-index: 5;
}

.tooltip > span {
    /* FIX 1: Scaled by 75% (was 16px) */
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--text-light);
    color: var(--panel-bg);
    font-size: 0.75rem;
    font-weight: 700;
    /* FIX 1: Scaled by 75% (was 16px) */
    line-height: 12px;
    text-align: center;
    cursor: help;
    display: block;
}
.slider-label .tooltip {
    order: -1;
    margin-right: 8px;
}
.ai-toggle-group .tooltip {
    margin-right: -4px;
}


.tooltip .tooltip-text {
    visibility: hidden;
    /* FIX 1: Scaled by 75% (was 280px) */
    width: 210px;
    background-color: #1A1A1A;
    color: #FFF;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    border-radius: 6px;
    padding: 0.75rem;

    position: absolute;
    z-index: 10;
    bottom: 125%;
    left: 50%;
    /* FIX 1: Scaled by 75% (was -140px) */
    margin-left: -105px;

    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.tooltip .tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #1A1A1A transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.tooltip-text b {
    color: var(--color-accent);
}

/* =================================================================================
   SECTION 6: MODAL & ROSTER EDITOR
================================================================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-panel {
    width: 100%;
    max-width: 600px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-left: auto;
    margin-right: auto;
}

.modal-panel .panel-content {
    overflow-y: auto;
}

.modal-close {
    font-family: var(--font-sans);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-light);
    background: none;
    border: none;
    cursor: pointer;
    /* margin-left: auto; */ /* MODIFICATION: Removed */
    padding: 0;
    position: absolute; /* MODIFICATION: Pulled from layout */
    right: 1.25rem; /* MODIFICATION: Positioned manually */
    top: 50%; /* MODIFICATION: Center vertically */
    transform: translateY(-50%); /* MODIFICATION: Center vertically */
}
.modal-close:hover {
    color: var(--text-primary);
}

.modal-desc {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.modal-textarea {
    width: 100%;
    /* FIX 1: Scaled by 75% (was 350px) */
    min-height: 263px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    resize: vertical;
}
.modal-textarea:focus {
    outline: none;
    border-color: var(--color-home);
    box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.2);
}

.modal-error {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-away);
    background-color: rgba(213, 0, 50, 0.05);
    border: 1px solid rgba(213, 0, 50, 0.2);
    padding: 0.75rem;
    border-radius: 6px;
}

/* =================================================================================
   SECTION 7: PLAY-BY-PLAY PANEL
================================================================================= */

.pbp-panel .panel-content {
    /* FIX 1: Scaled by 75% (was 250px) */
    height: 225px;
    overflow-y: scroll;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
}

.pbp-entry {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-secondary);
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border-color);
}

.pbp-panel .panel-content:first-child {
    padding-bottom: 0;
    border-bottom: none;
}

.pbp-entry.score {
    font-weight: 700;
    color: var(--text-primary);
}

.pbp-entry.home {
    border-left: 3px solid var(--color-home);
    padding-left: 0.5rem;
}

.pbp-entry.away {
    border-left: 3px solid var(--color-away);
    padding-left: 0.5rem;
}

.pbp-entry.system {
    font-weight: 700;
    font-style: italic;
    text-align: center;
    color: var(--text-primary);
    border: none;
    padding-left: 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border-color);
}
/* =================================================================================
   SECTION 8: CHALLENGE MODE & MENU SCREENS
================================================================================= */

/* Challenge setup screen styles */
.challenge-step {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.challenge-step-header {
    font-family: var(--font-header);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.challenge-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1rem 0;
}

.challenge-input-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default to 1 column */
    gap: 0.75rem;
}

/* FIX 1: Scaled breakpoint by 75% (was 680px) */
@media (min-width: 510px) {
    .challenge-input-grid {
        /* This component-level media query is good practice. */
        grid-template-columns: 1fr 1fr;
    }
}


.challenge-input-group {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: center;
}
.challenge-input-group label {
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.challenge-team-name-input {
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: all 0.2s ease;
}
.challenge-team-name-input:focus {
    outline: none;
    border-color: var(--color-home);
    box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.2);
}
#challenge-team-abbr {
    text-transform: uppercase;
}
#challenge-team-abbr::placeholder {
    text-transform: none;
}


.challenge-stars-display {
    text-align: center;
    font-size: 1.2rem;
    font-family: var(--font-header);
    font-weight: 500;
    margin-top: 1rem;
}

#challenge-builder-sliders {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* FIX 1: Scaled breakpoint by 75% (was 680px) */
@media (min-width: 510px) {
    #challenge-builder-sliders {
        /* This component-level media query is good practice. */
        grid-template-columns: 1fr 1fr;
    }
}


/* Roadmap grid */
#roadmap-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 6px;
    background-color: var(--bg-color);
    /* FIX 1: Scaled by 75% (was 400px) */
    max-height: 300px;
    overflow-y: auto;
}

/* FIX 1: Scaled breakpoint by 75% (was 600px) */
@media (max-width: 450px) {
    #roadmap-grid {
        /* This component-level media query is good practice. */
        grid-template-columns: 1fr;
    }
}

.roadmap-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: var(--panel-bg);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    opacity: 0.6;
    transition: all 0.2s ease;
    flex-wrap: wrap;
}

.roadmap-logo {
    font-family: var(--font-header);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 40px;
    flex-shrink: 0;
    text-align: center;
}

.roadmap-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    flex-grow: 1;
}

.roadmap-item.beaten {
    opacity: 1;
    background-color: var(--bg-color);
}
.roadmap-item.beaten .roadmap-name {
    text-decoration: line-through;
    color: var(--text-light);
}
.roadmap-item.beaten .roadmap-logo {
    color: var(--text-light);
}

.roadmap-item.next {
    opacity: 1;
    border-color: var(--color-home);
    box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.2);
}
.roadmap-item.next .roadmap-name {
    font-weight: 700;
    color: var(--text-primary);
}
.roadmap-item.next .roadmap-logo {
    color: var(--color-home);
}

.roadmap-score {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-left: auto;
}

.roadmap-score.win {
    background-color: var(--color-home);
    color: white;
}

.roadmap-item.lost {
    opacity: 1;
    background-color: rgba(213, 0, 50, 0.05); /* Faint red */
    border-color: var(--color-away);
}
.roadmap-item.lost .roadmap-name {
    font-weight: 700;
    color: var(--color-away);
}
.roadmap-item.lost .roadmap-logo {
    color: var(--color-away);
}

.roadmap-score.loss {
    background-color: var(--color-away);
    color: white;
}

#btn-roadmap-next-game:disabled {
    background-color: var(--text-light);
    border-color: var(--border-color);
    cursor: not-allowed;
}

/* Star Rating Styles for Challenge Setup */
.challenge-rating-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-color);
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}
.challenge-rating-label {
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.challenge-stars-container {
    display: flex;
    gap: 0.25rem;
}
.challenge-stars-container .star {
    font-size: 2rem;
    color: var(--border-color);
    cursor: pointer;
    transition: all 0.1s ease;
}
.challenge-stars-container .star:hover {
    color: var(--star-color);
    opacity: 0.7;
}
.challenge-stars-container .star.active {
    color: var(--star-color);
    opacity: 1;
}

/* =================================================================================
   SECTION 9: WIN PROBABILITY CHART
================================================================================= */

.wp-panel-content {
    padding: 1rem 1rem;
}

.wp-chart-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem; /* MODIFICATION: Increased gap */
    width: 100%;
}

#wp-chart {
    display: block;
    height: 75pt;
    max-width: 300px;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    flex: 1 1 auto; /* MODIFICATION: Allow canvas to flex */
    min-width: 0; /* MODIFICATION: Allow canvas to shrink */
}

.wp-label {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    min-width: 50px;
    flex: 0 0 50px; /* MODIFICATION: Constrain label width */
}

.wp-label.home { color: var(--color-home); }
.wp-label.away { color: var(--color-away); }

/* =================================================================================
   SECTION 10: USER-SELECT FIX
================================================================================= */

/* Re-enable text selection for textareas */
textarea {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

textarea,
input[type="text"] {
    user-select: text;
    -webkit-user-select: text; /* Safari */
    -moz-user-select: text; /* Firefox */
    -ms-user-select: text; /* IE10+/Edge */
}

/* =================================================================================
   SECTION 11: DRAFT MODE
================================================================================= */

#draft-player-choices {
    display: grid;
    /* FIX 1: Scaled by 75% (was 250px) */
    grid-template-columns: repeat(auto-fit, minmax(188px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.draft-player-card {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.draft-player-card:hover {
    border-color: var(--color-home);
    box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.2);
    transform: translateY(-2px);
}

.draft-card-name {
    font-family: var(--font-header);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.draft-card-pos {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.75rem;
}

.draft-card-ratings {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.draft-card-ratings li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.draft-card-ratings li span:first-child {
    color: var(--text-secondary);
    font-weight: 700;
}

.draft-card-ratings .star-rating {
    font-size: 1.1rem; /* Make stars in cards slightly smaller */
    color: var(--star-color);
}


/* =================================================================================
   SECTION 12: ROSTER SUMMARY
================================================================================= */
.roster-summary-header {
    font-family: var(--font-header);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-home);
    text-transform: uppercase;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 0.5rem;
}
.roster-summary-header:first-of-type {
    margin-top: 0;
}

.roster-summary-list {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.roster-summary-list li {
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 500;
    background-color: var(--bg-color);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}
.roster-summary-list li span {
    font-family: var(--font-header);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

/* Add to style.css */
.roster-adjustment-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.roster-column h4 {
    font-family: var(--font-header);
    text-align: center;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

.roster-adjust-list {
    list-style: none;
    padding: 0.75rem;
    margin: 0;
    background-color: var(--bg-color);
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    /* FIX 1: Scaled by 75% (was 200px) */
    min-height: 150px; /* Ensure drop zone is always visible */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.roster-player-item {
    background-color: var(--panel-bg);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1rem;
    border-radius: 4px;
    cursor: grab;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.roster-player-item:active {
    cursor: grabbing;
    opacity: 0.7;
}
.roster-player-item span { /* Style for Position */
    font-family: var(--font-header);
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
    background: var(--bg-color);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

/* Drag feedback */
.roster-adjust-list.drag-over {
    border-color: var(--color-home);
    background-color: #e8f0fe; /* Light blue */
}
.roster-player-item.dragging {
    opacity: 0.5;
    border-style: dashed;
}

/* This is the visual indicator for where the item will be dropped */
.roster-player-item.drag-over-indicator {
    border-top: 3px solid var(--color-home);
}

@media (max-width: 450px) {
    .roster-adjustment-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 400px) {
    
    .scoreboard-main {
    display: grid; 
    grid-template-columns: auto auto auto auto auto; 
    align-items: center;
    padding: 1rem 1rem;
    }

    .scoreboard-score {
        min-width: 0;
    }

    .quarter-display {
        font-size: 80%;
        min-width: 50pt;
    }

    .box-score-tab {
    padding: 0rem 0rem;
    font-size: 80% !important; 
    }
}
/* =================================================================================
   SECTION 13: ENHANCED ROSTER MODAL
================================================================================= */

#roster-modal .modal-panel {
    max-width: 900px;
}

.modal-content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    width: 100%;
}

.modal-editor-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-editor-header {
    font-family: var(--font-header);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: center;
}

#roster-modal .modal-textarea {
    min-height: 400px; /* Give more space */
    flex-grow: 1;
}

@media (max-width: 768px) {
    .modal-content-grid {
        grid-template-columns: 1fr;
    }
    #roster-modal .modal-textarea {
        min-height: 180px;
    }
}

/*FOOTBALL EXTRA*/

.down-distance-display {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
    margin-bottom: 0; /* CHANGED from 0.25rem */
    min-height: 1.2em; /* Prevents layout jump when text is empty */
}

@media (max-width: 400px) {
    .down-distance-display {
        font-size: 70%;
    }
}

@media (max-width: 600px) {
    .down-distance-display {
        font-size: 80%;
    }
}

/* [ADD] to the end of style.css SECTION 3 */
.box-score-row .stat-name.indented {
    padding-left: 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.box-score-row.divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
    padding: 0;
}

.baseball-scoreboard .q-score-row {
    /* This grid was for 9 innings + OT. Now it's just 3 summary columns. */
    grid-template-columns: 2fr repeat(3, 1.2fr);
}

/* This makes sure the R, H, and E columns are bolded, not just the last one */
.q-score-row .final-col {
    font-weight: 700;
}

/* =================================================================================
   SECTION 14: PLAYER BOX SCORE MODAL
================================================================================= */

/* Sub-header text on team box score */
.header-sub-action {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--color-home);
    text-transform: none;
    letter-spacing: 0;
    margin-left: 0.75rem;
    opacity: 0.8;
}
#btn-open-player-box:hover .header-sub-action {
    opacity: 1;
    text-decoration: underline;
}

/* Tab navigation for the modal */
.box-score-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
}

.box-score-tab {
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    margin-bottom: -2px; /* Pulls tab bottom border over the container border */
    transition: all 0.2s ease;
}
.box-score-tab:hover {
    color: var(--text-primary);
}
.box-score-tab.active {
    color: var(--color-home);
    border-bottom-color: var(--color-home);
}
#box-tab-away-batting.active,
#box-tab-away-bowling.active {
    color: var(--color-away);
    border-bottom-color: var(--color-away);
}


/* Tab content panels */
.player-box-content {
    display: none;
}
.player-box-content.active {
    display: block;
}

/* Table styles */
.player-box-table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-color);
}

.player-box-table {
    width: 100%;
    border-collapse: collapse;
}

.player-box-table thead tr {
    border-bottom: 2px solid var(--border-color);
    background-color: var(--panel-bg);
}

.player-box-table th {
    padding: 0.75rem 0.5rem;
    text-align: right;
    font-family: var(--font-header);
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.player-box-table td {
    padding: 0.6rem 0.5rem;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    background-color: var(--panel-bg);
}

.player-box-table tbody tr:last-child td {
    border-bottom: none;
}

/* Totals Row */
.player-box-table tbody tr.totals-row td {
    font-family: var(--font-header);
    font-weight: 700;
    background-color: var(--bg-color);
    color: var(--text-primary);
    border-top: 2px solid var(--border-color);
}

/* Special columns for player names */
.player-box-table .name-col {
    text-align: left;
    font-family: var(--font-sans);
    font-weight: 700;
    /* width: 40%; */ /* This rule is removed */
    min-width: 150px;
}
.player-box-table .name-col span {
    font-family: var(--font-header);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.player-box-table td.name-col {
    font-family: var(--font-sans);
    font-weight: 700;
}

/* Make team totals name-col bold */
.player-box-table tr.totals-row .name-col {
    font-family: var(--font-header);
    font-size: 1rem;
    text-transform: uppercase;
}
/* =================================================================================
   SECTION 15: VISUAL TEAM COMPARISON (Stat Bars)
================================================================================= */

.stat-bar {
    height: 100%;
    width: 0%; /* Default width */
    transition: width 0.4s ease-out;
}

/* Home team bars (left side) */
.box-score-row .stat-bar-container:first-of-type {
    direction: rtl; /* Makes bar fill from right-to-left */
}
.stat-bar.home {
    background-color: var(--color-home);
}
/* For lower-is-better, we want the "good" bar (less) to be green */
.stat-bar.home.lower-is-better {
    background-color: #008a00; /* Green */
}
.stat-bar.home.lower-is-better.losing { /* 'losing' class added by JS */
    background-color: var(--color-home); /* Back to team color if they are worse */
}


/* Away team bars (right side) */
.box-score-row .stat-bar-container:last-of-type {
    direction: ltr; /* Makes bar fill from left-to-right */
}
.stat-bar.away {
    background-color: var(--color-away);
}
.stat-bar.away.lower-is-better {
    background-color: #008a00; /* Green */
}
.stat-bar.away.lower-is-better.losing {
    background-color: var(--color-away);
}

.box-score-divider {
    grid-column: 1 / -1; /* Span all columns */
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    text-align: center;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin: 0.75rem 0 0.25rem 0;
}

/* The new single-row container for a stat with bars */
.box-score-row.comparison-row {
    align-items: center;
}

/* The new left/right cell that holds the value and the bar */
.comparison-stat-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* Space between value and bar */
}

/* Home (left) cell: [Value] [Bar] */
.comparison-stat-cell.home {
    justify-content: flex-start;
}

/* Away (right) cell: [Bar] [Value] */
.comparison-stat-cell.away {
    justify-content: flex-end;
}

/* Give the stat value (the number) a fixed width so all bars align */
.comparison-stat-cell span {
    flex: 0 0 30px; /* 30px wide, no grow, no shrink */
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
}
.comparison-stat-cell.home span {
    text-align: left;
}
.comparison-stat-cell.away span {
    text-align: right;
}

/* New style for the bar container */
.comparison-row .stat-bar-container {
    flex-grow: 1; /* Bar takes up all remaining space in the cell */
    height: 10px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    overflow: hidden;
    min-width: 50px; /* Ensures bar is visible even if cell is small */
}

/* Set the fill direction for home (left-side) bars */
.comparison-stat-cell.home .stat-bar-container {
    direction: rtl; /* Makes bar fill from right-to-left */
}

/* Set the fill direction for away (right-side) bars */
.comparison-stat-cell.away .stat-bar-container {
    direction: ltr; /* Makes bar fill from left-to-right */
}

/* =================================================================================
   SECTION 16: BULLPEN CONTROLS
================================================================================= */
.bullpen-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.btn-bullpen {
    font-family: var(--font-header);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--panel-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.btn-bullpen:hover:not(:disabled) {
    background: var(--bg-color);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* Stamina Span */
.btn-bullpen span {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: none;
}

/* Active/Disabled State */
.btn-bullpen:disabled,
.btn-bullpen.active {
    cursor: not-allowed;
    opacity: 1;
}

/* Team-specific active colors (solid fill) */
#home-controls .btn-bullpen.active {
    background-color: var(--color-home);
    border-color: var(--color-home);
    color: #FFF;
}
#away-controls .btn-bullpen.active {
    background-color: var(--color-away);
    border-color: var(--color-away);
    color: #FFF;
}
.btn-bullpen.active span {
    color: #FFF;
}

/* === NEW: Cricket-specific "Pending" state === */
#home-controls .btn-bullpen.pending {
    background-color: #e8f0fe; /* Light home color */
    border-color: var(--color-home);
    color: var(--color-home);
    box-shadow: 0 0 0 3px rgba(0, 74, 153, 0.2);
}
#away-controls .btn-bullpen.pending {
    background-color: #fbe6eb; /* Light away color */
    border-color: var(--color-away);
    color: var(--color-away);
    box-shadow: 0 0 0 3px rgba(213, 0, 50, 0.2);
}
.btn-bullpen.pending span {
    color: inherit;
}