@import url('https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap');

:root {
    --background-color: #022F40;
    --text-color: #FEF5EF;
    --text-muted: #9DA1A5;
    --green: #57A773;
    --red: #F34213;
    --blue: #08B2E3;
    --gold: #E2B714;
}

@media (prefers-color-scheme: light) {
    :root {
        --background-color: #FEF5EF;
        --text-color: #022F40;
        --text-muted: #646669;
        --green: #57A773;
        --red: #F34213;
        --blue: #08B2E3;
        --gold: #E2B714;
    }
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    font-family: 'Space Mono', monospace;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 1.8rem;
    color: var(--blue);
}

.logo-text {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
}

.nav {
    display: flex;
    gap: 8px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.nav-btn:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-color);
    color: var(--background-color);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
}

/* Config Bar */
.config-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.config-group {
    display: flex;
    gap: 4px;
}

.config-separator {
    width: 2px;
    height: 24px;
    background: var(--text-muted);
    opacity: 0.3;
}

.config-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.config-btn:hover {
    color: var(--text-color);
}

.config-btn.active {
    color: var(--blue);
    background: rgba(8, 178, 227, 0.1);
}

/* Stats Display */
.stats-display {
    display: flex;
    justify-content: center;
    gap: 48px;
    margin-bottom: 20px;
}

.stats-display.hidden {
    display: none;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--blue);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.score-panel {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
    padding: 24px 32px;
    border-radius: 20px;
    margin-bottom: 30px;
}

.level-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 24px;
    background: linear-gradient(180deg, rgba(96, 165, 250, 0.15) 0%, rgba(96, 165, 250, 0.05) 100%);
    border-radius: 16px;
    border: 2px solid var(--blue);
    min-width: 100px;
    position: relative;
    overflow: hidden;
}

.level-display::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

.level-display:hover::before {
    left: 100%;
}

.level-label {
    font-size: 0.7rem;
    color: var(--blue);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 700;
}

.level-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--blue);
    line-height: 1;
    text-shadow: 0 0 20px var(--blue), 0 0 40px var(--blue);
}

/* Score display - main focus */
.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 32px;
    background: linear-gradient(180deg, rgba(251, 191, 36, 0.1) 0%, rgba(251, 191, 36, 0.02) 100%);
    border-radius: 16px;
    border: 2px solid var(--gold);
    min-width: 220px;
    position: relative;
}

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

.score-current {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--text-color);
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.score-current.pulse {
    transform: scale(1.15);
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold), 0 0 40px var(--gold);
}

.score-separator {
    font-size: 1.8rem;
    color: var(--text-muted);
    opacity: 0.5;
}

.score-target {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold);
}

.score-bar-container {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.score-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--green) 0%, var(--gold) 50%, var(--blue) 100%);
    border-radius: 4px;
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 10px var(--gold);
    position: relative;
}

.score-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.3), transparent);
    border-radius: 4px 4px 0 0;
}

/* Streak and Multiplier cards */
.streak-mult-container {
    display: flex;
    gap: 16px;
}

.streak-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 20px;
    background: linear-gradient(180deg, rgba(74, 222, 128, 0.15) 0%, rgba(74, 222, 128, 0.05) 100%);
    border-radius: 16px;
    border: 2px solid var(--green);
    min-width: 90px;
    transition: all 0.2s ease;
}

.mult-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 20px;
    background: linear-gradient(180deg, rgba(255, 107, 107, 0.15) 0%, rgba(255, 107, 107, 0.05) 100%);
    border-radius: 16px;
    border: 2px solid var(--red);
    min-width: 90px;
    transition: all 0.2s ease;
}

.streak-label,
.mult-label {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 700;
}

.streak-label {
    color: var(--green);
}

.mult-label {
    color: var(--red);
}

.streak-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--green);
    line-height: 1;
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-shadow: 0 0 15px var(--green);
}

.streak-value.bump {
    transform: scale(1.3);
    text-shadow: 0 0 25px var(--green), 0 0 50px var(--green);
}

