:root {
    --futbol-green: #00c853;
    --futbol-yellow: #ffd600;
    --bg: #0a1a0a;
    --text: #ffffff;
    --panel-bg: rgba(10, 20, 10, 0.98);
    --safe-margin: 0px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    background-size: cover;
    background-position: center;
    cursor: crosshair;
}

canvas {
    display: block;
    position: relative;
    z-index: 1;
}

/* Pantalla de Inicio */
#start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    background-image: url('media/img/background2.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.8s ease, visibility 0.8s;
}

#start-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.start-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.start-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 74px;
    transform: translateY(-6vh);
}

#start-logo {
    width: min(820px, 92vw);
    height: auto;
    max-height: 25vh;
    object-fit: contain;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.6));
}

.start-p1 {
    background: linear-gradient(135deg, rgba(0, 200, 83, 0.15) 0%, transparent 100%);
}

.start-p2 {
    background: linear-gradient(225deg, rgba(255, 214, 0, 0.15) 0%, transparent 100%);
}

.start-divider {
    width: 2px;
    background: linear-gradient(to bottom, transparent, var(--futbol-green), var(--futbol-yellow), transparent);
    box-shadow: 0 0 15px rgba(0, 200, 83, 0.5);
}

.btn-start {
    padding: 25px 50px;
    font-size: 1.5rem;
    font-weight: 900;
    background: white;
    color: black;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-transform: uppercase;
}

#btn-start-main {
    --start-fill: 0%;
    width: min(320px, 90vw);
    height: min(150px, 20vh);
    padding: 0;
    background: transparent;
    background-image:
        linear-gradient(to right, rgba(0, 255, 0, 0.35) var(--start-fill), rgba(255, 255, 255, 0) var(--start-fill)),
        url('media/img/CARTEL.png');
    background-size: 100% 100%, 100% 100%;
    background-repeat: no-repeat, no-repeat;
    background-position: center, center;
    border-radius: 18px;
    color: #000;
    font-size: clamp(1.4rem, 4vw, 2.6rem);
    letter-spacing: 2px;
    text-shadow: none;
}

.btn-p1 {
    box-shadow: 6px 6px 0px var(--futbol-green), -3px -3px 0px var(--futbol-green);
}

.btn-p1:hover {
    transform: scale(1.08);
    box-shadow: 9px 9px 0px var(--futbol-green), -5px -5px 0px var(--futbol-green);
}

.btn-p2 {
    box-shadow: 6px 6px 0px var(--futbol-yellow), -3px -3px 0px var(--futbol-yellow);
}

.btn-p2:hover {
    transform: scale(1.08);
    box-shadow: 9px 9px 0px var(--futbol-yellow), -5px -5px 0px var(--futbol-yellow);
}

.btn-start.ready:not(#btn-start-main) {
    background: #4ade80;
    pointer-events: none;
    transform: scale(0.95);
}

#btn-start-main.ready {
    pointer-events: none;
    transform: scale(0.98);
    filter: brightness(1.05);
}

.ready-indicator {
    display: none;
    margin-top: 20px;
    font-size: 1.5rem;
    font-weight: 900;
    color: #4ade80;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
    animation: pulse-ready 0.5s infinite alternate;
}

.ready-indicator.active {
    display: block;
}

@keyframes pulse-ready {
    from {
        transform: scale(1);
        opacity: 0.8;
    }

    to {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Tutorial Screen */
#tutorial-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top left, rgba(0, 200, 83, 0.25) 0%, transparent 50%),
                radial-gradient(circle at bottom right, rgba(255, 214, 0, 0.25) 0%, transparent 50%),
                url('media/img/background/escena5.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 150;
    transition: opacity 0.5s ease, visibility 0.5s;
}

#tutorial-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.tutorial-content {
    text-align: center;
    max-width: 90%;
    animation: tutorialFadeIn 0.6s ease-out;
}

.tutorial-title-wrapper {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    padding: 15px 30px;
    border-radius: 16px;
    margin-bottom: 50px;
    text-align: center;
}

.tutorial-title {
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: 900;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--futbol-green), var(--futbol-yellow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titlePulse 2s ease-in-out infinite;
}

.tutorial-title .lang-es,
.tutorial-title .lang-pt {
    display: block;
    line-height: 1.2;
}

.tutorial-instructions {
    display: flex;
    flex-direction: column;
    gap: 40px;
    margin-bottom: 50px;
}

.tutorial-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    padding: 20px;
    border-radius: 20px;
    animation: itemSlideIn 0.8s ease-out;
}

