:root {
    --vermelho: #c8102e;
    --dourado: #f6c544;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: 'Nunito', system-ui, sans-serif;
    background: #0b1026;
    color: #fff;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
}

.sb-app { position: fixed; inset: 0; overflow: hidden; }

/* ---------- Imagem em tela cheia ---------- */
.sb-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #160f38;
    transition: opacity .45s ease;
}
.sb-bg.trocando { opacity: 0; }

.sb-scrim {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(to bottom, rgba(0,0,0,.38) 0%, rgba(0,0,0,0) 15%),
        linear-gradient(to top, rgba(0,0,0,.55) 0%, rgba(0,0,0,.08) 18%, rgba(0,0,0,0) 30%);
}

/* ---------- Topo ---------- */
.sb-top {
    position: absolute;
    top: 0; left: 0; right: 0;
    padding: calc(8px + env(safe-area-inset-top)) 12px 6px;
    z-index: 6;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sb-icon {
    flex: 0 0 auto;
    width: 36px; height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.42);
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    display: grid;
    place-items: center;
}
.sb-progress { flex: 1; display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.sb-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,.4);
    box-shadow: 0 1px 2px rgba(0,0,0,.4);
    transition: transform .25s, background .25s;
}
.sb-dot.feito { background: var(--dourado); }
.sb-dot.atual { background: #fff; transform: scale(1.5); }

/* ---------- Rodapé: botões nos cantos + legenda no meio ---------- */
.sb-bottombar {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 6;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 0 10px calc(8px + env(safe-area-inset-bottom));
}
.sb-grp { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; }
.sb-text {
    flex: 1 1 auto;
    margin: 0 0 4px;
    min-width: 0;
    background: rgba(10, 14, 32, .5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border-radius: 12px;
    padding: 7px 12px;
    font-size: clamp(11px, 1.9vw, 15px);
    line-height: 1.3;
    font-weight: 700;
    text-align: center;
}
.sb-text.aparece { animation: txtIn .4s ease; }
@keyframes txtIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.sb-btn {
    border: none;
    cursor: pointer;
    border-radius: 50%;
    background: rgba(255,255,255,.94);
    color: var(--vermelho);
    box-shadow: 0 4px 11px rgba(0,0,0,.45);
    display: grid;
    place-items: center;
    transition: transform .12s ease, opacity .2s;
    font-size: 17px;
    width: 44px; height: 44px;
}
.sb-btn:active { transform: scale(.9); }
.sb-btn[disabled] { opacity: .3; cursor: default; }
.sb-btn.grande { width: 52px; height: 52px; font-size: 21px; background: var(--dourado); color: #7a4a00; }
.sb-btn.grande.tocando { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 4px 11px rgba(0,0,0,.45); } 50% { box-shadow: 0 4px 20px rgba(246,197,68,.85); } }

/* ---------- Balão de fala (tela final) ---------- */
.sb-bubble {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) scale(.9);
    width: calc(100% - 60px);
    max-width: 460px;
    background: #fff;
    color: #222;
    padding: 16px 20px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 17px;
    text-align: center;
    box-shadow: 0 14px 32px rgba(0,0,0,.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 30;
}
.sb-bubble.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- Capa ---------- */
.sb-cover {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; padding: 20px;
    background:
        radial-gradient(circle at 50% 20%, rgba(246,197,68,.4), transparent 50%),
        linear-gradient(160deg, #4b2b8f, #1a0f3d);
    z-index: 20;
}
.sb-cover img { width: 90px; filter: drop-shadow(0 10px 24px rgba(0,0,0,.4)); animation: bob 4s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-10px) } }
.sb-cover .ep { margin-top: 10px; background: var(--vermelho); padding: 5px 16px; border-radius: 999px; font-weight: 800; font-size: 14px; }
.sb-cover h1 { font-family: 'Baloo 2', cursive; font-size: clamp(24px, 6vw, 44px); margin: 8px 0 4px; text-shadow: 0 4px 0 rgba(0,0,0,.25); }
.sb-cover .serie { opacity: .9; margin: 0 0 12px; font-size: 15px; }
.sb-cover .dica-girar {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,.14);
    border-radius: 999px; padding: 8px 16px; margin-bottom: 16px;
    font-size: 14px;
}
.sb-cover .dica-girar .gira { display: inline-block; animation: gira 2.2s ease-in-out infinite; }
@keyframes gira { 0%,40% { transform: rotate(0) } 60%,100% { transform: rotate(90deg) } }
.sb-start {
    border: none; cursor: pointer;
    background: var(--dourado); color: #7a4a00;
    font-family: 'Baloo 2', cursive;
    font-size: 20px; padding: 14px 32px; border-radius: 999px;
    box-shadow: 0 8px 0 #d6a325;
    animation: pulse 1.6s ease-in-out infinite;
}
.sb-start:active { transform: translateY(4px); box-shadow: 0 4px 0 #d6a325; }

/* ---------- Aviso de girar a tela ---------- */
.sb-girar {
    position: absolute; inset: 0;
    display: none; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; padding: 28px;
    background: linear-gradient(160deg, #4b2b8f, #140c30);
    z-index: 18;
}
.sb-girar .fone { font-size: 84px; animation: gira 2s ease-in-out infinite; }
.sb-girar p { font-size: 20px; font-weight: 800; max-width: 360px; margin: 18px 0 22px; }
.sb-girar button {
    border: none; cursor: pointer; background: rgba(255,255,255,.18);
    color: #fff; border: 2px solid rgba(255,255,255,.5);
    font-size: 15px; padding: 11px 22px; border-radius: 999px;
}
@media (orientation: portrait) {
    .sb-app:not(.girar-ok) .sb-girar { display: flex; }
}

/* ---------- Final / Medalha ---------- */
.sb-final {
    position: absolute; inset: 0;
    display: none; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; padding: 18px; z-index: 25;
    overflow-y: auto;
    background:
        radial-gradient(circle at 50% 35%, rgba(246,197,68,.5), transparent 60%),
        linear-gradient(160deg, #4b2b8f, #1a0f3d);
}
.sb-final.show { display: flex; }
.sb-medal { font-size: 72px; animation: medalPop .8s cubic-bezier(.2,1.4,.4,1) both; filter: drop-shadow(0 10px 20px rgba(0,0,0,.4)); }
@keyframes medalPop { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: scale(1) rotate(0); } }
.sb-final h2 { font-family: 'Baloo 2', cursive; font-size: clamp(22px,5vw,38px); margin: 6px 0 4px; }
.sb-final p { font-size: 16px; max-width: 460px; opacity: .95; margin: 0; }

.final-mascotes { margin: 16px 0 4px; }
.final-mascotes .titulo { font-weight: 800; font-size: 15px; opacity: .9; margin-bottom: 8px; }
.final-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.final-amigo {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: none; border: none; cursor: pointer; color: #fff; font-weight: 700; font-size: 12px;
}
.final-amigo .av {
    width: 74px; height: 74px; border-radius: 50%;
    border: 3px solid rgba(255,255,255,.85);
    background: rgba(255,255,255,.16);
    overflow: hidden; display: grid; place-items: center;
    transition: transform .15s;
    padding: 5px;
}
.final-amigo .av img {
    max-width: 100%; max-height: 100%;
    width: auto; height: auto;
    object-fit: contain; object-position: center;
    display: block; margin: auto;
}
.final-amigo:active .av { transform: scale(1.12); }
.final-amigo.falando .av { border-color: var(--dourado); animation: pulse 1.2s ease-in-out infinite; }

.sb-final .acoes { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }
.sb-final .acoes button, .sb-final .acoes a {
    text-decoration: none; border: none; cursor: pointer;
    font-family: 'Baloo 2', cursive; font-size: 16px;
    padding: 12px 22px; border-radius: 999px;
    background: var(--dourado); color: #7a4a00; box-shadow: 0 6px 0 #d6a325;
}
.sb-final .acoes .sec { background: rgba(255,255,255,.18); color: #fff; box-shadow: none; border: 2px solid rgba(255,255,255,.5); }

/* confete */
.confete { position: absolute; top: -20px; width: 11px; height: 16px; border-radius: 2px; opacity: .9; animation: cair linear forwards; z-index: 26; }
@keyframes cair { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }

/* ---------- ajustes ---------- */
@media (orientation: portrait) {
    .sb-text { font-size: clamp(11px, 3vw, 15px); }
}
@media (max-height: 430px) {
    .sb-final { justify-content: flex-start; padding-top: 12px; }
    .final-amigo .av { width: 60px; height: 60px; }
    .sb-medal { font-size: 54px; }
}
