/* ═══════════════════════════════════════════════════════════
   BRACKET BINGO TUTORIAL (bb-tutorial.js)
   Jackbox Party Pack–inspired motion-graphics style
   ═══════════════════════════════════════════════════════════ */

/* --- Overlay --- */
.bbt-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: linear-gradient(135deg, #0c0a1d 0%, #1a1145 40%, #0c0a1d 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden;
}

/* Animated dot-grid background (Jackbox style) */
.bbt-overlay::before {
    content: '';
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    background-image:
        radial-gradient(circle, rgba(139, 92, 246, 0.08) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: bbtGridDrift 20s linear infinite;
    pointer-events: none;
}

@keyframes bbtGridDrift {
    from { transform: translate(0, 0) rotate(0deg); }
    to   { transform: translate(40px, 40px) rotate(3deg); }
}

/* Subtle floating glow orbs */
.bbt-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(236, 72, 153, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(251, 191, 36, 0.06) 0%, transparent 40%);
    pointer-events: none;
    animation: bbtGlowPulse 6s ease-in-out infinite alternate;
}

@keyframes bbtGlowPulse {
    from { opacity: 0.7; }
    to   { opacity: 1; }
}

.bbt-overlay.bbt-visible {
    opacity: 1;
}

/* --- Close button --- */
.bbt-close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
    font-size: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.bbt-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: rotate(90deg);
}

/* --- Modal mode --- */
.bbt-overlay.bbt-modal-mode {
    background: none;
}

.bbt-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
}

.bbt-modal-container {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    background: linear-gradient(135deg, #0c0a1d 0%, #1a1145 40%, #0c0a1d 100%);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.5),
        0 0 60px rgba(102, 126, 234, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.2);
    z-index: 1;
    aspect-ratio: 16 / 10;
}

.bbt-modal-container .bbt-close-btn {
    top: 0.75rem;
    right: 0.75rem;
    width: 36px;
    height: 36px;
    font-size: 1.5rem;
}

.bbt-modal-container .bbt-stage { padding: 1.5rem; }
.bbt-modal-container .bbt-subtitle-bar { padding: 0 1.5rem 1rem; min-height: 60px; }
.bbt-modal-container .bbt-subtitle-text { font-size: 1rem; }
.bbt-modal-container .bbt-play-btn { padding: 1.5rem 2.5rem; font-size: 1rem; border-radius: 18px; }
.bbt-modal-container .bbt-play-btn svg { width: 36px; height: 36px; }
.bbt-modal-container .bbt-heading { font-size: 1.6rem; }
.bbt-modal-container .bbt-title-text { font-size: 3.5rem; }

/* --- Stage --- */
.bbt-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 900px;
    padding: 2rem;
    transition: opacity 0.2s ease, transform 0.2s ease;
    position: relative;
    z-index: 1;
}

.bbt-stage.bbt-fade-out {
    opacity: 0;
    transform: scale(0.96);
}

.bbt-stage.bbt-fade-in {
    animation: bbtFadeIn 0.4s ease both;
}

@keyframes bbtFadeIn {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Subtitle bar --- */
.bbt-subtitle-bar {
    width: 100%;
    max-width: 800px;
    min-height: 80px;
    padding: 0 2rem 1.5rem;
    text-align: center;
    position: relative;
    z-index: 1;
}

.bbt-subtitle-text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.15rem;
    line-height: 1.5;
    transition: opacity 0.25s ease;
    margin: 0;
}

/* --- Progress bar --- */
.bbt-progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    z-index: 2;
}

.bbt-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2, #ec4899);
    width: 0%;
    transition: width 0.3s linear;
}

/* --- Play overlay --- */
.bbt-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    background: rgba(0, 0, 0, 0.4);
}

.bbt-play-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 24px;
    padding: 2rem 3rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    box-shadow:
        0 8px 40px rgba(102, 126, 234, 0.35),
        0 0 30px rgba(118, 75, 162, 0.2);
}

.bbt-play-btn:hover {
    transform: scale(1.06);
    box-shadow:
        0 12px 50px rgba(102, 126, 234, 0.5),
        0 0 40px rgba(118, 75, 162, 0.3);
}

/* ─────────────────────────────────────────────────────
   SHARED SCENE STYLES
   ───────────────────────────────────────────────────── */
.bbt-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1.8rem;
    width: 100%;
}

.bbt-heading {
    font-size: 2.2rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 20px rgba(102, 126, 234, 0.3);
}

/* Reusable animations */
.bbt-fade-up {
    animation: bbtFadeUp 0.5s ease var(--delay, 0s) both;
}

