/* Thumbnail Battle — YouTube arena + TrustMRR-style loop */

.tb-page {
    --tb-bg: #0f0f0f;
    --tb-surface: #212121;
    --tb-chip: #272727;
    --tb-chip-hover: #3f3f3f;
    --tb-line: #3f3f3f;
    --tb-text: #f1f1f1;
    --tb-meta: #aaaaaa;
    --tb-muted: #717171;
    --tb-red: #ff0000;
    --tb-win: #22c55e;
    --tb-lose: #ef4444;
    --tb-bq: #4e39ff;
    --tb-white: #ffffff;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--tb-bg);
    color: var(--tb-text);
    font-family: Inter, system-ui, sans-serif;
}

.tb-page,
.tb-page * {
    box-sizing: border-box;
}

.tb-loader {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(15, 15, 15, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.tb-loader[hidden] {
    display: none !important;
}

.tb-loader-spin {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255, 255, 255, 0.16);
    border-top-color: var(--tb-white);
    border-radius: 50%;
    animation: tb-spin 0.7s linear infinite;
}

.tb-loader-text {
    margin: 0;
    color: var(--tb-meta);
    font-size: 0.98rem;
}

@keyframes tb-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tb-loader-spin {
        animation-duration: 1.4s;
    }
}

.tb-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tb-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--tb-text);
    text-decoration: none;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.tb-brand img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.tb-brand span {
    font-size: 0.95rem;
}

.tb-top-link {
    color: var(--tb-meta);
    text-decoration: none;
    font-size: 0.9rem;
}

.tb-top-link:hover {
    color: var(--tb-text);
}

.tb-shell {
    width: min(1080px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 2.5rem;
}

.tb-hud {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto auto;
    align-items: center;
    gap: 0.85rem 1rem;
    margin-bottom: 1.4rem;
}

.tb-hud[hidden] {
    display: none !important;
}

.tb-ghost {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--tb-meta);
    font: inherit;
    font-size: 0.92rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    padding: 0.35rem 0;
}

.tb-ghost:hover {
    color: var(--tb-text);
}

.tb-ghost:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.tb-hud-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.tb-progress {
    height: 10px;
    border-radius: 999px;
    background: #1a1a1a;
    overflow: hidden;
}

.tb-progress > span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--tb-white);
    transition: width 0.35s ease;
}

.tb-score-hud,
.tb-round,
.tb-timer {
    color: var(--tb-text);
    font-variant-numeric: tabular-nums;
    font-size: 0.92rem;
    white-space: nowrap;
}

.tb-score-hud {
    font-weight: 600;
}

.tb-timer {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--tb-meta);
}

.tb-prefetch {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--tb-meta);
    font-size: 0.8rem;
    white-space: nowrap;
}

.tb-prefetch[hidden] {
    display: none !important;
}

.tb-prefetch-spin {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.16);
    border-top-color: var(--tb-white);
    border-radius: 50%;
    animation: tb-spin 0.7s linear infinite;
}

.tb-stage {
    min-height: 62vh;
}

.tb-panel {
    display: none;
    animation: tb-in 0.28s ease;
}

.tb-panel.is-on {
    display: block;
}

.tb-panel[hidden] {
    display: none !important;
}

@keyframes tb-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.tb-intro,
.tb-finish,
.tb-empty {
    text-align: center;
    padding: 3.5rem 0 2rem;
}

.tb-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--tb-meta);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 0.85rem;
}

.tb-kicker-name {
    text-transform: none;
    letter-spacing: 0.02em;
}

.tb-intro h1,
.tb-finish h2,
.tb-empty h2 {
    margin: 0 0 0.75rem;
    font-size: clamp(2rem, 5vw, 3.4rem);
    line-height: 1.1;
    letter-spacing: -0.04em;
}

.tb-lead {
    margin: 0 auto 1.75rem;
    max-width: 34rem;
    color: var(--tb-meta);
    font-size: 1.05rem;
    line-height: 1.5;
}

.tb-btn {
    appearance: none;
    border: 0;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 48px;
    padding: 0 1.35rem;
    border-radius: 999px;
    font: 500 0.95rem/1 Inter, system-ui, sans-serif;
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.tb-btn:hover {
    transform: translateY(-1px);
}

.tb-btn:disabled {
    cursor: wait;
    opacity: 0.7;
    transform: none;
}

.tb-btn-white {
    background: var(--tb-white);
    color: #0f0f0f;
}

.tb-btn-white:hover {
    background: #e5e5e5;
}

.tb-btn-yt {
    background: var(--tb-chip);
    color: var(--tb-text);
}

.tb-btn-yt:hover {
    background: var(--tb-chip-hover);
}

.tb-btn-bq {
    background: var(--tb-bq);
    color: var(--tb-white);
}

.tb-btn-bq:hover {
    background: #3d2eff;
}

.tb-btn-wide {
    width: 100%;
}

.tb-question {
    text-align: center;
    margin: 0 0 1.15rem;
    font-size: clamp(1.15rem, 2.6vw, 1.55rem);
    letter-spacing: -0.03em;
}

.tb-arena {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem 1.1rem;
    align-items: stretch;
}

.tb-card {
    appearance: none;
    border: 2px solid transparent;
    background: transparent;
    color: inherit;
    text-align: left;
    padding: 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.tb-card:focus-visible {
    outline: 2px solid #3ea6ff;
    outline-offset: 3px;
    border-radius: 16px;
}

.tb-card.is-locked,
.tb-page.is-revealed .tb-card {
    cursor: default;
}

.tb-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    background: var(--tb-surface);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tb-card:hover .tb-thumb {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.38);
}

.tb-page.is-revealed .tb-card:hover .tb-thumb {
    transform: none;
}

.tb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tb-card.is-win .tb-thumb {
    box-shadow: 0 0 0 3px var(--tb-win), 0 12px 32px rgba(34, 197, 94, 0.18);
}

.tb-card.is-lose .tb-thumb {
    box-shadow: 0 0 0 3px var(--tb-lose), 0 12px 32px rgba(239, 68, 68, 0.12);
    filter: saturate(0.85);
}

.tb-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 4.6rem;
}