.streak-display.bump {
    transform: scale(1.05);
    box-shadow:
        0 6px 30px var(--green),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.mult-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--red);
    line-height: 1;
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-shadow: 0 0 15px var(--red);
}

.mult-value.bump {
    transform: scale(1.3);
    text-shadow: 0 0 25px var(--red), 0 0 50px var(--red);
}

.mult-display.bump {
    transform: scale(1.05);
    box-shadow:
        0 6px 30px var(--red),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Level up animation */
@keyframes levelUp {
    0% { transform: scale(1); filter: brightness(1); }
    25% { transform: scale(1.2); filter: brightness(1.5); }
    50% { transform: scale(1.4); filter: brightness(2); }
    75% { transform: scale(1.2); filter: brightness(1.5); }
    100% { transform: scale(1); filter: brightness(1); }
}

@keyframes levelUpGlow {
    0% { box-shadow: 0 4px 20px var(--blue); }
    50% { box-shadow: 0 4px 60px var(--gold), 0 0 100px var(--gold); }
    100% { box-shadow: 0 4px 20px var(--blue); }
}

.level-value.level-up {
    animation: levelUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--gold);
    text-shadow: 0 0 30px var(--gold), 0 0 60px var(--gold);
}

.level-display.level-up {
    animation: levelUpGlow 0.6s ease;
}

/* Shake animation for streak reset */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.streak-display.reset {
    animation: shake 0.3s ease;
    border-color: var(--text-muted);
}

.mult-display.reset {
    animation: shake 0.3s ease;
    border-color: var(--text-muted);
}

/* Typing Area */
.typing-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Disabled for the moment
#rarity-icon {
    position: absolute;
    left: 0;
    top: 0;
    transform: translateY(50%);
    width: 40px;
    height: 40px;
    color: var(--gold);
}*/

#words-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    min-height: 200px;
    margin: 0 auto;
}

#words-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: transparent;
    caret-color: var(--gold);
    font-family: 'Space Mono', monospace;
    font-size: 1.5rem;
    line-height: 2.5rem;
    padding: 40px;
    resize: none;
    overflow: hidden;
    z-index: 10;
    cursor: default;
}

#words-input::selection {
    background: transparent;
}

#words-checked,
#words {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    line-height: 2.5rem;
    font-size: 1.5rem;
    user-select: none;
    pointer-events: none;
    padding: 40px;
}

#words-checked {
    color: transparent;
    z-index: 2;
}

#words {
    color: var(--text-muted);
    z-index: 1;
}

.letter {
    display: inline-block;
    position: relative;
    font-size: 1.5rem;
    transition: color 0.05s ease;
}
.letter.space {
    width: 0.95rem;
}

.letter.correct {
    color: var(--text-color);
}

.letter.incorrect {
    color: var(--red);
    background-color: var(--background-color);
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

.letter.current::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 100%;
    background-color: var(--gold);
    animation: blink 1s ease-in-out infinite;
}

.word.current .letter:last-child.typed::after {
    content: '';
    position: absolute;
    right: -2px;
    top: 0;
    width: 2px;
    height: 100%;
    background-color: var(--gold);
    animation: blink 1s ease-in-out infinite;
}

.letter.extra {
    color: var(--red);
    opacity: 0.7;
}

#words-container:focus-within #words {
    filter: none;
}

#words-container:not(:focus-within) #words, #words-container:not(:focus-within) #words-checked {
    filter: blur(4px);
    transition: filter 0.2s ease;
}

#words-container:not(:focus-within)::after {
    content: 'Cliquez pour commencer';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-color);
    font-size: 1.2rem;
    z-index: 20;
    pointer-events: none;
}

/* Restart Button */
.restart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: 30px 0;
}

.restart-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.restart-btn:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.05);
}

.restart-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* Results */
.results {
    padding: 40px;
    text-align: center;
}

.results.hidden {
    display: none;
}

.results-main {
    display: flex;
    justify-content: center;
    gap: 80px;
    margin-bottom: 40px;
}

.result-big {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--blue);
    line-height: 1;
}

