:root {
    --bg-color: #050505;
    --terminal-bg: #0a0a0a;
    --crt-green: #39ffb6;
    --crt-green-dim: rgba(57, 255, 182, 0.1);
    --alert-red: #ff2a2a;
    --alert-red-dim: rgba(255, 42, 42, 0.15);
    --electric-blue: #00f0ff;
    --text-main: #e0e0e0;
    --scanline: rgba(0, 0, 0, 0.5);
    /* Palette - High Contrast Neon */
    --bg-deep: #020202;
    --bg-panel: rgba(10, 15, 20, 0.85);
    --neon-green: #0f0;
    --neon-green-dim: rgba(0, 255, 0, 0.1);
    --neon-red: #ff003c;
    --neon-red-dim: rgba(255, 0, 60, 0.1);
    --neon-blue: #00f3ff;
    --neon-blue-dim: rgba(0, 243, 255, 0.1);
    --neon-gold: #fcee0a;
    --grid-color: rgba(0, 243, 255, 0.15);
    --font-head: 'Orbitron', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
}

* {
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--neon-blue) var(--bg-deep);
}

body {
    margin: 0;
    background-color: var(--bg-color);
    font-family: 'Share Tech Mono', monospace;
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

/* Chroma Key Mode */
body.chroma-mode {
    background-color: #00b140 !important;
    background-image: none !important;
    --crt-green: #ffb000;
    --crt-green-dim: rgba(255, 176, 0, 0.15);
}

body.chroma-mode .scanlines,
body.chroma-mode .vignette,
body.chroma-mode .crt-overlay,
body.chroma-mode .cyber-grid {
    display: none;
}

body.chroma-mode .panel {
    background: rgba(10, 10, 10, 0.98);
}

/* CRT Overlay Effect */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.2) 50%, rgba(0, 0, 0, 0.2));
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 999;
    opacity: 0.6;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.8) 100%);
    pointer-events: none;
    z-index: 998;
}

/* Containers */
#app-container {
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    display: grid;
    gap: 20px;
    position: relative;
    z-index: 1;
}

/* Panels */
.panel {
    background: var(--terminal-bg);
    border: 2px solid var(--crt-green-dim);
    box-shadow: 0 0 15px var(--crt-green-dim);
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.panel::before {
    content: "SYSTEM_MONITOR";
    position: absolute;
    top: -10px;
    left: 20px;
    background: var(--bg-color);
    padding: 0 10px;
    color: var(--crt-green);
    font-size: 0.8rem;
    letter-spacing: 2px;
}

/* Typography */
h1 {
    margin: 0;
    color: var(--crt-green);
    text-shadow: 0 0 5px var(--crt-green);
    font-size: 2rem;
}

h2 {
    margin: 0 0 10px 0;
    color: var(--electric-blue);
    font-size: 1.2rem;
    border-bottom: 1px solid var(--electric-blue);
    padding-bottom: 5px;
}

h3 {
    margin: 0 0 5px 0;
    color: var(--crt-green);
    font-size: 1rem;
}

.glitch-text {
    animation: glitch 1s infinite alternate;
}

/* Lobby */
#lobby-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    border: 2px solid var(--crt-green);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0, 255, 0, 0.02) 10px, rgba(0, 255, 0, 0.02) 20px);
}

#host-settings {
    margin: 20px 0;
    padding: 15px;
    border: 1px dashed var(--electric-blue);
    display: flex;
    gap: 15px;
    text-align: left;
    flex-wrap: wrap;
    justify-content: center;
}

.setting-group {
    display: flex;
    flex-direction: column;
}

.setting-group label {
    font-size: 0.8rem;
    color: #dddddd;
    margin-bottom: 5px;
}

.setting-group input[type="number"],
.setting-group input[type="text"] {
    width: 100%;
    min-width: 100px;
    padding: 5px;
    font-size: 1rem;
}

