/* ============================================================================
   WOPR - Hidden BBS Archive Terminal Overlay
   ============================================================================ */

/* --- Dissolve effect on page --- */
.wopr-dissolving > *:not(.wopr-overlay):not(.wopr-dissolve-canvas) {
    animation: woprGlitch 0.6s ease-in forwards;
}

.wopr-dissolve-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99998;
    pointer-events: none;
}

@keyframes woprGlitch {
    0%   { filter: none; transform: none; opacity: 1; }
    20%  { filter: hue-rotate(90deg) saturate(3); transform: skewX(-2deg); }
    40%  { filter: hue-rotate(-60deg) brightness(2); transform: skewX(3deg) translateX(-5px); }
    60%  { filter: hue-rotate(180deg) contrast(3); transform: skewX(-1deg) translateY(3px); opacity: 0.6; }
    80%  { filter: brightness(5) blur(2px); transform: scale(0.98); opacity: 0.3; }
    100% { filter: brightness(0); transform: scale(0.95); opacity: 0; }
}

/* --- Fullscreen overlay --- */
.wopr-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    background: #000;
    opacity: 0;
    transition: opacity 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wopr-overlay.wopr-visible {
    opacity: 1;
}

.wopr-overlay.wopr-fadeout {
    opacity: 0;
    transition: opacity 1.5s ease;
}

/* --- CRT screen container --- */
.wopr-screen {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* CRT curvature */
    border-radius: 12px;
}

/* --- Scanline overlay --- */
.wopr-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(0, 255, 136, 0.015) 2px,
        rgba(0, 255, 136, 0.015) 4px
    );
}

.wopr-scanlines::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 60%,
        rgba(0, 0, 0, 0.4) 100%
    );
}

/* --- Terminal --- */
.wopr-terminal {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    padding: 55px 50px 40px;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    scrollbar-width: none;
}

.wopr-terminal::-webkit-scrollbar {
    display: none;
}

/* --- Lines --- */
.wopr-line {
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #33ff88;
    white-space: pre-wrap;
    word-break: break-word;
    text-shadow: 0 0 8px rgba(51, 255, 136, 0.4);
    min-height: 1.6em;
}

/* --- Cursor --- */
.wopr-cursor {
    animation: woprBlink 0.7s step-end infinite;
    color: #33ff88;
    text-shadow: 0 0 10px rgba(51, 255, 136, 0.6);
}

@keyframes woprBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Colored line variants --- */
.wopr-header {
    color: #00ccff;
    text-shadow: 0 0 10px rgba(0, 204, 255, 0.5);
    font-weight: bold;
}

.wopr-section {
    color: #ffaa00;
    text-shadow: 0 0 8px rgba(255, 170, 0, 0.4);
}

.wopr-user {
    color: #00ffcc;
    text-shadow: 0 0 8px rgba(0, 255, 204, 0.5);
    font-weight: bold;
}

.wopr-dim {
    color: #669988;
    text-shadow: none;
}

.wopr-highlight {
    color: #ffffff;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.3), 0 0 4px rgba(51, 255, 136, 0.5);
}

.wopr-success {
    color: #00ff66;
    text-shadow: 0 0 12px rgba(0, 255, 102, 0.5);
    font-weight: bold;
}

.wopr-warn {
    color: #ffaa00;
    text-shadow: 0 0 8px rgba(255, 170, 0, 0.4);
}

.wopr-alert {
    color: #ff4444;
    text-shadow: 0 0 12px rgba(255, 68, 68, 0.5);
    font-weight: bold;
}

.wopr-final {
    color: #ffffff;
    font-size: 16px;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.4), 0 0 30px rgba(51, 255, 136, 0.3);
}

/* --- Login input --- */
.wopr-input-line {
    display: flex;
    align-items: center;
}

.wopr-input {
    background: transparent;
    border: none;
    outline: none;
    color: #33ff88;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    text-shadow: 0 0 8px rgba(51, 255, 136, 0.4);
    caret-color: #33ff88;
    width: 300px;
    padding: 0;
    margin: 0;
}

.wopr-input-hidden {
    position: absolute;
    left: -9999px;
    opacity: 0;
    width: 1px;
}

.wopr-input-stars {
    color: #33ff88;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    text-shadow: 0 0 8px rgba(51, 255, 136, 0.4);
    letter-spacing: 2px;
}

