:root {
    --bg-color: #1a1a1a;
    --panel-bg: #252525;
    --text-main: #e0e0e0;
    --accent-green: #4caf50;
    --accent-dirt: #8d6e63;
    --accent-white: #ffffff;
    --border-color: #444;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Roboto Condensed', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: 'Teko', sans-serif;
    letter-spacing: 1px;
}

.app-container,
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* HEADER */
.main-header {
    height: 60px;
    background: #0f0f0f;
    border-bottom: 2px solid var(--accent-green);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.game-title {
    color: var(--accent-green);
    font-size: 2rem;
}

.header-status {
    font-size: 1.2rem;
    color: #aaa;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.league-content {
    overflow-y: auto;
    max-height: calc(100vh - 140px);
}

.league-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.league-left,
.league-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.header-nav {
    flex-wrap: wrap;
}

.nav-btn {
    background: transparent;
    border: 1px solid #444;
    color: #888;
    padding: 5px 15px;
    cursor: pointer;
    font-family: 'Teko', sans-serif;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.nav-btn:hover {
    border-color: var(--accent-green);
    color: var(--accent-white);
}

.nav-btn.active {
    background: var(--accent-green);
    color: white;
    border-color: var(--accent-green);
}

#view-mode-display,
#forty-man-indicator,
#waiver-indicator,
#transactions-indicator {
    background: #1f1f1f;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.95rem;
    color: #d0d0d0;
}

.nav-btn:disabled,
.cyber-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #444;
    color: #666;
}

/* MAIN CONTENT GRID */
/* DEFAULT (MATCH MODE) */
.main-content {
    flex: 1;
    display: grid;
    /* Default: Stadium takes focus, others hidden primarily or sidebars? 
       Let's stick to the plan: layout changes based on class.
       Default might be Match Mode or Team Mode. Let's define specific classes.
    */
    display: grid;
    /* Default: League Mode */
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    /* Robust fix for scrolling */
    margin: 10px;
    gap: 10px;
    height: calc(100vh - 70px);
    /* Explicit height minus header */
    overflow: hidden;
    min-height: 0;
}

/* LEAGUE MODE: Dashboard (Dugout | League | Roster) */
.main-content.league-mode {
    grid-template-columns: 320px 1fr 550px;
    align-items: stretch;
}

.main-content.league-mode .dugout-panel {
    grid-column: 1;
}

.main-content.league-mode .league-panel {
    grid-column: 2;
}

.main-content.league-mode .roster-panel {
    grid-column: 3;
}

.main-content.league-mode .dugout-panel,
.main-content.league-mode .league-panel,
.main-content.league-mode .roster-panel {
    display: flex;
}

.main-content.league-mode .home-panel {
    display: none;
}
.main-content.league-mode .stadium-panel {
    display: none;
}

.main-content.league-mode #bullpen-container {
    display: none;
}

.main-content.league-mode .bench-panel {
    display: none;
}

/* HOME MODE */
.main-content.home-mode {
    grid-template-columns: 1fr;
}

.main-content.home-mode .home-panel {
    display: flex;
}

.main-content.home-mode .dugout-panel,
.main-content.home-mode .stadium-panel,
.main-content.home-mode .league-panel,
.main-content.home-mode .roster-panel {
    display: none;
}