input[type="text"],
input[type="number"],
input[type="password"] {
    background: black;
    border: 1px solid var(--crt-green);
    color: var(--crt-green);
    padding: 15px;
    font-family: 'Fira Code', monospace;
    font-size: 1.2rem;
    margin: 10px 0;
    text-align: center;
    text-transform: uppercase;
}

input:focus {
    outline: none;
    box-shadow: 0 0 10px var(--crt-green);
}

.eye-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: black;
    border: 1px solid var(--crt-green);
    color: var(--crt-green);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 5px 10px;
    text-transform: uppercase;
    font-family: 'Share Tech Mono', monospace;
    transition: all 0.2s;
}

.eye-btn:hover {
    background: var(--crt-green);
    color: black;
}

.eye-btn::after {
    content: "[HIDE]";
}

.eye-btn.hidden::after {
    content: "[VIEW]";
    color: var(--alert-red);
}

.eye-btn.hidden {
    border-color: var(--alert-red);
}

/* Streamer Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle-box {
    width: 20px;
    height: 20px;
    border: 1px solid var(--crt-green);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-box.checked::after {
    content: 'X';
    color: var(--crt-green);
    font-weight: bold;
}

.btn {
    background: var(--crt-green-dim);
    border: 1px solid var(--crt-green);
    color: var(--crt-green);
    padding: 15px 30px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.2rem;
    cursor: pointer;
    transition: 0.2s;
    text-transform: uppercase;
    margin: 5px;
}

.btn:hover {
    background: var(--crt-green);
    color: black;
    box-shadow: 0 0 15px var(--crt-green);
}

.btn.danger {
    border-color: var(--alert-red);
    color: var(--alert-red);
    background: var(--alert-red-dim);
}

.btn.danger:hover {
    background: var(--alert-red);
    color: black;
    box-shadow: 0 0 15px var(--alert-red);
}

.btn:disabled {
    opacity: 0.2;
    pointer-events: none;
    filter: grayscale(100%);
    border-color: #333;
    color: #555;
}

/* Streamer Toolbar */
#streamer-toolbar {
    display: none;
    position: absolute;
    top: -50px;
    right: 0;
    background: #000;
    border: 1px solid var(--electric-blue);
    padding: 5px;
    gap: 10px;
    z-index: 1000;
    align-items: center;
}

.streamer-btn {
    font-size: 0.8rem;
    padding: 5px 10px;
    border: 1px solid #555;
    background: #111;
    color: #aaa;
    cursor: pointer;
}

.streamer-btn:hover {
    border-color: var(--electric-blue);
    color: var(--electric-blue);
}

#twitch-status {
    font-size: 0.8rem;
    color: #555;
    font-weight: bold;
    padding-right: 10px;
}

/* Game Grid */
#game-view {
    display: none;
    grid-template-columns: 250px 1fr 300px;
    grid-template-rows: 60px 1fr;
    height: 100%;
    gap: 15px;
}

/* Header */
header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--crt-green);
    padding-bottom: 10px;
    position: relative;
}

/* Left Sidebar: Users */
#user-panel {
    grid-row: 2;
    grid-column: 1;
    overflow-y: auto;
}

.user-card {
    padding: 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid #555;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    transition: all 0.3s;
}

.user-card-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
}

.user-card.submitted {
    border-left-color: var(--crt-green);
    background: var(--crt-green-dim);
    box-shadow: inset 0 0 10px var(--crt-green-dim);
}

.user-card.sysadmin {
    border-color: var(--crt-green);
    color: var(--crt-green);
}

.user-card.sus {
    border-color: var(--alert-red);
    animation: pulseRed 1s infinite;
}

.user-card.banned {
    opacity: 0.3;
    text-decoration: line-through;
    border-color: var(--alert-red);
    color: var(--alert-red);
}

/* Chat Sus Badge */
.chat-sus-badge {
    font-size: 0.7rem;
    color: var(--alert-red);
    background: rgba(255, 0, 0, 0.1);
    padding: 2px 5px;
    margin-top: 4px;
    border: 1px solid var(--alert-red);
    display: none;
    width: 100%;
    text-align: center;
    animation: blink 1s infinite;
}

