@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Nunito:wght@400;500;600;700&display=swap');

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

@keyframes moveGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes fadeSlideUp {
    0% { opacity: 0; transform: translateY(25px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(0.95) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes pulseUnderline {
    0% { opacity: 0.3; width: 80%; left: 10%; }
    50% { opacity: 1; width: 100%; left: 0%; }
    100% { opacity: 0.3; width: 80%; left: 10%; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

body {
    background: linear-gradient(-45deg, #e8f4f8, #ffffff, #dcedf6, #f0f7fa);
    background-size: 400% 400%;
    animation: moveGradient 15s ease infinite;
    background-attachment: fixed;
    color: #4a5568;
    font-family: 'Inter', sans-serif;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.container, .landing-container {
    width: 100%;
    max-width: 900px;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.hero { text-align: center; margin-bottom: 60px; }
.hero h1 { font-size: 38px; font-weight: 300; color: #2d3748; line-height: 1.3; margin-bottom: 15px; }
.hero p { font-size: 16px; color: #718096; max-width: 600px; margin: 0 auto; line-height: 1.6; }

.modes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    width: 100%;
}

.mode-card {
    background: rgba(255, 255, 255, 0.6);
    padding: 25px;
    border-radius: 8px;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.mode-icon { font-size: 32px; margin-bottom: 15px; opacity: 0.8; }
.mode-card h3 { font-size: 18px; font-weight: 600; color: #2d3748; margin-bottom: 8px; }
.mode-card p { font-size: 14px; color: #718096; line-height: 1.5; }

.mode-card.active { cursor: pointer; background: #ffffff; box-shadow: 0 10px 30px rgba(0,0,0,0.03); border: 1px solid #e2e8f0; }
.mode-card.active:hover { transform: translateY(-5px); box-shadow: 0 15px 40px rgba(0,0,0,0.06); border-color: #cbd5e0; }
.mode-card.disabled { opacity: 0.5; cursor: not-allowed; }

.hidden { display: none !important; }
.mt-30 { margin-top: 30px; }
.mt-15 { margin-top: 15px; }

.key-hint {
    background: #edf2f7;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #cbd5e0;
    color: #4a5568;
    font-family: inherit;
    box-shadow: 0 2px 0 #cbd5e0;
    font-size: 12px;
}

.spinner {
    width: 50px; height: 50px;
    border: 4px solid #e2e8f0; border-top-color: #805ad5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

.race-track-container {
    width: 100%; margin-bottom: 40px; padding: 15px 25px;
    background: #ffffff; border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05); box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}
.track-info { display: flex; justify-content: space-between; font-size: 14px; color: #718096; margin-bottom: 8px; }
.track-line { width: 100%; height: 2px; border-bottom: 2px dashed #cbd5e0; position: relative; margin-bottom: 10px; }
.track-avatar {
    width: 24px; height: 24px; border-radius: 50%;
    position: absolute; top: -11px; left: 0%;
    transition: left 0.1s linear; border: 4px solid #fff; box-sizing: content-box;
}
.player-avatar { background-color: #805ad5; box-shadow: 0 0 12px rgba(128,90,213,0.5); z-index: 2; }
.opponent-avatar { background-color: #a0aec0; box-shadow: 0 0 12px rgba(160,174,192,0.5); z-index: 1; }

.game-header { width: 100%; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 15px; margin-bottom: 30px; }
.stats { display: flex; gap: 30px; font-size: 14px; color: #718096; text-transform: lowercase; letter-spacing: 0.5px; justify-content: flex-start; }
.stats span { font-weight: 600; color: #2d3748; }

.word-display {
    width: 100%; font-family: 'Nunito', sans-serif; font-weight: 500; font-size: 30px; line-height: 1.7;
    color: #4a5568; height: 105px; overflow: hidden; position: relative; scroll-behavior: smooth; user-select: none; margin-bottom: 40px; text-align: left;
}
.word { margin-right: 12px; display: inline-block; transition: color 0.2s ease-in-out; position: relative; }
.word span { border-radius: 2px; }
.word.current { color: #2d3748; }
.word.current::after { content: ''; position: absolute; bottom: 2px; left: 0; height: 2px; background-color: #a0aec0; border-radius: 2px; animation: pulseUnderline 1.5s infinite ease-in-out; }
.word span.correct { color: #a0aec0; }
.word span.wrong { color: #e53e3e; background-color: rgba(229, 62, 62, 0.1); }
.word.extra-wrong { text-decoration: underline wavy #e53e3e; text-decoration-thickness: 1px; }

.typing-input {
    width: 100%; max-width: 500px; padding: 15px 20px; font-size: 18px; font-family: 'Inter', sans-serif;
    border: 1px solid #cbd5e0; border-radius: 6px; background: #fff; outline: none; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); margin-bottom: 30px; color: #2d3748; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
.typing-input:focus { border-color: #a0aec0; box-shadow: 0 0 0 4px rgba(160, 174, 192, 0.15); transform: translateY(-2px); }

.action-buttons { display: flex; gap: 15px; margin-bottom: 40px; }
.btn { padding: 10px 24px; font-size: 14px; font-family: 'Inter', sans-serif; font-weight: 500; background: rgba(255,255,255,0.6); color: #718096; border: 1px solid #cbd5e0; border-radius: 20px; cursor: pointer; transition: all 0.3s ease; }
.btn:hover { background: #ffffff; color: #2d3748; border-color: #a0aec0; box-shadow: 0 4px 10px rgba(0,0,0,0.03); }

.modal { width: 100%; background: transparent; margin-top: 20px; animation: popIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.modal h2 { font-size: 24px; font-weight: 300; margin-bottom: 30px; color: #2d3748; }

.match-result-banner { padding: 15px; border-radius: 8px; font-size: 22px; font-weight: 600; margin-bottom: 30px; text-transform: uppercase; letter-spacing: 2px; }
.match-result-banner.win { background-color: rgba(72, 187, 120, 0.15); color: #38a169; border: 1px solid #9ae6b4; }
.match-result-banner.lose { background-color: rgba(229, 62, 62, 0.1); color: #e53e3e; border: 1px solid #feb2b2; }

.main-stats { display: flex; justify-content: center; gap: 60px; margin-bottom: 40px; }
.stat-label { font-size: 12px; color: #a0aec0; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.stat-big { font-size: 56px; color: #805ad5; font-weight: 300; font-family: 'Nunito', sans-serif; }

.chart-container { width: 100%; background: #ffffff; border: 1px solid rgba(0,0,0,0.05); border-radius: 12px; padding: 30px 40px; margin-bottom: 30px; text-align: left; box-shadow: 0 4px 20px rgba(0,0,0,0.02); }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 60px; }
.chart-header h3 { font-size: 20px; font-weight: 500; color: #4a5568; margin: 0; }
#percentile-text { font-size: 15px; color: #718096; }
#percentile-text strong { color: #0056ff; }
.chart-wrapper { position: relative; height: 180px; margin-bottom: 10px; display: flex; align-items: flex-end; }
.chart-bars { display: flex; justify-content: space-between; align-items: flex-end; width: 100%; height: 100%; gap: 6px; position: relative; z-index: 2; }
.chart-bottom-line { position: absolute; bottom: 0; left: -5px; right: -5px; height: 2px; background-color: #0056ff; z-index: 1; }
.chart-bar-group { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; justify-content: flex-end; position: relative; }
.chart-bar { width: 100%; background-color: #7fb2ff; border-radius: 4px 4px 0 0; transition: height 0.9s cubic-bezier(0.2, 0.8, 0.2, 1); position: relative; }
.chart-bar-group.active .chart-bar { background-color: #0056ff; }
.chart-bar-group.active .chart-bar::before { content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); height: 40px; border-left: 2px dashed #0056ff; }
.chart-bar-group.active .chart-bar::after { content: 'Ty'; position: absolute; bottom: calc(100% + 45px); left: 50%; transform: translateX(-50%); color: #0056ff; font-weight: 600; font-size: 13px; }
.bar-label { font-size: 10px; color: #0056ff; margin-top: 8px; text-align: center; white-space: nowrap; }
.chart-footer { text-align: center; font-size: 12px; color: #7fb2ff; margin-top: 15px; }

.detailed-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; background: rgba(255, 255, 255, 0.5); padding: 25px; border-radius: 8px; margin-bottom: 30px; font-size: 14px; color: #4a5568; }
.stat-col { display: flex; flex-direction: column; gap: 12px; }
.stat-row { display: flex; justify-content: space-between; border-bottom: 1px solid rgba(0,0,0,0.03); padding-bottom: 4px; }
.stat-row span:last-child { font-weight: 600; color: #2d3748; }

.leaderboard { width: 100%; margin-top: 60px; }
.leaderboard h2 { font-size: 18px; font-weight: 400; color: #718096; margin-bottom: 20px; text-align: left; }
table { width: 100%; border-collapse: collapse; font-size: 14px; background: rgba(255,255,255,0.4); border-radius: 8px; overflow: hidden; }
th, td { padding: 15px 10px; text-align: left; border-bottom: 1px solid rgba(0,0,0,0.05); }
th { color: #a0aec0; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; font-size: 12px; }
td { color: #4a5568; }