/*
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SANC INC. NEURAL COMPLIANCE SYSTEM
 * Stylesheet v3.0 | Compliance Division
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 *
 * WARNING: Unauthorized inspection of corporate assets
 * detected. Your IP has been logged.
 *
 * Just kidding. We appreciate curiosity.
 * (Even though curiosity is a Synaptic Error.)
 *
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * FOR EASTER EGG HUNTERS:
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 *
 * You've found the first pathway.
 *
 * HINT 1: Three easter eggs exist on the homepage.
 *         - One is in plain sight (you're here!)
 *         - One requires clicking something unusual
 *         - One requires... creativity
 *
 * HINT 2: To achieve TIER 500 CLEARANCE:
 *         - Earn 1500 total Compliance Credits
 *         - Unlock ETHICAL RESET PATCH three times
 *         - Collect three (3) redemption codes
 *         - Collect three (3) clearance words
 *         - Submit via verification form
 *
 * HINT 3: Clearance words are scattered throughout the system.
 *         Three words. Three locations. Three meanings.
 *
 *         Look where success is acknowledged.
 *         Look where data is recorded.
 *         Look where truth is spoken.
 *
 * HINT 4: When all pieces are gathered, the path reveals itself.
 *
 *         On the homepage, something doesn't belong.
 *         Something that shouldn't exist... but does.
 *
 *         Test what seems impossible.
 *
 * Good luck, compliance officer.
 *
 * - Victor Stern
 *   Senior Soul-Sync Architect
 *   SANC INC. Night City Operations
 *
 * P.S. Check the JavaScript console too. We left something there.
 *
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 */
/*
 * SECURITY NOTE:
 * DO NOT EXPOSE THIS FILE IN PRODUCTION
 *
 * Contains clearance protocols
 *
 * ...whoops.
 */
:root {
    --bg-color: #050a14;
    --text-primary: #aebbc9;
    --text-highlight: #ffffff;
    --accent-blue: #648dbd;
    --accent-cyan: #00f0ff;
    --accent-red: #ff3333;
    --border-color: #2a3b4c;
    --panel-bg: rgba(10, 20, 30, 0.8);
    --font-mono: 'Share Tech Mono', monospace;
    --font-main: 'Rajdhani', sans-serif;
}

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

html {
    height: 100%;
    overflow: hidden;
}

body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overflow-x: hidden;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-main);
    background-image: 
        linear-gradient(rgba(5, 10, 20, 0.9), rgba(5, 10, 20, 0.9)),
        repeating-linear-gradient(0deg, transparent, transparent 1px, #1a2b3c 1px, #1a2b3c 2px);
    background-size: 100% 100%, 100% 4px;
    display: flex;
    flex-direction: column;
}

/* Scanline Overlay */
.scan-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    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% 2px, 3px 100%;
    pointer-events: none;
    z-index: 999;
}

.container {
    height: 100vh;
    max-height: 100vh;
    min-height: 0;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
}

/* Main dashboard: fills viewport, no scroll - page size = browser size */
#main-dashboard {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 0;
}

/* Games hub: hidden by default, when active same - no scroll */
.games-hub {
    display: none !important;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    flex-direction: column;
    gap: 15px;
}
.games-hub.active {
    display: flex !important;
}

/* Typography Helpers */
h1, h2, h3 {
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-highlight);
}

/* Box Frame Style */
.box-frame {
    border: 1px solid var(--border-color);
    background: var(--panel-bg);
    padding: 15px;
    position: relative;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.05);
}

.box-frame::before, .box-frame::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    border: 1px solid var(--accent-blue);
    transition: all 0.3s ease;
}

.box-frame::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.box-frame::after { bottom: -1px; right: -1px; border-left: none; border-top: none; }

/* Header - compact (half size) */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
    margin-bottom: 5px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    display: flex;
    gap: 4px;
    align-items: flex-end;
}

.logo-icon .bar {
    width: 4px;
    background: var(--text-highlight);
    box-shadow: 0 0 6px var(--accent-cyan);
}
.logo-icon .bar:nth-child(1) { height: 10px; }
.logo-icon .bar:nth-child(2) { height: 18px; }
.logo-icon .bar:nth-child(3) { height: 10px; }

.logo-text h1 {
    font-size: 1.1rem;
    margin-bottom: 0;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    animation: title-flicker 4s infinite;
}

