:root {
    --bg-dark: #081018;
    --accent-red: #d32f2f; /* Darker, richer red */
    --accent-gold: #ffeb3b; /* Brighter, more common gold */
    --accent-green: #388e3c; /* Bolder green */
    --text-light: #f5f5f5;
    /* Updated panel background for a rich, dark green */
    --panel-bg: rgba(0, 100, 50, 0.85);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    /* New background: Deep forest green with a subtle dark central glow */
    background: radial-gradient(circle at center, #02040a 10%, #004d40 100%);
    color: var(--text-light);
    min-height: 100vh;
    height: 100vh; /* Force 100% viewport height */
    display: flex;
    /* Change stretch to center to align the #app block */
    align-items: center;
    justify-content: center;
}

#app {
    /* width: 100%; */
    width: 96vw; /* Use 96% of viewport width */
    max-width: 1600px; /* Allow expansion up to a very large width */
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: calc(100vh - 2rem); /* Fill height minus vertical padding */
}

.card {
    /* Use a consistent background dark-green from the variable for a sleek look */
    background-color: var(--panel-bg);
    /* Adding a subtle linear gradient for a slight texture/depth */
    background-image: linear-gradient(145deg, rgba(255, 255, 255, 0.04) 0%, rgba(0, 0, 0, 0.08) 100%);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7);
    padding: 1rem; /* Reduced padding for more content space */
}

.header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.75rem;
}

.logo {
    width: 124px;
    height: 69px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--accent-gold);
    background: #111;
    flex-shrink: 0;
}

.logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.title-block h1 {
    font-size: 1.8rem;
    letter-spacing: 0.03em;
    font-weight:bold;
}

p.subtitle {
    font-size:1.3rem;
    font-weight:bold;
}

.title-block p {
    font-size: 0.9rem;
    font-weight:bold;
    color: gold;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    margin-left: auto;
}

.pill span {
    font-size: 1rem;
}

.layout {
    display: grid;
    /* Ratio: 3 parts game, 1 part info */
    grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
    gap: 1rem;
    flex-grow: 1; /* Make layout take up all available vertical space */
}

@media (max-width: 800px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .header {
        flex-wrap: wrap;
    }
    .pill {
        margin-left: 0;
    }
}

/* Mobile-specific adjustments for smaller screens */
@media (max-width: 600px) {
    /* Shrink overall app padding */
    #app {
        padding: 0.5rem;
    }

    /* Shrink card padding */
    .card {
        padding: 0.8rem;
    }

    /* Shrink the logo to give more room for text */
    .logo {
        width: 80px;
        height: 45px;
        border: 1px solid var(--accent-gold);
    }

    /* Shrink the title/subtitle more aggressively to prevent truncation */
    .title-block h1 {
        font-size: 1.2rem;
        line-height: 1.2;
    }
    p.subtitle {
        font-size: 0.85rem;
    }
    .title-block {
        flex-grow: 1; /* Allow title to fill available space */
    }

    /* Also adjust the start screen text */
    .start-text {
        font-size: 1rem;
    }

    /* Ensure small screen buttons are still legible */
    .btn, .btn-secondary {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}


/* start screen */
/* Opening screen split layout */

.start-layout {
    display: flex;
    gap: 1.5rem; /* Increased gap */
    align-items: stretch; /* Stretch items vertically */
}

.start-image {
    flex: 1 1 45%; /* Increased image space */
}

.start-image img {
    width: 100%;
    border-radius: 12px;
    display: block;
    object-fit: cover;
    max-height: 260px;
}

.start-text {
    flex: 1 1 55%; /* Ensure text block fills the remaining space */
    font-size:1.2rem;
    font-weight:bold;
}

div.htp {
    text-align:center;
    font-weight:bold;
    font-soze: 1.3rem;
}

/* Stack image and text on smaller screens */
@media (max-width: 650px) {
    .start-layout {
        flex-direction: column;
    }
}


