@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@700;900&family=Noto+Sans+Thai:wght@700;900&family=Rajdhani:wght@500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: transparent;
}

body {
    font-family: 'Rajdhani', sans-serif;
    background: transparent;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}



/*-------------------  set icon status */
.icon-svg {
    width: 35px;
    height: 35px;
    vertical-align: middle;
    margin: 0 6px;
}

/*-------------------  set icon hand */
.icon-hand-svg {
    width: 45px;
    height: 45px;
    vertical-align: middle;
    margin: 0 6px;
}



/* ─── Container ─────────────────────────────────── */
.pk-container {
    width: 100%;
    max-width: 1100px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pk-top-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 0;
    /* Removed padding to let them go to absolute edges */
    z-index: 10;
    position: relative;
    /* Added for absolute centering of round-info */
}

.pk-team-label-col {
    display: flex;
    flex-direction: column;
    width: 320px;
    position: relative;
}

.pk-team-label-col.right {
    align-items: flex-end;
}

.pk-main-card {
    width: calc(100% + 70px);
    margin-left: -35px;
    margin-right: -35px;
    height: 275px;
    /* absolute height based on SVG */
    min-height: 275px;
    /* Increased opacity and darkened rgb from SVG's default 0.6 for the pink side */
    background: linear-gradient(90deg, rgba(5, 120, 220, 0.4) 0%, rgba(197, 22, 87, 0.4) 100%);
    border: 5px solid rgba(227, 227, 227, 0.4);
    border-radius: 17.5px;
    /* box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); */
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 0;
    overflow: hidden;

}

.pk-card-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 50px 16.5px 0 16.5px;
    height: 128px;
    position: relative;
    overflow: hidden;
}

.pk-card-side {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    z-index: 1;
}

.pk-card-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1;
}