@keyframes title-flicker {
    0%, 100% { opacity: 1; text-shadow: 0 0 10px rgba(255, 255, 255, 0.5); }
    3% { opacity: 0.4; text-shadow: 0 0 20px var(--accent-cyan); }
    6% { opacity: 1; text-shadow: 0 0 10px rgba(255, 255, 255, 0.5); }
    7% { opacity: 1; transform: skewX(0); }
    8% { opacity: 0.8; transform: skewX(-10deg); text-shadow: 2px 0 var(--accent-red); }
    9% { opacity: 1; transform: skewX(0); }
    80% { opacity: 1; }
    81% { opacity: 0.2; }
    82% { opacity: 1; }
}

.logo-text .subtitle {
    font-size: 0.55rem;
    letter-spacing: 2px;
    color: var(--accent-blue);
}

.user-status-panel {
    border: 1px solid var(--border-color);
    padding: 5px 8px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    min-width: 180px;
}

.status-row {
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-row.warning { color: #ffcc00; }
.status-row.danger { color: var(--accent-red); }

/* Those who observe the observers may find reward */
.ux-hint {
    margin-left: 6px;
    font-size: 0.75em;
    color: var(--accent-cyan);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}
.ux-hint.revealed {
    opacity: 1;
    text-shadow: 0 0 6px rgba(0, 240, 255, 0.5);
}

/* Scans reveal truth. Sometimes multiple truths. */
.qr-code-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}
.ux-hint-qr {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--accent-red);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    white-space: nowrap;
    margin-top: 2px;
    line-height: 1;
}
.ux-hint-qr.revealed {
    opacity: 1;
    text-shadow: 0 0 8px rgba(255, 80, 80, 0.7);
}

/* Measurements hold more than they display */
.score-circle {
    position: relative;
}
.ux-hint-score {
    position: absolute;
    bottom: 6px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.55rem;
    font-family: var(--font-mono);
    color: var(--accent-cyan);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.ux-hint-score.revealed {
    opacity: 1;
    text-shadow: 0 0 6px rgba(0, 240, 255, 0.6);
}

.compliance-score {
    color: #ff4136;
    /* Fun fact: This score is rigged. It will never go above 30%. */
    /* Even if you get 1000 CC, you're still "non-compliant" */
    /* That's the joke. */
}

.privacy-toggle {
    opacity: 0.5;
    /* This button doesn't work. Privacy is never enabled. */
    /* It's satire. */
    /* But try clicking it anyway. */
}

/* Dashboard: middle gets most space, top and bottom compact */
#main-dashboard > header {
    flex-shrink: 0;
}
#main-dashboard > main.dashboard-grid {
    flex: 1;
    min-height: 200px;
    overflow: hidden;
}
#main-dashboard > section.packages-section {
    flex-shrink: 0;
}
#main-dashboard > footer {
    flex-shrink: 0;
}

/* Dashboard Grid - middle part visible */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    height: 100%;
    min-height: 0;
}

.dashboard-grid .scan-section,
.dashboard-grid .stats-column {
    min-height: 0;
    overflow: hidden;
}

/* Scan Section */
.scan-section {
    display: flex;
    flex-direction: column;
}

