:root {
    --background-color: #1a1a1a; /* Darker background */
    --primary-color: #282828;   /* Dark primary surfaces */
    --secondary-color: #333333; /* Even darker secondary surfaces */
    --text-color: #e0e0e0;      /* Light text for dark backgrounds */
    --text-secondary-color: #b0b0b0; /* Lighter grey for secondary text */
    --accent-color: #bb86fc;    /* A vibrant accent color (purple) */
    --correct-color: #4CAF50;   /* Green for correct */
    --incorrect-color: #F44336; /* Red for incorrect */
    --neutral-color: #607D8B;   /* Blue-grey for neutral messages */
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* Ensure body takes full viewport height */
    box-sizing: border-box; /* Ensure padding doesn't cause overflow */
    position: relative; /* Needed for any absolute child like the entire .modal (overlay) */
}

/* MODIFIED: Splash Screen Styles (relative to #game-content-area) */
#splash-screen {
    position: absolute; 
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* Covers its entire parent (#game-content-area) */
    background-color: var(--primary-color); /* Solid background to cover content */
    z-index: 5; /* Above game elements, below modals */
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    pointer-events: auto; /* Ensures it can block clicks when visible */
}

.splash-pentagon {
    position: relative; /* For pseudo-element positioning */
    width: 100px;
    height: 100px;
    background-color: var(--correct-color); /* Blinking outer color */
    clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
    animation: blinkAndRotate 1.5s linear infinite; /* Combined animation */
    box-sizing: border-box; 
    transform-origin: center center; /* Ensure rotation is centered */
}

/* NEW: Pseudo-element for the inner black pentagon to create the hollow effect */
.splash-pentagon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70px; /* MODIFIED: Slightly larger inner pentagon for a thicker frame */
    height: 70px; /* MODIFIED: Slightly larger inner pentagon for a thicker frame */
    background-color: black; /* The color of the "hollow" center */
    clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
    transform: translate(-50%, -50%); /* Center the inner pentagon */
    z-index: 1; /* Ensure it's above the outer pentagon's background */
}

@keyframes blinkAndRotate {
    0% { background-color: var(--correct-color); transform: rotate(0deg); }
    50% { background-color: var(--incorrect-color); transform: rotate(180deg); } /* Rotate as it changes color */
    100% { background-color: var(--correct-color); transform: rotate(360deg); }
}


/* Base Hidden Class for elements to be controlled by JS */
.hidden {
    display: none !important;
}
/* For elements that transition visibility/opacity */
.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Crucial: Prevents hidden overlay from blocking clicks */
}


.game-wrapper {
    width: 100%;
    max-width: 700px;
    background-color: var(--primary-color);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    padding: 20px 30px;
    box-sizing: border-box;
    display: flex; /* MODIFIED: Added display flex to game-wrapper for centering */
    flex-direction: column; /* Stack items vertically */
    align-items: center; /* Center items horizontally */
    position: relative; /* Needed for any absolute child like the entire .modal (overlay) */
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444; /* Darker border */
    padding-bottom: 15px;
    margin-bottom: 20px;
}

header h1 {
    margin: 0;
    color: var(--accent-color);
    font-size: 2em; /* Ensure prominent title */
}

.icon-button {
    font-size: 1.8em; /* Slightly larger for touch */
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-secondary-color); /* Subtle color */
    transition: color 0.2s ease, transform 0.2s ease;
}
.icon-button:hover {
    color: var(--accent-color);
    transform: rotate(45deg);
}


/* Main Game Container Layout */
.game-container {
    display: flex;
    flex-direction: column; /* Stacks sections vertically */
    gap: 20px; /* Space between sections */
    align-items: center; /* Center items horizontally within the column */
    position: relative; /* Crucial: Establishes positioning context for #game-content-area */
    flex-grow: 1; /* Allow game-container to take available height */
    justify-content: center; /* MODIFIED: Vertically center content within game-container */
}

/* Container for dynamic game content, relative for splash screen */
#game-content-area {
    position: relative; /* Allows splash-screen to be absolutely positioned within it */
    width: 100%;
    min-height: 250px; /* Default min-height, can be overridden by media queries */
    display: flex;
    flex-direction: column;
    gap: 20px; /* Match game-container gap */
    align-items: center;
    flex-grow: 1; /* MODIFIED: Allow game-content-area to take available height */
    justify-content: center; /* MODIFIED: Vertically center content within game-content-area */
}


#progress-indicator-container {
    width: 100px; /* Adjusted fixed size to allow fitting 3 items */
    height: 100px;
    margin: 0 10px; /* Margin to separate from actor cards */
    aspect-ratio: 1 / 1; /* Maintains square aspect ratio */
    background-color: var(--secondary-color); /* Subtle background for visibility */
    border-radius: 8px;
    padding: 5px; /* Reduced padding to maximize pentagram size */
    box-sizing: border-box;
    display: flex; /* For centering the inner text if no SVG is drawn */
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Prevent SVG overflow */
    flex-shrink: 0; /* Prevent it from shrinking more than necessary */
}

.actor-node-text {
    fill: white;
    font-weight: bold;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    font-family: 'Roboto', sans-serif; /* Explicit font */
}

