/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #060b14;
    --panel: rgba(10, 20, 40, 0.85);
    --border: rgba(0, 255, 140, 0.15);
    --accent: #00ff8c;
    --accent2: #00d4ff;
    --danger: #ff3355;
    --gold: #ffd700;
    --girls-color: #ff33cc;
    /* Updated */
    --girls-glow: rgba(255, 51, 204, 0.4);
    /* Added */
    --boys-color: #00ccff;
    /* Updated */
    --boys-glow: rgba(0, 204, 255, 0.4);
    /* Added */
    --bg-dark: #05080a;
    /* Added */
    --text: #e0f0ff;
    --text-dim: #6a8a9a;
    --panel-radius: 14px;
    --font-game: 'Orbitron', monospace;
    --font-ui: 'Inter', sans-serif;
    --topbar-h: 62px;
}

html,
body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    overflow: hidden;
}

/* ===== BACKGROUNDS ===== */
.bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image: linear-gradient(rgba(0, 255, 140, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(0, 255, 140, 0.03) 1px, transparent 1px);
    background-size: 36px 36px;
    pointer-events: none;
}

.bg-glow {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: radial-gradient(ellipse 60% 40% at 15% 50%, rgba(0, 255, 140, 0.05) 0%, transparent 70%), radial-gradient(ellipse 50% 40% at 85% 50%, rgba(0, 212, 255, 0.05) 0%, transparent 70%);
    pointer-events: none;
}

/* ===== TOP BAR ===== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: rgba(4, 10, 18, 0.9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

/* Hide Solo connection UI when in VS Mode */
body.mode-vs .solo-connection-ui {
    display: none;
}

.top-brand {
    font-family: var(--font-game);
    font-size: 18px;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: 2px;
    white-space: nowrap;
    text-shadow: 0 0 16px var(--accent);
    flex-shrink: 0;
}

.top-brand span {
    color: var(--accent2);
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    flex-shrink: 0;
}

.mode-btn {
    padding: 7px 16px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    font-family: var(--font-game);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    background: transparent;
    color: var(--text-dim);
    transition: all 0.25s;
}

.mode-btn.active {
    background: linear-gradient(135deg, var(--accent), #00b860);
    color: #000;
    box-shadow: 0 0 16px rgba(0, 255, 140, 0.4);
}

.mode-btn:not(.active):hover {
    background: rgba(0, 255, 140, 0.1);
    color: var(--accent);
}

/* Layout Toggle */
.layout-toggle {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 4px;
    flex-shrink: 0;
}

.layout-btn {
    padding: 7px 16px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    font-family: var(--font-game);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    background: transparent;
    color: var(--text-dim);
    transition: all 0.25s;
}

.layout-btn.active {
    background: linear-gradient(135deg, var(--accent2), #0088cc);
    color: #fff;
    box-shadow: 0 0 16px rgba(0, 212, 255, 0.4);
}

.layout-btn:not(.active):hover {
    background: rgba(0, 212, 255, 0.1);
    color: var(--accent2);
}

/* Top Connection */
.top-connection {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.input-group-inline {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.input-group-inline:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(0, 255, 140, 0.2);
}

.input-prefix {
    padding: 0 8px;
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    background: rgba(0, 255, 140, 0.08);
    height: 34px;
    display: flex;
    align-items: center;
}

.input-group-inline input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    padding: 6px 10px;
    font-size: 13px;
    font-family: var(--font-ui);
    width: 140px;
}

.input-group-inline input::placeholder {
    color: var(--text-dim);
}

.btn-connect {
    padding: 7px 14px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    font-family: var(--font-game);
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent), #00b860);
    color: #000;
    box-shadow: 0 0 12px rgba(0, 255, 140, 0.3);
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-connect:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 20px rgba(0, 255, 140, 0.5);
}

.btn-connect:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-connect.disconnect {
    background: linear-gradient(135deg, var(--danger), #cc0033);
    color: #fff;
    box-shadow: 0 0 12px rgba(255, 51, 85, 0.3);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: all 0.3s;
    white-space: nowrap;
}

.status-badge.online {
    background: rgba(0, 255, 140, 0.1);
    border-color: rgba(0, 255, 140, 0.3);
    color: var(--accent);
}

.status-badge.offline {
    background: rgba(255, 51, 85, 0.1);
    border-color: rgba(255, 51, 85, 0.3);
    color: var(--danger);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.online .status-dot {
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1)
    }

    50% {
        opacity: .5;
        transform: scale(.7)
    }
}

/* ===== GAME PAGES ===== */
.game-page {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* VS Mode game page needs full flex control */
#vsMode.game-page {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.game-layout {
    display: grid;
    grid-template-columns: 250px 1fr 230px;
    flex: 1;
    min-height: 0;
    gap: 10px;
    padding: 10px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--panel-radius);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    backdrop-filter: blur(20px);
}

