/* Real Madrid Premium Theme */
:root {
    --rm-gold: #FEBE10;
    --rm-blue: #00529F;
    --rm-white: #FFFFFF;
    --rm-dark: #0a1018;
    /* Darker blue-black for contrast */
    --rm-silver: #E1E1E1;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow-premium: 0 10px 40px rgba(0, 82, 159, 0.2);
    --font-heading: 'Cinzel', serif;
    /* Elegant serif for headings */
    --font-body: 'Montserrat', sans-serif;
}

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Montserrat:wght@300;400;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: #f5f5f7;
    background-image: radial-gradient(circle at top right, rgba(0, 82, 159, 0.1), transparent 40%),
        radial-gradient(circle at bottom left, rgba(254, 190, 16, 0.1), transparent 40%);
    background-attachment: fixed;
    color: var(--rm-dark);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(0, 82, 159, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.5rem;
    /* Reduced padding */
    flex-wrap: nowrap;
    /* Prevent wrapping */
}

.logo {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    /* Reduced from 1.8rem */
    font-weight: 700;
    color: var(--rm-blue);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    /* Reduced from 15px */
    white-space: nowrap;
    /* Prevent text wrapping */
    flex-shrink: 0;
    /* Prevent shrinking */
}

.header-logo {
    height: 40px;
    /* Reduced from 48px */
    width: auto;
    object-fit: contain;
}

.logo span {
    color: var(--rm-gold);
}

.nav-links {
    display: flex;
    gap: 20px;
    /* Reduced from 30px */
    flex-shrink: 0;
}

.nav-links a {
    text-decoration: none;
    color: var(--rm-dark);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
    position: relative;
    transition: color 0.3s;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--rm-gold);
    transition: width 0.3s ease;
}

.nav-links a:hover {
    color: var(--rm-blue);
}

.nav-links a:hover::after {
    width: 100%;
}

/* Hero Section */
.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(135deg, #fff 0%, #f0f4f8 100%);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(254, 190, 16, 0.05) 0%, transparent 60%);
    animation: rotate 60s linear infinite;
}

@keyframes rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.hero-content {
    z-index: 10;
    max-width: 800px;
    padding: 2rem;
}

.hero h1 {
    font-family: var(--font-heading);
    font-size: 5rem;
    color: var(--rm-blue);
    margin-bottom: 1rem;
    line-height: 1.1;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
    opacity: 0;
    animation: fadeInUp 1s ease forwards 0.5s;
}

.hero p {
    font-size: 1.5rem;
    color: #666;
    margin-bottom: 2rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    opacity: 0;
    animation: fadeInUp 1s ease forwards 0.8s;
}

.cta-button {
    display: inline-block;
    padding: 1rem 3rem;
    background: var(--rm-blue);
    color: white;
    text-decoration: none;
    font-weight: 600;
    border-radius: 50px;
    box-shadow: 0 10px 20px rgba(0, 82, 159, 0.3);
    transition: all 0.4s ease;
    opacity: 0;
    animation: fadeInUp 1s ease forwards 1.1s;
    border: 2px solid transparent;
}

.cta-button:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0, 82, 159, 0.4);
    background: white;
    color: var(--rm-blue);
    border-color: var(--rm-blue);
}

/* Sections */
section {
    padding: 8rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.section-title {
    text-align: center;
    font-family: var(--font-heading);
    font-size: 3rem;
    color: var(--rm-dark);
    margin-bottom: 4rem;
    position: relative;
    display: inline-block;
    width: 100%;
}

.section-title::after {
    content: '';
    display: block;
    width: 80px;
    height: 4px;
    background: var(--rm-gold);
    margin: 1rem auto 0;
}

/* History Timeline styled cards */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
}

.history-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.history-card {
    background: white;
    padding: 3rem 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow-premium);
    transition: transform 0.4s ease;
    border-top: 5px solid var(--rm-gold);
    text-align: center;
}

.history-card:hover {
    transform: translateY(-10px);
}

.year {
    font-size: 3rem;
    font-weight: 700;
    color: rgba(0, 82, 159, 0.1);
    margin-bottom: -1.5rem;
    display: block;
    font-family: var(--font-heading);
}

.history-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--rm-blue);
}

/* Squad Grid */
.squad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.player-card {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    transition: all 0.4s ease;
    position: relative;
}