/* TEAM MODE: Dugout + Roster */
.main-content.team-mode {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.main-content.team-mode .dugout-panel,
.main-content.team-mode .roster-panel {
    display: flex;
}

.main-content.team-mode .stadium-panel,
.main-content.team-mode .league-panel {
    display: none;
}

.main-content.team-mode .home-panel {
    display: none;
}
.main-content.team-mode .dugout-panel {
    grid-column: 1 / span 3;
}

.main-content.team-mode .roster-panel {
    grid-column: 4 / span 1;
}

.main-content.team-mode .dugout-columns {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 10px;
    min-height: 0;
}

.main-content.team-mode .dugout-section {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: var(--panel-bg);
    overflow: hidden;
}

.main-content.team-mode .pitching-section,
.main-content.team-mode .rankings-section {
    border-top: none;
    border-bottom: none;
    max-height: none;
}

/* ROSTER/MARKET MODE: Roster panel full width */
.main-content.roster-mode {
    grid-template-columns: 1fr;
}

.main-content.roster-mode .roster-panel {
    display: flex;
}

.main-content.roster-mode .dugout-panel,
.main-content.roster-mode .stadium-panel,
.main-content.roster-mode .league-panel {
    display: none;
}

.main-content.roster-mode .home-panel {
    display: none;
}
/* MARKET MODE */
.main-content.market-mode {
    grid-template-columns: 1fr;
}

.main-content.market-mode .roster-panel {
    display: flex;
}

.main-content.market-mode .dugout-panel,
.main-content.market-mode .stadium-panel,
.main-content.market-mode .league-panel,
.main-content.market-mode .home-panel {
    display: none;
}

.home-panel {
    display: none;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
}

.home-hero {
    background: linear-gradient(135deg, #2a2a2a, #1f2b1f);
    border: 1px solid #333;
    border-radius: 10px;
    padding: 24px;
    text-align: left;
}

.home-title {
    font-family: 'Teko', sans-serif;
    font-size: 3rem;
    color: var(--accent-green);
}

.home-subtitle {
    color: #b5b5b5;
    font-size: 1.1rem;
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.home-card {
    border: 1px solid #333;
    border-radius: 8px;
    background: #1d1d1d;
    overflow: hidden;
}

.home-summary {
    padding: 12px;
    color: #ddd;
    display: grid;
    gap: 6px;
    font-size: 1rem;
}

.home-actions {
    padding: 12px;
    display: grid;
    gap: 8px;
}

.log-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
    background: #1f1f1f;
    border-bottom: 1px solid #333;
}

.log-controls input {
    flex: 1;
    background: #1f1f1f;
    color: #eee;
    border: 1px solid #444;
    padding: 4px 6px;
    font-family: 'Teko', sans-serif;
}

.log-controls .log-label {
    font-size: 0.85rem;
    color: #aaa;
}

.log-controls .log-select {
    background: #1f1f1f;
    color: #eee;
    border: 1px solid #444;
    padding: 4px 6px;
    font-family: 'Teko', sans-serif;
}

.log-filter {
    display: flex;
    gap: 6px;
}

.log-filter .nav-btn {
    font-size: 0.85rem;
    padding: 4px 8px;
}

.schedule-log-card {
    width: min(720px, 92vw);
}

.schedule-log-score {
    padding: 8px 16px;
    font-family: 'Teko', sans-serif;
    font-size: 1.6rem;
    color: var(--accent-green);
}

.schedule-log-linescore {
    padding: 8px 16px;
}

.schedule-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: #ddd;
}

.schedule-log-table th,
.schedule-log-table td {
    border: 1px solid #333;
    padding: 4px 6px;
    text-align: center;
}

.schedule-log-body {
    max-height: 320px;
    overflow-y: auto;
    padding: 12px 16px;
    background: #1a1a1a;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
}

.schedule-log-body::-webkit-scrollbar,
.card-list::-webkit-scrollbar,
#goal-list::-webkit-scrollbar,
#transactions-list::-webkit-scrollbar,
.schedule-list::-webkit-scrollbar,
.game-log::-webkit-scrollbar,
.team-trend-chart::-webkit-scrollbar {
    width: 8px;
}

.schedule-log-body::-webkit-scrollbar-thumb,
.card-list::-webkit-scrollbar-thumb,
#goal-list::-webkit-scrollbar-thumb,
#transactions-list::-webkit-scrollbar-thumb,
.schedule-list::-webkit-scrollbar-thumb,
.game-log::-webkit-scrollbar-thumb,
.team-trend-chart::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 6px;
}

.schedule-log-body::-webkit-scrollbar-track,
.card-list::-webkit-scrollbar-track,
#goal-list::-webkit-scrollbar-track,
#transactions-list::-webkit-scrollbar-track,
.schedule-list::-webkit-scrollbar-track,
.game-log::-webkit-scrollbar-track,
.team-trend-chart::-webkit-scrollbar-track {
    background: #1d1d1d;
}

.schedule-log-body .log-entry {
    margin-bottom: 6px;
}

.roster-multi-controls .subtext {
    margin-right: 6px;
}


