:root {
    /* Pirate Palette - Sepia/Ink Theme (Default Light) */
    --bg-wood: #f0e6d2; /* Main Parchment Background */
    --parchment: #f0e6d2; /* Light Parchment */
    --parchment-dark: #c5b89d; /* Accents/Borders */
    --ink: #2b1d16; /* Dark Ink Text */
    --gold: #8b7355; /* Antique Brass */
    --red: #8b0000; /* Wax Seal Red */
    
    /* Header BG */
    --header-bg: rgba(220, 208, 182, 0.95); 
    
    /* Fonts */
    --font-header: 'Pirata One', cursive;
    --font-pixel: 'VT323', monospace;
}

[data-theme="dark"] {
    /* Medieval Hyprland Dark Theme */
    --bg-wood: #1a1a1a; /* Dark Charcoal Paper */
    --parchment: #252525; /* Dark Grey for cards/modals */
    --parchment-dark: #333333; /* Lighter Grey for borders */
    --ink: #e0d8c0; /* Off-white/Bone text */
    --gold: #a8a8a8; /* Steel/Silver Accent */
    --red: #ff4444; /* Brighter Red for visibility */
    
    --header-bg: rgba(26, 26, 26, 0.95);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Prevent any horizontal scrolling globally */
html, body {
    overflow-x: hidden;
}

body {
    background-color: var(--bg-wood);
    color: var(--ink);
    font-family: var(--font-pixel);
    font-size: 20px;
    /* Paper Texture Pattern (Light Mode Default) */
    background-image: repeating-linear-gradient(90deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px, transparent 1px, transparent 20px);
    min-height: 100vh;
    /* Layout: make footer sticky to bottom when content is short */
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s, color 0.3s;
}

[data-theme="dark"] body {
    /* Dark Mode Texture - Dark Paper */
    background-image: repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0px, rgba(255,255,255,0.03) 1px, transparent 1px, transparent 20px);
}

/* --- Footer --- */
.site-footer {
    background: linear-gradient(90deg, rgba(0,0,0,0.03), rgba(0,0,0,0.02));
    border-top: 3px double var(--parchment-dark);
    padding: 12px 2rem;
    margin-top: 2rem;
}
.site-footer .footer-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-family: var(--font-pixel);
    color: var(--ink);
    font-size: 0.95rem;
}
.site-footer .footer-left { font-family: var(--font-header); font-size: 1.05rem; color: var(--gold); }
.site-footer .footer-right { opacity: 0.95; font-style: italic; }

@media (max-width: 600px) {
    .site-footer { padding: 10px 1rem; }
    .site-footer .footer-content { flex-direction: column; align-items: center; text-align: center; gap: 6px; }
    .site-footer .footer-left, .site-footer .footer-right { font-size: 0.85rem; }
}

/* --- Sidebar --- */
:root {
    --sidebar-width: 80px;
    --sidebar-width-expanded: 220px;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--parchment);
    border-right: 3px double var(--gold);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 15px rgba(0,0,0,0.2);
    overflow: hidden; /* Hide text when collapsed */
}

/* Texture overlay for sidebar */
.sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
    pointer-events: none;
}

.sidebar:hover {
    width: var(--sidebar-width-expanded);
}

.sidebar-logo {
    text-align: center;
    margin-bottom: 30px;
    padding: 0 20px;
    opacity: 0.8;
}

