/* =========================================================
   STYLE - TROUVE LA COQUILLE !
   Design premium : Bureau / Cahier d'écolier
========================================================= */

:root {
    --bg-main: #1e293b;
    --paper-bg: #f8fafc;
    --paper-line: #bae6fd;
    --paper-margin: #fca5a5;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    
    --text-main: #334155;
    --text-light: #f1f5f9;
    
    --correct: #10b981;
    --wrong: #ef4444;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    background-image: radial-gradient(circle at top right, #334155, #0f172a);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* Floating Back Button */
.btn-back {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.app-container {
    width: 100%;
    max-width: 800px;
    margin: auto;
    position: relative;
}

.screen {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.screen.active {
    display: block;
}

/* Menu Screen */
.glass-panel {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.logo-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

h1 {
    font-size: 2.8rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1.2rem;
    color: #cbd5e1;
    margin-bottom: 2rem;
    font-weight: 300;
}

.instructions {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2.5rem;
    color: #e2e8f0;
    line-height: 1.6;
    border-left: 4px solid var(--primary);
}

h2 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    color: #fff;
}

.level-selector {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.btn-level {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1rem 1.5rem;
    width: 100%;
    max-width: 400px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    color: #fff;
    text-align: left;
}

.btn-level:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.level-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #93c5fd;
}

.level-desc {
    font-size: 0.9rem;
    color: #94a3b8;
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.score-board {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 99px;
    font-weight: 600;
    font-size: 1.1rem;
    border: 1px solid rgba(255,255,255,0.2);
}

.level-badge {
    background: var(--primary);
    padding: 0.3rem 1rem;
    border-radius: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

.btn-quit {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #cbd5e1;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-quit:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* Notebook UI */
.notebook-container {
    background-color: var(--paper-bg);
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
    padding: 2rem 1rem 3rem 4rem;
    min-height: 400px;
    /* Drawing the notebook lines */
    background-image: 
        linear-gradient(90deg, transparent 3.8rem, var(--paper-margin) 3.8rem, var(--paper-margin) 3.9rem, transparent 3.9rem),
        linear-gradient(var(--paper-line) 1px, transparent 1px);
    background-size: 100% 100%, 100% 3rem;
    background-position: 0 0, 0 1.5rem;
}

.notebook-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-right: 1rem;
}

.notebook-title {
    font-family: 'Caveat', cursive;
    font-size: 2rem;
    color: #1e293b;
    font-weight: 700;
}

.notebook-stamp {
    border: 3px solid #ef4444;
    color: #ef4444;
    font-weight: 800;
    padding: 0.3rem 1rem;
    border-radius: 6px;
    transform: rotate(-5deg);
    font-size: 1.2rem;
    letter-spacing: 2px;
    opacity: 0.8;
}

/* Calculation Lines */
.notebook-lines {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 1rem;
}

.calc-line {
    font-size: 1.5rem;
    color: var(--text-main);
    padding: 0.4rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    position: relative;
}

.calc-line:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateX(10px);
}

.calc-line.selected-wrong {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--wrong);
    animation: shake 0.4s;
}

.calc-line.selected-correct {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--correct);
    transform: scale(1.02);
}

/* Katex adjustments */
.katex-display {
    margin: 0 !important;
}
.katex {
    font-size: 1.4rem !important;
}

/* Feedback Overlay */
.feedback-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    text-align: center;
    z-index: 10;
    width: 80%;
    border: 3px solid transparent;
}

.feedback-overlay.hidden {
    display: none;
}

.feedback-overlay.correct {
    border-color: var(--correct);
}
.feedback-overlay.wrong {
    border-color: var(--wrong);
}

.feedback-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.feedback-text {
    font-family: 'Caveat', cursive;
    font-size: 2rem;
    color: #1e293b;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.btn-next {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Outfit', sans-serif;
}

.btn-next:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}
.btn-next.hidden {
    display: none;
}


/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.footer-discreet {
    position: fixed;
    bottom: 5px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.25);
    pointer-events: none;
    z-index: 100;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

/* Mobile */
@media (max-width: 600px) {
    .notebook-container {
        padding: 1.5rem 0.5rem 2rem 2.5rem;
        background-size: 100% 100%, 100% 2.5rem;
        background-position: 0 0, 0 1.25rem;
        background-image: 
            linear-gradient(90deg, transparent 2rem, var(--paper-margin) 2rem, var(--paper-margin) 2.1rem, transparent 2.1rem),
            linear-gradient(var(--paper-line) 1px, transparent 1px);
    }
    
    .katex {
        font-size: 1.1rem !important;
    }
    .notebook-title {
        font-size: 1.5rem;
    }
    h1 {
        font-size: 2rem;
    }
    .btn-back {
        top: 10px;
        left: 10px;
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
}
