/* Speed Typer - Terminal Typing Test */

/* Override body centering */
main[data-page="games"] {
    width: 100%;
    max-width: none;
    align-self: stretch;
}

/* Main container */
.typing-container {
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
}

/* ============ MENU SCREEN ============ */
.menu-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.4s ease;
    width: 100%;
    max-width: 500px;
    min-height: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.typing-header {
    margin-bottom: 30px;
}

.typing-title {
    font-size: 10px;
    line-height: 1.2;
    color: var(--border-accent);
    margin: 0 0 15px 0;
    white-space: pre;
}

.header-sub {
    font-size: 14px;
    color: var(--text-secondary);
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 300px;
}

.menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: max-content;
    white-space: nowrap;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    padding: 14px 24px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    letter-spacing: 1px;
}

.menu-btn:hover {
    border-color: var(--border-accent);
    background-color: var(--bg-color);
    box-shadow: 0 0 15px rgba(50, 107, 120, 0.3);
}

.menu-btn.primary {
    border-color: var(--border-accent);
    background-color: var(--border-accent);
    color: var(--bg-color);
}

.menu-btn.primary:hover {
    background-color: transparent;
    color: var(--text-primary);
}

/* Info Panel */
.menu-info {
    margin-bottom: 30px;
    width: 100%;
}

.info-panel {
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    padding: 15px;
    text-align: left;
}

.info-title {
    font-size: 11px;
    color: var(--border-accent);
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.info-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.info-text p {
    margin: 5px 0;
}

/* High Scores */
.high-scores {
    width: 100%;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    padding: 15px;
}

.scores-title {
    font-size: 11px;
    color: var(--border-accent);
    letter-spacing: 1px;
    margin-bottom: 12px;
    text-align: center;
}

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

.score-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 5px 0;
    border-bottom: 1px dashed var(--border-color);
}

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

.score-row .rank {
    color: var(--border-accent);
    min-width: 25px;
}

.score-row .name {
    flex: 1;
    color: var(--text-primary);
    margin-left: 10px;
}

.score-row .score {
    color: var(--text-secondary);
    min-width: 70px;
    text-align: right;
}

.score-row.loading {
    justify-content: center;
    color: var(--text-secondary);
}

.score-row.you {
    background-color: rgba(50, 107, 120, 0.2);
    margin: 0 -10px;
    padding: 5px 10px;
}

/* ============ GAME SCREEN ============ */
.game-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    animation: fadeIn 0.3s ease;
    min-height: 0;
}

.game-header {
    display: flex;
    justify-content: space-around;
    gap: 15px;
    margin-bottom: 30px;
    padding: 15px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 60px;
}

.stat-box .stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.stat-box .stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* Typing Area */
.typing-area {
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-accent);
    padding: 30px;
    margin-bottom: 20px;
}

.text-display {
    font-size: 20px;
    line-height: 2;
    margin-bottom: 25px;
    min-height: 120px;
    word-wrap: break-word;
}

.word {
    display: inline-block;
    margin-right: 12px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.word.current {
    color: var(--text-primary);
    position: relative;
}

.word.current::before {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--border-accent);
}

.char {
    transition: color 0.1s ease;
}

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

.char.error {
    color: #E74C3C;
    text-decoration: underline;
}

.char.extra {
    color: #E74C3C;
    opacity: 0.7;
}

/* Input */
.input-wrapper {
    display: flex;
    align-items: center;
    background-color: var(--bg-color);
    border: 2px solid var(--border-color);
    padding: 12px 15px;
}

.prompt {
    color: var(--border-accent);
    font-size: 18px;
    margin-right: 10px;
}

.typing-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    font-family: inherit;
    outline: none;
    caret-color: var(--text-primary);
}

.typing-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.cursor {
    width: 2px;
    height: 20px;
    background-color: var(--text-primary);
    animation: blink 1s step-end infinite;
    margin-left: 2px;
}

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

/* Progress Bar */
.game-footer {
    margin-top: auto;
}

.progress-bar {
    height: 8px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 100%;
    background-color: var(--border-accent);
    transition: width 1s linear;
}

.progress-fill.warning {
    background-color: #f39c12;
}

.progress-fill.critical {
    background-color: #e74c3c;
    animation: pulse 0.5s infinite;
}

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

/* ============ RESULT SCREEN ============ */
.result-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: fadeIn 0.5s ease;
    width: 100%;
    max-width: 400px;
    min-height: 0;
}

.result-header {
    margin-bottom: 30px;
}

.result-wpm {
    font-size: 72px;
    font-weight: bold;
    color: var(--text-primary);
    line-height: 1;
    animation: wpmPop 0.5s ease;
}

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

.result-wpm-label {
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 2px;
    margin-top: 10px;
}

.result-stats {
    width: 100%;
    margin-bottom: 25px;
}

.result-stats .stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.result-stats .stat-label {
    color: var(--text-secondary);
}

.result-stats .stat-value {
    color: var(--text-primary);
    font-weight: bold;
}

.result-stats .stat-row.highlight {
    animation: pulse 1s infinite;
}

.result-stats .stat-row.highlight .stat-label,
.result-stats .stat-row.highlight .stat-value {
    color: var(--border-accent);
}

/* Grade */
.result-grade {
    margin-bottom: 30px;
    animation: gradeSlide 0.5s ease 0.3s backwards;
}

@keyframes gradeSlide {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.grade-letter {
    font-size: 48px;
    font-weight: bold;
    line-height: 1;
}

.grade-text {
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 2px;
    margin-top: 5px;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 250px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
    .typing-container {
        padding: 15px 10px;
    }

    .typing-title {
        font-size: 7px;
    }

    .game-header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 10px;
    }

    .stat-box {
        min-width: 50px;
    }

    .stat-box .stat-value {
        font-size: 20px;
    }

    .typing-area {
        padding: 20px 15px;
    }

    .text-display {
        font-size: 16px;
        line-height: 1.8;
    }

    .typing-input {
        font-size: 16px;
    }

    .result-wpm {
        font-size: 56px;
    }

    .grade-letter {
        font-size: 36px;
    }
}

/* Focus state */
.typing-input:focus + .cursor {
    animation: blink 0.5s step-end infinite;
}

/* Hide default cursor when input focused */
.input-wrapper:focus-within .cursor {
    display: none;
}