.nav-links {
    list-style: none;
    flex: 1; /* Push bottom controls down */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 15px 26px; /* Center icon when width is 80px */
    cursor: pointer;
    color: var(--ink);
    font-family: var(--font-header);
    font-size: 1.4rem;
    position: relative;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.nav-item i {
    font-size: 1.6rem;
    min-width: 30px;
    text-align: center;
}

.link-text {
    margin-left: 20px;
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.2s, transform 0.2s;
}

.sidebar:hover .link-text {
    opacity: 1;
    transform: translateX(0);
}

.nav-item:hover {
    background: rgba(0,0,0,0.05); /* Subtle dark overlay */
    color: var(--red);
}
[data-theme="dark"] .nav-item:hover {
    background: rgba(255,255,255,0.05);
}

.nav-item.active {
    color: var(--gold);
    background: rgba(0,0,0,0.03);
    border-right: 4px solid var(--gold);
}

.nav-bottom {
    border-top: 1px dashed var(--ink);
    padding-top: 10px;
}


/* --- Header Adjustments for Sidebar --- */
header {
    left: var(--sidebar-width); /* Push header right */
    width: calc(100% - var(--sidebar-width));
    padding-left: 2rem;
    transition: left 0.3s, width 0.3s;
}

/* Shift main content too */
body.with-sidebar main {
    padding-left: calc(var(--sidebar-width) + 0.25rem);
    transition: padding-left 0.3s;
}

.header-content {
    /* Center logo in remaining space */
    max-width: 1200px; 
}

/* --- Hide Old Controls --- */
.top-controls { display: none; } 
.galleon-icon { display: none; } /* Moved to sidebar top or removed */

/* --- Footer --- */
.site-footer {
    padding-left: calc(var(--sidebar-width) + 2rem);
    transition: padding-left 0.3s;
}

/* --- Header --- */
header {
    background: var(--header-bg);
    border-bottom: 3px double var(--gold);
    padding: 1rem 2rem;
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    transition: background-color 0.3s, box-shadow 0.3s, left 0.3s;
}

[data-theme="dark"] header {
    box-shadow: 0 4px 20px rgba(0,0,0,0.8);
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    max-width: 1600px;
    margin: 0 auto;
    position: relative;
}

.header-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 1.5rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-icon-btn {
    background: none;
    border: 2px solid var(--gold);
    color: var(--gold);
    font-size: 1.1rem;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-pixel);
}

.header-icon-btn:hover {
    background: var(--gold);
    color: var(--bg);
    transform: scale(1.05);
}

.top-controls {
    position: absolute;
    top: 12px;
    right: 16px;
    display: flex;
    gap: 15px;
    align-items: center;
    z-index: 120; /* sit above header content */
}

.theme-toggle, .admin-link {
    background: none;
    border: none;
    color: var(--gold);
    font-family: var(--font-pixel);
    font-size: 1.2rem;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.theme-toggle:hover, .admin-link:hover {
    color: var(--parchment);
}

.logo {
    font-family: var(--font-header);
    font-size: 2.5rem;
    color: var(--gold);
    text-shadow: 3px 3px 0px #000;
    letter-spacing: 3px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}

.logo-text {
    transform: translateY(5%); /* Force move downwards */
    display: inline-block;
}

/* --- Search --- */
.search-container {
    position: relative;
    flex: 1;
    max-width: 600px;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 15px;
    color: var(--ink);
    font-size: 1.2rem;
    z-index: 10;
}

#search-input {
    width: 100%;
    background: var(--parchment);
    border: 2px solid var(--ink);
    color: var(--ink);
    font-family: var(--font-pixel);
    font-size: 1.4rem;
    padding: 0.5rem 2.5rem 0.5rem 2.5rem; /* Space for icon and X */
    border-radius: 4px;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.3);
    /* Paper Texture */
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.15'/%3E%3C/svg%3E");
}

#search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--ink);
    font-family: var(--font-pixel);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 20;
    opacity: 0.6;
}

#search-clear:hover {
    opacity: 1;
    color: var(--red);
}

.dropdown {
    position: absolute;
    top: 110%;
    left: 0;
    width: 100%;
    background: var(--parchment);
    border: 2px solid var(--ink);
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
    box-shadow: 5px 5px 15px rgba(0,0,0,0.5);
}

.live-item {
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-bottom: 1px dashed var(--ink);
    color: var(--ink);
}

.live-item:hover {
    background: var(--parchment-dark);
}

.live-info {
    display: flex;
    flex-direction: column;
}

.live-title {
    font-family: var(--font-header);
    font-size: 1.2rem;
    color: var(--ink);
}

.live-year {
    font-family: var(--font-pixel);
    font-size: 1rem;
    color: var(--ink);
    opacity: 0.7;
}

/* --- Main Content --- */
main {
    padding: 1rem;
    max-width: 1600px;
    margin: 0 0;
    flex: 1 1 auto;
    margin-left: 9rem !important;
}


@media (max-width: 768px) {
    main { padding-top: 80px; }
}

@media (max-width: 480px) {
    main { padding-top: 120px; }
}

/* Rows */
.row-wrapper {
    margin-bottom: 3rem;
    position: relative;
    padding: 0 30px; /* space for circular arrow buttons */
    width: 100%;
    box-sizing: border-box;
}
/* Remove extra padding when row-wrapper contains a collection grid */
.row-wrapper:has(.collection-grid) {
    padding: 0;
}