/* MATCH MODE: Dugout + Stadium */
.main-content.match-mode {
    grid-template-columns: 360px minmax(0, 1fr);
    align-items: stretch;
}

.main-content.match-mode .dugout-panel,
.main-content.match-mode .stadium-panel {
    display: flex;
}

.main-content.match-mode .roster-panel,
.main-content.match-mode .league-panel {
    display: none;
}

.main-content.match-mode .home-panel {
    display: none;
}

.main-content.match-mode .dugout-panel {
    grid-column: 1;
}

.main-content.match-mode .stadium-panel {
    grid-column: 2;
}

.main-content.match-mode .dugout-columns {
    overflow-y: auto;
}

.main-content.match-mode .pitching-section {
    max-height: 45%;
    overflow-y: auto;
}

.main-content.match-mode .rankings-section {
    display: none;
}

.main-content.stats-mode {
    grid-template-columns: 1fr;
}

.main-content.stats-mode .league-panel {
    display: flex;
}

.main-content.stats-mode .dugout-panel,
.main-content.stats-mode .roster-panel,
.main-content.stats-mode .stadium-panel {
    display: none;
}

.main-content.stats-mode .home-panel {
    display: none;
}

#team-stats-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    padding-right: 6px;
}

.stats-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stats-column {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.player-rank-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.stats-column h2 {
    margin: 0;
}


.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    background: #333;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.roster-panel .panel-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.panel-header h2 {
    font-size: 1.4rem;
}

/* DUGOUT STYLES */
.dugout-panel {
    border-right: 2px solid #333;
    display: flex;
    flex-direction: column;
    /* Critical for layout */
    height: 100%;
    /* Ensure it takes full height of grid cell */
    overflow: hidden;
    /* Manage internal scrolling */
}

.dugout-columns {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.dugout-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.batting-section {
    flex: 1;
}

.pitching-section {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    background: #252525;
}

.rankings-section {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    background: #1f1f1f;
    max-height: 200px;
}

.section-title {
    padding: 8px 12px;
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    color: #cfcfcf;
    background: #1f1f1f;
    border-bottom: 1px solid #333;
}

.batting-order {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    min-height: 0;
    /* Allow Flexbox nested scrolling */
}

.bench-panel {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    background: #262626;
    border-top: 1px solid #333;
    max-height: 170px;
    overflow-y: auto;
    min-height: 0;
}

.bench-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.bench-panel .label {
    font-weight: bold;
    color: var(--accent-green);
}

.bench-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #888;
}

.bench-controls select {
    background: #1f1f1f;
    color: #ddd;
    border: 1px solid #444;
    padding: 2px 6px;
    font-family: 'Teko', sans-serif;
}

.bench-controls .nav-btn {
    padding: 2px 6px;
    font-size: 0.75rem;
}

#bench-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    min-height: 0;
}

.bench-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #222;
    border: 1px solid #333;
    padding: 6px 8px;
    border-radius: 4px;
    font-family: 'Teko', sans-serif;
    color: #e0e0e0;
}

.bench-card.injured {
    border-color: #ff5252;
    box-shadow: 0 0 6px rgba(255, 82, 82, 0.4);
}

.bench-card .bench-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bench-card .bench-pos {
    font-size: 0.85rem;
    color: var(--accent-green);
}

.bench-card .bench-age {
    font-size: 0.75rem;
    color: #888;
}

.bench-card .bench-stats {
    font-size: 0.75rem;
    color: #aaa;
}

.empty-slot {
    background: #333;
    border: 1px dashed #666;
    padding: 12px;
    margin-bottom: 5px;
    color: #888;
    cursor: pointer;
    text-align: center;
}

.pitcher-selection {
    padding: 15px;
    background: #2a2a2a;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    /* Prevent collapsing */
}

.pitcher-selection .label {
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--accent-green);
}

#bullpen-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.bullpen-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #222;
    border: 1px solid #333;
    padding: 6px 8px;
    border-radius: 4px;
}

.bullpen-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bullpen-card .bullpen-name {
    font-family: 'Teko', sans-serif;
    color: #e0e0e0;
    font-size: 1rem;
}

.bullpen-card .bullpen-stamina {
    font-size: 0.75rem;
    color: #aaa;
}

