/* Design Tokens & CSS Reset */
:root {
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: rgba(79, 70, 229, 0.1);
    
    --color-success: #10b981;
    --color-success-bg: #ecfdf5;
    --color-success-border: #a7f3d0;
    --color-success-text: #065f46;
    
    --color-error: #ef4444;
    --color-error-bg: #fef2f2;
    --color-error-border: #fca5a5;
    --color-error-text: #991b1b;
    
    --color-bg-app: #f8fafc;
    --color-bg-card: #ffffff;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
}

@font-face {
    font-family: 'lcddot_trregular';
    src: url('../font/lcddot-webfont.eot');
    src: url('../font/lcddot-webfont.eot?#iefix') format('embedded-opentype'),
        url('../font/lcddot-webfont.woff2') format('woff2'),
        url('../font/lcddot-webfont.woff') format('woff'),
        url('../font/lcddot-webfont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

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

html, body {
    height: 100%;
    background-color: var(--color-bg-app);
    font-family: var(--font-sans);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    user-select: none;
}

/* App Layout */
.app-container {
    min-height: 100%;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Button & Config Headers */
.controls-header {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    animation: fadeInDown 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.bouton {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 10px 20px;
    height: auto;
    min-height: 44px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.bouton:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background-color: var(--color-primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.bouton:active {
    transform: translateY(0);
}

/* Main Card */
.card {
    width: 100%;
    background-color: var(--color-bg-card);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 24px;
    padding: 28px;
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

/* Score Panel & Progress Bar */
.score-panel {
    width: 100%;
    margin-bottom: 8px;
}

.progress-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #f1f5f9;
    border-radius: 9999px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #4f46e5);
    border-radius: 9999px;
    width: 0%;
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-align: right;
    letter-spacing: 0.5px;
}

/* Calculator Screen Display */
.display-container {
    width: 100%;
    display: flex;
    justify-content: center;
}

#nombre {
    background-image: url('calculatrice.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    font-family: 'lcddot_trregular', var(--font-mono);
    color: #1e251c; /* Sharp retro dark LCD ink */
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.4);
    font-size: 38px;
    width: 341px;
    height: 160px;
    box-sizing: border-box;
    padding: 72px 45px 0 0; /* Diminué de 85px à 72px pour décaler vers le haut */
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    letter-spacing: 2px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

@media (min-width: 600px) {
    #nombre {
        width: 440px;
        height: 200px;
        font-size: 46px;
        padding: 95px 68px 0 0; /* Diminué de 110px à 95px pour décaler vers le haut sur grand écran */
    }
}

/* Consigne Text */
.consigne-text {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.5;
    color: var(--color-text);
    text-align: center;
    margin: 8px 0;
}

/* Canvas Area */
.canvas-wrapper {
    width: 100%;
    max-width: 600px;
    margin: 8px auto;
    overflow-x: auto;
    border-radius: 16px;
    background-color: #fafafa;
    border: 1px dashed var(--color-border);
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}

#droite {
    display: block;
    width: 100%;
    max-width: 512px;
    height: auto;
    aspect-ratio: 512 / 150;
    /* Drawing pixel ratio is set dynamically in JS */
}

/* Explication Area */
.explication-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--color-text-muted);
    min-height: 58px;
    padding: 12px 16px;
    border-radius: 12px;
    background-color: var(--color-bg-app);
    border: 1px solid var(--color-border);
    text-align: center;
    margin: 4px 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}

.explication-text b {
    color: var(--color-primary);
    font-weight: 600;
}

/* Answer Section */
.answer-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

#reponse {
    font-family: var(--font-mono);
    font-size: 2.2rem;
    font-weight: 500;
    text-align: center;
    width: 100%;
    max-width: 320px;
    height: 60px;
    padding: 8px 16px;
    border: 2px solid var(--color-border);
    border-radius: 16px;
    background-color: var(--color-bg-app);
    color: var(--color-text);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

#reponse:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
    background-color: var(--color-bg-card);
}

#reponse::placeholder {
    font-family: var(--font-sans);
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--color-text-muted);
}

/* Footer Msg */
.footer-msg {
    margin-top: 24px;
    text-align: center;
}

.footer-msg span {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    letter-spacing: 0.2px;
}

/* Custom Notifications Overlay */
#notification-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#notification-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

#notification-box {
    background-color: var(--color-bg-card);
    border-radius: 24px;
    padding: 36px 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.8);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#notification-overlay.visible #notification-box {
    transform: scale(1) translateY(0);
}

#notification-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    line-height: 1;
}

#notification-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

#notification-message {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

.bouton-next {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1rem;
    color: #ffffff;
    background-color: var(--color-primary);
    border: none;
    border-radius: 14px;
    width: 100%;
    padding: 12px 24px;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2), 0 2px 4px -2px rgba(79, 70, 229, 0.2);
    transition: all 0.2s ease;
}

.bouton-next:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.3), 0 3px 6px -2px rgba(79, 70, 229, 0.3);
}

.bouton-next:active {
    transform: translateY(0);
}

/* Success State for Notification */
.notif-success #notification-box {
    border-top: 6px solid var(--color-success);
}

.notif-success #notification-title {
    color: var(--color-success-text);
}

/* Error State for Notification */
.notif-error #notification-box {
    border-top: 6px solid var(--color-error);
}

.notif-error #notification-title {
    color: var(--color-error-text);
}

/* Helper Class to Hide Elements (removes completely from layout) */
.hidden {
    display: none !important;
}

/* Helper Class to Hide Elements Visually while keeping Layout Flow & Dimensions constant */
.invisible-layout {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