.row-title {
    font-family: var(--font-header);
    font-size: 2.8rem;
    color: var(--ink); /* Changed from parchment to ink for visibility on light bg */
    margin-bottom: 1rem;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.1);
    border-bottom: 1px solid var(--gold);
    display: inline-flex; /* Changed from inline-block to align items */
    align-items: center; /* Vertically center content */
    padding-right: 2rem;
    gap: 15px; /* Space between text and button */
}

.row-scroller {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    padding: 1rem 0 1.5rem;
    scrollbar-width: none; /* Hide scrollbar for clean look */
    -ms-overflow-style: none;
    padding-left: 0.3rem;
}
.row-scroller::-webkit-scrollbar { display: none; }

.row-arrow {
    position: absolute;
    top: 55%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.6);
    color: var(--gold);
    border: 2px solid var(--gold);
    font-size: 1.1rem;
    padding: 10px 12px;
    cursor: pointer;
    z-index: 10;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-pixel);
    transition: opacity 0.3s ease, background 0.3s, transform 0.2s;
    backdrop-filter: blur(4px);
}

.row-arrow.prev { left: 0px; }
.row-arrow.next { right: 0px; }
.row-arrow:hover {
    background: var(--gold);
    color: var(--ink);
    transform: translateY(-50%) scale(1.1);
}

/* Cards - "Treasure Map" Style */
.card {
    flex: 0 0 auto;
    width: 180px;
    aspect-ratio: 2/3;
    transition: transform 0.35s cubic-bezier(.25,.8,.25,1), filter 0.3s, box-shadow 0.35s;
    cursor: pointer;
    border: 3px solid var(--parchment-dark);
    box-shadow:
        0 4px 12px rgba(0,0,0,0.5),
        inset 0 0 20px rgba(0,0,0,0.15);
    filter: sepia(30%) contrast(1.05) brightness(0.95);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    background: var(--parchment-dark);
}

/* Gold corner accents */
.card::before,
.card::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid var(--gold);
    opacity: 0.5;
    transition: opacity 0.3s, width 0.3s, height 0.3s;
    z-index: 2;
    pointer-events: none;
}
.card::before {
    top: 4px; left: 4px;
    border-right: none; border-bottom: none;
}
.card::after {
    bottom: 4px; right: 4px;
    border-left: none; border-top: none;
}

/* Title overlay that appears on hover */
.card .card-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 24px 8px 8px;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    color: var(--gold);
    font-family: var(--font-pixel);
    font-size: 0.85rem;
    line-height: 1.2;
    text-shadow: 1px 1px 2px #000;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s, transform 0.3s;
    z-index: 2;
    pointer-events: none;
}

.card:hover {
    transform: scale(1.06) translateY(-4px);
    border-color: var(--gold);
    filter: sepia(0%) contrast(1.05) brightness(1);
    box-shadow:
        0 8px 24px rgba(0,0,0,0.5),
        0 0 12px rgba(212,175,55,0.2);
    z-index: 10;
}

.card:hover::before,
.card:hover::after {
    opacity: 1;
    width: 22px;
    height: 22px;
}

.card:hover .card-overlay {
    opacity: 1;
    transform: translateY(0);
}

.poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Continue Watching progress bar */
.continue-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 4px;
    background: rgba(0,0,0,0.5);
    z-index: 3;
}
.continue-fill {
    height: 100%;
    background: var(--gold);
    transition: width 0.3s;
}
.continue-ep {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 2px;
}