/* Game area */

#game-container {
    position: relative;
    overflow: hidden;
    border-radius: 14px;
    /* Use the accent red */
    background: var(--accent-red);

    /* UPDATED: Aspect Ratio to 4:3 (75%) */
    width: 100%;
    padding-bottom: 75%;
    height: 0;
}

#game-background {
    position: absolute;
    inset: 0;
    background-position: center;
    background-size: cover;
    filter: none; /*brightness(0.85); */
    transition: background-image 0.4s ease-out;
    width: 100%;
    height: 100%;
}

/*
#overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at bottom, transparent 30%, rgba(0, 153, 76, 0.6));
    pointer-events: none;
}
*/
.hud {
    position: absolute;
    inset: 0.6rem 0.6rem auto 0.6rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}

.hud-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: auto;
}

.hud-badge {
    background: var(--panel-bg);
    border-radius: 999px;
    padding: 0.25rem 0.7rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-badge strong {
    color: var(--accent-gold);
}

#timer-bar {
    width: 150px;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

#timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-gold), var(--accent-red));
    transform-origin: left;
}

.btn {
    cursor: pointer;
    border: none;
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    /* Using variables for primary button color */
    background-color: var(--accent-red);
    color: var(--text-light); /* White text on red */
    /* Gold-tinted shadow */
    box-shadow: 0 8px 18px rgba(255, 200, 0, 0.45);
    transition: transform 0.08s ease-out, box-shadow 0.12s ease-out, filter 0.12s ease-out;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    /* Stronger gold-green hover shadow */
    box-shadow: 0 10px 22px rgba(200, 255, 0, 0.6);
    filter: brightness(1.05);
}

.btn:active {
    transform: translateY(1px);
    box-shadow: 0 5px 12px rgba(255, 0, 0, 0.5);
    filter: brightness(0.97);
}

.btn-secondary {
    cursor: pointer;
    border: none;
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    /* Secondary color: Green with light text */
    background-color: var(--accent-green);
    color: var(--text-light);
    /* Green-tinted shadow */
    box-shadow: 0 8px 18px rgba(50, 200, 50, 0.45);
    transition: transform 0.08s ease-out, box-shadow 0.12s ease-out, filter 0.12s ease-out;
    text-decoration: none;
}

.btn-secondary:hover {
    filter: brightness(1.08);
    /* Darker shadow for secondary hover */
    box-shadow: 0 10px 22px rgba(50, 200, 50, 0.6);
}

.floating-icon {
    position: absolute;
    width: 64px;
    height: 64px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease-out, transform 0.12s ease-out;
    will-change: transform, opacity;
    user-select: none;
}

.floating-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.floating-icon.grinch {
    z-index: 3;
}

.floating-icon.bonus {
    z-index: 2;
}

.pop {
    animation: pop 0.35s ease-out;
}

