:root {
    --background-dark: #121822;
    --primary-accent: #00AFFF;
    --secondary-accent: #00E676;
    --text-light: #F0F0F0;
    --text-dark: #1a1a1a;
    --ui-surface: #1F2937;
    --ui-border: #4B5563;
    --danger-color: #EF4444;
}

body {
    background-color: var(--background-dark);
    color: var(--text-light);
    font-family: 'Montserrat', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    font-size: 14px;
}

#game-container {
    display: none; /* Initially hidden */
    flex-direction: column;
    align-items: center;
    gap: 15px;
    background: var(--ui-surface);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid var(--ui-border);
    width: 95vw;
    max-width: 1100px;
}

#canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 1000px; /* Match canvas width */
    aspect-ratio: 2 / 1;
    border-radius: 8px;
    overflow: hidden;
    background-color: #5C8D4D; /* Base field color */
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5);
}

#gameCanvas {
    width: 100%;
    height: 100%;
}

.message-box {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 15px;
    border-radius: 5px;
    font-weight: bold;
    z-index: 10;
}

#gameEventOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3em;
    font-weight: bold;
    text-align: center;
    white-space: pre-wrap;
    z-index: 50;
    transition: opacity 0.5s ease-in-out;
}

/* --- Coach's Corner --- */
.coach-corner {
    background-color: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    width: 100%;
    max-width: 1000px;
}

.coach-title {
    margin: 0 0 15px 0;
    color: var(--primary-accent);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
}

.llm-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.llm-button {
    background: linear-gradient(145deg, var(--primary-accent), #0077B6);
    color: white;
    border: none;
    padding: 12px 20px;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 175, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.llm-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 175, 255, 0.3);
}
.llm-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(0, 175, 255, 0.2);
}
.llm-button:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
    box-shadow: none;
}
.llm-button.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Modals and Overlays --- */
.hidden {
    display: none !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: var(--ui-surface);
    padding: 30px 40px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid var(--ui-border);
    text-align: center;
    max-width: 90vw;
    width: 500px;
    position: relative;
}

.modal-content h2 {
    color: var(--primary-accent);
    margin-top: 0;
    margin-bottom: 25px;
}

/* --- Main Menu --- */
#mainMenu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--background-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    flex-direction: column;
}

.main-menu-title {
    font-size: 3em;
    color: var(--primary-accent);
    text-shadow: 0 0 15px var(--primary-accent);
    margin-bottom: 40px;
}

.main-menu-buttons, .game-mode-buttons, .pause-menu-buttons, .pat-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 250px;
    margin: 0 auto;
}

/* --- Tutorial --- */
.tutorial-controls {
    text-align: left;
    margin-bottom: 25px;
}
.tutorial-controls p {
    margin: 10px 0;
    background-color: rgba(0,0,0,0.2);
    padding: 8px;
    border-radius: 6px;
}
.tutorial-controls strong {
    color: var(--secondary-accent);
    width: 100px;
    display: inline-block;
}

/* --- Playbook --- */
.playbook-content {
    width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}
.close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: var(--ui-border);
    transition: color 0.2s;
}
.close-button:hover {
    color: var(--text-light);
}

#playbookList {
    list-style: none;
    padding: 0;
    text-align: left;
}
#playbookList li {
    background-color: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 4px solid var(--primary-accent);
}
#playbookList h4 {
    margin: 0 0 8px 0;
    color: var(--secondary-accent);
}
#playbookList p {
    margin: 0;
    line-height: 1.6;
}

/* Play Selection */
.play-selection-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(31, 41, 55, 0.95);
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
}

#play-selection-formation-name {
    margin: 0 0 10px 0;
    color: var(--primary-accent);
    font-weight: bold;
    text-align: center;
}

#play-selection-list {
    display: flex;
    gap: 10px;
}

.play-selection-item {
    background-color: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
    width: 150px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.play-selection-item:hover {
    background-color: var(--primary-accent);
}

.play-icon {
    width: 40px;
    height: 40px;
    background-color: rgba(255,255,255,0.1);
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.play-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-light);
    stroke-width: 2;
    fill: none;
}
.play-selection-item-name {
    font-weight: bold;
}
.play-selection-item-type {
    font-size: 0.8em;
    color: #ccc;
}

