/* ============================================================
   SHOW DO STLZÃO - Complete Styling
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: Arial, "Helvetica Neue", sans-serif;
    overflow: hidden;
}

body {
    /* Starburst background: deep blue with rays and vignette */
    background:
        /* vignette (dark purple corners) */
        radial-gradient(ellipse at center, transparent 0%, rgba(40, 0, 80, 0.5) 100%),
        /* bright center glow */
        radial-gradient(circle at center, rgba(100, 150, 255, 0.3) 0%, transparent 60%),
        /* starburst rays: alternating dark-blue / lighter-blue wedges */
        repeating-conic-gradient(
            from 0deg,
            rgba(20, 40, 100, 1) 0deg 3.6deg,
            rgba(30, 60, 140, 1) 3.6deg 7.2deg
        ),
        /* base deep blue */
        #0a1f4d;
    background-attachment: fixed;
}

/* ============================================================
   MAIN LAYOUT: Two-Column Grid (Left 50%, Right 50% Green)
   ============================================================ */

.main-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    height: 100%;
    gap: 0;
}

.left-column {
    position: relative;
    display: flex;
    flex-direction: column;
    padding-top: clamp(1rem, 3%, 2rem);
    padding-right: clamp(1rem, 3%, 2rem);
    /* Extra bottom clearance so hud-area/footer-area never render underneath
       the fixed, always-on-top .host-bar (~60-65px tall). */
    padding-bottom: clamp(6.5rem, 11%, 8rem);
    padding-left: clamp(1rem, 3%, 2rem);
    background: transparent;
    overflow: hidden;
}

.right-column {
    /* Pure chroma-key green, absolutely nothing rendered on top */
    background: #00FF00;
    width: 100%;
    height: 100%;
    border: none;
    box-shadow: none;
    position: relative;
    z-index: -1;
}

/* ============================================================
   LOGO AREA
   ============================================================ */

.logo-area {
    position: relative;
    height: clamp(4rem, 7%, 6rem);
    margin-bottom: clamp(0.6rem, 1%, 1rem);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(0.5rem, 2%, 1.5rem);
    flex-shrink: 0;
}

.logo-wrap {
    position: relative;
    height: 100%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.remaining-top {
    color: #FFD700;
    font-weight: 900;
    font-size: clamp(1rem, 2.2vw, 1.7rem);
    text-transform: uppercase;
    text-align: right;
    line-height: 1.2;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
}

#logo-img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    display: block;
    border-radius: clamp(0.5rem, 1.5%, 1rem);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

#logo-img:not([src]), #logo-img.error {
    display: none;
}

#logo-img:not([src]) ~ .logo-fallback,
#logo-img.error ~ .logo-fallback {
    display: flex;
}

.logo-fallback {
    display: none;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.logo-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.2rem, 1%, 0.4rem);
}

.logo-show, .logo-stlzao {
    font-family: Arial, "Arial Black", sans-serif;
    font-weight: 900;
    font-size: clamp(1.2rem, 3vw, 2.5rem);
    color: #FFD700;
    text-shadow:
        2px 2px 0 #B8860B,
        4px 4px 0 #8B6508,
        6px 6px 0 #5C4103;
    letter-spacing: 0.1em;
}

.logo-do {
    font-family: Arial, "Helvetica Neue", sans-serif;
    font-size: clamp(0.7rem, 1.5vw, 1.2rem);
    color: #FFFFFF;
    font-weight: normal;
}

/* ============================================================
   QUESTION PANEL
   ============================================================ */