@keyframes pop {
    0% { transform: scale(1); }
    40% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Room info under game */

.room-info {
    margin-top: 0.4rem; /* Reduced margin */
    padding: 0.4rem 0.6rem; /* Reduced padding */
    border-radius: 12px;
    /* Slightly less dark background */
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.85rem;
}

.room-info h3 {
    font-size: 0.9rem; /* Reduced size */
    margin-bottom: 0.25rem;
    color: var(--accent-gold);
}

.room-info p {
    font-size: 0.8rem; /* Reduced size */
    opacity: 0.95;
    line-height: 1.35;
}

/* CTA bar under game */

.cta-bar {
    margin-top: 0.4rem; /* Reduced margin */
    padding: 0.4rem 0.6rem; /* Reduced padding */
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    font-size: 0.8rem; /* Reduced size */
}

.cta-bar p {
    flex: 1 1 180px;
    opacity: 0.95;
}

.cta-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

/* Panels on the right */

.section-title {
    font-size: 1.1rem; /* Slightly larger heading */
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Add a subtle underline */
    border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
    padding-bottom: 0.3rem;
}

.section-title span {
    font-size: 0.75rem;
    opacity: 0.8;
}

.section-body {
    font-size: 0.9rem; /* Reduced font size to fit more text/rows */
    font-weight: 500; /* Reduced font weight for better reading */
}

.section-body ul {
    margin-left: 1.1rem;
    margin-top: 0.45rem;
    display: grid;
    gap: 0.2rem;
}

.section-body li {
    list-style: "★ ";
}

/* Screens (start / end) */

.center-screen {
    position: absolute;
    inset: 0;
    display: flex;
    /* FIX: Revert alignment to center content vertically */
    align-items: center;
    justify-content: center;
    background: transparent;
    z-index: 10;
    width: 100%;
    height: 100%;
    /* Keep padding for viewport safety */
    padding: 1rem 0.5rem;
}

.screen-content {
    background: var(--panel-bg);
    border-radius: 16px;
    padding: 1.5rem 1.3rem;
    max-width: 900px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.75);

    /* FIX: Use vh units to reliably force scroll on small screens */
    max-height: 90vh;
    overflow-y: auto;
}

.screen-content h2 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.screen-content p {
    font-size: 0.9rem;
    opacity: 0.94;
    text-align: center;
    margin-bottom: 0.4rem;
}

.tagline {
    font-style: italic;
    font-size: 0.85rem;
    opacity: 0.9;
    text-align: center;
    margin-top: 0.35rem;
}

.screen-actions {
    margin-top: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.label {
    font-size: 0.8rem;
    opacity: 0.9;
    display: block;
    margin-bottom: 0.25rem;
}

.input {
    width: 100%;
    padding: 0.4rem 0.55rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.7);
    color: #eee;
    font-size: 0.85rem;
    outline: none;
}

.input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.two-col {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.7rem;
}

.status {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    text-align: center;
    opacity: 0.9;
}

.status strong {
    color: var(--accent-gold);
}

/* Leaderboard */

.leaderboard-table {
    margin-top: 0.4rem;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.5);
}

.leaderboard-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem; /* Increased size for readability */
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 0.4rem 0.6rem; /* Increased padding */
    text-align: left;
}

.leaderboard-table th {
    background: rgba(255, 255, 255, 0.08);
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.leaderboard-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.03);
}

.leaderboard-table tr:nth-child(1) td:first-child {
    color: var(--accent-gold);
}

.badge-win {
    color: var(--accent-green);
    font-weight: 600;
}

.badge-lose {
    color: var(--accent-red);
    font-weight: 600;
}

.caption-box {
    margin-top: 0.4rem;
    border-radius: 10px;
    border: 1px dashed rgba(255, 255, 255, 0.3);
    padding: 0.4rem 0.5rem;
    font-size: 0.78rem;
    max-height: 90px;
    overflow: auto;
    background: rgba(0, 0, 0, 0.6);
    white-space: pre-wrap;
}

.level-video {
    width:100%;
    border-radius:12px;
    margin-top:0.6rem;
}

.level-video-wrapper {
    width: 100%;
    max-width: 360px;       /* Reverted to 360px to fix rendering bug */
    margin: 0.75rem auto 0;
}

.level-video-wrapper video {
    width: 100%;
    border-radius: 12px;
    display: block;
}
/* --- START SCREEN HEIGHT OVERRIDE --- */
/* Forces a much taller aspect ratio for the intro screen image only (3:4 ratio) */
#game-container.is-tall-screen {
    /* Height is 75% of width (4:3) or 133.3% of width (3:4) */
    /* Using 133.33% to match your original tall image aspect ratio (2133/1600) */
    padding-bottom: 133.33%;
}

/* Ensure the floating content doesn't crash into the top of the screen */
#game-container.is-tall-screen + .room-info {
    margin-top: 1.5rem;
}
