/* Inherit variables from style.css (assuming style.css is loaded first or variables are redefined here) */
:root {
    --primary-color: #007bff; /* New blue color */
    --secondary-color: #f5f5f1; /* Off-white */
    --background-color: #141414; /* Dark background */
    --card-background: #222;
    --text-color: #fff;
    --text-muted: #aaa;
    --hover-color: #0056b3; /* Darker blue for hover */
}

/* Apply base styles */
body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Ensure footer stays at bottom */
}

main {
    flex-grow: 1; /* Allow main content to fill space */
    padding-top: 20px; /* Add padding below sticky header */
    padding-bottom: 40px; /* Space above footer */
}

/* Player Header */
header {
    /* Use styles from style.css for consistency */
    background-color: rgba(20, 20, 20, 0.9);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid #333;
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Adjust as needed */
}

.player-logo a {
    display: flex;
    align-items: center;
    text-decoration: none; /* Remove underline from link */
}

.player-logo img {
    height: 35px; /* Match style.css */
    margin-right: 8px;
}

.player-logo h1 {
    font-size: 1.6em; /* Match style.css */
    color: var(--primary-color);
    font-weight: 700;
    margin: 0; /* Remove default margin */
}

/* Simple Back Button Example (Optional) */
.back-button {
    color: var(--text-color);
    background-color: var(--card-background);
    padding: 8px 15px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.back-button:hover {
    background-color: #444;
}

.back-button:active {
    transform: scale(0.9); /* Click feedback */
}

.back-button:disabled {
    opacity: 0.4; /* More pronounced disabled state */
    cursor: not-allowed;
    color: #666; /* Darker color when disabled */
}

/* Player Container Specifics */
.player-container {
    /* .container styles are applied globally */
    margin-top: 20px; /* Space below header */
}

/* Video Wrapper */
.anime-video-wrapper {
    background-color: #000;
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    display: none; /* Initially hidden by JS */
    margin-bottom: 20px; /* Space below player */
    border-radius: 5px; /* Optional rounded corners */
    overflow: hidden; /* Ensure iframe stays within bounds */
}

.anime-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Watermark Styles - KEEP AS IS */
.watermark-link {
    position: absolute;
    top: 10px; /* Adjusted for larger screens/padding */
    right: 10px; /* Adjusted for larger screens/padding */
    display: block;
    z-index: 10;
}

.watermark-image {
    display: block;
    width: 50px; /* Adjusted for larger screens/padding */
    height: auto;
    opacity: 1; /* Full opacity */
}

/* Controls Container */
.controls-container {
    display: flex;
    justify-content: space-between; /* Space out season and episode controls */
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px 15px;
    background-color: var(--card-background);
    border-radius: 5px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

/* Style labels within controls */
.controls-container label {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-right: 8px;
    font-weight: 500;
}

/* Season Selector */
.season-control, #episode-nav {
    display: flex;
    align-items: center;
    gap: 8px; /* Space between label and element / buttons */
}

.season-selector {
    padding: 6px 10px;
    font-size: 0.9rem;
    border-radius: 3px;
    border: 1px solid #444; /* Use site's border color */
    background-color: #333; /* Slightly darker than card bg */
    color: var(--text-color);
    cursor: pointer;
    min-width: 80px; /* Ensure it has some width */
    transition: border-color 0.3s ease;
}
.season-selector:hover {
    border-color: var(--primary-color);
}
.season-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
}

/* Navigation Buttons (Prev/Next) */
.nav-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: var(--text-muted); /* Muted color */
    transition: color 0.2s, transform 0.1s;
}

.nav-button:hover:not(:disabled) {
    color: var(--primary-color); /* Blue on hover */
}

.nav-button:active:not(:disabled) {
    transform: scale(0.9); /* Click feedback */
}

.nav-button:disabled {
    opacity: 0.4; /* More pronounced disabled state */
    cursor: not-allowed;
    color: #666; /* Darker color when disabled */
}

.nav-button svg {
    vertical-align: middle;
    width: 24px; /* Consistent size */
    height: 24px;
}

/* Episode List Container */
.episode-list-container {
    background-color: var(--card-background);
    border-radius: 5px;
    padding: 15px;
    margin-top: 10px; /* Space from controls */
    min-height: 100px;
}

