/* --- EXTERNAL FONTS --- */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

/* --- GLOBAL 8-BIT PALETTE & RESET --- */
:root {
    --bg-color: #101018;       /* Deep Void Blue */
    --card-bg: #1a1a24;        /* Orbital Platform Grey */
    --border-color: #4a6a8a;   /* Muted Steel HUD */
    --dark-blue-border: #2b4a5c; /* Dark Slate Blue for Folders */
    --terminal-text: #aaddff;  /* Hologram Cyan */
    --accent-gold: #ffcc00;    /* High Score Gold */
    --neon-pink: #ff55aa;      /* Critical Error Pink */
    --success-green: #55ffaa;  /* System Ready Green */
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-color);
    background-image: url("pcf_equation_tile_dark.png");
    background-repeat: repeat; 
    color: var(--terminal-text);
    font-family: 'VT323', monospace; 
    font-size: 1.3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: 100dvh;
    margin: 0;
    padding: 5px;
    overflow-x: hidden;
}

/* CRT SCANLINE EFFECT */
body::before {
    content: " "; display: block; position: fixed;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    z-index: 2; background-size: 100% 2px, 3px 100%; pointer-events: none;
}

/* --- LAYOUT ORDERING --- */
.order-1 { order: 1; width: 100%; display: flex; justify-content: center; z-index: 3;} 
.order-2 { order: 2; width: 100%; display: flex; justify-content: center; flex-direction:column; align-items:center; z-index: 3;}
.order-3 { order: 3; width: 100%; z-index: 3;} 
.order-4 { order: 4; z-index: 3;} 

.ad-container { width: 100%; max-width: 728px; min-height: 90px; margin-bottom: 10px; display: flex; justify-content: center; align-items: center; overflow: hidden; }
.adsense-placeholder { width: 100%; max-width: 600px; min-height: 100px; background: transparent; display: flex; align-items: center; justify-content: center; }

/* --- NAVIGATION BAR --- */
.main-nav { 
    background-color: #000; 
    border-bottom: 2px dashed var(--border-color); 
    width: 100%; padding: 5px 15px; text-align: center; 
    margin-bottom: 10px; z-index: 5; 
    white-space: nowrap; 
    font-size: clamp(0.7rem, 3.5vw, 1rem);
}
.main-nav a { color: var(--success-green); text-decoration: none; font-size: 1.2em; margin: 0 10px; display: inline-block; }
.main-nav a:hover { color: #fff; text-shadow: 0 0 5px var(--success-green); }

/* --- GAME INTERFACE --- */
#game-wrapper { flex-grow: 1; width: 100%; max-width: 600px; }

#game-container {
    background-color: var(--card-bg);
    border: 4px solid var(--border-color); border-radius: 4px;
    padding: 15px; width: 100%; 
    box-shadow: 0 5px 0 #223344; 
    text-align: center; position: relative;
}

h1 { 
    font-family: 'VT323', monospace; 
    font-size: clamp(1.5rem, 7vw, 3.0em); 
    color: var(--accent-gold); text-shadow: 2px 2px #000; 
    margin: 0; line-height: 1; font-weight: normal; 
}

.header-row { 
    display: flex; justify-content: space-between; align-items: center; 
    margin-bottom: 5px; 
    white-space: nowrap; 
}

.settings-icon { font-size: 1.5rem; cursor: pointer; color: var(--border-color); }
.settings-icon:hover { color: var(--accent-gold); }

.stats-bar {
    display: flex; justify-content: space-between;
    background: #111; padding: 5px 10px; border: 2px solid #333;
    margin-bottom: 10px; color: #fff; font-family: 'Press Start 2P', cursive; font-size: 0.6em; letter-spacing: 1px;
}

#level-name { display: block; color: var(--terminal-text); font-family: 'Press Start 2P', cursive; font-size: 0.8em; margin-bottom: 5px; line-height: 1.4; }
#equation-display { font-size: 2.2em; margin: 5px 0; min-height: 50px; color: #fff; text-shadow: 2px 2px 0px #000; font-family: 'VT323', monospace; }
.katex { font-family: 'VT323', monospace !important; font-size: 1.1em; }
#equation-context { font-size: 1.4em; color: var(--accent-gold); margin-bottom: 10px; min-height: 25px; font-weight: bold; }

/* --- CONTROLS & DYNAMIC KEYPAD --- */
.controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }

input[type="text"] {
    background: #080810; border: 2px solid var(--border-color); color: #fff;
    padding: 10px; font-size: 1.5em; width: 80%; text-align: center; outline: none;
    font-family: 'VT323', monospace; caret-color: var(--success-green);
}
input[type="text"]:focus { border-color: var(--accent-gold); }

