/* Backrooms - Modern Flat Black & White Style */

#backrooms-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(11,17,20,0.88);
    z-index: 9999;
    display: none;
    overflow: hidden;
    font-family: inherit;
    color: #fff;
    padding: 0;
    box-sizing: border-box;
}

#backrooms-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.crt-screen {
    width: min(1100px, 96%);
    height: min(820px, 92%);
    background: linear-gradient(180deg, rgba(11,14,17,0.98), rgba(7,10,12,0.95));
    display: flex;
    flex-direction: column;
    padding: 28px;
    box-sizing: border-box;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

/* Minimal vignette for depth */
.crt-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    box-shadow: inset 0 0 80px rgba(0,0,0,0.6);
    pointer-events: none;
}

/* Hide decorative scanline for flat design */
.crt-scanline { display: none; }

/* CRT visual effects: scanlines + subtle jitter/warp */
.crt-scanline {
    position: absolute;
    inset: 0;
    pointer-events: none;
    mix-blend-mode: overlay;
    background-image: repeating-linear-gradient(
        to bottom,
        rgba(255,255,255,0.02) 0px,
        rgba(255,255,255,0.02) 1px,
        transparent 1px,
        transparent 4px
    );
    opacity: 0.08;
    z-index: 4;
    animation: crt-scan 6s linear infinite;
}

@keyframes crt-scan {
    from { background-position: 0 0; }
    to { background-position: 0 1200px; }
}

/* Slight periodic jitter to emulate tube instability */
@keyframes crt-jitter {
    0% { transform: translate3d(0,0,0) rotateZ(0deg) skewX(0deg); }
    10% { transform: translate3d(-0.6px,0.4px,0) rotateZ(-0.05deg) skewX(-0.08deg); }
    30% { transform: translate3d(0.4px,-0.6px,0) rotateZ(0.04deg) skewX(0.06deg); }
    50% { transform: translate3d(-0.3px,0.3px,0) rotateZ(-0.03deg) skewX(-0.04deg); }
    70% { transform: translate3d(0.5px,-0.2px,0) rotateZ(0.02deg) skewX(0.03deg); }
    100% { transform: translate3d(0,0,0) rotateZ(0deg) skewX(0deg); }
}

/* Apply subtle warp/distortion using the SVG filter we added in the document */
#backrooms-game {
    position: relative;
    z-index: 5;
    filter: url(#crt-wobble);
    will-change: filter, transform;
    animation: crt-jitter 3.6s ease-in-out infinite;
}

/* Reduce intensity on small screens to keep performance sane */
@media (max-width: 480px) {
    .crt-scanline { opacity: 0.04; }
    #backrooms-game { filter: none; animation: none; }
}

#backrooms-game {
    max-width: 1000px;
    width: 100%;
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

#game-header {
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding-bottom: 10px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    color: rgba(255,255,255,0.92);
}

/* SANITY indicator uses CSS variables updated from JS for smooth transitions */
#status-sanity {
    transition: color 320ms ease, text-shadow 320ms ease;
    color: var(--sanity-color, #0f0);
    text-shadow: 0 0 8px var(--sanity-glow, rgba(0,255,0,0.6));
    font-weight: 700;
}

#game-output {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 18px;
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 1.05rem;
    padding-right: 8px;
    color: #eaeff2;
}

#game-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 8px;
}

.choice-btn {
    background: rgba(255,255,255,0.03);
    color: #e6eff2;
    border: 1px solid rgba(255,255,255,0.06);
    padding: 12px 14px;
    border-radius: 10px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease, color 0.12s ease;
    font-size: 1rem;
    position: relative;
}

.choice-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(2,6,8,0.45); background-color: rgba(255,255,255,0.06); color: #ffffff; }
.choice-btn:active { transform: translateY(0); }

.choice-btn::before { content: ''; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 6px; height: 6px; border-radius: 2px; background: rgba(255,255,255,0.12); }
.choice-btn { padding-left: 28px; }

.keypad-btn, .symbol-btn, .switch-btn {
    background: rgba(255,255,255,0.02);
    color: #e6eff2;
    border: 1px solid rgba(255,255,255,0.04);
    padding: 10px 12px;
    margin: 4px;
    min-width: 56px;
    min-height: 44px;
    border-radius: 8px;
    font-size: 0.98rem;
}

.keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; justify-items: center; }
.symbol-grid { display:flex; gap:8px; flex-wrap:wrap; }
.switch-panel { display:flex; gap:8px; align-items:center; }

.pressed { transform: translateY(1px) scale(0.995); box-shadow: none; }

/* Inventory Display */
#inventory-display { margin-top: 12px; border-top: 1px solid rgba(255,255,255,0.04); padding-top: 8px; font-size: 0.9rem; color: rgba(255,255,255,0.8); }

/* Scrollbar */
#game-output::-webkit-scrollbar { width: 8px; }
#game-output::-webkit-scrollbar-track { background: transparent; }
#game-output::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 6px; }

@media (max-width: 768px) {
    .crt-screen { padding: 16px; }
    #game-output { font-size: 0.98rem; }
    .choice-btn { font-size: 0.98rem; }
    .keypad-btn, .symbol-btn, .switch-btn { min-width: 52px; min-height: 44px; }
}

/* Low sanity effect: subtle red tint */
.low-sanity { box-shadow: 0 0 30px rgba(255, 42, 42, 0.08) inset; }
.low-sanity #game-output, .low-sanity .choice-btn { color: #ffd6d6; }