@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Exo+2:wght@400;600;700;900&family=Bebas+Neue&display=swap');

:root {
    --header-bg: #0a0a0a;
    --neon-gold: #ffd700;
    --neon-blue: #00cfff;
    --neon-green: #00ff88;
    --neon-red: #ff3860;
    --neon-orange: #ff6a00;
    --text-pri: #f5f5f5;
    --header-h: 52px;
    --wins-bar-h: 40px;
    --lane-h: 90px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
    background: #0d0d0d;
    color: var(--text-pri);
    font-family: 'Exo 2', sans-serif;
}

select option {
    background: #1a1a2a;
    color: #ffffff;
}

::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

/* ─── LAYOUT ─── */
#app {
    display: grid;
    grid-template-rows: var(--header-h) var(--wins-bar-h) 1fr;
    height: 100vh;
}

/* ─── HEADER ─── */
#header {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 14px;
    background: var(--header-bg);
    border-bottom: 2px solid #1a1a1a;
    z-index: 100;
}

.brand {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 3px;
    color: var(--neon-gold);
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.5);
    white-space: nowrap;
    flex-shrink: 0;
}

.brand span {
    color: #fff;
}

.btn-leaderboard {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.28);
    color: var(--neon-gold);
    border-radius: 7px;
    padding: 5px 12px;
    font-family: 'Exo 2', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.btn-leaderboard:hover {
    background: rgba(255, 215, 0, 0.2);
}

.conn-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    max-width: 360px;
    margin: 0 auto;
}

.conn-form input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid #2a2a2a;
    border-radius: 7px;
    padding: 6px 11px;
    color: #fff;
    font-family: inherit;
    font-size: 0.84rem;
    outline: none;
    transition: border-color 0.2s;
}

.conn-form input:focus {
    border-color: var(--neon-blue);
}

.conn-form input::placeholder {
    color: #555;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-family: 'Exo 2', sans-serif;
    font-weight: 700;
    font-size: 0.78rem;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-connect {
    background: linear-gradient(135deg, #00ff88, #00cfff);
    color: #001;
}

.btn-connect:hover {
    filter: brightness(1.1);
}

.btn-disconnect {
    background: rgba(255, 56, 96, 0.13);
    color: var(--neon-red);
    border: 1px solid rgba(255, 56, 96, 0.28);
}

.btn-disconnect:hover {
    background: rgba(255, 56, 96, 0.25);
}

.btn-config {
    background: rgba(255, 215, 0, 0.1);
    color: var(--neon-gold);
    border: 1px solid rgba(255, 215, 0, 0.25);
}

.btn-config:hover {
    background: rgba(255, 215, 0, 0.2);
}

.btn-reset {
    background: rgba(255, 255, 255, 0.06);
    color: #bbb;
    border: 1px solid #2a2a2a;
}

.btn-reset:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-test {
    background: rgba(120, 80, 255, 0.15);
    color: #b090ff;
    border: 1px solid rgba(120, 80, 255, 0.3);
}

.btn-test:hover {
    background: rgba(120, 80, 255, 0.28);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid #222;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--neon-red);
    transition: all 0.3s;
}

.status-dot.online {
    background: var(--neon-green);
    box-shadow: 0 0 8px var(--neon-green);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: 0.4
    }
}

.viewers-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 20px;
    background: rgba(0, 207, 255, 0.07);
    border: 1px solid rgba(0, 207, 255, 0.18);
    font-size: 0.78rem;
    color: var(--neon-blue);
    font-weight: 700;
    white-space: nowrap;
}

/* ─── WINS BAR ─── */
#wins-bar {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 14px;
    background: #080808;
    border-bottom: 1px solid #1a1a1a;
    overflow-x: auto;
    scrollbar-width: none;
}

#wins-bar::-webkit-scrollbar {
    display: none;
}

.wins-bar-label {
    font-size: 0.66rem;
    color: #444;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-right: 5px;
    flex-shrink: 0;
}

