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

body {
    font-family: 'Courier New', monospace;
    background: #d4d4aa;
    color: #1a1a1a;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    position: fixed;
}

.game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* HUD Superior */
.hud-top {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 20px;
    background: rgba(26, 26, 26, 0.03);
    border-bottom: 2px solid #1a1a1a;
    position: relative;
}

.back-arrow {
    position: absolute;
    left: 10px;
    font-size: 28px;
    color: #1a1a1a;
    text-decoration: none;
    font-weight: bold;
    line-height: 1;
    transition: all 0.2s ease;
    padding: 4px 8px;
    border: 2px solid transparent;
}

.back-arrow:hover {
    background: #1a1a1a;
    color: #e8e8c0;
    border: 2px solid #1a1a1a;
}

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

.stat-label {
    font-size: 9px;
    color: rgba(26, 26, 26, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #1a1a1a;
}

.stat-value.combo {
    color: #3a3a3a;
}

/* Barra de XP */
.xp-bar-container {
    position: relative;
    width: 100%;
    height: 16px;
    background: #b8b890;
    border-top: 3px solid #1a1a1a;
    border-bottom: 3px solid #1a1a1a;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 10;
}

.xp-bar {
    position: absolute;
    left: 0;
    top: 0;
    width: 0%;
    height: 100%;
    background: #2a2a2a;
    transition: width 0.4s ease-out;
}

/* Canvas */
#gameCanvas {
    flex: 1;
    width: 100%;
    height: 100%;
    background: #e8e8c0;
    display: block;
}

/* Tutorial overlay */
.tutorial-overlay {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    opacity: 0.2;
    pointer-events: none;
    user-select: none;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tutorial-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.tutorial-text {
    font-size: 14px;
    font-weight: bold;
    color: #1a1a1a;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.tutorial-key {
    display: inline-block;
    padding: 4px 8px;
    background: rgba(26, 26, 26, 0.15);
    border: 2px solid #1a1a1a;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
    color: #1a1a1a;
    min-width: 28px;
    text-align: center;
}

/* HUD Inferior */
.hud-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: rgba(26, 26, 26, 0.03);
    border-top: 2px solid #1a1a1a;
    min-height: 50px;
}

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

.lives-label {
    font-size: 16px;
    filter: grayscale(100%);
}

.lives-bars {
    display: flex;
    gap: 4px;
}

.life-bar {
    width: 20px;
    height: 20px;
    background: #1a1a1a;
    border: 2px solid #1a1a1a;
    transition: all 0.2s ease;
}

.life-bar.empty {
    background: transparent;
    border: 2px solid rgba(26, 26, 26, 0.25);
}

