/* Typing Kids - Styles */
/* Mobile-first design */

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

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-game: #0f0f23;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --color-accent: #e94560;
    --color-success: #4ade80;
    --color-warning: #fbbf24;
    --color-word: #00d9ff;
    --color-danger: #ef4444;
    --color-heart: #ff6b6b;
    --transition-speed: 0.3s;
    --font-main: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.4;
}

/* Screen System */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
}

.screen.active {
    display: flex;
}

/* === MENU SCREEN === */
#screen-menu {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    padding: 20px;
}

.menu-content {
    text-align: center;
    width: 100%;
    max-width: 400px;
}

.title-container {
    margin-bottom: 40px;
}

.title-icon {
    font-size: 64px;
    display: block;
    margin-bottom: 16px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 4px;
    background: linear-gradient(90deg, var(--color-word), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Buttons */
.btn-primary, .btn-secondary {
    display: block;
    width: 100%;
    padding: 18px 32px;
    font-size: 1.25rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 56px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-accent) 0%, #d63384 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.4);
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 2px 10px rgba(233, 69, 96, 0.3);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--color-word);
    margin-top: 12px;
}

.btn-secondary:active {
    transform: scale(0.98);
    background: rgba(0, 217, 255, 0.1);
}

.btn-icon {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--color-word);
    border-radius: 12px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-icon:active {
    transform: scale(0.95);
}

/* Stats Display */
.stats-display {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-top: 40px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-word);
}

.tip {
    margin-top: 30px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* === GAME SCREEN === */
#screen-game {
    flex-direction: column;
    background: var(--bg-game);
}

/* Game Stats Bar */
.game-stats {
    padding: 12px 16px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.stat-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
    font-weight: 600;
}

.game-stat .stat-emoji {
    font-size: 1.25rem;
}

.game-stat.lives {
    font-size: 1.25rem;
    letter-spacing: 2px;
}

.stat-label-small {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Game Area */
#game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(180deg,
            transparent 0%,
            transparent 80%,
            rgba(239, 68, 68, 0.1) 100%
        );
}

#danger-zone {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg,
        transparent,
        var(--color-danger),
        transparent
    );
    animation: pulse-danger 1s ease-in-out infinite;
}

@keyframes pulse-danger {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Falling Words */
.falling-word {
    position: absolute;
    top: -40px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.2) 0%, rgba(0, 217, 255, 0.1) 100%);
    border: 2px solid var(--color-word);
    border-radius: 8px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-word);
    white-space: nowrap;
    animation: fall linear forwards;
    z-index: 5;
    text-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
}

@keyframes fall {
    0% {
        top: -40px;
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        top: calc(100% - 20px);
        opacity: 0.8;
    }
}

.falling-word.matched {
    animation: word-matched 0.3s ease-out forwards !important;
}

@keyframes word-matched {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.8;
        border-color: var(--color-success);
        color: var(--color-success);
        background: rgba(74, 222, 128, 0.3);
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.falling-word.missed {
    animation: word-missed 0.4s ease-out forwards !important;
}

@keyframes word-missed {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        border-color: var(--color-danger);
        color: var(--color-danger);
        background: rgba(239, 68, 68, 0.3);
    }
    100% {
        transform: scale(0) translateY(20px);
        opacity: 0;
    }
}

/* Input Area */
.input-area {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-top: 2px solid rgba(0, 217, 255, 0.2);
}

#word-input {
    flex: 1;
    padding: 16px 20px;
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--bg-game);
    border: 2px solid var(--color-word);
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
    min-height: 56px;
    font-family: var(--font-main);
}

#word-input:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 15px rgba(233, 69, 96, 0.3);
}

#word-input::placeholder {
    color: var(--text-secondary);
}

/* Level Up Notification */
.level-up {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, var(--color-warning), #f59e0b);
    color: var(--bg-primary);
    padding: 20px 40px;
    border-radius: 16px;
    font-size: 2rem;
    font-weight: 800;
    z-index: 100;
    animation: level-up-anim 1.5s ease-out forwards;
}

@keyframes level-up-anim {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    20% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
    }
    80% {
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
}

.hidden {
    display: none !important;
}

/* Pause Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.overlay-content {
    text-align: center;
    padding: 40px;
    background: var(--bg-secondary);
    border-radius: 20px;
    border: 2px solid var(--color-word);
    width: 90%;
    max-width: 320px;
}

.overlay-content h2 {
    font-size: 2rem;
    margin-bottom: 30px;
}

/* === GAME OVER SCREEN === */
#screen-gameover {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    padding: 20px;
}

.gameover-content {
    text-align: center;
    width: 100%;
    max-width: 400px;
}

#gameover-title {
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(90deg, var(--color-danger), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.new-record {
    font-size: 1.25rem;
    color: var(--color-warning);
    margin-bottom: 20px;
    animation: pulse-record 0.5s ease-in-out infinite alternate;
}

@keyframes pulse-record {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
}

.final-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.final-stat:first-child {
    grid-column: span 2;
}

.final-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.final-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-word);
}

.final-stat:first-child .final-value {
    font-size: 2.5rem;
    color: var(--color-warning);
}

.gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* === RESPONSIVE === */
@media (min-width: 480px) {
    h1 {
        font-size: 3rem;
    }

    .title-icon {
        font-size: 80px;
    }

    .falling-word {
        font-size: 1.5rem;
    }

    #word-input {
        font-size: 1.5rem;
    }

    .final-stats {
        grid-template-columns: repeat(3, 1fr);
    }

    .final-stat:first-child {
        grid-column: span 3;
    }
}

@media (min-width: 768px) {
    .game-stats {
        flex-direction: row;
        justify-content: space-between;
    }

    .stat-group {
        gap: 24px;
    }

    #game-area {
        max-width: 800px;
        margin: 0 auto;
        width: 100%;
    }

    .input-area {
        max-width: 800px;
        margin: 0 auto;
        width: 100%;
    }

    .gameover-buttons {
        flex-direction: row;
    }

    .gameover-buttons .btn-primary,
    .gameover-buttons .btn-secondary {
        flex: 1;
        margin-top: 0;
    }
}

/* Paused state */
body.paused .falling-word {
    animation-play-state: paused !important;
}

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

.shake {
    animation: shake 0.3s ease-in-out;
}
