@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;800&family=Syne:wght@400;600;700;800&display=swap');

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

:root {
    --bg: #050c18;
    --surf: #091424;
    --surf2: #0d1b30;
    --border: #1a3050;
    --glow: #1e4880;
    --accent: #1a8cff;
    --gold: #f5c542;
    --green: #1fd978;
    --red: #ff2d55;
    --text: #b8cce8;
    --dim: #4a6a8a;
    --bright: #e0ecff;
    --mono: 'JetBrains Mono', monospace;
    --sans: 'Syne', sans-serif;
}

html,
body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--bg);
    font-family: var(--sans);
}

/* ── LOADING ── */
#loadingScreen {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.4rem;
    transition: opacity .4s, visibility .4s;
}

#loadingScreen.gone {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.spin {
    width: 38px;
    height: 38px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.load-txt {
    font-family: var(--mono);
    font-size: .7rem;
    letter-spacing: 2px;
    color: var(--dim);
    text-transform: uppercase;
}

/* ── GATE ── */
#gateScreen {
    position: fixed;
    inset: 0;
    z-index: 8000;
    background: var(--bg);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.8rem;
}

#gateScreen.show {
    display: flex;
}

.gate-mono {
    font-family: var(--mono);
    font-size: .65rem;
    letter-spacing: 4px;
    color: var(--accent);
    text-transform: uppercase;
}

.gate-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    border: 2px solid var(--glow);
    background: var(--surf);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 18px rgba(26, 140, 255, .1)
    }

    50% {
        box-shadow: 0 0 48px rgba(26, 140, 255, .35)
    }
}

.gate-title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 800;
    color: var(--bright);
    text-align: center;
    line-height: 1.1;
}

.gate-title em {
    font-style: normal;
    color: var(--accent);
}

.gate-rules {
    background: var(--surf);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rule-row {
    display: flex;
    gap: .7rem;
    align-items: flex-start;
    font-size: .82rem;
    color: var(--text);
    line-height: 1.4;
}

.ri {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: .05rem;
}

.btn-enter {
    font-family: var(--sans);
    font-weight: 800;
    font-size: .95rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--bg);
    background: var(--accent);
    border: none;
    padding: .95rem 2.5rem;
    border-radius: 3px;
    cursor: pointer;
    transition: .15s;
}

.btn-enter:hover {
    filter: brightness(1.15);
}

.btn-enter:active {
    transform: scale(.97);
}

/* ── HARD INTERCEPT WALL ── z:7000
           Shown immediately on any focus loss / tab switch / back attempt.
           Covers EVERYTHING. User MUST click the button. ── */
#interceptWall {
    position: fixed;
    inset: 0;
    z-index: 7000;
    background: var(--bg);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.6rem;
    /* No pointer-events restriction — captures all clicks */
}

#interceptWall.show {
    display: flex;
}

.iw-ring {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 3px solid var(--red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    animation: ringpulse 1s ease-in-out infinite;
}

@keyframes ringpulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 45, 85, .5)
    }

    50% {
        box-shadow: 0 0 0 22px rgba(255, 45, 85, 0)
    }
}

.iw-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--red);
    text-align: center;
    letter-spacing: .3px;
}

.iw-sub {
    font-family: var(--mono);
    font-size: .72rem;
    color: var(--dim);
    letter-spacing: 1px;
    text-align: center;
    max-width: 340px;
    line-height: 1.7;
}

.iw-dots {
    display: flex;
    gap: 9px;
}

.iwdot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--border);
    transition: .2s;
}

.iwdot.on {
    background: var(--red);
    box-shadow: 0 0 8px var(--red);
}

.iw-count {
    font-family: var(--mono);
    font-size: .65rem;
    letter-spacing: 2px;
    color: var(--dim);
    text-transform: uppercase;
}

.iw-warn {
    font-family: var(--mono);
    font-size: .7rem;
    color: #ff6080;
    background: rgba(255, 45, 85, .08);
    border: 1px solid rgba(255, 45, 85, .25);
    padding: .4rem 1rem;
    border-radius: 3px;
    text-align: center;
}

