/* Apply box-sizing to all elements for easier layout */
* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f2f2f2;
    margin: 20px;
    color: #333;
}

h1, h2, h3 {
    text-align: center;
    color: #333;
}

h2, h3 {
    margin-top: 30px;
}

img.logo { /* Style for the main logo */
    display: block;
    margin: 20px auto;
    width: 150px; /* Adjusted size */
    height: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    margin-bottom: 20px;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-radius: 5px; /* Added border radius */
    overflow: hidden; /* Ensures radius applies to children */
    font-size: 14px; /* Reduce font size for the entire table */
    table-layout: auto; /* Change default to auto */
}

th, td {
    padding: 4px 6px; /* Adjusted padding */
    text-align: left; /* Default alignment */
    border-bottom: 1px solid #ddd;
    vertical-align: top; /* Default alignment */
    word-break: break-word;
    overflow-wrap: break-word;
}

th {
    background-color: #f8f8f8;
    font-weight: bold;
}

/* Remove bottom border for last row */
tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: #f1f1f1;
}

.container {
    max-width: 900px; /* Unified max-width */
    margin: 20px auto; /* Added top/bottom margin */
    padding: 30px; /* Increased padding */
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 8px; /* Increased radius */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1); /* Added shadow */
}

.footer {
    text-align: center;
    font-size: 11px;
    color: #aaa; /* Lighter color */
    margin-top: 30px; /* Increased margin */
}

.footer em {
    font-style: normal;
}

/* Status Message Style */
.status-message {
    text-align: center;
    font-size: 0.8em; /* Smaller font size */
    color: #888; /* Grey color */
    margin-top: 25px;
    margin-bottom: 5px; /* Space before footer link */
}

/* Chart specific styles (from verlauf.php) */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    margin-bottom: 20px;
    background-color: #fff;
    padding: 15px;
    box-shadow: 0 2px 3px rgba(0,0,0,0.1);
    border-radius: 5px;
    border: 1px solid #eee; /* Added subtle border */
    max-width: 100vw;
    min-width: 0;
}