@keyframes bbtFadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes bbtPopIn {
    from { opacity: 0; transform: scale(0) rotate(-10deg); }
    to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ─────────────────────────────────────────────────────
   SCENE: Title
   ───────────────────────────────────────────────────── */
.bbt-title-text {
    font-size: 5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #764ba2, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    letter-spacing: -2px;
    animation: bbtTitleSlam 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    filter: drop-shadow(0 4px 30px rgba(102, 126, 234, 0.4));
}

.bbt-title-text-2 {
    animation-delay: 0.15s;
    background: linear-gradient(135deg, #fbbf24, #f97316, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    filter: drop-shadow(0 4px 30px rgba(251, 191, 36, 0.4));
}

.bbt-title-sub {
    color: rgba(255, 255, 255, 0.45);
    font-size: 1.3rem;
    font-weight: 500;
    animation: bbtFadeUp 0.5s ease 0.4s both;
}

@keyframes bbtTitleSlam {
    from { opacity: 0; transform: scale(1.8) rotate(-3deg); }
    to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ─────────────────────────────────────────────────────
   SCENE: Intro – Bingo balls
   ───────────────────────────────────────────────────── */
.bbt-bingo-balls {
    display: flex;
    gap: 1rem;
}

.bbt-ball {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    color: white;
    background: var(--clr);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.3),
        inset 0 -4px 10px rgba(0, 0, 0, 0.15),
        inset 0 4px 10px rgba(255, 255, 255, 0.2);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.bbt-ball-pop {
    animation: bbtBallPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay) both;
}

@keyframes bbtBallPop {
    0% { opacity: 0; transform: scale(0) rotate(-180deg); }
    60% { transform: scale(1.15) rotate(10deg); }
    100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ─────────────────────────────────────────────────────
   SCENE: Card – Mini bingo grid
   ───────────────────────────────────────────────────── */
.bbt-mini-card {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    max-width: 340px;
    width: 100%;
}

.bbt-mini-card-small {
    max-width: 260px;
    gap: 4px;
    padding: 8px;
}

.bbt-card-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    color: white;
    transition: all 0.3s ease;
}

.bbt-mini-card-small .bbt-card-cell {
    font-size: 0.75rem;
    border-radius: 6px;
}

.bbt-card-free {
    background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
    font-size: 0.55rem !important;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.bbt-cell-pop {
    animation: bbtCellPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay) both;
}

@keyframes bbtCellPop {
    from { opacity: 0; transform: scale(0); }
    to   { opacity: 1; transform: scale(1); }
}

.bbt-card-note {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.95rem;
}

/* ─────────────────────────────────────────────────────
   SCENE: Expression
   ───────────────────────────────────────────────────── */
.bbt-expr-display {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.5rem 2.5rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
}

.bbt-expr-num {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    font-family: 'Courier New', monospace;
}

.bbt-expr-op {
    font-size: 2.2rem;
    font-weight: 600;
    color: #8b5cf6;
    font-family: 'Courier New', monospace;
}

.bbt-expr-pop {
    animation: bbtExprPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay) both;
}

@keyframes bbtExprPop {
    from { opacity: 0; transform: translateY(30px) scale(0.5); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bbt-expr-note {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.95rem;
}

/* ─────────────────────────────────────────────────────
   SCENE: Highlights – yellow glowing cells
   ───────────────────────────────────────────────────── */
.bbt-highlight-row {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.bbt-card-hinted {
    background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
    animation: bbtHintPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.5);
}

@keyframes bbtHintPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(251, 191, 36, 0.4); transform: scale(1); }
    50%      { box-shadow: 0 0 20px rgba(251, 191, 36, 0.7); transform: scale(1.08); }
}

.bbt-highlight-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bbt-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

.bbt-legend-swatch {
    width: 18px;
    height: 18px;
    border-radius: 5px;
}

.bbt-legend-yellow {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

/* ─────────────────────────────────────────────────────
   SCENE: Brackets – step-by-step demo
   ───────────────────────────────────────────────────── */
.bbt-bracket-demo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bbt-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.2rem 1rem;
    min-width: 130px;
}

.bbt-step-pop {
    animation: bbtPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay) both;
}

.bbt-step-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bbt-step-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bbt-step-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.bbt-target-chip {
    font-size: 2rem;
    font-weight: 800;
    color: #fbbf24;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
}