.player-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.player-img-placeholder {
    height: 350px;
    background: linear-gradient(to top, #cfd9df 0%, #e2ebf0 100%);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: relative;
    overflow: hidden;
}

/* Dynamic CSS generated jersey */
.jersey {
    width: 150px;
    height: 180px;
    background: white;
    border-radius: 20px 20px 0 0;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
}

.jersey::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid #f0f0f0;
}

.jersey::after {
    content: '';
    /* Stripe */
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent 40%, var(--rm-gold) 45%, var(--rm-gold) 55%, transparent 60%);
    opacity: 0.3;
}

.player-info {
    padding: 1.5rem;
    text-align: center;
}

.player-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.05);
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-family: var(--font-heading);
}

.player-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--rm-dark);
    margin-bottom: 0.5rem;
}

.player-pos {
    color: var(--rm-blue);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.player-desc {
    font-size: 0.9rem;
    color: #555;
    margin-top: 0.8rem;
    line-height: 1.5;
    border-top: 1px solid #eee;
    padding-top: 0.8rem;
}

/* Timeline Styles */
.timeline-section {
    position: relative;
    padding: 4rem 2rem;
    max-width: 1000px;
    margin: 0 auto;
}

.timeline {
    position: relative;
}

/* Vertical Line */
.timeline::after {
    content: '';
    position: absolute;
    width: 4px;
    background-color: var(--rm-gold);
    top: 0;
    bottom: 0;
    left: 20px;
    /* Left aligned line */
    margin-left: -2px;
}

.timeline-item {
    padding: 10px 40px;
    position: relative;
    background-color: inherit;
    width: 100%;
    margin-bottom: 2rem;
    opacity: 0;
    animation: fadeInUp 0.5s ease forwards;
}

.timeline-item:nth-child(2) {
    animation-delay: 0.1s;
}

.timeline-item:nth-child(3) {
    animation-delay: 0.2s;
}

.timeline-item:nth-child(4) {
    animation-delay: 0.3s;
}

.timeline-item:nth-child(5) {
    animation-delay: 0.4s;
}

.timeline-item:nth-child(6) {
    animation-delay: 0.5s;
}

/* Add more delays if needed, but CSS limits usually stop here for hardcoded ones */

/* The Circle */
.timeline-item::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    right: auto;
    left: 10px;
    background-color: white;
    border: 4px solid var(--rm-blue);
    top: 25px;
    border-radius: 50%;
    z-index: 1;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.timeline-item:hover::after {
    background-color: var(--rm-gold);
    transform: scale(1.2);
}

.timeline-content {
    padding: 2rem;
    background-color: white;
    position: relative;
    border-radius: 15px;
    box-shadow: var(--shadow-premium);
    border-left: 5px solid var(--rm-gold);
}

.timeline-year {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: rgba(0, 82, 159, 0.1);
    position: absolute;
    top: 10px;
    right: 20px;
    line-height: 1;
}

.timeline-title {
    font-size: 1.5rem;
    color: var(--rm-blue);
    margin-bottom: 1rem;
    font-weight: 700;
    padding-right: 3rem;
    /* Space for year */
}

.timeline-text {
    font-size: 1rem;
    color: #555;
    line-height: 1.6;
}

/* Response for larger screens to center line? 
   Actually, keeping it left-aligned is cleaner for reading flow 
   and safer for varying text lengths. */

.trophy-section {
    background: var(--rm-dark);
    color: white;
    padding: 6rem 2rem;
    margin-top: 4rem;
    border-radius: 40px;
    position: relative;
    overflow: hidden;
}

.trophy-count {
    font-size: 8rem;
    font-weight: 700;
    color: var(--rm-gold);
    line-height: 1;
    font-family: var(--font-heading);
    text-shadow: 0 0 40px rgba(254, 190, 16, 0.4);
}

.trophy-label {
    font-size: 2rem;
    margin-bottom: 2rem;
}

/* Footer */
footer {
    background: white;
    padding: 4rem 2rem;
    text-align: center;
    border-top: 1px solid #eee;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.social-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #f5f5f7;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    color: var(--rm-dark);
    font-size: 1.2rem;
}

.social-icon:hover {
    background: var(--rm-blue);
    color: white;
    transform: scale(1.1);
}

/* Animations */
@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Archive Table Styles */
.archive-section {
    padding: 120px 2rem 4rem 2rem;
    /* merged padding */
    max-width: 1400px;
    /* Increased width */
    margin: 0 auto;
    background: #f9f9f9;
}

.archive-container {
    overflow-x: auto;
    box-shadow: var(--shadow-premium);
    border-radius: 10px;
    background: white;
}

.archive-table {
    width: 100%;
    border-collapse: collapse;
    /* Remove min-width or keep it small to allow fitting in container */
    min-width: 500px;
}

.archive-table th,
.archive-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    white-space: normal;
    /* Allow wrapping */
    vertical-align: middle;
    font-size: 0.9rem;
    color: var(--rm-blue);
    font-weight: 700;
}