/* Button style for links */
.button-link {
    display: inline-block;
    padding: 10px 22px;
    background-color: #ffd600; /* Dynamo Yellow */
    color: #222;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    text-align: center;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.button-link:hover,
.button-link:focus {
    background-color: #e6c000; /* Darker yellow on hover */
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    color: #000;
    outline: none;
}

/* Center align buttons within paragraphs */
p.center-button {
    text-align: center;
}

/* Specific table cell alignments/styles if needed */
td.center-align {
    text-align: center;
}

/* Styles for result highlighting in verlauf.php */
.result-win { background-color: #c8e6c9; }
.result-loss { background-color: #ffcdd2; }
.result-draw { background-color: #eeeeee; }
.home-match { background-color: #fff9c4; }

/* Style for opponent logo in table */
td img.opponent-logo {
    height: 20px;
    vertical-align: middle;
    margin-right: 5px;
}

/* Style for assist text in scorer list */
.assist-text {
    color: #666; /* Gray color */
    font-style: italic; /* Optional: make it italic */
}

/* Style for scorers summary table */
.scorers-table {
    flex: 1; /* Allow tables to grow and shrink */
    min-width: 250px; /* Minimum width before wrapping */
    background:#fff;
    border:1px solid #eee;
    border-radius:4px;
    margin-bottom: 0; /* Remove bottom margin if container handles spacing */
}
.scorers-table th, .scorers-table td {
    padding: 8px 12px;
}
.scorers-table td:last-child {
    text-align: center;
}

/* Container for the two scorer tables */
.scorers-container {
    display: flex;
    justify-content: space-between; /* Distribute space between tables */
    flex-wrap: wrap; /* Allow tables to wrap on smaller screens */
    gap: 20px; /* Space between the tables */
    margin-top: 20px;
}

/* Styles for Pie Chart Layout */
.chart-row {
    display: flex;
    justify-content: space-around; /* Distribute space evenly */
    align-items: flex-start; /* Align items at the top */
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 20px; /* Space between chart wrappers */
    margin-top: 30px; /* Space above the chart row */
    margin-bottom: 20px;
}

.pie-chart-wrapper {
    flex: 1; /* Allow wrappers to grow */
    min-width: 280px; /* Minimum width before wrapping */
    max-width: 48%; /* Roughly half width, accounting for gap */
    padding: 15px;
    background-color: #fff;
    border: 1px solid #eee;
    border-radius: 5px;
    box-shadow: 0 2px 3px rgba(0,0,0,0.05);
    text-align: center; /* Center title */
    height: 350px; /* Fixed height for consistency */
    display: flex; /* Use flexbox for vertical centering */
    flex-direction: column; /* Stack title and canvas */
}

.pie-chart-wrapper h4 {
    margin-top: 0;
    margin-bottom: 15px; /* Space below title */
    font-size: 1.1em;
    color: #555;
}

.pie-chart-wrapper canvas {
    max-height: 250px; /* Limit canvas height within wrapper */
}

/* Average Stats Section */
.average-stats {
    text-align: center;
    margin-top: 30px; /* Space above the stats */
    margin-bottom: 20px;
    font-size: 1em;
    color: #555;
}
.average-stats p {
    margin: 5px 0; /* Space between average lines */
}

/* Flash Animation */
@keyframes flash {
  0%, 100% { background-color: transparent; } /* Start and end transparent */
  25%, 75% { background-color: rgba(255, 255, 0, 0.3); } /* Light yellow flash */
  50% { background-color: transparent; } /* Back to transparent between flashes */
}

.flash-effect {
  animation: flash 0.8s ease-in-out 1; /* Apply animation once over 0.8 seconds */
  /* Note: The JS removes the class after 800ms, allowing re-trigger */
}

/* Responsive table and chart container styles */
.mini-table-container,
.summary-container,
.goal-timing-charts {
    display: flex; /* Re-apply flex here */
    gap: 20px; /* Re-apply gap */
    flex-wrap: wrap;
}
.mini-table-container,
.summary-container {
    margin-bottom: 20px;
}
.mini-standings,
.mini-table-right-col,
.summary-table {
    flex: 1 1 300px;
    min-width: 0; /* Prevent flex item from overflowing */
}
.mini-standings table,
.mini-table-right-col table,
.summary-table table {
    width: 100%;
    table-layout: fixed;
    word-break: break-word;
}
.goal-timing-charts {
    flex: 1 1 100%; /* Ensure it takes full width before wrapping */
    margin-top: 20px;
}
.goal-timing-charts > div {
    flex: 1 1 300px;
    min-width: 0;
}
.chart-wrapper { /* Wrapper for goal timing charts */
    flex: 1 1 300px;
    min-width: 0; /* Prevent flex item from overflowing */
}
.chart-inner-wrapper { /* Wrapper for canvas to control height */
    position: relative;
    height: 150px;
}
.col-ergebnis {
    white-space: nowrap;
}

/* Styles moved from inline */
.current-fixtures {
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}
.current-fixtures h4 {
    margin-bottom: 4px;
}
.speculative-note {
    font-size: 0.7em;
    color: #666;
    margin-bottom: 8px;
}
.summary-container {
    margin-top: 20px;
}

/* Fixture related styles */
.fixture-row {
    text-align: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.teams-line {
    display: grid;
    grid-template-columns: 1fr auto auto auto 1fr;
    align-items: center;
    text-align: center;
    column-gap: 4px;
}

.teams-line .home-team {
    text-align: right;
}

.teams-line .away-team {
    text-align: left;
}

.teams-line .separator {
    font-weight: bold;
    padding: 0 2px;
}

.teams-line span {
    flex: 1;
}

.teams-line span:first-child {
    text-align: right;
    margin-right: 5px;
}

.teams-line span:last-child {
    text-align: left;
    margin-left: 5px;
}

.score-line {
    margin-bottom: 5px;
}

.date-line {
    font-size: 0.9em;
    color: #555;
}

.score-input {
    width: 40px;
    text-align: center;
}

/* Table styles */
.center-align {
    text-align: center;
}

.col-ergebnis {
    /* Custom styles for result column */
}

.col-scorers {
    /* Custom styles for scorers column */
}

.main-fixture-table {
    /* Styles for the main fixture table wrapper */
}

/* Chart related styles */
.chart-container {
    /* Chart container styles */
}

.chart-wrapper {
    /* Chart wrapper styles */
}

.chart-inner-wrapper {
    /* Inner chart wrapper styles */
}

/* Flash effect for speculative table changes */
@keyframes flash-effect {
    0%   { background-color: transparent; }
    50%  { background-color: rgba(255, 215, 0, 0.5); }
    100% { background-color: transparent; }
}

.flash-effect {
    animation: flash-effect 0.8s ease;
}

/* Additional styles */
.speculative-note {
    /* Styles for speculative note */
}

.status-message {
    /* Styles for status message */
}

/* --- Responsive Adjustments --- */

@media (max-width: 900px) {
    body {
        font-size: 17px; /* Increased base font size for mobile */
        margin: 10px; /* Reduce body margin */
    }

    .container {
        padding: 15px; /* Reduce container padding */
        margin: 10px auto;
    }

    h1 {
        font-size: 1.6em; /* Adjust heading size */
    }

    h2 {
        font-size: 1.4em;
    }

    h3 {
        font-size: 1.2em;
    }

    th, td {
        padding: 9px 7px; /* Adjust padding */
        font-size: 1em; /* Use 1em to match body font size */
    }

    /* Reduce padding specifically for the result column */
    th.col-ergebnis,
    td.col-ergebnis {
        padding-left: 4px;
        padding-right: 4px;
        text-align: center; /* Center the result */
    }

    .button-link {
        padding: 9px 16px; /* Adjust button size */
        font-size: 1em;
    }

    .chart-container {
        height: 250px; /* Adjust chart height */
        padding: 10px;
    }

    /* Adjust scorer tables for better stacking */
    .scorers-container {
        gap: 15px;
    }

    .scorers-table {
        min-width: 100%; /* Make tables stack vertically */
        flex-basis: 100%;
    }
    .scorers-table th, .scorers-table td {
         padding: 7px 9px; /* Adjust padding */
    }

    /* Adjust Pie Chart Layout */
    .chart-row {
        gap: 15px;
        margin-top: 25px;
    }

    .pie-chart-wrapper {
        flex-basis: 100%; /* Stack charts vertically */
        max-width: 100%;
        height: 320px; /* Adjust height */
    }
     .pie-chart-wrapper canvas {
        max-height: 230px;
    }
     .pie-chart-wrapper h4 {
        font-size: 1em;
        margin-bottom: 10px;
    }

    /* Status Message Style on Mobile */
    .status-message {
        font-size: 0.85em; /* Slightly larger on mobile relative to base */
        margin-top: 20px;
    }

    /* Average Stats Section on Mobile */
    .average-stats {
        margin-top: 25px;
        font-size: 0.95em;
    }

    .mini-table-container,
    .summary-container,
    .goal-timing-charts {
        flex-direction: column;
        gap: 10px;
    }
    .mini-standings,
    .mini-table-right-col,
    .summary-table,
    .goal-timing-charts > div {
        flex: 1 1 100%;
        min-width: 0;
    }
}

@media (max-width: 600px) {
    .mini-table-container,
    .summary-container,
    .goal-timing-charts {
        gap: 15px; /* Increased gap slightly */
    }
    .mini-standings table,
    .mini-table-right-col table,
    .summary-table table {
        font-size: 0.9em; /* Slightly larger font */
    }
    .chart-container,
    .goal-timing-charts > .chart-wrapper { /* Target the wrapper */
        min-width: 0;
        width: 100%; /* Use 100% instead of 100vw */
        max-width: 100%;
    }
    .chart-container canvas,
    .goal-timing-charts canvas {
        /* Let chart.js handle canvas sizing within its container */
    }

    /* Make tables horizontally scrollable on small screens */
    /* Target specific table containers for overflow */
    .mini-standings,
    .mini-table-right-col,
    .summary-table,
    .main-fixture-table { /* Added .main-fixture-table */
        overflow-x: auto;
        width: 100%;
        max-width: 100%; /* Ensure it doesn't exceed container */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }

    /* Apply block display and nowrap only to tables within the overflowing containers */
    .mini-standings table,
    .mini-table-right-col table,
    .summary-table table,
    .main-fixture-table table {
        display: table; /* Revert to table display or use block if needed, but table often works better with overflow */
        table-layout: auto; /* Ensure auto layout for content-based width */
        width: auto; /* Allow table to size based on content */
        min-width: 100%; /* Ensure it fills the scroll container */
        border-collapse: collapse; /* Ensure borders look right */
    }

    /* Ensure cells don't wrap when scrolling, EXCEPT for the scorer column */
    .mini-standings th, .mini-standings td,
    .mini-table-right-col th, .mini-table-right-col td,
    .summary-table th, .summary-table td,
    .main-fixture-table th, .main-fixture-table td {
        white-space: nowrap;
        padding: 5px 8px; /* Adjust padding for mobile */
    }

    /* Allow scorer column content to wrap */
    .main-fixture-table td.col-scorers {
        white-space: normal; /* Override nowrap for this specific column */
    }

    /* Adjust fixture row layout for smaller screens if needed */
    .fixture-row {
        font-size: 0.9em;
    }
    .fixture-row span[style*="flex: 2"] { /* Target the middle score span */
        flex-grow: 1.5; /* Adjust flex basis if needed */
        flex-shrink: 1;
    }
    .fixture-row span[style*="flex: 3"] { /* Target team name spans */
         flex-grow: 2.5;
         flex-shrink: 1;
         overflow: hidden; /* Prevent long names breaking layout */
         text-overflow: ellipsis; /* Add ellipsis for very long names */
    }
    .fixture-row input[type="number"] {
        width: 35px; /* Slightly smaller input */
    }
}