.panel::-webkit-scrollbar {
    width: 3px;
}

.panel::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 2px;
}

.section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-label {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-dim);
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
}

.stat-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 9px;
    text-align: center;
}

.stat-value {
    font-family: var(--font-game);
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
}

.stat-label {
    font-size: 9px;
    color: var(--text-dim);
    margin-top: 2px;
    letter-spacing: 1px;
}

.donor-card {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 165, 0, 0.05));
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 9px;
    padding: 10px;
    text-align: center;
}

.donor-name {
    font-family: var(--font-game);
    font-size: 14px;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.donor-diamonds {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 3px;
}

.gift-feed {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
}

.gift-empty {
    font-size: 11px;
    color: var(--text-dim);
    text-align: center;
    padding: 12px;
}

.gift-item {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 7px;
    padding: 7px 9px;
    animation: giftSlide .3s ease;
}

@keyframes giftSlide {
    from {
        opacity: 0;
        transform: translateX(-8px)
    }

    to {
        opacity: 1;
        transform: translateX(0)
    }
}

.gift-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.gift-info {
    flex: 1;
    min-width: 0;
}

.gift-user {
    font-size: 10px;
    font-weight: 600;
    color: var(--accent2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gift-details {
    font-size: 9px;
    color: var(--text-dim);
}

.gift-apples {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    white-space: nowrap;
}

.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    height: 100%;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    flex: 1;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 0 2px rgba(0, 255, 140, 0.3), 0 0 30px rgba(0, 255, 140, 0.1);
}

#gameCanvas {
    display: block;
    background: #060f1a;
}

.how-to {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.how-to li {
    font-size: 11px;
    color: var(--text-dim);
    padding: 7px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 5px;
    border-left: 2px solid var(--accent);
    line-height: 1.5;
}

.how-to li b {
    color: var(--text);
}

.gifts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.gifts-table th {
    text-align: left;
    padding: 5px 7px;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.gifts-table td {
    padding: 5px 7px;
    color: var(--text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.gifts-table tr:hover td {
    background: rgba(0, 255, 140, 0.04);
}

.speed-control {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-size: 11px;
    color: var(--text-dim);
}

.speed-control span {
    color: var(--accent);
    font-weight: 700;
    font-family: var(--font-game);
}

#speedSlider {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ===== OVERLAY ===== */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(6, 11, 20, 0.93);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: overlayFadeIn .5s ease;
    backdrop-filter: blur(8px);
}

@keyframes overlayFadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

.overlay-card {
    text-align: center;
    padding: 36px 44px;
    background: rgba(10, 20, 40, 0.96);
    border: 1px solid rgba(255, 51, 85, 0.4);
    border-radius: 18px;
    box-shadow: 0 0 50px rgba(255, 51, 85, 0.2);
    animation: cardPop .4s cubic-bezier(.175, .885, .32, 1.275);
}

@keyframes cardPop {
    from {
        opacity: 0;
        transform: scale(.7)
    }

    to {
        opacity: 1;
        transform: scale(1)
    }
}

.overlay-emoji {
    font-size: 55px;
    margin-bottom: 6px;
    animation: floatEmoji 2s ease-in-out infinite;
}

@keyframes floatEmoji {

    0%,
    100% {
        transform: translateY(0)
    }

    50% {
        transform: translateY(-7px)
    }
}

.overlay-title {
    font-family: var(--font-game);
    font-size: 36px;
    font-weight: 900;
    color: var(--danger);
    text-shadow: 0 0 28px rgba(255, 51, 85, 0.8);
    letter-spacing: 4px;
    margin-bottom: 8px;
}

.overlay-score {
    font-size: 16px;
    color: var(--text-dim);
    margin-bottom: 20px;
}

.overlay-score span {
    color: var(--accent);
    font-weight: 700;
    font-family: var(--font-game);
}

.overlay-donor {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12), rgba(255, 165, 0, 0.06));
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 12px;
    padding: 18px 24px;
    margin-bottom: 20px;
    animation: donorShine 2s ease-in-out infinite alternate;
}

@keyframes donorShine {
    from {
        box-shadow: 0 0 18px rgba(255, 215, 0, 0.2)
    }

    to {
        box-shadow: 0 0 35px rgba(255, 215, 0, 0.5)
    }
}

.overlay-donor-label {
    font-size: 9px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 215, 0, .7);
    margin-bottom: 5px;
}

.overlay-donor-name {
    font-family: var(--font-game);
    font-size: 22px;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 16px rgba(255, 215, 0, .6);
    margin-bottom: 3px;
}

.overlay-donor-diamonds {
    font-size: 16px;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.overlay-donor-thanks {
    font-size: 12px;
    color: var(--accent2);
    font-style: italic;
}

.restart-countdown {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 14px;
}

.restart-countdown span {
    color: var(--accent);
    font-weight: 700;
    font-family: var(--font-game);
}

.btn-restart {
    padding: 12px 22px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    font-family: var(--font-game);
    font-weight: 700;
    font-size: 12px;
    background: linear-gradient(135deg, var(--accent2), #0090cc);
    color: #000;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
    transition: all .2s;
}

.btn-restart:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 212, 255, 0.6);
}

.gift-popup {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 20, 40, .95);
    border: 1px solid rgba(0, 212, 255, .5);
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent2);
    z-index: 5;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 0 20px rgba(0, 212, 255, .3);
    animation: popupAnim .3s ease;
}