.win-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    transition: all 0.3s;
}

.win-badge .wb-flag {
    font-size: 1rem;
}

.win-badge .wb-wins {
    color: var(--neon-gold);
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.92rem;
}

.win-badge.leading {
    background: rgba(255, 215, 0, 0.12);
    border-color: rgba(255, 215, 0, 0.32);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.18);
}

/* ─── RACE AREA ─── */
#race-area {
    overflow-y: auto;
    /* Stadium background at the very back */
    background: url('stadium_bg.png') center top / cover no-repeat;
    position: relative;
    padding: 6px 10px;
}

/* ─── ROTARY PANEL ─── */
#rotary-panel {
    display: none;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
    padding: 6px 16px;
    background: rgba(0, 0, 0, 0.72);
    border-radius: 10px;
    border: 2px solid var(--neon-gold);
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.35);
    animation: rotary-glow 1s ease-in-out infinite alternate;
}

#rotary-panel.active {
    display: flex;
}

@keyframes rotary-glow {
    from {
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.22)
    }

    to {
        box-shadow: 0 0 28px rgba(255, 215, 0, 0.5)
    }
}

.rotary-label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

.rotary-country {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 900;
    font-size: 0.92rem;
}

.rotary-flag {
    font-size: 1.4rem;
}

.rotary-gift-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
}

.rotary-gift-name {
    font-size: 0.74rem;
    color: var(--neon-gold);
    font-weight: 700;
}

#rotary-countdown {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.9rem;
    line-height: 1;
    color: var(--neon-gold);
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.8);
    min-width: 36px;
    text-align: center;
}

#rotary-countdown.urgent {
    color: var(--neon-red);
    text-shadow: 0 0 13px rgba(255, 56, 96, 0.9);
    animation: blink-u 0.3s infinite;
}

@keyframes blink-u {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: 0.3
    }
}

/* ─── HORSE LANE ─── */
.lane {
    position: relative;
    height: var(--lane-h);
    margin-bottom: 5px;
    border-radius: 6px;
    overflow: visible;
    transition: box-shadow 0.3s, border-color 0.3s;
    /* Rich dark grass track to match the video style perfectly and allow 'screen' blending to work seamlessly */
    background: linear-gradient(to bottom, #103310, #164d16, #103310);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5) inset, 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Lane effects */
.lane.rotary-active {
    border-color: var(--neon-gold) !important;
    box-shadow: 0 0 0 2px var(--neon-gold), 0 0 20px rgba(255, 215, 0, 0.5);
    animation: rotary-lane-p 0.5s ease-in-out infinite alternate;
    z-index: 5;
}

@keyframes rotary-lane-p {
    from {
        box-shadow: 0 0 0 2px var(--neon-gold), 0 0 14px rgba(255, 215, 0, 0.35)
    }

    to {
        box-shadow: 0 0 0 3px #ffe03a, 0 0 32px rgba(255, 215, 0, 0.65)
    }
}

.lane.supersonic {
    border-color: rgba(0, 207, 255, 0.8) !important;
    box-shadow: 0 0 0 2px #00cfff, 0 0 20px rgba(0, 207, 255, 0.4);
}

.lane.super-saiyan {
    border-color: var(--neon-gold) !important;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.45);
}

.lane.turbo-mode {
    border-color: var(--neon-orange) !important;
    box-shadow: 0 0 0 3px var(--neon-orange), 0 0 40px rgba(255, 106, 0, 0.7);
    animation: turbo-shake 0.1s infinite;
}

@keyframes turbo-shake {
    0% {
        transform: translateX(0)
    }

    25% {
        transform: translateX(-3px)
    }

    75% {
        transform: translateX(3px)
    }

    100% {
        transform: translateX(0)
    }
}

/* ── TRACK OVERLAY — dark top strip for label visibility ── */
.lane::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right, rgba(0, 0, 0, 0.65) 0px, rgba(0, 0, 0, 0.4) 110px, rgba(0, 0, 0, 0.08) 220px, transparent 400px);
    border-radius: 6px;
    pointer-events: none;
    z-index: 0;
}