.tutorial-item.collect {
    background: rgba(0, 0, 0, 0.65);
    border: 2px solid var(--futbol-green);
    animation-delay: 0.2s;
    backdrop-filter: blur(6px);
}

.tutorial-item.avoid {
    background: rgba(0, 0, 0, 0.65);
    border: 2px solid var(--futbol-yellow);
    animation-delay: 0.4s;
    backdrop-filter: blur(6px);
}

.tutorial-icon-container {
    min-width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tutorial-icon {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 0 20px currentColor);
    animation: iconFloat 2s ease-in-out infinite;
}

.tutorial-icon-small {
    width: 64px;
    height: 64px;
}

.tutorial-item.collect .tutorial-icon {
    color: var(--futbol-green);
}

.tutorial-item.avoid .tutorial-icon {
    color: var(--futbol-yellow);
    animation: iconShake 0.5s ease-in-out infinite;
}

.tutorial-text {
    flex: 1;
    text-align: left;
}

.tutorial-text p {
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: 700;
    color: white;
    margin: 5px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.tutorial-countdown {
    font-size: clamp(1.2rem, 4vw, 2rem);
    font-weight: 900;
    color: white;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
    animation: countdownPulse 1s ease-in-out infinite;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    padding: 20px 35px;
    border-radius: 16px;
    margin-top: 30px;
}

.tutorial-countdown span:first-child {
    display: block;
    margin-bottom: 10px;
    color: var(--futbol-green);
}

#tutorial-timer {
    display: inline-block;
    font-size: clamp(2rem, 8vw, 4rem);
    color: white;
    background: linear-gradient(135deg, var(--futbol-green), var(--futbol-yellow));
    padding: 10px 30px;
    border-radius: 15px;
    margin-top: 10px;
    animation: timerBounce 1s ease-in-out infinite;
}

@keyframes tutorialFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes titlePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes itemSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes iconFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes iconShake {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-5deg);
    }
    75% {
        transform: rotate(5deg);
    }
}

@keyframes countdownPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes timerBounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Pantalla de Selección de Jugadores */
#player-selection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('media/img/background/escena5.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 120;
    transition: opacity 0.5s ease, visibility 0.5s;
}

#player-selection-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.selection-content {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 50px;
    border-radius: 30px;
    border: 2px solid var(--futbol-green);
    text-align: center;
    animation: tutorialFadeIn 0.6s ease-out;
}

.selection-title {
    font-size: 2.2rem;
    font-weight: 900;
    color: white;
    margin-bottom: 40px;
    text-transform: uppercase;
    text-shadow: 0 0 20px var(--futbol-green);
}

.selection-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    justify-content: center;
}

.btn-selection {
    background: linear-gradient(135deg, var(--futbol-green) 0%, var(--futbol-yellow) 50%, var(--futbol-green) 100%);
    background-size: 200% auto;
    color: black;
    border: 3px solid rgba(255, 255, 255, 0.3);
    padding: 30px 50px;
    font-size: 3rem;
    font-weight: 900;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-width: 150px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    animation: selectionGradient 4s linear infinite;
    position: relative;
    overflow: hidden;
}

@keyframes selectionGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.btn-selection:hover {
    transform: scale(1.1) translateY(-5px);
    border-color: white;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4);
}

.btn-selection.p1 {
    /* Share animated gradient */
}

.btn-selection.p2 {
    /* Share animated gradient */
}