@keyframes popupAnim {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-8px)
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0)
    }
}

/* Canvas area fills remaining space after header */
.vs-canvas-area {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 6px 10px 10px;
    position: relative;
}

.vs-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    flex: 1;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
    background: #040a12;
    box-shadow: 0 0 0 2px rgba(0, 255, 140, 0.3), 0 0 40px rgba(0, 0, 0, 0.5);
}

/* VS canvas area fills remaining space after the VS header */
/* Canvas area takes ALL remaining height after the VS header */
.vs-canvas-area {
    flex: 1 1 0;
    /* grow AND allow shrinking below content height */
    min-height: 0;
    /* critical: override browser min-height:auto on flex child */
    overflow: hidden;
    /* hard clip, nothing leaks past this */
    display: flex;
    justify-content: center;
    align-items: stretch;
    position: relative;
    padding: 8px 10px;
}

/* Wrapper is the visible green-bordered box, fills the area completely */
.vs-canvas-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    /* match the flex area height */
    border: 3px solid var(--accent);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 20px rgba(0, 255, 140, 0.3);
    overflow: hidden;
    /* clip canvas if it ever exceeds – belt & suspenders */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Canvas sized entirely by JS — no CSS dimensions */
#vsCanvas {
    display: block;
    background: #060f1a;
    max-width: 100%;
    max-height: 100%;
}

#vsParticleCanvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    max-width: 100%;
    max-height: 100%;
}

/* VS Header — compact, no wasted space */
.vs-header {
    padding: 2px 16px 4px;
    flex-shrink: 0;
}

.mini-badge {
    padding: 2px 6px;
    font-size: 9px;
}

.mini-badge .status-dot {
    width: 6px;
    height: 6px;
}