/* Lane fill progress */
.lane-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    border-radius: 6px 0 0 6px;
    opacity: 0.3;
    transition: width 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1;
}

/* Finish line */
.finish-line {
    position: absolute;
    right: 100px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: repeating-linear-gradient(0deg, #fff 0, #fff 7px, #000 7px, #000 14px);
    opacity: 0.35;
    z-index: 2;
}

/* Country label */
.lane-label {
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    z-index: 3;
    width: 140px;
    pointer-events: none;
}

.lane-assigned-gift {
    display: inline-block;
    margin-right: 4px;
    vertical-align: middle;
}

.lane-gift-icon {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    object-fit: cover;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.lane-flag {
    font-size: 1.4rem;
    line-height: 1;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8));
}

.lane-name {
    font-size: 0.66rem;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 700;
    margin-top: 2px;
    text-shadow: 1px 1px 3px #000, 0 0 6px #000;
}

/* Score right */
.lane-score {
    position: absolute;
    right: 6px;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    z-index: 3;
    min-width: 88px;
}

.score-total {
    font-size: 1rem;
    font-weight: 900;
    color: var(--neon-gold);
    font-family: 'Rajdhani', sans-serif;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6), 1px 1px 2px #000;
}

.score-breakdown {
    font-size: 0.59rem;
    color: rgba(255, 255, 255, 0.65);
    text-align: right;
    text-shadow: 1px 1px 2px #000;
}

/* Gift pop */
.gift-pop {
    position: absolute;
    right: 100px;
    top: 5px;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 215, 0, 0.45);
    border-radius: 18px;
    padding: 2px 9px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--neon-gold);
    animation: pop-in 2.5s forwards;
    z-index: 20;
    white-space: nowrap;
    pointer-events: none;
}

@keyframes pop-in {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(8px)
    }

    10% {
        opacity: 1;
        transform: scale(1.08) translateY(0)
    }

    20% {
        transform: scale(1)
    }

    80% {
        opacity: 1
    }

    100% {
        opacity: 0;
        transform: translateY(-18px)
    }
}

/* ══════════════════════════════════════════════════════════
   HORSE WRAP — Image-based with CSS color overlay for jockey
   ══════════════════════════════════════════════════════════ */
.horse-wrap {
    position: absolute;
    top: 50%;
    left: 108px;
    transform: translateY(-50%);
    z-index: 10;
    transition: left 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    width: var(--horse-w, 110px);
    height: var(--horse-h, 80px);
    /* Removed mix-blend-mode: screen since we now use True Alpha Transparency! */
    filter: drop-shadow(2px 6px 6px rgba(0, 0, 0, 0.5));
    /* Add a nice realistic shadow */
}

/* CSS Sprite Animation using responsive img + container */
.horse-sprite-container {
    height: 100%;
    aspect-ratio: 1.78 / 1;
    /* 356w/200h */
    overflow: hidden;
    position: absolute;
    top: 0;
    left: 0;
}

.horse-sprite-sheet {
    display: block;
    height: 100%;
    width: 1600%;
    /* 16 frames horizontally */
    max-width: none;
    animation: horse-run 0.85s steps(16) infinite;
}

@keyframes horse-run {
    to {
        transform: translateX(-100%);
    }
}

@keyframes horse-nudge {
    0% {
        transform: translateX(0);
    }

    15% {
        transform: translateX(12px);
    }

    100% {
        transform: translateX(0);
    }
}

