@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --bg-color: #0a0a0c;
    --text-color: #f0f0f0;
    --accent-blue: #7ec8e3;
    --accent-orange: #ff9d47;
}

/* --- BASE --- */
body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(white, rgba(255,255,255,.2) 2px, transparent 40px),
        radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 30px);
    background-size: 550px 550px, 350px 350px;
    background-position: 0 0, 40px 60px;
    color: var(--text-color);
    font-family: 'Press Start 2P', cursive; 
    font-size: 12px; 
    line-height: 1.8;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden; 
}

/* Effet CRT */
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: 9999;
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
}

/* --- HEADER --- */
.pixel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 3px solid white;
}

.user-stats { display: flex; align-items: center; gap: 15px; }

.btn-settings {
    background: transparent; border: none; cursor: pointer;
    width: 30px; height: 30px; transition: transform 0.2s;
}
.btn-settings:hover { transform: rotate(90deg); }

.pixel-cog {
    position: relative; width: 14px; height: 14px; background: #808080; border: 3px solid black;
    box-shadow: 
        0 -6px 0 -2px #808080, 0 -6px 0 1px black,
        0 6px 0 -2px #808080, 0 6px 0 1px black,
        -6px 0 0 -2px #808080, -6px 0 0 1px black,
        6px 0 0 -2px #808080, 6px 0 0 1px black;
}
.pixel-cog::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); width: 4px; height: 4px; background: black;
}

/* --- TUTORIEL --- */
.tutorial-zone {
    display: flex; flex-direction: row; align-items: center; justify-content: center;
    margin-bottom: 30px; gap: 10px; width: 100%;
}
.step { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.step p { font-size: 7px; margin: 0; color: var(--accent-blue); text-transform: uppercase; white-space: nowrap; }
.step-arrow { font-size: 10px; color: rgba(255, 255, 255, 0.4); animation: bounceHorizontal 1.5s infinite; }

@keyframes bounceHorizontal { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(5px); } }

/* --- ZONE D'ÉCRITURE --- */
#writing-zone { display: flex; flex-direction: column; align-items: center; padding: 40px 20px; }

.paper-sheet {
    background: white; border: 4px solid black; outline: 4px solid white;
    box-shadow: 12px 12px 0px var(--accent-blue); padding: 30px;
    margin: 20px auto; width: 85%; max-width: 500px; color: black;
    display: flex; flex-direction: column; align-items: center;
    box-sizing: border-box;
    overflow-x: hidden;
}

.paper-sheet h2, .signature-zone { width: 100%; text-align: left; margin: 10px 0; }

.pixel-input, .pixel-textarea { font-family: 'Press Start 2P', cursive; outline: none; background: transparent; }
.pixel-input { font-size: 10px; border: none; border-bottom: 2px solid #ccc; width: 60%; }

.pixel-textarea {
    font-size: 12px; width: 100%; min-height: 150px; height: auto;
    border: 2px dashed #ccc; margin: 20px 0; padding: 10px;
    resize: vertical; box-sizing: border-box; overflow-y: hidden;
}

/* --- BOUTON ENVOYER --- */
.btn-pixel-send {
    background: var(--accent-orange); color: white; font-family: 'Press Start 2P', cursive;
    font-size: 10px; border: 4px solid black; padding: 15px 30px; cursor: pointer;
    box-shadow: 6px 6px 0px #5a3200;
}
.btn-pixel-send:active { box-shadow: 0px 0px 0px; transform: translate(6px, 6px); }

/* --- AVION ET ÉTOILE MARIO --- */
.paper-plane {
    position: fixed; bottom: -150px; left: 45%; width: 60px; height: 70px;
    background-color: white; clip-path: polygon(50% 0%, 100% 100%, 50% 80%, 0% 100%);
    border: 4px solid black; z-index: 1000; transition: all 3s;
}
.fly-away { bottom: 120%; left: 55%; opacity: 0; }

.mario-star {
    width: 30px; height: 30px; background: #FFD700; border: 2px solid black;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    position: relative;
}
.mario-star::before, .mario-star::after {
    content: ''; position: absolute; width: 3px; height: 6px; background: black; top: 40%;
}
.mario-star::before { left: 35%; }
.mario-star::after { right: 35%; }

/* --- MODALES (PARAMÈTRES / À PROPOS) --- */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.9); display: flex;
    justify-content: center; align-items: center; z-index: 10000;
}
.modal-content {
    background-color: #e0e0e0; border: 4px solid black; padding: 30px;
    width: 90%; max-width: 400px; color: black; text-align: center;
    box-shadow: 10px 10px 0px var(--accent-orange); position: relative;
}

