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

body {
    background: #000;
    color: #c4cdd6;
    font-family: system-ui, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    line-height: 1.5;
}

.container {
    padding: 32px 18px;
    max-width: 700px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 18px;
}

h1 {
    font-size: 1.6rem;
    color: #d4353f;
    margin-bottom: 6px;
    font-weight: 700;
}

.subtitle {
    color: #6b7a8d;
    font-size: 0.9rem;
}

.modes {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 26px;
}

.mode-btn {
    padding: 9px 22px;
    border-radius: 4px;
    border: 1px solid #1a2332;
    background: #0a0a0a;
    color: #6b7a8d;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s;
}

.mode-btn:hover {
    border-color: #2e3d50;
}

.mode-btn.active {
    border-color: #d4353f;
    color: #d4353f;
    background: rgba(212, 53, 63, 0.05);
}

.game-area {
    text-align: center;
    margin-bottom: 34px;
}

.big-letter {
    font-size: 5rem;
    font-weight: 800;
    color: #dce3ec;
    margin: 28px 0;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "SF Mono", Monaco, "Curier New", monospace;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.big-letter.wrong {
    color: #e04242;
    animation: shake 0.4s;
}

.big-letter.finished {
    color: #d4353f;
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    20% {
        transform: translateX(-10px);
    }
    40% {
        transform: translateX(10px);
    }
    60% {
        transform: translateX(-6px);
    }
    80% {
        transform: translateX(6px);
    }
}

.progress {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 7px;
    margin: 30px 0 20px;
    min-height: 38px;
}

.letter {
    width: 26px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all 0.2s;
}

.letter.done {
    color: #d4353f;
    background: rgba(212, 53, 63, 0.1);
    border-radius: 3px;
    transform: scale(0.9);
}

.letter.current {
    color: #dce3ec;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
    transform: scale(1.15);
}

.letter.upcoming {
    color: #4a5868;
}

.timer {
    font-family: "SM Mono", Monaco, "Courier New", monospace;
    font-size: 2.2rem;
    font-weight: 700;
    color: #dce3ec;
    margin: 24px 0px;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.status {
    font-size: 1rem;
    color: #6b7a8d;
    margin: 14px 0;
    min-height: 24px;
}

.completion {
    display: none;
    margin: 26px 0;
    padding: 20px;
}

.completion.show {
    display: block;
}

.completion-title {
    font-size: 1.2rem;
    color: #d4353f;
    margin-bottom: 12px;
    font-weight: 700;
}

.completion .final-time {
    font-family: "SF Mono", Monaco, "Courier New", monospace;
    font-size: 2.6rem;
    font-weight: 800;
    color: #d4353f;
    margin: 14px 0;
}

.completion .record-badge {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(232, 179, 14, 0.08);
    border: 1px solid #e8b30e;
    border-radius: 3px;
    color: #e8b30e;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 10px;
}

.completion .perfect {
    color: #1aab7a;
    font-size: 0.95rem;
    margin-top: 8px;
    font-weight: 500;
}

.completion .mistakes-text {
    color: #e04242;
    font-size: 0.85rem;
    margin-top: 8px;
}

.restart-hint {
    color: #4a5868;
    font-size: 0.8rem;
    margin-top: 14px;
}

kbd {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    padding: 2px 5px;
    font-size: 0.75rem;
}

.leaderboard {
    margin-top: 44px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.leaderboard h3 {
    font-size: 0.85rem;
    color: #6b7a8d;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
}

#lbList {
    background: rgba(255, 255, 255, 0.015);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.lb-row:last-child {
    border-bottom: none;
}

.lb-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.lb-row.gold {
    background: rgba(232, 179, 14, 0.04);
}

.lb-rank {
    font-weight: 700;
    color: #4a5868;
    width: 30px;
    font-size: 0.85rem;
}

.lb-row.gold .lb-rank {
    color: #e8b30e;
}

.lb-time {
    font-weight: 600;
    color: #4ccdd6;
    flex: 1;
    font-size: 0.9rem;
}

.lb-row.gold .lb-time {
    color: #e8b30e;
}

.lb-mistakes {
    font-size: 0.75rem;
    color: #4a5868;
    font-weight: 500;
}

.no-scores {
    text-align: center;
    color: #4a5868;
    font-size: 0.85rem;
    padding: 30px 20px;
}

.leaderboard-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.export-btn,
.clear-btn {
    padding: 8px 15px;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition:
        border-color 0.15s,
        color 0.15s;
}

.export-btn {
    flex: 1;
    border: 1px solid rgba(26, 171, 122, 0.25);
    color: #1aab7a;
}

.export-btn:hover {
    border-color: rgba(26, 171, 122, 0.4);
    background: rgba(26, 171, 122, 0.05);
}

.clear-btn {
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #4a5868;
    font-size: 0.7rem;
}

.clear-btn:hover {
    color: #e04242;
    border-color: rgba(224, 66, 66, 0.3);
}

.confirm-text {
    font-size: 0.75rem;
    color: #6b7a8d;
    flex: 1;
    display: flex;
    align-items: center;
}

.confirm-yes {
    padding: 8px 14px;
    background: transparent;
    border: 1px solid rgba(212, 53, 63, 0.35);
    border-radius: 6px;
    color: #d4353f;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition:
        border-color 0.15s,
        background 0.15s;
}

.confirm-yes:hover {
    border-color: #d4353f;
    background: rgba(212, 53, 63, 0.08);
}

.confirm-no {
    padding: 8px 14px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    color: #4a5868;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition:
        border-color 0.15s,
        color 0.15s;
}

.confirm-no:hover {
    color: #c4cdd6;
    border-color: rgba(255, 255, 255, 0.15);
}

.game-info {
    margin-top: 35px;
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.stats span {
    font-size: 0.8rem;
    color: #6b7a8d;
    font-weight: 500;
}

.stats span span {
    color: #c4cdd6;
    font-weight: 600;
}

.controls-hint {
    font-size: 0.7rem;
    color: #4a5868;
    line-height: 1.4;
}

@media (max-width: 600px) {
    .container {
        padding: 25px 16px;
    }
    h1 {
        font-size: 1.4rem;
    }
    .big-letter {
        font-size: 4rem;
        margin: 25px 0;
    }
    .timer {
        font-size: 2rem;
        padding: 15px 20px;
    }
    .letter {
        width: 24px;
        height: 28px;
        font-size: 0.8rem;
    }
    .modes {
        gap: 8px;
    }
    .mode-btn {
        padding: 9px 20px;
        font-size: 0.85rem;
    }
}

@media (max-width: 400) {
    .letter {
        width: 22px;
        height: 26px;
        font-size: 0.75rem;
    }
    .progress {
        gap: 5px;
    }
    .big-letter {
        font-size: 3.5rem;
    }
    .timer {
        font-size: 1.8rem;
    }
}