.horse-wrap.nudge {
    animation: horse-nudge 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Speed states change playback speed of the sprite animation */
.horse-wrap.fast .horse-sprite-sheet {
    animation-duration: 0.5s;
}

.horse-wrap.supersonic .horse-sprite-sheet {
    animation-duration: 0.3s;
    filter: drop-shadow(0 0 10px #00cfff) drop-shadow(0 0 15px #00cfff);
}

.horse-wrap.turbo .horse-sprite-sheet {
    animation-duration: 0.15s;
    filter: drop-shadow(0 0 18px #ff6a00) drop-shadow(0 0 32px #ffd700);
}


@keyframes horse-bounce {
    0% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-4px) rotate(2deg) scaleY(0.97);
    }

    50% {
        transform: translateY(-2px) rotate(0deg);
    }

    75% {
        transform: translateY(-3px) rotate(-2deg) scaleY(0.97);
    }

    100% {
        transform: translateY(0) rotate(0deg);
    }
}

/* Colored jockey overlay — use mix-blend-mode to colorize */
.horse-jockey-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    clip-path: polygon(15% 0%, 85% 0%, 85% 52%, 15% 52%);
    mix-blend-mode: hue;
    opacity: 0.65;
    pointer-events: none;
    border-radius: 4px;
}

/* SPEED STATES */
.horse-wrap.fast .horse-img,
.horse-wrap.fast .horse-video {
    animation-duration: 0.22s;
}

.horse-wrap.supersonic .horse-img,
.horse-wrap.supersonic .horse-video {
    animation-duration: 0.12s;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.4)) drop-shadow(0 0 12px #00cfff);
}

.horse-wrap.turbo .horse-img,
.horse-wrap.turbo .horse-video {
    animation-duration: 0.06s;
    filter: drop-shadow(0 0 18px #ff6a00) drop-shadow(0 0 32px #ffd700) drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.5));
}

/* SPEED LINES — streaks beside the horse */
.speed-lines {
    position: absolute;
    right: calc(100% - 5px);
    top: 25%;
    bottom: 20%;
    width: 60px;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.horse-wrap.fast .speed-lines {
    opacity: 0.5;
}

.horse-wrap.supersonic .speed-lines {
    opacity: 0.85;
}

.horse-wrap.turbo .speed-lines {
    opacity: 1;
}

.speed-line {
    position: absolute;
    height: 2px;
    right: 0;
    border-radius: 1px;
    animation: sl-fly 0.25s linear infinite;
}

.speed-line:nth-child(1) {
    top: 15%;
    width: 55px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.9), transparent);
    animation-delay: 0s;
}

.speed-line:nth-child(2) {
    top: 40%;
    width: 38px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.65), transparent);
    animation-delay: 0.08s;
}

/* The fill bar itself */
.lane-fill {
    height: 100%;
    width: 0%;
    /* Brightened the fill colors so they are clearly visible behind the solid horse */
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.8));
    transition: width 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    border-right: 3px solid rgba(255, 255, 255, 1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

.speed-line:nth-child(3) {
    top: 65%;
    width: 46px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.8), transparent);
    animation-delay: 0.14s;
}

.speed-line:nth-child(4) {
    top: 82%;
    width: 28px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.5), transparent);
    animation-delay: 0.06s;
}

.horse-wrap.turbo .speed-line {
    background: linear-gradient(to left, rgba(255, 140, 0, 0.9), transparent) !important;
}

@keyframes sl-fly {
    from {
        transform: translateX(0)
    }

    to {
        transform: translateX(-20px)
    }
}

