/* ═══════════════════════════════════════════════
   BALLOON POP — odd/even balloon-popping game
═══════════════════════════════════════════════ */
.pop-page {
    background: linear-gradient(160deg, #e0f2fe 0%, #fce7f3 100%);
    min-height: calc(100vh - 250px);
    padding: 40px 0 60px;
}
.pop-shell {
    max-width: 640px;
    margin: 0 auto;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, .12);
    padding: 28px 24px 32px;
}
.pop-title {
    text-align: center;
    font-weight: 800;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    color: #1e293b;
    margin-bottom: 4px;
}
.pop-subtitle {
    text-align: center;
    color: #64748b;
    font-size: 1rem;
    margin-bottom: 24px;
}
.pop-screen { display: none; }
.pop-screen.active { display: block; animation: pop-fade .25s ease; }
@keyframes pop-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Setup screen ── */
.pop-step-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: #334155;
    margin: 18px 0 10px;
}
.pop-category-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.pop-category-btn {
    border: 3px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 18px;
    padding: 26px 10px;
    font-weight: 800;
    font-size: 1.3rem;
    color: #334155;
    cursor: pointer;
    transition: transform .15s, border-color .15s, background .15s;
    text-align: center;
}
.pop-category-btn .pop-category-icon { display: block; font-size: 2.2rem; margin-bottom: 8px; }
.pop-category-btn:hover { transform: translateY(-2px); }
.pop-category-btn.pop-category-even.selected {
    border-color: #22c55e;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: #15803d;
    transform: translateY(-2px);
}
.pop-category-btn.pop-category-odd.selected {
    border-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    color: #b91c1c;
    transform: translateY(-2px);
}
.pop-instruction {
    text-align: center;
    font-weight: 700;
    color: #6366f1;
    margin-top: 14px;
    min-height: 1.4em;
}
.pop-nickname {
    width: 100%;
    border: 3px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b;
}
.pop-nickname:focus { outline: none; border-color: #a5b4fc; }
.pop-btn-primary {
    width: 100%;
    margin-top: 24px;
    border: none;
    border-radius: 16px;
    padding: 16px;
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 8px 20px rgba(22,163,74,.3);
    cursor: pointer;
    transition: transform .15s, opacity .15s;
}
.pop-btn-primary:hover:not(:disabled) { transform: translateY(-2px); }
.pop-btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ── Play screen ── */
.pop-instruction-banner {
    text-align: center;
    font-weight: 800;
    font-size: 1.05rem;
    color: #4338ca;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border-radius: 14px;
    padding: 10px 14px;
    margin-bottom: 16px;
}
.pop-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.pop-stat { text-align: center; flex: 1; min-width: 70px; }
.pop-stat .pop-stat-num { font-weight: 800; font-size: 1.5rem; line-height: 1; }
.pop-stat-correct .pop-stat-num { color: #16a34a; }
.pop-stat-incorrect .pop-stat-num { color: #dc2626; }
.pop-stat .pop-stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; font-weight: 700; }
.pop-timer-wrap { flex: 1.2; min-width: 100px; }
.pop-timer-bar {
    height: 14px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
    margin-bottom: 4px;
}
.pop-timer-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    transition: width 1s linear, background .3s;
    width: 100%;
}
.pop-timer-fill.pop-warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.pop-timer-fill.pop-danger { background: linear-gradient(90deg, #dc2626, #f87171); }
.pop-timer-num { text-align: center; font-weight: 800; font-size: 1rem; color: #334155; }

.pop-play-area {
    position: relative;
    height: min(70vh, 520px);
    min-height: 360px;
    border-radius: 20px;
    overflow: hidden;
    background: linear-gradient(180deg, #bae6fd 0%, #e0f2fe 60%, #f0f9ff 100%);
    box-shadow: inset 0 0 0 3px #e0f2fe;
    touch-action: manipulation;
}

.pop-balloon {
    position: absolute;
    width: clamp(56px, 15vw, 78px);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.pop-balloon-sway {
    animation: pop-sway 2.6s ease-in-out infinite;
}
@keyframes pop-sway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(var(--pop-sway-amount, 10px)); }
}
.pop-balloon-body {
    position: relative;
    width: 100%;
    aspect-ratio: 0.85;
    border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
    background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.55), transparent 45%), var(--balloon-color, #f472b6);
    box-shadow: 0 6px 14px rgba(15,23,42,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: clamp(1rem, 3.6vw, 1.3rem);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.pop-balloon-body::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -7px;
    width: 0;
    height: 0;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid var(--balloon-color, #f472b6);
}
.pop-balloon-string {
    width: 2px;
    height: 22px;
    background: #94a3b8;
    margin: 0 auto;
}

.pop-balloon.pop-popping { pointer-events: none; }
.pop-balloon.pop-popping .pop-balloon-body {
    animation: pop-shrink .28s ease forwards;
}
@keyframes pop-shrink {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(.2); opacity: 0; }
}

.pop-burst {
    position: absolute;
    width: 64px;
    height: 64px;
    margin-left: -32px;
    margin-top: -32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
    pointer-events: none;
    animation: pop-burst-pop .5s ease forwards;
}
.pop-burst.pop-burst-correct { background: radial-gradient(circle, #22c55e, #16a34a); }
.pop-burst.pop-burst-incorrect { background: radial-gradient(circle, #ef4444, #dc2626); }
@keyframes pop-burst-pop {
    0% { transform: scale(.3); opacity: 0; }
    35% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* ── End screen ── */
.pop-stars {
    text-align: center;
    font-size: 2.6rem;
    letter-spacing: 6px;
    margin: 6px 0 18px;
    color: #e2e8f0;
}
.pop-stars .pop-star-on { color: #fbbf24; }
.pop-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 6px;
}
.pop-summary-item {
    text-align: center;
    background: #f8fafc;
    border-radius: 14px;
    padding: 16px 6px;
}
.pop-summary-item .pop-summary-num { font-weight: 800; font-size: 1.5rem; color: #1e293b; }
.pop-summary-item .pop-summary-label { font-size: .72rem; color: #94a3b8; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.pop-log-wrap { margin-top: 18px; }
.pop-log-list {
    max-height: 220px;
    overflow-y: auto;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 6px 10px;
}
.pop-log-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 4px;
    font-weight: 700;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}
.pop-log-row:last-child { border-bottom: none; }
.pop-log-num { font-size: 1.05rem; }
.pop-log-verdict { font-size: .82rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; }
.pop-log-verdict.pop-log-correct { background: #dcfce7; color: #166534; }
.pop-log-verdict.pop-log-incorrect { background: #fee2e2; color: #991b1b; }
.pop-log-empty { text-align: center; color: #94a3b8; font-weight: 600; padding: 14px 0; }

.pop-leaderboard-link { text-align: center; margin-top: 14px; }
.pop-leaderboard-link a { color: #4f46e5; font-weight: 700; text-decoration: none; }
.pop-leaderboard-link a:hover { text-decoration: underline; }

.pop-error-banner {
    background: #fef2f2;
    border: 2px solid #fecaca;
    color: #991b1b;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 600;
    font-size: .9rem;
    margin-bottom: 16px;
    display: none;
}
.pop-error-banner.active { display: block; }

/* ── Leaderboard page ── */
.pop-lb-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.pop-lb-filters select {
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 600;
    color: #334155;
}
.pop-lb-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.pop-lb-table tr { background: #f8fafc; }
.pop-lb-table td { padding: 12px 14px; font-weight: 600; color: #334155; }
.pop-lb-table td:first-child { border-radius: 12px 0 0 12px; font-weight: 800; color: #6366f1; }
.pop-lb-table td:last-child { border-radius: 0 12px 12px 0; text-align: right; }
.pop-lb-empty { text-align: center; color: #94a3b8; padding: 30px 0; font-weight: 600; }

@media (max-width: 480px) {
    .pop-shell { padding: 22px 16px 26px; border-radius: 18px; }
    .pop-category-btn { padding: 20px 8px; font-size: 1.1rem; }
}

/* ── Fullscreen mobile play (see base.css body.game-page rules) ── */
@media (max-width: 991.98px) {
    body.game-page .pop-page { min-height: 100dvh; padding: 0; }
    body.game-page .pop-page .container { max-width: none; padding: 0; }
    body.game-page .pop-shell {
        max-width: none;
        min-height: 100dvh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        padding: 54px 16px 16px;
        display: flex;
        flex-direction: column;
    }
    body.game-page .pop-subtitle { display: none; }
    body.game-page .pop-screen.active {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        justify-content: center;
    }
    body.game-page .pop-play-area { flex: 1; min-height: 0; height: auto; }
}
