@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'JetBrains Mono', monospace;
    color: #333;
    height: 100vh;
    overflow: hidden;
    display: flex;
    background: #1a1a1a;
}

.game-fact-panel {
    position: absolute;        /* ⬅️ Not fixed! Tie it to .simulation-container */
    top: 500px;                /* ⬅️ Directly below the 500px game container */
    left: 0;
    width: 100%;
    height: 200px;
    background: #d4b483;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    z-index: 99;
}


.game-fact-panel .bulb {
    font-size: 2em;
    margin-bottom: 4px;
}

.game-fact-panel .fact-title {
    font-weight: bold;
    font-size: 1.1em;
    color: #a0672a;
    margin-bottom: 2px;
}

.game-fact-panel .fact-text {
    color: #5a3921;
    font-weight: 500;
    font-size: 1em;
    text-align: center;
    max-width: 90%;
}


.simulation-container {
    width: 60%;
    height: auto;
    min-height: 700px;
    position: relative;
    overflow: hidden;
    perspective: 1000px;
    background: #d4b483;
}

canvas {
    display: block;
    position: relative;
    z-index: 1;
}

.terminal {
    width: 40%;
    height: 100vh;
    background: linear-gradient(135deg, #3a3a3a 0%, #2a2a2a 100%);
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #555;
    color: #c0c0c0;
    font-family: 'Courier New', monospace;
    position: relative;
    overflow: hidden;
}

.terminal::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
                linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.2;
    pointer-events: none;
}

.terminal-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
    position: relative;
    z-index: 2;
}

.terminal-title {
    color: #d4a657;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(212, 166, 87, 0.3);
}

.output {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    min-height: 400px;
    border: 1px solid #444;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 2;
}

.line {
    color: #d4d4d4;
    margin-bottom: 5px;
    line-height: 1.4;
}

.response {
    color: #d4d4d4;
    margin-bottom: 15px;
    line-height: 1.6;
}

.current-line {
    display: flex;
    align-items: center;
}

.input-prompt {
    color: #d4a657;
    margin-right: 10px;
    font-weight: bold;
}

.command-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #d4d4d4;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    outline: none;
}