.question-panel {
    position: relative;
    background: linear-gradient(135deg, #8B0000, #FF0000);
    border: clamp(3px, 0.5%, 6px) solid rgba(255, 255, 255, 0.8);
    border-radius: clamp(1rem, 3%, 2rem);
    padding: clamp(0.5rem, 1%, 1rem) clamp(1rem, 2.5%, 1.6rem);
    margin-bottom: clamp(0.5rem, 1%, 1rem);
    flex-shrink: 0;
    width: 90%;
    align-self: flex-start;
    min-height: clamp(3rem, 7vh, 4.5rem);
    max-height: 38vh;
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.question-panel.entrance-animation {
    animation: questionEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes questionEntrance {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(-20px);
    }
    70% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.question-text {
    color: #FFFFFF;
    font-weight: bold;
    font-size: clamp(18px, 2.2vw, 30px);
    text-transform: uppercase;
    line-height: 1.25;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.countdown-display {
    position: absolute;
    top: 50%;
    right: clamp(1rem, 3%, 2rem);
    transform: translateY(-50%);
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 900;
    color: rgba(255, 255, 255, 0.7);
    font-family: Arial, "Arial Black", sans-serif;
    animation: countdownPulse 1s ease-out;
}

/* Host wants the countdown fully invisible to the audience. The delay/tick
   logic in app.js (scheduleCountdown) is untouched and keeps toggling
   style.display='block'/'none' inline — this !important rule overrides that
   inline style so the element is NEVER actually rendered, regardless. */
#countdownDisplay {
    display: none !important;
}

@keyframes countdownPulse {
    0% {
        transform: translateY(-50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-50%) scale(1.2);
    }
    100% {
        transform: translateY(-50%) scale(1);
        opacity: 0.7;
    }
}

/* ============================================================
   ANSWER PILLS
   ============================================================ */

.answer-pills-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(6px, 1vh, 14px);
    margin-bottom: clamp(0.4rem, 0.8%, 0.7rem);
    width: 88%;
    align-self: flex-start;
    /* This is the ONE flexible region between the fixed-size question panel
       above and the fixed-size HUD/footer below: it grows to fill whatever
       vertical space is left. Internal scrolling is intentionally NOT used
       here (it used to cause an ugly scrollbar that cut pills A and D) —
       instead, the surrounding elements and the pill min-heights below are
       sized so all 4 pills always fit on screen without scrolling, even at
       720p and even if every answer wraps to 2 lines. justify-content:center
       keeps the pills vertically centered in whatever space is left over. */
    flex: 1 1 auto;
    min-height: 0;
}

.answer-pill {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1%, 1rem);
    padding: clamp(0.3rem, 0.7%, 0.5rem) clamp(0.7rem, 1.8%, 1.2rem);
    background: rgba(255, 250, 205, 0.9);
    border: 2px solid transparent;
    border-radius: clamp(1.5rem, 3%, 3rem);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    /* ~44px floor at 720p, scaling up to ~65-77px at 1080p+ via vh. Text
       that wraps to 2 lines still grows the pill past this floor — sized
       (together with .answer-pills-container's gap and the rest of the
       column's fixed-size elements) so all 4 pills always fit on screen
       without scrolling, even at 720p with every answer wrapped to 2 lines. */
    min-height: clamp(44px, 6vh, 76px);
    box-sizing: border-box;
}

.answer-pill.pop-animation {
    animation: pillPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    /* Safety net: guarantees full visibility even if the animation is
       skipped/interrupted for any reason — never rely on fill-mode alone. */
    opacity: 1;
}

@keyframes pillPop {
    0% {
        opacity: 0;
        transform: scale(0.6);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.answer-pill:hover {
    background: #FFD700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.answer-pill.selected {
    background: #FFD700;
    border-color: #FF8C00;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8),
                inset 0 0 10px rgba(255, 165, 0, 0.3);
}

.answer-pill.correct {
    background: #00CC00;
    border-color: #008800;
    animation: correctPulse 0.8s ease-out;
}

@keyframes correctPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(0, 200, 0, 0.8);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(0, 200, 0, 1);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(0, 200, 0, 0.5);
    }
}

.answer-pill.wrong {
    animation: wrongFlash 0.5s ease-out;
}

@keyframes wrongFlash {
    0%, 100% {
        background: rgba(255, 250, 205, 0.9);
        transform: scale(1);
    }
    25%, 75% {
        background: #FF4444;
        transform: scale(1.02);
    }
}

.answer-badge {
    position: relative;
    min-width: clamp(2.4rem, 5.6vh, 3.7rem);
    width: clamp(2.4rem, 5.6vh, 3.7rem);
    height: clamp(2.4rem, 5.6vh, 3.7rem);
    background: #003D82;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: clamp(1.1rem, 2.4vh, 1.6rem);
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.answer-text {
    flex: 1;
    color: #003D82;
    font-weight: bold;
    /* Answer options in the question bank run long (many wrap to 2-3 lines
       even at the floor size), so the preferred term is tuned to stay near
       the 16px floor at 720p rather than jumping straight to 26px — that
       keeps 4 wrapped pills fittable without scrolling the pills area,
       while still scaling up naturally on taller/wider canvases (1080p+). */
    font-size: clamp(18px, 1.5vw, 29px);
    text-transform: uppercase;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.justification-text {
    display: none !important;
    color: #FFFFFF;
    font-size: clamp(0.8rem, 1.5vw, 1.2rem);
    font-style: italic;
    margin-top: clamp(0.5rem, 1%, 1rem);
    padding: clamp(0.5rem, 1%, 1rem);
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid #FFD700;
    border-radius: 0.3rem;
}

/* ============================================================
   HUD AREA (Level, Progress)
   ============================================================ */

.hud-area {
    /* Only the (visually hidden) question counter lives here now — the
       level badge was removed and "FALTAM X..." moved up next to the logo
       (see .remaining-top) — so this area no longer needs spacing of its
       own; the gap between pills and footer comes from footer-area's
       margin-top instead. */
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.progress-text {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

#questionCounter {
    /* Host explicitly does not want this counter ever visible to the
       audience. Kept in the DOM (app.js still writes its textContent so
       rung/progress logic stays intact) — just permanently hidden. */
    display: none;
}


/* ============================================================
   FOOTER AREA
   ============================================================ */

.footer-area {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1%, 1rem);
    margin-top: clamp(0.5rem, 1%, 1rem);
    flex-shrink: 0;
}

#eventLogo {
    max-width: clamp(120px, 12vw, 160px);
    max-height: clamp(3.5rem, 7vh, 5rem);
    width: auto;
    object-fit: contain;
}

#eventLogo:not([src]), #eventLogo.error {
    display: none;
}

/* ============================================================
   OVERLAYS (confined to left column via position:absolute)
   ============================================================ */

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: clamp(0.5rem, 1%, 1rem);
    padding: clamp(1rem, 2%, 2rem);
}

