:root {
    --font-primary: 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    --color-bg-body: #f4f7f6;
    --color-text-body: #5d5d5d;
    --color-text-heading: #3498db;
    --color-text-label: #7f8c8d;
    --color-text-list-item: #2980b9;
    --color-text-light: #ffffff;

    --color-primary: #3498db;
    --color-primary-dark: #2980b9;
    --color-secondary: #e67e22;
    --color-secondary-dark: #d35400;

    --color-border-light: #e0e0e0;
    --color-border-medium: #ccc;
    --color-line: #bdc3c7;
    --color-disabled: #95a5a6;

    --color-bg-card: #ffffff;
    --color-bg-input: #f9f9f9;

    --shadow-card: 0 10px 25px rgba(0, 0, 0, 0.08);
    --shadow-racer: 0 2px 4px rgba(0, 0, 0, 0.15);

    --border-radius-soft: 15px;
    --border-radius-standard: 8px;

    --spacing-xs: 0.3125rem; /* 5px */
    --spacing-s: 0.5rem;    /* 8px */
    --spacing-m: 0.625rem;  /* 10px */
    --spacing-l: 0.9375rem; /* 15px */
    --spacing-xl: 1.25rem;  /* 20px */
    --spacing-xxl: 1.5625rem;/* 25px */
    --spacing-xxxl: 1.875rem;/* 30px */

    font-size: 100%; /* Base for rem units, typically 16px */
}

body {
    font-family: 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    background-color: #f4f7f6;
    color: #5d5d5d;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 40px); /* Account for padding */
    overflow-x: hidden; /* Prevent horizontal scroll */
}

h1 {
    font-size: 2.6em;
    margin: 0 0 25px 0;
    color: #3498db;
    font-weight: 700;
}

p {
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
    color: #5d5d5d; /* Consistent text color */
}

button {
    padding: 12px 25px;
    font-size: 1.2em;
    background-color: #3498db;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: background-color 0.3s ease, transform 0.1s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Consistent shadow */
    margin: 5px; /* Keep some margin */
}

button:hover {
    background-color: #2980b9; /* Darker blue */
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Specific Button Overrides */
#startGameBtn, #restartGameBtn {
    background-color: #2ecc71; /* Emerald green */
}

#startGameBtn:hover, #restartGameBtn:hover {
    background-color: #27ae60; /* Darker emerald */
}

#updateNamesBtn {
    background-color: #e67e22; /* Carrot orange */
}

#updateNamesBtn:hover {
    background-color: #d35400; /* Darker orange */
}

#copySessionUrlBtn {
    background-color: #9b59b6; /* Amethyst purple */
    font-size: 1em;
    padding: 8px 15px;
}

#copySessionUrlBtn:hover {
    background-color: #8e44ad; /* Darker purple */
}

button:disabled {
    background-color: #95a5a6; /* Muted grey when disabled */
    cursor: not-allowed;
}


#sessionInfo,
#captured-list-container {
    background-color: #ffffff; /* Clean white */
    padding: 25px 30px; /* Generous padding */
    border-radius: 15px; /* Softer radius */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08); /* Softer shadow */
    border: 1px solid #e0e0e0; /* Light border */
    margin: 15px auto; /* Center and add vertical margin */
    width: 90%;
    max-width: 600px; /* Max width for these info/config blocks */
    text-align: left; /* Align content left within these cards */
    box-sizing: border-box; /* Include padding/border in width */
}

#sessionInfo {
    text-align: center; /* Center text within session info */
    display: none; /* Hidden by default, JS toggles */
    font-size: 1.1em;
    color: #2c3e50;
}

#sessionInfo span {
    font-weight: bold;
    color: #3498db; /* Friendly blue for session ID */
    word-break: break-all; /* Ensure long IDs wrap */
}

#settingsToggleBtn {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 10px 18px;
    font-size: 1em;
    background-color: #3498db;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-weight: 600;
}

#config-area {
    position: absolute;
    top: 75px;
    right: 20px;
    background-color: #ffffff;
    padding: 25px 30px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
    max-width: 450px;
    z-index: 20;
    text-align: left;
}

#config-area label {
    display: block;
    margin-bottom: 8px;
    font-size: 1em;
    color: #7f8c8d;
    font-weight: 600;
}

.config-hidden {
    display: none !important;
}

#namesInput {
    width: calc(100% - 20px); /* Account for padding */
    min-height: 60px; /* Consistent height */
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    color: #5d5d5d;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95em;
    margin-bottom: 10px;
    resize: vertical;
}

#game-container {
    position: relative;
    width: 95%; /* Make it responsive */
    max-width: 850px; /* Original max width */
    height: auto; /* Allow height to adjust */
    aspect-ratio: 4 / 3; /* Maintain 800x600 aspect ratio */
    border: 5px solid #34495e; /* Keep the strong border for game area */
    border-radius: 15px;
    background-color: #ecf0f1;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2); /* Keep strong shadow for game area */
    margin-bottom: 20px;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(44, 62, 80, 0.95); /* Slightly darker overlay */
    color: white;
    display: none; /* Hidden by default */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 10;
    border-radius: 10px; /* Match container radius */
}

#game-over-overlay h2 {
    font-size: 3em;
    margin-bottom: 10px;
    color: #f1c40f; /* Sun Flower yellow */
}

#game-over-overlay p {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: #ecf0f1; /* Light grey text */
}