.result-label {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.results-details {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.result-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.detail-value {
    font-size: 1rem;
    color: var(--text-color);
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--blue);
    color: var(--background-color);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.action-btn.secondary {
    background: transparent;
    color: var(--text-muted);
    border: 2px solid var(--text-muted);
}

.action-btn.secondary:hover {
    color: var(--text-color);
    border-color: var(--text-color);
}

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: auto;
}

.footer-left {
    display: flex;
    gap: 20px;
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--text-color);
}

.footer-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.game-over-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    padding: 48px 64px;
    border-radius: 16px;
}

.game-over-label {
    font-size: 1.1rem;
    color: var(--background-color);
    background-color: var(--red);
    opacity: 0.9;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.leaderboard-container {
    position: fixed;
    top: 75px;
    left: 20px;
    z-index: 100;
}

.leaderboard-panel {
    padding: 16px 20px;
    border-radius: 12px;
    min-width: 200px;
    max-width: 280px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
}

.leaderboard-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s ease;
}

.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-item:first-child .leaderboard-rank {
    color: var(--gold);
}

.leaderboard-item:nth-child(2) .leaderboard-rank {
    color: #c0c0c0;
}

.leaderboard-item:nth-child(3) .leaderboard-rank {
    color: #cd7f32;
}

.leaderboard-rank {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 20px;
    text-align: center;
}

.leaderboard-name {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-score {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--blue);
}

.game-over-stats {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 65%;
    min-width: 280px;
}

.game-over-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.game-over-stat-row:last-child {
    border-bottom: none;
}

.game-over-stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.game-over-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-color);
}

.game-over-restart-btn {
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    color: var(--blue);
    background: rgba(8, 178, 227, 0.1);
}

.game-over-restart-btn:hover {
    color: var(--background-color);
    background-color: var(--blue);
}

.game-over-quote {
    font-style: italic;
    font-size: 0.95rem;
    color: var(--text-muted);
    text-align: center;
    padding: 12px 16px;
    margin: 8px 0;
    line-height: 1.5;
}

.game-over-name-input {
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
    width: 200px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.game-over-name-input:focus {
    border-color: var(--blue);
    background: rgba(255, 255, 255, 0.08);
}

.game-over-name-input::placeholder {
    color: var(--text-muted);
}

.game-over-submit-btn {
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--blue);
    background: rgba(8, 178, 227, 0.1);
}

.game-over-submit-btn:hover {
    color: var(--background-color);
    background-color: var(--blue);
}

.game-over-submit-btn:disabled {
    background: var(--green);
    cursor: default;
}

.game-over-name-input:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Responsive */
@media (max-width: 768px) {
    .leaderboard-container {
        position: relative;
        top: auto;
        left: auto;
        margin-bottom: 20px;
    }

    .leaderboard-panel {
        max-width: 100%;
        min-width: auto;
    }

    .container {
        padding: 0 20px;
    }

    .score-panel {
        flex-wrap: wrap;
        gap: 12px;
        padding: 16px;
    }

    .level-display {
        padding: 12px 16px;
        min-width: 80px;
    }

    .level-value {
        font-size: 2rem;
    }

    .score-display {
        order: -1;
        width: 100%;
        padding: 16px;
        min-width: auto;
    }

    .score-current {
        font-size: 2rem;
    }

    .score-target {
        font-size: 1.2rem;
    }

    .streak-mult-container {
        gap: 12px;
    }

    .streak-display,
    .mult-display {
        padding: 12px 16px;
        min-width: 75px;
    }

    .streak-value,
    .mult-value {
        font-size: 1.6rem;
    }

    .config-bar {
        padding: 12px 16px;
        gap: 12px;
    }

    .config-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .results-main {
        gap: 40px;
    }

    .result-value {
        font-size: 3rem;
    }

    #words-checked,
    #words {
        font-size: 1.2rem;
        line-height: 2rem;
    }

    #words-input {
        font-size: 1.2rem;
        line-height: 2rem;
    }

    .game-over-stats {
        min-width: auto;
        width: 100%;
    }
}