.overlay.overlay-active {
    display: flex;
}

.overlay-content {
    text-align: center;
    color: white;
    display: flex;
    flex-direction: column;
    gap: clamp(1rem, 2%, 2rem);
    align-items: center;
}

.overlay-content h1 {
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 900;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.overlay-content h2 {
    font-size: clamp(1.3rem, 3vw, 2.5rem);
    font-weight: bold;
    text-transform: uppercase;
}

.overlay-content p {
    font-size: clamp(1rem, 2vw, 1.5rem);
    max-width: 90%;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    padding: clamp(0.6rem, 1.5%, 1.2rem) clamp(1.2rem, 2.5%, 2rem);
    font-size: clamp(0.9rem, 2vw, 1.4rem);
    font-weight: bold;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.btn-primary {
    background: #FFD700;
    color: #333;
}

.btn-primary:hover:not(:disabled) {
    background: #FFA500;
    transform: scale(1.05);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   HOST CONTROL BAR (bottom, outside green area)
   ============================================================ */

.host-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    height: auto;
    background: rgba(0, 0, 0, 0.8);
    border-top: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1%, 1rem);
    padding: clamp(0.5rem, 1%, 1rem);
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
    /* Must stay above the overlays (z-index 100) so the host controls
       (NOVO, VALIDAR, ZERAR...) remain clickable during start/win/wrong screens. */
    z-index: 1000;
    /* Only span the left portion (not over the green) — 50% of screen */
    width: 50%;
    flex-wrap: wrap;
}

.host-btn, .host-select {
    padding: clamp(0.3rem, 0.8%, 0.6rem) clamp(0.6rem, 1.2%, 1rem);
    font-size: clamp(0.75rem, 1.3vw, 1rem);
    font-weight: bold;
    background: rgba(100, 100, 100, 0.8);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.host-btn:hover:not(:disabled) {
    background: rgba(150, 150, 150, 0.9);
    border-color: rgba(255, 255, 255, 0.6);
}

.host-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.host-select {
    background: rgba(80, 80, 80, 0.9);
    color: white;
}

.host-label {
    color: rgba(255, 255, 255, 0.7);
    font-weight: bold;
    white-space: nowrap;
}

.host-counter {
    color: rgba(255, 255, 255, 0.8);
    font-size: clamp(0.7rem, 1.2vw, 1rem);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ============================================================
   CONFETTI ANIMATION
   ============================================================ */

.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

.confetti-piece {
    position: absolute;
    width: clamp(4px, 1vw, 12px);
    height: clamp(4px, 1vw, 12px);
    opacity: 1;
    animation: fall linear;
    pointer-events: none;
}

@keyframes fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0;
    }
}

/* ============================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================ */

/* For smaller screens (1280x720 and below) */
@media (max-height: 800px) {
    .main-container {
        grid-template-columns: 1fr 1fr;
    }

    .left-column {
        /* Still clears the ~60-65px host-bar, just with less slack than the
           taller-viewport default, to give the answer pills more room. */
        padding-bottom: clamp(6rem, 10%, 7rem);
    }

    .logo-area {
        height: clamp(2.4rem, 6%, 3.6rem);
        margin-bottom: 0.4rem;
    }

    .question-panel {
        min-height: clamp(2.5rem, 6vh, 4rem);
        margin-bottom: 0.4rem;
    }

    .answer-pills-container {
        gap: 6px;
        margin-bottom: 0.3rem;
    }
}

/* ============================================================
   COMPACT SCALING (JS-driven, via fitContent() in app.js)
   Applied to .left-column when the rendered content (question +
   4 answer pills) would otherwise overflow into the footer area
   or off-screen (mainly 1280x720 with long questions/answers).
   Specificity here (.left-column.compact <descendant>) is higher
   than both the base rules above and the max-height:800px media
   query rules (single-class selectors), so these always win
   regardless of viewport height or source order.
   ============================================================ */

.left-column.compact .question-text {
    font-size: clamp(15px, 1.9vw, 26px);
}

.left-column.compact .question-panel {
    padding: clamp(0.35rem, 0.8%, 0.7rem) clamp(0.7rem, 2%, 1.2rem);
    min-height: clamp(2.5rem, 5.5vh, 3.8rem);
    margin-bottom: 0.35rem;
}

.left-column.compact .answer-pills-container {
    gap: clamp(4px, 0.7vh, 10px);
    margin-bottom: 0.3rem;
}

.left-column.compact .answer-pill {
    min-height: clamp(36px, 5vh, 60px);
}

.left-column.compact .answer-text {
    font-size: clamp(15px, 1.3vw, 25px);
}

.left-column.compact2 .question-text {
    font-size: clamp(13px, 1.6vw, 22px);
}

.left-column.compact2 .question-panel {
    padding: clamp(0.25rem, 0.6%, 0.5rem) clamp(0.5rem, 1.5%, 0.9rem);
    min-height: clamp(2rem, 4.5vh, 3rem);
    margin-bottom: 0.25rem;
}

.left-column.compact2 .answer-pills-container {
    gap: clamp(3px, 0.5vh, 6px);
    margin-bottom: 0.2rem;
}

.left-column.compact2 .answer-pill {
    min-height: clamp(30px, 4vh, 48px);
}

.left-column.compact2 .answer-text {
    font-size: clamp(13px, 1.1vw, 20px);
}

.left-column.compact2 .logo-area {
    height: clamp(1.8rem, 4.5%, 2.7rem);
    margin-bottom: 0.3rem;
}

/* Ensure no elements extend into green column */
.left-column > * {
    max-width: 100%;
}

.overlay {
    /* Ensure overlay stays within left-column bounds */
    pointer-events: auto;
}

.overlay.overlay-active {
    pointer-events: auto;
}

#wrongOverlay { display: none !important; }

