* {
    box-sizing: border-box; /* This prevents padding from adding to width */
}

:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --box-bg: #F0F0F0;
    --accent: #ffc300;
    --header-text: #ffffff;
    --star-visibility: hidden;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden; 
    margin: 0;
    padding: 0;
    position: relative;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    /* Adding a transition ensures a smooth shift, not a jarring flash */
    transition: background-color 0.4s ease; 
}

body.dark-mode {
    --bg-color: #000814;
    --text-color: #e0e0e0;
    --box-bg: #001d3d;
    --accent: #ffc300;
    --header-text: #000000;
    --star-visibility: visible;
}

#star-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    /* Remove fixed background here so it doesn't block the body */
    background: transparent; 
    overflow: hidden;
    visibility: var(--star-visibility);
}

.site-wrapper {
    display: grid;
    grid-template-columns: 1fr 4.5fr 1fr; 
    gap: 15px;
    width: 95%;
    max-width: 1400px;
    overflow-x: hidden;
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
}

.site-wrapper.downloads-layout #main-column {
    grid-column: 2 / 4;
}

.site-wrapper.wiki-layout {
    grid-template-columns: 250px 1fr; /* Two columns: Sidebar and expanding Center */
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Ensure the main content in the wiki spans correctly */
.wiki-layout .main-content {
    grid-column: 2; 
}

.header-banner {
    grid-column: 1 / 4; 
    display: flex;
    justify-content: center;
    padding: 20px 0;
    border-bottom: 2px solid var(--accent);
}

.logo {
    max-width: 450px;
    height: auto;
}

.ticker-zone {
    grid-column: 1 / 4;
    background: var(--accent);
    color: var(--header-text);
    overflow: hidden; /* This acts as the 'window' */
    white-space: nowrap;
    padding: 8px 0;
    display: flex; /* Ensures the child aligns correctly */
}

.ticker-text {
    display: inline-block;
    padding-left: 100%; /* Forces the text to start completely off-screen to the right */
    font-weight: bold;
    text-transform: uppercase;
    animation: marquee 20s linear infinite; /* Adjusted speed for readability */
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

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

.box {
    border: 1px solid var(--text-color);
    padding: 15px;
    background: var(--box-bg);
    text-align: center;
    overflow: hidden;
}

.box-header {
    background-color: var(--accent);
    color: var(--header-text);
    margin: -15px -15px 15px -15px; 
    padding: 5px 10px;
    font-weight: bold;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.latest-update-link {
    text-align: right;
    margin-top: 15px;
}

.latest-update-link a {
    text-decoration: none;
}

.latest-update-link a:hover {
    text-decoration: underline;
}

.featured-content {
    border: 2px solid var(--accent);
    box-shadow: 0 0 15px rgba(255, 195, 0, 0.1);
}

.episode-navigation {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px 20px;

    width: 100%;
    max-width: 800px;

    margin: 20px auto 10px;
}

.episode-navigation-button {
    flex: 1;

    padding: 12px 18px;

    border: 1px solid #888;
    border-radius: 4px;

    background: rgba(255, 255, 255, 0.08);
    color: inherit;

    font-family: inherit;
    font-size: 0.95rem;
    font-weight: bold;

    cursor: pointer;

    transition:
        background 0.2s ease,
        opacity 0.2s ease,
        transform 0.2s ease;
}

.episode-navigation-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.episode-navigation-button:disabled {
    opacity: 0.35;
    cursor: default;
    transform: none;
}

.episode-navigation-secondary {
    width: 100%;

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;

    margin-top: 2px;
}

.episode-navigation-small-button {
    padding: 6px 12px;

    border: 1px solid #888;
    border-radius: 4px;

    background: rgba(255, 255, 255, 0.05);
    color: inherit;

    font-family: inherit;
    font-size: 0.8rem;

    cursor: pointer;

    transition:
        background 0.2s ease,
        opacity 0.2s ease;
}

.episode-navigation-small-button:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* --- DOWNLOADS --- */

.downloads-box {
    text-align: left;
}

.downloads-navigation {
    display: flex;
    justify-content: center;
    gap: 30px;
    border-bottom: 1px solid var(--accent);
    padding-bottom: 15px;
    margin-bottom: 30px;
}

.downloads-navigation a {
    color: var(--text-color);
    font-weight: bold;
    text-decoration: none;
}

.downloads-navigation a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.downloads-section {
    margin-bottom: 45px;
    scroll-margin-top: 20px;
}

.downloads-section h2 {
    border-bottom: 1px solid var(--accent);
    padding-bottom: 8px;
    margin-bottom: 25px;
}

.download-item {
    display: flex;
    align-items: flex-start;
    gap: 30px;
}

.download-image {
    flex: 0 0 280px;
}

.download-image img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--accent);
}

.download-info {
    flex: 1;
    text-align: left;
}

.download-info h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.download-info p {
    line-height: 1.6;
    margin-bottom: 20px;
}

.download-button {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid var(--accent);
    color: var(--text-color);
    text-decoration: none;
    font-weight: bold;
    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.download-button:hover {
    background: var(--accent);
    color: var(--header-text);
}

@media (max-width: 600px) {

    .downloads-navigation {
        flex-wrap: wrap;
        gap: 15px 20px;
    }

    .download-item {
        flex-direction: column;
        gap: 20px;
    }

    .download-image {
        flex: none;
        width: 100%;
        max-width: 350px;
        margin: 0 auto;
    }

    .download-info {
        width: 100%;
    }
}

@media (max-width: 600px) {

    .episode-navigation {
        gap: 10px;
    }

    .episode-navigation-button {
        padding: 10px 8px;
        font-size: 0.85rem;
    }

    .episode-navigation-small-button {
        padding: 5px 9px;
        font-size: 0.75rem;
    }
}

.centered-header {
    text-align: center;
    border-bottom: 1px solid var(--accent);
    padding-bottom: 10px;
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-links li {
    margin-bottom: 8px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: bold;
    display: block;
    padding: 5px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.nav-links a.active {
    font-weight: bold;
    color: #ff9900;
    border-left: 3px solid #ff9900;
    padding-left: 5px;
}

.nav-links a:hover {
    background: rgba(255, 195, 0, 0.1);
    border-left: 3px solid var(--accent);
    padding-left: 10px;
    transition: all 0.2s ease;
}

#archive-list {
    max-height: 1150px;
    overflow-y: auto;
    padding-right: 10px;
}

#archive-list::-webkit-scrollbar {
    width: 8px;
}

#archive-list::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}

#archive-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

.panel-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
}

.quote-box {
    border-left: 4px solid var(--accent);
}

.quote-box p {
    margin: 10px 0;
    font-style: italic;
} /* SEALED */

.quote-box small {
    display: block;
    text-align: right;
    font-style: italic;
    opacity: 0.8;
}

/* --- THEME CONTROLS ALIGNMENT --- */
.theme-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 0;
}