/* Collection Filter Bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: flex-end;
    padding: 0 1.5rem 1rem;
}
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.filter-label {
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.pixel-filter-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--parchment-dark);
    border: 2px solid var(--gold);
    border-radius: 4px;
    color: var(--ink);
    font-family: var(--font-pixel);
    font-size: 0.85rem;
    padding: 6px 28px 6px 10px;
    cursor: pointer;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23d4af37'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.2s, box-shadow 0.2s;
    image-rendering: pixelated;
    min-width: 120px;
}
.pixel-filter-select:hover,
.pixel-filter-select:focus {
    border-color: #fff;
    box-shadow: 0 0 0 1px var(--gold), inset 0 0 6px rgba(212,175,55,0.1);
}
.pixel-filter-select option {
    background: var(--parchment-dark);
    color: var(--ink);
    font-family: var(--font-pixel);
}
.filter-clear {
    /* Match the filter dropdowns so it lines up in the bar */
    background: transparent;
    border: 2px solid var(--gold);
    color: var(--ink);
    font-family: var(--font-pixel);
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    height: fit-content;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.filter-clear:hover {
    border-color: #fff;
    background: var(--gold);
    color: var(--parchment);
}
.collection-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
    gap: 0.75rem;
    padding: 0;
    width: 100%;
}
.collection-grid .card {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    flex: none !important;
    aspect-ratio: 2/3;
    box-sizing: border-box !important;
}
.filter-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.35rem;
    padding: 1.2rem 0;
    flex-wrap: wrap;
}
.filter-pagination .page-btn {
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    border: 2px solid var(--gold);
    background: transparent;
    color: var(--ink);
    font-family: var(--font-pixel);
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.filter-pagination .page-btn:hover {
    background: var(--gold);
    color: var(--parchment);
}
.filter-pagination .page-btn.active {
    background: var(--gold);
    color: var(--parchment);
    font-weight: bold;
}
.filter-pagination .page-btn:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}
.filter-pagination .page-ellipsis {
    color: var(--ink);
    font-family: var(--font-pixel);
    font-size: 0.85rem;
    padding: 0 2px;
    user-select: none;
}

/* --- Modal (The Captain's Quarters) --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--parchment);
    color: var(--ink);
    width: 90%;
    max-width: 960px;
    max-height: 92vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    border: 6px double var(--ink);
    box-shadow: 0 0 50px rgba(0,0,0,0.9);
    padding: 1.8rem 2rem;
    /* Paper texture effect */
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.15'/%3E%3C/svg%3E");
}

/* When the modal is showing the player, reduce chrome and expand the player area */
.modal.player-open {
    align-items: center;
}
.modal.player-open .modal-content {
    width: 96%;
    max-width: 1100px;
    padding: 10px;
    border-width: 4px;
}
.modal.player-open .modal-content .modal-header {
    display: none !important;
}
.modal.player-open #player-wrapper {
    border-width: 4px;
    margin: 0;
    width: 100%;
    max-width: 100%;
}
.modal.player-open .close-btn { display: none !important; }

/* Make source select and close/exit buttons smaller on narrow screens so they fit without overlap */
#source-select {
    font-size: 1rem;
    padding: 6px 10px;
    border-radius: 6px;
}
.modal.player-open #source-select {
    font-size: 0.95rem;
    padding: 4px 8px;
}

/* Reduce close button size on smaller viewports (when not in player-open state) so it doesn't crowd the UI */
.close-btn {
    transition: transform 0.15s, font-size 0.15s;
}

@media (max-width: 900px) {
    #source-select { font-size: 0.95rem; padding: 4px 8px; }
    .close-btn { font-size: 1.6rem; top: 10px; right: 12px; }
}

@media (max-width: 480px) {
    #source-select { font-size: 0.85rem; padding: 3px 6px; }
    .close-btn { font-size: 1.2rem; top: 8px; right: 10px; }
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 2.5rem; /* Larger */
    cursor: pointer;
    color: var(--red);
    transition: transform 0.2s;
    z-index: 500; /* High Z-Index */
}
.close-btn:hover { transform: scale(1.2); }

.modal-header {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
    align-items: flex-start;
}

.poster-wrapper {
    flex-shrink: 0;
}

.poster-wrapper img {
    width: 200px;
    border: 3px solid var(--ink);
    box-shadow: 6px 6px 0px rgba(0,0,0,0.2);
    transform: rotate(-1.5deg);
    display: block;
}

.modal-info {
    flex: 1;
    min-width: 0;
}

.modal-info h2 {
    font-family: var(--font-header);
    font-size: 2.8rem;
    margin-bottom: 0.3rem;
    color: var(--ink);
    line-height: 1;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.2);
}

.m-meta {
    display: flex;
    gap: 10px;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.ai-badge-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
    width: 100%;
}

.pixel-badge {
    background: var(--ink);
    color: var(--parchment);
    padding: 5px 12px;
    font-size: 1.2rem;
    border: 2px solid var(--ink);
}

.pixel-badge.gold {
    background: var(--gold);
    color: var(--ink);
    border-color: var(--ink);
}

.pixel-badge.red {
    background: var(--red);
    color: white;
}


.ai-badge {
    background: var(--red) !important;
    color: white !important;
    border: 2px solid black !important;
    font-family: var(--font-pixel);
    padding: 6px 14px;
    font-size: 1.3rem;
    display: inline-flex;
    align-items: center;
}

