/* --- GLOBAL & BASE STYLES --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    /* Added horizontal padding for mobile safety */
    box-sizing: border-box;
    margin: 0;
    /* Fallback background */
    background: #1D2B64;
    color: #fff;
    /* Default text color for dark background */
    overflow-x: hidden;
    /* Prevent scrollbar from animations */
}

/* --- DREAMSCAPE BACKGROUND ANIMATION --- */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    /* Deep Night Sky Gradient */
    background: linear-gradient(to bottom, #0f2027, #203a43, #2c5364);
    overflow: hidden;
}

.stars {
    background: black url(http://www.script-tutorials.com/demos/360/images/stars.png) repeat top center;
    z-index: 0;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
    mix-blend-mode: screen;
    /* Ensures stars show but black background disappears */
    opacity: 0.6;
}

.twinkling {
    background: transparent url(http://www.script-tutorials.com/demos/360/images/twinkling.png) repeat top center;
    z-index: 1;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
    animation: move-twinkling 200s linear infinite;
    opacity: 0.5;
}

.clouds {
    background: transparent url(http://www.script-tutorials.com/demos/360/images/clouds3.png) repeat top center;
    z-index: 2;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
    animation: move-clouds 200s linear infinite;
    opacity: 0.3;
}

@keyframes move-twinkling {
    from {
        background-position: 0 0;
    }

    to {
        background-position: -10000px 5000px;
    }
}

@keyframes move-clouds {
    from {
        background-position: 0 0;
    }

    to {
        background-position: 10000px 0;
    }
}

/* --- GLASSMORPHISM CONTAINER --- */
.container {
    text-align: center;
    background: rgba(255, 255, 255, 0.2);
    /* Increased opacity slightly */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 2.5rem;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    width: 100%;
    max-width: 550px;
    animation: floatIn 0.8s ease-out;
    position: relative;
    z-index: 10;
}

@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    font-family: 'Pacifico', cursive;
    color: #FDEE87;
    /* Soft yellow/gold for contrast on dark background */
    /* Smart sizing: Minimum 1rem, Preferred 4vw, Maximum 1.8rem to fit container */
    font-size: clamp(1rem, 4vw, 1.8rem);
    font-weight: 400;
    line-height: 1.2;
    margin: 0 auto 1rem auto;
    /* Ensure centered block with bottom margin */
    text-align: center;
    /* Explicitly center text */
    width: 100%;
    /* Ensure full width for centering */
    text-shadow: 0 0 10px rgba(253, 238, 135, 0.3);
    /* Subtle glow */
    white-space: normal;
    /* Allow wrapping */
    overflow-wrap: break-word;
}

#story-output h1 {
    margin-top: 3rem;
    /* Space between button and title */
}

.story-paragraph {
    text-align: left;
    /* Changed from justify to fix spacing issues */
    text-indent: 2rem;
    margin-bottom: 1rem;
    line-height: 1.8;
}

.toc-container {
    display: table;
    /* Shrink to fit content */
    margin: 2rem auto;
    /* Center the block */
    text-align: left;
    /* Align text inside left */
    padding: 1.5rem;
    border: 1px solid rgba(253, 238, 135, 0.3);
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.the-end-container {
    text-align: center;
    margin-top: 2rem;
    font-size: 1.2rem;
    color: #FDEE87;
    /* Match title color for consistency */
}

h2 {
    color: #FDEE87;
    /* Yellow to match h1 and pop against dark background */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 1rem;
}

/* Keep dark for inside modal (which is white) */
.modal-content h2 {
    color: #1D2B64;
}

.modal-content p.content-text {
    color: #2c3e50;
    /* Dark grey for readability on white modal */
}

p.content-text {
    text-align: left;
    line-height: 1.7;
    color: #FFFFFF;
    /* White text for readability on dark background */
    font-size: 1.1rem;
}

/* --- FORM ELEMENTS --- */
.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    color: #FDEE87;
    /* Yellow label */
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-icon {
    font-size: 1.5rem;
    /* Make emoji icon slightly larger */
}

.magical-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    /* High opacity white */
    border: 2px solid #FDEE87;
    /* Yellow border */
    border-radius: 15px;
    padding: 15px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    color: #1D2B64;
    /* Dark text inside the white box */
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    /* Ensure select arrow is visible */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Add custom arrow for select if needed, or just let browser handle it for simplicity in vanilla. 
   For now, let's keep it simple but ensure padding is right. */
select.magical-input {
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%231D2B64%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 15px top 50%;
    background-size: 12px auto;
    padding-right: 40px;
}

.magical-input:focus {
    outline: none;
    border-color: #fff;
    box-shadow: 0 0 15px rgba(253, 238, 135, 0.5);
}

.headline-image {
    width: 100%;
    height: auto;
    margin: 1rem auto 2rem auto;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

/* Only animate if it's a link (i.e., on sub-pages) */
a .headline-image:hover {
    transform: scale(1.02) rotate(2deg);
    /* Twist effect */
    cursor: pointer;
}

/* --- MAGICAL BUTTONS --- */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center content horizontally */
    box-sizing: border-box;
    width: 100%;
    text-decoration: none;
    /* Original Yellow Background */
    background-color: #FDEE87;
    /* Original Light Blue Text */
    color: #5F99E3;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    border: none;
    /* Symmetric padding */
    padding: 18px 20px;
    border-radius: 50px;
    cursor: pointer;
    margin-top: 1.5rem;
    text-align: center;
}

.container .btn+.btn,
.container .btn+a.btn,
.container a.btn+.btn {
    margin-top: 1.2rem;
}

.btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Secondary Buttons (Future/Support) */
a.btn[href="/future.html"],
a.btn[href="/support.html"] {
    background-color: #FDEE87;
    color: #5F99E3;
}

/* Back Button (Inverted Theme) */
.btn-back {
    background-color: #5F99E3 !important;
    /* Light Blue Background */
    color: #FDEE87 !important;
    /* Yellow Text */
    justify-content: center;
    /* Ensure text is centered since it usually has no icon */
    padding-left: 20px;
    /* Reset padding since no icon */
}

.btn-back:hover {
    background-color: #4a8ad4 !important;
    /* Slightly darker blue on hover */
    transform: translateY(-4px) scale(1.02);
}

/* --- NAVIGATION ICONS --- */
.nav-icon {
    height: 50px;
    /* Slightly smaller to fit nicely in flex flow */
    width: 50px;
    position: static;
    /* Remove absolute positioning */
    transform: none;
    /* Remove centering transform */
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    flex-shrink: 0;
    /* Prevent icon from squishing */
}

.btn:hover .nav-icon {
    transform: rotate(-5deg) scale(1.1);
}

/* --- SCROLL INDICATOR --- */
#scroll-indicator {
    margin-top: 3rem;
    /* Increased from 1rem */
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

#scroll-indicator p {
    font-size: 1.2rem;
    color: #FDEE87;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}

/* --- SOCIAL MEDIA ICONS --- */
.social-header {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    width: 100%;
}

.social-header h3 {
    font-family: 'Pacifico', cursive;
    color: #FDEE87;
    font-size: 1.5rem;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.social-icon-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
    margin-top: 1rem;
    /* Reduced margin since header provides spacing */
}

.social-icon {
    height: 42px;
    width: 42px;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.social-icon:hover {
    transform: scale(1.2) rotate(8deg);
    filter: drop-shadow(0 5px 10px rgba(255, 255, 255, 0.4));
}

/* --- MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in-out;
}

.modal-content {
    position: relative;
    background: #fff;
    /* Keep modal white for readability */
    padding: 2.5rem;
    border-radius: 25px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 450px;
    text-align: center;
    color: #333;
}

.modal-content h2 {
    font-family: 'Pacifico', cursive;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2.5rem;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
}

.close-button:hover {
    color: #1D2B64;
}

#acknowledge-button {
    margin-top: 0.5rem;
    width: 100%;
    padding-left: 0;
    /* Reset padding for center text */
    text-align: center;
    justify-content: center;
}

.modal-legal-links {
    font-size: 0.75rem;
    color: #999;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.modal-legal-links a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.modal-legal-links a:hover {
    color: #1D2B64;
    text-decoration: underline;
}

/* --- FOOTER --- */
footer {
    width: 100%;
    padding: 1.5rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    margin-top: auto;
    position: relative;
    z-index: 10;
}

.legal-links {
    font-size: 0.9rem;
}

.legal-links a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: color 0.2s;
}