/* DUST CLOUD */
.dust-cloud {
    position: absolute;
    bottom: 0;
    right: calc(100% - 10px);
    width: 50px;
    height: 22px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.horse-wrap.fast .dust-cloud {
    opacity: 0.4;
}

.horse-wrap.supersonic .dust-cloud {
    opacity: 0.7;
}

.horse-wrap.turbo .dust-cloud {
    opacity: 1;
}

.dust-puff {
    position: absolute;
    border-radius: 50%;
    background: rgba(200, 180, 140, 0.6);
    animation: dust-rise 0.5s ease-out infinite;
}

.dust-puff:nth-child(1) {
    width: 18px;
    height: 14px;
    bottom: 0;
    left: 0;
    animation-delay: 0s;
}

.dust-puff:nth-child(2) {
    width: 12px;
    height: 10px;
    bottom: 4px;
    left: 12px;
    animation-delay: 0.15s;
}

.dust-puff:nth-child(3) {
    width: 8px;
    height: 8px;
    bottom: 2px;
    left: 22px;
    animation-delay: 0.28s;
}

@keyframes dust-rise {
    0% {
        transform: scale(0.6) translateY(0);
        opacity: 0.7
    }

    100% {
        transform: scale(1.4) translateY(-18px);
        opacity: 0
    }
}

/* FIRE TRAIL — turbo only */
.fire-trail {
    position: absolute;
    right: calc(100% - 6px);
    top: 30%;
    bottom: 10%;
    width: 50px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.horse-wrap.turbo .fire-trail {
    opacity: 1;
}

.fire-chunk {
    position: absolute;
    font-size: 1.4rem;
    animation: fire-fly 0.4s ease-out infinite;
}

.fire-chunk:nth-child(1) {
    right: 0;
    top: 0;
    animation-delay: 0s;
}

.fire-chunk:nth-child(2) {
    right: 15px;
    top: 10px;
    font-size: 1rem;
    animation-delay: 0.13s;
}

.fire-chunk:nth-child(3) {
    right: 28px;
    top: 5px;
    font-size: 0.8rem;
    animation-delay: 0.07s;
}

@keyframes fire-fly {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1
    }

    100% {
        transform: translateX(-40px) scale(0.3);
        opacity: 0
    }
}

/* LIGHTNING — supersonic */
.lightning-bolt {
    position: absolute;
    top: 5px;
    right: calc(100% + 2px);
    font-size: 1.3rem;
    opacity: 0;
    transition: opacity 0.2s;
    animation: bolt-flash 0.2s steps(2) infinite;
    pointer-events: none;
}

.horse-wrap.supersonic .lightning-bolt {
    opacity: 1;
}

.horse-wrap.turbo .lightning-bolt {
    opacity: 1;
    font-size: 1.6rem;
    color: #ff6a00;
}

@keyframes bolt-flash {
    0% {
        opacity: 1
    }

    50% {
        opacity: 0.2
    }

    100% {
        opacity: 1
    }
}

/* Saiyan aura */
.saiyan-aura {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    border-radius: 6px;
    opacity: 0;
    transition: opacity 0.3s;
}

.saiyan-aura.active {
    opacity: 1;
    animation: saiyan-p 0.4s ease-in-out infinite alternate;
    background: radial-gradient(ellipse at center, rgba(255, 215, 0, 0.18), transparent 65%);
}

@keyframes saiyan-p {
    from {
        box-shadow: inset 0 0 18px rgba(255, 215, 0, 0.12)
    }

    to {
        box-shadow: inset 0 0 38px rgba(255, 215, 0, 0.30)
    }
}

.saiyan-aura.active::before {
    content: '⚡⚡';
    position: absolute;
    font-size: 0.9rem;
    top: 3px;
    left: 50%;
    transform: translateX(-50%);
    animation: lightning 0.3s steps(2) infinite;
    color: var(--neon-gold);
}

@keyframes lightning {
    0% {
        opacity: 1
    }

    50% {
        opacity: 0
    }

    100% {
        opacity: 1
    }
}

/* Turbo flash */
#turbo-flash {
    position: fixed;
    inset: 0;
    z-index: 490;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(ellipse at center, rgba(255, 106, 0, 0.55), transparent 70%);
    transition: opacity 0.08s;
}

#turbo-flash.flash {
    opacity: 1;
}

/* ═══ LEADERBOARD POPUP ═══ */
#lb-modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: none;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 62px 0 0 14px;
    pointer-events: none;
}

