@import url('../styles.css');

.mobile-score {
    display: none;
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 1002;
    background: rgba(36,36,36,0.85);
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0.7rem 1.2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-weight: bold;
}
.responsive-layout {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 2.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    box-sizing: border-box;
}
.game-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}
.info-side {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 280px;
    max-width: 400px;
    background: rgba(36,36,36,0.85);
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    padding: 2rem;
}
.info-side h1 {
    font-size: 2.2rem;
    margin-bottom: 1rem;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.info-side p { font-size: 1.1rem; margin-bottom: 1.5rem; color: var(--text-muted); }
.buttons-panel { display: flex; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }
@media (max-width: 900px) {
    .responsive-layout { flex-direction: column; align-items: center; gap: 1.5rem; padding: 1rem 0.5rem; }
    .info-side { max-width: 100vw; width: 100%; margin-top: 0; align-items: center; text-align: center; }
    .info-side h1 { font-size: 1.7rem; }
    .game-side { width: 100%; justify-content: center; }
}
body { background: var(--grad-bg); color: #fff; min-height: 100vh; margin: 0; }

/* ===================== TYPING PANEL ===================== */
.typing-panel {
    background: rgba(36,36,36,0.9);
    border-radius: 16px;
    padding: 2rem;
    width: 520px;
    max-width: 95vw;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

/* ===================== TIME SELECTOR ===================== */
.time-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.time-btn {
    padding: 0.4rem 1.1rem;
    border: 2px solid #555;
    background: #2a2a2a;
    color: #aaa;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    touch-action: manipulation;
}
.time-btn.active {
    border-color: #8fd3f4;
    color: #8fd3f4;
    background: rgba(143,211,244,0.12);
}
.time-btn:hover { border-color: #8fd3f4; color: #8fd3f4; }

/* ===================== TIMER BAR ===================== */
.timer-bar-wrap {
    height: 10px;
    background: #333;
    border-radius: 5px;
    overflow: hidden;
}
.timer-bar {
    height: 100%;
    background: var(--grad-primary);
    border-radius: 5px;
    transition: width 1s linear, background 0.5s;
}
.timer-bar.danger  { background: linear-gradient(90deg, #d50000, #ff6f00); }
.timer-bar.warning { background: linear-gradient(90deg, #f9a825, #ff6f00); }

/* ===================== STATS ROW ===================== */
.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: bold;
}

/* WPM prominent display */
.wpm-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}
.wpm-number {
    font-size: 3rem;
    font-weight: 900;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: transform 0.15s;
    display: inline-block;
}
.wpm-number.bump {
    animation: wpmBump 0.2s ease-out forwards;
}
.wpm-label {
    font-size: 0.75rem;
    color: #888;
    letter-spacing: 2px;
    text-transform: uppercase;
}

@keyframes wpmBump {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ===================== STREAK BADGE ===================== */
.streak-badge {
    display: none;
    align-items: center;
    gap: 4px;
    background: rgba(255,81,47,0.18);
    border: 1.5px solid #ff512f;
    border-radius: 20px;
    padding: 0.3rem 0.9rem;
    font-size: 0.95rem;
    font-weight: bold;
    color: #ff8c5f;
    animation: streakPop 0.3s ease-out;
}
.streak-badge.visible { display: flex; }
@keyframes streakPop {
    0%   { transform: scale(0.7); opacity: 0; }
    70%  { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* ===================== TARGET WORD ===================== */
.target-word-wrap {
    position: relative;
    min-height: 5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

@keyframes wordFadeOut {
    0%   { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-18px); }
}
@keyframes wordFadeIn {
    0%   { opacity: 0; transform: translateY(18px); }
    100% { opacity: 1; transform: translateY(0); }
}

.target-word {
    font-size: 3.5rem;
    font-weight: bold;
    text-align: center;
    letter-spacing: 4px;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
    width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
    transition: font-size 0.1s, letter-spacing 0.1s;
}
.target-word.fade-out {
    animation: wordFadeOut 0.1s ease-in forwards;
}
.target-word.fade-in {
    animation: wordFadeIn 0.15s ease-out forwards;
}

/* ===================== WORD INPUT ===================== */
.word-input {
    font-size: 1.8rem;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    border: 2px solid #555;
    background: #1a1a1a;
    color: #fff;
    outline: none;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    font-family: inherit;
}
.word-input:focus { border-color: #8fd3f4; }
.word-input.correct {
    border-color: #538d4e;
    background: rgba(83,141,78,0.1);
    box-shadow: 0 0 12px rgba(0,200,83,0.35);
}
.word-input.wrong {
    border-color: #ef5350;
    background: rgba(239,83,80,0.1);
    box-shadow: 0 0 12px rgba(213,0,0,0.35);
}

/* ===================== UPCOMING WORDS QUEUE ===================== */
.upcoming-words {
    display: flex;
    gap: 8px;
    min-height: 2.2em;
    align-items: center;
    overflow: hidden;
    padding: 4px 0;
}
.upcoming-word {
    font-size: 1rem;
    padding: 3px 10px;
    background: #2a2a2a;
    border-radius: 6px;
    border: 1px solid #3a3a3a;
    white-space: nowrap;
    transition: opacity 0.2s, transform 0.2s;
}
.upcoming-word:nth-child(1) { opacity: 0.75; color: #ccc; }
.upcoming-word:nth-child(2) { opacity: 0.5;  color: #999; }
.upcoming-word:nth-child(3) { opacity: 0.3;  color: #777; }
.upcoming-word:nth-child(4) { opacity: 0.15; color: #666; }

/* Word-correct check flash */
@keyframes checkFloat {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-40px) scale(1.3); }
}
.check-flash {
    position: absolute;
    font-size: 1.4rem;
    color: #00c853;
    font-weight: bold;
    pointer-events: none;
    animation: checkFloat 0.6s ease-out forwards;
    z-index: 100;
}

/* ===================== RESULT SCREEN ===================== */
@keyframes resultSlideIn {
    0%   { transform: translateY(40px) scale(0.95); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}
.popup-content.animated {
    animation: resultSlideIn 0.35s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.5rem;
    margin: 1.2rem 0;
    text-align: left;
}
.result-item {
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 0.7rem 1rem;
}
.result-item .r-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.result-item .r-value {
    font-size: 1.6rem;
    font-weight: 900;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}
.result-streak {
    font-size: 1rem;
    color: #ff8c5f;
    margin-top: 0.2rem;
}

/* ===================== BUTTONS ===================== */
#startBtn, #restartBtn {
    background: var(--grad-primary); color: #222; border: none; border-radius: 8px;
    padding: 0.9rem 2rem; font-size: 1.1rem; font-weight: bold; cursor: pointer;
    margin: 0 0.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: background 0.2s, transform 0.2s;
}
#startBtn:hover, #restartBtn:hover { opacity: 0.9; transform: scale(1.05); }
#playAgainBtn {
    background: #8fd3f4; color: #222; border: none; border-radius: 8px;
    padding: 1rem 2.2rem; font-size: 1.2rem; font-weight: bold; cursor: pointer;
    transition: background 0.2s; margin-top: 1rem;
}
#playAgainBtn:hover { background: #5ec2e6; }
.popup {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(24,24,24,0.95); display: flex; align-items: center;
    justify-content: center; z-index: 1000;
}
.popup-content {
    background: #242424; padding: 2.5rem 3rem; border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4); text-align: center;
    min-width: 300px; max-width: 92vw;
}
.popup-content h2 { margin-top: 0; color: #8fd3f4; font-size: 2rem; }
.popup-content p { font-size: 1.4rem; margin: 1rem 0; }

.score-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 1rem;
    color: var(--text-muted);
    width: 100%;
}

@media (max-width: 540px) {
    .typing-panel { padding: 1rem; gap: 0.8rem; }
    .wpm-number { font-size: 2.2rem; }
    .target-word { font-size: 2.5rem; }
    .word-input { font-size: 1.4rem; }
    .result-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
    .popup-content { padding: 1.5rem 1.2rem; }
}