/* NEW: Sabotage Button */
.sabotage-btn {
    font-size: 0.6rem;
    background: black;
    color: #dddddd;
    border: 1px solid #555;
    cursor: pointer;
    padding: 2px 5px;
    margin-left: 5px;
}

.sabotage-btn:hover {
    color: var(--alert-red);
    border-color: var(--alert-red);
}

/* Center: Main Terminal */
#main-panel {
    grid-row: 2;
    grid-column: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

#question-display {
    font-size: 1.8rem;
    line-height: 1.6;
    text-align: center;
    max-width: 800px;
    margin-bottom: 30px;
}

/* Encrypted State */
#encrypted-overlay {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--terminal-bg);
    z-index: 10;
}

.lock-icon {
    font-size: 4rem;
    color: var(--electric-blue);
    margin-bottom: 20px;
}

.q-word {
    display: inline-block;
    padding: 2px 5px;
    border-radius: 4px;
    margin: 0 2px;
    cursor: default;
}

.admin-mode .q-word:hover {
    background: var(--alert-red);
    color: black;
    cursor: pointer;
}

.q-word.redacted {
    background: black;
    color: var(--alert-red);
    border: 1px dashed var(--alert-red);
}

.q-word.glitched {
    color: var(--alert-red);
    font-family: 'Fira Code', monospace;
    text-shadow: 2px 0 red, -2px 0 blue;
}

/* Right Sidebar: Controls */
#control-panel {
    grid-row: 2;
    grid-column: 3;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#health-container {
    height: 30px;
    width: 100%;
    border: 2px solid var(--crt-green);
    padding: 2px;
    margin-bottom: 10px;
}

#health-fill {
    height: 100%;
    width: 100%;
    background: var(--crt-green);
    transition: width 0.5s;
}

#health-fill.critical {
    background: var(--alert-red);
    animation: pulseRed 0.2s infinite;
}

#timer-container {
    text-align: center;
    margin-bottom: 20px;
    border: 1px solid #333;
    padding: 10px;
}

#timer-label {
    font-size: 0.8rem;
    color: #dddddd;
}

#timer-display {
    font-size: 2.5rem;
    color: var(--crt-green);
    font-weight: bold;
}

#admin-controls {
    display: none;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    overflow-y: auto;
}

.admin-mode #admin-controls {
    display: flex;
}

#incoming-data-container {
    display: none;
    width: 100%;
    max-width: 800px;
    margin-top: 30px;
    border-top: 1px dashed #333;
    padding-top: 10px;
}

.admin-mode #incoming-data-container {
    display: block !important;
}

select {
    width: 100%;
    background: black;
    color: white;
    padding: 10px;
    border: 1px solid #555;
}

#answer-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 600px;
}

textarea {
    width: 100%;
    max-width: 600px;
    background: #111;
    color: var(--crt-green);
    border: 1px solid var(--crt-green);
    padding: 10px;
    font-family: inherit;
    font-size: 1.2rem;
}

#results-list {
    flex-grow: 1;
    overflow-y: auto;
    font-size: 1.3rem;
    padding-top: 10px;
    max-height: 300px;
}

.result-item {
    margin-bottom: 5px;
    padding: 5px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
}

.result-item .ans {
    color: var(--electric-blue);
    font-weight: bold;
    margin-left: 10px;
}

.ban-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
    background: white;
    color: black;
    border: none;
    cursor: pointer;
}

.ban-btn:hover {
    font-size: 0.8rem;
    background: var(--alert-red);
    color: white;
}

/* Instructions Modal */
#instructions-modal,
#solitaire-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 5000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #0a0a0a;
    border: 2px solid var(--crt-green);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    position: relative;
    box-shadow: 0 0 40px var(--crt-green-dim);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: var(--alert-red);
    cursor: pointer;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

@media (max-width: 700px) {
    .modal-grid {
        grid-template-columns: 1fr;
    }
}

.instruction-section {
    margin-bottom: 20px;
    line-height: 21px;
}

.instruction-section h3 {
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
    color: var(--electric-blue);
}

