@import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;700&display=swap');

:root {
    --color-green: #00ff00;
    --color-amber: #ffb000;
    --color-violet: #bb88ff;
    --color-white: #ffffff;
    --bg-dark: #0a0a0a;
    --frame-color: #333;
}

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

body {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    font-family: 'Source Code Pro', monospace;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 10px;
}

.game-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.terminal-frame {
    width: min(800px, 100vw - 20px);
    height: min(600px, 100vh - 20px);
    background: var(--frame-color);
    border: 4px solid #555;
    border-radius: 12px;
    box-shadow: 
        0 0 20px rgba(0,0,0,0.8),
        inset 0 0 10px rgba(255,255,255,0.1);
    position: relative;
}

.terminal-frame::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #666, #333, #666);
    border-radius: 14px;
    z-index: -1;
}

.terminal-header {
    background: #222;
    padding: 8px 16px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #444;
    flex-wrap: wrap;
    gap: 8px;
}

.terminal-title {
    color: var(--color-amber);
    font-size: clamp(10px, 2.5vw, 14px);
    font-weight: bold;
    letter-spacing: 1px;
}

.color-selector {
    display: flex;
    gap: 5px;
}

.color-btn {
    background: #333;
    border: 1px solid #555;
    color: #aaa;
    padding: 4px 8px;
    font-size: 10px;
    font-family: inherit;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
}

.color-btn:hover {
    background: #444;
}

.color-btn.active {
    background: #555;
    color: white;
}

.terminal-screen {
    background: var(--bg-dark);
    height: calc(100% - 40px);
    padding: clamp(8px, 2vw, 16px);
    color: var(--color-green);
    font-size: clamp(10px, 2.5vw, 14px);
    line-height: 1.4;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.terminal-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255,255,255,0.03) 2px,
            rgba(255,255,255,0.03) 4px
        );
    pointer-events: none;
}

.output {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
}

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

.output::-webkit-scrollbar-track {
    background: transparent;
}

.output::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

.input-line {
    display: flex;
    align-items: center;
}

.prompt {
    margin-right: 8px;
    white-space: nowrap;
}

#command-input {
    background: transparent;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    flex: 1;
    outline: none;
}

#command-input::selection {
    background: rgba(255,255,255,0.3);
}

.game-controls {
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.game-controls button {
    background: #333;
    border: 2px solid #555;
    color: var(--color-amber);
    padding: 10px 20px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px;
    margin: 0;
    transition: all 0.3s;
    flex: 1;
    min-width: 120px;
}

.game-controls button:hover {
    background: #444;
    border-color: #666;
}

/* Color themes */
.terminal-screen.green { color: var(--color-green); }
.terminal-screen.amber { color: var(--color-amber); }
.terminal-screen.violet { color: var(--color-violet); }
.terminal-screen.white { color: var(--color-white); }

/* Special text styles */
.error { color: #ff4444; }
.warning { color: #ffaa00; }
.success { color: #44ff44; }
.dim { opacity: 0.6; }
.blink {
    animation: blink 1s infinite;
}

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

.boot-text {
    color: #888;
    font-size: 12px;
}

.system-text {
    color: #aaa;
}

.chat-bubble {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 12px 20px;
    max-width: min(400px, 90vw);
    font-style: italic;
    font-size: 14px;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
    text-align: center;
    color: #ffffff;
}

@keyframes slideUp {
    from { transform: translate(-50%, 100%); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.output pre {
    white-space: pre-wrap;
    font-family: inherit;
    margin: 0;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    body {
        padding: 5px;
        align-items: flex-start;
        padding-top: 10px;
    }
    
    .terminal-frame {
        width: 100vw;
        height: calc(100vh - 40px);
        border-radius: 8px;
        border-width: 2px;
    }
    
    .terminal-header {
        padding: 6px 12px;
        min-height: 32px;
    }
    
    .terminal-title {
        font-size: 12px;
        letter-spacing: 0.5px;
    }
    
    .color-btn {
        padding: 3px 6px;
        font-size: 9px;
    }
    
    .terminal-screen {
        height: calc(100% - 32px);
        padding: 8px;
        font-size: 12px;
    }
    
    .game-controls {
        position: fixed;
        bottom: 10px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 100;
        display: flex;
        gap: 10px;
    }
    
    .game-controls button {
        padding: 8px 16px;
        font-size: 12px;
        margin: 0;
        flex: 1;
        min-width: 100px;
    }
    
    .chat-bubble {
        bottom: 60px;
        font-size: 22px;
        padding: 8px 16px;
    }
}

/* Portrait phone - dynamic height for keyboard */
@media (max-width: 480px) and (orientation: portrait) {
    .terminal-frame {
        height: calc(100dvh - 120px);
        min-height: 300px;
    }
    
    .terminal-screen {
        font-size: 11px;
        padding: 6px;
    }
    
    .terminal-title {
        font-size: 10px;
    }
    
    .color-btn {
        padding: 2px 4px;
        font-size: 8px;
    }
    
    .game-controls {
        bottom: 5px;
    }
}

/* Landscape phone */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 2px;
        padding-top: 5px;
    }
    
    .terminal-frame {
        height: calc(100vh - 10px);
        border-radius: 6px;
    }
    
    .terminal-header {
        padding: 4px 8px;
        min-height: 28px;
    }
    
    .terminal-screen {
        height: calc(100% - 28px);
        padding: 4px;
        font-size: 10px;
    }
    
    .game-controls {
        bottom: 5px;
    }
    
    .game-controls button {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .chat-bubble {
        bottom: 35px;
        font-size: 20px;
        padding: 6px 12px;
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    .color-btn {
        min-height: 32px;
        min-width: 32px;
    }
    
    .game-controls button {
        min-height: 40px;
        touch-action: manipulation;
    }
    
    #command-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}