/* Timer pulse + scale */
@keyframes timer-warning {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    40% {
        opacity: 0.4;
        transform: scale(1.12);
    }

    70% {
        opacity: 0.8;
        transform: scale(1.04);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.pk-container.warning .pk-timer {
    color: #ff2d2d;
    font-size: 100px;
    letter-spacing: 0;
    -webkit-text-stroke: 3px rgba(255, 0, 0, 0.8);
    text-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);
    animation: timer-warning 0.8s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

/* Container shake */
@keyframes warning-shake {

    0%,
    100% {
        transform: translate(0, 0);
    }

    15% {
        transform: translate(-2px, 1px);
    }

    35% {
        transform: translate(2px, -1px);
    }

    55% {
        transform: translate(-1px, 0);
    }

    75% {
        transform: translate(1px, 1px);
    }
}

.pk-container.warning {
    animation: warning-shake 0.6s ease-in-out infinite;
}


/* Score bar heartbeat */
@keyframes warning-heartbeat {

    0%,
    100% {
        transform: scaleY(1);
    }

    15% {
        transform: scaleY(1.06);
    }

    30% {
        transform: scaleY(1);
    }

    45% {
        transform: scaleY(1.04);
    }

    60% {
        transform: scaleY(1);
    }
}

.pk-container.warning .pk-score-bar {
    animation: warning-heartbeat 0.8s ease-in-out infinite;
}


/* ─── HEADER ─────────────────────────────────────── */
.pk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 0 40px;
}

.pk-team-column {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transform: scale(0.7);
}

.pk-team-column.left {
    align-items: center;
    transform-origin: left center;
}

.pk-team-column.right {
    align-items: center;
    transform-origin: right center;
}

.team-label-top {
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    color: #fff;
    font-weight: 900;
    margin-bottom: 5px;
    /* Moved up by 10px (was -5px) */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    z-index: 5;
    position: relative;
}

.pk-team-column.left .team-label-top {
    margin-left: 0;
    /* Fully flush to the left edge */
}

.pk-team-column.right .team-label-top {
    margin-right: 0;
    /* Fully flush to the right edge */
}

.pk-team-profile {
    display: flex;
    align-items: center;
}

/* Redesigned Name Boxes (Top Row) */
.idol-name-box {
    background: rgba(28, 30, 41, 0.95);
    border-radius: 10px;
    padding: 0;
    width: 320px;
    min-width: 320px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.idol-name-box.left {
    border: 4px solid #00B9C7;
    box-shadow: 0 0 20px rgba(0, 185, 199, 0.9), 0 0 35px rgba(0, 185, 199, 0.5);
    margin-right: -40px;
    /* Tuck under avatar */
}

.idol-name-box.right {
    border: 4px solid #FF55AF;
    box-shadow: 0 0 20px rgba(255, 85, 175, 0.9), 0 0 35px rgba(255, 85, 175, 0.5);
    margin-left: -40px;
    /* Tuck under avatar */
}

.idol-name {
    font-family: 'Noto Sans Thai', sans-serif;
    font-weight: 900;
    font-size: 28px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    display: inline-block;
    width: 100%;
    text-align: center;
    flex-shrink: 0;
}

.idol-name.marquee-active {
    width: auto;
    text-align: left;
    padding-left: 100%;
    animation: scroll-text-left 10s linear infinite;
}

@keyframes scroll-text-left {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* Wings + Avatar Container */
.avatar-container {
    position: relative;
    z-index: 3;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 80px;
    overflow: visible;
    flex-shrink: 0;
}

.pk-team-profile.left .avatar-container {
    filter: drop-shadow(0 0 10px rgba(0, 185, 199, 1)) drop-shadow(0 0 25px rgba(0, 185, 199, 0.8));
}

.pk-team-profile.right .avatar-container {
    filter: drop-shadow(0 0 10px rgba(255, 85, 175, 1)) drop-shadow(0 0 25px rgba(255, 85, 175, 0.8));
}

/* ── Avatar Frame Overlay (SVG ring + wings) ── */
.avatar-frame {
    position: absolute;
    width: 153px;
    /* Scaling the 118px SVG to fit its inner 61px ring over the 80px avatar */
    pointer-events: none;
    z-index: 4;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.team-avatar {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
    border-radius: 50%;
    background: #888;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.team-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Idol Name Box */
/* Score labels have been moved inside the progress bars below */

.score-section {
    position: absolute;
    bottom: 24px;
    /* Increased 15px bottom space */
    left: 21.5px;
    right: 21.5px;
    height: 80px;
    z-index: 10;
}

.score-bar-wrapper {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: stretch;
}

.pk-score-bar {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 40px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
}

.score-side {
    height: 100%;
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    align-items: center;
    /* Bar width = pure score proportion (dp%/ap% set inline by render.js).
       min-width:0 so neither side reserves extra space nor lets a long number
       (e.g. 10000001) shrink the other side via flex-shrink. The number itself
       can overflow the colored area (overflow: visible) without moving the seam. */
    min-width: 0;
    overflow: visible;
}

/* Defender Bar: Purple to Pink */
.score-side.blue {
    background: linear-gradient(90deg, #00C7F0 0%, #2FFEFB 100%);
    justify-content: flex-start;
    padding-left: 27px;
    /* matches x=51 SVG text start */
    border-radius: 40px 0 0 40px;
}

/* Attacker Bar: Blue to Green */
.score-side.pink {
    background: linear-gradient(90deg, #EA45A7 0%, #FE1494 100%);
    justify-content: flex-end;
    padding-right: 27px;
    border-radius: 0 40px 40px 0;
}

.score-label-left,
.score-label-right {
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
    font-size: 60px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.clash-indicator {
    display: none;
}

.idol-name {
    font-family: 'Noto Sans Thai', sans-serif;
    font-weight: 700;
    font-size: 32px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    min-width: 140px;
    text-align: center;
}

/* Round Info */
.pk-round-info {
    display: none;
    /* Hidden per user request, was flex */
    align-items: center;
    gap: 16px;
    font-family: 'Noto Sans Thai', sans-serif;
    font-size: 40px;
    font-weight: 700;
    position: absolute;
    left: 50%;
    bottom: 16px;
    /* Aligns center of text with center of avatars */
    transform: translateX(-50%);
    white-space: nowrap;
}

.round-text {
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.red-arrow {
    color: #ff2a7a;
    text-shadow: 0 0 10px rgba(255, 42, 122, 0.6);
}

.blue-arrow {
    color: #00e5ff;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

/* ─── MAIN PANEL ─────────────────────────────────── */
.pk-main {
    margin-top: 10px;
    padding: 24px 32px;
    background: linear-gradient(90deg, #A12B6B 0%, #4D3C8A 50%, #206FBA 100%);
    border-radius: 20px;
    border: 4px solid #fff;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* ─── GIFT + TIMER ROW ───────────────────────────── */
.gift-timer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.gift-strip-side {
    width: 308px;
    height: 68px;
    display: flex;
    align-items: center;
}

.gift-strip-side.left {
    justify-content: flex-start;
}

.gift-strip-side.right {
    justify-content: flex-end;
}

.marquee-clip {
    width: 100%;
    height: 140%;
    overflow: hidden;
    position: relative;
    display: flex;
}

.marquee-track {
    display: flex;
    gap: 15px;
    align-items: center;
}

.gift-icon {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

/* ── Gift cycler (gift-marquee.js) ───────────────────────────────────────────
   gc-row/gc-card: page-based carousel (cycle & slide modes)
   ─────────────────────────────────────────────────────────────────────────── */
.gc-row {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 100%;
}

.gc-row.gc-row-right {
    justify-content: flex-end;
}

.gc-card {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes gc-anim-in {
    0% {
        transform: scale(0.4);
        opacity: 0;
    }

    70% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* zoom-in → hold → zoom-out (same rhythm as multi-pk giftCycle) */
@keyframes gc-anim-cycle {
    0% {
        transform: scale(0.2);
        opacity: 0;
        animation-timing-function: ease-out;
    }

    15% {
        transform: scale(1.1);
        opacity: 1;
        animation-timing-function: ease-in-out;
    }

    25% {
        transform: scale(1);
        opacity: 1;
        animation-timing-function: linear;
    }

    75% {
        transform: scale(1);
        opacity: 1;
        animation-timing-function: ease-in-out;
    }

    85% {
        transform: scale(1.1);
        opacity: 1;
        animation-timing-function: ease-in;
    }

    100% {
        transform: scale(0.2);
        opacity: 0;
    }
}

.gc-anim-in {
    animation: gc-anim-in 0.4s ease-out both;
}

.gc-anim-cycle {
    animation: gc-anim-cycle 2.2s both;
}

/* slide mode viewport/track */
.gc-viewport {
    overflow: hidden;
    width: 100%;
    height: 100%;
}

.gc-track {
    display: flex;
    gap: 12px;
    align-items: center;
    height: 100%;
    will-change: transform;
}

.gc-slide-item {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

/* ── Score-boost effects (score-boost.js) ────────────────────────────────────
   Multi-pk inspired: burst particles + bar sweep + shockwave + floater
   ─────────────────────────────────────────────────────────────────────────── */

/* Burst particles */
.score-burst-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 20;
    width: 8px;
    height: 8px;
    transform: translate(-50%, -50%);
    animation: score-burst-out 0.7s ease-out forwards;
}

@keyframes score-burst-out {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.3);
    }
}

/* Bar sweep flash */
.score-bar-flash {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
    z-index: 4;
    pointer-events: none;
    animation: score-bar-sweep 0.55s ease-out forwards;
}

@keyframes score-bar-sweep {
    0% {
        opacity: 1;
        transform: scaleX(0);
        transform-origin: left;
        filter: brightness(2);
    }

    50% {
        opacity: 0.8;
        transform: scaleX(1);
        transform-origin: left;
    }

    100% {
        opacity: 0;
        transform: scaleX(1.4);
        transform-origin: left;
    }
}

/* Shockwave ring */
.score-shockwave {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid currentColor;
    pointer-events: none;
    z-index: 10;
    animation: score-shockwave-expand 0.5s ease-out forwards;
}

@keyframes score-shockwave-expand {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.2);
        border-width: 6px;
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2.5);
        border-width: 0;
    }
}

/* Score label pulse */
@keyframes score-label-pulse {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.28);
        color: #ffffaa;
        text-shadow: 0 0 12px #ffff00;
    }

    100% {
        transform: scale(1);
    }
}

.score-label-pulsing {
    animation: score-label-pulse 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Floating +X */
.score-floater {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 32px;
    font-weight: 900;
    white-space: nowrap;
    pointer-events: none;
    z-index: 20;
    animation: mk-float 1s ease-out forwards;
}

.score-floater.blue {
    color: #f5d0fe;
    text-shadow: 0 0 12px #d946ef, 0 0 24px #7c3aed, 0 2px 4px rgba(0, 0, 0, 0.8);
}

.score-floater.pink {
    color: #a7f3d0;
    text-shadow: 0 0 12px #34d399, 0 0 24px #0d9488, 0 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes mk-float {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(10px) scale(0.3) rotate(-10deg);
    }

    15% {
        opacity: 1;
        transform: translateX(-50%) translateY(-15px) scale(1.4) rotate(5deg);
    }

    40% {
        transform: translateX(-50%) translateY(-35px) scale(1.1) rotate(-3deg);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-80px) scale(0.6) rotate(0deg);
    }
}

/* ─── TIMER ─────────────────────────────────────── */
.pk-timer {
    font-family: 'Montserrat';
    font-size: 100px;
    /* Reduced from 130px so it fits better */
    font-weight: 700;
    /* Thinner than before (was 900) */
    color: #fff;
    text-align: center;
    letter-spacing: 2px;
    line-height: 1;
    text-shadow: 4px 8px 12px rgba(0, 0, 0, 0.6);
    flex-shrink: 0;
    padding: 0 20px;
}

.pk-timer.timer-ready {
    font-size: 60px;
    color: #ffffff;
    text-shadow: 0 0 30px #ffffff, 0 4px 24px rgba(0, 0, 0, 0.7);
}

@keyframes timeup-scale {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.04);
    }
}

.pk-timer.timer-timeup {
    font-size: 52px;
    font-weight: 900;
    letter-spacing: 6px;
    /* TikTok pink → purple → cyan gradient text */
    background: linear-gradient(90deg, #FE2C55 0%, #c040ff 50%, #25F4EE 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    animation: timeup-scale 0.7s ease-in-out infinite alternate;
}

.pk-timer.disconnected {
    opacity: 0.25;
    text-shadow: none;
}

/* ─── CLASH BURST particles (clash-burst.js) ─────── */
/* Container sits at the seam (width:0), sparks fly outward */
.cb-container {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    pointer-events: none;
    z-index: 20;
}

@keyframes cb-spark-fly {
    0% {
        transform: translate(-50%, -50%) translate(0, 0) scale(1.3);
        opacity: 1;
    }

    55% {
        opacity: 0.7;
    }

    100% {
        transform: translate(-50%, -50%) translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

.cb-spark {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--c, #fff);
    box-shadow: 0 0 5px var(--c, #fff), 0 0 10px var(--c, #fff);
    animation: cb-spark-fly 0.55s ease-out forwards;
}

/* ─── SCORE BAR ──────────────────────────────────── */




/* ─── SCORE CHANGE EFFECTS ─────────────────────── */
/* losing side */
.score-side.losing {
    opacity: 0.85;
    filter: brightness(0.8);
}

/* Boost flash overlay */
.score-boost-flash {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 3;
    animation: boost-flash 0.6s ease-out forwards;
}

/* Defender visual Purple/Pink flash */
.score-boost-flash.blue {
    background: radial-gradient(ellipse at center, rgba(217, 70, 239, 0.6) 0%, rgba(124, 58, 237, 0.3) 40%, transparent 70%);
}

/* Attacker visual Teal/Green flash */
.score-boost-flash.pink {
    background: radial-gradient(ellipse at center, rgba(52, 211, 153, 0.6) 0%, rgba(13, 148, 136, 0.3) 40%, transparent 70%);
}

@keyframes boost-flash {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.1);
    }
}

/* Score number pop */
.score-pop-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: inherit;
    padding: inherit;
    pointer-events: none;
    z-index: 4;
    font-size: inherit;
    font-weight: 900;
    color: #fff;
    animation: pop-bounce 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.8), 0 0 60px rgba(255, 255, 255, 0.4);
}

@keyframes pop-bounce {
    0% {
        transform: scale(1.5);
        opacity: 0.8;
    }

    40% {
        transform: scale(0.9);
        opacity: 0.4;
    }

    70% {
        transform: scale(1.1);
        opacity: 0.2;
    }

    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Floating +X */
.score-floater {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 32px;
    font-weight: 900;
    white-space: nowrap;
    pointer-events: none;
    z-index: 20;
    animation: mk-float 1s ease-out forwards;
}

/* Defender Purple/Pink text */
.score-floater.blue {
    color: #f5d0fe;
    text-shadow: 0 0 12px #d946ef, 0 0 24px #7c3aed, 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* Attacker Teal/Green text */
.score-floater.pink {
    color: #a7f3d0;
    text-shadow: 0 0 12px #34d399, 0 0 24px #0d9488, 0 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes mk-float {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(10px) scale(0.3) rotate(-10deg);
    }

    15% {
        opacity: 1;
        transform: translateX(-50%) translateY(-15px) scale(1.4) rotate(5deg);
    }

    40% {
        transform: translateX(-50%) translateY(-35px) scale(1.1) rotate(-3deg);
    }

    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-80px) scale(0.6) rotate(0deg);
    }
}

/* Star burst */
.score-star {
    position: absolute;
    pointer-events: none;
    z-index: 18;
    font-size: 20px;
    animation: mk-star 0.8s ease-out var(--delay, 0s) forwards;
}

@keyframes mk-star {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
    }

    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5) rotate(180deg) translate(var(--tx, 0px), var(--ty, 0px));
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(360deg) translate(calc(var(--tx, 0px) * 2), calc(var(--ty, 0px) * 2));
    }
}

/* Boost flame trail */
.score-flame {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 60px;
    pointer-events: none;
    z-index: 5;
    animation: mk-flame 0.5s ease-out forwards;
    background: radial-gradient(ellipse at center, rgba(255, 200, 0, 0.9) 0%, rgba(255, 100, 0, 0.6) 40%, transparent 70%);
    border-radius: 50%;
    filter: blur(4px);
}

.score-flame.blue {
    left: -10px;
}

.score-flame.pink {
    right: -10px;
}

@keyframes mk-flame {
    0% {
        opacity: 1;
        transform: translateY(-50%) scaleX(1.5) scaleY(1);
    }

    50% {
        opacity: 0.8;
        transform: translateY(-50%) scaleX(2) scaleY(1.3);
    }

    100% {
        opacity: 0;
        transform: translateY(-50%) scaleX(0.5) scaleY(0.5);
    }
}

/* Speed streak particles */
.score-streak {
    position: absolute;
    top: var(--y, 50%);
    width: var(--w, 20px);
    height: 2px;
    pointer-events: none;
    z-index: 15;
    border-radius: 2px;
    animation: mk-streak 0.4s linear var(--delay, 0s) forwards;
}

.score-streak.blue {
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(217, 70, 239, 0.8), #fff);
    box-shadow: 0 0 4px rgba(217, 70, 239, 0.6);
}

.score-streak.pink {
    background: linear-gradient(270deg, transparent, rgba(52, 211, 153, 0.8), #fff);
    box-shadow: 0 0 4px rgba(52, 211, 153, 0.6);
}

@keyframes mk-streak {
    0% {
        opacity: 1;
        transform: scaleX(0.3);
    }

    50% {
        opacity: 1;
        transform: scaleX(1.5);
    }

    100% {
        opacity: 0;
        transform: scaleX(0.1) translateX(var(--dir, -30px));
    }
}


.score-profiles {
    margin-top: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
}

.score-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-profile.right {
    flex-direction: row-reverse;
}

.score-profile-avatar {
    width: 56px;
    height: 56px;
    min-width: 56px;
    min-height: 56px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-profile.left .score-profile-avatar {
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.5), 0 0 16px rgba(56, 189, 248, 0.3);
}

.score-profile.right .score-profile-avatar {
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.5), 0 0 16px rgba(244, 63, 94, 0.3);
}

.score-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.score-profile-name {
    font-family: 'Noto Sans Thai', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* ═══════════════════════════════════════════════════
   RESULT OVERLAY  —  TikTok PK style
   OBS-safe: zero backgrounds anywhere. Visual weight
   comes from large italic gradient text + avatar glow.
═══════════════════════════════════════════════════ */

#result-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease;
}

#result-overlay.show {
    pointer-events: all;
    opacity: 1;
}

