.game-header {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: start;
    gap: 12px;
    z-index: 20;
    pointer-events: none;
}

.game-header > * {
    pointer-events: auto;
}

.back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #2F3542;
    font-size: 1.2rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    backdrop-filter: blur(5px);
    transition: all 0.3s;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
}

.back-button > * {
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.back-button:active {
    transform: scale(0.95);
}

.back-button.disabled {
    opacity: 0.8;
    background: rgba(220, 220, 220, 0.4);
    color: #747d8c;
    box-shadow: none;
}

.back-button.back-ready-glow {
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.12), 0 0 20px rgba(34, 197, 94, 0.35);
    animation: back-ready-glow 2.4s ease-in-out infinite;
}

.back-button.back-ready-flash {
    animation: back-ready-flash 0.9s ease-in-out 2;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.16), 0 0 24px rgba(34, 197, 94, 0.45);
}

@keyframes back-ready-glow {
    0%,
    100% {
        box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.1), 0 0 18px rgba(34, 197, 94, 0.28);
    }

    50% {
        box-shadow: 0 0 0 7px rgba(34, 197, 94, 0.16), 0 0 26px rgba(34, 197, 94, 0.42);
    }
}

@keyframes back-ready-flash {
    0%,
    100% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.08);
    }
}

.game-header .back-button {
    position: static;
    justify-self: start;
}

.game-header .wallet-display {
    grid-column: 2;
    justify-self: center;
}

.game-header .score-display,
.game-header .score-container {
    grid-column: 3;
    position: static;
    justify-self: end;
    align-self: start;
    max-width: min(42vw, 270px);
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-content: flex-start;
    overflow: visible;
}

.wallet-display {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: 'Fredoka One', 'Nunito', cursive;
    font-size: 1.4rem;
    line-height: 1;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 50px;
    padding: 8px 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(249, 202, 36, 0.5);
    color: #2F3542;
    backdrop-filter: blur(8px);
}