.rotation-slot .player-stamina {
    font-size: 0.7rem;
    color: #9dc3a7;
    margin-left: auto;
}

.bullpen-card select {
    background: #1f1f1f;
    color: #ddd;
    border: 1px solid #444;
    padding: 2px 6px;
    font-family: 'Teko', sans-serif;
}

.action-btn {
    width: 100%;
    padding: 20px;
    background: var(--accent-green);
    border: none;
    color: white;
    font-family: 'Teko', sans-serif;
    font-size: 1.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.action-btn:hover {
    background: #388e3c;
}

.action-btn.secondary {
    background: #202020;
    border: 1px solid #3a3a3a;
    color: #ddd;
    font-size: 1.1rem;
    padding: 12px;
    margin-top: 8px;
}

.action-btn.secondary:hover {
    background: #2b2b2b;
}

/* STADIUM STYLES */
.stadium-panel {
    display: flex;
    flex-direction: column;
    background: #111;
    overflow: hidden; /* Ensure panel itself doesn't cause scrollbars */
}

.stadium-body-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0; /* Critical for flex children to scroll */
}

.stadium-main {
    flex: 2;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Critical for flex children */
}

.stadium-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #111;
    border-left: 1px solid #333;
}

.scoreboard {
    height: 100px;
    background: #000;
    border-bottom: 4px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    font-family: 'Teko', sans-serif;
    color: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.line-score {
    display: flex;
    flex-direction: column;
    background: #0a0a0a;
    border-bottom: 1px solid #222;
    padding: 6px 12px;
    font-family: 'Teko', sans-serif;
    color: #ddd;
}

.line-score-row {
    display: grid;
    grid-template-columns: 140px repeat(9, 1fr) 40px;
    gap: 6px;
    align-items: center;
    font-size: 0.9rem;
}

.line-score-header {
    color: #9a9a9a;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.line-score-cell {
    text-align: center;
    padding: 2px 0;
}

.line-score-cell.team-cell {
    text-align: left;
    padding-left: 4px;
    color: #fff;
}

.line-score-cell.total-cell {
    color: #f5c542;
    font-weight: bold;
}

.sb-team {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 40%;
}

.sb-team.away-team {
    margin-right: auto;
}

.sb-team.home-team {
    margin-left: auto;
    justify-content: flex-end;
}

.sb-name {
    font-size: 1.8rem;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.sb-score {
    font-size: 3.5rem;
    color: #ff3333;
    /* LED Red */
    font-family: 'Courier New', monospace;
    font-weight: bold;
    text-shadow: 0 0 10px #ff3333;
    min-width: 60px;
    text-align: center;
}

.sb-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 20%;
    border-left: 1px solid #333;
    border-right: 1px solid #333;
    height: 80%;
}

.sb-inning {
    font-size: 1.5rem;
    color: yellow;
    font-weight: bold;
}

.sb-outs {
    display: flex;
    gap: 5px;
    margin-top: 5px;
    font-size: 0.8rem;
    color: #888;
}

.sb-outs .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #333;
    border: 1px solid #555;
    display: inline-block;
}

.sb-outs .dot.active {
    background: #f5c542;
    box-shadow: 0 0 6px rgba(245, 197, 66, 0.8);
    border-color: #f5c542;
}

/* FIELD CONTAINER */
.field-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #1e1e1e;
    overflow: hidden;
    position: relative;
}