/* ── Card: layout only, zero visual background ── */
.result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
}

/* ── Avatar ── */
.result-avatar {
    width: 190px;
    height: 190px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.result-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Name ── */
.result-name {
    font-family: 'Noto Sans Thai', sans-serif;
    font-weight: 900;
    font-size: 40px;
    color: #fff;
    text-align: center;
}

/* ── Label: big italic gradient — the hero element ── */
.result-label {
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
    font-style: italic;
    font-size: 90px;
    letter-spacing: 2px;
    text-transform: uppercase;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 14px;
}

.icon-svg {
    width: 56px;
    height: 56px;
    opacity: 0.9;
}

/* ═══ WINNER ════════════════════════════════════════
   White-to-pink gradient text, pink ring avatar glow
══════════════════════════════════════════════════ */
@keyframes winner-pop {
    0% {
        transform: scale(0.48) translateY(18px);
        opacity: 0;
    }

    62% {
        transform: scale(1.06) translateY(-4px);
        opacity: 1;
    }

    80% {
        transform: scale(0.98);
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes winner-glow {

    0%,
    100% {
        box-shadow: 0 0 0 5px #FE2C55, 0 0 50px rgba(254, 44, 85, 0.7);
    }

    50% {
        box-shadow: 0 0 0 10px #FE2C55, 0 0 90px rgba(254, 44, 85, 1), 0 0 160px rgba(254, 44, 85, 0.4);
    }
}

.result-card.winner {
    animation: winner-pop 0.6s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

.result-card.winner .result-label {
    background: linear-gradient(120deg, #fff 0%, #ffd6df 40%, #FE2C55 80%, #c4003d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-card.winner .result-avatar {
    border: 5px solid #FE2C55;
    animation: winner-glow 1.8s ease-in-out 0.5s infinite;
}

.result-card.winner .result-name {
    color: #fff;
}

/* Confetti */
@keyframes confetti-fly {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(-300px) rotate(600deg);
        opacity: 0;
    }
}

.confetti-dot {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    animation: confetti-fly 1.3s ease-out forwards;
    z-index: 1;
}

/* Punch arms */
@keyframes punch-left {
    0% {
        transform: translateX(-300px) scaleX(-1);
        opacity: 0;
    }

    42% {
        transform: translateX(12px) scaleX(-1);
        opacity: 1;
    }

    58% {
        transform: translateX(-18px) scaleX(-1);
    }

    72% {
        transform: translateX(5px) scaleX(-1);
    }

    100% {
        transform: translateX(-300px) scaleX(-1);
        opacity: 0;
    }
}

@keyframes punch-right {
    0% {
        transform: translateX(300px);
        opacity: 0;
    }

    42% {
        transform: translateX(-12px);
        opacity: 1;
    }

    58% {
        transform: translateX(18px);
    }

    72% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(300px);
        opacity: 0;
    }
}

.punch {
    position: absolute;
    font-size: 72px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    line-height: 1;
}

.punch.left {
    left: -150px;
    animation: punch-left 1.1s ease-in-out 0.5s both;
}

.punch.right {
    right: -150px;
    animation: punch-right 1.1s ease-in-out 0.5s both;
}

/* ═══ LOSER ═════════════════════════════════════════
   Dark muted gradient text, gray desaturated avatar
══════════════════════════════════════════════════ */
@keyframes loser-drop {
    0% {
        transform: translateY(-14px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes screen-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    12% {
        transform: translateX(-9px) rotate(-0.5deg);
    }

    25% {
        transform: translateX(9px) rotate(0.5deg);
    }

    37% {
        transform: translateX(-7px);
    }

    50% {
        transform: translateX(7px);
    }

    62% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }

    87% {
        transform: translateX(-2px);
    }
}

.result-card.loser {
    animation: loser-drop 0.4s ease-out forwards;
}

.result-card.loser .result-label {
    background: linear-gradient(120deg, #4a4a4a 0%, #333 60%, #222 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-card.loser .result-avatar {
    border: 5px solid #2a2a2a;
    filter: grayscale(65%) brightness(0.6);
}

.result-card.loser .result-name {
    color: #555;
}

#result-overlay.loser-phase {
    animation: screen-shake 0.5s ease-in-out 0.2s both;
}

/* ═══ DRAW ══════════════════════════════════════════
   Pink→purple→cyan gradient text, dual avatar glow
══════════════════════════════════════════════════ */
@keyframes draw-pop {
    0% {
        transform: scale(0.52) translateY(24px);
        opacity: 0;
    }

    66% {
        transform: scale(1.05) translateY(-3px);
        opacity: 1;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes glow-pink {

    0%,
    100% {
        box-shadow: 0 0 0 5px #FE2C55, 0 0 35px rgba(254, 44, 85, 0.65);
    }

    50% {
        box-shadow: 0 0 0 9px #FE2C55, 0 0 70px rgba(254, 44, 85, 0.95);
    }
}

@keyframes glow-cyan {

    0%,
    100% {
        box-shadow: 0 0 0 5px #25F4EE, 0 0 35px rgba(37, 244, 238, 0.65);
    }

    50% {
        box-shadow: 0 0 0 9px #25F4EE, 0 0 70px rgba(37, 244, 238, 0.95);
    }
}

/* Draw card: pure layout, no box */
.draw-card {
    position: relative;
}

.draw-card::before,
.draw-card::after {
    display: none;
}

/* Layout children sit above the (disabled) ::before/::after layer. Exclude
   .confetti-dot: it is appended directly to the card and must stay
   position:absolute, otherwise it re-enters flow and pushes the centered
   label/avatar row upward on every burst. */
.draw-card>*:not(.confetti-dot) {
    position: relative;
    z-index: 1;
}

.draw-label {
    font-family: 'Montserrat', sans-serif;
    font-weight: 900;
    font-style: italic;
    font-size: 90px;
    letter-spacing: 2px;
    text-transform: uppercase;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    /* In normal flow (not absolute) — appears above avatar row */
    position: static;
    background: linear-gradient(120deg, #FE2C55 0%, #d040ff 50%, #25F4EE 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* draw-avatar-left / draw-avatar-right set by result.js */
.draw-avatar {
    animation: draw-pop 0.6s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

.draw-avatar-left {
    border: 5px solid #25F4EE;
    animation: draw-pop 0.6s cubic-bezier(0.34, 1.4, 0.64, 1) forwards,
        glow-cyan 2s ease-in-out 0.6s infinite;
}

.draw-avatar-right {
    border: 5px solid #FE2C55;
    animation: draw-pop 0.6s cubic-bezier(0.34, 1.4, 0.64, 1) 0.1s forwards,
        glow-pink 2s ease-in-out 0.6s infinite;
}

/* ═══ FADE IN / OUT ════════════════════════════════ */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: scale(0.94) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.94) translateY(6px);
    }
}

.result-card.fade-in {
    animation: fade-in 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

.result-card.fade-out {
    animation: fade-out 0.4s ease forwards;
}

/* ── pk-clash-video: seam video inside .clash-indicator (injected by clash-video.js) ── */
/* Mirrors .runner-video in race.css: absolute offset out of zero-width container */
.pk-clash-video {
    position: absolute;
    left: -55px;
    top: -55px;
    width: 110px;
    height: 110px;
    object-fit: contain;
    pointer-events: none;
    will-change: opacity;
    transform: translateZ(0);
}

/* ── pk-bg-overlay: background video for pk-card-content (injected by bg-overlay.js) ── */
.pk-bg-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 0;
    display: none;
    border-radius: 40px 40px 0px 0px;
    will-change: opacity;
    transform: translateZ(0);
}

.draw-card.fade-in {
    animation: fade-in 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

.draw-card.fade-out {
    animation: fade-out 0.4s ease forwards;
}

/* ─── RESPONSIVE ────────────────────────────────── */
@media (max-width: 768px) {
    .pk-timer {
        font-size: 64px;
        letter-spacing: 10px;
    }

    .idol-name {
        font-size: 18px;
        min-width: 90px;
        padding: 5px 14px;
    }

    .team-avatar {
        width: 56px;
        height: 56px;
        font-size: 26px;
    }

    .score-label-left,
    .score-label-right {
        font-size: 26px;
        min-width: 44px;
    }

    .pk-score-bar {
        height: 52px;
        border-radius: 26px;
    }

    .pk-main {
        padding: 8px 10px 18px;
    }

    .gift-icon {
        width: 60px;
        height: 60px;
    }

    .result-avatar {
        width: 140px;
        height: 140px;
        font-size: 56px;
    }

    .result-name {
        font-size: 32px;
    }

    .score-profiles {
        margin-top: 24px;
    }

    .score-profile-avatar {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    .score-profile-name {
        font-size: 16px;
    }
}