.instruction-section p,
.instruction-section ul {
    font-size: 0.9rem;
    color: #ccc;
    line-height: 1.6;
}

.role-badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.7rem;
    border-radius: 4px;
    margin-right: 5px;
}

.role-sys {
    border: 1px solid var(--crt-green);
    color: var(--crt-green);
}

.role-hack {
    border: 1px solid var(--alert-red);
    color: var(--alert-red);
}

.role-user {
    border: 1px solid #ccc;
    color: #ccc;
}

@keyframes pulseRed {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@keyframes glitch {
    0% {
        transform: translate(0)
    }

    20% {
        transform: translate(-2px, 2px)
    }

    40% {
        transform: translate(-2px, -2px)
    }

    60% {
        transform: translate(2px, 2px)
    }

    80% {
        transform: translate(2px, -2px)
    }

    100% {
        transform: translate(0)
    }
}

@keyframes blink {
    0% {
        opacity: 0.2;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.2;
    }
}

/* --- MELTDOWN ANIMATIONS --- */

/* 1. Violent Screen Shake */
@keyframes shake-hard {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-3px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

/* 2. Red Alert Background Pulse */
@keyframes red-strobe {
    0% {
        background: rgba(0, 0, 0, 0.9);
        box-shadow: inset 0 0 0 red;
    }

    50% {
        background: rgba(50, 0, 0, 0.95);
        box-shadow: inset 0 0 100px red;
    }

    100% {
        background: rgba(0, 0, 0, 0.9);
        box-shadow: inset 0 0 0 red;
    }
}

/* 3. The Glitch Text Effect */
@keyframes glitch-skew {
    0% {
        transform: skew(0deg);
    }

    20% {
        transform: skew(-20deg);
    }

    40% {
        transform: skew(20deg);
    }

    60% {
        transform: skew(-5deg);
    }

    80% {
        transform: skew(5deg);
    }

    100% {
        transform: skew(0deg);
    }
}

/* Classes to apply via JS */
.meltdown-mode .panel,
.meltdown-mode header {
    animation: shake-hard 0.5s infinite;
    filter: blur(1px) contrast(200%);
    border-color: red !important;
}

.meltdown-overlay {
    animation: red-strobe 0.8s infinite;
}

.hacker-win-text {
    animation: glitch-skew 0.3s infinite;
    color: red !important;
    text-shadow: 4px 0 white, -4px 0 blue;
}

/* Matrix Rain Characters */
.corruption-char {
    position: absolute;
    color: rgba(255, 0, 0, 0.4);
    font-family: 'Fira Code', monospace;
    font-weight: bold;
    user-select: none;
    pointer-events: none;
    z-index: 2999;
    /* Behind the victory modal (3000) */
}

/* Boot Sequence Overlay */
#boot-sequence {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: 10000;
    padding: 20px;
    font-family: var(--font-code);
    font-size: 1.1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    margin: 0;
    color: var(--crt-green);
    text-shadow: 0 0 5px var(--crt-green);
    line-height: 1.7rem;
}

/* --- CRT MONITOR EFFECTS --- */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 3px, 3px 100%;
    box-shadow: inset 0 0 8rem rgba(0, 0, 0, 0.7);
}

/* Utility */

.text-neon {
    color: var(--neon-green);
}

.text-alert {
    color: var(--neon-red);
}

.text-info {
    color: var(--neon-blue);
}

/* Moving Grid Background */
.cyber-grid {
    position: fixed;
    width: 200vw;
    height: 200vh;
    left: -50%;
    top: -50%;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 50px 50px;
    transform: perspective(500px) rotateX(60deg) translateY(0);
    animation: gridMove 5s linear infinite;
    z-index: -2;
    opacity: 0.4;
    pointer-events: none;
}

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    /* For horizontal scrolling */
}

::-webkit-scrollbar-track {
    background: #000;
    border-left: 1px solid #222;
}

