/* ============================================
   FOURIER GUESS GAME - STYLE PROPRE
   ============================================ */

:root {
    --green: #58CC89;
    --white: #FFFFFF;
    --text-white: rgba(255, 255, 255, 0.95);
    --text-muted: rgba(255, 255, 255, 0.7);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--green);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

body.mobile-input-active {
    overflow: hidden;
}

/* Ajustement si workspace header présent */
body:has(.workspace-header) {
    padding-top: 0; /* Le workspace header est en fixed, pas besoin de padding */
}

body:has(.workspace-header) .game-header {
    margin-top: 65px; /* Espace pour le workspace header fixe */
}

/* HEADER */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.logo-big {
    font-family: 'Pacifico', cursive;
    font-size: 1.6rem;
    color: var(--white);
}

.logo-small {
    font-family: 'Pacifico', cursive;
    font-size: 1rem;
    color: var(--text-muted);
}

.btn-back {
    padding: 8px 16px;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    color: var(--white);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* STATS */
.stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 16px 20px;
    flex-shrink: 0;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--white);
}

/* GUESS SECTION */
.guess-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    flex-shrink: 0;
}

.guess-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-white);
    white-space: nowrap;
}

.btn-accelerate {
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    color: var(--white);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-accelerate:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: var(--white);
}

.btn-decelerate {
    background: rgba(0, 0, 0, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

.btn-decelerate:hover {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

/* LETTER BOXES */
.letter-boxes {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-shrink: 0;
}

.letter-boxes-mobile {
    display: none;
}

.guess-section-mobile {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.letter-box {
    width: 60px;
    height: 70px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    color: var(--white);
    transition: all 0.2s;
}

.letter-box.active {
    border-color: var(--white);
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.letter-box.correct {
    background: rgba(80, 200, 120, 0.3);
    border-color: #50C878;
    animation: bounce 0.4s;
}

.letter-box.wrong {
    background: rgba(255, 107, 107, 0.3);
    border-color: #FF6B6B;
    animation: shake 0.4s;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

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

/* STATUS MESSAGE */
.status-message {
    text-align: center;
    padding: 8px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 30px;
    flex-shrink: 0;
}

/* CANVAS */
.canvas-area {
    flex: 1;
    position: relative;
    background: var(--white);
    overflow: hidden;
    margin: 0 20px;
    border-radius: 16px;
}

#canvas-container {
    width: 100%;
    height: 100%;
}

.canvas-overlay-bottom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.skip-link {
    color: rgba(0, 0, 0, 0.5);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: underline;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.skip-link:hover {
    color: rgba(0, 0, 0, 0.8);
    text-decoration-thickness: 2px;
}

/* MOBILE STATS & INPUT (hidden on desktop) */
.mobile-stats-section {
    display: none;
}

.mobile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.mobile-stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mobile-stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--white);
}

.mobile-input-section {
    display: none;
    padding: 0 16px 16px;
}

.mobile-guess-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    color: #333;
    transition: all 0.2s;
}

.mobile-guess-input:focus {
    outline: none;
    border-color: var(--white);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.mobile-guess-input::placeholder {
    color: rgba(0, 0, 0, 0.3);
    font-weight: 500;
}

.mobile-guess-input.correct {
    background: rgba(80, 200, 120, 0.3);
    border-color: #50C878;
    animation: bounce 0.4s;
}

.mobile-guess-input.wrong {
    background: rgba(255, 107, 107, 0.3);
    border-color: #FF6B6B;
    animation: shake 0.4s;
}

.mobile-guess-input.partial-wrong {
    background: rgba(255, 200, 107, 0.3);
    border-color: #FFC86B;
}

/* MOBILE CONTROLS OVERLAY */
.mobile-controls-overlay {
    display: none;
}

.mobile-control-btn {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-control-btn:active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.5);
}

.mobile-speed-indicator {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 32px;
    text-align: center;
}

.mobile-divider {
    color: rgba(255, 255, 255, 0.3);
    font-size: 1.2rem;
    margin: 0 8px;
}

.mobile-skip-btn {
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-skip-btn:active {
    transform: scale(0.95);
    background: rgba(0, 0, 0, 0.5);
}

/* FOOTER */
.footer {
    display: flex;
    justify-content: center;
    padding: 16px 20px;
    flex-shrink: 0;
}

.btn-skip {
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
}

.btn-skip:hover {
    color: var(--white);
}

/* TIMER BAR */
.timer-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: rgba(0, 0, 0, 0.1);
    overflow: hidden;
    z-index: 10;
    border-radius: 16px 16px 0 0;
}

#timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ECDC4, #58A6FF);
    width: 100%;
    transition: width 0.1s linear;
}

/* INPUT INVISIBLE */
.mobile-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   RESPONSIVE MOBILE
   ============================================ */

@media (max-width: 768px) {
    /* Header plus compact */
    .game-header {
        padding: 10px 16px;
    }

    .logo-big {
        font-size: 1.3rem;
    }

    .logo-small {
        font-size: 0.85rem;
    }

    .btn-back {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* Stats desktop cachées sur mobile */
    .stats {
        display: none;
    }

    /* Mobile stats visible */
    .mobile-stats-section {
        display: flex;
        justify-content: center;
        gap: 32px;
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
        flex-shrink: 0;
    }

    /* Mobile input visible */
    .mobile-input-section {
        display: block;
    }

    /* Desktop guess section cachée */
    .guess-section {
        display: none;
    }

    .letter-boxes-desktop {
        display: none;
    }

    /* Canvas avec moins de marge */
    .canvas-area {
        margin: 0 12px;
        border-radius: 12px;
    }

    /* Hide desktop skip link */
    .canvas-overlay-bottom {
        display: none;
    }

    /* Show mobile controls */
    .mobile-controls-overlay {
        display: flex;
        align-items: center;
        gap: 12px;
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 10;
        background: rgba(0, 0, 0, 0.2);
        padding: 8px 16px;
        border-radius: 24px;
        backdrop-filter: blur(10px);
    }

    /* Footer avec safe area */
    .footer {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .timer-bar {
        height: 5px;
    }

    body.mobile-input-active .game-header,
    body.mobile-input-active .mobile-stats-section,
    body.mobile-input-active .mobile-controls-overlay,
    body.mobile-input-active .canvas-overlay-bottom {
        display: none;
    }

    body.mobile-input-active .canvas-area {
        margin: 0;
        border-radius: 0;
    }

    body.mobile-input-active .mobile-input-section {
        padding: 8px 16px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,0.35));
    }

    body.mobile-input-active #status-message {
        display: none;
    }
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
}

.modal-message {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 24px;
    white-space: pre-line;
}

.btn-primary {
    padding: 14px 40px;
    background: var(--green);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #4AB876;
    transform: scale(1.05);
}

/* ============================================
   CONFETTI ANIMATION
   ============================================ */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    z-index: 9999;
    animation: confetti-fall linear forwards;
    pointer-events: none;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}