.help-text {
    color: #777;
    font-size: 12px;
    margin-top: 10px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.cursor {
    animation: blink 1s infinite;
    color: #d4a657;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.error-message {
    color: #ff6b6b;
    font-weight: bold;
}

.name-tag {
    position: absolute;
    width: 220px;
    height: 140px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="220" height="140" viewBox="0 0 220 140"><rect width="220" height="140" rx="4" fill="%23d4b483"/><rect x="5" y="5" width="210" height="130" rx="2" fill="%23e8d9b5" stroke="%23b38b5a" stroke-width="0.5"/></svg>');
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 
                inset 0 0 0 1px rgba(255, 255, 255, 0.2),
                inset 0 0 15px rgba(139, 69, 19, 0.4);
    cursor: grab;
    z-index: 10;
    display: none;
    pointer-events: auto;
    user-select: none;
    transform-origin: center;
    transform-style: preserve-3d;
    transition: transform 0.1s ease-out, box-shadow 0.2s ease;
}

.name-tag:active {
    cursor: grabbing;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.name-tag-content {
    padding: 15px;
    text-align: center;
    color: #5a3921;
    pointer-events: none;
    transform: translateZ(20px);
    backface-visibility: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.name-tag-content::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="220" height="140" viewBox="0 0 220 140"><path d="M10,20 Q30,10 50,20 T90,20 T130,20 T170,20" fill="none" stroke="%23b38b5a" stroke-width="0.3" opacity="0.5"/><path d="M10,40 Q30,30 50,40 T90,40 T130,40 T170,40" fill="none" stroke="%23b38b5a" stroke-width="0.3" opacity="0.5"/><path d="M10,60 Q30,50 50,60 T90,60 T130,60 T170,60" fill="none" stroke="%23b38b5a" stroke-width="0.3" opacity="0.5"/><path d="M10,80 Q30,70 50,80 T90,80 T130,80 T170,80" fill="none" stroke="%23b38b5a" stroke-width="0.3" opacity="0.5"/><path d="M10,100 Q30,90 50,100 T90,100 T130,100 T170,100" fill="none" stroke="%23b38b5a" stroke-width="0.3" opacity="0.5"/><path d="M10,120 Q30,110 50,120 T90,120 T130,120 T170,120" fill="none" stroke="%23b38b5a" stroke-width="0.3" opacity="0.5"/></svg>');
    opacity: 0.4;
    pointer-events: none;
}

.profile-pic {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(45deg, #8B4513, #A0522D);
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #e8d9b5;
    font-weight: bold;
    border: 3px solid #b38b5a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: relative;
    z-index: 1;
}

.name {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
    color: #5a3921;
    position: relative;
    z-index: 1;
}

.title {
    font-size: 13px;
    color: #8B4513;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    position: relative;
    z-index: 1;
}

.fixed-point {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #8B4513;
    border-radius: 50%;
    box-shadow: 
        0 0 0 2px rgba(229, 191, 143, 0.8),
        inset 0 1px 2px rgba(0,0,0,0.2);
    z-index: 2;
}

.subtle-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(139, 69, 19, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(139, 69, 19, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: 0;
}

.handwritten-code {
    position: absolute;
    font-family: 'Caveat', cursive;
    color: rgba(91, 60, 17, 0.5);
    font-size: 18px;
    transform: rotate(var(--rotation, 0deg)) translate(var(--tx, 0), var(--ty, 0));
    z-index: 0;
    pointer-events: none;
    white-space: pre;
    line-height: 1.4;
    transition: transform 0.5s ease-out;
}

.handwritten-code.dark {
    color: rgba(91, 60, 17, 0.6);
}

.handwritten-code.light {
    color: rgba(91, 60, 17, 0.3);
}

.code-keyword {
    color: rgba(91, 60, 17, 0.7);
    font-weight: bold;
}

.code-string {
    color: rgba(91, 60, 17, 0.5);
}

.code-comment {
    color: rgba(91, 60, 17, 0.4);
    font-style: italic;
}

.output::-webkit-scrollbar {
    width: 8px;
}

.output::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.output::-webkit-scrollbar-thumb {
    background: #8B4513;
    border-radius: 4px;
}

.rust-effect {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M10,10 Q25,5 40,10 T70,10 T100,10" fill="none" stroke="%238B4513" stroke-width="1" opacity="0.1"/><path d="M10,30 Q25,25 40,30 T70,30 T100,30" fill="none" stroke="%238B4513" stroke-width="1" opacity="0.1"/><path d="M10,50 Q25,45 40,50 T70,50 T100,50" fill="none" stroke="%238B4513" stroke-width="1" opacity="0.1"/><path d="M10,70 Q25,65 40,70 T70,70 T100,70" fill="none" stroke="%238B4513" stroke-width="1" opacity="0.1"/><path d="M10,90 Q25,85 40,90 T70,90 T100,90" fill="none" stroke="%238B4513" stroke-width="1" opacity="0.1"/></svg>');
    pointer-events: none;
    z-index: 1;
}

/* Game Styles */
.game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 500px;
    background: linear-gradient(to bottom, #87CEEB, #E0F7FA);
    display: none;
    z-index: 5;
    overflow: hidden;
}

.bird {
    position: absolute;
    width: 40px;
    height: 30px;
    background: #FFD700;
    border-radius: 50% 50% 20% 20%;
    z-index: 10;
}

.bird-eye {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #000;
    border-radius: 50%;
    top: 5px;
    left: 10px;
}

.bird-beak {
    position: absolute;
    width: 10px;
    height: 5px;
    background: #FF4500;
    clip-path: polygon(0% 0%, 100% 50%, 0% 100%);
    top: 10px;
    left: 25px;
}

.pipe {
    position: absolute;
    width: 60px;
    z-index: 8;
}

.pipe.top {
    top: 0;
    background: linear-gradient(to bottom, #4CAF50, #388E3C);
}

.pipe.bottom {
    bottom: 30px;
    background: linear-gradient(to top, #4CAF50, #388E3C);
}

.pipe::after {
    content: "";
    position: absolute;
    width: 70px;
    height: 20px;
    background: #2E7D32;
    left: -5px;
    border-radius: 5px;
}

.pipe.top::after {
    bottom: -10px;
}

.pipe.bottom::after {
    top: -10px;
}

.ground {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 30px;
    background: linear-gradient(to bottom, #5D4037, #4E342E);
    z-index: 9;
    box-shadow: 0 -5px 10px rgba(0, 0, 0, 0.3);
}

.ground::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(to right, 
        transparent 0%, 
        rgba(255, 255, 255, 0.2) 50%, 
        transparent 100%);
}

.ground::after {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="10" viewBox="0 0 20 10"><path d="M0,5 Q5,0 10,5 T20,5" fill="none" stroke="%234E342E" stroke-width="1"/></svg>');
    background-size: 20px 10px;
    opacity: 0.8;
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FF5722;
    font-size: 36px;
    font-weight: bold;
    text-align: center;
    display: none;
    z-index: 20;
}

.score {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #000;
    font-size: 24px;
    font-weight: bold;
    z-index: 15;
}

/* Audio Controls */
#unmute {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    z-index: 1000;
    font-family: 'JetBrains Mono', monospace;
}

#unmute:hover {
    background: rgba(139, 0, 0, 0.7);
}

/* Elements to hide during game */
.simulation-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.snake-fact-panel {
    position: absolute;        /* ⬅️ Not fixed! Tie it to .simulation-container */
    top: 500px;                /* ⬅️ Directly below the 500px game container */
    left: 0;
    width: 60%;
    height: 200px;
    background: #d4b483;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    z-index: 99;
}


.snake-fact-panel .bulb {
    font-size: 2em;
    margin-bottom: 4px;
}

.snake-fact-panel .fact-title {
    font-weight: bold;
    font-size: 1.1em;
    color: #a0672a;
    margin-bottom: 2px;
}

.snake-fact-panel .fact-text {
    color: #5a3921;
    font-weight: 500;
    font-size: 1em;
    text-align: center;
    max-width: 90%;
}


/* Snake Game Styles */
.snake-game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 60%;
    height: 500px;
    background: #222;
    z-index: 5;
    overflow: hidden;
}

.snake-game-container canvas {
    display: block;
    margin: 0 auto;
    background: #111;
    border-radius: 8px;
}

.snake-scoreboard {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #0f0;
    font-size: 22px;
    font-family: 'JetBrains Mono', monospace;
    z-index: 10;
}

.snake-game-over {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FF5722;
    font-size: 32px;
    font-weight: bold;
    text-align: center;
    z-index: 20;
}

.snake-game-over button {
    margin-top: 16px;
    padding: 8px 18px;
    font-size: 1em;
    border: none;
    border-radius: 4px;
    background: #0f0;
    color: #222;
    cursor: pointer;
}

.snake-game-over button:active {
    background: #0c0;
}

/* Responsive layout for mobile */
@media (max-width: 900px) {
    body {
        flex-direction: column;
        height: auto;
        overflow: auto;
    }
    .simulation-container,
    .terminal {
        width: 100%;
        height: 50vh;
        min-height: 220px;
        max-height: 60vh;
    }
    .simulation-container {
        min-height: 220px;
        height: 50vh;
    }
    .terminal {
        min-height: 220px;
        height: 50vh;
        border-left: none;
        border-top: 1px solid #555;
        padding: 10px;
    }
    .output {
        min-height: 100px;
        font-size: 13px;
    }
    .game-container {
        height: 220px;
    }
    .score {
        font-size: 16px;
        top: 8px;
        left: 8px;
    }
    .game-over {
        font-size: 18px;
    }
    .name-tag {
        width: 120px;
        height: 60px;
        font-size: 11px;
    }
    .profile-pic {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }
    .bird {
        width: 28px;
        height: 20px;
    }
    .bird-eye {
        width: 6px;
        height: 6px;
        left: 7px;
        top: 3px;
    }
    .bird-beak {
        width: 7px;
        height: 3px;
        left: 18px;
        top: 8px;
    }
    .pipe {
        width: 36px;
    }
    .pipe::after {
        width: 44px;
        height: 12px;
        left: -4px;
    }
    .snake-game-container {
        width: 100%;
        height: 220px; /* Match game-container height on mobile */
    }
    
    .snake-scoreboard {
        font-size: 16px;
        top: 8px;
        left: 8px;
    }
    
    .snake-game-over {
        font-size: 18px;
    }
    
    .snake-game-over button {
        padding: 6px 14px;
        font-size: 0.9em;
    }
    
    .snake-fact-panel {
        width: 100%;
        top: 220px; /* Position below the game container */
        height: auto;
        padding: 10px;
    }

}

/* Show rotate message on portrait mobile */
@media (max-width: 900px) and (orientation: portrait) {
    #rotate-message {
        display: flex;
    }
    .simulation-container,
    .terminal {
        filter: blur(2px);
        pointer-events: none;
        user-select: none;
    }
}

#rotate-message {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(30,30,30,0.95);
    color: #fff;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    text-align: center;
    flex-direction: column;
}

#rotate-message svg {
    width: 60px;
    height: 60px;
    margin-bottom: 20px;
}

