/* =============================================
   INFINITE LOOP ADVENTURE - RETRO CRT TERMINAL
   ============================================= */

/* --- CSS Variables --- */
:root {
    --bg-primary: #0a0e14;
    --bg-secondary: #0d1117;
    --bg-terminal: #0c1018;
    --bg-input: #111820;

    --green-bright: #00ff41;
    --green-mid: #00cc33;
    --green-dim: #00aa28;
    --green-dark: #004d15;
    --green-glow: rgba(0, 255, 65, 0.15);
    --green-glow-strong: rgba(0, 255, 65, 0.4);

    --amber: #ffb000;
    --amber-dim: #cc8800;
    --amber-glow: rgba(255, 176, 0, 0.2);

    --cyan: #00e5ff;
    --cyan-dim: #00b8cc;
    --cyan-glow: rgba(0, 229, 255, 0.2);

    --red: #ff3e3e;
    --red-dim: #cc3232;
    --red-glow: rgba(255, 62, 62, 0.2);

    --magenta: #ff6ac1;
    --magenta-glow: rgba(255, 106, 193, 0.2);

    --text-primary: #c5d0dc;
    --text-dim: #6b7d8e;
    --text-bright: #e8edf3;

    --border-color: #1e2d3d;
    --border-glow: rgba(0, 255, 65, 0.1);

    --font-mono: 'VT323', 'Courier New', monospace;
    --font-pixel: 'Press Start 2P', monospace;
    --font-cn: 'Noto Sans SC', sans-serif;

    --header-height: 42px;
    --footer-height: 36px;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* --- CRT Overlay Effects --- */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: radial-gradient(
        ellipse at center,
        transparent 60%,
        rgba(0, 0, 0, 0.4) 100%
    );
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 3px
    );
    animation: scanline-move 8s linear infinite;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 998;
    box-shadow: inset 0 0 150px rgba(0, 0, 0, 0.7);
}

.screen-flicker {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 997;
    animation: flicker 0.15s infinite;
    opacity: 0;
}

/* --- Terminal Container --- */
.terminal-container {
    width: 95vw;
    max-width: 1100px;
    height: 92vh;
    max-height: 850px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 0 30px rgba(0, 255, 65, 0.05),
        0 0 60px rgba(0, 0, 0, 0.5),
        0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

/* --- Terminal Header --- */
.terminal-header {
    height: var(--header-height);
    background: linear-gradient(180deg, #1a2332 0%, #151e2b 100%);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
    user-select: none;
}

.header-dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.2s;
}

.dot-red {
    background: #ff5f57;
    box-shadow: 0 0 6px rgba(255, 95, 87, 0.4);
}

.dot-yellow {
    background: #febc2e;
    box-shadow: 0 0 6px rgba(254, 188, 46, 0.4);
}

.dot-green {
    background: #28c840;
    box-shadow: 0 0 6px rgba(40, 200, 64, 0.4);
}

.dot:hover {
    transform: scale(1.2);
}

.header-title {
    flex: 1;
    text-align: center;
    font-family: var(--font-pixel);
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 2px;
}

.header-status {
    font-size: 14px;
}

.status-online {
    color: var(--green-bright);
    text-shadow: 0 0 8px var(--green-glow-strong);
    animation: pulse-glow 2s ease-in-out infinite;
}

/* --- Main Screen --- */
.terminal-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-terminal);
    position: relative;
}

/* --- Info Bar --- */
.info-bar {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    background: linear-gradient(180deg, #0e151d 0%, #0c1219 100%);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
    transition: all 0.3s ease;
}

.info-bar.hidden {
    display: none;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: rgba(0, 255, 65, 0.03);
    border: 1px solid rgba(0, 255, 65, 0.08);
    border-radius: 4px;
    flex: 1;
    min-width: 120px;
}

.info-label {
    font-size: 13px;
    color: var(--text-dim);
    font-family: var(--font-cn);
    white-space: nowrap;
}

.info-value {
    font-size: 16px;
    color: var(--green-bright);
    text-shadow: 0 0 4px var(--green-glow);
    font-family: var(--font-cn);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hp-bar {
    display: inline-block;
    width: 60px;
    height: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--green-dark);
    border-radius: 2px;
    overflow: hidden;
    vertical-align: middle;
    margin-right: 4px;
}

.hp-fill {
    display: block;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--green-dim), var(--green-bright));
    box-shadow: 0 0 6px var(--green-glow-strong);
    transition: width 0.5s ease;
}

/* --- Game Output --- */
.game-output {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    scroll-behavior: smooth;
    font-size: 18px;
    line-height: 1.6;
}

.game-output::-webkit-scrollbar {
    width: 6px;
}

.game-output::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.game-output::-webkit-scrollbar-thumb {
    background: var(--green-dark);
    border-radius: 3px;
}

.game-output::-webkit-scrollbar-thumb:hover {
    background: var(--green-dim);
}

/* --- Welcome Screen --- */
.welcome-screen {
    animation: fadeInUp 0.8s ease-out;
}