.wopr-input:disabled + .wopr-input-stars,
.wopr-input-hidden:disabled ~ .wopr-input-stars {
    opacity: 0.5;
}

/* --- Page header with year --- */
.wopr-page-header {
    text-align: center;
    margin-bottom: 1.5em;
    padding-bottom: 1em;
    border-bottom: 1px solid rgba(51, 255, 136, 0.15);
}

.wopr-year {
    display: block;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 48px;
    font-weight: bold;
    color: #33ff88;
    text-shadow: 0 0 20px rgba(51, 255, 136, 0.5), 0 0 40px rgba(51, 255, 136, 0.2);
    letter-spacing: 12px;
    line-height: 1.2;
}

.wopr-location {
    display: block;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    color: #669988;
    letter-spacing: 2px;
    margin-top: 6px;
}

@media (max-width: 768px) {
    .wopr-year {
        font-size: 32px;
        letter-spacing: 8px;
    }
    .wopr-location {
        font-size: 9px;
    }
}

/* --- Space prompt (inverse text) --- */
.wopr-space-prompt {
    margin-top: 1.5em;
    text-align: center;
    animation: woprBlink 1s step-end infinite;
}

.wopr-inverse {
    background: #33ff88;
    color: #000;
    padding: 2px 8px;
    font-weight: bold;
    text-shadow: none;
    letter-spacing: 1px;
    cursor: pointer;
}

/* --- Menu button (top-left) --- */
.wopr-menu-btn {
    position: fixed;
    top: 15px;
    left: 20px;
    z-index: 5;
    color: #446655;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    padding: 5px 12px;
    border: 1px solid #335544;
    border-radius: 3px;
    user-select: none;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.wopr-menu-btn:hover {
    color: #33ff88;
    border-color: #33ff88;
    background: rgba(51, 255, 136, 0.08);
}

/* --- Forward button (top-right, next to close) --- */
.wopr-forward-btn {
    position: fixed;
    top: 15px;
    right: 62px;
    z-index: 5;
    color: #446655;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    padding: 4px 10px;
    border: 1px solid #335544;
    border-radius: 3px;
    user-select: none;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.wopr-forward-btn:hover {
    color: #33ff88;
    border-color: #33ff88;
    background: rgba(51, 255, 136, 0.08);
}

/* --- Close button --- */
.wopr-close {
    position: fixed;
    top: 15px;
    right: 20px;
    z-index: 5;
    color: #446655;
    font-size: 28px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
    user-select: none;
}

.wopr-close:hover {
    color: #33ff88;
    background: rgba(51, 255, 136, 0.1);
}

/* --- Game menu panel (overlay) --- */
.wopr-menu-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.94);
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wopr-menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 20px;
}

.wopr-menu-header-block {
    text-align: center;
    margin-bottom: 1.5em;
}

.wopr-menu-header-block pre {
    margin: 0;
}

.wopr-menu-buttons-block {
    display: inline-block;
    text-align: left;
}

.wopr-menu-saves {
    margin: 0 0 1em;
}

.wopr-menu-actions.wopr-action-bar {
    flex-direction: column;
    align-items: flex-start;
    margin-top: 0;
    gap: 8px;
}

.wopr-menu-actions .wopr-action,
.wopr-menu-actions .wopr-lang-select {
    border: 2px solid #1a6b3a;
}

.wopr-menu-actions .wopr-action[data-act="continue"] {
    background: #1a8a44;
    color: #fff;
}

.wopr-menu-actions .wopr-action[data-act="continue"]:hover {
    background: #22aa55;
}

.wopr-menu-actions .wopr-action[data-act="exit"] {
    background: #cc3333;
    color: #fff;
    border-color: #881a1a;
}

.wopr-menu-actions .wopr-action[data-act="exit"]:hover {
    background: #ee4444;
    box-shadow: 0 0 14px rgba(255, 68, 68, 0.6);
}

.wopr-menu-bottom-row {
    display: flex;
    gap: 80px;
    margin-top: 24px;
}

/* --- Confirm popup overlay --- */
.wopr-confirm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wopr-confirm-box {
    border: 2px solid #33ff88;
    background: rgba(0, 8, 4, 0.95);
    padding: 2em 3em;
    text-align: center;
    box-shadow: 0 0 30px rgba(51, 255, 136, 0.15), inset 0 0 60px rgba(0, 0, 0, 0.5);
}