/* Divisor Central */
#divider {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--futbol-green), var(--futbol-yellow), transparent);
    box-shadow: 0 0 15px rgba(0, 200, 83, 0.5);
    z-index: 5;
}

/* UI de Jugadores */
.player-ui {
    position: absolute;
    top: 55px;
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    width: 45%;
}

#ui-p1 {
    left: 20px;
    align-items: flex-start;
}

#ui-p2 {
    right: 20px;
    align-items: flex-end;
}

.score-board {
    font-size: 2.5rem;
    font-weight: 900;
    text-shadow: 2px 2px 0px var(--futbol-yellow), -2px -2px 0px var(--futbol-green);
}

.combo-meter {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--futbol-green);
    margin-top: -5px;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-meter.active {
    opacity: 1;
    transform: scale(1.3);
    animation: combo-bounce 0.3s ease;
}

@keyframes combo-bounce {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.5);
    }

    100% {
        transform: scale(1.3);
    }
}

.lives-container {
    display: flex;
    gap: 10px;
    margin-top: 5px;
    font-size: 1.5rem;
}

/* Ocultar puntaje y vidas de ambos jugadores */
.score-board,
.lives-container {
    display: none !important;
}

.heart {
    color: var(--futbol-green);
    filter: drop-shadow(0 0 5px var(--futbol-green));
    transition: all 0.3s;
}

.heart.default {
    color: var(--futbol-green);
    filter: drop-shadow(0 0 5px var(--futbol-green));
}

.heart.lost {
    opacity: 0.5;
    filter: grayscale(1);
}

/* Cronómetro Central */
#center-ui {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 20;
    pointer-events: none;
}

#timer-display {
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
    line-height: 1;
}

#fx-name-display {
    display: none;
}

#timer-display.low-time {
    animation: pulse-timer 0.5s infinite alternate;
}

#safe-wrapper {
    position: fixed;
    top: var(--safe-margin);
    left: var(--safe-margin);
    width: calc(100% - (var(--safe-margin) * 2));
    height: calc(100% - (var(--safe-margin) * 2));
    box-sizing: border-box;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
    transform: translateZ(0);
    background-image: url('media/img/background/escena5.jpg');
    background-size: cover;
    background-position: center;
}

#safe-wrapper>* {
    pointer-events: auto;
}

@keyframes pulse-timer {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.1);
    }
}

/* Barra de Progreso Superior */
#progress-bar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 80px;
    background: rgba(0,0,0,0.5);
    z-index: 30;
    display: flex;
    overflow: visible;
    border-bottom: 2px solid rgba(255,255,255,0.1);
}

#progress-p1 {
    height: 100%;
    background: linear-gradient(180deg, #00e676 0%, #00c853 50%, #009624 100%);
    width: 50%;
    transition: width 0.3s ease-out;
    position: relative;
    box-shadow: inset 0 -4px 10px rgba(0,0,0,0.3);
}

#progress-p1::after {
    display: none; /* Removed the diagonal cut for a cleaner look if desired, or keep if preferred */
}

#progress-p2 {
    height: 100%;
    background: linear-gradient(180deg, #ffee58 0%, #ffd600 50%, #c7a500 100%);
    width: 50%;
    transition: width 0.3s ease-out;
    position: relative;
    box-shadow: inset 0 -4px 10px rgba(0,0,0,0.3);
}

#progress-p2::before {
    display: none;
}

#progress-phrase {
    position: absolute;
    width: 100%;
    text-align: center;
    color: white;
    font-weight: 900;
    font-size: 2.2rem;
    line-height: 80px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    z-index: 31;
    pointer-events: none;
    text-transform: uppercase;
}

/* Timer central */
#timer-box {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 35;
    display: flex;
    align-items: center;
    background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 100%);
    padding: 6px 20px;
    border-radius: 0 0 15px 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