.vs-info-bar {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 1px;
    padding: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vs-connection-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group-inline.mini {
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-group-inline.mini input {
    width: 80px;
    font-size: 11px;
    background: transparent;
    border: none;
    color: #fff;
    outline: none;
}

.btn.mini {
    padding: 4px 10px;
    font-size: 10px;
    height: auto;
}

.vs-scores {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.vs-team {
    text-align: center;
    min-width: 160px;
}

.vs-team-label {
    font-family: var(--font-game);
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 3px;
}

.girls-team .vs-team-label {
    color: var(--girls-color);
    text-shadow: 0 0 20px var(--girls-color);
}

.boys-team .vs-team-label {
    color: var(--boys-color);
    text-shadow: 0 0 20px var(--boys-color);
}

.vs-wins {
    font-size: 11px;
    color: var(--text-dim);
}

.vs-score-big {
    font-family: var(--font-game);
    font-size: 38px;
    font-weight: 900;
}

.girls-team .vs-score-big {
    color: var(--girls-color);
    text-shadow: 0 0 24px var(--girls-color);
}

.boys-team .vs-score-big {
    color: var(--boys-color);
    text-shadow: 0 0 24px var(--boys-color);
}

.vs-divider {
    font-family: var(--font-game);
    font-size: 22px;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 2px;
}

/* VS Win overlay title */
.overlay-title.girls-win {
    color: var(--girls-color);
    text-shadow: 0 0 28px var(--girls-color);
}

.overlay-title.boys-win {
    color: var(--boys-color);
    text-shadow: 0 0 28px var(--boys-color);
}

/* VS Comment Prompt Instruction */
.vs-comment-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-game);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: none;
    z-index: 5;
    text-align: center;
    white-space: nowrap;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

/* VS Center Gifts Overlay — positioned at the bottom per user request */
.vs-center-gifts {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    z-index: 10;
    pointer-events: none;
}

.vs-gift-col {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.vs-gift-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.vs-gift-row {
    font-size: 13px;
    font-weight: 900;
    font-family: var(--font-game);
    letter-spacing: 0.5px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
    text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.9), 0px 0px 6px rgba(0, 0, 0, 1);
    white-space: nowrap;
}

.girls-col .vs-gift-row {
    flex-direction: row-reverse;
}

.boys-col .vs-gift-row {
    flex-direction: row;
}

.vs-gift-row img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.vs-center-logo {
    display: flex;
    align-items: flex-end;
    padding-bottom: 25px;
    margin: 0 10px;
}

.vs-center-logo img {
    height: 55px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.8));
}

/* VS Center Powers Legend (Plantilla de Poderes) */
.vs-center-powers {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    z-index: 10;
    pointer-events: none;
    width: 100%;
}

.vs-power-col {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.girls-powers {
    align-items: flex-end;
}

.boys-powers {
    align-items: flex-start;
}

.vs-power-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vs-power-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-game);
    font-size: 14px;
    font-weight: 800;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
}

.girls-powers .vs-power-row {
    flex-direction: row-reverse;
    color: var(--girls-color);
}

.boys-powers .vs-power-row {
    flex-direction: row;
    color: var(--boys-color);
}

.vs-power-row img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));
}

.vs-power-name {
    letter-spacing: 1px;
}

.vs-power-divider {
    width: 2px;
    height: 100px;
    background: repeating-linear-gradient(to bottom, transparent, transparent 5px, rgba(255, 255, 255, 0.1) 5px, rgba(255, 255, 255, 0.1) 10px);
    margin: 0 10px;
}

.frozen-label {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 10px;
    font-weight: 700;
    color: #00aaff;
    font-family: var(--font-game);
    letter-spacing: 1px;
    animation: frozenBlink .6s infinite alternate;
}

@keyframes frozenBlink {
    from {
        opacity: .5
    }

    to {
        opacity: 1
    }
}

/* ===== GIFT CONFIG BUTTON ===== */
.btn-gifts-config {
    margin-left: 12px;
    padding: 5px 12px;
    border: none;
    cursor: pointer;
    border-radius: 7px;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 77, 187, 0.15);
    border: 1px solid rgba(255, 77, 187, 0.4);
    color: var(--girls-color);
    transition: all 0.2s;
}

.btn-gifts-config:hover {
    background: rgba(255, 77, 187, 0.3);
    box-shadow: 0 0 12px rgba(255, 77, 187, 0.3);
}

/* ===== GIFTS MODAL ===== */
.modal-bg {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.modal-card {
    background: rgba(10, 18, 35, 0.98);
    border: 1px solid var(--border);
    border-radius: 18px;
    width: min(800px, 95vw);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 60px rgba(0, 255, 140, 0.1), 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: cardPop 0.3s cubic-bezier(.175, .885, .32, 1.275);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 12px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-family: var(--font-game);
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255, 51, 85, 0.1);
    color: var(--danger);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 51, 85, 0.3);
}

