* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none; /* Prevent text selection while tapping */
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

img {
    -webkit-user-drag: none;
    pointer-events: none; /* Except where explicitly allowed */
}

body {
    font-family: 'Fredoka One', cursive, sans-serif;
    background-color: #f0e6d2; /* Light wall color */
    background-image: 
        radial-gradient(#d5cbb8 10%, transparent 11%),
        radial-gradient(#d5cbb8 10%, transparent 11%);
    background-size: 60px 60px;
    background-position: 0 0, 30px 30px;
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Prevent scrolling */
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    background: url('bg_football.jpg') no-repeat center center / cover;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    overflow: hidden;
}

#ui {
    position: absolute;
    top: 20px;
    width: 100%;
    text-align: center;
    z-index: 10;
    pointer-events: none;
}

#reload-button {
    position: absolute;
    top: 0;
    right: 20px;
    background: #fff;
    border: 3px solid #ccc;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 0 #ccc;
}

#reload-button:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #ccc;
}

h1 {
    color: #ff3366;
    text-shadow: 3px 3px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
    font-size: 2.5rem;
    margin-bottom: 10px;
    animation: pulse 2s infinite;
}

#progress-container {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 30px;
    display: inline-block;
    border: 4px solid #ffcc00;
    box-shadow: 0 4px 0 #cc9900;
    width: 80%;
    max-width: 400px;
}

#progress-text {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 5px;
    font-weight: bold;
}

#progress-bar-wrapper {
    width: 100%;
    height: 20px;
    background-color: #ddd;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

#progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 10px;
    transition: width 0.3s ease-out, background 0.3s;
}

#lives-container {
    font-size: 2rem;
    margin-top: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    border: 2px solid #ccc;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#play-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.gameObject {
    position: absolute;
    font-size: 5.5rem;
    cursor: pointer;
    user-select: none;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 0 12px #ffffff) drop-shadow(0 0 4px #ffffff) drop-shadow(0 6px 10px rgba(0,0,0,0.6));
    z-index: 10;
    animation: popInBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gameObject-img {
    height: 5.5rem;
    width: auto;
    pointer-events: none;
    filter: drop-shadow(0 0 8px white);
}

.gameObject:active {
    transform: scale(0.9);
}

.shatter-squish {
    animation: shatter 0.25s forwards !important;
}

.effect {
    position: absolute;
    font-size: 2.5rem;
    font-weight: 900;
    font-family: 'Fredoka One', cursive;
    pointer-events: none;
    z-index: 25;
    animation: comicPop 0.5s ease-out forwards;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 20;
    animation: explode 0.6s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

.star-particle {
    position: absolute;
    font-size: 1.5rem;
    pointer-events: none;
    z-index: 21;
    animation: starBurst 0.7s ease-out forwards;
}

/* Animations */
@keyframes popInBounce {
    0% { transform: scale(0) rotate(-20deg); opacity: 0; }
    70% { transform: scale(1.2) rotate(10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes shatter {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4, 0.5) rotate(15deg); opacity: 0.8; filter: brightness(2); }
    100% { transform: scale(0, 0) rotate(-30deg); opacity: 0; }
}

@keyframes comicPop {
    0% { transform: scale(0.2) rotate(-25deg); opacity: 0; }
    50% { transform: scale(1.5) rotate(10deg); opacity: 1; }
    80% { transform: scale(1.1) rotate(-5deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 0; }
}

@keyframes explode {
    0% { transform: scale(0.5); opacity: 1; }
    50% { transform: scale(1.5) rotate(15deg); }
    100% { transform: scale(2) rotate(-15deg); opacity: 0; }
}

@keyframes starBurst {
    0% { transform: scale(0.3) translate(0, 0) rotate(0deg); opacity: 1; }
    50% { opacity: 1; }
    100% { transform: scale(1.3) translate(var(--dx), var(--dy)) rotate(360deg); opacity: 0; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@media (max-width: 600px) {
    h1 { font-size: 1.8rem; }
    #score-board { font-size: 1.2rem; }
    .gameObject { font-size: 4rem; }
}

/* Nuevos Estilos - Fase 2 */

.hidden {
    display: none !important;
}

#tadeo-character {
    position: absolute;
    width: 80px;
    height: 100px;
    text-align: center;
    pointer-events: none;
    z-index: 15;
    opacity: 0;
    transition: transform 0.2s ease-out, opacity 0.2s;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.4));
}

#tadeo-name {
    background-color: #333;
    color: white;
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-bottom: 10px; /* Cambiado de -5px a 10px para que no tape la cara */
    position: relative;
    z-index: 2;
}

#tadeo-body {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    position: relative;
    height: 80px; /* Asegura que haya espacio para la imagen */
}