/* Panel de Control */
#control-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--panel-bg);
    padding: 30px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 100px rgba(0, 0, 0, 1);
    z-index: 1000;
    display: none;
    width: 90%;
    max-width: 450px;
    backdrop-filter: blur(25px);
    max-height: 90vh;
    overflow-y: auto;
}

/* Tabs Styles */
.tab-header {
    display: flex;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 5px;
    gap: 5px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    padding: 10px;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 700;
    transition: all 0.2s;
    font-size: 0.8rem;
}

.tab-btn.active {
    background: var(--futbol-green);
    color: black;
    box-shadow: 0 4px 10px rgba(0, 200, 83, 0.3);
}

.tab-btn:nth-child(2).active {
    background: var(--futbol-yellow);
    color: black;
    box-shadow: 0 4px 10px rgba(255, 214, 0, 0.3);
}

.tab-btn:nth-child(3).active {
    background: #fff;
    color: black;
    box-shadow: 0 4px 10px rgba(255, 255, 255, 0.3);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#control-panel.active {
    display: block;
}

.field {
    margin-bottom: 15px;
}

.field label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.75rem;
    color: #888;
    font-weight: 600;
}

.field input,
.field select {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: white;
    outline: none;
    font-size: 0.85rem;
}

.btn-close {
    background: #fff;
    color: #000;
    border: none;
    padding: 14px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 800;
    width: 100%;
    margin-top: 10px;
    text-transform: uppercase;
}

.floating-text {
    position: absolute;
    pointer-events: none;
    color: white;
    font-weight: 900;
    font-size: 2.2rem;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.8);
    animation: floatUp 1.2s forwards;
    z-index: 5;
}

/* Overlays */
#confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 400;
    flex-direction: column;
    transition: all 0.5s ease;
    animation: overlayFadeIn 0.6s ease-out;
    background: rgba(0, 0, 0, 0.4); /* Volvemos a un fondo sutil para que se vea el cartel */
}

.coop-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease, visibility 0.8s;
}

.coop-stage.active {
    opacity: 1;
    visibility: visible;
}

.coop-stage img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* P1 overlay (left side) */
#overlay-p1 {
    border: none;
}

/* P2 overlay (right side) */
#overlay-p2 {
    border: none;
}

.overlay-win {
    background: transparent !important;
}

.overlay-lose {
    background: transparent !important;
}

.game-over-overlay h2 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    text-transform: uppercase;
    padding: 15px 25px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    font-weight: 900;
    color: white;
    letter-spacing: 5px;
    text-align: center;
    animation: titleBounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.game-over-overlay .final-score {
    font-size: 1.3rem;
    margin-top: 15px;
    font-weight: bold;
    color: white;
    background: rgba(0, 0, 0, 0.65);
    padding: 8px 24px;
    border-radius: 20px;
    animation: scoreFadeIn 1s ease-out 0.3s both;
    backdrop-filter: blur(4px);
}

#gameover-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('media/img/Dibu_00.jpg');
    background-size: cover;
    background-position: center;
    z-index: 38;
    display: none;
    animation: overlayFadeIn 0.8s ease-out;
}

#gameover-bg.active {
    display: block;
}

.reset-btn-container {
    position: absolute;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 50;
    display: none;
}

.reset-btn-container.active {
    display: block;
}

.reset-btn-container {
    display: none !important;
}

.btn-reset {
    padding: 18px 45px;
    font-size: 1.3rem;
    font-weight: 900;
    background: white;
    color: black;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 4px 4px 0px var(--futbol-green), -4px -4px 0px var(--futbol-yellow);
    transition: all 0.2s;
    text-transform: uppercase;
}

.btn-reset:hover {
    transform: translate(-2px, -2px) scale(1.05);
    box-shadow: 6px 6px 0px var(--futbol-green), -6px -6px 0px var(--futbol-yellow);
}

@keyframes floatUp {
    0% {
        transform: translate(-50%, 0) scale(0.3);
        opacity: 0;
    }

    20% {
        transform: translate(-50%, -30px) scale(1.4);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -100px) scale(1);
        opacity: 0;
    }
}