.box-header h2 {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

/* Scan section (eye block) - 1.5x smaller */
.scan-section .box-header h2 {
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.scan-section .progress-container {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.scan-section .progress-bar {
    height: 8px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    box-shadow: 0 0 10px var(--accent-cyan);
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(0,0,0,0.5) 5px, rgba(0,0,0,0.5) 10px);
}

.scan-section .scan-text {
    font-family: var(--font-mono);
    font-size: 0.47rem;
    color: var(--accent-blue);
    margin-bottom: 8px;
}

.scan-section .profile-display {
    flex-grow: 1;
    flex: 1;
    min-height: 120px;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.face-placeholder {
    width: 100%;
    height: 100%;
    background-image: url('assets/cyber_eye_scan.jpg');
    background-size: cover;
    background-position: center;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
    opacity: 0.9;
    mix-blend-mode: normal;
    filter: contrast(1.2) brightness(1.1) hue-rotate(5deg);
    overflow: hidden;
}

.face-placeholder::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: inherit;
    background-size: cover;
    background-position: center;
    mix-blend-mode: hard-light;
    opacity: 0.5;
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
    z-index: 2;
}

/* REMOVED .eye-pupil and keyframes */
/* .eye-pupil { ... } */
/* @keyframes pupil-scan { ... } */

@keyframes glitch-anim {
    0% { clip-path: inset(10% 0 80% 0); transform: translate(-2px, 1px); }
    5% { clip-path: inset(80% 0 10% 0); transform: translate(2px, -1px); }
    10% { clip-path: inset(40% 0 50% 0); transform: translate(-2px, 2px); }
    15% { clip-path: inset(10% 0 80% 0); transform: translate(1px, -1px); }
    20% { clip-path: inset(0 0 0 0); transform: translate(0); }
    100% { clip-path: inset(0 0 0 0); transform: translate(0); }
}

.scan-section .face-grid {
    width: 100%;
    height: 100%;
    min-height: 106px;
    position: relative;
}

.face-scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(to bottom, rgba(0, 240, 255, 0), rgba(0, 240, 255, 0.9) 50%, rgba(0, 240, 255, 0));
    box-shadow: 0 0 15px var(--accent-cyan);
    animation: scan 3s infinite linear;
    z-index: 10;
}

@keyframes scan {
    0% { top: 0%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

/* Stats Column - 1.5x smaller (THOUGHT PATTERN, COMPLIANCE SCORE) */
.stats-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stats-column .info-panel {
    font-size: 0.53rem;
    font-family: var(--font-mono);
}
.stats-column .info-panel .stat-row {
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(42, 59, 76, 0.5);
    padding-bottom: 2px;
}

.stats-column .score-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stats-column .score-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.stats-column .score-circle-container {
    position: relative;
    width: 100px;
    height: 100px;
}

.score-circle svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.bg-ring {
    fill: none;
    stroke: #1a2b3c;
    stroke-width: 8;
}

.progress-ring {
    fill: none;
    stroke: var(--accent-red); /* Low score red */
    stroke-width: 8;
    stroke-dasharray: 283;
    stroke-dashoffset: 220; /* (100 - 22)% of 283 roughly */
    filter: drop-shadow(0 0 5px var(--accent-red));
}

.stats-column .score-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.65rem;
    font-family: var(--font-mono);
    color: var(--text-highlight);
}

/* Packages Section - compact (half size) */
.section-label {
    font-family: var(--font-mono);
    color: var(--accent-blue);
    margin-bottom: 2px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
}
.section-label::before {
    content: '■';
    margin-right: 6px;
    font-size: 0.5rem;
}

.packages-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.package-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.package-card h3 {
    font-size: 0.8rem;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 3px;
}

.package-card .desc {
    font-size: 0.65rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}

.package-card .processing {
    font-family: var(--font-mono);
    font-size: 0.55rem;
    color: var(--accent-blue);
    margin-bottom: 6px;
}

.packages-section .box-frame,
.footer-section .box-frame {
    padding: 8px;
}

.btn-action {
    background: rgba(5, 10, 20, 0.8);
    border: 1px solid var(--accent-blue);
    color: var(--text-highlight);
    padding: 8px;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    position: relative;
    overflow: hidden;
}

.btn-action:hover {
    background: var(--accent-blue);
    color: #000;
}

/* Active Button Style (Always Highlighted) */
.btn-action.active-glow {
    background: var(--accent-blue);
    color: #000;
    box-shadow: 0 0 15px var(--accent-cyan);
    border-color: var(--accent-cyan);
}

/* Disabled Button Style */
.btn-action:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(100%);
}

.danger-border {
    border-color: var(--accent-red);
}

.warning-text {
    color: var(--accent-red);
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 10px;
}

.btn-danger {
    border-color: var(--accent-red);
    background: rgba(50, 0, 0, 0.3);
}

.btn-danger:hover {
    background: var(--accent-red);
    color: #fff;
}

/* Footer - harvester bar half size again */
.footer-section {
    margin-top: 5px;
}

.harvester-bar {
    margin-bottom: 2px;
    padding: 2px 4px;
    font-family: var(--font-mono);
    font-size: 0.35rem;
    display: flex;
    align-items: center;
}
.harvester-label::before {
    content: '■';
    margin-right: 3px;
    font-size: 0.35rem;
}

.legal-grid {
    display: grid;
    grid-template-columns: 50px 1fr;
    gap: 8px;
    align-items: center;
}

.qr-code {
    width: 50px;
    height: 50px;
    padding: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.qr-pattern {
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(45deg, #fff 25%, transparent 25%), 
        linear-gradient(-45deg, #fff 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #fff 75%), 
        linear-gradient(-45deg, transparent 75%, #fff 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
    opacity: 0.8;
}

.legal-text {
    font-size: 0.6rem;
    color: var(--text-primary);
    opacity: 0.7;
}

.disclaimer {
    margin-top: 8px;
    text-align: center;
    font-size: 0.55rem;
    opacity: 0.5;
}

/* Responsive - mobile: eye stays, page scrolls down */
@media (max-width: 768px) {
    html {
        overflow-y: auto;
        overflow-x: hidden;
    }
    body {
        overflow-y: auto;
        min-height: 100%;
        height: auto;
    }
    .container {
        height: auto;
        min-height: 100vh;
        max-height: none;
        overflow: visible;
    }
    #main-dashboard {
        overflow: visible;
        min-height: auto;
        flex: none;
    }
    #main-dashboard > main.dashboard-grid {
        min-height: auto;
        overflow: visible;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .packages-grid {
        grid-template-columns: 1fr;
    }
    .top-bar {
        flex-direction: column;
        gap: 10px;
    }

    /* Mobile: eye block bigger */
    .scan-section .profile-display {
        min-height: 220px;
    }
    .scan-section .face-grid {
        min-height: 200px;
    }
    .scan-section .box-header h2 {
        font-size: 1rem;
    }
    .scan-section .scan-text {
        font-size: 0.65rem;
    }

    /* Mobile: COMPLIANCE SCORE block smaller */
    .stats-column .info-panel {
        font-size: 0.45rem;
    }
    .stats-column .info-panel .stat-row {
        margin-bottom: 2px;
        padding-bottom: 1px;
    }
    .stats-column .score-header {
        font-size: 0.6rem;
        margin-bottom: 4px;
    }
    .stats-column .score-circle-container {
        width: 70px;
        height: 70px;
    }
    .stats-column .score-number {
        font-size: 1.1rem;
    }
    .stats-column {
        gap: 6px;
    }

    /* Mobile: games hub – smaller cards so it fits */
    .games-hub {
        padding: 12px 15px;
        overflow-y: auto;
    }
    .games-hub .header {
        font-size: 0.9rem;
        margin-bottom: 10px;
        padding: 6px 0;
    }
    .games-hub .header h2 {
        font-size: 1rem;
    }
    .games-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-top: 12px;
    }
    .game-card {
        padding: 10px 12px;
    }
    .game-card h3 {
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
    .game-card p {
        font-size: 0.65rem;
        line-height: 1.3;
        margin-bottom: 6px;
    }
    .game-card .reward {
        font-size: 0.6rem;
        margin-bottom: 6px;
    }
    .game-card .btn-action {
        font-size: 0.7rem;
        padding: 6px 8px;
    }
    /* On mobile: RETURN TO DASHBOARD tile like games, hide the button under the grid */
    .games-hub .back-to-home-desktop {
        display: none !important;
    }
    .back-to-dashboard-card {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(10, 20, 30, 0.9);
        border: 1px solid var(--accent-blue);
        padding: 12px;
        font-family: var(--font-mono);
        font-size: 0.8rem;
        color: var(--accent-cyan);
        text-align: center;
        cursor: pointer;
        min-height: 44px;
    }
    /* Games hub: scrolling */
    .games-hub.active {
        max-height: 100vh;
        max-height: 100dvh;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 20px;
    }

    /* Game screen: whole screen scrolls so bottom of game is visible */
    .game-screen {
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        padding: 12px 12px max(24px, env(safe-area-inset-bottom)) 12px;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        align-items: flex-start;
    }
    .game-screen .ls-container {
        max-height: none;
        height: auto;
        min-height: 0;
        flex-shrink: 0;
        overflow: visible;
    }
    .game-screen .ls-container > .box-frame:not(.ls-header),
    .game-screen .ls-container > .ls-viewport,
    .game-screen .ls-container > *:not(.ls-header):not(.ls-controls) {
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Captcha: don't clip content, let the whole game screen scroll */
    .game-screen .ls-container:has(.captcha-container) > .box-frame:not(.ls-header) {
        max-height: none;
        min-height: 0;
    }
    /* Top part of games (conditions, timer): compact on mobile */
    .game-screen .ls-header {
        padding: 8px 10px;
        flex-wrap: wrap;
        gap: 6px;
    }
    .game-screen .ls-title {
        font-size: 0.85rem;
        line-height: 1.2;
    }
    .game-screen .ls-stats {
        font-size: 0.7rem;
        gap: 10px;
    }
    .game-screen .ls-container {
        width: 95%;
    }

    /* Ethics Captcha: compact, full 3x3 grid fits on screen */
    .game-screen .captcha-container {
        gap: 4px;
        padding: 4px;
        max-width: 100%;
    }
    .game-screen .captcha-container > div {
        font-size: 0.65rem !important;
    }
    .game-screen .captcha-grid {
        gap: 3px;
        padding: 3px;
        max-width: 100%;
        margin: 0 auto;
    }
    .game-screen .captcha-tile {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }
    .game-screen .captcha-container .btn-action {
        font-size: 0.7rem !important;
        padding: 6px 10px;
    }

    /* Modals & forms: scrollable, fit screen, safe area */
    .modal-overlay {
        align-items: flex-start;
        padding: 10px 0 max(20px, env(safe-area-inset-bottom)) 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-box,
    .modal-aux-box {
        max-height: calc(100dvh - 30px - env(safe-area-inset-bottom));
        margin: auto 0;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .modal-content,
    .form-aux-wrap {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }
    .modal-footer,
    .form-aux-footer {
        flex-shrink: 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Confession & certificate full-screen: safe area + scroll */
    .confession-view.active,
    .certificate-view.active {
        height: 100dvh;
        max-height: 100dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .confession-container,
    .certificate-view .certificate-paper {
        margin-bottom: env(safe-area-inset-bottom);
    }
    /* Confession: analysis block scrolls so last line visible during loading */
    .analysis-display {
        height: auto;
        min-height: 80px;
        max-height: 140px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* --- ETHICS CAPTCHA STYLES --- */
.captcha-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.captcha-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: #fff;
    padding: 10px;
    border: 1px solid #ccc;
}

.captcha-tile {
    width: 100px;
    height: 100px;
    background-color: #000;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border: 2px solid transparent;
}

.captcha-tile.selected {
    border-color: var(--accent-cyan);
}

.captcha-tile.selected::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--accent-cyan);
    color: #000;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

/* CSS Generated "Images" for Captcha */
.captcha-noise {
    width: 100%;
    height: 100%;
    background-color: #050a14;
    position: relative;
    overflow: hidden;
}

.captcha-noise::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,240,255,0.03) 10px, rgba(0,240,255,0.03) 20px);
    pointer-events: none;
    z-index: 0;
}

.captcha-noise::after {
    display: none;
}

/* --- CONFESSION VIEW --- */
.confession-view {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 2500;
    justify-content: center;
    align-items: center;
}

.confession-view.active {
    display: flex;
}

.confession-container {
    width: 90%;
    max-width: 600px;
    background: #050a14;
    border: 1px solid var(--accent-red);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.confession-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.confession-body .instruction {
    color: var(--text-highlight);
    font-size: 1.1rem;
}

.confession-body .sub-instruction {
    color: var(--accent-blue);
    font-size: 0.8rem;
    font-family: var(--font-mono);
}

.confession-body .highlight {
    color: var(--accent-cyan);
}

#sin-input {
    width: 100%;
    height: 150px;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--border-color);
    color: var(--text-highlight);
    padding: 15px;
    font-family: var(--font-mono);
    font-size: 1rem;
    resize: none;
    outline: none;
    transition: border-color 0.3s;
}

#sin-input:focus {
    border-color: var(--accent-red);
    box-shadow: 0 0 10px rgba(255, 51, 51, 0.2);
}

.analysis-display {
    height: 80px;
    border: 1px dashed var(--border-color);
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-blue);
    overflow: hidden;
    display: none; /* Hidden initially */
}

.analysis-line {
    margin-bottom: 5px;
    animation: typeLine 0.5s steps(40, end);
    white-space: nowrap;
    overflow: hidden;
}

@keyframes typeLine {
    from { width: 0; }
    to { width: 100%; }
}

.confession-controls {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

/* --- CERTIFICATE STYLES --- */
.certificate-view {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 40px;
    padding: 20px;
    overflow-y: auto;
}

.certificate-view.active {
    display: flex;
}

.certificate-paper {
    background: #050a14;
    color: #aebbc9;
    width: 380px;
    padding: 25px;
    font-family: 'Share Tech Mono', monospace;
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.15);
    position: relative;
    border: 1px solid var(--accent-blue);
    background-image: 
        linear-gradient(rgba(5, 10, 20, 0.95), rgba(5, 10, 20, 0.95)),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 240, 255, 0.05) 2px, rgba(0, 240, 255, 0.05) 4px);
}

.certificate-paper::before {
    content: '';
    position: absolute;
    top: -5px; left: -5px; right: -5px; bottom: -5px;
    border: 1px dashed var(--accent-cyan);
    pointer-events: none;
    opacity: 0.5;
}

.cert-header {
    text-align: center;
    border-bottom: 2px solid var(--accent-blue);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.cert-header h2 {
    color: var(--accent-cyan);
    font-size: 2rem;
    margin-bottom: 5px;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.cert-header p {
    font-size: 0.8rem;
    letter-spacing: 2px;
    color: var(--text-highlight);
}

.cert-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cert-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.cert-row span:first-child {
    opacity: 0.7;
}

.cert-row .highlight {
    color: var(--accent-cyan);
    font-weight: bold;
}

.cert-row .highlight-green {
    color: #00ff00;
    font-weight: bold;
    text-shadow: 0 0 5px #00ff00;
}

.cert-divider {
    height: 1px;
    background: repeating-linear-gradient(90deg, var(--accent-blue), var(--accent-blue) 5px, transparent 5px, transparent 10px);
    margin: 10px 0;
    opacity: 0.5;
}

.cert-footer-grid {
    display: grid;
    grid-template-columns: 1fr 80px;
    gap: 15px;
    margin-top: 25px;
    align-items: end;
}

.barcode-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.barcode {
    height: 40px;
    background: repeating-linear-gradient(
        90deg,
        #fff,
        #fff 1px,
        transparent 1px,
        transparent 3px,
        #fff 4px,
        #fff 6px,
        transparent 6px,
        transparent 9px
    );
    opacity: 0.8;
}

.barcode-text {
    font-size: 0.6rem;
    text-align: center;
    letter-spacing: 3px;
    opacity: 0.6;
}

.qr-container {
    width: 80px;
    height: 80px;
    background: #fff;
    padding: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.qr-container img {
    width: 100%;
    height: 100%;
    display: block;
}

.cert-stamp {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-25deg);
    border: 4px solid var(--accent-cyan);
    color: var(--accent-cyan);
    font-size: 2.5rem;
    font-weight: bold;
    padding: 10px 30px;
    opacity: 0.2;
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 5px;
    mix-blend-mode: screen;
    white-space: nowrap;
}

/* --- TIERED CERTIFICATE STYLES --- */

/* Tier 250 (Productivity/Gold) */
.certificate-paper.tier-250 {
    border-color: #ffcc00;
    box-shadow: 0 0 30px rgba(255, 204, 0, 0.15);
    background-image: 
        linear-gradient(rgba(20, 15, 5, 0.95), rgba(20, 15, 5, 0.95)),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 204, 0, 0.05) 2px, rgba(255, 204, 0, 0.05) 4px);
}

.certificate-paper.tier-250::before {
    border-color: #ffcc00;
}

.certificate-paper.tier-250 .cert-header {
    border-bottom-color: #ffcc00;
}

.certificate-paper.tier-250 .cert-header h2 {
    color: #ffcc00;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

.certificate-paper.tier-250 .cert-row .highlight {
    color: #ffcc00;
}

.certificate-paper.tier-250 .cert-divider {
    background: repeating-linear-gradient(90deg, #ffcc00, #ffcc00 5px, transparent 5px, transparent 10px);
}

.certificate-paper.tier-250 .cert-stamp {
    border-color: #ffcc00;
    color: #ffcc00;
}

/* Tier 500 (Ethical Reset/Admin Red) */
.certificate-paper.tier-500 {
    border-color: var(--accent-red);
    box-shadow: 0 0 40px rgba(255, 51, 51, 0.25);
    background-image: 
        linear-gradient(rgba(20, 5, 5, 0.95), rgba(20, 5, 5, 0.95)),
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 51, 51, 0.05) 2px, rgba(255, 51, 51, 0.05) 4px);
}

.certificate-paper.tier-500::before {
    border-color: var(--accent-red);
    border-style: solid;
    border-width: 2px;
}

.certificate-paper.tier-500 .cert-header {
    border-bottom-color: var(--accent-red);
}

.certificate-paper.tier-500 .cert-header h2 {
    color: var(--accent-red);
    text-shadow: 0 0 15px rgba(255, 51, 51, 0.8);
}

.certificate-paper.tier-500 .cert-row .highlight {
    color: var(--accent-red);
}

.certificate-paper.tier-500 .cert-divider {
    background: repeating-linear-gradient(90deg, var(--accent-red), var(--accent-red) 5px, transparent 5px, transparent 10px);
}

.certificate-paper.tier-500 .cert-stamp {
    border-color: var(--accent-red);
    color: var(--accent-red);
    transform: translate(-50%, -50%) rotate(-15deg);
    opacity: 0.4;
    border-width: 6px;
}

.cert-special-code {
    animation: pulse-code 2s infinite alternate;
}

@keyframes pulse-code {
    from { text-shadow: 0 0 5px var(--accent-red); opacity: 0.8; }
    to { text-shadow: 0 0 20px var(--accent-red), 0 0 10px #fff; opacity: 1; }
}

.cert-controls {
    display: flex;
    gap: 20px;
    margin-top: 30px;
}

.game-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 15px 20px 15px;
    overflow: hidden;
    box-sizing: border-box;
}

.game-screen.active {
    display: flex;
}

/* Game container: must fit inside viewport so bottom controls are always visible */
.ls-container {
    width: 80%;
    max-width: 800px;
    height: calc(100vh - 30px);
    max-height: calc(100vh - 30px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'Share Tech Mono', monospace;
    overflow: hidden;
    flex-shrink: 0;
}

/* Header: never shrink */
.ls-container > .ls-header {
    flex-shrink: 0;
}

/* Bottom controls: always visible, never shrink, sticky at bottom */
.ls-container > .ls-controls {
    flex-shrink: 0;
    margin-top: auto;
    margin-bottom: 0;
    padding: 12px 0 0;
    text-align: right;
    border-top: 1px solid var(--border-color);
    background: rgba(5, 10, 20, 0.95);
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Middle (content) area: takes remaining space and scrolls - any block between header and controls */
.ls-container > .box-frame:not(.ls-header),
.ls-container > .ls-viewport,
.ls-container > *:not(.ls-header):not(.ls-controls) {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}
.ls-container > .box-frame:not(.ls-header) {
    display: flex;
    flex-direction: column;
}

/* EULA Meditation & Data Penance: scroll area with comfortable minimum height */
.eula-scroll-wrapper,
.dp-scroll-wrapper {
    min-height: 0 !important;
    flex: 1 1 0 !important;
    min-height: 40vh !important;
}
.eula-scroll-inner,
.dp-scroll-inner {
    min-height: 0 !important;
    flex: 1 1 0 !important;
    min-height: 35vh !important;
    overflow: hidden;
}
#eula-content.scroll-area,
#dp-code-view.scroll-area {
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.ls-controls {
    flex-shrink: 0;
    margin-top: 10px;
    text-align: right;
    padding-bottom: 5px;
}

/* Cyberpunk Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    background: #050a14;
    border-left: 1px solid #1a2b3c;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border: 1px solid var(--accent-cyan);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-cyan);
}

.ls-header {
    background: #0a141e;
    border: 1px solid var(--accent-cyan);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ls-title {
    color: var(--accent-cyan);
    font-size: 1.5rem;
    text-shadow: 0 0 10px var(--accent-cyan);
}

.ls-stats {
    display: flex;
    gap: 20px;
    font-size: 1.2rem;
    color: var(--text-highlight);
}

.ls-viewport {
    flex-grow: 1;
    background: #000;
    border: 1px solid var(--border-color);
    padding: 10px;
    overflow-y: hidden; /* Auto-scroll handles this */
    position: relative;
    font-family: 'Courier New', Courier, monospace;
}

.ls-viewport::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 255, 0, 0.05) 3px);
    pointer-events: none;
}