@media (max-width: 600px) {
    .modal-content {
        padding: 20px;
        box-sizing: border-box;
        max-height: 90vh;
        overflow-y: auto;
    }
}
.close-btn { position: absolute; top: 10px; right: 10px; cursor: pointer; font-size: 20px; }

/* KOFI*/
.vinyl-container {
    margin: 40px auto; /* "auto" sur les côtés aide au centrage global */
    text-align: center;
    width: 100%;
}

.vinyl-icon {
    font-size: 16px;
    display: block; /* Pour être bien au-dessus du lien */
    margin: 0 auto 10px auto;
}

.kofi-support-link {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    line-height: 2;
    color: #4a90e2;
    text-decoration: none;
    border-bottom: 2px dotted #4a90e2;
    transition: all 0.3s ease;
    display: inline-block; /* Garde-le ainsi pour que le text-align: center fonctionne */
    padding: 5px;
    margin: 0 auto; /* Sécurité supplémentaire */
}

.kofi-support-link:hover {
    color: #ff7e5f;
    border-bottom: 2px solid #ff7e5f;
    transform: scale(1.05);
}

/* Disclaimer & Tooltips */
.disclaimer { font-size: 8px; line-height: 1.6; text-align: justify; margin: 15px 0; color: #333; }
.tooltip-trigger { color: #4a90e2; text-decoration: underline dotted; cursor: help; position: relative; display: inline-block; }
.tooltip-box {
    visibility: hidden; width: 280px; background-color: #333; color: #fff; text-align: left;
    padding: 15px; border: 2px solid white; position: absolute; z-index: 100; bottom: 125%;
    left: 50%; transform: translateX(-50%); opacity: 0; transition: opacity 0.3s; font-size: 8px;
}

@media (max-width: 600px) {
    .tooltip-box {
        width: 200px;
        left: 0;
        transform: none;
    }
}
.tooltip-trigger:hover .tooltip-box { visibility: visible; opacity: 1; }

/* Boutons Modale */
.btn-pixel-small, .btn-pixel-danger {
    font-family: 'Press Start 2P', cursive; font-size: 8px; padding: 12px;
    border: 3px solid black; cursor: pointer; margin: 5px;
}
.btn-pixel-small { background-color: white; color: black; box-shadow: 4px 4px 0px #888; }
.btn-pixel-danger { background-color: #ff4747; color: white; box-shadow: 4px 4px 0px #a00; }
.btn-pixel-small:active, .btn-pixel-danger:active { box-shadow: 0px 0px 0px; transform: translate(4px, 4px); }

/* --- FENÊTRE RÉINITIALISATION ROUGE --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.8); display: flex; justify-content: center; align-items: center; z-index: 999999;
}
.modal-box {
    background: white; border: 4px solid #ff4b2b; width: 320px;
    font-family: 'Press Start 2P', cursive; box-shadow: 10px 10px 0px rgba(0,0,0,0.5);
}
.modal-header { background: #ff4b2b; color: white; padding: 10px; font-size: 10px; text-align: center; }
.modal-body { padding: 20px; font-size: 8px; line-height: 1.6; color: #333; text-align: center; }
.modal-footer { padding: 15px; display: flex; justify-content: space-around; border-top: 2px dashed #eee; }

/* --- BOUTONS DE LA MODALE --- */
.modal-footer button {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    padding: 10px 15px;
    cursor: pointer;
    border: 3px solid;
    background: white;
    transition: all 0.1s steps(2);
    box-shadow: 4px 4px 0px rgba(0,0,0,0.2);
}

/* Bouton ANNULER (Gris/Noir) */
.btn-cancel {
    border-color: #333;
    color: #333;
}

.btn-cancel:hover {
    background: #eee;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px rgba(0,0,0,0.2);
}

/* Bouton RÉINITIALISER (Rouge) */
.btn-confirm {
    border-color: #ff4b2b;
    color: #ff4b2b;
}

.btn-confirm:hover {
    background: #ff4b2b;
    color: white;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px rgba(255, 75, 43, 0.3);
}

/* Effet au clic (pour les deux) */
.modal-footer button:active {
    transform: translate(2px, 2px);
    box-shadow: 0px 0px 0px;
}

/* --- ÉTOILE VOLANTE --- */
.flying-star {
    position: fixed; top: 50%; left: 50%; width: 20px; height: 20px; background: #FFD700;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    z-index: 5000; pointer-events: none; animation: starToCounter 1.5s ease-in forwards;
}
@keyframes starToCounter {
    0% { transform: translate(-50%, -50%) scale(0) rotate(0deg); opacity: 0; }
    20% { transform: translate(-50%, -50%) scale(2) rotate(180deg); opacity: 1; }
    100% { transform: translate(calc(40vw), calc(-45vh)) scale(0.5) rotate(720deg); opacity: 0; }
}

/* --- FOOTER --- */
.pixel-footer {
    text-align: center; padding: 60px 20px; margin-top: 40px;
    font-size: 7px; color: rgba(255, 255, 255, 0.4);
}

/* Empêche le pied de page de remonter brusquement */
#writing-zone {
    min-height: 600px; /* Ajuste cette valeur selon la taille de ton papier */
}

.pixel-footer {
    position: relative;
    margin-top: auto; /* Pousse le footer vers le bas */
    padding-bottom: 40px;
}

/* =========================================
   AMBIANCES
   ========================================= */

/* JOUR */
body.day-mode {
    --bg-color: #87CEEB !important;
    background-image: radial-gradient(white, rgba(255,255,255,0.8) 10px, transparent 40px) !important;
}
body.day-mode .site-title, body.day-mode #note-count, body.day-mode .pixel-footer { color: #2c3e50 !important; }
body.day-mode .paper-sheet { box-shadow: 12px 12px 0px #ff9d47 !important; }
body.day-mode .step p { color: #2c3e50 !important; }

/* AUBE (DÉGRADÉ) */
body.aube-mode {
    background-image: linear-gradient(180deg, #a18cd1 0%, #fbc2eb 50%, #ff9a9e 100%) !important;
    background-size: cover !important;
    background-attachment: fixed;
}
body.aube-mode .paper-sheet { box-shadow: 12px 12px 0px #a18cd1 !important; }
body.aube-mode .step p, body.aube-mode .pixel-footer { color: #8e44ad !important; }

/* CRÉPUSCULE */
body.sunset-mode {
    --bg-color: #ff7e5f; 
    background-image: linear-gradient(#2c3e50 0%, #6a11cb 40%, #ff7e5f 80%, #feb47b 100%) !important;
    background-size: cover !important;
    background-attachment: fixed;
}
body.sunset-mode .paper-sheet { box-shadow: 12px 12px 0px #b04b32 !important; }
body.sunset-mode .step p, body.sunset-mode .pixel-footer { color: #fee140 !important; }

/* --- MENU AMBIANCE BOUTONS --- */
.theme-switch .btn-pixel {
    font-family: 'Press Start 2P', cursive; font-size: 8px; padding: 12px;
    border: 3px solid black; cursor: pointer; background: white; margin: 5px;
}

@media (max-width: 600px) {
    .theme-switch .btn-pixel {
        font-size: 7px; padding: 8px 6px; margin: 3px;
    }
}
.theme-switch .btn-pixel.active { color: white !important; transform: translate(4px, 4px); box-shadow: none !important; }
.theme-switch .btn-pixel.active.aube { background-color: #ff9a9e !important; }
.theme-switch .btn-pixel.active.jour { background-color: #4facfe !important; }
.theme-switch .btn-pixel.active.crepuscule { background-color: #fa709a !important; }
.theme-switch .btn-pixel.active.nuit { background-color: #30336b !important; }

.hidden { display: none !important; }

/* Animation de scintillement des étoiles */
@keyframes twinkle {
    0% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.8; transform: scale(1); }
}

/* On applique l'effet uniquement en mode Nuit pour ne pas gêner la lecture le jour */
body:not(.day-mode):not(.aube-mode):not(.sunset-mode) {
    animation: starsPulse 4s infinite ease-in-out;
}

@keyframes starsPulse {
    0%, 100% { background-size: 550px 550px, 350px 350px; }
    50% { background-size: 560px 560px, 360px 360px; }
}

/* --- BOUTON LANGUE ARCADE --- */
.btn-pixel-lang {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    padding: 8px 12px;
    cursor: pointer;
    background: #fff;
    color: #000;
    border: 3px solid #000;
    box-shadow: 4px 4px 0px var(--accent-blue);
    transition: all 0.1s steps(2);
}

.btn-pixel-lang {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    padding: 8px 12px;
    cursor: pointer;
    background: #fff;
    color: #000;
    border: 3px solid #000;
    box-shadow: 4px 4px 0px var(--accent-blue);
    transition: all 0.1s steps(2);
}

.btn-pixel-lang:hover {
    background: var(--accent-orange);
    color: #fff;
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px #000;
}

.btn-pixel-lang:active {
    transform: translate(2px, 2px);
    box-shadow: 0px 0px 0px;
}
@media (max-width: 600px) {
    .paper-sheet {
        box-shadow: 6px 6px 0px var(--accent-blue);
        width: 80%;
    }
}

.language-picker {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
}