.ascii-title {
    color: var(--green-bright);
    text-shadow: 0 0 10px var(--green-glow-strong);
    font-size: 9px;
    line-height: 1.1;
    margin-bottom: 24px;
    overflow-x: auto;
    white-space: pre;
    font-family: var(--font-mono);
    animation: title-glow 3s ease-in-out infinite;
}

.welcome-text {
    font-family: var(--font-cn);
}

.glow-text {
    color: var(--green-bright);
    font-size: 22px;
    font-weight: 700;
    text-shadow: 0 0 15px var(--green-glow-strong);
    margin-bottom: 8px;
}

.sub-text {
    color: var(--text-dim);
    font-size: 16px;
    margin-bottom: 4px;
}

.instruction-text {
    color: var(--text-primary);
    font-size: 17px;
    margin-bottom: 6px;
}

.prompt-arrow {
    color: var(--cyan);
    margin-right: 4px;
}

.highlight-cmd {
    color: var(--amber);
    text-shadow: 0 0 6px var(--amber-glow);
    font-weight: 700;
    padding: 2px 8px;
    background: rgba(255, 176, 0, 0.08);
    border-radius: 4px;
    border: 1px solid rgba(255, 176, 0, 0.15);
}

/* --- Game Message Blocks --- */
.msg-block {
    margin-bottom: 20px;
    animation: fadeInUp 0.4s ease-out;
    font-family: var(--font-cn);
}

.msg-block.user-input-echo {
    padding: 6px 0;
    opacity: 0.6;
    font-size: 15px;
}

.msg-block.user-input-echo .msg-prefix {
    color: var(--cyan);
}

.msg-block .msg-prefix {
    color: var(--green-dim);
    font-size: 14px;
    margin-bottom: 2px;
    font-family: var(--font-mono);
}

.msg-separator {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
    opacity: 0.5;
}

/* --- ASCII Art Container --- */
.ascii-art-box {
    background: rgba(0, 255, 65, 0.02);
    border: 1px solid rgba(0, 255, 65, 0.1);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
    overflow-x: auto;
    position: relative;
}

.ascii-art-box::before {
    content: '🎨 SCENE';
    position: absolute;
    top: -10px;
    left: 12px;
    background: var(--bg-terminal);
    padding: 0 8px;
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 2px;
    font-family: var(--font-pixel);
}

.ascii-art-box pre {
    color: var(--green-bright);
    text-shadow: 0 0 3px var(--green-glow);
    font-size: 12px;
    line-height: 1.2;
    font-family: var(--font-mono);
    white-space: pre;
    margin: 0;
}

/* --- Narrative Text --- */
.narrative-text {
    color: var(--text-primary);
    font-size: 17px;
    line-height: 1.8;
    margin: 10px 0;
    font-family: var(--font-cn);
}

.narrative-text .highlight {
    color: var(--amber);
    text-shadow: 0 0 4px var(--amber-glow);
}

.narrative-text .danger {
    color: var(--red);
    text-shadow: 0 0 4px var(--red-glow);
}

.narrative-text .magic {
    color: var(--magenta);
    text-shadow: 0 0 4px var(--magenta-glow);
}

.narrative-text .info {
    color: var(--cyan);
    text-shadow: 0 0 4px var(--cyan-glow);
}

/* --- Choices --- */
.choices-container {
    margin: 16px 0;
    padding: 12px 0;
}

.choices-title {
    color: var(--amber);
    font-size: 15px;
    margin-bottom: 10px;
    font-family: var(--font-cn);
    text-shadow: 0 0 6px var(--amber-glow);
}

.choice-item {
    display: flex;
    align-items: flex-start;
    padding: 10px 16px;
    margin: 6px 0;
    background: rgba(0, 255, 65, 0.03);
    border: 1px solid rgba(0, 255, 65, 0.08);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-cn);
}

.choice-item:hover {
    background: rgba(0, 255, 65, 0.08);
    border-color: var(--green-mid);
    transform: translateX(4px);
    box-shadow: 0 0 12px var(--green-glow);
}

.choice-item:active {
    transform: translateX(2px);
}

.choice-key {
    color: var(--cyan);
    font-weight: 700;
    margin-right: 12px;
    font-size: 18px;
    min-width: 28px;
    text-shadow: 0 0 6px var(--cyan-glow);
    font-family: var(--font-mono);
}

.choice-text {
    color: var(--text-primary);
    font-size: 16px;
}