.actors-display {
    display: flex; 
    justify-content: center; /* Center the whole group */
    align-items: center;
    gap: 0; /* Gaps provided by #progress-indicator-container margin */
    width: 100%; /* Ensure it takes full width of its parent */
    flex-wrap: nowrap; /* CRUCIAL: Prevent wrapping on smaller screens */
    overflow-x: auto; /* Allow horizontal scrolling if content overflows on very small screens */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    padding-bottom: 5px; /* Prevent scrollbar from overlapping content */
}

.actor-card {
    background-color: var(--secondary-color);
    border-radius: 8px;
    padding: 10px; 
    text-align: center;
    flex: 1; /* Allows actor cards to grow/shrink equally */
    min-width: 90px; /* Adjusted minimum width for each actor card */
    max-width: 130px; /* Adjusted maximum width for each actor card */
    flex-shrink: 0; /* Prevents excessive shrinking */
    display: flex; 
    flex-direction: column;
    align-items: center;
}

.actor-card img {
    width: 80px; /* Adjusted width */
    height: 120px; /* Adjusted height to maintain aspect ratio */
    object-fit: cover;
    border-radius: 4px;
    background-color: #555; /* Placeholder background */
    margin-bottom: 8px;
}

.actor-card h2 {
    margin: 0;
    font-size: 1.1em; 
    color: var(--text-color);
    word-break: break-word; /* Allow long names to break */
}

.input-area {
    display: flex;
    gap: 10px;
    width: 100%;
}

#movie-title-input {
    flex-grow: 1;
    padding: 12px;
    font-size: 1rem;
    border-radius: 6px; 
    border: 1px solid #555;
    background-color: #3a3a3a; 
    color: var(--text-color);
    outline: none; 
}
#movie-title-input:focus {
    border-color: var(--accent-color); 
    box-shadow: 0 0 0 2px rgba(var(--accent-color), 0.5);
}


.game-button, .form-button {
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 6px; 
    background-color: var(--accent-color);
    color: var(--primary-color); 
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    white-space: nowrap; 
}

.game-button:hover, .form-button:hover {
    background-color: #a06ee0; 
    transform: translateY(-1px);
}

.game-button:disabled, .form-button:disabled {
    background-color: #555;
    cursor: not-allowed;
    transform: none;
    opacity: 0.7;
}

/* MODIFIED: #message-area size */
#message-area {
    width: 100%;
    padding: 8px 12px; /* Reduced vertical padding */
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
    margin-top: -10px; /* Pull up closer to input */
    box-sizing: border-box;
    font-size: 0.95rem; /* Slightly smaller font to save space */
    line-height: 1.3; /* Control line height for multi-line messages */
    min-height: 40px; /* Ensure a minimum height even with short messages */
    display: flex; /* For vertical centering of text */
    align-items: center; /* Vertically center content */
    justify-content: center; /* Horizontally center content */
}
#message-area p { /* Style the paragraph inside to control its margin */
    margin: 0;
    padding: 0;
}
#message-area.correct { background-color: var(--correct-color); color: white; }
#message-area.incorrect { background-color: var(--incorrect-color); color: white; }
#message-area.neutral { background-color: var(--neutral-color); color: white; }


.controls-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding-top: 10px;
    border-top: 1px solid #444; 
    position: relative; 
    z-index: 10; /* Ensures it's above the splash screen */
}

.score-display {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--text-color);
    margin: 0;
}
.score-display span {
    color: var(--accent-color);
}

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 100; /* Higher than splash screen */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8); 
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0; 
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
}

.modal:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--primary-color);
    padding: 30px; 
    border-radius: 12px; 
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 8px 30px rgba(0,0,0,0.7);
    transform: scale(0.95); 
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal:not(.hidden) .modal-content {
    transform: scale(1); 
}

.close-button {
    position: absolute;
    top: 15px;
    right: 18px;
    color: var(--text-secondary-color);
    font-size: 2.2em; 
    font-weight: normal; 
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1; 
    padding: 0;
    transition: color 0.2s ease;
}
.close-button:hover {
    color: var(--text-color);
}

/* General .hidden is now a utility class to be used where immediate hide is needed */
/* For elements that need transition, use .fade-out and control opacity/visibility */


/* Auth Form Styles */
#auth-view h2, #stats-view h2, #auth-view h3, #stats-view h3 {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 20px;
}
#auth-view h3, #stats-view h3 {
    margin-top: 25px;
    margin-bottom: 15px;
    color: var(--accent-color);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-form input {
    padding: 12px;
    font-size: 1rem;
    background-color: #3a3a3a;
    border: 1px solid #555;
    border-radius: 6px;
    color: var(--text-color);
    outline: none;
}
.auth-form input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(var(--accent-color), 0.5);
}

.form-link {
    text-align: center;
    margin-top: 15px;
    font-size: 0.95em;
}

.form-link a {
    color: var(--accent-color);
    cursor: pointer;
    text-decoration: none;
    font-weight: bold;
}
.form-link a:hover {
    text-decoration: underline;
}

