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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 900px;
    padding: 20px;
}

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

h1 {
    font-size: 2.5rem;
    color: #00d9ff;
    text-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
    letter-spacing: 2px;
}

h2 {
    font-size: 2rem;
    color: #ff6b6b;
    margin-bottom: 20px;
}

.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

/* Start Screen */
#start-screen {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 40px;
    backdrop-filter: blur(10px);
}

.instructions {
    font-size: 1.2rem;
    margin-bottom: 25px;
    color: #b0b0b0;
}

.rules {
    list-style: none;
    margin-bottom: 30px;
    text-align: left;
    max-width: 350px;
    margin-left: auto;
    margin-right: auto;
}

.rules li {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1rem;
}

.rules li::before {
    content: "•";
    color: #00d9ff;
    margin-right: 10px;
}

.start-prompt {
    font-size: 1.3rem;
    color: #00d9ff;
    animation: pulse 2s infinite;
}

kbd {
    background: #00d9ff;
    color: #1a1a2e;
    padding: 5px 15px;
    border-radius: 5px;
    font-weight: bold;
    font-family: inherit;
}

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

/* Settings Bar */
.settings-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.setting {
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting label {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.setting select {
    background: rgba(0, 0, 0, 0.4);
    color: #00d9ff;
    border: 1px solid rgba(0, 217, 255, 0.3);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s ease;
}

.setting select:focus {
    border-color: #00d9ff;
    box-shadow: 0 0 8px rgba(0, 217, 255, 0.2);
}

.setting select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Game Screen */
#game-screen {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 30px;
    backdrop-filter: blur(10px);
}

.stats-bar {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat {
    text-align: center;
    min-width: 100px;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #00d9ff;
}

#accuracy-display.warning {
    color: #ffd93d;
}

#accuracy-display.danger {
    color: #ff6b6b;
}

.typing-area {
    margin-bottom: 25px;
    position: relative;
}

.word-display {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 20px;
    font-size: 1.4rem;
    line-height: 2;
    min-height: 150px;
    max-height: 200px;
    overflow: hidden;
    word-wrap: break-word;
}

.word-display .word {
    display: inline;
    margin-right: 0.5em;
    padding: 2px 0;
    transition: all 0.1s ease;
}

.word-display .word.current {
    padding: 2px 0;
    margin-right: 0.5em;
}

.char {
    display: inline;
}

.char-correct {
    color: #4ade80;
}

.char-wrong {
    color: #ff6b6b;
    text-decoration: underline wavy #ff6b6b;
}

.char-pending {
    color: #888;
}

.char-extra {
    color: #ff6b6b;
    text-decoration: underline wavy #ff6b6b;
}

.cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background-color: #00d9ff;
    vertical-align: text-bottom;
    margin: 0 1px;
    animation: blink 0.75s step-end infinite;
}

.ghost-cursor-overlay {
    position: absolute;
    width: 2px;
    background-color: rgba(255, 160, 0, 0.7);
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 4px rgba(255, 160, 0, 0.5);
    animation: blink 1s step-end infinite;
}

.waiting-indicator {
    display: block;
    margin-top: 20px;
    text-align: center;
    color: #ffd93d;
    font-size: 1rem;
    animation: pulse 1s infinite;
}

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

.word-display .word.correct {
    color: #4ade80;
}

.word-display .word.incorrect {
    color: #ff6b6b;
    text-decoration: line-through;
}

.word-display .word.pending {
    color: #888;
}

.word-display .word.behind {
    color: #ff6b6b;
    opacity: 0.5;
}

.typing-input {
    width: 100%;
    padding: 15px 20px;
    font-size: 1.3rem;
    border: 2px solid rgba(0, 217, 255, 0.3);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    outline: none;
    transition: border-color 0.3s ease;
}

.typing-input:focus {
    border-color: #00d9ff;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.3);
}

.typing-input.error {
    border-color: #ff6b6b;
    animation: shake 0.3s ease;
}

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

.progress-bar-container {
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.period-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4ade80, #00d9ff);
    border-radius: 4px;
    transition: width 0.1s linear;
}

.period-label {
    text-align: center;
    font-size: 0.85rem;
    color: #666;
    margin-top: 8px;
}

.idle-prompt {
    text-align: center;
    font-size: 1rem;
    color: #00d9ff;
    margin-top: 6px;
    animation: pulse 2s infinite;
}

/* Game Over Screen */
#gameover-screen {
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 40px;
    backdrop-filter: blur(10px);
}

.final-stats {
    margin: 30px 0;
    text-align: left;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.final-stats p {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 1.1rem;
}

.final-stats p span:last-child {
    color: #00d9ff;
    font-weight: bold;
}

.final-stats .highlight {
    font-size: 1.3rem;
    color: #4ade80;
}

.final-stats .highlight span:last-child {
    color: #4ade80;
}

.restart-button {
    background: linear-gradient(90deg, #00d9ff, #4ade80);
    color: #0b1220;
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.restart-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(74, 222, 128, 0.2);
}

.restart-button:active {
    transform: translateY(0);
}

.gameover-buttons {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

.copy-score-button {
    background: rgba(255, 255, 255, 0.08);
    color: #00d9ff;
    border: 1px solid rgba(0, 217, 255, 0.35);
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

.copy-score-button:hover {
    background: rgba(0, 217, 255, 0.12);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(0, 217, 255, 0.15);
}

.copy-score-button:active {
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 600px) {
    h1 {
        font-size: 1.8rem;
    }

    .stats-bar {
        gap: 10px;
    }

    .stat {
        min-width: 80px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .word-display {
        font-size: 1.1rem;
        padding: 15px;
    }

    .typing-input {
        font-size: 1.1rem;
        padding: 12px 15px;
    }
}