.theme-controls span {
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    background-color: var(--text-color);
    border-radius: 50%;
    opacity: 0.3;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dot.active, .dot:hover {
    background-color: var(--accent);
    opacity: 1;
    transform: scale(1.2);
    box-shadow: 0 0 8px var(--accent);
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The actual slider track */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc; /* Grey when 'Off' (Day) */
    transition: .4s;
    border-radius: 34px;
}

/* The circle inside the slider */
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 4px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.episode-lore-box {
    text-align: left;
    padding: 15px;
    line-height: 1.6;
    background: rgba(0, 0, 0, 0.05); /* Slight tint to separate it from the art */
    border-radius: 8px;
    margin-top: 10px;
}

body.dark-mode .episode-lore-box {
    background: rgba(255, 255, 255, 0.05); /* Lighter tint for Night Mode */
}

.episode-info-zone {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed var(--accent);
    text-align: left;
}

.info-header {
    font-size: 0.9rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

/* When checked (Night), change track to Gold */
input:checked + .slider {
    background-color: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

/* When checked, move the circle to the right */
input:checked + .slider:before {
    transform: translateX(24px);
}

.wiki-landing {
    display: flex;
    flex-direction: column;
    align-items: center; /* Centers the title and links */
}

.wiki-main-title {
    font-size: 3rem;
    color: var(--accent);
    letter-spacing: 5px;
    text-transform: uppercase;
    margin-bottom: 30px;
    text-align: center;
}

.wiki-body-text {
    width: 100%;
    text-align: left;
    line-height: 1.6;
    font-size: 1.2rem;
    line-height: 1.8;
    margin-bottom: 40px;
    padding: 0 30px;
    box-sizing: border-box;
}

.wiki-quick-links {
    display: flex;
    gap: 30px;
    border-top: 1px solid var(--accent);
    padding-top: 20px;
    width: 100%;
    justify-content: center;
}

.wiki-quick-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: bold;
    letter-spacing: 2px;
    transition: color 0.3s ease;
}

.wiki-quick-links a:hover {
    color: var(--accent);
}

/* Custom Wiki Logic */
.wiki-title-centered {
    font-size: 2.5rem;
    color: var(--accent);
    text-align: center;
    border-bottom: 2px solid var(--accent);
    margin-bottom: 30px;
    padding-bottom: 15px;
    width: 100%;
    max-width: calc(100% - 60px); 
    margin: 0 auto 30px auto;
}

.wiki-profile-img {
    float: right;
    width: 200px;
    max-width: 45%; 
    height: auto;
    margin-left: 20px;
    margin-bottom: 15px;
    border: 1px solid var(--accent);
    background: var(--box-bg);
}

.wiki-contents-box {
    text-align: left;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--accent);
    padding: 20px;
    margin-left: 30px;
    margin-bottom: 30px;
    font-size: 1.1rem;
    display: table; /* Shrinks to fit text width */
}

body.dark-mode .wiki-contents-box {
    background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 800px) {
    .site-wrapper {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding: 5px;
    }

    .wiki-quick-links {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .wiki-body-text {
        padding: 0 15px;
        font-size: 1.1rem;
        line-height: 1.6;
    }
    
    .wiki-main-title {
        font-size: 2rem;
    }

    .wiki-profile-img {
        float: none;
        display: block;
        width: 100%;
        max-width: 100%;
        margin: 0 0 20px 0;
    }

    .header-banner, .ticker-zone {
    width: 100%; /* Ensures they span the full width of the phone screen */
    }

    body {
        background-color: var(--bg-color) !important; 
        color: var(--text-color);
    }

    body.dark-mode {
        background-color: var(--bg-color) !important;
        color: var(--text-color);
    }

/* Ensure the star container doesn't have a 'ghost' background */
#star-container {
    background-color: transparent !important;
}
}