@keyframes overlayFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes titleBounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes scoreFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseSide {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.5));
    }
    50% {
        transform: scale(1.05);
        filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.8));
    }
}

/* Responsive Mobile */
@media (max-width: 768px) {
    .player-ui {
        top: 45px;
        width: 48%;
    }

    #ui-p1 {
        left: 5px;
    }

    #ui-p2 {
        right: 5px;
    }

    .score-board {
        font-size: clamp(1.2rem, 5vw, 2rem);
    }

    .combo-meter {
        font-size: clamp(0.7rem, 3vw, 1rem);
    }

    .lives-container {
        gap: 5px;
        font-size: clamp(0.9rem, 4vw, 1.3rem);
    }

    .heart {
        width: 20px !important;
        height: 20px !important;
    }

    #timer-display {
        font-size: clamp(1rem, 4vw, 1.4rem);
    }

    #timer-box {
        padding: 4px 12px;
    }

    #progress-bar-container {
        height: 40px;
    }

    #progress-p1::after {
        border-width: 25px 15px 0 0;
    }

    #progress-p2::before {
        border-width: 0 15px 25px 0;
    }

    .btn-start {
        padding: 18px 35px;
        font-size: clamp(1rem, 4vw, 1.3rem);
    }

    .ready-indicator {
        font-size: clamp(1rem, 4vw, 1.3rem);
    }

    .floating-text {
        font-size: clamp(1.5rem, 6vw, 2rem);
    }

    .game-over-overlay h2 {
        font-size: clamp(1.8rem, 8vw, 3rem);
        letter-spacing: 2px;
    }

    .game-over-overlay .final-score {
        font-size: clamp(1rem, 4vw, 1.3rem);
    }

    .btn-reset {
        padding: 14px 30px;
        font-size: clamp(1rem, 4vw, 1.2rem);
    }

    #control-panel {
        padding: 20px;
        max-width: 95%;
    }

    /* Tutorial responsive */
    .tutorial-title {
        font-size: clamp(1.5rem, 6vw, 2.5rem);
        margin-bottom: 30px;
    }

    .tutorial-instructions {
        gap: 25px;
        margin-bottom: 30px;
    }

    .tutorial-item {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .tutorial-icon-container {
        min-width: 80px;
        height: 80px;
    }

    .tutorial-icon {
        width: 70px;
        height: 70px;
    }

    .tutorial-text {
        text-align: center;
    }

    .tutorial-text p {
        font-size: clamp(0.9rem, 3vw, 1.2rem);
    }

    .tutorial-countdown {
        font-size: clamp(1rem, 3.5vw, 1.5rem);
    }

    #tutorial-timer {
        font-size: clamp(1.5rem, 6vw, 2.5rem);
        padding: 8px 20px;
    }
}

/* Responsive para pantallas muy pequeñas */
@media (max-width: 400px) {
    .player-ui {
        top: 35px;
    }

    .score-board {
        font-size: 1rem;
    }

    .lives-container {
        gap: 3px;
    }

    .heart {
        width: 16px !important;
        height: 16px !important;
    }

    #progress-bar-container {
        height: 20px;
    }

    #progress-p1::after {
        border-width: 20px 12px 0 0;
    }

    #progress-p2::before {
        border-width: 0 12px 20px 0;
    }

    #timer-box {
        top: 40px;
        padding: 3px 10px;
    }

    .btn-start {
        padding: 15px 25px;
        font-size: 0.9rem;
    }
}

/* Responsive para pantallas verticales (9:16) */
@media (max-aspect-ratio: 9/16) {
    .score-board {
        font-size: clamp(1.5rem, 6vw, 2.2rem);
    }

    .lives-container {
        font-size: clamp(1rem, 5vw, 1.5rem);
    }

    .heart {
        width: 24px !important;
        height: 24px !important;
    }

    .btn-start {
        padding: 20px 40px;
        font-size: clamp(1.1rem, 5vw, 1.4rem);
    }
}