.auth-message {
    text-align: center;
    margin-top: 15px;
    font-weight: bold;
    color: var(--text-color); 
    min-height: 1.2em; 
}


/* Stats View Styles */
#user-status {
    text-align: center;
    margin-bottom: 20px;
    color: var(--text-secondary-color);
    font-weight: bold;
    font-size: 1.1em;
}

.stats-grid {
    display: flex;
    justify-content: space-around;
    text-align: center;
    margin: 20px 0;
    padding-bottom: 20px;
    border-bottom: 1px solid #444;
}

.stat-item .stat-value {
    font-size: 2.8rem; 
    font-weight: bold;
    color: var(--accent-color);
}

.stat-item .stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary-color);
}

.chart-container {
    width: 100%;
    margin-top: 15px;
    padding-bottom: 20px; 
    border-bottom: 1px solid #444;
}

.chart-bar-row {
    display: flex;
    align-items: center;
    margin-bottom: 10px; 
    font-size: 0.95rem;
}

.chart-bar-label {
    width: 20%; 
    text-align: right;
    padding-right: 15px;
    color: var(--text-secondary-color);
    flex-shrink: 0;
}

.chart-bar-wrapper {
    width: 80%; 
    background-color: #444; 
    border-radius: 4px;
    display: flex;
    align-items: center; 
}

.chart-bar {
    background-color: var(--correct-color);
    height: 25px; 
    border-radius: 4px;
    color: white;
    font-weight: bold;
    font-size: 0.85rem;
    line-height: 25px; 
    text-align: right;
    padding-right: 10px;
    min-width: 25px; 
    white-space: nowrap;
    box-sizing: border-box;
    transition: width 0.5s ease-out; 
}

/* Share Card Styles */
#share-section {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid #444;
    text-align: center; 
}
#share-section h3 {
    margin-bottom: 20px;
}

#share-card {
    background-color: var(--background-color); 
    border: 1px solid #555; 
    border-radius: 10px;
    padding: 20px;
    margin: 0 auto 20px auto; 
    max-width: 300px; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center; 
    gap: 10px;
}

.share-header {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 5px;
}

#share-pentagon-container {
    width: 140px; 
    height: 140px;
    margin: 0 auto;
    background-color: var(--primary-color); 
    border-radius: 8px;
    padding: 5px;
    box-sizing: border-box;
    display: flex; 
    justify-content: center;
    align-items: center;
}

#share-score {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 5px 0;
}

.share-footer {
    font-size: 0.9rem;
    color: var(--text-secondary-color);
    margin-top: 5px;
}

#share-button {
    width: auto; 
    padding: 12px 25px;
    display: inline-block; 
}

/* NEW: Media Queries for Mobile Responsiveness */
@media (max-width: 550px) { /* Adjust breakpoint as needed for typical phones */
    body {
        padding: 10px; /* Reduce overall body padding */
        min-height: 100svh; /* Use small viewport height */
    }

    .game-wrapper {
        padding: 15px 20px; /* Reduce game wrapper padding */
        display: flex; /* Ensure flex is enabled in mobile view */
        flex-direction: column; /* Stack items vertically */
        align-items: center; /* Center items horizontally on mobile */
        flex-grow: 1; /* Allow to fill vertical space */
        justify-content: center; /* Vertically center content */
    }

    header {
        margin-bottom: 10px; /* Reduce space below header */
        padding-bottom: 10px;
    }

    .game-container {
        gap: 15px; /* Reduce gap between main sections */
        flex-grow: 1; /* Allow game-container to take available height */
        justify-content: center; /* Vertically center content within game-container */
    }

    #game-content-area {
        gap: 15px; /* Reduce gap within game content area */
        min-height: 200px; /* Adjust min-height for smaller screens */
        flex-grow: 1; /* Allow to take available height */
        justify-content: center; /* Vertically center content */
    }

    .actors-display {
        flex-wrap: nowrap; /* Keep items side-by-side */
    }

    .actor-card {
        min-width: 80px; /* Allow actor cards to shrink more */
        max-width: 100px; /* Cap max width */
        padding: 8px; /* Reduced padding */
    }

    .actor-card img {
        width: 70px; /* Smaller images */
        height: 105px; /* Maintain aspect ratio */
    }

    .actor-card h2 {
        font-size: 0.95em; /* Smaller font for names */
    }

    #progress-indicator-container {
        width: 80px; /* Smaller pentagon */
        height: 80px;
        margin: 0 8px; /* Reduced margin */
    }

    .input-area {
        gap: 8px; /* Smaller gap in input area */
    }

    #movie-title-input {
        padding: 10px; /* Smaller input padding */
        font-size: 0.9rem;
    }

    .game-button, .form-button {
        padding: 10px 15px; /* Smaller button padding */
        font-size: 0.9rem;
    }

    #message-area {
        padding: 6px 10px; /* Further reduced padding */
        margin-top: -8px; /* Further pull up */
        font-size: 0.85rem;
        min-height: 35px; /* Even smaller min-height */
    }

    .controls-area {
        padding-top: 8px; /* Reduced padding above controls */
    }

    .score-display {
        font-size: 1em; /* Slightly smaller score display */
    }
}