#game-over-overlay ol {
    list-style: decimal inside;
    padding: 0;
    margin: 0 0 20px 0;
    font-size: 1.1em;
    color: #ecf0f1; /* Light grey list numbers */
}

#game-over-overlay li {
    margin-bottom: 5px;
    color: #ecf0f1; /* Light grey list items */
}

#captured-list-container h2 {
    color: #3498db; /* Friendly blue for sub-heading */
    margin-top: 0;
}

#captured-list {
    list-style: none;
    padding: 0;
    max-height: 150px;
    overflow-y: auto;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

#captured-list li {
    background-color: #f9f9f9;
    padding: 8px 12px;
    margin-bottom: 5px;
    border-radius: 5px;
    color: #2980b9; /* Darker blue for list items */
    font-weight: 600;
}

.effect-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(241, 196, 15, 0.9);
    color: #2c3e50;
    padding: 20px 30px;
    border-radius: 15px;
    font-size: 2.5em;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 100;
    animation: fadeInOut 2.5s forwards;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    10% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    90% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
}


@media (max-width: 768px) {
    body {
        padding: 15px;
        min-height: calc(100vh - 30px);
    }

    h1 {
        font-size: 2em;
        margin-bottom: 20px;
    }

    button {
        padding: 10px 20px;
        font-size: 1em;
    }

    #settingsToggleBtn {
        margin: 15px auto;
    }

    #sessionInfo,
    #config-area,
    #captured-list-container {
        padding: 15px;
        width: 95%; /* Take more width on smaller screens */
        max-width: none;
    }

    #namesInput {
        min-height: 50px;
        font-size: 0.9em;
    }

    #game-container {
        width: 95%;
        height: auto;
        aspect-ratio: 4 / 3;
    }

    .effect-notification {
        font-size: 1.8em;
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
        min-height: calc(100vh - 20px);
    }
    h1 { font-size: 1.8em; margin-bottom: 15px; }
    button { font-size: 0.9em; padding: 8px 15px; }
    #settingsToggleBtn { font-size: 0.9em; padding: 8px 15px; margin: 10px auto; }
    #sessionInfo, #config-area, #captured-list-container { padding: 10px; }
    #namesInput { min-height: 40px; font-size: 0.85em; }
    #game-over-overlay h2 { font-size: 2.2em; }
    #game-over-overlay p { font-size: 1em; }
    #game-over-overlay ol { font-size: 1em; }
    #captured-list li { font-size: 0.9em; }
    .effect-notification { font-size: 1.5em; padding: 12px 18px; }
}

#captured-list-container {
    display: none; /* Hidden by default */
};

@keyframes slideIn {
    from { top: -100px; opacity: 0; }
    to { top: 0; opacity: 1; }
}

.close-btn {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 35px;
    font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal h2 {
    text-align: center;
    color: #3498db;
    margin-top: 0;
}

.guide-section {
    margin-bottom: 20px;
}

.guide-section h3 {
    color: #2c3e50;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.guide-section p,
.guide-section ul {
    text-align: left;
    line-height: 1.6;
}

.guide-section ul {
    list-style-position: inside;
    padding-left: 10px;
}

.guide-section li {
    margin-bottom: 8px;
}

#howToPlayBtn {
    background-color: #9b59b6; /* Amethyst */
}

#howToPlayBtn:hover {
    background-color: #8e44ad; /* Darker Amethyst */
}

.hidden{
    display: none !important;
}

/* How to Play Modal Styles */
.modal {
    position: absolute;
    top: 0; /* Stay in place */
    z-index: 100; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.6); /* Black w/ opacity */
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; /* 10% from the top and centered */
    padding: 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 700px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    animation: slideIn 0.4s ease-out;
}

/* Countdown Overlay Styles */
#countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(44, 62, 80, 0.9); /* Dark overlay */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10; /* Above the canvas, below game over */
    border-radius: 10px; /* Match game container */
    display: none; /* Hidden by default */
}

#countdown {
    font-size: 8em; /* Very large number */
    font-weight: bold;
    color: #f1c40f; /* Bright yellow for visibility */
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.4); /* Stronger shadow for pop */
    animation: pulse 1s infinite alternate; /* Pulsing animation */
}

@keyframes pulse {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Responsive adjustments for countdown */
@media (max-width: 768px) {
    #countdown {
        font-size: 6em;
    }
}

@media (max-width: 480px) {
    #countdown {
        font-size: 4em;
    }
}


.seo-content-area {
    background-color: var(--color-bg-card);
    padding: var(--spacing-xxl) var(--spacing-xxxl);
    border-radius: var(--border-radius-soft);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border-light);
    max-width: 700px; /* Or adjust to fit your layout */
    width: 90%;
    margin: var(--spacing-xxxl) auto; /* Spacing from game elements */
    text-align: left;
    line-height: 1.7;
    width: auto;
}

.seo-content-area h2 {
    color: var(--color-text-heading); /* Friendly blue */
    margin-top: 0;
    margin-bottom: var(--spacing-l);
    font-size: 1.8rem;
}

.seo-content-area h3 {
    color: var(--color-primary-dark); /* Darker blue */
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-m);
    font-size: 1.4rem;
}

.seo-content-area p,
.seo-content-area li {
    color: var(--color-text-body); /* Standard text color */
    margin-bottom: var(--spacing-m);
}

.seo-content-area ul {
    padding-left: var(--spacing-xl);
    margin-bottom: var(--spacing-l);
}

.seo-content-area a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.seo-content-area a:hover {
    text-decoration: underline;
    color: var(--color-primary-dark);
}