.btn-return {
    font-family: var(--sans);
    font-weight: 800;
    font-size: .9rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #fff;
    background: var(--red);
    border: none;
    padding: .85rem 2.2rem;
    border-radius: 3px;
    cursor: pointer;
    transition: .15s;
    animation: btnpulse 1.5s ease-in-out infinite;
}

@keyframes btnpulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 45, 85, .4)
    }

    50% {
        box-shadow: 0 0 0 12px rgba(255, 45, 85, 0)
    }
}

.btn-return:hover {
    filter: brightness(1.2);
}

/* ── FS EXIT SUB-LAYER ── z:7500 — sits above intercept wall */
#fsLayer {
    position: fixed;
    inset: 0;
    z-index: 7500;
    background: rgba(5, 12, 24, .96);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.4rem;
}

#fsLayer.show {
    display: flex;
}

.fsl-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--red);
    text-align: center;
}

.fsl-cd {
    font-family: var(--mono);
    font-size: 3rem;
    font-weight: 800;
    color: var(--red);
    line-height: 1;
}

.fsl-sub {
    font-size: .8rem;
    color: var(--dim);
    text-align: center;
}

.btn-refs {
    font-family: var(--sans);
    font-weight: 700;
    font-size: .85rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #fff;
    background: var(--red);
    border: none;
    padding: .75rem 2rem;
    border-radius: 3px;
    cursor: pointer;
}

/* ── EXAM SHELL ── z:100 */
#examShell {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    flex-direction: column;
    background: var(--bg);
    overflow: hidden;
}

#examShell.show {
    display: flex;
}

.topbar {
    height: 58px;
    flex-shrink: 0;
    background: var(--surf);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.8rem;
    gap: 1rem;
}

.topbar-l {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.badge {
    font-family: var(--mono);
    font-size: .6rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--green);
    background: rgba(31, 217, 120, .07);
    border: 1px solid rgba(31, 217, 120, .25);
    padding: 3px 9px;
    border-radius: 2px;
}

.etitle {
    font-weight: 700;
    font-size: .95rem;
    color: var(--bright);
}

.topbar-r {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.meta {
    font-family: var(--mono);
    font-size: .65rem;
    color: var(--dim);
}

.meta strong {
    color: var(--text);
}

.timer-pill {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--surf2);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 4px 14px;
}

.tlbl {
    font-family: var(--mono);
    font-size: .55rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--dim);
}

#timerDisplay {
    font-family: var(--mono);
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--gold);
    min-width: 5ch;
}

#timerDisplay.urgent {
    color: var(--red);
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    50% {
        opacity: .35
    }
}

#warnStrip {
    flex-shrink: 0;
    display: none;
    align-items: center;
    gap: .6rem;
    background: linear-gradient(90deg, #2a0010, #150008);
    border-bottom: 1px solid var(--red);
    padding: 6px 1.8rem;
    font-family: var(--mono);
    font-size: .72rem;
    color: #ffb0c0;
}

#warnStrip.show {
    display: flex;
}

.sdots {
    display: flex;
    gap: 5px;
    margin-left: auto;
}

.sdot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: .2s;
}

.sdot.on {
    background: var(--red);
    box-shadow: 0 0 6px var(--red);
}

#qScroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.8rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

#qScroll::-webkit-scrollbar {
    width: 4px;
}

#qScroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.q-card {
    background: var(--surf);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1.5rem 1.7rem;
    margin-bottom: 1.3rem;
    border-left: 3px solid var(--glow);
    transition: .15s;
}

.q-card.answered {
    border-left-color: var(--accent);
}

.qnum {
    font-family: var(--mono);
    font-size: .6rem;
    color: var(--dim);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: .5rem;
}

.qtext {
    font-size: 1rem;
    font-weight: 600;
    color: var(--bright);
    line-height: 1.5;
    margin-bottom: 1.2rem;
}

.opts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .55rem;
}