.diamond-view {
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1 / 1;
    /* Force Square */
    position: relative;
    background:
        radial-gradient(circle at 50% 120%, #2e7d32 20%, transparent 21%),
        /* Infield Grass shape approx */
        linear-gradient(to top, #388e3c 0%, #2e7d32 100%);
    border: 2px solid #555;
    margin: 10px;
    box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
    border-radius: 5px;
}

/* Dirt Circle */
.dirt-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 35%;
    height: 35%;
    background: #8d6e63;
    /* Dirt color */
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

/* Bases Container - Rotated 45deg for Diamond */
.diamond {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 45%;
    height: 45%;
    transform: translate(-50%, -50%) rotate(-45deg);
    /* Box is rotated, so corners are bases */
    /* border: 1px dashed rgba(255,255,255,0.1); */
    /* Debug alignment */
    background: #9a7b65;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.35);
    z-index: 2;
}

.base {
    width: 28px;
    height: 28px;
    background: #f2f2f2;
    position: absolute;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.6);
    transition: background 0.3s;
    border: 2px solid rgba(0, 0, 0, 0.15);
    z-index: 3;
}

.base.active {
    background: yellow;
    box-shadow: 0 0 10px yellow;
}

.home-plate {
    bottom: -12.5px;
    left: -12.5px;
    cursor: default;
    clip-path: polygon(0 0, 50% 100%, 100% 0, 100% 100%, 0 100%);
    border-radius: 0;
    transform: rotate(45deg);
    /* Adjustment for shape if needed, plain box fine for now */
}

/* Actually, let's keep bases simple boxes for now, positioning them at corners of the .diamond box */

.home-plate {
    bottom: -12px;
    left: -12px;
}

.first-base {
    bottom: -12px;
    right: -12px;
}

.second-base {
    top: -12px;
    right: -12px;
}

.third-base {
    top: -12px;
    left: -12px;
}

.match-info {
    padding: 10px;
    text-align: center;
    background: #111;
    border-bottom: 1px solid #333;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.match-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
}

.match-control-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.match-control-row label {
    color: #888;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
}

.match-control-row select {
    background: #222;
    color: #eee;
    border: 1px solid #444;
    padding: 4px 6px;
    font-family: 'Teko', sans-serif;
}

.match-control-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-green);
}

#game-status-text {
    font-size: 1.5rem;
    color: yellow;
    margin-bottom: 5px;
}

#pitcher-stamina {
    color: #bbb;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.matchup-next {
    margin-top: 4px;
    font-size: 0.85rem;
    color: #9a9a9a;
}

.match-summary-title {
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    color: #9fd0a8;
}

.match-summary-score {
    font-size: 1.1rem;
    margin-top: 4px;
    color: #f2f2f2;
}

.match-summary-grid {
    margin-top: 8px;
    display: grid;
    gap: 6px;
}

.match-summary-row {
    display: grid;
    grid-template-columns: 2.2fr repeat(6, 1fr);
    gap: 6px;
    align-items: center;
    font-size: 0.85rem;
    color: #cfcfcf;
}

.match-summary-row.header {
    font-size: 0.7rem;
    color: #7d7d7d;
    letter-spacing: 0.06em;
}

.match-summary-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.match-summary-actions .nav-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.match-summary-card {
    width: min(720px, 92vw);
    background: #161616;
}

.match-summary-card .match-summary-grid {
    margin-top: 12px;
}

.game-log {
    flex: 1;
    background: #000;
    color: #0f0;
    font-family: monospace;
    padding: 10px;
    overflow-y: auto;
    font-size: 0.9rem;
}

.log-entry {
    margin-bottom: 4px;
}

.log-entry.highlight {
    color: #ffd54f;
    font-weight: bold;
}

/* Rotation Slots */
.rotation-slot {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px;
    background: #333;
    margin-bottom: 5px;
    border: 1px solid #444;
    cursor: pointer;
}

.rotation-slot.next-starter {
    border-color: var(--accent-green);
    box-shadow: 0 0 5px var(--accent-green);
    background: #2a3a2a;
}

.rotation-slot .order-num {
    font-weight: bold;
    color: #666;
    margin-right: 10px;
    width: 30px;
}

.rotation-slot.next-starter .order-num {
    color: var(--accent-green);
}


/* ROSTER PANEL (Horizontal Split) */
/* ROSTER PANEL (Horizontal Split) */
.roster-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.roster-nav {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: center;
}

.roster-multi-controls {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    justify-content: center;
}

.roster-panel.multi-mode .roster-nav {
    display: none;
}

.roster-panel.multi-mode .roster-multi-controls {
    display: flex;
}

.roster-content.multi-mode {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
    overflow: hidden;
    padding: 10px;
}

.roster-content.multi-mode .roster-view {
    display: none;
    border: 1px solid #333;
    border-radius: 6px;
    background: #1d1d1d;
}

.roster-content.multi-mode .roster-view.multi-active {
    display: flex;
}