.modal-desc {
    padding: 10px 24px;
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.6;
}

.modal-search {
    padding: 0 24px 10px;
}

.modal-search input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text);
    font-size: 13px;
    font-family: var(--font-ui);
    outline: none;
    transition: border-color 0.2s;
}

.modal-search input:focus {
    border-color: var(--accent);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.modal-body::-webkit-scrollbar {
    width: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 2px;
}

.loading-gifts {
    grid-column: 1/-1;
    text-align: center;
    color: var(--text-dim);
    padding: 24px;
    font-size: 13px;
}

.gift-lib-card {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.2s;
}

.gift-lib-card:hover {
    border-color: rgba(0, 255, 140, 0.3);
}

.gift-lib-card.team-girls {
    border-color: rgba(255, 77, 187, 0.4);
    background: rgba(255, 77, 187, 0.07);
}

.gift-lib-card.team-boys {
    border-color: rgba(0, 204, 255, 0.4);
    background: rgba(0, 204, 255, 0.07);
}

.gift-lib-card.team-both {
    border-color: rgba(255, 215, 0, 0.3);
    background: rgba(255, 215, 0, 0.05);
}

.gift-lib-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gift-lib-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.3);
}

.gift-lib-img-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(0, 255, 140, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.gift-lib-info {
    flex: 1;
    min-width: 0;
}

.gift-lib-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gift-lib-dia {
    font-size: 10px;
    color: var(--text-dim);
}

.gift-team-selector {
    display: flex;
    gap: 4px;
}

.team-sel-btn {
    flex: 1;
    padding: 4px 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    transition: all 0.2s;
    font-family: var(--font-ui);
}

.team-sel-btn.active-girls {
    background: rgba(255, 77, 187, 0.3);
    border-color: var(--girls-color);
    color: var(--girls-color);
}

.team-sel-btn.active-boys {
    background: rgba(0, 204, 255, 0.3);
    border-color: var(--boys-color);
    color: var(--boys-color);
}

.team-sel-btn.active-both {
    background: rgba(255, 215, 0, 0.2);
    border-color: var(--gold);
    color: var(--gold);
}

.team-sel-btn:hover {
    opacity: 0.85;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
}

.btn-cancel {
    padding: 9px 18px;
    border: 1px solid var(--border);
    cursor: pointer;
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    background: transparent;
    color: var(--text-dim);
    transition: all 0.2s;
}

.btn-cancel:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.btn-save {
    padding: 9px 18px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    font-family: var(--font-game);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent), #00b860);
    color: #000;
    box-shadow: 0 0 12px rgba(0, 255, 140, 0.3);
    transition: all 0.2s;
}

.btn-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 20px rgba(0, 255, 140, 0.5);
}

/* ===== VS DONOR MINI (in header) ===== */
.vs-donor-mini {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    justify-content: center;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 8px;
    padding: 4px 10px;
}

.vs-donor-crown {
    font-size: 12px;
}

.vs-donor-nick {
    font-size: 11px;
    font-weight: 700;
    color: var(--gold);
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vs-donor-dia {
    font-size: 10px;
    color: var(--text-dim);
}

/* ===== VS DONOR WINNER BLOCKS ===== */
.vs-donor-winner-block {
    border-radius: 10px;
    padding: 10px 20px;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.08), rgba(255, 165, 0, 0.04));
}

.vs-donor-winner-label {
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(255, 215, 0, 0.6);
    margin-bottom: 4px;
}

/* ===== VS GIFT PANEL TITLE ===== */
.vs-gift-panel-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.vs-gift-empty {
    font-size: 10px;
    color: var(--text-dim);
    text-align: center;
    padding: 4px;
}

/* ===== 3-COLUMN GIFT MODAL ===== */
.modal-card-wide {
    max-width: 1080px !important;
    width: 96vw !important;
    height: 82vh !important;
    display: flex;
    flex-direction: column;
}

.modal-columns {
    display: flex;
    gap: 10px;
    flex: 1;
    min-height: 0;
    padding: 0 16px;
    overflow: hidden;
}

