/* ===== ZType Space Typing Game - Complete Styles ===== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

:root {
    --space-bg: #050a18;
    --space-surface: rgba(10, 20, 50, 0.85);
    --space-border: rgba(100, 180, 255, 0.15);
    --neon-cyan: #00e5ff;
    --neon-magenta: #ff00e5;
    --neon-blue: #4488ff;
    --neon-green: #00ff88;
    --neon-yellow: #ffd700;
    --neon-red: #ff4455;
    --neon-orange: #ff8800;
    --text-primary: #e8f0ff;
    --text-dim: rgba(200, 220, 255, 0.5);
    --kb-key-bg: rgba(20, 40, 80, 0.8);
    --kb-key-text: #c8dcff;
    --kb-key-hover: rgba(0, 229, 255, 0.25);
    --kb-key-active: rgba(0, 229, 255, 0.5);
    --kb-height: 210px;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    background: var(--space-bg);
    color: var(--text-primary);
}

/* ===== Layout ===== */
.ztype-container {
    position: relative;
    width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* ===== HUD ===== */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: env(safe-area-inset-top, 12px) 15px 8px;
    background: linear-gradient(180deg, rgba(5, 10, 24, 0.9) 0%, transparent 100%);
    transition: opacity 0.3s ease;
}

.hud.hidden {
    opacity: 0;
    pointer-events: none;
}

.hud-left {
    justify-self: start;
}

.hud-right {
    justify-self: end;
    font-size: 20px;
    letter-spacing: 2px;
}

.hud-center {
    justify-self: center;
    display: flex;
    align-items: center;
    gap: 20px;
}

.hud-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.hud-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--neon-cyan);
    text-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}

.combo-stat .hud-value {
    color: var(--neon-yellow);
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
}

.combo-mult {
    font-size: 11px;
    font-weight: 700;
    color: var(--neon-yellow);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.hud-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--space-border);
    border-radius: 50%;
    background: var(--space-surface);
    color: var(--text-primary);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.hud-btn:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
}

/* ===== Word Target Display ===== */
.word-target {
    position: absolute;
    bottom: calc(var(--kb-height) + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    display: flex;
    gap: 3px;
    padding: 8px 16px;
    background: rgba(5, 10, 30, 0.9);
    border: 1px solid var(--space-border);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    min-height: 42px;
    align-items: center;
    transition: opacity 0.2s ease;
}

.word-target.hidden {
    opacity: 0;
    pointer-events: none;
}

.word-target .letter {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dim);
    transition: color 0.15s ease, text-shadow 0.15s ease;
}

.word-target .letter.typed {
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.6);
}

.word-target .letter.current {
    color: var(--neon-cyan);
    text-shadow: 0 0 12px rgba(0, 229, 255, 0.7);
    animation: pulse-letter 0.8s ease-in-out infinite;
}

@keyframes pulse-letter {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===== Overlays ===== */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 10, 24, 0.7);
    backdrop-filter: blur(6px);
    transition: opacity 0.4s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-panel {
    position: relative;
    width: 85%;
    max-width: 380px;
    padding: 45px 28px 36px;
    background: rgba(10, 20, 55, 0.9);
    border: 1px solid var(--space-border);
    border-radius: 24px;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: 0 0 60px rgba(0, 100, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.menu-back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--space-border);
    border-radius: 50%;
    background: var(--space-surface);
    color: var(--text-primary);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
    z-index: 10;
}

.menu-back-btn:hover {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
}

.game-title {
    font-size: 32px;
    font-weight: 900;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
    text-shadow: none;
}

.game-subtitle {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 28px;
    letter-spacing: 0.5px;
}

.gameover-title {
    font-size: 28px;
    font-weight: 900;
    color: var(--neon-red);
    text-shadow: 0 0 20px rgba(255, 68, 85, 0.4);
    margin-bottom: 24px;
}