::-webkit-scrollbar-thumb {
    background: #111;
    border: 1px solid var(--neon-blue);
    /* Sci-fi "data block" look - no rounded corners */
    border-radius: 0;
    box-shadow: inset 0 0 5px var(--neon-blue-dim);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--neon-green-dim);
    border-color: var(--neon-green);
    box-shadow: 0 0 10px var(--neon-green);
    cursor: grab;
}

::-webkit-scrollbar-corner {
    background: #000;
}

/* ========================================================================== */
/* MOBILE DEVICE FIXES                             */
/* ========================================================================== */

@media (max-width: 900px) {

    /* 1. ENABLE SCROLLING: Remove fixed 100vh restrictions */
    body {
        height: auto;
        min-height: 100vh;
        overflow-y: auto;
        display: block;
        padding-top: 10px;
        /* Add breathing room top */
    }

    #app-container {
        height: auto;
        display: flex;
        flex-direction: column;
        margin: 0 auto;
        padding-bottom: 20px;
        /* Room for bottom scroll */
    }

    /* 2. FLEX STACK: Convert Grid to Column Flexbox */
    #game-view {
        display: none;
        flex-direction: column;
        height: auto;
        gap: 15px;
    }

    /* 3. REORDERING: Game & Controls BEFORE Users on Mobile */
    header {
        order: 1;
    }

    #control-panel {
        order: 2;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
        /* Make control panel compact */
    }

    #main-panel {
        order: 3;
        min-height: 400px;
        /* Ensure game area is tall enough */
    }

    #user-panel {
        order: 4;
        height: 250px;
        /* Fixed height for scrollable user list */
    }

    /* 4. COMPACT ELEMENTS */
    #health-container {
        width: 100%;
        margin-bottom: 5px;
    }

    #timer-container {
        width: 48%;
        margin: 0;
    }

    #admin-controls {
        width: 100%;
        border-top: 1px solid #333;
        padding-top: 10px;
        margin-top: 10px;
    }

    /* 5. FIX OVERSIZED FONTS */
    #question-display {
        font-size: 1.2rem;
        padding: 0 10px;
    }

    #banned-view h1,
    #victory-title {
        font-size: 2.5rem !important;
        /* Shrink huge text */
    }

    #banned-view h3,
    #victory-subtitle {
        font-size: 1.2rem !important;
    }
}

/* Background music toggle */
#btn-music-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 9999;
    padding: 0;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--crt-green-dim);
    color: var(--crt-green);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#btn-music-toggle.on {
    border-color: var(--crt-green);
    box-shadow: 0 0 10px var(--crt-green);
}

/* Connection lost banner */
.connection-banner {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: none;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--crt-green-dim);
    color: var(--crt-green);
    font-size: 0.85rem;
}

.connection-banner.error {
    border-color: var(--alert-red);
    color: var(--alert-red);
}

#screensaver-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 20000;
    display: none;
    cursor: none;
    /* Hide cursor for immersion */
}

/* Container moving around */
#saver-container {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
    max-width: 300px;
    user-select: none;
}

/* The Speech Bubble */
#saver-bubble {
    background: none;
    color: #000;
    padding: 15px;
    border-radius: 8px;
    position: relative;
    margin-bottom: 15px;
    font-family: 'Fira Code', monospace;
    font-weight: bold;
    font-size: 1.1rem;
    text-align: center;
    border: 3px solid currentColor;
    box-shadow: 0 0 15px currentColor;
    transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
    min-width: 400px;
}

/* The Triangle for the bubble */
#saver-bubble::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 15px 15px 0;
    border-style: solid;
    border-color: inherit transparent transparent transparent;
    /* Inherits color from parent */
    color: inherit;
    /* Needed for border-color inheritance trick in some browsers, mainly relies on parent border color matching bg if not set specifically. actually simpler: */
    border-top-color: inherit;
}

/* Fix for border color inheritance on pseudo elements is tricky, let's just make the arrow white (inner) and rely on effect */
#saver-bubble::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 12px 12px 0;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
    z-index: 1;
}

