@font-face {
    font-family: 'Inter-Alia';
    src: url('fonts/InterAlia-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Inter-Alia';
    src: url('fonts/InterAlia-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: 'Inter-Alia';
    src: url('fonts/InterAlia-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Ormin';
    src: url('fonts/Ormin-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

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

body {
    font-family: 'Inter-Alia', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

p {
    margin-bottom: 1em;
}

h3 {
    color: #333;
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    font-size: 1.2em;
    font-weight: 600;
}

details {
    margin-bottom: 0.75em;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.5em;
}

summary {
    font-weight: 600;
    color: #667eea;
    cursor: pointer;
    padding: 0.5em;
    border-radius: 4px;
    transition: background-color 0.2s;
    user-select: none;
}

summary:hover {
    background-color: #f0f0ff;
}

summary::marker {
    color: #667eea;
}

details[open] summary {
    margin-bottom: 0.5em;
}

details > ul {
    margin-left: 2em;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

ul {
    margin-left: 1.5em;
    margin-bottom: 0.5em;
}

li {
    margin-bottom: 0.25em;
    line-height: 1.5;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    max-width: 600px;
    width: 100%;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.back-btn {
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #667eea;
    transition: color 0.3s;
    min-width: 40px;
}

.back-btn:hover {
    color: #5568d3;
}

.back-btn.hidden {
    visibility: hidden;
}

h1 {
    text-align: center;
    color: #333;
    margin: 0;
    font-size: 36px;
    font-weight: bold;
    font-family: 'Ormin', 'Inter-Alia', sans-serif;
    flex: 1;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 18px;
    font-weight: normal;
}

.home-screen {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 50px;
}

.home-screen.hidden {
    display: none;
}

.countdown-screen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    padding: 40px;
    margin-top: 50px;
}

.countdown-screen.hidden {
    display: none !important;
}

.countdown-screen:not(.hidden) {
    display: flex;
}

.home-btn {
    padding: 20px;
    font-size: 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.home-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.game-content {
    display: block;
}

.game-content.hidden {
    display: none;
}

.word-display {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    min-height: 100px;
    position: relative;
    overflow: hidden;
}

.word-carousel {
    position: relative;
    height: 60px;
    overflow: hidden;
}

.word-slot {
    position: absolute;
    top: 50%;
    font-size: 48px;
    font-family: 'Inter-Alia', sans-serif;
    letter-spacing: 4px;
    white-space: nowrap;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Position classes for the carousel - transform will be set dynamically */
.word-slot.pos-prev-prev {
    opacity: 0;
}

.word-slot.pos-prev {
    opacity: 0.2;
}

.word-slot.pos-current {
    opacity: 1;
}

.word-slot.pos-next {
    opacity: 0.3;
}

.word-slot.pos-next-next {
    opacity: 0;
}

.word-display .word {
    font-size: 48px;
    font-family: Inter-Alia', sans-serif;
    letter-spacing: 4px;
}

.word-display .char {
    display: inline-block;
    transition: all 0.2s ease;
    white-space: pre; /* Preserve spaces */
}

.word-display .char.correct {
    opacity: 0.4;
    color: #28a745;
}

.word-display .char.incorrect {
    color: #dc3545;
    font-weight: bold;
}

.input-container {
    margin-bottom: 20px;
}

#typingInput {
    width: 100%;
    padding: 15px;
    font-size: 32px;
    font-family: 'Inter-Alia', sans-serif;
    border: 3px solid #e0e0e0;
    border-radius: 10px;
    text-align: center;
    letter-spacing: 4px;
    transition: border-color 0.3s;
}

#typingInput:focus {
    outline: none;
    border-color: #667eea;
}

.stats {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.stat {
    text-align: center;
}

.stat-label {
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

.stat-value {
    color: #333;
    font-size: 24px;
    font-weight: bold;
}

.countdown-text {
    font-size: 72px;
    font-weight: bold;
    color: #667eea;
    animation: countdown-pulse 0.5s ease-in-out;
}

@keyframes countdown-pulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes error-flash {
    0% {
        background-color: #e74c3c;
    }
    100% {
        background-color: white;
    }
}

.completion-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.completion-modal.show {
    display: flex;
}

.completion-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    animation: slideIn 0.3s ease;
}

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

.completion-content h2 {
    color: #667eea;
    font-size: 36px;
    margin-bottom: 20px;
}

.completion-content .final-score {
    font-size: 48px;
    font-weight: bold;
    color: #333;
    margin: 20px 0;
}

.completion-content .stat-row {
    margin: 10px 0;
    font-size: 18px;
    color: #666;
}

.level-stats-container {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.level-stat {
    padding: 5px 0;
    font-size: 14px;
    color: #555;
    border-bottom: 1px solid #e0e0e0;
}

.level-stat:last-child {
    border-bottom: none;
}

.completion-content button {
    margin-top: 30px;
    padding: 15px 40px;
    font-size: 18px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s;
}

.completion-content button:hover {
    background: #5568d3;
}

.mode-btn {
    padding: 10px 30px;
    font-size: 16px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    margin: 0 10px;
    transition: all 0.3s;
}

.mode-btn:hover {
    background: #f0f0ff;
}

.mode-btn.active {
    background: #667eea;
    color: white;
}

.settings-btn {
    padding: 10px 20px;
    font-size: 16px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    margin-left: 15px;
    transition: all 0.3s;
}

.settings-btn:hover {
    background: #f0f0ff;
}

.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.settings-modal.show {
    display: flex;
}

.settings-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

.settings-content h2 {
    color: #667eea;
    font-size: 28px;
    margin-bottom: 25px;
}

.settings-option {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.settings-option:last-child {
    border-bottom: none;
}

.settings-option label {
    display: flex;
    align-items: center;
    font-size: 16px;
    color: #333;
    cursor: pointer;
}

.settings-option input[type="checkbox"] {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.settings-option-desc {
    font-size: 13px;
    color: #666;
    margin-top: 8px;
    margin-left: 32px;
}

.settings-close-btn {
    margin-top: 25px;
    padding: 12px 30px;
    font-size: 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.settings-close-btn:hover {
    background: #5568d3;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 32px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #333;
}

.completion-content,
.settings-content {
    position: relative;
}

#lengthSelect {
    padding: 8px 15px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
}

.burger-menu {
    position: relative;
    display: inline-block;
    min-width: 40px;
}

.burger-btn {
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: #667eea;
    transition: color 0.3s;
}

.burger-btn:hover {
    color: #5568d3;
}

.burger-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    min-width: 160px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    border-radius: 8px;
    z-index: 2000;
    overflow: hidden;
}

.burger-dropdown.show {
    display: block;
}

.burger-dropdown a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    transition: background 0.3s;
}

.burger-dropdown a:hover {
    background: #f0f0ff;
}

.copyright {
    text-align: center;
    color: #000000;
    font-size: 14px;
    margin-top: 20px;
    padding: 10px;
}

.lesson-option {
    padding: 15px;
    margin: 10px 0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.lesson-option:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.lesson-option strong {
    color: #333;
    font-size: 16px;
}

/* Mobile-friendly compact layout */
@media (max-width: 768px) {
    body {
        justify-content: flex-start;
        padding-top: 40px;
    }

    h1 {
        font-size: 32px;
        margin-bottom: 10px;
    }

    .subtitle {
        font-size: 16px;
        margin-bottom: 20px;
    }

    .word-display {
        padding: 20px;
        margin-bottom: 20px;
        min-height: 60px;
    }

    .word-display .word {
        font-size: 36px;
        letter-spacing: 2px;
    }

    #typingInput {
        padding: 12px;
        font-size: 24px;
    }

    .input-container {
        margin-bottom: 15px;
    }

    .stats {
        gap: 15px;
        margin-bottom: 15px;
    }

    .countdown-text {
        font-size: 48px;
    }
}

/* Center keyboard images */
img[src*="keyboard_images/"] {
    display: block;
    margin: 10px auto;
}

/* Keyboard documentation styles */
.key-style {
    background-color: #e8e8e8;
    padding: 0px 0px;
    border-radius: 3px;
    font-family: 'Inter-Alia', monospace;
    border: 1px solid #ccc;
    white-space: nowrap;
}

.modal-content ul {
    background-color: #f5f5f5;
    padding: 12px 20px 12px 40px;
    border-left: 3px solid #555fdc;
    margin: 10px 0;
    border-radius: 4px;
}

.modal-content ul li {
    margin: 6px 0;
    color: #444;
}