.action-btn {
    display: block;
    width: 100%;
    padding: 14px 24px;
    margin: 8px 0;
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-blue));
    color: #fff;
    box-shadow: 0 4px 20px rgba(0, 229, 255, 0.3);
    transition: all 0.2s ease;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 229, 255, 0.5);
}

.action-btn:active {
    transform: translateY(1px);
}

.pulse-btn {
    animation: btn-pulse 2s ease-in-out infinite;
}

@keyframes btn-pulse {

    0%,
    100% {
        box-shadow: 0 4px 20px rgba(0, 229, 255, 0.3);
    }

    50% {
        box-shadow: 0 4px 35px rgba(0, 229, 255, 0.6);
    }
}

.secondary-btn {
    display: block;
    width: 100%;
    padding: 12px 24px;
    margin: 8px 0;
    border: 1px solid var(--space-border);
    border-radius: 14px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: var(--text-primary);
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    border-color: var(--neon-cyan);
    background: rgba(0, 229, 255, 0.08);
}

.instructions {
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
}

/* Stats Grid (Game Over) */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 24px;
}

.go-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border: 1px solid rgba(100, 180, 255, 0.1);
    border-radius: 12px;
    background: rgba(0, 40, 100, 0.2);
}

.go-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.go-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}

/* ===== Keyboard ===== */
.ztype-keyboard {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    height: var(--kb-height);
    padding: 5px 4px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: linear-gradient(0deg, rgba(5, 10, 30, 0.95) 0%, rgba(5, 10, 30, 0.8) 100%);
    border-top: 1px solid rgba(100, 180, 255, 0.08);
}

.keyboard-row {
    display: flex;
    width: 100%;
    gap: 3px;
    touch-action: manipulation;
}

.keyboard-row button {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: clamp(14px, 3.8vw, 18px);
    height: clamp(38px, 7vh, 48px);
    flex: 1;
    border: 1px solid rgba(100, 180, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    background: var(--kb-key-bg);
    color: var(--kb-key-text);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.08s ease;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.keyboard-row button:active,
.keyboard-row button.pressed {
    transform: translateY(2px);
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.4);
    background: var(--kb-key-active);
    border-color: var(--neon-cyan);
    color: #fff;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
}

.keyboard-row button.wide-button {
    flex: 1.4;
    font-size: clamp(12px, 3.2vw, 15px);
}

/* Level Banner */
.level-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    z-index: 30;
    font-size: 36px;
    font-weight: 900;
    color: var(--neon-cyan);
    text-shadow: 0 0 30px rgba(0, 229, 255, 0.6);
    opacity: 0;
    pointer-events: none;
    animation: level-pop 1.5s ease-out forwards;
}

@keyframes level-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }

    40% {
        transform: translate(-50%, -50%) scale(1);
    }

    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -60%) scale(1);
    }
}

/* Power-up Active Indicator */
.powerup-indicator {
    position: absolute;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 12;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(0, 255, 136, 0.15);
    border: 1px solid rgba(0, 255, 136, 0.3);
    color: var(--neon-green);
    animation: pop-in 0.3s ease-out;
}

@keyframes pop-in {
    0% {
        transform: translateX(-50%) scale(0.7);
        opacity: 0;
    }

    100% {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

/* ===== Responsive ===== */
@media (max-width: 380px) {
    :root {
        --kb-height: 190px;
    }

    .hud-center {
        gap: 12px;
    }

    .hud-value {
        font-size: 16px;
    }

    .game-title {
        font-size: 26px;
    }
}

@media (min-width: 600px) {
    .ztype-keyboard {
        max-width: 520px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 16px 16px 0 0;
    }
}

@media (min-height: 800px) {
    :root {
        --kb-height: 230px;
    }

    .keyboard-row button {
        height: 50px;
    }
}

.ztype-select {
    margin: 15px auto 25px;
    display: block;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    font-size: 18px;
    border-radius: 10px;
    cursor: pointer;
    backdrop-filter: blur(5px);
}

.ztype-select option {
    background: #0f172a;
    color: white;
}