#saver-char {
    width: 120px;
    height: 120px;
    position: relative;
    image-rendering: pixelated;
    animation: bounce-char 0.5s infinite alternate;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Emoji layer */
#saver-char::before {
    content: "🤖";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    font-size: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    pointer-events: none;
    line-height: 1;
}


@keyframes bounce-char {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-12px);
    }
}

#saver-hint {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    color: #444;
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.8rem;
    animation: blink 2s infinite;
}

/* --- MINI PANEL ICONS --- */
#panel-footer-icons {
    margin-top: auto;
    /* Pushes to bottom of flex container */
    padding-top: 15px;
    border-top: 1px dashed #333;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}

.mini-icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #fff;
    font-size: 4rem;
    cursor: pointer;
    padding: 5px 10px;
    transition: all 0.2s;
    border-radius: 4px;
}

.mini-icon-btn:hover {
    color: var(--crt-green);
    text-shadow: 0 0 8px var(--crt-green);
    border-color: var(--crt-green-dim);
    background: rgba(0, 20, 0, 0.2);
}

.mini-icon-btn:active {
    transform: translateY(2px);
}

label.popup {
    cursor: help;
    border-bottom: 1px dotted var(--crt-green);
}

/* --- CUSTOM TOOLTIP STYLES --- */
/* The Floating Box */
#custom-tooltip {
    position: fixed;
    /* Fixed so it ignores scroll position */
    background: rgba(5, 5, 5, 0.95);
    border: 1px solid var(--electric-blue);
    color: var(--electric-blue);
    padding: 8px 12px;
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    z-index: 100000;
    /* Above everything, even modals */
    pointer-events: none;
    /* Mouse passes through it */
    display: none;
    /* Hidden by default */
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.15);
    max-width: 250px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* A decorative "corner" piece for extra tech-feel */
#custom-tooltip::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 6px;
    height: 6px;
    background: var(--electric-blue);
    box-shadow: 0 0 5px var(--electric-blue);
}

/* Header inside tooltip */
#custom-tooltip .tt-header {
    display: block;
    color: #fff;
    font-size: 0.65rem;
    opacity: 0.5;
    margin-bottom: 2px;
    border-bottom: 1px dashed rgba(0, 240, 255, 0.3);
    padding-bottom: 2px;
}

/* The Label Triggers */
.popup {
    cursor: help;
    position: relative;
    transition: color 0.2s;
    border-bottom: 1px dotted var(--electric-blue);
}

.popup:hover {
    text-shadow: 0 0 5px var(--electric-blue);
}

.madlib-prompts {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.madlib-label {
    font-size: 0.9rem;
    color: var(--crt-green);
    text-transform: uppercase;
}

.madlib-input {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--crt-green);
    padding: 6px 8px;
    color: #fff;
    font-family: inherit;
    margin-bottom: 6px;
}

.madlib-sentence {
    font-size: 1.05rem;
    line-height: 1.6;
}

.sabotaged {
    padding: 0 6px;
    background: #ff2a2a;
    color: #000;
}

/* --- URGENCY / PANIC ANIMATIONS --- */

/* 1. Red Alert Border Pulse */
@keyframes panic-border {
    0% {
        box-shadow: inset 0 0 0 var(--alert-red);
        border-color: var(--crt-green);
    }

    50% {
        box-shadow: inset 0 0 50px var(--alert-red-dim);
        border-color: var(--alert-red);
    }

    100% {
        box-shadow: inset 0 0 0 var(--alert-red);
        border-color: var(--crt-green);
    }
}

/* 2. Gentle Button Shake (Subtle enough to still click) */
@keyframes shake-gentle {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

/* The class we will add via JS */
body.panic-mode .panel {
    animation: panic-border 1s infinite;
    /* Flash borders */
}

body.panic-mode #timer-display {
    color: var(--alert-red) !important;
    transform: scale(1.5);
    /* Make timer big */
    text-shadow: 0 0 15px var(--alert-red);
    transition: all 0.3s;
}

body.panic-mode #answer-area button {
    animation: shake-gentle 0.5s infinite;
    /* Shake the submit button */
    background: var(--alert-red);
    color: black;
    border-color: white;
}