.bbt-bracket-expr {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

.bbt-br {
    color: #667eea;
    font-weight: 800;
    font-size: 1.4rem;
    text-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.bbt-result-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

.bbt-result-x {
    color: #ef4444;
    font-size: 1.3rem;
}

.bbt-result-correct {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    font-weight: 500;
}

.bbt-step-arrow {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.25);
}

/* ─────────────────────────────────────────────────────
   SCENE: Timer – animated ring
   ───────────────────────────────────────────────────── */
.bbt-clock {
    position: relative;
    width: 150px;
    height: 150px;
    animation: bbtPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.bbt-clock-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.bbt-clock-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 6;
}

.bbt-clock-progress {
    fill: none;
    stroke: url(#bbt-timer-gradient);
    stroke: #667eea;
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 264;
    stroke-dashoffset: 0;
    animation: bbtClockDrain 4s linear forwards;
}

@keyframes bbtClockDrain {
    from { stroke-dashoffset: 0; stroke: #667eea; }
    70%  { stroke: #fbbf24; }
    to   { stroke-dashoffset: 264; stroke: #ef4444; }
}

.bbt-clock-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 20px rgba(102, 126, 234, 0.4);
}

.bbt-timer-note {
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.1rem;
    font-weight: 500;
}

/* ─────────────────────────────────────────────────────
   SCENE: Win condition – winning diagonal
   ───────────────────────────────────────────────────── */
.bbt-win-row {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.bbt-card-winning {
    background: linear-gradient(135deg, #667eea, #764ba2) !important;
    animation: bbtWinPulse 1s ease-in-out infinite;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

@keyframes bbtWinPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(102, 126, 234, 0.4); }
    50%      { transform: scale(1.1); box-shadow: 0 0 25px rgba(102, 126, 234, 0.7); }
}

.bbt-win-types {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bbt-win-type {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

/* ─────────────────────────────────────────────────────
   SCENE: Endgame – Podium
   ───────────────────────────────────────────────────── */
.bbt-podium {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}

.bbt-podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.bbt-podium-pop {
    animation: bbtPodiumRise 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay) both;
}

@keyframes bbtPodiumRise {
    from { opacity: 0; transform: translateY(50px); }
    to   { opacity: 1; transform: translateY(0); }
}

.bbt-podium-crown {
    font-size: 2.5rem;
    animation: bbtCrownBounce 2s ease-in-out infinite;
}

@keyframes bbtCrownBounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

.bbt-podium-block {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100px;
    border-radius: 12px 12px 0 0;
    font-weight: 800;
    font-size: 1.3rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.bbt-podium-1 .bbt-podium-block {
    height: 140px;
    background: linear-gradient(180deg, #fbbf24, #f59e0b);
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.3);
}

.bbt-podium-2 .bbt-podium-block {
    height: 100px;
    background: linear-gradient(180deg, #94a3b8, #64748b);
}

.bbt-podium-3 .bbt-podium-block {
    height: 70px;
    background: linear-gradient(180deg, #d97706, #b45309);
}

.bbt-endgame-note {
    color: rgba(255, 255, 255, 0.45);
    font-size: 1rem;
}

/* ─────────────────────────────────────────────────────
   SCENE: Outro
   ───────────────────────────────────────────────────── */
.bbt-outro-scene .bbt-title-text {
    font-size: 4rem;
}

.bbt-outro-sub {
    color: rgba(255, 255, 255, 0.45);
    font-size: 1.3rem;
    font-style: italic;
    animation: bbtFadeUp 0.5s ease 0.3s both;
}

/* ─────────────────────────────────────────────────────
   HOW TO PLAY BUTTON (lobby integration)
   ───────────────────────────────────────────────────── */
.bbt-how-to-play-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.3);
    color: #667eea;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
}

.bbt-how-to-play-btn:hover {
    background: rgba(102, 126, 234, 0.18);
    border-color: rgba(102, 126, 234, 0.5);
}

/* ─────────────────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────────────────── */
@media (max-width: 700px) {
    .bbt-title-text {
        font-size: 3rem;
    }

    .bbt-heading {
        font-size: 1.5rem;
    }

    .bbt-ball {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }

    .bbt-expr-num {
        font-size: 2rem;
    }

    .bbt-expr-op {
        font-size: 1.5rem;
    }

    .bbt-bracket-demo {
        flex-direction: column;
        gap: 0.75rem;
    }

    .bbt-step-arrow {
        transform: rotate(90deg);
    }

    .bbt-highlight-row,
    .bbt-win-row {
        flex-direction: column;
        gap: 1rem;
    }

    .bbt-podium-block {
        width: 75px;
    }

    .bbt-podium-1 .bbt-podium-block { height: 110px; }
    .bbt-podium-2 .bbt-podium-block { height: 80px; }
    .bbt-podium-3 .bbt-podium-block { height: 55px; }

    .bbt-clock {
        width: 120px;
        height: 120px;
    }

    .bbt-clock-number {
        font-size: 2.5rem;
    }
}