.roster-content.multi-mode .roster-view .section-header {
    border-bottom: 1px solid #333;
}

.roster-view {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.roster-view.active {
    display: flex;
}

.market-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #333;
    background: #1f1f1f;
}

.market-nav .nav-btn,
.roster-nav .nav-btn {
    font-size: 0.95rem;
    padding: 6px 8px;
}

.market-section {
    display: none;
    flex-direction: column;
    min-height: 0;
}

.market-section.active {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.section-header {
    background: #222;
    padding: 5px 10px;
    font-size: 0.9rem;
    color: #888;
    border-bottom: 1px solid #333;
    font-weight: bold;
}

.schedule-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #1f1f1f;
    border-bottom: 1px solid #333;
    color: #aaa;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.schedule-controls select {
    background: #1f1f1f;
    color: #eee;
    border: 1px solid #444;
    padding: 4px 6px;
    font-family: 'Teko', sans-serif;
}

.schedule-list {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
}

.schedule-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid #333;
    border-radius: 4px;
    background: #222;
    font-size: 0.85rem;
}

.schedule-row.player-team {
    border-color: var(--accent-green);
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.3);
}

.schedule-row.clickable {
    cursor: pointer;
}

.schedule-row.clickable:hover {
    border-color: #555;
    background: #262626;
}

.schedule-row .schedule-status {
    color: #9aa0a6;
    font-size: 0.8rem;
}

.schedule-filters {
    margin-left: auto;
    display: flex;
    gap: 6px;
}

.schedule-filters .nav-btn {
    font-size: 0.8rem;
    padding: 4px 8px;
}

#goal-list,
#transactions-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 8px 10px;
}

.stack-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.scouting-section {
    border-top: 1px solid #333;
}

.position-rankings {
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    overflow-y: auto;
}

.position-rank-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid #333;
    border-radius: 4px;
    background: #222;
    font-size: 0.85rem;
    color: #ddd;
}

.position-rank-row .pos-name {
    font-weight: bold;
    color: #cfcfcf;
}

.position-rank-row .pos-rank {
    color: var(--accent-green);
}

.position-rank-row .pos-value {
    color: #aaa;
    min-width: 36px;
    text-align: right;
}

.trade-section {
    border-top: 1px solid #333;
}

.trade-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
}

.trade-controls label {
    font-size: 0.75rem;
    color: #888;
    letter-spacing: 0.04em;
}

.trade-controls select,
.trade-controls input {
    background: #1f1f1f;
    color: #eee;
    border: 1px solid #444;
    padding: 4px 6px;
    font-family: 'Teko', sans-serif;
}

.scouting-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #1f1f1f;
    border-bottom: 1px solid #333;
}

.subtext {
    color: #888;
    font-size: 0.85rem;
}

.options-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #ddd;
    font-size: 0.9rem;
}

.draft-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 10px 0;
}

.postseason-area {
    margin-top: 18px;
    text-align: left;
    border: 1px solid #333;
    background: #1c1c1c;
}

#postseason-bracket {
    padding: 10px;
    display: grid;
    gap: 10px;
}

