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

body {
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    background: linear-gradient(135deg, #0d1117 0%, #161b22 30%, #0d1117 100%);
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(0, 255, 0, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(0, 150, 255, 0.02) 0%, transparent 50%);
    color: #00ff00;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Desktop background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(0, 255, 0, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(0, 255, 0, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Desktop container */
.desktop {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

/* Window frame */
.window {
    width: 90%;
    max-width: 1200px;
    height: 85vh;
    background: #1e1e1e;
    border: 1px solid rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    box-shadow: 
        0 25px 80px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    backdrop-filter: blur(10px);
}

/* Window titlebar */
.window-titlebar {
    background: linear-gradient(to bottom, #3a3a3a, #2d2d2d);
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    user-select: none;
    cursor: move;
    flex-shrink: 0;
    height: 40px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.window-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 500;
    flex: 1;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.window-icon {
    font-size: 14px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

.window-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.window-btn {
    width: 12px;
    height: 12px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.2);
}

.window-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    opacity: 0;
    transition: all 0.2s ease;
}

.window-btn.close {
    background: #ff5f57;
    border: 0.5px solid rgba(0, 0, 0, 0.1);
}

.window-btn.close:hover {
    background: #ff3b30;
    transform: scale(1.1);
}

.window-btn.close:hover::before {
    content: '×';
    color: rgba(0, 0, 0, 0.6);
    font-size: 10px;
    font-weight: bold;
    width: auto;
    height: auto;
    opacity: 1;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.window-btn.minimize {
    background: #ffbd2e;
    border: 0.5px solid rgba(0, 0, 0, 0.1);
}

.window-btn.minimize:hover {
    background: #ff9500;
    transform: scale(1.1);
}

.window-btn.minimize:hover::before {
    content: '−';
    color: rgba(0, 0, 0, 0.6);
    font-size: 12px;
    font-weight: bold;
    width: auto;
    height: auto;
    opacity: 1;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1;
}

.window-btn.maximize {
    background: #28c840;
    border: 0.5px solid rgba(0, 0, 0, 0.1);
}

.window-btn.maximize:hover {
    background: #20d046;
    transform: scale(1.1);
}

.window-btn.maximize:hover::before {
    content: '□';
    color: rgba(0, 0, 0, 0.6);
    font-size: 8px;
    font-weight: bold;
    width: auto;
    height: auto;
    opacity: 1;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1;
}

/* CRT Scanline Effect (inside window) */
#terminal-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        transparent 50%,
        rgba(0, 255, 0, 0.03) 50%
    );
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 1000;
    animation: scanline 8s linear infinite;
}

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

/* Flicker and Glow Effect (inside window) */
#terminal-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at center, rgba(0, 255, 0, 0.05) 0%, transparent 70%),
        rgba(0, 0, 0, 0.02);
    pointer-events: none;
    z-index: 1001;
    animation: flicker 0.15s infinite;
}

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

/* Boot Screen */
#boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.5s ease-out;
}

#boot-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.boot-content {
    text-align: center;
    color: #00ff00;
}

.boot-title {
    font-size: 2.5em;
    margin-bottom: 1em;
    text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00;
    animation: pulse 2s ease-in-out infinite;
}

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

.boot-subtitle {
    font-size: 1.2em;
    margin-bottom: 2em;
    color: #00cc00;
}

.boot-progress {
    width: 400px;
    height: 20px;
    background: #001100;
    border: 1px solid #00ff00;
    margin: 0 auto 2em;
    position: relative;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: #00ff00;
    width: 0%;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px #00ff00;
}

.boot-text {
    font-size: 0.9em;
    color: #00aa00;
    min-height: 1.5em;
}

/* Terminal Container */
#terminal-container {
    width: 100%;
    flex: 1;
    background: #0d1117;
    position: relative;
    overflow: hidden;
    border-radius: 0 0 10px 10px;
}

/* Terminal Glow - combined with flicker in ::after above */

/* XTerm.js Customization */
.xterm {
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 15px;
    font-weight: 400;
    padding: 20px;
    letter-spacing: 0;
}

.xterm .xterm-rows {
    font-variant-ligatures: normal;
    line-height: 1.4;
    white-space: pre;
}

.xterm .xterm-rows > div {
    white-space: pre;
    font-variant-ligatures: none;
}

.xterm-viewport {
    background: #0d1117 !important;
    scrollbar-width: thin;
}

.xterm-screen {
    background: #0d1117 !important;
}

.xterm-cursor-layer {
    z-index: 2;
}

/* Custom scrollbar */
.xterm-viewport::-webkit-scrollbar {
    width: 8px;
}

.xterm-viewport::-webkit-scrollbar-track {
    background: #001100;
}

.xterm-viewport::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

.xterm-viewport::-webkit-scrollbar-thumb:hover {
    background: #00cc00;
}

/* Text selection */
::selection {
    background: #00ff00;
    color: #000;
}

/* Ending modal */
.ending-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2500;
    padding: 24px;
    color: #c9d1d9;
}

.ending-modal.visible {
    display: flex;
}

.ending-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 12, 24, 0.78);
    backdrop-filter: blur(6px);
}

.ending-modal__panel {
    position: relative;
    background: linear-gradient(155deg, rgba(13, 17, 23, 0.97), rgba(22, 29, 40, 0.97));
    border: 1px solid rgba(120, 170, 255, 0.2);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
    padding: 32px;
    max-width: 500px;
    width: 100%;
    border-radius: 18px;
    z-index: 1;
    text-align: center;
}

.ending-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(201, 209, 217, 0.08);
    color: #f0f6fc;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.ending-modal__close:hover,
.ending-modal__close:focus {
    outline: none;
    background: rgba(201, 209, 217, 0.18);
    transform: scale(1.05);
}

.ending-modal h2 {
    font-size: 1.45rem;
    margin-bottom: 12px;
    color: #8cb4ff;
    letter-spacing: 0.04em;
}

.ending-modal__description {
    font-size: 0.95rem;
    margin: 0 auto 24px;
    max-width: 360px;
    color: rgba(201, 209, 217, 0.85);
}

.ending-modal__actions {
    display: grid;
    gap: 14px;
    margin-bottom: 28px;
}

.ending-modal__button {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(112, 168, 255, 0.3);
    background: rgba(14, 21, 32, 0.9);
    cursor: pointer;
    color: #f0f6fc;
    font-size: 1rem;
    font-weight: 500;
    transition: border 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.ending-modal__button:hover,
.ending-modal__button:focus {
    outline: none;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(65, 130, 255, 0.25);
    border-color: rgba(154, 200, 255, 0.7);
}

.ending-modal__button:active {
    transform: translateY(0);
}

.ending-modal__hint {
    font-size: 0.8rem;
    color: rgba(201, 209, 217, 0.7);
    letter-spacing: 0.02em;
}

.ending-modal__footer {
    display: flex;
    justify-content: center;
}

.ending-modal__secondary {
    background: transparent;
    color: rgba(140, 180, 255, 0.85);
    border: 1px solid rgba(140, 180, 255, 0.4);
    border-radius: 999px;
    padding: 10px 22px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border 0.2s ease;
}

.ending-modal__secondary:hover,
.ending-modal__secondary:focus {
    outline: none;
    background: rgba(140, 180, 255, 0.15);
    border-color: rgba(140, 180, 255, 0.7);
    color: #f0f6fc;
}