@media(max-width:560px) {
    .opts {
        grid-template-columns: 1fr;
    }
}

.opt {
    display: flex;
    align-items: center;
    gap: .7rem;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: .6rem .95rem;
    border-radius: 3px;
    cursor: pointer;
    transition: .12s;
}

.opt:hover {
    border-color: var(--accent);
    background: rgba(26, 140, 255, .05);
}

.opt.sel {
    border-color: var(--accent);
    background: rgba(26, 140, 255, .1);
}

.opt input {
    display: none;
}

.optk {
    font-family: var(--mono);
    font-size: .65rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--surf2);
    border: 1px solid var(--glow);
    width: 21px;
    height: 21px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-transform: uppercase;
    transition: .12s;
}

.opt.sel .optk {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.optlbl {
    font-size: .88rem;
    color: var(--text);
    line-height: 1.3;
}

.qfoot {
    margin-top: .9rem;
    padding-top: .7rem;
    border-top: 1px solid var(--border);
    font-family: var(--mono);
    font-size: .65rem;
    color: var(--dim);
    text-align: right;
}

.qfoot .pos {
    color: var(--green);
}

.qfoot .neg {
    color: var(--red);
}

.botbar {
    height: 62px;
    flex-shrink: 0;
    background: var(--surf);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.8rem;
}

.prog-wrap {
    display: flex;
    align-items: center;
    gap: .8rem;
}

.plbl {
    font-family: var(--mono);
    font-size: .6rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--dim);
}

.pbar {
    width: 140px;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.pfill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width .3s;
}

.pct {
    font-family: var(--mono);
    font-size: .7rem;
    color: var(--text);
}

.btn-sub {
    font-family: var(--sans);
    font-weight: 800;
    font-size: .8rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--bg);
    background: var(--accent);
    border: none;
    padding: .65rem 1.8rem;
    border-radius: 3px;
    cursor: pointer;
    transition: .15s;
}

.btn-sub:hover {
    filter: brightness(1.2);
}

.btn-sub:active {
    transform: scale(.97);
}

/* ── ENDED SCREEN ── z:9999 permanent */
#endedScreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.8rem;
}

#endedScreen.show {
    display: flex;
}

.end-icon {
    font-size: 3.5rem;
}

.end-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--bright);
    text-align: center;
}

.end-score {
    font-family: var(--mono);
    font-size: 3.2rem;
    font-weight: 800;
    color: var(--green);
    line-height: 1;
}

.end-sub {
    font-size: .85rem;
    color: var(--dim);
    text-align: center;
    line-height: 1.8;
    max-width: 380px;
}

.end-viol {
    font-size: .8rem;
    color: var(--red);
    text-align: center;
}

.end-lock {
    font-family: var(--mono);
    font-size: .65rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--dim);
    background: var(--surf);
    border: 1px solid var(--border);
    padding: .5rem 1.2rem;
    border-radius: 2px;
}

/* ── FLASH ── */
#flashFx {
    position: fixed;
    inset: 0;
    z-index: 6999;
    background: rgba(255, 45, 85, .07);
    border: 3px solid var(--red);
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
}

#flashFx.on {
    opacity: 1;
}

/* Video Container - Upper Right Corner */
#videoContainer {
    position: fixed;
    top: 5vh;
    right: 20px;
    width: 150px;
    height: 100px;
    background: #1a1a2e;
    border: 2px solid var(--glow, #00d4ff);
    border-radius: 8px;
    overflow: hidden;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#videoContainer.active {
    opacity: 1;
    visibility: visible;
}

#videoContainer.error {
    border-color: #ff2d55;
    background: rgba(255,45,85,0.1);
}

#userVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror effect for natural self-view */
}

#videoErrorMsg {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.8);
    color: #ff2d55;
    font-size: 10px;
    padding: 4px 8px;
    text-align: center;
    font-family: var(--mono, monospace);
}

/* Optional: Add a small indicator for microphone */
#micIndicator {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: #00ff00;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}