/* --- Butterfly Effect Notification --- */
.butterfly-notification {
    background: linear-gradient(135deg, rgba(255, 106, 193, 0.08), rgba(0, 229, 255, 0.08));
    border: 1px solid rgba(255, 106, 193, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: butterfly-flash 0.6s ease-out;
    font-family: var(--font-cn);
}

.butterfly-notification .butterfly-icon {
    font-size: 22px;
    animation: butterfly-fly 2s ease-in-out infinite;
}

.butterfly-notification .butterfly-text {
    color: var(--magenta);
    font-size: 14px;
    text-shadow: 0 0 4px var(--magenta-glow);
}

/* --- Humor Response --- */
.humor-response {
    background: rgba(255, 176, 0, 0.05);
    border-left: 3px solid var(--amber);
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: 0 8px 8px 0;
    font-family: var(--font-cn);
}

.humor-response .humor-header {
    color: var(--amber);
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
}

.humor-response .humor-text {
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.6;
}

/* --- Help Box --- */
.help-box {
    background: rgba(0, 229, 255, 0.03);
    border: 1px solid rgba(0, 229, 255, 0.15);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 12px 0;
    font-family: var(--font-cn);
}

.help-box h3 {
    color: var(--cyan);
    font-size: 18px;
    margin-bottom: 12px;
    text-shadow: 0 0 6px var(--cyan-glow);
}

.help-box p {
    color: var(--text-primary);
    font-size: 15px;
    margin-bottom: 6px;
    line-height: 1.6;
}

.help-box .help-cmd {
    color: var(--amber);
    font-weight: 700;
}

/* --- Game Over --- */
.game-over-box {
    text-align: center;
    padding: 30px 20px;
    animation: fadeInUp 0.6s ease-out;
}

.game-over-box .game-over-title {
    font-family: var(--font-pixel);
    font-size: 20px;
    color: var(--red);
    text-shadow: 0 0 20px var(--red-glow);
    margin-bottom: 16px;
    animation: pulse-glow-red 1.5s ease-in-out infinite;
}

.game-over-box .game-over-text {
    color: var(--text-primary);
    font-size: 17px;
    margin-bottom: 8px;
    font-family: var(--font-cn);
}

.game-over-box.victory .game-over-title {
    color: var(--amber);
    text-shadow: 0 0 20px var(--amber-glow);
}

/* --- Input Area --- */
.input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: linear-gradient(180deg, #0e151d 0%, #0c1219 100%);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 14px;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--green-mid);
    box-shadow: 0 0 12px var(--green-glow);
}

.input-prompt {
    font-size: 15px;
    margin-right: 8px;
    white-space: nowrap;
    user-select: none;
}

.prompt-user { color: var(--green-bright); }
.prompt-at { color: var(--text-dim); }
.prompt-machine { color: var(--cyan); }
.prompt-colon { color: var(--text-dim); }
.prompt-path { color: var(--amber); }
.prompt-dollar { color: var(--text-dim); margin-left: 2px; }

.game-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 18px;
    caret-color: var(--green-bright);
}

.game-input::placeholder {
    color: var(--text-dim);
    opacity: 0.5;
}

.input-hint {
    text-align: center;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-dim);
    opacity: 0.5;
    font-family: var(--font-cn);
}

.input-hint kbd {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: var(--font-mono);
    font-size: 11px;
}

/* --- Footer --- */
.terminal-footer {
    height: var(--footer-height);
    background: linear-gradient(180deg, #151e2b 0%, #1a2332 100%);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
    font-size: 13px;
}

.footer-text {
    color: var(--text-dim);
    font-family: var(--font-cn);
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--amber);
    font-family: var(--font-cn);
    font-size: 13px;
}

.typing-indicator.hidden {
    display: none;
}

.typing-dot {
    width: 5px;
    height: 5px;
    background: var(--amber);
    border-radius: 50%;
    animation: typing-bounce 1s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

/* --- Blink cursor --- */
.blink-cursor {
    animation: blink 1s step-end infinite;
    color: var(--green-bright);
}

/* --- Utility --- */
.hidden {
    display: none !important;
}

/* =============================================
   ANIMATIONS
   ============================================= */

@keyframes scanline-move {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

@keyframes flicker {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.02; }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes pulse-glow-red {
    0%, 100% { text-shadow: 0 0 20px var(--red-glow); }
    50% { text-shadow: 0 0 40px rgba(255, 62, 62, 0.6); }
}

@keyframes title-glow {
    0%, 100% { text-shadow: 0 0 10px var(--green-glow-strong); }
    50% { text-shadow: 0 0 20px var(--green-glow-strong), 0 0 40px var(--green-glow); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes butterfly-flash {
    0% { opacity: 0; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes butterfly-fly {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-3px) rotate(-5deg); }
    75% { transform: translateY(2px) rotate(5deg); }
}

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

@keyframes typewriter {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media (max-width: 768px) {
    .terminal-container {
        width: 100vw;
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }

    .ascii-title {
        font-size: 6px;
    }

    .info-bar {
        gap: 2px;
        padding: 6px 10px;
    }

    .info-item {
        min-width: 80px;
        padding: 3px 8px;
    }

    .game-output {
        padding: 12px 14px;
    }

    .input-prompt {
        font-size: 12px;
    }

    .ascii-art-box pre {
        font-size: 10px;
    }

    .header-title {
        font-size: 8px;
    }
}

@media (max-width: 480px) {
    .ascii-title {
        font-size: 5px;
    }

    .input-prompt {
        display: none;
    }

    .info-item {
        min-width: 60px;
    }
}