.tb-title {
    font-family: Roboto, Arial, sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tb-meta {
    display: none;
    color: var(--tb-meta);
    font-family: Roboto, Arial, sans-serif;
    font-size: 0.78rem;
    line-height: 1.35;
}

.tb-page.is-revealed .tb-meta {
    display: block;
}

.tb-vs {
    align-self: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--tb-white);
    color: #111;
    font-weight: 800;
    letter-spacing: -0.04em;
    display: grid;
    place-items: center;
    transform: rotate(-8deg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    z-index: 2;
}

.tb-choices {
    display: contents;
}

.tb-choice {
    margin-top: 0.15rem;
}

.tb-page.is-revealed .tb-choice {
    display: none;
}

.tb-score {
    display: none;
    margin-top: 0.15rem;
}

.tb-page.is-revealed .tb-score {
    display: block;
}

.tb-views {
    margin: 0;
    font-size: clamp(1.7rem, 4vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.tb-card.is-win .tb-views {
    color: #86efac;
}

.tb-card.is-lose .tb-views {
    color: #fca5a5;
}

.tb-watch {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.45rem;
    color: var(--tb-meta);
    text-decoration: none;
    font-size: 0.82rem;
}

.tb-watch:hover {
    color: var(--tb-text);
}

.tb-result-bar {
    display: none;
    margin-top: 1.35rem;
    text-align: center;
}

.tb-page.is-revealed .tb-result-bar {
    display: block;
}

.tb-why {
    margin: 0 0 1rem;
    color: var(--tb-meta);
    font-size: 0.95rem;
}

.tb-iq-line {
    margin: 0 0 1.15rem;
    color: var(--tb-meta);
    font-size: 1rem;
}

.tb-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
    max-width: 28rem;
    margin: 0 auto 1rem;
}

.tb-stat {
    background: var(--tb-chip);
    border-radius: 14px;
    padding: 0.7rem 0.45rem 0.65rem;
}

.tb-stat b {
    display: block;
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}

.tb-stat span {
    display: block;
    margin-top: 0.15rem;
    color: var(--tb-meta);
    font-size: 0.75rem;
}

.tb-stats-all {
    margin: 0 auto 1.5rem;
    max-width: 28rem;
    color: var(--tb-muted);
    font-size: 0.88rem;
}

.tb-finish-score {
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 700;
    letter-spacing: -0.05em;
    margin: 0.4rem 0;
}

.tb-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
}

.tb-confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 40;
}

@media (max-width: 800px) {
    .tb-question {
        margin-bottom: 0.75rem;
        font-size: 1.15rem;
    }

    .tb-card {
        gap: 0.5rem;
    }

    .tb-choice .tb-btn {
        min-height: 42px;
    }

    .tb-shell {
        width: min(100% - 1.25rem, 720px);
        padding-top: 0.85rem;
    }

    .tb-hud {
        grid-template-columns: 1fr auto auto auto;
        grid-template-areas:
            "restart score round timer"
            "progress progress progress prefetch";
    }

    .tb-hud .tb-hud-actions { grid-area: restart; }
    .tb-hud .tb-progress { grid-area: progress; }
    .tb-hud .tb-score-hud { grid-area: score; }
    .tb-hud .tb-round { grid-area: round; }
    .tb-hud .tb-timer { grid-area: timer; }
    .tb-hud .tb-prefetch { grid-area: prefetch; justify-self: end; }

    .tb-arena {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .tb-vs {
        width: 52px;
        height: 52px;
        font-size: 0.85rem;
        justify-self: center;
        margin: -0.15rem 0;
    }

    .tb-choices {
        display: block;
    }

    .tb-card-body {
        min-height: 0;
    }

    .tb-intro,
    .tb-finish,
    .tb-empty {
        padding-top: 2rem;
    }

    .tb-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .tb-top {
        padding: 0.7rem 0.9rem;
    }

    .tb-brand span {
        display: none;
    }

    .tb-btn {
        width: 100%;
    }

    .tb-actions {
        flex-direction: column;
    }
}