.modal-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
}

.modal-col-library {
    flex: 1.6;
    /* wider — holds all cards */
}

.modal-col-team {
    flex: 1;
}

.modal-col-header {
    padding: 9px 12px;
    font-family: var(--font-game);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    text-align: center;
    flex-shrink: 0;
}

.girls-col-header {
    color: var(--girls-color);
    text-shadow: 0 0 12px var(--girls-color);
}

.boys-col-header {
    color: var(--boys-color);
    text-shadow: 0 0 12px var(--boys-color);
}

.modal-col-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-col-body::-webkit-scrollbar {
    width: 3px;
}

.modal-col-body::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 2px;
}

/* ── Apple count row inside gift card ── */
.gift-apples-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.apples-label {
    font-size: 10px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.apples-input {
    width: 56px;
    padding: 3px 6px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 255, 140, 0.2);
    border-radius: 5px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-game);
    text-align: center;
    outline: none;
}

.apples-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 6px rgba(0, 255, 140, 0.2);
}

.btn-default-apples {
    font-size: 9px;
    padding: 3px 7px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-default-apples:hover {
    background: rgba(0, 255, 140, 0.12);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-default-inactive {
    opacity: 0.45;
}

/* ── Assigned gift rows (Girls/Boys columns) ── */
.assigned-gift-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    animation: giftSlide .25s ease;
    flex-shrink: 0;
}

.assigned-img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
}

.assigned-img-placeholder {
    font-size: 18px;
    flex-shrink: 0;
}

.assigned-info {
    flex: 1;
    min-width: 0;
}

.assigned-name {
    font-size: 11px;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assigned-meta {
    font-size: 10px;
    color: var(--text-dim);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.assigned-power-tag {
    font-weight: 800;
    letter-spacing: 0.5px;
    text-shadow: 0 0 5px rgba(255, 221, 68, 0.2);
}

.assigned-meta b {
    color: var(--accent);
}

.assigned-empty {
    text-align: center;
    color: var(--text-dim);
    font-size: 11px;
    padding: 24px 8px;
    opacity: 0.6;
}

/* ===== TIKTOK LAYOUT MODS ===== */
body.tiktok-layout {
    overflow: hidden;
}

body.tiktok-layout .top-bar {
    justify-content: center;
}

body.tiktok-layout .top-connection,
body.tiktok-layout .solo-connection-ui,
body.tiktok-layout .top-brand {
    display: none;
}

body.tiktok-layout .game-page {
    position: absolute;
    top: var(--topbar-h);
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: min(100vw, calc((100vh - var(--topbar-h)) * 9 / 16));
    background: #000;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent vertical overflow */
}

body.tiktok-layout .game-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

body.tiktok-layout .panel-left,
body.tiktok-layout .panel-right {
    display: none !important;
}

body.tiktok-layout .game-area,
body.tiktok-layout .vs-canvas-area {
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    display: flex;
    flex-direction: column;
    padding: 5px !important;
}

body.tiktok-layout .vs-canvas-wrapper,
body.tiktok-layout #soloCanvasWrapper {
    max-width: 100% !important;
    max-height: 100% !important;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

body.tiktok-layout canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
}

body.tiktok-layout .vs-header {
    padding: 6px 10px;
}

body.tiktok-layout .vs-score-big {
    font-size: 24px;
}

body.tiktok-layout .vs-team-label {
    font-size: 14px;
}

body.tiktok-layout .vs-comment-prompt {
    font-size: 12px;
    white-space: normal;
    padding: 0 20px;
    line-height: 1.5;
}

body.tiktok-layout .vs-center-gifts {
    bottom: 30px;
    gap: 8px;
}

body.tiktok-layout .vs-gift-row img {
    width: 18px;
    height: 18px;
}

/* Solo TikTok Gifts Overlays */
body.tiktok-layout .solo-tiktok-gifts {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    display: flex !important;
    flex-direction: column;
    z-index: 10;
}

body.tiktok-layout .solo-tiktok-gifts .vs-gift-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

body.tiktok-layout .solo-tiktok-gifts .vs-gift-row {
    font-size: 11px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Solo TikTok Header Info Button */
.btn-info-mini {
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

/* Solo Gift Legend Overlay */
.solo-legend-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.solo-legend-overlay .modal-card {
    width: 280px;
    background: #05080a;
    border: 1px solid var(--accent);
    padding: 20px;
}

.solo-legend-overlay h3 {
    margin-bottom: 15px;
    font-size: 14px;
    color: var(--accent);
}

/* ===== FLOATING POWERS PANEL ===== */
.powers-panel-float {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 200;
    width: 210px;
    background: rgba(8, 14, 26, 0.96);
    border: 1px solid rgba(255, 221, 68, 0.4);
    border-radius: 12px;
    box-shadow: 0 0 24px rgba(255, 221, 68, 0.15), 0 8px 32px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    overflow: hidden;
    transition: all 0.25s ease;
}

.powers-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(255, 221, 68, 0.1);
    border-bottom: 1px solid rgba(255, 221, 68, 0.25);
    font-family: var(--font-game);
    font-size: 11px;
    font-weight: 700;
    color: #ffdd44;
    letter-spacing: 1.5px;
    cursor: pointer;
    user-select: none;
}

.powers-panel-toggle {
    background: none;
    border: none;
    color: #ffdd44;
    font-size: 10px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: transform 0.2s;
}

.powers-panel-float.collapsed .powers-panel-toggle {
    transform: rotate(-90deg);
}

.powers-panel-body {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 280px;
    overflow-y: auto;
    transition: max-height 0.25s ease, padding 0.25s ease;
}

.powers-panel-float.collapsed .powers-panel-body {
    max-height: 0;
    padding: 0 10px;
    overflow: hidden;
}

.powers-panel-body::-webkit-scrollbar {
    width: 3px;
}

.powers-panel-body::-webkit-scrollbar-thumb {
    background: rgba(255, 221, 68, 0.4);
    border-radius: 2px;
}

.powers-panel-empty {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    padding: 10px 4px;
    line-height: 1.5;
}

.power-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 7px;
    padding: 6px 8px;
    border-left: 3px solid transparent;
    font-size: 10px;
}

.power-row.power-freeze {
    border-left-color: #00aaff;
}

.power-row.power-speed {
    border-left-color: #00ff8c;
}

.power-row.power-cut {
    border-left-color: #ff3355;
}

.power-row.power-ghost {
    border-left-color: #cc88ff;
}

.power-row-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 4px;
}