.encrypted {
    font-family: 'VT323', 'Consolas', 'Monaco', monospace;
    /* Use a pixelated font if possible */
    color: transparent;
    text-shadow: 0 0 8px rgba(0, 255, 0, 0.8);
    background-color: #001100;
    border: 1px dashed #00ff00;
    padding: 0 5px;
    cursor: help;
    user-select: none;
    /* Prevents user from highlighting to cheat */
    transition: all 0.3s ease;
}

/* Reveal slightly on hover */
.encrypted:hover {
    color: #00ff00;
    text-shadow: none;
    background-color: #000;
    filter: contrast(150%);
}

/* --- HISTORY SLIDER (JUDGMENT DAY) --- */
#history-slider-container {
    display: none;
    /* Hidden until Judgment Phase */
    width: 100%;
    max-width: 700px;
    background: rgba(0, 20, 0, 0.6);
    border: 1px solid var(--crt-green);
    margin-bottom: 20px;
    padding: 10px;
    flex-direction: column;
}

.history-header {
    background: var(--crt-green-dim);
    color: var(--crt-green);
    padding: 5px;
    font-size: 0.9rem;
    border-bottom: 1px dashed var(--crt-green);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.history-slide {
    display: none;
    /* Hidden by default */
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    animation: fadeIn 0.3s ease;
}

.history-slide.active {
    display: flex;
}

.slide-question {
    font-size: 1.1rem;
    color: var(--electric-blue);
    margin-bottom: 10px;
    border-left: 3px solid var(--electric-blue);
    padding-left: 10px;
}

.slide-answers {
    max-height: 150px;
    overflow-y: auto;
    font-size: 0.9rem;
    border-top: 1px solid #333;
    padding-top: 5px;
}

.slide-answer-row {
    padding: 4px 0;
    border-bottom: 1px solid #222;
}

.slider-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    border-top: 1px dashed #333;
    padding-top: 10px;
}

.slider-btn {
    background: black;
    color: var(--crt-green);
    border: 1px solid var(--crt-green);
    cursor: pointer;
    font-family: 'Share Tech Mono', monospace;
    padding: 5px 15px;
}

.slider-btn:hover {
    background: var(--crt-green);
    color: black;
}

.slider-btn:disabled {
    border-color: #444;
    color: #444;
    cursor: not-allowed;
    background: black;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

#setting-timeout-behavior {
    width: auto;
}

#role-tutorial-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 4500;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.role-tutorial-content {
    max-width: 960px;
    max-height: 90vh;
    overflow-y: auto;
    background: radial-gradient(circle at top, #111 0, #050505 60%);
    border: 1px solid var(--electric-blue);
    box-shadow: 0 0 40px rgba(0, 240, 255, 0.3);
    position: relative;
}

.role-tutorial-tabs {
    display: flex;
    gap: 8px;
    margin: 16px 0 10px;
    flex-wrap: wrap;
}

.rt-tab {
    flex: 1 1 0;
    background: transparent;
    border: 1px solid #333;
    padding: 6px 10px;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.8rem;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.rt-tab:hover {
    border-color: var(--electric-blue);
    transform: translateY(-1px);
}

.rt-tab-active {
    border-color: var(--electric-blue);
    background: rgba(0, 240, 255, 0.06);
}

.rt-tab-sub {
    color: #777;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
}

.role-tutorial-body {
    margin-top: 6px;
}

.rt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.rt-card {
    border: 1px solid #333;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.7);
    font-size: 0.85rem;
}

.rt-card h4 {
    margin: 0 0 6px;
    color: var(--electric-blue);
    font-size: 0.9rem;
}

.rt-card ul {
    margin: 0;
    padding-left: 16px;
    color: #ccc;
}

.rt-tip {
    margin-top: 14px;
    font-size: 0.85rem;
    padding: 8px 10px;
    border-left: 3px solid var(--electric-blue);
    background: rgba(0, 240, 255, 0.05);
    color: #ddd;
}