button {
    border: 2px solid var(--border-color); color: var(--terminal-text);
    padding: 10px; font-size: 1.2em; cursor: pointer;
    font-family: 'VT323', monospace; text-transform: uppercase; 
    background: #222; box-shadow: 0 4px 0 #111; border-radius: 0;
    flex: 1 0 45%; position: relative;
}
button:active { top: 4px; box-shadow: 0 0 0; }
button:hover { background: #333; }

.btn-gold { border-color: var(--accent-gold); color: var(--accent-gold); }
.btn-green { background: #2a3a4a; border-color: var(--success-green); color: var(--success-green); }
.btn-ghost { border-color: var(--terminal-text); color: var(--terminal-text); }

#submit-btn { 
    background-color: var(--border-color); color: #fff; border: none; flex-basis: 100%;
    font-family: 'Press Start 2P', cursive; font-size: 0.8em; padding: 15px; box-shadow: 0 6px 0 #223344;
}
#submit-btn:active { top: 6px; box-shadow: 0 0 0; }

/* DYNAMIC KEYPAD (For Level 20) */
#dynamic-keypad {
    display: none; /* Hidden by default */
    gap: 5px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; width: 100%;
}
.keypad-btn {
    background: #1a1a24; border: 2px solid var(--border-color); color: var(--accent-gold);
    font-family: 'VT323', monospace; font-size: 1.4em; padding: 5px 10px; cursor: pointer;
    box-shadow: 0 4px 0 #111; flex: 1 1 auto; max-width: 50px; text-align: center; text-transform: none;
}
.keypad-btn:active { top: 4px; box-shadow: 0 0 0; }
.keypad-btn.op-key { color: var(--neon-pink); border-color: var(--neon-pink); }

#message-area { min-height: 25px; color: var(--success-green); margin-bottom: 5px; font-size: 1.2em; }
#helper-text { color: #666; font-size: 0.9em; margin-top: 5px; }

/* --- MODALS --- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.9); z-index: 100; justify-content: center; align-items: center; }
.modal-content { background: var(--bg-color); border: 4px solid var(--border-color); padding: 20px; width: 95%; max-width: 500px; max-height: 90vh; overflow-y: auto; text-align: center; position: relative; font-family: 'VT323', monospace; }
.modal-close-x { position: absolute; top: 5px; right: 10px; color: var(--neon-pink); font-size: 2em; cursor: pointer; font-family: sans-serif; }
.modal-title { color: var(--accent-gold); font-family: 'Press Start 2P'; font-size: 1.2em; margin-bottom: 20px; border-bottom: 2px dashed #333; padding-bottom:10px; }
.modal-btn-close { margin-top: 20px; background: #333; color:#fff; width: 100%; border:none; box-shadow:none;}
.curr-item { border-bottom: 1px dashed #333; padding: 10px 0; text-align: left; }
.curr-title { font-weight: bold; font-size: 1.3em; display:block; margin-bottom:4px; color: var(--accent-gold); }
.curr-desc { color: #aaa; font-size: 1.1em; line-height: 1.3; }

/* --- CONTENT CSS (Philosophy/Guides Pages) --- */
.content-container {
    width: 100%; max-width: 800px; margin: 20px auto; padding: 25px; 
    background: var(--card-bg); 
    border: 4px solid var(--border-color); 
    
    /* DOSSIER FOLDER LOOK */
    border-left: 4px solid var(--dark-blue-border); 
    border-top: 4px solid var(--dark-blue-border);
    border-top-left-radius: 12px;
    
    box-shadow: 0 5px 0 #223344;
    color: var(--terminal-text); line-height: 1.6; font-size: 1.2em; text-align: left;
}
.content-container h2, .content-container h3 { 
    font-family: 'Press Start 2P', cursive; 
    color: var(--accent-gold); 
    font-size: clamp(0.9em, 4vw, 1.2em); /* Scales dynamically to prevent wrapping */
    line-height: 1.4; 
    margin-top: 20px; 
    word-spacing: -4px; /* Pulls the words closer together */
}

.content-container p {
    margin-bottom: 15px; /* Tightens the gap after paragraphs */
}

.content-container h4 { 
    color: var(--neon-pink); 
    font-size: 1.3em; 
    margin-top: 25px; /* Overrides default browser margins to pull levels closer together */
}

.content-container strong { color: var(--success-green); }

/* --- EASTER EGG CSS --- */
#easter-egg-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; color: var(--success-green); font-family: 'Courier New', monospace; z-index: 9999; padding: 20px; overflow-y: auto; text-align: left; }
.ascii-art { white-space: pre; font-size: 10px; line-height: 10px; color: var(--success-green); text-align: center; margin-bottom: 20px; }
h1.glitch { text-shadow: 2px 0 #f00, -2px 0 #00f; }
.close-console { position: fixed; top: 20px; right: 20px; color: #0f0; cursor: pointer; border: 1px solid #0f0; padding: 5px 10px; }

/* --- FOOTER & MERCH --- */
footer { margin-top: 10px; padding: 20px; border-top: 1px dashed #333; text-align: center; color: #666; width: 100%; font-family: 'VT323', monospace; }
footer a { color: #888; margin: 0 10px; text-decoration: none; }
footer a:hover { color: var(--terminal-text); }

.merch-grid { display: flex; gap: 5px; margin: 5px 0; }

/* TRANSPARENT MERCH WITH GLOW EFFECT */
.merch-item { 
    flex: 1; 
    border: none; 
    overflow: hidden; 
    aspect-ratio: 1; 
    background: transparent; 
    transition: all 0.2s;
}
.merch-item:hover { 
    transform: scale(1.05); 
    filter: drop-shadow(0 0 8px var(--accent-gold)); 
}
.merch-item img { width: 100%; height: 100%; object-fit: contain; }

.btn-coffee { 
    background: var(--accent-gold); color: #000; width: 100%; 
    font-family: 'Press Start 2P'; font-size:0.8em; padding:15px; border:none; 
    box-shadow: 0 4px 0 #bfa600; margin-top:0px; cursor: pointer;
}
.btn-coffee:active { transform: translateY(4px); box-shadow: none; }