#lb-modal.open {
    display: flex;
    pointer-events: all;
}

#lb-box {
    width: 310px;
    max-height: 85vh;
    overflow-y: auto;
    background: rgba(8, 8, 16, 0.97);
    border-radius: 14px;
    border: 1px solid #222;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
    animation: lb-slide-in 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes lb-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95)
    }

    to {
        opacity: 1;
        transform: none
    }
}

#lb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid #1a1a1a;
}

.lb-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 2px;
    color: var(--neon-gold);
}

.lb-close-btn {
    background: none;
    border: none;
    color: #555;
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.lb-close-btn:hover {
    color: #fff;
}

#leaderboard {
    padding: 8px;
}

.lb-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 9px;
    border-radius: 7px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #1a1a2a;
    transition: all 0.3s;
}

.lb-item.rank-1 {
    background: rgba(255, 215, 0, 0.09);
    border-color: rgba(255, 215, 0, 0.28);
}

.lb-item.rank-2 {
    background: rgba(200, 200, 200, 0.05);
}

.lb-item.rank-3 {
    background: rgba(205, 127, 50, 0.06);
}

.lb-rank {
    font-size: 0.72rem;
    width: 18px;
    color: #555;
    flex-shrink: 0;
}

.lb-flag {
    font-size: 1.1rem;
}

.lb-info {
    flex: 1;
}

.lb-name {
    font-size: 0.78rem;
    font-weight: 700;
}

.lb-pts {
    font-size: 0.64rem;
    color: #444;
}

.lb-total {
    font-size: 0.93rem;
    font-weight: 900;
    font-family: 'Rajdhani', sans-serif;
    color: var(--neon-gold);
}

#lb-feed-title {
    padding: 8px 14px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #333;
    border-top: 1px solid #1a1a1a;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#comment-feed {
    max-height: 180px;
    overflow-y: auto;
    padding: 5px;
}

.comment-item {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    padding: 4px 6px;
    margin-bottom: 2px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.02);
    border-left: 2px solid transparent;
    font-size: 0.7rem;
    animation: slide-in 0.2s ease;
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateX(5px)
    }

    to {
        opacity: 1;
        transform: none
    }
}

.comment-flag {
    font-size: 0.85rem;
    flex-shrink: 0;
}

.comment-nick {
    font-weight: 700;
    font-size: 0.66rem;
    margin-bottom: 1px;
}

.comment-text {
    color: #444;
    word-break: break-word;
}

/* ═══ WINNER OVERLAY ═══ */
#winner-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(14px);
}

#winner-overlay.show {
    display: flex;
}

#winner-box {
    text-align: center;
    padding: 44px 56px;
    background: linear-gradient(135deg, #0a0800, #1a1200);
    border-radius: 20px;
    border: 2px solid var(--neon-gold);
    box-shadow: 0 0 60px rgba(255, 215, 0, 0.4);
    animation: winner-b 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

#winner-box::before {
    content: '';
    position: absolute;
    inset: -50%;
    background: conic-gradient(from 0deg, transparent 0%, rgba(255, 215, 0, 0.05) 25%, transparent 50%);
    animation: rotate-bg 4s linear infinite;
}

@keyframes rotate-bg {
    to {
        transform: rotate(360deg)
    }
}

@keyframes winner-b {
    from {
        transform: scale(0.4);
        opacity: 0
    }

    to {
        transform: scale(1);
        opacity: 1
    }
}

#winner-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    color: var(--neon-gold);
    letter-spacing: 5px;
    margin-bottom: 10px;
}

#winner-flag {
    font-size: 5rem;
    animation: winner-float 2s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

@keyframes winner-float {

    0%,
    100% {
        transform: translateY(0)
    }

    50% {
        transform: translateY(-12px)
    }
}

#winner-name {
    font-size: 2.5rem;
    font-weight: 900;
    margin: 6px 0;
    position: relative;
    z-index: 1;
}