.wallet-coin {
    position: relative;
    display: inline-block;
    width: 1.02em;
    height: 1.12em;
    flex: 0 0 auto;
    border-radius: 50%;
    background:
        linear-gradient(90deg, rgba(255, 220, 92, 0.45) 0 10%, transparent 11% 100%),
        radial-gradient(ellipse at 38% 22%, #ffe66d 0 12%, transparent 13%),
        linear-gradient(90deg, #e88900 0%, #ffd23a 18%, #f6b51d 42%, #df8500 72%, #8f4b00 100%);
    border: 0.07em solid #ffd75a;
    box-shadow:
        inset -0.12em 0 0 rgba(126, 67, 0, 0.5),
        inset 0.12em 0 0 rgba(255, 226, 87, 0.42),
        0 0.08em 0.18em rgba(122, 72, 0, 0.28);
}

.wallet-coin::after {
    content: '';
    position: absolute;
    top: 16%;
    bottom: 16%;
    left: 36%;
    width: 20%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(140, 72, 0, 0.54), rgba(255, 214, 67, 0.72), rgba(126, 65, 0, 0.48));
    box-shadow:
        -0.16em 0 0 rgba(255, 212, 60, 0.18),
        0.18em 0 0 rgba(123, 64, 0, 0.2);
}

@keyframes coin-spin {
    0%, 100% { transform: rotateY(0deg) scale(1); }
    50% { transform: rotateY(82deg) scale(1.06); }
}

.coin-anim {
    position: fixed;
    width: 56px;
    height: 62px;
    line-height: 1;
    pointer-events: none;
    z-index: 9999;
    transition: transform 0.45s cubic-bezier(0.34, 1.2, 0.64, 1), opacity 0.28s;
    will-change: transform, opacity;
}

.coin-anim .coin-face {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background:
        linear-gradient(90deg, rgba(255, 220, 92, 0.5) 0 9%, transparent 10% 100%),
        radial-gradient(ellipse at 36% 20%, rgba(255, 230, 109, 0.9) 0 12%, transparent 13%),
        linear-gradient(90deg, #e88900 0%, #ffd43b 18%, #f4b61f 43%, #df8500 72%, #8f4b00 100%);
    border: 4px solid #ffd85f;
    box-shadow:
        inset -8px 0 0 rgba(128, 68, 0, 0.48),
        inset 7px 0 0 rgba(255, 222, 77, 0.35),
        0 8px 15px rgba(112, 67, 0, 0.28);
    animation: coin-spin 0.96s ease-in-out 2;
    transform-style: preserve-3d;
}

.coin-anim .coin-face::after {
    content: '';
    position: absolute;
    top: 14%;
    bottom: 14%;
    left: 35%;
    width: 22%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(137, 70, 0, 0.6), rgba(255, 213, 58, 0.82), rgba(126, 64, 0, 0.54));
    box-shadow:
        -8px 0 0 rgba(255, 208, 42, 0.22),
        9px 0 0 rgba(117, 61, 0, 0.22);
}

.coin-anim.penalty-coin .coin-face {
    background:
        linear-gradient(90deg, rgba(255, 150, 150, 0.48) 0 9%, transparent 10% 100%),
        radial-gradient(ellipse at 36% 20%, rgba(255, 180, 180, 0.82) 0 12%, transparent 13%),
        linear-gradient(90deg, #8f1010 0%, #ff5a5a 18%, #e22f2f 43%, #b91515 72%, #650606 100%);
    border-color: #ff8a8a;
    box-shadow:
        inset -8px 0 0 rgba(90, 0, 0, 0.5),
        inset 7px 0 0 rgba(255, 120, 120, 0.34),
        0 8px 15px rgba(80, 0, 0, 0.26);
}

.coin-anim.penalty-coin .coin-face::after {
    background: linear-gradient(90deg, rgba(80, 0, 0, 0.62), rgba(255, 120, 120, 0.78), rgba(80, 0, 0, 0.54));
    box-shadow:
        -8px 0 0 rgba(255, 110, 110, 0.2),
        9px 0 0 rgba(80, 0, 0, 0.24);
}

.coin-earn-label {
    position: fixed;
    font-family: 'Fredoka One', 'Nunito', cursive;
    font-size: 1.75rem;
    color: #ffd43b;
    -webkit-text-stroke: 1px rgba(122, 72, 0, 0.45);
    text-shadow: 0 3px 5px rgba(0, 0, 0, 0.28);
    pointer-events: none;
    z-index: 9999;
    transform: scale(0);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.coin-earn-label.penalty-label {
    color: #ff4d4d;
    -webkit-text-stroke: 1px rgba(94, 0, 0, 0.55);
    text-shadow: 0 3px 5px rgba(80, 0, 0, 0.32);
}

.wallet-bounce {
    animation: wallet-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.app-version {
    position: fixed;
    right: 10px;
    bottom: 8px;
    z-index: 20;
    font-family: 'Nunito', sans-serif;
    font-size: 0.72rem;
    font-weight: 800;
    color: rgba(47, 53, 66, 0.5);
    background: rgba(255, 255, 255, 0.42);
    border: 1px solid rgba(255, 255, 255, 0.38);
    border-radius: 999px;
    backdrop-filter: blur(6px);
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    cursor: default;
    padding: 6px 12px;
}

/* Panel secreto de ajustes para adultos */
.pp-overlay { position: fixed; inset: 0; z-index: 9999; background: rgba(20, 25, 32, 0.42); font-family: 'Nunito', sans-serif; overflow: hidden; }
.pp-overlay[hidden] { display: none; }
.pp-panel { width: min(100%, 760px); height: 100%; margin: 0 auto; background: #fff; color: #25303b; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pp-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #dfe4ea; background: #fff; }
.pp-header h2 { margin: 0; font: 800 1.35rem/1.2 'Nunito', sans-serif; }
.pp-close { border: 0; background: transparent; color: #394653; font: 700 0.95rem/1 'Nunito', sans-serif; padding: 10px; cursor: pointer; }
.pp-body { padding: 8px 20px 40px; }
.pp-section { padding: 18px 0; border-bottom: 1px solid #e8ebef; }
.pp-section h3 { margin: 0 0 12px; font: 800 1rem/1.2 'Nunito', sans-serif; color: #25303b; }
.pp-section-heading { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.pp-game-count, .pp-balance, .pp-min-note { font-size: 0.84rem; color: #677482; }
.pp-games { border: 1px solid #e2e6ea; border-radius: 10px; overflow: hidden; }
.pp-toggle-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 44px; padding: 8px 10px; border-bottom: 1px solid #edf0f2; font-size: 0.92rem; }
.pp-toggle-row:last-child { border-bottom: 0; }
.pp-toggle-row small { display: block; margin-top: 3px; color: #768390; font-size: 0.78rem; }
.pp-toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.pp-switch { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #aeb7c0; transition: background 0.15s ease; }
.pp-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.22); transition: transform 0.15s ease; }
.pp-toggle-row input:checked + .pp-switch { background: #2676d9; }
.pp-toggle-row input:checked + .pp-switch::after { transform: translateX(16px); }
.pp-toggle-row input:disabled + .pp-switch { opacity: .48; }
.pp-min-note { margin: 8px 0 0; color: #a14735; }
.pp-inline, .pp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pp-coins-input { width: 120px; border: 1px solid #b9c2cb; border-radius: 7px; padding: 9px 10px; font: 700 1rem 'Nunito', sans-serif; }
.pp-primary, .pp-secondary { min-height: 38px; border-radius: 7px; padding: 8px 13px; font: 700 .88rem 'Nunito', sans-serif; cursor: pointer; }
.pp-primary { border: 1px solid #1768ca; background: #1768ca; color: #fff; }
.pp-secondary { border: 1px solid #b7c0c9; background: #fff; color: #34414d; }
.pp-routine { margin-bottom: 12px; border: 1px solid #e2e6ea; border-radius: 8px; }
.pp-routine-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 10px; border-bottom: 1px solid #edf0f2; font-size: .86rem; }
.pp-routine-row:last-child { border-bottom: 0; }
.pp-routine-row strong { color: #596674; }
body.pp-open { overflow: hidden; }

@keyframes wallet-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

@media (max-width: 520px) {
    .game-header {
        top: 10px;
        left: 10px;
        right: 10px;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        gap: 8px;
    }

    .game-header .score-display,
    .game-header .score-container {
        max-width: 34vw;
    }

    .wallet-display {
        font-size: 1rem;
        padding: 7px 10px;
    }
}

@media (max-width: 380px) {
    .game-header {
        gap: 6px;
    }

    .wallet-display {
        font-size: 0.95rem;
        padding: 6px 8px;
    }
}