/* Make headers slightly smaller too to match or keep distinct? */
/* Header rule below sets it to 0.9rem already, so tds match now. */

/* Ensure the cell icons align vertically with the text */
.archive-table td {
    vertical-align: middle;
}

.archive-table th {
    background-color: var(--rm-dark);
    color: var(--rm-gold);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.archive-table tr:nth-child(even) {
    background-color: #fafafa;
}

.archive-table tr:hover {
    background-color: rgba(254, 190, 16, 0.05);
}

.result-winner {
    font-weight: 700;
    color: var(--rm-blue);
    background-color: rgba(254, 190, 16, 0.1) !important;
}

.trophy-icon {
    color: var(--rm-gold);
    margin-right: 5px;
}

.season-cell {
    font-weight: 600;
    color: #333;
}

/* History Narrative Row Styles */
.narrative-row td.season-narrative {
    padding-top: 0.5rem;
    padding-bottom: 2rem;
    padding-left: 2rem;
    padding-right: 2rem;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--rm-blue);
    /* Unified to Blue */
    font-weight: 500 !important;
    border-bottom: 2px solid #aaa !important;
    /* Stronger visible separator */
}

/* Hide border between main row and narrative row */
.archive-table tr:not(.narrative-row) td {
    border-bottom: none;
}

.narrative-row {
    background-color: inherit;
    /* Should inherit from result-winner */
}


/* Default Mobile Menu Button (Hidden on Desktop) */
.mobile-menu-btn {
    display: none;
}

/* Decade Navigation */
.decade-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    position: sticky;
    top: 100px;
    /* Adjusted to match Header Height (approx 100px) */
    background: rgba(255, 255, 255, 0.95);
    padding: 1rem;
    z-index: 900;
    /* Below header */
    border-bottom: 1px solid var(--rm-gold);
    backdrop-filter: blur(5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
    .decade-nav {
        top: 90px;
        /* Match smaller mobile header height */
    }
}