.postseason-round {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.postseason-series {
    border: 1px solid #3a3a3a;
    background: #222;
    border-radius: 6px;
    padding: 8px;
    font-size: 0.85rem;
    color: #ddd;
}

.postseason-series .series-title {
    font-size: 0.8rem;
    color: #9aa0a6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.postseason-series .series-team {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.postseason-series .series-team span {
    color: #cfcfcf;
}

.card-list {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
    /* Allow Flexbox nested scrolling */
}

.card-list.compact {
    flex: 0 0 180px;
    max-height: 180px;
}

.player-card {
    background: #333;
    border: 1px solid #444;
    padding: 8px;
    border-radius: 4px;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    grid-template-rows: auto auto;
    row-gap: 1px;
    align-items: center;
    min-height: 60px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.player-card.injured,
.lineup-slot.injured,
.rotation-slot.injured {
    border-color: #ff5252;
    box-shadow: 0 0 6px rgba(255, 82, 82, 0.4);
}

.status-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: #3a3a3a;
    color: #ddd;
    margin-left: 6px;
}

.status-badge.injury {
    background: #5a1e1e;
    color: #ffb3b3;
}

.status-badge.fatigue {
    background: #2a2f3f;
    color: #b9c6ff;
}

.player-card:hover {
    background: #444;
    transform: translateX(5px);
    border-color: var(--accent-green);
}

.player-card.pitcher-card {
    border-left: 3px solid var(--accent-dirt);
    border-top: 1px solid #444;
    /* Reset from previous change if needed, effectively just border-left matters */
}

.card-pos {
    grid-column: 1;
    grid-row: 1;
    font-weight: bold;
    color: #888;
}

.card-age {
    grid-column: 1;
    grid-row: 2;
    font-size: 0.8rem;
    color: #777;
}

.card-name {
    grid-column: 2;
    grid-row: 1;
    color: white;
    font-family: 'Teko', sans-serif;
    font-size: 1.12rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-stats {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.75rem;
    color: #aaa;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    max-height: 1.6em;
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: #1f1f1f;
    border: 1px solid #444;
    border-radius: 8px;
    width: 420px;
    max-width: 90vw;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #333;
    padding-bottom: 8px;
}

.modal-header h3 {
    font-family: 'Teko', sans-serif;
    font-size: 1.6rem;
    margin: 0;
    color: var(--accent-green);
}

.modal-close {
    background: none;
    border: none;
    color: #999;
    font-size: 1.6rem;
    cursor: pointer;
}

.modal-close:hover {
    color: white;
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    font-size: 0.95rem;
    color: #ccc;
}

.modal-section {
    grid-column: 1 / -1;
    border-top: 1px solid #333;
    padding-top: 6px;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-section-title {
    color: #777;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.season-line {
    font-size: 0.85rem;
    color: #cfcfcf;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.season-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: #cfcfcf;
}

.season-table th,
.season-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #2a2a2a;
    text-align: left;
}

.season-table th {
    color: #888;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.team-stats-table th,
.team-stats-table td {
    text-align: center;
    white-space: nowrap;
    font-size: 0.75rem;
    padding: 4px 6px;
}

.team-stats-table th:nth-child(2),
.team-stats-table td:nth-child(2) {
    text-align: left;
}

.team-stats-table th[data-sort-key],
.player-rank-table th[data-sort-key] {
    cursor: pointer;
    position: relative;
}

.team-stats-table th[data-sort-key]:hover,
.player-rank-table th[data-sort-key]:hover {
    color: var(--accent-green);
}


.team-trend-card {
    border: 1px solid #333;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 14px;
    background: #1f1f1f;
}

.team-trend-header {
    display: flex;
    justify-content: space-between;
    color: #888;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.team-trend-chart {
    height: 120px;
    background: #141414;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 0.85rem;
}

.player-rank-section {
    margin-top: 10px;
    overflow-x: auto;
}

.player-rank-table th,
.player-rank-table td {
    text-align: center;
    white-space: nowrap;
    font-size: 0.72rem;
    padding: 4px 6px;
}

.player-rank-table th:nth-child(2),
.player-rank-table td:nth-child(2) {
    text-align: left;
}

.team-stats-table,
.player-rank-table {
    table-layout: fixed;
    min-width: 860px;
}

.standings-table-wrapper {
    overflow-x: auto;
}

.recent-games-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.recent-game-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #181818;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.82rem;
    color: #cfcfcf;
}

.recent-game-row .result {
    font-weight: 600;
    color: #9fd0a8;
}

.recent-game-row .result.loss {
    color: #d08f8f;
}

.modal-body .stat-label {
    color: #777;
    font-size: 0.8rem;
    text-transform: uppercase;
}

.modal-body .stat-value {
    color: #eee;
    font-weight: bold;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 6px;
}

.draft-pick-btn {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 6px 10px;
    font-family: 'Teko', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 3px;
}

.draft-pick-btn:hover {
    background: #388e3c;
}

/* Lineup Slots */
.lineup-slot {
    background: #2a2a2a;
    border: 1px solid #444;
    padding: 8px;
    /* Reduced from 15px */
    /* Increased from 8px -> revert/smaller */
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    border-radius: 4px;
    min-height: 40px;
    /* Reduced from 50px */
    /* Ensure minimum height */
}

.lineup-slot.filled {
    background: #2e3b2f;
    /* Dark green tint */
    border-color: #2e7d32;
}

.order-num {
    width: 25px;
    color: #666;
    font-weight: bold;
}

.player-name {
    flex: 1;
    font-family: 'Teko', sans-serif;
    font-size: 1.2rem;
    color: #eee;
}

.player-pos {
    background: #000;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
    color: #aaa;
    margin-right: 10px;
}

.remove-btn {
    background: none;
    border: none;
    color: #ff5252;
    border-left: 4px solid var(--accent-green);
}

.league-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid #444;
}

.goals-card {
    margin-top: 16px;
    padding: 10px;
    border: 1px solid #333;
    border-radius: 6px;
    background: #1f1f1f;
}

#goal-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.goal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid #333;
    border-radius: 4px;
    background: #222;
    color: #ddd;
    font-size: 0.85rem;
}