/* --- Mobile adjustments --- */
@media (max-width: 768px) {
    .wopr-terminal {
        padding: 45px 15px 20px;
    }

    .wopr-line {
        font-size: 11px;
        line-height: 1.5;
    }

    .wopr-final {
        font-size: 13px;
    }

    .wopr-input {
        font-size: 11px;
        width: 200px;
    }
}

/* --- Choice options (legacy) --- */
.wopr-choice {
    color: #00ccff;
    text-shadow: 0 0 8px rgba(0, 204, 255, 0.4);
    cursor: pointer;
    transition: color 0.15s, text-shadow 0.15s;
}

.wopr-choice:hover {
    color: #66ddff;
    text-shadow: 0 0 12px rgba(102, 221, 255, 0.6);
}

/* --- Character name in selection list --- */
.wopr-char-name {
    color: #33ff88;
    text-shadow: 0 0 8px rgba(51, 255, 136, 0.4);
}

/* --- CES event styling --- */
.wopr-ces-title {
    color: #ffcc00;
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

.wopr-ces-headline {
    color: #ffcc00;
    text-shadow: 0 0 8px rgba(255, 204, 0, 0.3);
    font-weight: bold;
}

.wopr-disclaimer {
    color: #556655;
    font-size: 0.8em;
    font-style: italic;
}

/* --- Action buttons (inverse text, clickable) --- */
.wopr-action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 1em;
    padding: 4px 0;
}

.wopr-action-bar.wopr-char-select {
    max-width: 880px;
}

.wopr-action {
    background: #33ff88;
    color: #000;
    padding: 3px 10px;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    text-shadow: none;
    letter-spacing: 1px;
    user-select: none;
    transition: background 0.12s, box-shadow 0.12s;
}

.wopr-action:hover {
    background: #88ffbb;
    box-shadow: 0 0 14px rgba(51, 255, 136, 0.6);
}

.wopr-action-picked,
.wopr-action-picked:hover {
    background: #ff4444;
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.5);
    text-shadow: none;
    cursor: default;
}

.wopr-action-done,
.wopr-action-done:hover {
    background: #1a2a1a;
    color: #334433;
    cursor: default;
    pointer-events: none;
}

/* --- Language dropdown in menu --- */
.wopr-lang-select {
    background: #33ff88 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23000'/%3E%3C/svg%3E") no-repeat right 8px center;
    color: #000;
    padding: 3px 24px 3px 10px;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    font-weight: bold;
    border: none;
    outline: none;
    cursor: pointer;
    letter-spacing: 1px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border-radius: 0;
}

.wopr-lang-select:hover {
    background: #88ffbb;
    box-shadow: 0 0 14px rgba(51, 255, 136, 0.6);
}

.wopr-lang-select option {
    background: #111;
    color: #33ff88;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-weight: bold;
}

/* --- Scene layout --- */
.wopr-scene-location {
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    color: #ffffff;
    font-weight: bold;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 8px 0 6px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.wopr-scene-separator {
    border-bottom: 1px solid rgba(51, 255, 136, 0.12);
    margin: 6px 0 10px;
}

/* --- ASCII art block (instant display) --- */
.wopr-ascii-block {
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.25;
    color: #33ff88;
    text-shadow: 0 0 6px rgba(51, 255, 136, 0.3);
    white-space: pre;
    margin: 0.8em 0;
    padding: 0;
    overflow-x: auto;
    min-height: auto;
}

@media (max-width: 768px) {
    .wopr-action {
        font-size: 11px;
        padding: 2px 6px;
    }
    .wopr-ascii-block {
        font-size: 8px;
        line-height: 1.15;
    }
}

/* --- CRT flicker on boot --- */
.wopr-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
    animation: woprFlicker 0.15s ease-in 1;
    background: rgba(51, 255, 136, 0.03);
}

@keyframes woprFlicker {
    0%   { opacity: 0; }
    10%  { opacity: 1; }
    20%  { opacity: 0; }
    40%  { opacity: 0.8; }
    50%  { opacity: 0; }
    70%  { opacity: 0.6; }
    100% { opacity: 0; }
}