.decade-link {
    color: var(--rm-dark);
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 20px;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.decade-link:hover {
    background: var(--rm-gold);
    color: var(--rm-blue);
    border-color: var(--rm-gold);
    transform: translateY(-2px);
}

/* Anchor Offset Hack for Robust Scroll Positioning */
/* Anchor Offset Hack for Robust Scroll Positioning */
.decade-offset-anchor {
    display: block;
    position: relative;
    top: -220px;
    /* Offset to clear Header + Nav + Extra Buffer */
    visibility: hidden;
    height: 0;
    width: 0;
}

@media (max-width: 768px) {
    .decade-offset-anchor {
        top: -320px;
        /* Larger offset for Mobile wrapped nav */
    }
}

/* Season Detail Page Styles */
.season-hero {
    position: relative;
    height: 40vh;
    min-height: 300px;
    background: linear-gradient(135deg, var(--rm-blue) 0%, #001f3f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    margin-top: 60px;
    /* Header height */
    overflow: hidden;
}

.season-hero-content {
    z-index: 2;
    position: relative;
}

.season-hero h1 {
    font-size: 3rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1rem;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    background: linear-gradient(to right, #fff, var(--rm-gold));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.trophy-badges {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.trophy-badge {
    background: rgba(254, 190, 16, 0.2);
    border: 1px solid var(--rm-gold);
    border-radius: 50px;
    padding: 0.5rem 1.5rem;
    color: var(--rm-gold);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    backdrop-filter: blur(5px);
}

.season-detail-container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.back-link {
    display: inline-block;
    margin-bottom: 2rem;
    color: var(--rm-blue);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.3s;
}

.back-link:hover {
    color: var(--rm-gold);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: var(--shadow-light);
    border-top: 3px solid var(--rm-gold);
    text-align: center;
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: #777;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}


.history-pixel-art {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    /* Optional: Ensure they don't get too big if container allows, but usually width is auto */
    /* width: 48px; usually set by inline or other css? Check js */
    vertical-align: middle;
    margin-right: 4px;
    height: auto;
    width: 32px;
    /* Set a default reasonable width if not set */
}


/* Layout Split */
.detail-split {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3rem;
}

@media (max-width: 900px) {
    .detail-split {
        grid-template-columns: 1fr;
    }
}

/* Prevent Grid Blowout */
.detail-main,
.detail-sidebar {
    min-width: 0;
}

.season-section {
    margin-bottom: 3rem;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-premium);
}

.section-title-sm {
    font-size: 1.5rem;
    color: var(--rm-dark);
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
    display: inline-block;
}

.season-text {
    line-height: 1.8;
    color: #444;
    font-size: 1.05rem;
    text-align: justify;
}

/* Matches Table */
.matches-table {
    width: 100%;
    border-collapse: collapse;
}

.matches-table th,
.matches-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.matches-table th {
    background: #f4f4f4;
    font-size: 0.9rem;
    color: #555;
}

/* Transfer Box */
.transfer-box {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.transfer-group h4 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.transfer-group.in h4 {
    color: #2ecc71;
}

.transfer-group.out h4 {
    color: #e74c3c;
}

.transfer-group ul {
    list-style: none;
    padding: 0;
}

.transfer-group li {
    padding: 0.5rem 0;
    border-bottom: 1px dashed #eee;
    font-size: 0.95rem;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {

    /* Navigation */
    .nav-container {
        padding: 1rem;
    }

    .logo {
        font-size: 0.8rem;
        /* Further reduced to 0.8rem to accommodate English title */
        white-space: nowrap;
        /* Prevent wrapping */
        flex-shrink: 1;
        /* Allow shrinking if absolutely needed */
    }


    .mobile-menu-btn {
        display: block;
        font-size: 1.5rem;
        cursor: pointer;
        color: var(--rm-blue);
        z-index: 2000;
        /* Ensure on top of everything */
        margin-left: auto;
        /* Force right alignment */
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        height: 100vh;
        background: rgba(255, 255, 255, 0.98);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        transition: right 0.3s ease;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        z-index: 1000;
        display: flex;
    }

    .nav-links.active {
        right: 0;
    }

    .nav-links a {
        font-size: 1.2rem;
        margin: 1rem 0;
        width: 100%;
        text-align: center;
    }

    .nav-links a::after {
        display: none;
        /* simple hover effect on mobile */
    }

    /* Hero Typography */
    .hero h1 {
        font-size: 3rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .section-title {
        font-size: 2rem;
        margin-bottom: 2.5rem;
    }

    .section-title::after {
        margin-top: 0.5rem;
    }

    /* Sections Padding */
    section,
    .archive-section,
    .timeline-section,
    .trophy-section {
        padding: 4rem 1.5rem;
    }

    .hero-content {
        padding: 1rem;
    }

    /* Timeline */
    .timeline::after {
        left: 15px;
    }

    .timeline-item {
        padding-left: 50px;
        padding-right: 10px;
        text-align: left;
    }

    .timeline-item::after {
        left: 5px;
        width: 16px;
        height: 16px;
    }

    .timeline-year {
        position: relative;
        top: auto;
        right: auto;
        font-size: 2rem;
        margin-bottom: 0.5rem;
        display: block;
    }

    .timeline-title {
        padding-right: 0;
    }

    /* Tables */
    .archive-table th,
    .archive-table td {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    /* Formation Pitch */
    .formation-pitch {
        width: 100% !important;
        height: auto;
        aspect-ratio: 3/4;
        /* Ensure vertical pitch ratio */
        background-size: cover;
    }

    .player-token {
        transform: translate(-50%, -50%) scale(0.8);
        /* Scale down players */
    }

    .player-name-label {
        font-size: 10px;
        /* Smaller text */
        background: rgba(0, 0, 0, 0.7);
        /* Better readability */
        padding: 2px 6px;
    }

    /* Trophies */
    .trophy-count {
        font-size: 5rem;
    }

    .trophy-label {
        font-size: 1.5rem;
    }

    /* Season Detail */
    .season-hero {
        height: 30vh;
        min-height: 250px;
    }

    .season-hero h1 {
        font-size: 2rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-card p {
        font-size: 1rem;
    }

    .detail-split {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    /* Table Wrapper for mobile scroll */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
        box-shadow: var(--shadow-light);
        box-shadow: var(--shadow-light);
        border-radius: 8px;
    }

    /* Mobile Decade Nav Override */
    .decade-nav {
        justify-content: flex-start;
        overflow-x: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
        padding-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
        border-bottom: none;
        /* Remove border to cleaner look */
    }

    .decade-link {
        flex: 0 0 auto;
        /* Prevent shrinking */
    }
}


/* Formation Pitch Styles */
.formation-section {
    grid-column: 1 / -1;
    /* Take full width if possible, or adjust based on layout */
    margin-top: 2rem;
    text-align: center;
}

.formation-pitch {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 700px;
    /* Vertical pitch */
    background-color: #4CAF50;
    /* Grass green */
    margin: 0 auto;
    border: 5px solid white;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    /* Grass pattern */
    background-image:
        repeating-linear-gradient(0deg,
            transparent,
            transparent 50px,
            rgba(0, 0, 0, 0.05) 50px,
            rgba(0, 0, 0, 0.05) 100px);
}

/* Pitch Markings */
.pitch-line {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.8);
}

.pitch-center-line {
    width: 100%;
    height: 2px;
    top: 50%;
    left: 0;
}

.pitch-center-circle {
    width: 120px;
    height: 120px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    position: absolute;
}

.pitch-penalty-area-top {
    width: 60%;
    height: 16%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-top: none;
    top: 0;
    left: 20%;
    position: absolute;
}

.pitch-penalty-area-bottom {
    width: 60%;
    height: 16%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-bottom: none;
    bottom: 0;
    left: 20%;
    position: absolute;
}

/* Player Token */
.player-token {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80px;
    text-align: center;
    z-index: 10;
    cursor: pointer;
    transition: transform 0.2s;
}

.player-token:hover {
    transform: translate(-50%, -50%) scale(1.1);
    z-index: 20;
}

/* Player icons in episode text */
.player-episode-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    transition: transform 0.2s;
    cursor: pointer;
    image-rendering: pixelated;
}

.player-episode-icon:hover {
    transform: scale(1.5);
}

.player-dot {
    width: 36px;
    height: 36px;
    background: white;
    border: 3px solid var(--rm-blue);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.8rem;
    color: var(--rm-dark);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    margin-bottom: 4px;
    background-image: url('https://upload.wikimedia.org/wikipedia/en/thumb/5/56/Real_Madrid_CF.svg/1200px-Real_Madrid_CF.svg.png');
    background-size: cover;
    background-position: center;
}

/* Fallback if image doesn't load or just use number/color */
.player-dot.no-img {
    background: white;
}

.player-name-label {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    text-shadow: 0 1px 2px black;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.squad-list {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.squad-list li {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem;
    border-left: 3px solid var(--rm-blue);
    font-weight: 500;
}

/* Fix Formation Pitch Mobile Height Override */
@media (max-width: 768px) {
    .formation-pitch {
        height: auto !important;
        aspect-ratio: 3/5;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--rm-gold);
    color: var(--rm-dark);
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-size: 1.2rem;
    align-items: center;
    justify-content: center;
    display: flex;
    transition: all 0.3s ease;
    z-index: 999;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--rm-blue);
    color: white;
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* Pixel Art Player Icons */
.player-token.has-image {
    width: 85px;
    height: 85px;
    transform: translate(-50%, -50%);
    /* Correct centering */
    z-index: 10;
}

.player-pixel-art {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
    animation: bounce 2s infinite ease-in-out;
}

.player-token.has-image .player-name-label {
    position: absolute;
    top: 80px;
    /* Position below image */
    background: rgba(0, 0, 0, 0.8);
    font-weight: bold;
    color: #FEBE10;
    border: 1px solid #FEBE10;
    width: auto;
    min-width: 60px;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* History Page Pixel Art */
.history-pixel-art {
    height: 36px;
    width: auto;
    vertical-align: middle;
    margin-right: 2px;
    /* Close spacing as requested */
    margin-left: 0;
    image-rendering: pixelated;
    transition: transform 0.2s;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.history-pixel-art:hover {
    transform: scale(2.5);
    z-index: 100;
    position: relative;
}

.player-name-with-icon {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    vertical-align: middle;
    /* Ensure the text-icon wrapper aligns to middle of line */
}

/* Ensure all elements in cells align middle */
.archive-table td span,
.archive-table td {
    vertical-align: middle;
}

/* Flexbox fix for Transfers alignment */
.transfer-row {
    display: flex;
    align-items: center;
    /* Vertically center the label relative to content */
    margin-bottom: 6px;
}

.transfer-content {
    flex: 1;
    display: flex;
    align-items: center;
    /* Vertically center text and icons mixed together */
    flex-wrap: wrap;
    /* Allow wrapping */
    gap: 0;
    /* Let text spaces handle spacing, or small gap? Text nodes have spaces. */
    line-height: 1.5;
}

/* Ensure text nodes inside align with icons */
.transfer-content>* {
    display: inline-flex;
    align-items: center;
}

/* Since text nodes aren't elements, we can't target them directly with > *. 
   But the flex-wrap on parent implicitly wraps them. 
   The align-items: center on parent handles vertical alignment of text nodes relative to icons!
*/

/* Remove vertical-align from pixel art as flex handles it now? 
   No, keep it safe. */

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        gap: 0;
        /* Let space-between handle it */
        padding: 1rem;
    }

    /* Ensure Squad List fits */
    .squad-list {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }

    .nav-links {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }

    .archive-section {
        padding: 160px 10px 40px 10px;
        /* Increased top padding for stacked header */
    }

    /* --- Mobile Card View --- */
    .archive-table {
        display: block;
        min-width: 0;
        /* Remove min-width constrain */
    }

    .archive-table thead {
        display: none;
        /* Hide standard header */
    }

    .archive-table tbody {
        display: block;
    }

    .archive-table tr {
        display: block;
        margin-bottom: 1.5rem;
        background: white;
        border-radius: 12px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
        border: 1px solid #eee;
        overflow: hidden;
    }

    .archive-table td {
        display: block;
        text-align: left;
        padding: 1rem;
        border-bottom: 1px solid #f5f5f5;
        font-size: 0.9rem;
        position: relative;
    }

    .archive-table td:last-child {
        border-bottom: none;
    }

    /* Add Labels via CSS */
    .archive-table td.season-cell {
        background: var(--rm-dark);
        color: var(--rm-gold);
        font-size: 1.2rem;
        font-weight: bold;
        text-align: center;
        padding: 0.8rem;
    }

    .archive-table td.season-cell a {
        color: var(--rm-gold);
        text-decoration: none;
    }

    /* Specific Column Labels */
    /* Nth-of-type logic relies on creating labels above content */

    /* Helper to style label - Applied to specific children below */
    .archive-table td::before {
        display: block;
        font-size: 0.75rem;
        color: #888;
        font-weight: 600;
        text-transform: uppercase;
        margin-bottom: 4px;
    }

    /* Row 2: Manager */
    .archive-table td:nth-of-type(2)::before {
        content: "監督";
    }

    /* Row 3: Best Player */
    .archive-table td:nth-of-type(3)::before {
        content: "MVP / 得点王";
    }

    /* Row 4: Transfers */
    .archive-table td:nth-of-type(4)::before {
        content: "移籍市場";
    }

    /* Row 5: Liga */
    .archive-table td:nth-of-type(5)::before {
        content: "LIGA";
    }

    /* Row 6: UCL */
    .archive-table td:nth-of-type(6)::before {
        content: "UCL / EUROPE";
    }


    /* --- Matches Table Responsive Fix (Scoped) --- */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
        scrollbar-width: thin;
        /* Firefox */
    }

    .matches-table {
        width: 100%;
        min-width: 600px;
        /* Ensure table has enough width, forcing scroll */
        border-collapse: collapse;
    }

    .matches-table th,
    .matches-table td {
        padding: 12px 10px;
        text-align: left;
        border-bottom: 1px solid #eee;
        font-size: 0.9rem;
        white-space: nowrap;
        /* Keep rows single line by default */
    }

    .matches-table th {
        background-color: #f8f9fa;
        font-weight: 600;
        color: var(--rm-dark);
    }

    /* Scorer Column (4th) - Allow width but strictly control wrapping */
    .matches-table th:nth-child(4),
    .matches-table td:nth-child(4) {
        min-width: 200px;
        /* reduced slightly to be safe, but enough for names */
        white-space: normal;
        /* Allow wrapping if text is genuinely too long, but min-width prevents crushing */
        max-width: 300px;
    }

    /* Narrative Row Styling */
    .archive-table tr.narrative-row {
        margin-top: -1.5rem;
        /* Pull up to join previous card visually? Or separate? */
        /* Let's keep it separate or merged. 
           Actually, structure is: TR(data) TR(narrative).
           If we want them to look like one card, we need to style differently.
           But simple approach: Narrative is its own card, or attached?
           Let's make narrative row attach to the top one by removing top rounded corners and margin.
        */
        box-shadow: none;
        background: transparent;
        border: none;
        margin-bottom: 2rem;
    }

    .archive-table tr.narrative-row td {
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
        border: 1px solid #eee;
        padding: 1.2rem;
        font-style: italic;
    }

    /* Remove label for narrative */
    .archive-table td.season-narrative::before {
        content: none !important;
    }

    /* Merge Data Row and Narrative Row visually */
    /* The data row is the previous TR. It has margin-bottom 1.5rem. 
       We can't target "previous sibling" in CSS.
       So keep them separate but close? 
       Just keep them as two blocks. Data Block + Story Block.
    */

    /* Result Winner Styling in Card View */
    .result-winner td.season-cell {
        background: var(--rm-gold);
        /* Gold header for winners */
        color: var(--rm-dark);
        text-shadow: none;
    }

    .result-winner td.season-cell a {
        color: var(--rm-dark);
    }

    .result-winner {
        border: 2px solid var(--rm-gold);
        /* Highlight card */
        background-color: #fffaf0 !important;
    }

    /* Transfer styling adjustment */
    .transfer-row {
        flex-wrap: wrap;
        /* Already set but ensure it */
    }

    /* Smaller Icons for Mobile */
    .history-pixel-art {
        height: 24px;
    }

    .decade-nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }

    .decade-link {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
        margin-bottom: 5px;
    }

    .section-title {
        font-size: 1.5rem;
        margin-bottom: 2rem;
    }

    /* Mobile Formation Adjustments */
    .player-token {
        width: 14px;
        /* Anchor point size remains small? No, container should be substantial to hold label */
        /* Actually detailed layout relies on center transform. */
        /* Let's set a standard size for the container to align everything */
    }

    /* Resizing for better visibility */
    .player-token.has-image {
        width: 60px;
        height: 60px;
    }

    .player-token.has-image .player-name-label {
        top: 55px;
        /* Push label down */
        font-size: 0.7rem;
        padding: 1px 4px;
        width: 80px;
        min-width: unset;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    }

    /* Styles for players WITHOUT specific image (the "squashed" ones) */
    .player-token:not(.has-image) .player-dot {
        width: 40px;
        height: 40px;
        border-width: 3px;
        /* Thicker border */
    }

    .player-name-label {
        top: 45px;
        /* Align with bigger dot */
        font-size: 0.7rem;
    }

    .header-logo {
        height: 32px;
        /* Reduced for mobile */
    }

    .logo {
        font-size: 1.1rem;
        /* Slightly reduced */
        flex: 1;
        /* Allow logo to take space but not push menu too far if restricted */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .logo span {
        display: none;
        /* Hide '攻略サイト' on mobile to prevent overflow */
    }

    /* Hamburger Menu Visible */
    .mobile-menu-btn {
        display: block;
        /* Show on mobile */
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0 10px;
        color: var(--rm-dark);
        z-index: 1001;
        /* Above nav if needed */
    }

    .nav-links {
        display: none;
        /* Hide standard links by default on mobile */
        flex-direction: column;
        width: 100%;
        gap: 1rem;
        padding-top: 1rem;
        border-top: 1px solid #eee;
        margin-top: 1rem;
    }

    .nav-links.active {
        display: flex;
        /* Show when active */
    }
}

@import url('collection.css');