/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: #000;
    color: #0f0;
    overflow: hidden;
    height: 100vh;
}

/* Background Effects */
#shade {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    opacity: 0.8;
    pointer-events: none;
    animation: flicker 3s infinite;
    z-index: 1;
}

#gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent 50%, rgba(0, 255, 0, 0.02) 50%);
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 2;
}

/* Main Container */
#main-container {
    display: flex;
    height: 100vh;
    position: relative;
    z-index: 3;
}

/* Terminal Section */
#terminal-section {
    flex: 1;
    background: rgba(0, 20, 0, 0.9);
    position: relative;
    padding: 20px;
    border-right: 2px solid #0f0;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

.scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(to bottom, transparent, rgba(0, 255, 0, 0.5), transparent);
    animation: scan 4s linear infinite;
    pointer-events: none;
    z-index: 10;
}

#terminal-container {
    height: 100%;
    position: relative;
}

#terminal {
    height: 100%;
    font-size: 16px;
}

/* Terminal Customization */
.terminal {
    background: transparent !important;
    border: none !important;
    --color: #0f0;
    --background: transparent;
    --link-color: #00ff00;
}

.terminal .terminal-output > div {
    color: #0f0;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.7);
}

.terminal .cmd {
    color: #00ff00 !important;
    text-shadow: 0 0 8px rgba(0, 255, 0, 0.8);
}

.terminal .cmd .prompt {
    color: #00ffff !important;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.8);
}

.terminal .cmd span {
    color: #00ff00 !important;
}

.terminal .cmd .cmd-prompt {
    display: inline !important;
}

.terminal .cmd .cmd-cursor-line {
    display: inline !important;
}

.terminal .terminal-error {
    color: #ff0000 !important;
    text-shadow: 0 0 8px rgba(255, 0, 0, 0.8);
}

.terminal .cursor {
    background: #00ff00 !important;
    color: #000 !important;
    animation: terminal-blink 1s infinite steps(1);
}

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

.user-system {
    color: #00ffff !important;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.8);
}

.user-agent {
    color: #ff9a00 !important;
    text-shadow: 0 0 8px rgba(255, 154, 0, 0.8);
}

/* Puzzle Section */
#puzzle-section {
    width: 450px;
    background: rgba(0, 10, 0, 0.95);
    overflow-y: auto;
    padding: 20px;
    position: relative;
}

#puzzle-section::-webkit-scrollbar {
    width: 8px;
}

#puzzle-section::-webkit-scrollbar-track {
    background: rgba(0, 255, 0, 0.1);
}

#puzzle-section::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 0, 0.4);
    border-radius: 4px;
}

#puzzle-section::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 0, 0.6);
}

/* Tree Visualization */
#tree-container {
    position: sticky;
    top: 0;
    background: rgba(0, 10, 0, 0.95);
    padding-bottom: 20px;
    z-index: 5;
}

#tree-svg {
    width: 100%;
    height: 150px;
}

.tree-line {
    stroke: #0f0;
    stroke-width: 2;
    opacity: 0.5;
}

.tree-line.active {
    opacity: 1;
    stroke: #00ff00;
    filter: drop-shadow(0 0 3px #0f0);
}

.tree-dot {
    fill: #0f0;
    stroke: #000;
    stroke-width: 2;
}

.tree-dot.completed {
    fill: #00ff00;
    filter: drop-shadow(0 0 5px #0f0);
}

.tree-dot.active {
    animation: pulse 1s infinite;
}

/* Puzzle Cards */
.puzzle-card {
    background: rgba(0, 255, 0, 0.05);
    border: 2px solid #0f0;
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.2);
    animation: fadeIn 0.5s ease-in;
}

.puzzle-card.completed {
    border-color: #00ff00;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.4);
}

.puzzle-card.locked {
    opacity: 0.4;
    border-color: #555;
    box-shadow: none;
}

.puzzle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 255, 0, 0.3);
}

.puzzle-id {
    font-size: 18px;
    color: #00ff00;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.8);
    font-weight: bold;
}

.puzzle-status {
    padding: 5px 10px;
    border: 1px solid #0f0;
    font-size: 12px;
    text-transform: uppercase;
}

.puzzle-status.new {
    color: #00ff00;
    border-color: #00ff00;
    animation: glow 1.5s infinite;
}

.puzzle-status.completed {
    color: #0f0;
}

.puzzle-status.locked {
    color: #555;
    border-color: #555;
}

.puzzle-info {
    margin-bottom: 15px;
    font-size: 14px;
    line-height: 1.6;
}

.puzzle-meta {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 5px;
}

.load-button {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 2px solid #0f0;
    color: #0f0;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.load-button:hover:not(:disabled) {
    background: rgba(0, 255, 0, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    transform: translateY(-2px);
}

.load-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.load-button.active {
    background: rgba(0, 255, 0, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.4);
}

/* Audio Toggle */
#audio-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 20px;
    background: rgba(0, 255, 0, 0.1);
    border: 2px solid #0f0;
    color: #0f0;
    text-decoration: none;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    z-index: 100;
    transition: all 0.3s;
    text-transform: uppercase;
}

#audio-toggle:hover {
    background: rgba(0, 255, 0, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
}

#audio-toggle .status {
    color: #00ff00;
}

#audio-toggle.muted .status {
    color: #ff0000;
}

/* Animations */
@keyframes scan {
    0% { top: 0%; }
    100% { top: 100%; }
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(0, 255, 0, 0.5); }
    50% { box-shadow: 0 0 20px rgba(0, 255, 0, 0.8); }
}

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

@keyframes glitch {
    0% { transform: translateX(0); }
    20% { transform: translateX(-2px); }
    40% { transform: translateX(2px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    100% { transform: translateX(0); }
}

/* CRT Effect */
#terminal-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}

/* Responsive */
@media (max-width: 1024px) {
    #main-container {
        flex-direction: column;
    }

    #terminal-section {
        height: 60%;
        border-right: none;
        border-bottom: 2px solid #0f0;
    }

    #puzzle-section {
        width: 100%;
        height: 40%;
    }
}
