* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: #1b4332; overflow: hidden; font-family: 'Fredoka', sans-serif; color: #fff; touch-action: none; user-select: none; }
body { display: flex; align-items: center; justify-content: center; }

#stage {
    position: relative; width: min(100vw, calc(100vh * 1.5)); aspect-ratio: 3 / 2;
    container-type: size; overflow: hidden; background: #2d6a4f;
}
#view { width: 100%; height: 100%; display: block; touch-action: none; }

.back-home, .mute-btn {
    position: fixed; top: 8px; z-index: 50; background: rgba(0,0,0,.45); color: #fff;
    border: 0; border-radius: 20px; padding: 6px 12px; font: 700 14px 'Fredoka', sans-serif; text-decoration: none; cursor: pointer;
}
.back-home { left: 8px; }
.mute-btn { right: 8px; }

/* HUD */
.hud {
    position: absolute; left: 1.5cqw; right: 1.5cqw; top: 1.2cqw; display: none; gap: 1cqw;
    align-items: flex-start; pointer-events: none; z-index: 4;
}
.hud.show { display: flex; }
.hud-box {
    background: rgba(0,0,0,.45); border-radius: 1.2cqw; padding: .4cqw 1.4cqw; text-align: center;
    font-family: 'Lilita One', sans-serif; line-height: 1.1; min-width: 9cqw;
}
.hud-box small { display: block; font-size: 1.3cqw; opacity: .85; font-family: 'Fredoka', sans-serif; }
.hud-box b { font-size: 2.6cqw; font-weight: 400; }
.hud-goal { flex: 1; }
.bar { height: 1cqw; background: rgba(255,255,255,.25); border-radius: 1cqw; margin-top: .4cqw; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd60a, #ff6b35); transition: width .2s; }
.hud-btns { margin-left: auto; pointer-events: auto; }
.hud-btns button {
    width: 4.6cqw; height: 4.6cqw; border-radius: 50%; border: 0; background: rgba(0,0,0,.5);
    color: #fff; font-size: 2.2cqw; cursor: pointer;
}

/* Aviso de nivel */
.intro { position: absolute; left: 0; right: 0; top: 36%; text-align: center; pointer-events: none; display: none; z-index: 3; }
.intro.show { display: block; animation: pop 2.2s ease both; }
.intro h2 { font: 400 7cqw 'Lilita One', sans-serif; text-shadow: 0 .5cqw 0 rgba(0,0,0,.35), 0 0 2cqw rgba(0,0,0,.4); }
.intro p { font: 700 2.4cqw 'Fredoka', sans-serif; text-shadow: 0 .2cqw .6cqw rgba(0,0,0,.7); margin-top: .8cqw; }
@keyframes pop {
    0% { opacity: 0; transform: scale(.7); }
    15% { opacity: 1; transform: scale(1.05); }
    25% { transform: scale(1); }
    85% { opacity: 1; }
    100% { opacity: 0; }
}

/* Overlays */
.overlay {
    position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
    gap: 2cqw; z-index: 6; text-align: center; padding: 3cqw;
    background: radial-gradient(circle at 50% 40%, rgba(64,145,108,.94), rgba(16,50,36,.97));
}
.overlay.show { display: flex; }
.logo-small { font: 700 2cqw 'Fredoka', sans-serif; letter-spacing: .3cqw; color: #fffc; }
.logo h1 {
    font: 400 9cqw 'Lilita One', sans-serif; line-height: 1; color: #fff;
    text-shadow: 0 .6cqw 0 #1b4332, 0 1.2cqw 2cqw rgba(0,0,0,.4); -webkit-text-stroke: .25cqw #0b2419;
}
.logo h1 span { color: #ffd60a; }
.title-tags { font-size: 5cqw; display: flex; gap: 2cqw; }
.title-tags span { animation: bob 1.6s ease-in-out infinite; }
.title-tags span:nth-child(2) { animation-delay: .2s; }
.title-tags span:nth-child(3) { animation-delay: .4s; }
.title-tags span:nth-child(4) { animation-delay: .6s; }
@keyframes bob { 50% { transform: translateY(-1.2cqw); } }
.help, .end-text { font-size: 1.8cqw; opacity: .92; max-width: 80cqw; line-height: 1.4; }
.sel-title { font: 400 5cqw 'Lilita One', sans-serif; text-shadow: 0 .4cqw 0 rgba(0,0,0,.3); }
.end-btns { display: flex; flex-direction: column; align-items: center; gap: 1.4cqw; }

.big-btn {
    font: 400 4cqw 'Lilita One', sans-serif; color: #fff; cursor: pointer;
    background: linear-gradient(#80ed99, #2d6a4f); border: .35cqw solid #fff; border-radius: 3cqw;
    padding: 1.2cqw 5cqw; box-shadow: 0 .8cqw 0 #1b4332;
}
.big-btn:active { transform: translateY(.5cqw); box-shadow: 0 .3cqw 0 #1b4332; }
.small-btn {
    font: 700 2.2cqw 'Fredoka', sans-serif; color: #fff; cursor: pointer;
    background: rgba(255,255,255,.18); border: .2cqw solid rgba(255,255,255,.7); border-radius: 2cqw; padding: .8cqw 2.6cqw;
}

/* Controles táctiles */
.dpad {
    position: absolute; right: 2cqw; bottom: 2cqw; display: none; z-index: 5;
    grid-template-columns: repeat(3, 7cqw); grid-template-rows: repeat(3, 7cqw); gap: .6cqw;
    grid-template-areas: ". up ." "left . right" ". down .";
}
.dpad button {
    background: rgba(0,0,0,.4); color: #fff; border: 0; border-radius: 2cqw;
    font-size: 3cqw; touch-action: none; cursor: pointer;
}
.dpad [data-dir="up"] { grid-area: up; }
.dpad [data-dir="left"] { grid-area: left; }
.dpad [data-dir="right"] { grid-area: right; }
.dpad [data-dir="down"] { grid-area: down; }
@media (pointer: coarse) { .dpad { display: grid; } }

#rotate-hint {
    position: fixed; inset: 0; z-index: 100; display: none; flex-direction: column;
    align-items: center; justify-content: center; gap: 10px; background: #1b4332; text-align: center;
}
@media (orientation: portrait) and (pointer: coarse) { #rotate-hint { display: flex; } }
