:root {
    --bg-color: #14181c;
    --card-color: #2c3440;
    --font-color: #e0e0e0;
    --accent-color: #00e054;
    --border-color: #445566;
    --correct-color: #00b020;
    --incorrect-color: #ff4500;
}

/* --- Global Styles --- */
body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--font-color);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
    width: 100%;
    max-width: 900px;
}

header h1 {
    font-family: 'Roboto Slab', serif;
    color: var(--accent-color);
    margin: 0;
}

.back-link {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-color);
    text-decoration: none;
    font-size: 1em;
    padding: 5px 10px;
}

.back-link:hover {
    text-decoration: underline;
}

footer {
    margin-top: auto;
    padding-top: 40px;
    color: #9ab;
    font-size: 0.9em;
    text-align: center;
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* --- Main Menu Page --- */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-top: 40px;
}

.game-modes {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-card {
    background-color: var(--card-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px 30px;
    width: 250px;
    text-align: center;
    text-decoration: none;
    color: var(--font-color);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.mode-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-color);
}

.mode-card h3 {
    margin: 0 0 10px 0;
    color: var(--accent-color);
    font-size: 1.3em;
}

.mode-card p {
    margin: 0;
    color: #9ab;
    line-height: 1.4;
}

/* --- Shared Game Styles --- */
#game-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 500px;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-left-color: var(--accent-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-top: 50px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* --- Classic Boxdle Styles --- */
#movie-card {
    background-color: var(--card-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

#movie-progress {
    width: 100%;
    text-align: right;
    font-size: 0.9em;
    color: #9ab;
    margin-bottom: 10px;
}

.movie-poster {
    width: 200px;
    height: 300px;
    border-radius: 8px;
    object-fit: cover;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    background-color: var(--bg-color); /* Placeholder color */
}

.movie-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.title-line {
    text-align: center;
}

.title-line h2 {
    margin: 0;
    font-size: 1.5em;
}

.movie-year {
    font-size: 1.1em;
    color: #9ab;
}

.guess-area {
    display: flex;
    gap: 10px;
}

.rating-input {
    width: 100%;
    flex-grow: 1;
    padding: 12px;
    font-size: 1.1em;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--font-color);
    border-radius: 4px;
    text-align: center;
}

.guess-button {
    padding: 12px 20px;
    background-color: var(--accent-color);
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1em;
}
.guess-button:disabled {
    background-color: #555;
    cursor: not-allowed;
}

.feedback-area {
    text-align: center;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.feedback {
    font-weight: bold;
    font-size: 1.1em;
    margin: 0;
}

.guesses-left-text {
    color: #9ab;
    margin-top: 5px;
}

.result-stats {
    display: flex;
    justify-content: space-around;
    width: 100%;
    background-color: var(--bg-color);
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.5s ease-in 0.2s;
}

.result-stats.visible {
    opacity: 1;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 33%;
}

.stat-item span {
    color: #9ab;
    font-size: 0.9em;
}

.stat-item strong {
    font-size: 1.4em;
    color: var(--font-color);
    margin-top: 4px;
}

/* --- Higher or Lower Styles --- */
#hl-top-bar {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 700px;
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 20px;
    padding: 0 10px;
    box-sizing: border-box;
}

#hl-card {
    width: 100%;
}

#hl-movies {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.movie-choice {
    background-color: var(--card-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    width: 300px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.movie-choice:hover:not(.no-hover) {
    transform: translateY(-5px);
    border-color: var(--accent-color);
}

.movie-choice.selected.correct {
    border-color: var(--correct-color);
    background-color: #1a4a2a;
    transform: scale(1.05);
}

.movie-choice.selected.incorrect {
    border-color: var(--incorrect-color);
    background-color: #4a2a1a;
    transform: scale(1.05);
}

.movie-choice.not-selected {
    opacity: 0.6;
}

.movie-choice img {
    width: 150px;
    height: 225px;
    border-radius: 4px;
    object-fit: cover;
    margin-bottom: 10px;
    background-color: var(--bg-color);
}

.movie-choice h3 {
    margin: 0 0 5px 0;
    font-size: 1.2em;
    min-height: 44px; /* Prevent layout shift for 2-line titles */
}

.movie-choice p {
    margin: 0;
    color: #9ab;
}

.vs-circle {
    align-self: center;
    font-family: 'Roboto Slab', serif;
    font-size: 2em;
    color: var(--accent-color);
    background-color: var(--card-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 90px 0;
}

.rating-reveal {
    font-family: 'Roboto Slab', serif;
    font-size: 2em;
    font-weight: bold;
    margin-top: 10px;
    min-height: 40px;
}

#hl-feedback {
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    margin-top: 20px;
    min-height: 30px;
}

/* --- Shared Modal Styles --- */
.modal {
    position: fixed;
    z-index: 100;
    left: 0; top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-color);
    padding: 20px 30px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

#share-text {
    background-color: var(--bg-color);
    padding: 15px;
    border-radius: 5px;
    white-space: pre-wrap;
    text-align: left;
    font-size: 1.1em;
    line-height: 1.6;
    margin-top: 10px;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.modal-button {
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    border-radius: 5px;
    font-weight: bold;
    text-decoration: none;
    border: 2px solid var(--accent-color);
    transition: background-color 0.2s, color 0.2s;
}

#copy-share-button {
    background-color: var(--accent-color);
    color: #000;
}

#copy-share-button:hover {
    background-color: #00ff62;
}

.modal-button.secondary {
    background-color: transparent;
    color: var(--accent-color);
}

.modal-button.secondary:hover {
    background-color: var(--accent-color);
    color: #000;
}

#copy-feedback:not(.hidden) {
    color: var(--accent-color);
    margin-top: 10px;
}
/* --- Media Queries for Mobile Responsiveness --- */

@media (max-width: 768px) {
    .back-link {
        /* Make the back link smaller and position it better on mobile */
        left: 5px;
        font-size: 0.9em;
        padding: 2px 5px;
    }

    /* --- Higher or Lower Mobile Styles --- */
    #hl-movies {
        /* Change direction to vertical and reduce gap */
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .movie-choice {
        /* Make the cards take up more width */
        width: 90%;
        max-width: 320px;
    }

    .vs-circle {
        /* Shrink the VS circle and rotate it for vertical layout */
        width: 50px;
        height: 50px;
        font-size: 1.5em;
        margin: 10px 0;
        /* Optional: Rotate to be a diamond shape */
        /* transform: rotate(45deg); */
    }

    .movie-choice h3 {
        /* Ensure title height is still consistent */
        min-height: auto;
    }
}

/* =============================================== */
/* == Mobile-Specific Layout Adjustments == */
/* =============================================== */

@media (max-width: 768px) {

    /* --- Back Button Fix for Mobile --- */
    .back-link {
        position: static; /* Remove absolute positioning */
        transform: none;  /* Reset the transform */
        
        display: block; /* Make it a block element to take its own line */
        text-align: center; /* Center the text inside the link */
        width: fit-content; /* Make the button width fit its content */
        margin: 0 auto 1.5rem auto; /* Center the block itself and add margin below it */
        
        /* Optional: Add some padding to make it a bigger tap target */
        padding: 8px 16px;
        border: 1px solid var(--accent-color);
        border-radius: 6px;
    }

    /* Adjust the header to accommodate the new button position */
    header {
        /* Remove the relative positioning needed for the desktop absolute layout */
        position: static;
        /* Add some padding to the top to space it from the browser edge */
        padding-top: 1rem;
    }
}