.power-row-img-placeholder {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.power-row-info {
    flex: 1;
    min-width: 0;
}

.power-row-name {
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
}

.power-row-type {
    font-size: 9px;
    margin-top: 1px;
}

.power-type-freeze {
    color: #00aaff;
}

.power-type-speed {
    color: #00ff8c;
}

.power-type-cut {
    color: #ff3355;
}

.power-type-ghost {
    color: #cc88ff;
}

/* ── Universal Powers Config Modal ── */
.pcfg-row {
    display: grid;
    grid-template-columns: 1fr 160px 160px;
    gap: 6px;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.pcfg-row:last-child {
    border-bottom: none;
}

.pcfg-gift-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.pcfg-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 4px;
    flex-shrink: 0;
}

.pcfg-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pcfg-dia {
    font-size: 9px;
    color: var(--text-dim);
}

.pcfg-power-select {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 11px;
    font-family: var(--font-ui);
    outline: none;
    cursor: pointer;
}

.pcfg-power-select:focus {
    border-color: var(--accent);
}

.pcfg-team-btns {
    display: flex;
    gap: 3px;
    justify-content: center;
}

.pcfg-team-btn {
    flex: 1;
    padding: 3px 2px;
    font-size: 9px;
    font-weight: 700;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.pcfg-team-btn.active-girls {
    background: rgba(255, 77, 187, 0.3);
    border-color: var(--girls-color);
    color: var(--girls-color);
}

.pcfg-team-btn.active-both {
    background: rgba(255, 215, 0, 0.2);
    border-color: var(--gold);
    color: var(--gold);
}

.pcfg-team-btn.active-boys {
    background: rgba(0, 204, 255, 0.3);
    border-color: var(--boys-color);
    color: var(--boys-color);
}

.pcfg-team-btn:hover {
    opacity: 0.85;
}