* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: 'Fredoka', 'Comic Sans MS', system-ui, sans-serif;
    background: linear-gradient(180deg, #7ecff0 0%, #a8e3ff 50%, #c6f0ff 100%);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#app {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 4 / 3;
    max-height: 100vh;
}

#game {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 50, 100, 0.25);
    image-rendering: -webkit-optimize-contrast;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
    position: absolute;
    inset: 0;
    padding: 14px 20px;
    pointer-events: none;
    color: white;
    text-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.score-box, .distance-box {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 14px;
    padding: 6px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    font-weight: 700;
    border: 2px solid rgba(255,255,255,0.4);
}

.score-box .label, .distance-box .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}

.score-box span:last-child, .distance-box span:last-child {
    font-size: 22px;
}

.air-bar-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.air-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.air-bar-bg {
    flex: 1;
    height: 18px;
    background: rgba(0, 30, 60, 0.35);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.5);
}

.air-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff6b6b 0%, #ffd93d 40%, #6bffb5 100%);
    border-radius: 8px;
    transition: width 0.1s linear;
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.4);
}

/* ---------- Overlays (menú y game over) ---------- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    text-align: center;
    background: rgba(135, 206, 235, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 16px;
    color: white;
}

.title {
    font-size: clamp(40px, 8vw, 72px);
    font-weight: 700;
    color: #fff;
    text-shadow:
        0 4px 0 #ff6fa3,
        0 6px 20px rgba(0,0,0,0.3),
        -3px -3px 0 #fff;
    margin-bottom: 10px;
    animation: floaty 3s ease-in-out infinite;
    letter-spacing: 1px;
}

.wiggle {
    display: inline-block;
    color: #ffe066;
    text-shadow:
        0 4px 0 #ff6fa3,
        0 6px 20px rgba(0,0,0,0.3);
    animation: wiggle 2s ease-in-out infinite;
}

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

@keyframes wiggle {
    0%, 100% { transform: rotate(-3deg); }
    50% { transform: rotate(3deg); }
}

.subtitle {
    font-size: clamp(16px, 2.5vw, 20px);
    margin-bottom: 24px;
    text-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-weight: 500;
}

.difficulty {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.difficulty .label {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
    opacity: 0.9;
}

.diff-buttons {
    display: flex;
    gap: 8px;
}

.diff-btn {
    padding: 10px 18px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    border: 3px solid white;
    background: rgba(255,255,255,0.2);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s, background 0.15s;
    min-height: 44px;
}

.diff-btn:hover { transform: translateY(-2px); }
.diff-btn.active {
    background: white;
    color: #ff6fa3;
    box-shadow: 0 4px 0 #ff6fa3, 0 6px 20px rgba(0,0,0,0.2);
}

.big-btn {
    padding: 16px 40px;
    font-family: inherit;
    font-size: 28px;
    font-weight: 700;
    color: white;
    background: linear-gradient(180deg, #ff8ab8 0%, #ff6fa3 100%);
    border: 4px solid white;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #d94a7f, 0 10px 30px rgba(0,0,0,0.25);
    transition: transform 0.12s, box-shadow 0.12s;
    animation: pulse 1.6s ease-in-out infinite;
    min-height: 60px;
    margin: 10px;
}

.big-btn:hover { transform: translateY(-3px); }
.big-btn:active {
    transform: translateY(3px);
    box-shadow: 0 2px 0 #d94a7f, 0 4px 15px rgba(0,0,0,0.2);
}

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

.small-btn {
    padding: 10px 24px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    color: #ff6fa3;
    background: white;
    border: 3px solid white;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.15);
    min-height: 44px;
}

.menu-footer {
    margin-top: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.high-score-box {
    background: rgba(255, 255, 255, 0.25);
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 14px;
    padding: 8px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: 700;
}

.high-score-box .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.9;
}

.high-score-box span:last-child {
    font-size: 22px;
    color: #ffe066;
}

.mute-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid white;
    background: rgba(255,255,255,0.2);
    font-size: 20px;
    cursor: pointer;
    pointer-events: auto;
}

.hint {
    margin-top: 18px;
    font-size: 13px;
    opacity: 0.85;
    font-weight: 500;
}

/* ---------- Game Over ---------- */
.go-title {
    font-size: clamp(36px, 7vw, 60px);
    color: #fff;
    text-shadow: 0 4px 0 #d94a7f, 0 6px 20px rgba(0,0,0,0.3);
    margin-bottom: 6px;
}

#go-reason {
    font-size: 18px;
    margin-bottom: 18px;
    font-weight: 500;
}

.go-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
}