#winner-score {
    font-size: 1rem;
    color: #888;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

#winner-total-wins {
    font-size: 0.88rem;
    color: var(--neon-gold);
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
    font-weight: 700;
}

#winner-box-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 501;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -10px;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0
    }
}

/* ═══ CONFIG MODAL ═══ */
#config-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
}

#config-modal.open {
    display: flex;
}

#config-box {
    width: 760px;
    max-width: 96vw;
    max-height: 92vh;
    overflow-y: auto;
    background: #0c0c18;
    border-radius: 16px;
    border: 1px solid #2a2a3a;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.75);
    padding: 22px;
}

#config-box h2 {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.5rem;
    letter-spacing: 2px;
    color: var(--neon-gold);
    margin-bottom: 14px;
}

.tab-buttons {
    display: flex;
    gap: 5px;
    margin-bottom: 13px;
    border-bottom: 1px solid #1a1a2a;
    padding-bottom: 10px;
}

.tab-btn {
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid #2a2a3a;
    background: transparent;
    color: #555;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78rem;
    transition: all 0.15s;
}

.tab-btn.active {
    background: rgba(255, 215, 0, 0.12);
    border-color: var(--neon-gold);
    color: var(--neon-gold);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Custom Gift Select inside Country Row */
.custom-gift-select {
    position: relative;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid #2a2a3a;
    border-radius: 6px;
    height: 38px;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    color: #fff;
    display: flex;
    align-items: center;
}

.custom-gift-select:hover {
    border-color: var(--neon-gold);
}

.cg-selected {
    display: flex;
    align-items: center;
    padding: 0 10px;
    height: 100%;
    width: 100%;
}

.cg-sel-img {
    width: 24px;
    height: 24px;
    object-fit: cover;
    margin-right: 8px;
    border-radius: 4px;
}

.cg-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 240px;
    background: #0c0c18;
    border: 1px solid #2a2a3a;
    border-radius: 6px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 999;
    display: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.custom-gift-select.open .cg-dropdown {
    display: block;
}

.cg-opt {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    transition: background 0.2s;
}

.cg-opt:hover {
    background: rgba(255, 255, 255, 0.1);
}

.cg-opt.disabled {
    opacity: 0.3;
    pointer-events: none;
    filter: grayscale(100%);
}

.cg-opt-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin-right: 12px;
}

.cg-opt-name {
    font-weight: 500;
}

/* Country rows — new picker style */
.country-row {
    display: grid;
    grid-template-columns: 52px 46px 1fr 1fr 36px;
    gap: 7px;
    align-items: center;
    padding: 7px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 7px;
    border: 1px solid #1a1a2a;
}

.country-row input,
.country-row select {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid #2a2a3a;
    border-radius: 6px;
    padding: 5px 8px;
    color: #fff;
    font-family: inherit;
    font-size: 0.78rem;
    outline: none;
    width: 100%;
}

.cr-flag-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    width: 44px;
    height: 34px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid #2a2a3a;
    border-radius: 6px;
    transition: background 0.15s;
}

.cr-flag-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-del {
    background: rgba(255, 56, 96, 0.1);
    border: 1px solid rgba(255, 56, 96, 0.25);
    color: var(--neon-red);
    border-radius: 5px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.btn-del:hover {
    background: rgba(255, 56, 96, 0.22);
}

.btn-add-country {
    margin-top: 8px;
    width: 100%;
    padding: 8px;
    background: rgba(0, 255, 136, 0.07);
    border: 1px dashed rgba(0, 255, 136, 0.28);
    border-radius: 7px;
    color: var(--neon-green);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s;
}

.btn-add-country:hover {
    background: rgba(0, 255, 136, 0.14);
}

/* Flag picker popup */
#flag-picker {
    position: fixed;
    z-index: 999;
    background: #0c0c18;
    border: 1px solid #2a2a3a;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    display: none;
    max-width: 340px;
    flex-direction: column;
    gap: 8px;
}