.typing-display {
    flex: 1;
    text-align: center;
    padding: 4px 15px;
    min-height: 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.typing-target {
    font-size: 9px;
    color: rgba(26, 26, 26, 0.35);
    letter-spacing: 1px;
}

.typing-current {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 3px;
    line-height: 1.4;
}

.typing-current .correct {
    background: #1a1a1a;
    color: #e8e8c0;
    padding: 2px 4px;
    margin: 0 1px;
}

.typing-current .remaining {
    color: rgba(26, 26, 26, 0.5);
    padding: 0 2px;
}

.upgrades-mini {
    display: flex;
    gap: 4px;
}

.upgrade-icon {
    width: 24px;
    height: 24px;
    background: rgba(26, 26, 26, 0.08);
    border: 2px solid #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    filter: grayscale(100%);
}

/* Menú de Mejoras */
.upgrade-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(212, 212, 170, 0.98);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.upgrade-menu-content {
    text-align: center;
    width: 90%;
    max-width: 800px;
}

.upgrade-menu-content h2 {
    font-size: 36px;
    margin-bottom: 8px;
    color: #1a1a1a;
    animation: blink 1s step-end infinite;
}

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

.upgrade-subtitle {
    font-size: 12px;
    color: rgba(26, 26, 26, 0.6);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.current-upgrades {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 12px;
    background: rgba(26, 26, 26, 0.05);
    border-radius: 4px;
}

.current-upgrade-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #e8e8c0;
    border: 2px solid #1a1a1a;
    font-size: 13px;
    min-width: 100px;
}

.current-upgrade-icon {
    font-size: 18px;
    filter: grayscale(100%);
}

.current-upgrade-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.current-upgrade-name {
    font-weight: bold;
    font-size: 11px;
    color: #1a1a1a;
}

.current-upgrade-level {
    display: flex;
    align-items: center;
    gap: 3px;
}

.current-upgrade-dots {
    display: flex;
    gap: 2px;
}

.current-upgrade-dot {
    width: 6px;
    height: 6px;
    background: rgba(26, 26, 26, 0.2);
    border: 1px solid #1a1a1a;
}

.current-upgrade-dot.filled {
    background: #1a1a1a;
}

.upgrade-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.upgrade-option {
    background: #e8e8c0;
    border: 3px solid #1a1a1a;
    padding: 20px;
    width: 180px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.upgrade-option .upgrade-number {
    position: absolute;
    top: 5px;
    right: 8px;
    font-size: 24px;
    font-weight: bold;
    color: rgba(26, 26, 26, 0.25);
}

.upgrade-option:hover {
    background: #1a1a1a;
    color: #e8e8c0;
}

.upgrade-option:hover .upgrade-name {
    color: #e8e8c0;
}

.upgrade-option:hover .upgrade-description {
    color: rgba(232, 232, 192, 0.75);
}

.upgrade-option:hover .upgrade-level {
    color: rgba(232, 232, 192, 0.85);
}

.upgrade-option:hover .upgrade-number {
    color: rgba(232, 232, 192, 0.5);
}

.upgrade-icon-big {
    font-size: 32px;
    margin-bottom: 10px;
    filter: grayscale(100%);
}

.upgrade-name {
    font-size: 14px;
    font-weight: bold;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.upgrade-description {
    font-size: 10px;
    color: rgba(26, 26, 26, 0.65);
    line-height: 1.4;
}

.upgrade-level {
    margin-top: 10px;
    font-size: 9px;
    color: rgba(26, 26, 26, 0.5);
    font-weight: bold;
}

/* Game Over */
.game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(212, 212, 170, 0.98);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    animation: fadeIn 0.3s ease;
}

.game-over-content {
    text-align: center;
    width: 90%;
    max-width: 600px;
}

.game-over-content h2 {
    font-size: 48px;
    color: #1a1a1a;
    margin-bottom: 30px;
    animation: blink 0.5s step-end infinite;
}

.final-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.final-stat {
    background: #e8e8c0;
    border: 2px solid #1a1a1a;
    padding: 15px 20px;
    min-width: 120px;
}

.final-stat-label {
    font-size: 9px;
    color: rgba(26, 26, 26, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.final-stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #1a1a1a;
}

.restart-btn {
    padding: 15px 40px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    background: #1a1a1a;
    color: #e8e8c0;
    border: 3px solid #1a1a1a;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.restart-btn:hover {
    background: #e8e8c0;
    color: #1a1a1a;
}

.hidden {
    display: none !important;
}

/* Animación de shake para damage */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.2s ease;
}

/* Media queries para pantallas más pequeñas */
@media (max-width: 768px) {
    .stat-value {
        font-size: 14px;
    }

    .stat-label {
        font-size: 8px;
    }

    .tutorial-overlay {
        top: 15%;
    }

    .tutorial-text {
        font-size: 11px;
    }

    .tutorial-key {
        font-size: 9px;
        padding: 3px 6px;
        min-width: 22px;
    }

    .upgrade-option {
        width: 140px;
        padding: 15px;
    }

    .current-upgrade-item {
        min-width: 85px;
        padding: 5px 8px;
    }

    .current-upgrade-icon {
        font-size: 16px;
    }

    .current-upgrade-name {
        font-size: 10px;
    }

    .upgrade-menu-content h2 {
        font-size: 28px;
    }

    .game-over-content h2 {
        font-size: 36px;
    }
}

@media (max-width: 480px) {
    .hud-top {
        padding: 5px 10px;
    }

    .back-arrow {
        font-size: 24px;
        left: 5px;
        padding: 2px 6px;
    }

    .hud-bottom {
        padding: 5px 10px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .typing-display {
        order: -1;
        width: 100%;
        padding: 8px 10px;
        min-height: 45px;
    }

    .typing-current {
        font-size: 16px;
        letter-spacing: 2px;
    }

    .typing-target {
        font-size: 10px;
    }

    .tutorial-overlay {
        top: 10%;
        gap: 10px;
    }

    .upgrade-option {
        width: 120px;
        padding: 12px;
    }

    .current-upgrade-item {
        min-width: 75px;
        padding: 4px 6px;
        gap: 4px;
    }

    .current-upgrade-icon {
        font-size: 14px;
    }

    .current-upgrade-name {
        font-size: 9px;
    }

    .current-upgrade-dot {
        width: 5px;
        height: 5px;
    }

    .final-stats {
        flex-direction: column;
        align-items: center;
    }
}