.stat {
    background: rgba(255,255,255,0.25);
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 14px;
    padding: 10px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-weight: 700;
}

.stat .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat span:last-child {
    font-size: 26px;
    color: #ffe066;
}

.new-record {
    font-size: 22px;
    font-weight: 700;
    color: #ffe066;
    margin-bottom: 12px;
    animation: pulse 1s ease-in-out infinite;
    text-shadow: 0 3px 0 #ff6fa3, 0 5px 15px rgba(0,0,0,0.3);
}

/* ---------- Powers bar (in-game) ---------- */
.powers-bar {
    position: absolute;
    left: 20px;
    bottom: 20px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.power-btn {
    width: 62px;
    height: 62px;
    border-radius: 16px;
    border: 3px solid white;
    background: rgba(255,255,255,0.22);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: white;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 4px 0 rgba(0,0,0,0.25), 0 6px 20px rgba(0,0,0,0.2);
    transition: transform 0.12s;
}

.power-btn:hover { transform: translateY(-3px); }
.power-btn:active { transform: translateY(2px); }

.power-btn.empty {
    opacity: 0.35;
    cursor: not-allowed;
}

.power-btn .icon {
    font-size: 26px;
    line-height: 1;
}

.power-btn .count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff6fa3;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.power-btn .key {
    position: absolute;
    bottom: 2px;
    left: 4px;
    font-size: 10px;
    opacity: 0.9;
}

.power-btn.active {
    background: rgba(255,230,100,0.55);
    border-color: #ffe066;
    animation: powerPulse 0.7s ease-in-out infinite;
}

@keyframes powerPulse {
    0%, 100% { box-shadow: 0 4px 0 rgba(0,0,0,0.25), 0 0 0 rgba(255,230,100,0.6); }
    50% { box-shadow: 0 4px 0 rgba(0,0,0,0.25), 0 0 30px rgba(255,230,100,0.9); }
}

.power-toast {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.55);
    color: white;
    padding: 14px 28px;
    border-radius: 40px;
    font-size: 24px;
    font-weight: 700;
    border: 3px solid white;
    box-shadow: 0 6px 30px rgba(0,0,0,0.4);
    pointer-events: none;
    animation: toastIn 0.3s ease-out;
    white-space: nowrap;
}

@keyframes toastIn {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ---------- Shop ---------- */
.wallet-box span:last-child { color: #ffe066; }

.shop-btn-menu {
    margin-top: 8px;
    background: linear-gradient(180deg, #ffe066 0%, #ffc83d 100%);
    color: #7a4a00;
    border: 3px solid white;
    box-shadow: 0 4px 0 #b38600, 0 6px 20px rgba(0,0,0,0.2);
    font-size: 18px;
    padding: 12px 26px;
}

.wallet-display {
    background: rgba(255,255,255,0.25);
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 14px;
    padding: 8px 20px;
    margin-bottom: 18px;
    font-weight: 700;
    display: flex;
    gap: 10px;
    align-items: center;
}

.wallet-display .label { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; }
.wallet-display span:last-child { color: #ffe066; font-size: 26px; }

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 560px;
    margin-bottom: 14px;
}

.shop-item {
    background: rgba(255,255,255,0.22);
    border: 3px solid white;
    border-radius: 16px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: white;
    font-weight: 700;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2);
}

.shop-item .icon { font-size: 34px; line-height: 1; }
.shop-item .name { font-size: 14px; }
.shop-item .desc { font-size: 10px; font-weight: 500; opacity: 0.9; text-align: center; min-height: 24px; }
.shop-item .owned { font-size: 11px; color: #ffe066; }

.buy-btn {
    background: #ff6fa3;
    color: white;
    border: 2px solid white;
    border-radius: 20px;
    padding: 6px 14px;
    font-family: inherit;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 3px 0 #c93a6d;
    margin-top: 4px;
}

.buy-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c93a6d; }
.buy-btn:disabled {
    background: #888;
    box-shadow: 0 3px 0 #555;
    cursor: not-allowed;
}

.coins-earned {
    font-size: 16px;
    color: #ffe066;
    font-weight: 700;
    margin-bottom: 10px;
}

@media (max-width: 480px) {
    .power-btn { width: 52px; height: 52px; }
    .power-btn .icon { font-size: 22px; }
    .powers-bar { left: 10px; bottom: 10px; gap: 6px; }
    .title { margin-bottom: 4px; }
    .big-btn { font-size: 22px; padding: 14px 32px; }
    .go-stats { gap: 12px; }
    .stat { padding: 8px 16px; }
    .shop-grid { grid-template-columns: repeat(2, 1fr); }
}