#flag-picker.open {
    display: flex;
}

#flag-picker h4 {
    font-size: 0.75rem;
    color: #555;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#flag-picker .fp-head {
    display: flex;
    gap: 8px;
    align-items: center;
}

#flag-search {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid #2a2a3a;
    border-radius: 6px;
    padding: 6px 8px;
    color: #fff;
    font-family: inherit;
    font-size: 0.75rem;
    outline: none;
}

#flag-search:focus {
    border-color: var(--neon-gold);
}

#flag-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}

.fp-group-title {
    grid-column: 1 / -1;
    font-size: 0.65rem;
    color: var(--neon-blue);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 8px;
    padding-bottom: 2px;
    border-bottom: 1px solid rgba(0, 207, 255, 0.2);
}

.flag-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.1s;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
}

.flag-opt:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--neon-gold);
}

.flag-opt-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.flag-opt-name {
    font-size: 0.5rem;
    color: #888;
    margin-top: 3px;
    text-align: center;
    word-break: break-word;
    line-height: 1.1;
}



/* Gifts tab */
.gift-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 9px;
    margin-bottom: 4px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 7px;
    border: 1px solid #1a1a2a;
}

.gift-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 4px;
}

.gift-name {
    flex: 1;
    font-size: 0.76rem;
}

.gift-diamonds {
    font-size: 0.68rem;
    color: var(--neon-blue);
}

.gift-row select {
    background: #0c0c18;
    border: 1px solid #2a2a3a;
    border-radius: 6px;
    color: #fff;
    padding: 4px 6px;
    font-family: inherit;
    font-size: 0.74rem;
    outline: none;
    min-width: 120px;
}

.gift-special-btn {
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.66rem;
    border: 1px solid rgba(255, 106, 0, 0.4);
    background: rgba(255, 106, 0, 0.1);
    color: var(--neon-orange);
    cursor: pointer;
    transition: all 0.15s;
}

.gift-special-btn.selected {
    background: rgba(255, 106, 0, 0.32);
    border-color: var(--neon-orange);
    color: #fff;
    box-shadow: 0 0 7px rgba(255, 106, 0, 0.38);
}

/* Settings tab */
.setting-row {
    margin-bottom: 13px;
}

.setting-row label {
    display: block;
    font-size: 0.76rem;
    color: #555;
    margin-bottom: 5px;
}

.setting-row input {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid #2a2a3a;
    border-radius: 7px;
    padding: 8px 12px;
    color: #fff;
    font-family: inherit;
    font-size: 0.84rem;
    outline: none;
}

.setting-row input:focus {
    border-color: var(--neon-gold);
}

.setting-hint {
    font-size: 0.66rem;
    color: #333;
    margin-top: 3px;
}

.config-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 14px;
    border-top: 1px solid #1a1a2a;
    padding-top: 13px;
    flex-wrap: wrap;
}

.btn-save {
    background: linear-gradient(135deg, var(--neon-gold), #ff9900);
    color: #001;
    padding: 9px 24px;
    font-size: 0.86rem;
    border-radius: 8px;
}

.btn-save:hover {
    filter: brightness(1.1);
}

.btn-close-modal {
    background: rgba(255, 255, 255, 0.05);
    color: #666;
    border: 1px solid #2a2a3a;
}

.btn-wins-reset {
    background: rgba(255, 56, 96, 0.08);
    color: var(--neon-red);
    border: 1px solid rgba(255, 56, 96, 0.25);
}

/* Particles */
.particle {
    position: absolute;
    pointer-events: none;
    z-index: 30;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    animation: particle-burst 0.8s forwards;
}

@keyframes particle-burst {
    from {
        transform: scale(1) translate(0, 0);
        opacity: 1
    }

    to {
        transform: scale(0) translate(var(--dx), var(--dy));
        opacity: 0
    }
}