#tadeo-person {
    height: 100px; /* Ajusta la altura de la foto */
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

#tadeo-weapon {
    position: absolute;
    right: -20px;
    top: 20px;
    font-size: 2.5rem;
    transform-origin: bottom right;
    transition: transform 0.1s;
    z-index: 5;
}

.hit-animation #tadeo.hit-animation {
    animation: hit 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.throw-animation {
    animation: throw 0.3s ease-out;
}

@keyframes hit {
    0% { transform: rotate(0deg) scale(1); }
    40% { transform: rotate(-45deg) scale(1.3); }
    70% { transform: rotate(30deg) scale(1.1); }
    100% { transform: rotate(0deg) scale(1); }
}

@keyframes throw {
    0% { transform: translateY(0) rotate(0deg); }
    30% { transform: translateY(20px) rotate(-30deg); }
    100% { transform: translateY(-30px) rotate(360deg); }
}

.relative-event {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 30;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.relative-warning {
    color: red;
    font-size: 2rem;
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
    animation: pulse 0.5s infinite;
    margin-bottom: 0px;
}

.relative-name {
    font-size: 1.5rem;
    color: white;
    background-color: #ff3366;
    padding: 5px 15px;
    border-radius: 20px;
    border: 3px solid white;
    display: inline-block;
    margin-bottom: -10px;
    position: relative;
    z-index: 5;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.relative-character img {
    height: 60px !important;
    width: auto;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.8));
}

.relative-dialog {
    background-color: white;
    color: #333;
    padding: 8px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    font-family: 'Fredoka One', cursive;
    margin-top: 5px;
    position: relative;
    max-width: 150px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.relative-dialog::after {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 10px 10px 10px;
    border-style: solid;
    border-color: transparent transparent white transparent;
}

.hide-btn {
    display: block;
    margin: 5px auto 0 auto;
    background-color: #ff3366;
    color: white;
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    padding: 8px 15px;
    border: 3px solid white;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 25;
    animation: pulse 1s infinite;
    transform: scale(0.9);
}

.hide-btn:active {
    transform: scale(0.8) !important;
}

#continue-button {
    position: absolute;
    top: 75%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #4CAF50;
    color: white;
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    padding: 15px 40px;
    border: 4px solid white;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 0 #388E3C;
    z-index: 35;
    white-space: nowrap;
}

#continue-button:active {
    transform: translate(-50%, -40%);
    box-shadow: 0 0 0 #388E3C;
}

#hide-button {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ff3366;
    color: white;
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    padding: 20px 40px;
    border: 6px solid white;
    border-radius: 40px;
    box-shadow: 0 10px 0 #cc0033, 0 15px 20px rgba(0,0,0,0.4);
    cursor: pointer;
    z-index: 40;
    transition: transform 0.1s, box-shadow 0.1s;
    animation: pulse 1s infinite alternate;
}

#hide-button:active {
    transform: translateX(-50%) translateY(10px);
    box-shadow: 0 0 0 #cc0033, 0 5px 10px rgba(0,0,0,0.4);
    animation: none;
}

.screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0,0,0,0.85);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    color: white;
    overflow-y: auto;
    padding: 50px 20px;
    box-sizing: border-box;
}

.screen-overlay h2 {
    font-size: 3rem;
    color: #ff3366;
    text-shadow: 3px 3px 0 #fff;
    margin-bottom: 20px;
}

#player-name {
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    padding: 10px 20px;
    border-radius: 20px;
    border: 4px solid #ffcc00;
    text-align: center;
    margin-bottom: 20px;
    outline: none;
    width: 80%;
    max-width: 300px;
}

#start-button {
    background-color: #ffcc00;
    color: #333;
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    padding: 15px 40px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 0 #cc9900;
    transition: transform 0.1s;
    margin-bottom: 30px;
}

#start-button:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #cc9900;
}