.legal-links a:hover {
    color: #fff;
    text-decoration: underline;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 600px) {
    .container {
        padding: 1.5rem 1rem;
        /* Reduce side padding */
        width: 95%;
    }

    h1 {
        /* Force font size to scale with viewport width so it fits on one line */
        font-size: 5.5vw;
        white-space: normal;
        /* Allow wrapping on mobile */
        padding: 0;
        /* Remove any potential padding conflicts */
        margin-left: 0;
        /* Ensure no left margin offset */
        margin-right: 0;
    }

    .social-header h3 {
        font-size: 1.2rem;
        /* Scale down for mobile */
    }

    .btn {
        font-size: 0.95rem;
        /* Slightly smaller text */
        padding: 12px 15px;
        /* Tighter padding */
        gap: 8px;
        /* Closer gap */
        white-space: nowrap;
        /* Force text to stay on one line */
    }

    .nav-icon {
        height: 36px;
        /* Smaller icon */
        width: 36px;
    }

    .social-icon-group {
        gap: 15px;
    }

    /* Mobile Modal Optimization */
    .modal-content {
        padding: 1.5rem;
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }

    .close-button {
        top: 10px;
        right: 15px;
        font-size: 2rem;
    }

    .modal-content h2 {
        font-size: 1.5rem;
        margin-top: 1rem;
    }

    #scroll-indicator p {
        font-size: 2.5vw;
        /* Responsive size to fit screen */
        white-space: nowrap;
        /* Force single line */
        text-align: center;
        margin: 0;
        margin-left: -2vw;
        /* Nudge left per user request */
        padding: 0;
        width: 100%;
    }
}

/* --- ANIMATIONS --- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* --- PROGRESS BAR --- */
.progress-container {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    margin: 1.5rem 0;
    height: 20px;
    overflow: hidden;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #FDEE87, #5F99E3);
    /* Yellow to Blue */
    border-radius: 20px;
    transition: width 0.4s ease;
    box-shadow: 0 0 10px rgba(253, 238, 135, 0.5);
}

#loading p {
    font-size: 1.1rem;
    color: #5F99E3;
    /* Blue text */
    margin-top: 0.5rem;
    font-weight: bold;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.7;
    }
}

/* --- SCROLL INDICATOR --- */
#scroll-indicator {
    margin-top: 3rem;
    /* Increased from 1rem */
    margin-bottom: 1rem;
    margin-left: auto;
    margin-right: auto;
    animation: bounce 2s infinite;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    text-align: center;
    /* Fallback */
}

#scroll-indicator p {
    font-size: 1.2rem;
    color: #FDEE87;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}