.regen-btn {
    font-size: 1.2rem;
    padding: 6px 12px;
    background: var(--red);
    border: 2px solid var(--ink);
    color: white;
    cursor: pointer;
    font-family: var(--font-pixel);
    transition: background 0.12s, color 0.12s;
    margin-left: 0;
    vertical-align: middle;
}

.regen-btn:hover {
    background: var(--ink);
    color: var(--parchment);
}

#m-desc {
    font-size: 1.15rem;
    line-height: 1.45;
    margin-bottom: 1rem;
    font-family: var(--font-pixel);
    border-left: 3px solid var(--gold);
    padding-left: 0.8rem;
    max-height: 6.5em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

/* Controls */
.control-deck {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 0.8rem;
    padding: 0.8rem 1rem;
    border: 2px dashed var(--ink);
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
}

.pixel-select {
    padding: 12px;
    font-family: var(--font-pixel);
    font-size: 1.3rem;
    background: var(--bg-wood);
    color: var(--gold);
    border: 2px solid var(--ink);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.pixel-btn {
    padding: 12px 25px;
    font-family: var(--font-pixel);
    font-size: 1.6rem;
    letter-spacing: 0.5px;
    border: 2px solid var(--ink);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
    background: var(--parchment);
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 10px;
    /* Engraved double-frame: a thin inner rule set off by a hair of parchment.
       Echoes the modal's double border — crafted, vintage, no neobrutalist shadow. */
    box-shadow: inset 0 0 0 2px var(--parchment), inset 0 0 0 3px var(--ink);
}

/* Inked stamp: fills with ink on hover; the inner rule flips so it stays visible */
.pixel-btn:hover {
    background: var(--ink);
    color: var(--parchment);
    box-shadow: inset 0 0 0 2px var(--ink), inset 0 0 0 3px var(--parchment);
}

.pixel-btn:active {
    transform: translateY(1px);
}

/* Primary action (Play / Download / Start): wax-seal red w/ a thin engraved rule */
.pixel-btn.action {
    background: var(--red);
    color: #fff;
    border-color: var(--ink);
    box-shadow: inset 0 0 0 2px var(--red), inset 0 0 0 3px rgba(255,255,255,0.55);
}
.pixel-btn.action:hover {
    background: var(--ink);
    color: var(--parchment);
    box-shadow: inset 0 0 0 2px var(--ink), inset 0 0 0 3px var(--parchment);
}

/* --- Spin the Helm --- */
.helm-title {
    font-family: var(--font-header);
    font-size: 2.2rem;
    color: var(--ink);
    margin-bottom: 0.2rem;
}
.helm-sub {
    font-family: var(--font-pixel);
    color: var(--ink);
    opacity: 0.75;
    margin-bottom: 0.4rem;
}
.helm-wheel-wrap {
    margin: 1rem 0 1.2rem;
    line-height: 1;
}
.helm-wheel {
    font-size: 130px;
    color: var(--gold);
    display: inline-block;
    transition: transform 2.2s cubic-bezier(.15, .72, .18, 1);
    text-shadow: 3px 3px 0 rgba(0,0,0,0.18);
}
.helm-filters {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}
.helm-result {
    margin-top: 1rem;
    min-height: 1.6rem;
    font-family: var(--font-pixel);
    font-size: 1.2rem;
    color: var(--red);
}
.helm-pick { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.helm-pick-label { font-family: var(--font-pixel); color: var(--ink); opacity: 0.8; }
.helm-pick-poster { width: 120px; border: 2px solid var(--ink); border-radius: 3px; box-shadow: 4px 4px 0 rgba(0,0,0,0.15); }
.helm-pick-title { font-family: var(--font-header); font-size: 1.5rem; color: var(--ink); line-height: 1.1; }
.helm-pick-actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }

/* "More like this" cards reuse the main .card look + animation, just smaller */
.rec-card { width: 92px; }

/* Auto-next-episode countdown card */
#autonext-overlay { position: fixed; bottom: 28px; right: 28px; z-index: 10000; }
.autonext-card {
    background: var(--parchment);
    color: var(--ink);
    border: 3px double var(--ink);
    padding: 14px 18px;
    font-family: var(--font-pixel);
    box-shadow: 0 6px 26px rgba(0,0,0,0.55);
    max-width: 280px;
}
.autonext-title { font-family: var(--font-header); font-size: 1.4rem; }
.autonext-sub { margin: 6px 0 10px; opacity: 0.85; }
.autonext-actions { display: flex; gap: 8px; }
.autonext-actions .pixel-btn { font-size: 1rem; padding: 6px 12px; }

/* CAM/TS warning — diagonal corner ribbon (the .card already clips overflow) */
.avail-badge {
    position: absolute;
    top: 16px;
    left: -36px;
    width: 140px;
    transform: rotate(-45deg);
    background: var(--red);
    color: #fff;
    font-family: var(--font-pixel);
    font-weight: bold;
    font-size: 0.82rem;
    letter-spacing: 1px;
    text-align: center;
    text-transform: uppercase;
    padding: 3px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.45);
    border-bottom: 1px solid rgba(0, 0, 0, 0.35);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
    z-index: 4;
    pointer-events: none;
}
/* CAM/TS section header — red warning styling */
.cam-section .row-title.cam-title {
    color: var(--red);
    border-bottom-color: var(--red);
}
.cam-title .fa-triangle-exclamation { margin-right: 8px; font-size: 0.85em; }

