/* ========================================
   Falling Blocks - Mobile-first Styles
   ======================================== */

/* CSS Variables */
:root {
    /* Fondo y ambiente */
    --color-sky-top: #1a1a2e;
    --color-sky-bottom: #16213e;
    --color-ground: #4a752c;
    --color-ground-dark: #3d6124;

    /* UI */
    --color-primary: #e94560;
    --color-primary-hover: #ff6b6b;
    --color-secondary: #4a4a6a;
    --color-secondary-hover: #5a5a7a;
    --color-text: #FFFFFF;
    --color-text-shadow: #000000;
    --color-hud-bg: rgba(0, 0, 0, 0.5);

    /* Estados */
    --color-overlay: rgba(0, 0, 0, 0.85);
    --color-catch-good: rgba(46, 204, 113, 0.4);
    --color-catch-bad: rgba(231, 76, 60, 0.5);

    /* Canasta */
    --color-basket: #8b4513;
    --color-basket-dark: #5d3a1a;

    /* Timing */
    --transition-speed: 0.3s;
}

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

/* Prevent text selection and pull-to-refresh */
html,
body {
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(180deg, var(--color-sky-top) 0%, var(--color-sky-bottom) 100%);
    color: var(--color-text);
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

/* ========================================
   Screen System
   ======================================== */

.screen {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

/* ========================================
   Menu Screen
   ======================================== */

#menu-screen {
    background: linear-gradient(180deg, var(--color-sky-top) 0%, var(--color-sky-bottom) 70%, var(--color-ground-dark) 100%);
    padding: 20px;
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    max-width: 320px;
    width: 100%;
}

.menu-title {
    text-align: center;
}

.menu-emoji {
    font-size: 64px;
    display: block;
    margin-bottom: 10px;
    animation: bounce 1s ease-in-out infinite;
}

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

.menu-title h1 {
    font-size: 42px;
    font-weight: 900;
    text-shadow: 3px 3px 0 var(--color-text-shadow), -1px -1px 0 var(--color-primary);
    letter-spacing: 2px;
    line-height: 1.1;
}

.menu-subtitle {
    font-size: 18px;
    text-align: center;
    opacity: 0.9;
    line-height: 1.4;
}

.high-score-display {
    font-size: 20px;
    background: var(--color-hud-bg);
    padding: 10px 20px;
    border-radius: 10px;
}

.instructions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    font-size: 16px;
    background: var(--color-hud-bg);
    padding: 15px 20px;
    border-radius: 10px;
}

.instruction-item {
    text-align: center;
}

.control-hint {
    font-size: 14px;
    opacity: 0.7;
    text-align: center;
}

/* ========================================
   Buttons
   ======================================== */

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text);
    font-size: 24px;
    font-weight: 700;
    padding: 16px 48px;
    border-radius: 12px;
    min-height: 56px;
    min-width: 200px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 0 #b8324a, 0 6px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #b8324a, 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-secondary {
    background: var(--color-secondary);
    color: var(--color-text);
    font-size: 18px;
    font-weight: 600;
    padding: 12px 32px;
    border-radius: 10px;
    min-height: 48px;
    min-width: 180px;
    box-shadow: 0 3px 0 #3a3a5a, 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-secondary:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #3a3a5a, 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ========================================
   Game Screen
   ======================================== */

#game-screen {
    background: transparent;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-hud-bg);
    font-size: 18px;
    font-weight: 600;
    z-index: 10;
}

.hud-score,
.hud-best {
    text-shadow: 1px 1px 2px var(--color-text-shadow);
}

/* Tap Zones */
#tap-zones {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    height: 60px;
    pointer-events: none;
    z-index: 5;
}

.tap-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    opacity: 0.3;
    color: var(--color-text);
}

.tap-left {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
}

.tap-right {
    background: linear-gradient(270deg, rgba(255, 255, 255, 0.1) 0%, transparent 100%);
}

/* ========================================
   Game Over Screen
   ======================================== */

#gameover-screen {
    background: var(--color-overlay);
    z-index: 100;
}

.gameover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 30px;
    max-width: 320px;
    width: 100%;
}

.explosion-emoji {
    font-size: 36px;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.gameover-content h2 {
    font-size: 36px;
    font-weight: 900;
    text-shadow: 2px 2px 0 var(--color-text-shadow);
}

.final-score {
    font-size: 28px;
    font-weight: 700;
}

.new-record {
    font-size: 22px;
    color: #ffd700;
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); opacity: 0.9; }
    to { transform: scale(1.05); opacity: 1; }
}

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

.gameover-best {
    font-size: 20px;
    opacity: 0.8;
}

/* ========================================
   Catch Effect
   ======================================== */

.catch-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
    z-index: 50;
}

.catch-effect.good {
    background: var(--color-catch-good);
    opacity: 1;
}

.catch-effect.bad {
    background: var(--color-catch-bad);
    opacity: 1;
}

/* ========================================
   Screen Shake Animation
   ======================================== */

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

@keyframes screenShake {
    0%, 100% { transform: translate(0, 0); }
    10%, 50%, 90% { transform: translate(-3px, -3px); }
    20%, 60% { transform: translate(3px, 3px); }
    30%, 70% { transform: translate(-3px, 3px); }
    40%, 80% { transform: translate(3px, -3px); }
}

/* ========================================
   Responsive Design
   ======================================== */

@media (min-width: 768px) {
    .menu-title h1 {
        font-size: 56px;
    }

    .menu-emoji {
        font-size: 80px;
    }

    #hud {
        font-size: 22px;
        padding: 16px 24px;
    }

    .instructions {
        font-size: 18px;
    }
}

/* Landscape warning (optional) */
@media (orientation: landscape) and (max-height: 500px) {
    .menu-emoji {
        font-size: 40px;
    }

    .menu-title h1 {
        font-size: 28px;
    }

    .menu-content {
        gap: 10px;
    }

    .instructions {
        padding: 10px 15px;
    }
}
