:root {
    --bg-color: #0f0f17;
    --text-color: #cdd6f4;
    --primary: #89b4fa;
    --surface: #1e1e2e;
    --error-red: #f38ba8;
    --success-green: #a6e3a1;
    --header-bg: #181825;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

body { 
    background-color: var(--bg-color); 
    color: var(--text-color); 
    height: 100vh; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
}

header { 
    background-color: var(--header-bg); 
    height: 60px;
    padding: 0 25px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid #313244; 
    flex-shrink: 0;
}

header .logo { color: var(--primary); font-weight: 800; font-size: 1.2rem; }
#btn-logout { background: transparent; border: 1px solid var(--error-red); color: var(--error-red); padding: 5px 15px; cursor: pointer; border-radius: 4px; margin-left: 15px; }

.screen { 
    flex: 1; 
    display: flex; 
    flex-direction: column;
    overflow-y: auto; 
    padding: 20px;
}

.hidden { display: none !important; }

/* Grid de Módulos & Progress Bar */
.modules-container { max-width: 1200px; margin: 0 auto; width: 100%; }
.modules-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 20px; padding-bottom: 20px; }

.module-card { 
    background: var(--surface); padding: 25px; border-radius: 8px; 
    cursor: pointer; border: 2px solid transparent; 
    display: flex; flex-direction: column; min-height: 200px;
    transition: border 0.3s;
}
.module-card:hover { border-color: var(--primary); }
.module-card h3 { margin-bottom: 10px; color: var(--primary); }
.module-card p { flex: 1; color: #bac2de; line-height: 1.5; font-size: 0.95rem; }

.progress-container { margin-top: 20px; border-top: 1px solid #45475a; padding-top: 15px; width: 100%; }
.progress-info { display: flex; justify-content: space-between; font-size: 0.85rem; color: #bac2de; margin-bottom: 8px; font-weight: bold; }
.progress-bar { width: 100%; height: 8px; background: #11111b; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--success-green); transition: width 0.5s ease-in-out; }

/* Layout Tripartido do Game */
.game-layout {
    display: grid;
    grid-template-columns: 320px 1fr 400px;
    width: 100%;
    height: 100%;
    gap: 15px;
}

.panel {
    display: flex; flex-direction: column; background: var(--surface);
    border-radius: 8px; border: 1px solid #313244; overflow: hidden;
}

.panel-header { background: #11111b; padding: 10px 15px; font-size: 0.75rem; font-weight: bold; color: #a6adc8; border-bottom: 1px solid #313244; }

.explanation-panel { padding: 20px; overflow-y: auto; }
#btn-back-modules { align-self: flex-start; background: none; border: none; color: var(--primary); cursor: pointer; margin-bottom: 15px; text-decoration: underline; font-weight: bold; }
#phase-title { font-size: 1.2rem; margin-bottom: 15px; color: var(--primary); border-bottom: 1px solid #313244; padding-bottom: 10px; }
#phase-explanation { font-size: 0.95rem; line-height: 1.6; color: #bac2de; }

.editor-panel .CodeMirror { flex: 1; font-size: 15px; height: auto; }
.action-btn { background: var(--primary); color: #11111b; border: none; padding: 15px; font-weight: 900; font-size: 1.1rem; cursor: pointer; text-transform: uppercase; }
.action-btn:hover { opacity: 0.9; }

.preview-panel { display: grid; grid-template-rows: 1fr 1fr; gap: 2px; background: #313244; }
.preview-section { background: #fff; display: flex; flex-direction: column; }
.preview-section .panel-header { background: #e0e0e0; color: #333; }
.preview-frame { flex: 1; border: none; width: 100%; height: 100%; background: #fff; }

.error-label { border-left: 4px solid var(--error-red); }
.success-label { border-left: 4px solid var(--success-green); }

/* Landing Wrapper */
.landing-wrapper { display: flex; max-width: 1100px; margin: auto; gap: 40px; align-items: center; }
.landing-info { flex: 1; }
.landing-info h1 { font-size: 3rem; color: var(--primary); }
.landing-info h2 { font-size: 1.3rem; margin: 15px 0; color: #bac2de; }
.producer-info { margin-top: 30px; padding: 20px; background: #11111b; border-left: 4px solid var(--success-green); border-radius: 0 8px 8px 0; }
.producer-info h3 { color: var(--success-green); margin-bottom: 5px; }

.login-container { background: var(--surface); padding: 40px; border-radius: 8px; width: 350px; text-align: center; border: 1px solid #313244; }

/* ========================================================= */
/* OVERLAYS (Z-INDEX FORÇADO)                                */
/* ========================================================= */
#error-overlay, #success-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 999999; display: flex; align-items: center; justify-content: center;
}

#error-overlay { background: rgba(0,0,0,0.85); }
.error-stripes {
    width: 100%; height: 200px;
    background: repeating-linear-gradient(45deg, #111, #111 40px, #d32f2f 40px, #d32f2f 80px);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: white; font-size: 3rem; font-weight: 900; text-transform: uppercase;
    box-shadow: 0 10px 40px rgba(255,0,0,0.4); border-top: 5px solid #fff; border-bottom: 5px solid #fff;
    overflow: hidden; white-space: nowrap;
}

#success-overlay { background: rgba(15, 15, 23, 0.95); flex-direction: column; }
.success-message { text-align: center; background: var(--surface); padding: 50px; border-radius: 12px; border: 2px solid var(--success-green); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.success-message h2 { color: var(--success-green); font-size: 3rem; margin-bottom: 10px; }
.success-message p { color: #bac2de; font-size: 1.2rem; margin-bottom: 25px; }

/* ========================================================= */
/* RESPONSIVIDADE E MOBILE PRESETS                           */
/* ========================================================= */
@media (max-width: 1024px) {
    .game-layout { grid-template-columns: 280px 1fr; grid-template-rows: 1fr 350px; }
    .preview-panel { grid-column: span 2; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
}

@media (max-width: 768px) {
    .landing-wrapper { flex-direction: column; text-align: center; }
    .login-container { width: 100%; max-width: 400px; }
    .producer-info { text-align: left; }
    
    .game-layout { display: flex; flex-direction: column; height: auto; }
    .panel { min-height: 400px; margin-bottom: 15px; }
    .preview-panel { grid-template-columns: 1fr; grid-template-rows: 300px 300px; }
    .error-stripes { font-size: 1.8rem; height: 150px; }
}

/* Ajuste específico para mobile em paisagem (Landscape) */
@media (max-width: 900px) and (orientation: landscape) {
    .screen {
        padding-bottom: 60px; /* Garante que os cards não fiquem cortados no bottom */
    }
    .panel { min-height: 300px; }
}