.episode-list-container h3 {
    margin: 0 0 15px 0;
    font-size: 1.2em;
    font-weight: 500;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

#episode-list {
    display: grid; /* Use grid for better layout */
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); /* Responsive columns */
    gap: 12px; /* Increased gap */
    max-height: 350px; /* Limit height */
    overflow-y: auto;
    padding-right: 5px; /* Space for scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--card-background);
}

#episode-list::-webkit-scrollbar {
  width: 8px;
}
#episode-list::-webkit-scrollbar-thumb {
  background-color: var(--primary-color);
  border-radius: 10px;
}
#episode-list::-webkit-scrollbar-track {
  background-color: var(--card-background);
}

.episode-button {
    background-color: #333; /* Slightly darker than card bg */
    color: var(--text-muted); /* Muted text color */
    border: 1px solid #444; /* Subtle border */
    border-radius: 4px; /* Consistent border-radius */
    padding: 8px 12px; /* Consistent padding */
    font-size: 0.9em; /* Slightly smaller font */
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, transform 0.1s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500; /* Medium weight */
    margin: 5px; /* Added margin as requested */
}

.episode-button:hover {
    background-color: #444; /* Slightly lighter on hover */
    border-color: var(--primary-color); /* Highlight border */
    color: var(--text-color); /* Brighter text */
}

.episode-button:active {
    transform: scale(0.98); /* Slight press effect */
}

.episode-button.active {
    background-color: var(--primary-color); /* Primary color for active */
    border-color: var(--primary-color);
    color: var(--text-color); /* White text */
    font-weight: 700; /* Bold active */
}

#episode-list .loading-message,
#episode-list .error-message {
    color: var(--text-muted);
    text-align: center;
    padding: 15px;
    grid-column: 1 / -1; /* Span all columns */
    font-size: 0.9em;
}
#episode-list .error-message {
    color: #ff8a8a; /* Reddish tint for errors */
}

/* Error Display Below Player */
.error-message {
    background-color: #331a1a; /* Dark red background */
    color: #ffdddd; /* Light red text */
    padding: 10px 15px;
    border-radius: 4px;
    margin-bottom: 15px; /* Space below */
    border: 1px solid #882222; /* Red border */
    text-align: center;
    font-size: 0.95em;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
     /* Make controls stack vertically */
    .controls-container {
        flex-direction: column;
        align-items: stretch; /* Stretch items to full width */
    }
    .season-control, #episode-nav {
        justify-content: space-between; /* Space out label and selector/buttons */
        width: 100%; /* Take full width */
    }
    #episode-nav label {
        margin-right: auto; /* Push buttons to the right */
    }
     #episode-list {
        max-height: 250px; /* Shorter list on mobile */
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); /* Slightly smaller min size */
        gap: 10px; /* Gap for tablet */
    }
    .episode-button {
        padding: 6px 10px;
        font-size: 0.85em;
    }
}

@media (max-width: 480px) {
    .player-container {
        margin-top: 10px; /* Reduce top margin */
    }
    .anime-video-wrapper {
        margin-bottom: 15px; /* Reduce space */
    }
    .controls-container {
        padding: 8px 10px; /* Reduce padding */
        margin-bottom: 15px;
    }
     .controls-container label {
        font-size: 0.85em;
    }
    .season-selector {
        font-size: 0.85em;
    }
    .nav-button svg {
        width: 20px;
        height: 20px;
    }
    .episode-list-container {
        padding: 10px; /* Reduce padding */
    }
    .episode-list-container h3 {
        font-size: 1.1em;
        margin-bottom: 10px;
        padding-bottom: 8px;
    }
    #episode-list {
        display: block; /* Change to block layout for list view */
        gap: 0; /* Remove grid gap */
        max-height: 200px;
        padding-left: 0; /* Remove padding */
        padding-right: 5px; /* Keep scrollbar padding */
    }
    .episode-button {
        display: block; /* Ensure buttons are block elements */
        width: calc(100% - 5px); /* Take full width minus scrollbar padding */
        margin-bottom: 8px; /* Add margin between buttons in list view */
        padding: 8px 12px; /* Slightly more padding for list items */
        font-size: 0.85em; /* Adjusted font size */
        text-align: left; /* Align text left for list view */
    }
     .episode-button:last-child {
        margin-bottom: 0; /* Remove margin from last button */
     }
    .watermark-link {
        top: 5px;
        right: 5px;
    }
    .watermark-image {
        width: 40px;
    }
     .error-message {
        padding: 8px 10px;
        font-size: 0.9em;
     }
}