/* --- Dedicated show page --- */
.show-topbar { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:0.7rem 1.5rem; border-bottom:2px solid var(--ink); background:var(--header-bg); position:sticky; top:0; z-index:50; }
.show-topbar .pixel-btn { font-size:1.1rem; padding:8px 16px; }
#show-root { width:100%; max-width:1100px; margin:0 auto; padding:1.5rem; box-sizing:border-box; }
.show-hero { display:flex; gap:1.5rem; margin-bottom:1.5rem; flex-wrap:wrap; }
.show-hero-poster { width:200px; border:3px solid var(--ink); box-shadow:6px 6px 0 rgba(0,0,0,0.2); flex-shrink:0; }
.show-hero-info { flex:1; min-width:260px; }
.show-hero-title { font-family:var(--font-header); font-size:3rem; color:var(--ink); line-height:1; margin-bottom:0.6rem; }
.show-hero-overview { font-family:var(--font-pixel); font-size:1.15rem; line-height:1.45; margin-bottom:1rem; opacity:0.9; }
.show-seasons { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:1.2rem; }
.season-tab { font-family:var(--font-pixel); font-size:1.1rem; padding:6px 16px; background:var(--parchment); color:var(--ink); border:2px solid var(--ink); cursor:pointer; transition:background 0.12s,color 0.12s; }
.season-tab:hover { background:var(--ink); color:var(--parchment); }
.season-tab.active { background:var(--gold); color:var(--ink); }
.show-episodes { display:flex; flex-direction:column; gap:10px; }
.episode-row { display:flex; gap:14px; padding:10px; border:2px solid var(--parchment-dark); background:rgba(0,0,0,0.03); cursor:pointer; transition:border-color 0.15s, background 0.15s; }
.episode-row:hover { border-color:var(--gold); background:rgba(0,0,0,0.06); }
.episode-row.watched { opacity:0.6; }
.ep-thumb { position:relative; width:140px; height:80px; flex-shrink:0; background:var(--parchment-dark); border:1px solid var(--ink); overflow:hidden; }
.ep-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.ep-play { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:#fff; font-size:1.6rem; opacity:0; background:rgba(0,0,0,0.35); transition:opacity 0.15s; }
.episode-row:hover .ep-play { opacity:1; }
.ep-check { position:absolute; top:4px; right:4px; background:var(--gold); color:var(--ink); width:22px; height:22px; display:flex; align-items:center; justify-content:center; border:1px solid var(--ink); font-size:0.8rem; }
.ep-meta { flex:1; min-width:0; font-family:var(--font-pixel); }
.ep-title { font-size:1.25rem; color:var(--ink); }
.ep-sub { font-size:0.95rem; opacity:0.7; margin:2px 0 4px; }
.ep-overview { font-size:1rem; line-height:1.3; opacity:0.85; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.ep-progress { height:4px; background:var(--parchment-dark); margin-top:6px; }
.ep-progress-fill { height:100%; background:var(--red); }

/* Player */
#player-wrapper {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    margin-bottom: 2rem;
    border: 6px solid var(--gold);
    box-shadow: 0 0 30px rgba(0,0,0,0.7);
    position: relative;
    display: flex;
    flex-direction: column;
}

#artplayer-app, #embed-frame {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
}