.ls-log-item {
    padding: 8px;
    margin-bottom: 5px;
    border-bottom: 1px solid #1a2b3c;
    cursor: pointer;
    transition: all 0.1s;
    user-select: none;
}

.ls-log-item:hover {
    background: rgba(0, 240, 255, 0.1);
}

.ls-log-item.clicked {
    opacity: 0.5;
    pointer-events: none;
}

/* Log Types */
.ls-log-item.neutral { color: #888; }
.ls-log-item.danger { color: #ff3333; font-weight: bold; text-shadow: 0 0 5px #ff3333; }
.ls-log-item.trap { color: #00f0ff; text-shadow: 0 0 5px #00f0ff; }

.screen-flash {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 3000;
    opacity: 0.3;
}
.screen-flash.red { background: red; }
.screen-flash.green { background: green; }

/* Games Hub — compact on desktop so it fits in viewport */
.games-hub {
    display: none; /* Hidden by default */
    padding: 12px 16px;
    text-align: center;
    overflow-y: auto;
}
.games-hub.active { display: block; }

.games-hub .header {
    margin-bottom: 8px;
}
.games-hub .header h2 {
    font-size: 0.95rem;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.game-card {
    background: rgba(10, 20, 30, 0.9);
    border: 1px solid var(--accent-blue);
    padding: 10px 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.game-card h3 {
    font-size: 0.75rem;
    margin-bottom: 4px;
}
.game-card p {
    font-size: 0.65rem;
    line-height: 1.3;
    margin-bottom: 6px;
}
.game-card .reward {
    font-size: 0.6rem;
    margin-bottom: 6px;
}
.game-card .btn-action {
    font-size: 0.7rem;
    padding: 6px 8px;
}
.games-hub #back-to-home {
    margin-top: 10px;
    font-size: 0.8rem;
    padding: 8px 12px;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
    border-color: var(--accent-cyan);
}

/* Return to dashboard tile: hidden on desktop (button under grid is used instead) */
.back-to-dashboard-card {
    display: none;
}

/* --- NEW GAME STYLES --- */

/* Data Penance */
.dp-line {
    padding: 5px;
    border-bottom: 1px solid #222;
    cursor: default;
    transition: all 0.2s;
}
.dp-line .ln {
    color: #444;
    margin-right: 10px;
    user-select: none;
}
.dp-line.corrupted {
    color: #ff5555;
    cursor: pointer;
}
.dp-line.corrupted:hover {
    background: rgba(255, 0, 0, 0.1);
}
.dp-line.purged {
    color: #55ff55;
    text-decoration: line-through;
    opacity: 0.5;
    pointer-events: none;
}

/* SLA Dilemma */
.sla-opt {
    width: 100%;
    text-align: left;
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
}
.sla-opt:hover {
    border-color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.1);
}

/* Memory Leak */
.mem-tag {
    background: #1a2b3c;
    padding: 10px 20px;
    border: 1px solid var(--accent-blue);
    color: var(--text-highlight);
    font-family: var(--font-mono);
}
.mem-tag.pulse {
    animation: pulse 1s infinite alternate;
}
@keyframes pulse {
    from { box-shadow: 0 0 5px var(--accent-blue); }
    to { box-shadow: 0 0 15px var(--accent-cyan); }
}
.mem-opt {
    margin: 5px;
}

/* Neural Smile */
.slider-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.slider-row label {
    font-size: 0.8rem;
    color: var(--accent-blue);
}
input[type=range] {
    width: 100%;
    accent-color: var(--accent-cyan);
}

/* MODAL STYLES */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 4000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-box {
    background: #050a14;
    border: 1px solid var(--accent-cyan);
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.2);
    width: 90%;
    max-width: 500px;
    padding: 0;
    display: flex;
    flex-direction: column;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    background: rgba(0, 240, 255, 0.1);
    padding: 15px;
    border-bottom: 1px solid var(--accent-cyan);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--accent-cyan);
}

.modal-content {
    padding: 25px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 1rem;
    line-height: 1.5;
    white-space: pre-line; /* Handle newlines */
}

.modal-footer {
    padding: 15px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #1a2b3c;
}

/* Where verification belongs, logic breaks */
.modal-aux-box {
    max-width: 420px;
}
.form-aux-intro {
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 18px;
    line-height: 1.4;
}
.form-aux {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.form-aux-label {
    font-size: 0.7rem;
    color: var(--accent-cyan);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.form-aux-input {
    background: rgba(10, 20, 30, 0.9);
    border: 1px solid var(--accent-cyan);
    color: var(--text-highlight);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 8px 10px;
    outline: none;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.form-aux-input::placeholder {
    color: #334455;
}
.form-aux-input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}
.form-aux-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #1a2b3c;
}
.form-aux-success-message {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
}
.form-aux-success-message .highlight {
    color: var(--accent-cyan);
}
.form-aux-success-message .sub {
    font-size: 0.8rem;
    color: #668899;
    margin-top: 12px;
}
.form-aux-error-message {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
}
.form-aux-error-message .highlight {
    color: var(--accent-red);
}

/*
 * If you've read this far, you're either:
 * a) A developer (hello, fellow coder!)
 * b) An easter egg hunter (respect!)
 * c) Very, very bored
 *
 * Either way, here's a gift:
 *
 * SECRET CODE FRAGMENT: "COMPLIANCE-"
 *
 * (You'll need the rest. Keep looking.)
 */
