/* Reset y variables */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-bg: #1a1a2e;
    --color-card: #16213e;
    --color-card-border: #0f3460;
    --color-primary: #e94560;
    --color-success: #00bf63;
    --color-error: #ff4757;
    --color-text: #ffffff;
    --color-text-muted: #a0a0a0;
    --color-price: #ffd700;
    --color-vs: #e94560;
    --transition-speed: 0.3s;
    --card-radius: 16px;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* Pantallas */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
    width: 100%;
}

.screen.active {
    display: flex;
}

/* Botones base */
button {
    font-family: inherit;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    min-height: 48px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s, opacity 0.2s;
}

button:active {
    transform: scale(0.97);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text);
    font-size: 1.25rem;
    padding: 16px 48px;
    width: 100%;
    max-width: 300px;
}

.btn-secondary {
    background: var(--color-card);
    color: var(--color-text);
    font-size: 1rem;
    padding: 14px 32px;
    border: 2px solid var(--color-card-border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 300px;
}

/* === PANTALLA INICIO === */
#screen-inicio {
    gap: 40px;
    text-align: center;
}

.logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.logo-emoji {
    font-size: 5rem;
    line-height: 1;
}

.logo h1 {
    font-size: 2rem;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 1rem;
}

.highscore-display {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

#best-score-inicio,
#best-score {
    color: var(--color-price);
    font-weight: 700;
}

/* === PANTALLA JUEGO === */
#screen-juego {
    justify-content: space-between;
    padding: 16px;
    gap: 12px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    padding: 8px 0;
}

.score-display {
    font-size: 1.1rem;
    font-weight: 600;
}

#current-score {
    color: var(--color-success);
    font-size: 1.3rem;
}

.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 400px;
    flex: 1;
    justify-content: center;
}

/* Product Cards */
.product-card {
    background: var(--color-card);
    border: 2px solid var(--color-card-border);
    border-radius: var(--card-radius);
    padding: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: border-color var(--transition-speed), transform var(--transition-speed);
}

.product-card.correct {
    border-color: var(--color-success);
    animation: pulse-success 0.5s ease;
}

.product-card.incorrect {
    border-color: var(--color-error);
    animation: shake 0.5s ease;
}

@keyframes pulse-success {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

.product-emoji {
    font-size: 3.5rem;
    line-height: 1;
}

.product-name {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
    min-height: 2.4em;
    display: flex;
    align-items: center;
}

.product-price {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--color-price);
    min-height: 1.5em;
}

.product-price.hidden {
    color: var(--color-text-muted);
}

.product-price.revealing {
    animation: count-up 0.8s ease-out;
}

@keyframes count-up {
    0% { opacity: 0.5; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

/* VS Divider */
.vs-divider {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-vs);
    padding: 4px 0;
}

/* Game Actions */
.game-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 400px;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.btn-choice {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 8px;
    font-size: 0.9rem;
    min-height: 70px;
}

.btn-choice .arrow {
    font-size: 1.5rem;
    line-height: 1;
}

.btn-caro {
    background: linear-gradient(135deg, #00bf63 0%, #00a855 100%);
    color: white;
}

.btn-barato {
    background: linear-gradient(135deg, #e94560 0%, #c73e54 100%);
    color: white;
}

/* === PANTALLA GAME OVER === */
#screen-gameover {
    text-align: center;
}

.gameover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

#gameover-title {
    font-size: 2.5rem;
    letter-spacing: 3px;
}

.final-score {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.final-score span:first-child {
    color: var(--color-text-muted);
    font-size: 1rem;
}

.score-big {
    font-size: 4rem;
    font-weight: 800;
    color: var(--color-price);
}

.new-record {
    color: var(--color-success);
    font-size: 1.5rem;
    font-weight: 700;
    animation: bounce 0.6s ease infinite;
}

.new-record.hidden {
    display: none;
}

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

.gameover-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
}

/* === PANTALLA ERROR === */
#screen-error {
    text-align: center;
}

.error-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.error-emoji {
    font-size: 4rem;
}

#error-message {
    color: var(--color-text-muted);
    font-size: 1.1rem;
    max-width: 280px;
}

/* === RESPONSIVE === */
@media (min-width: 768px) {
    .logo h1 {
        font-size: 2.5rem;
    }

    .logo-emoji {
        font-size: 6rem;
    }

    .product-card {
        padding: 24px;
    }

    .product-emoji {
        font-size: 4rem;
    }

    .product-name {
        font-size: 1.25rem;
    }

    .product-price {
        font-size: 1.75rem;
    }

    .btn-choice {
        font-size: 1rem;
        min-height: 80px;
    }

    .game-area {
        gap: 16px;
    }
}

/* Landscape orientation adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    #screen-juego {
        padding: 8px 16px;
    }

    .game-area {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .product-card {
        flex: 1;
        min-width: 140px;
        max-width: 200px;
        padding: 12px;
    }

    .product-emoji {
        font-size: 2.5rem;
    }

    .vs-divider {
        order: 2;
        flex: 0 0 auto;
    }

    #card-actual {
        order: 1;
    }

    #card-comparar {
        order: 3;
    }

    .game-actions {
        order: 4;
        width: 100%;
    }
}