.player-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--ink);
    padding: 5px 10px;
    border-bottom: 1px solid var(--gold);
    gap: 6px;
    flex-wrap: wrap;
}

.player-controls .pixel-select {
    font-size: 0.85rem;
    padding: 3px 8px;
    background: rgba(255,255,255,0.08);
    color: var(--gold);
    border: 1px solid var(--gold);
    border-radius: 4px;
    box-shadow: none;
    max-width: 200px;
}

/* ─── Hunt Overlay ─── */
.hunt-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: linear-gradient(135deg, #0a0a0f 0%, #0d1117 50%, #0a0a12 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: huntFadeIn 0.3s ease;
}

.hunt-overlay.hunt-fade-out {
    animation: huntFadeOut 0.5s ease forwards;
}

@keyframes huntFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes huntFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.hunt-content {
    text-align: center;
    padding: 2rem;
}

.hunt-logo {
    font-size: 3rem;
    animation: huntPulse 1.5s ease-in-out infinite;
    margin-bottom: 0.5rem;
}

@keyframes huntPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; }
}

.hunt-title {
    font-family: var(--font-header);
    font-size: 1.8rem;
    color: var(--gold);
    margin: 0 0 0.3rem 0;
    letter-spacing: 0.15em;
    text-shadow: 0 0 20px rgba(218,165,32,0.4);
}

.hunt-subtitle {
    font-family: var(--font-pixel);
    color: rgba(255,255,255,0.5);
    font-size: 0.85rem;
    margin-bottom: 1.2rem;
}

.hunt-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 500px;
    margin: 0 auto 1rem;
}

.hunt-cell {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-family: var(--font-pixel);
    font-size: 0.75rem;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    transition: all 0.3s ease;
}

.hunt-cell.scanning {
    animation: huntScan 1.2s ease-in-out infinite;
    border-color: rgba(218,165,32,0.3);
}

.hunt-cell.scanning .hunt-dot {
    color: var(--gold);
    animation: huntDotPulse 0.8s ease-in-out infinite;
}

.hunt-cell.found {
    border-color: #4ade80;
    background: rgba(74,222,128,0.1);
    animation: huntFound 0.4s ease;
}

.hunt-cell.found .hunt-dot {
    color: #4ade80;
}

.hunt-cell.found .hunt-name {
    color: #4ade80;
}

.hunt-cell.failed .hunt-dot {
    color: rgba(255,255,255,0.2);
}

.hunt-name {
    color: rgba(255,255,255,0.6);
}

.hunt-dot {
    font-size: 0.6rem;
}

@keyframes huntScan {
    0%, 100% { opacity: 0.4; transform: scale(0.97); }
    50% { opacity: 1; transform: scale(1.02); }
}

@keyframes huntDotPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

@keyframes huntFound {
    0% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.hunt-status {
    font-family: var(--font-pixel);
    color: rgba(255,255,255,0.4);
    font-size: 0.75rem;
}

/* Make the player responsive on narrow screens */
@media (max-width: 900px) {
    #player-wrapper {
        aspect-ratio: auto; /* allow explicit height */
        height: 44vw; /* scale with viewport width */
        max-height: 320px;
        border-width: 4px;
        margin-bottom: 1.2rem;
    }
    .player-controls { padding: 6px; }
}

@media (max-width: 480px) {
    #player-wrapper {
        height: 52vw; /* slightly taller on very narrow screens */
        max-height: 300px;
        border-width: 3px;
    }
    .player-controls { padding: 4px; font-size: 0.95rem; }
    #artplayer-app, #embed-frame { height: 100%; }
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Episodes */
.pixel-title {
    font-family: var(--font-header);
    font-size: 2rem;
    border-bottom: 1px solid var(--ink);
    margin-bottom: 10px;
}