/* Team Selection */
.team-selection-content {
    width: 800px;
    max-height: 85vh; /* Set max height to allow scrolling */
    overflow-y: auto; /* Enable vertical scrollbar when content overflows */
}
.team-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.team-card {
    background: var(--background-dark);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    border: 1px solid var(--ui-border);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}
.team-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 175, 255, 0.2);
    border-color: var(--primary-accent);
}
.team-card-colors {
    display: flex;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}
.team-card-color {
    flex: 1;
}
.team-card-name {
    margin: 0 0 5px 0;
    font-size: 1.1em;
}
.team-card-city {
    margin: 0 0 12px 0;
    font-size: 0.9em;
    color: #ccc;
    flex-grow: 1;
}
.view-roster-btn {
    background: var(--ui-border);
    color: var(--text-light);
    border: none;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.view-roster-btn:hover {
    background-color: var(--primary-accent);
}


/* Roster Modal */
.roster-content {
    width: 700px;
    max-width: 90vw;
}

.roster-table-container {
    max-height: 65vh;
    overflow-y: auto;
    margin-top: 15px;
}

.roster-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.roster-table th, .roster-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--ui-border);
}
.roster-table th {
    background-color: var(--background-dark);
    color: var(--primary-accent);
    position: sticky;
    top: 0;
}
.roster-table td:first-child {
    font-weight: bold;
}
.roster-table td:not(:first-child) {
    text-align: center;
}
.roster-table tbody tr:hover {
    background-color: rgba(0, 175, 255, 0.1);
}

/* Season Hub */
.season-hub-content {
    width: 90vw;
    max-width: 900px;
    text-align: left;
    max-height: 85vh; /* Set max height to allow scrolling */
    overflow-y: auto; /* Enable vertical scrollbar when content overflows */
}
#season-hub-header {
    text-align: center;
    margin-bottom: 25px;
}
.season-hub-main {
    display: flex;
    gap: 30px;
}
.season-hub-left {
    flex: 2;
}
.season-hub-right {
    flex: 3;
    border-left: 1px solid var(--ui-border);
    padding-left: 30px;
}
.season-hub-left h3, .season-hub-right h3 {
    color: var(--secondary-accent);
    border-bottom: 1px solid var(--ui-border);
    padding-bottom: 8px;
    margin-top: 0;
    margin-bottom: 15px;
}
.next-game-card {
    background: var(--background-dark);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid var(--ui-border);
}
.next-game-matchup {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 10px;
}
.next-game-team {
    display: flex;
    align-items: center;
    gap: 10px;
}
.team-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #fff;
}
.next-game-vs {
    margin: 0 20px;
    color: var(--ui-border);
}
.next-game-location {
    font-size: 0.9em;
    color: #ccc;
}
#playNextGameBtn {
    width: 100%;
    margin-bottom: 25px;
}

.weekly-schedule-list .game-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background-color: rgba(0,0,0,0.2);
    border-radius: 6px;
    margin-bottom: 8px;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
}
.standings-table th, .standings-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--ui-border);
}
.standings-table th {
    font-weight: bold;
    color: var(--primary-accent);
}
.standings-table tbody tr:hover {
    background-color: rgba(255,255,255,0.05);
}
.standings-table .user-team-row {
    background-color: rgba(0, 175, 255, 0.1);
    font-weight: bold;
}
.standings-table td:not(:first-child) {
    text-align: center;
}

/* Custom scrollbar for modals */
.season-hub-content::-webkit-scrollbar,
.team-selection-content::-webkit-scrollbar,
.roster-table-container::-webkit-scrollbar {
    width: 10px;
}

.season-hub-content::-webkit-scrollbar-track,
.team-selection-content::-webkit-scrollbar-track,
.roster-table-container::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
    border-radius: 5px;
}

.season-hub-content::-webkit-scrollbar-thumb,
.team-selection-content::-webkit-scrollbar-thumb,
.roster-table-container::-webkit-scrollbar-thumb {
    background-color: var(--ui-border);
    border-radius: 5px;
}

.season-hub-content::-webkit-scrollbar-thumb:hover,
.team-selection-content::-webkit-scrollbar-thumb:hover,
.roster-table-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--primary-accent);
}