.goal-row.achieved {
    border-color: var(--accent-green);
    color: #c7f5c7;
}

.goal-label {
    font-weight: bold;
}

.goal-meta {
    color: #aaa;
    font-size: 0.8rem;
}

#next-opponent-display {
    font-size: 1.5rem;
    color: #e0e0e0;
    font-family: 'Teko', sans-serif;
}

.cyber-button {
    background: var(--accent-green);
    color: white;
    border: none;
    padding: 15px 30px;
    font-family: 'Teko', sans-serif;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.cyber-button.compact {
    padding: 8px 14px;
    font-size: 1.1rem;
}

.cyber-button:hover {
    background: #388e3c;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

/* DRAG AND DROP */
.player-card.dragging {
    opacity: 0.5;
    border: 2px dashed var(--accent-green);
}

.lineup-slot.drag-over {
    background: #388e3c;
    border: 2px dashed #fff;
    transform: scale(1.02);
}

/* START SCREEN OVERLAY */
#start-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    /* Flex to center content */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.start-content {
    background: #252525;
    padding: 30px;
    border: 2px solid var(--accent-green);
    border-radius: 10px;
    text-align: center;
    width: 500px;
    position: relative;
    /* For close button */
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.3);
    max-width: 800px;
    width: 90%;
}

.start-title {
    font-size: 4rem;
    color: var(--accent-green);
    font-family: 'Teko', sans-serif;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.input-group {
    margin-bottom: 30px;
}

.input-group label {
    display: block;
    color: #aaa;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

#team-name-input {
    background: #222;
    border: 1px solid #444;
    color: white;
    padding: 10px 20px;
    font-size: 1.5rem;
    font-family: 'Teko', sans-serif;
    width: 300px;
    text-align: center;
    outline: none;
}

#team-name-input:focus {
    border-color: var(--accent-green);
}

.save-slots {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
}

.save-slot-card {
    background: #222;
    border: 1px solid #444;
    padding: 20px;
    width: 200px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 150px;
    position: relative;
    /* Context for delete btn */
}

.delete-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: #333;
    color: #ff4444;
    border: 1px solid #444;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
}

.delete-btn:hover {
    background: #ff4444;
    color: white;
    transform: scale(1.1);
}

.save-slot-card:hover {
    border-color: var(--accent-green);
    transform: translateY(-5px);
    background: #2a2a2a;
}

.save-slot-card h3 {
    color: var(--accent-green);
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.slot-info {
    color: #888;
    font-size: 0.9rem;
    line-height: 1.4;
}

.slot-empty {
    color: #666;
    font-style: italic;
}

/* ── elcherlab 통합 로그인 ─────────────────────────────── */
/* 로그인하면 세이브 슬롯이 서버에도 올라간다. 로그인하지 않으면 지금까지와 같다. */

#bm-auth-form input[type="text"],
#bm-auth-form input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 8px;
}

.bm-auth-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 8px 0;
    font-size: 0.75rem;
    line-height: 1.5;
    cursor: pointer;
}

.bm-auth-check input {
    margin: 2px 0 0;
    flex: none;
    width: auto;
    cursor: pointer;
}

.bm-auth-error {
    margin: 6px 0;
    font-size: 0.8rem;
    color: #ff6b6b;
}