.ep-item {
    padding: 10px;
    border-bottom: 1px dashed var(--ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ep-item:hover {
    background: rgba(0,0,0,0.1);
}

/* Utilities */
.hidden { display: none !important; }

/* Scrollbars */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}
::-webkit-scrollbar-track {
    background: var(--bg-wood);
}
::-webkit-scrollbar-thumb {
    background: var(--gold);
    border: 3px solid var(--bg-wood);
    border-radius: 0;
}

/* Mobile Responsiveness */

/* Download Modal Quality Pills */
#dl-content {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}
#dl-content.hidden {
    display: none;
}
.dl-quality-pill {
    padding: 6px 16px;
    font-family: var(--font-pixel);
    font-size: 1rem;
    border: 2px solid var(--ink);
    background: var(--parchment);
    color: var(--ink);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.dl-quality-pill.active {
    background: var(--gold);
    color: #000;
    border-color: var(--ink);
}
.dl-quality-pill:hover {
    background: var(--ink);
    color: var(--parchment);
}

@media (max-width: 768px) {
    .modal-header {
        flex-direction: column;
    }
    .poster-wrapper img {
        width: 150px;
        margin: 0 auto;
        display: block;
    }
    .modal-info h2 {
        font-size: 2.5rem;
        text-align: center;
    }
    .control-deck {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Additional mobile adjustments for homepage rows and cards */
@media (max-width: 900px) {
    /* Header/search */
    .header-content { max-width: 100%; padding: 0 1rem; }
    .search-container { width: 100%; }
    .logo { font-size: 3.2rem; }

    /* Row titles and scrollers */
    .row-title { font-size: 1.8rem; }
    .row-scroller { gap: 0.8rem; padding: 0.6rem 0; }
    .row-arrow { display: none; } /* Hide desktop arrows on small screens */

    /* Cards smaller on mobile */
    .card { width: 130px; }
    .card::before, .card::after { display: none; }
    .poster-wrapper img, .poster { width: 100%; height: auto; }

    /* Modal adjustments */
    .modal-content { padding: 1rem; max-width: 95%; }

    /* Charts: reduce canvas heights on narrow screens */
    .chart-box { min-height: 220px; }
    .chart-box canvas { height: 220px !important; }
}

@media (max-width: 480px) {
    .logo { font-size: 2.4rem; }
    .row-title { font-size: 1.4rem; }
    .card { width: 110px; }
    .card-overlay { font-size: 0.7rem; padding: 16px 4px 4px; }
    .poster { height: 160px; }
    #search-input { font-size: 1rem; }
    body { font-size: 16px; }
}

@media (max-width: 480px) {
    header { padding: 0.8rem 1rem; }
    .header-row { flex-wrap: wrap; gap: 0.5rem; }
    .header-right { order: -1; margin-left: auto; }
}

/* Ensure main content is pushed below fixed header on narrow screens
   so the first row title is never hidden behind the header. */
@media (max-width: 900px) {
    main { padding-top: 80px; }
}

@media (max-width: 480px) {
    main { padding-top: 120px; }
}

/* Mobile navigation styles */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: 2px solid var(--ink);
    color: var(--ink);
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 1.2rem;
}

.mobile-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--parchment);
    border-top: 1px solid var(--parchment-dark);
    z-index: 200;
    padding: 10px 1rem;
}

.mobile-nav a, .mobile-nav button {
    display: block;
    padding: 10px 0;
    color: var(--ink);
    text-decoration: none;
}

@media (max-width: 1200px) {
    /* On narrow screens prefer compact icon-only top controls instead of a burger */
    .mobile-menu-toggle { display: none; }
    /* place controls a bit lower so they don't overlap the centered logo */
    .top-controls { display: flex; gap: 8px; position: absolute; right: 12px; top: 18px; }
    .top-controls .theme-toggle, .top-controls .admin-link { padding: 6px; border-radius: 8px; }
    /* hide textual labels so controls are icon-only on mobile/tablet widths */
    .top-controls .btn-text { display: none; }
    /* ensure dark-mode text is hidden even if specificity/ordering interferes */
    .top-controls .theme-toggle .btn-text { display: none !important; }
    .top-controls .theme-toggle i, .top-controls .admin-link i { font-size: 1.1rem; }
    .mobile-nav { display: none; }
    /* give extra top spacing inside header-content to avoid overlap */
    .header-content { padding-top: 1.4rem; }
}

@media (max-width: 360px) {
    .top-controls { right: 4px; }
    .top-controls .theme-toggle, .top-controls .admin-link { padding: 4px; }
}

.galleon-icon {
    height: 80px;
    vertical-align: middle;
    margin-right: 10px;
    /* Dark Ink Tint for Sepia Theme */
    filter: sepia(100%) saturate(100%) hue-rotate(350deg) brightness(30%) drop-shadow(2px 2px 0px rgba(0,0,0,0.2));
    transition: filter 0.3s;
}

[data-theme="dark"] .galleon-icon {
    /* Steel/Silver for Dark Mode */
    filter: invert(70%) grayscale(100%) brightness(130%) drop-shadow(2px 2px 0px #000);
}