#instructions-container {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 15px 20px;
    margin: 15px 0;
    max-width: 400px;
    text-align: left;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#instructions-container h3 {
    margin-top: 0;
    margin-bottom: 10px;
    text-align: center;
    color: #ffeb3b;
    font-size: 1.3rem;
}

#instructions-container ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

#instructions-container li {
    font-size: 0.95rem;
    margin-bottom: 8px;
    line-height: 1.3;
}

#leaderboard-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 20px;
    width: 80%;
    max-width: 350px;
    border: 2px solid rgba(255,255,255,0.2);
}

.leaderboard-container h3 {
    color: #ffcc00;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    font-size: 1.2rem;
}

.leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.2);
}

.leaderboard-list li:last-child {
    border-bottom: none;
}

.mt-20 {
    margin-top: 20px;
}

/* Nuevos Estilos - Fase 4 */

.floating-score {
    position: absolute;
    font-size: 3rem;
    font-family: 'Fredoka One', cursive;
    font-weight: bold;
    pointer-events: none;
    z-index: 25;
    animation: floatUp 1s ease-out forwards;
}

.score-positive {
    color: #4CAF50;
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
}

.score-negative {
    color: #F44336;
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-80px) scale(1.5); opacity: 0; }
}

.error-flash {
    animation: flashRed 0.5s;
}

@keyframes flashRed {
    0% { background-color: rgba(255, 0, 0, 0.5); }
    100% { background-color: transparent; }
}

/* Fase 5 - Emma */
.emma-character {
    position: absolute;
    font-size: 5rem;
    cursor: pointer;
    filter: drop-shadow(0 0 15px gold);
    z-index: 20;
    animation: emmaRun 3s linear forwards;
}

.emma-img {
    height: 120px;
    width: auto;
    pointer-events: none;
    filter: drop-shadow(0 0 8px white);
}

@keyframes emmaRun {
    0% { transform: scale(1) translateX(-100px) rotate(-10deg); opacity: 0; }
    10% { opacity: 1; transform: scale(1.2) translateX(0) rotate(10deg); }
    90% { opacity: 1; transform: scale(1.2) translateX(300px) rotate(-10deg); }
    100% { transform: scale(1) translateX(400px) rotate(10deg); opacity: 0; }
}

.magic-flash {
    animation: flashGold 0.8s;
}

@keyframes flashGold {
    0% { background-color: rgba(255, 215, 0, 0.6); }
    100% { background-color: transparent; }
}

.emma-text {
    position: absolute;
    font-size: 3rem;
    font-family: 'Fredoka One', cursive;
    color: gold;
    text-shadow: 2px 2px 0 #ff3366, -2px -2px 0 #ff3366, 2px -2px 0 #ff3366, -2px 2px 0 #ff3366;
    pointer-events: none;
    z-index: 25;
    animation: floatUp 1.5s ease-out forwards;
}

#game-over-screen p {
    font-size: 2rem;
    margin-bottom: 40px;
}

#restart-button {
    background-color: #ffcc00;
    color: #333;
    font-family: 'Fredoka One', cursive;
    font-size: 2rem;
    padding: 15px 30px;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 0 #cc9900;
    transition: transform 0.1s;
}

#restart-button:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #cc9900;
}

/* =========================================
   RESPONSIVE DESIGN (MÓVILES)
========================================= */
@media (max-width: 600px) {
    h1 {
        font-size: 1.5rem;
    }

    #progress-container {
        padding: 5px 10px;
        max-width: 250px;
    }

    #progress-text {
        font-size: 1rem;
    }

    #lives-container {
        font-size: 1.5rem;
    }

    .gameObject {
        font-size: 4rem;
    }

    .gameObject-img {
        height: 4rem;
    }

    .relative-dialog {
        font-size: 0.9rem;
        padding: 6px;
        max-width: 120px;
    }

    .relative-warning {
        font-size: 1.5rem;
    }
    
    .relative-name {
        font-size: 1.2rem;
    }

    .hide-btn {
        font-size: 0.9rem;
        padding: 6px 12px;
        border-width: 2px;
        white-space: nowrap;
    }
    
    #continue-button {
        font-size: 1.2rem;
        padding: 12px 25px;
    }

    #instructions-container {
        width: 90%;
        max-width: none;
        padding: 15px;
        font-size: 0.9rem;
    }
    
    .emma-img {
        height: 80px;
    }
    
    .relative-character img {
        height: 50px !important;
    }
}
