/* ============================================
   eFootball Squad Generator — Teambuilder Styles
   ============================================ */

/* Hide scrollbars globally but keep scrolling */
.tb-browser::-webkit-scrollbar,
.tb-squad__list::-webkit-scrollbar {
    display: none;
}

.tb-browser,
.tb-squad__list {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ── Browser Tab Switcher ── */
.tb-browser-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.tb-browser-tab {
    flex: 1;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-muted);
    transition: all 0.2s;
    text-align: center;
}
.tb-browser-tab:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}
.tb-browser-tab.active {
    color: #fff;
    background: var(--accent);
}
.tb-browser-tab--epic.active {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
}
.tb-browser-tab--new.active {
    background: linear-gradient(135deg, var(--accent), var(--cyan));
}

/* ── Epic Cards Grid (Team Builder) ── */
.tb-epics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

/* ── New Cards Grid (Team Builder) ── */
.tb-new-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

/* New card selected state override for Team Builder */
.tb-new-grid .player-card-new.is-selected {
    opacity: 0.5;
    border-color: #22c55e;
}
.tb-new-grid .player-card-new.is-selected::after {
    content: '✓';
    position: absolute;
    top: 6px; right: 6px;
    width: 20px; height: 20px;
    background: #22c55e;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    z-index: 10;
}
.tb-new-grid .player-card-new.is-selected:hover {
    opacity: 0.65;
    border-color: #ef4444;
}
.tb-new-grid .player-card-new.is-selected:hover::after {
    content: '✕';
    background: #ef4444;
}

.tb-epic-card {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    aspect-ratio: 0.7;
    background: var(--bg-card);
    border: 2px solid transparent;
}
.tb-epic-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 24px rgba(168, 85, 247, 0.25), 0 0 12px rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.4);
}
.tb-epic-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.tb-epic-card__overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 6px 8px 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 50%, transparent 100%);
    pointer-events: none;
}
.tb-epic-card__name {
    display: none !important;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
}
.tb-epic-card__meta {
    display: none  !important;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}
.tb-epic-card__ovr {
    font-size: 0.75rem;
    font-weight: 900;
    color: #d8b4fe;
    text-shadow: 0 0 6px rgba(168, 85, 247, 0.5);
}
.tb-epic-card__pos {
    font-size: 0.55rem;
    font-weight: 700;
    color: rgba(255,255,255,0.7);
    background: rgba(168, 85, 247, 0.3);
    padding: 1px 4px;
    border-radius: 3px;
}

/* Epic card selected state */
.tb-epic-card.is-selected {
    opacity: 0.5;
    border-color: #22c55e;
}
.tb-epic-card.is-selected::after {
    content: '✓';
    position: absolute;
    top: 6px; right: 6px;
    width: 20px; height: 20px;
    background: #22c55e;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    z-index: 3;
}
.tb-epic-card.is-selected:hover {
    opacity: 0.65;
    border-color: #ef4444;
}
.tb-epic-card.is-selected:hover::after {
    content: '✕';
    background: #ef4444;
}

/* ── Epic Squad Item Styling ── */
.squad-item--epic {
    border-left: 3px solid #a855f7;
}
.squad-item__img--epic {
    border-radius: 4px;
    border-color: #a855f7;
}
.squad-item__epic-badge {
    display: inline-block;
    margin-left: 4px;
    padding: 0 4px;
    border-radius: 3px;
    font-size: 0.55rem;
    font-weight: 800;
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

/* ── Hero Section ── */
.tb-hero {
    background: linear-gradient(135deg, rgba(59,130,246,0.08) 0%, transparent 60%);
    border-bottom: 1px solid var(--border-color);
    padding: 28px 0 20px;
}

.tb-hero__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

.tb-hero__text {
    flex-shrink: 0;
}

.tb-hero__title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.tb-hero__sub {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.tb-hero__search {
    flex: 1;
    max-width: 600px;
}

.tb-hero__info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.tb-players-counter {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.tb-players-counter__value {
    color: var(--accent);
    font-weight: 800;
}

/* ── Layout (Step 1) ── */
.tb-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 0;
    min-height: calc(100vh - 170px);
}

/* ── Player Browser (Left) ── */
.tb-browser {
    padding: 20px 24px 48px;
    overflow-y: auto;
    max-height: calc(100vh - 170px);
}

/* Search Bar */
.tb-search-bar { margin-bottom: 0; }

.tb-search-bar .search-input-wrap { position: relative; }

.tb-search-bar .search-input-wrap svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 16px;
    height: 16px;
    pointer-events: none;
}

.tb-search-bar .search-input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tb-search-bar .search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.tb-search-bar .search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Results info */
.tb-results-info {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.tb-results-info span {
    color: var(--text-secondary);
    font-weight: 700;
}

/* Player card selected — still clickable (for deselect) */
.player-card.is-selected {
    border-left-color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
    opacity: 0.55;
    cursor: pointer;
}

.player-card.is-selected::after {
    content: '✓';
    font-size: 14px;
    font-weight: 800;
    color: #22c55e;
    margin-left: 4px;
    flex-shrink: 0;
}

.tb-browser .player-card {
    cursor: pointer;
    user-select: none;
}

.tb-browser .player-card:hover:not(.is-selected) {
    border-left-color: var(--accent);
    background: var(--bg-card-hover);
}

.tb-browser .player-card.is-selected:hover {
    opacity: 0.7;
    background: rgba(239, 68, 68, 0.08);
    border-left-color: #ef4444;
}

.tb-browser .player-card.is-selected:hover::after {
    content: '✕';
    color: #ef4444;
}

/* Loading */
.tb-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.tb-loading__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 14px;
    animation: spin 0.8s linear infinite;
}

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

/* Empty */
.tb-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.tb-empty svg {
    width: 36px;
    height: 36px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.tb-empty h3 {
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.tb-empty p { font-size: 0.82rem; }

/* Load More */
.tb-load-more {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 20px 0 8px;
}

.tb-load-more > span {
    display: inline-flex;
}

.btn-load-more {
    padding: 10px 36px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-load-more:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-draft-generate {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 28px;
    border: 1px solid rgba(57, 255, 20, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(57, 255, 20, 0.08);
    color: #a7f3d0;
    font-size: 13px;
    font-weight: 800;
    transition: transform 0.2s, border-color 0.2s, background 0.2s;
}

.btn-draft-generate:hover {
    transform: translateY(-1px);
    border-color: rgba(57, 255, 20, 0.7);
    background: rgba(57, 255, 20, 0.14);
}

/* ===================================
   SQUAD SIDEBAR (right column, Step 1)
   =================================== */
.tb-squad-sidebar {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 170px);
    position: sticky;
    top: 65px;
    overflow: hidden;
}

.tb-squad__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border-color);
}

.tb-squad__title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
}

.tb-squad__count {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
}

.tb-squad__count span {
    color: var(--accent);
}

.tb-squad__list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px;
}

.tb-squad__empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* Squad Item */
.squad-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    margin-bottom: 4px;
    animation: squadSlide 0.25s ease;
    cursor: default;
}

@keyframes squadSlide {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}

.squad-item__img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.squad-item__info {
    flex: 1;
    min-width: 0;
}

.squad-item__name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.squad-item__pos {
    font-size: 0.6rem;
    color: var(--text-muted);
}

.squad-item__pos .pos-tag {
    margin-right: 4px;
}

.squad-item__ovr-input {
    width: 42px;
    padding: 3px 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    font-family: inherit;
    text-align: center;
    flex-shrink: 0;
    transition: border-color 0.2s;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Hide number input arrows */
.squad-item__ovr-input::-webkit-outer-spin-button,
.squad-item__ovr-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.squad-item__ovr-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

/* Squad Footer */
.tb-squad__footer {
    padding: 10px 14px 14px;
    border-top: 1px solid var(--border-color);
}

.tb-error {
    color: #ef4444;
    font-size: 12px;
    min-height: 14px;
    margin-bottom: 4px;
}

.tb-gen-loading {
    display: none;
    text-align: center;
    padding: 16px;
    color: var(--text-secondary);
}

.tb-gen-loading.active { display: block; }

/* Generate Button */
.tb-btn-generate {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--accent), #06b6d4);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tb-btn-generate:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.tb-btn-generate:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

/* ===================================
   AI LOADING OVERLAY
   =================================== */
.ai-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #0d1b2a 0%, #040914 100%);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: aiFadeIn 0.3s ease;
    overflow: hidden;
}

/* Premium animated grid background */
.ai-overlay::before {
    content: '';
    position: absolute;
    inset: -50%;
    background-image: 
        linear-gradient(rgba(59, 130, 246, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.1) 1px, transparent 1px);
    background-size: 40px 40px;
    transform: perspective(500px) rotateX(60deg) translateY(0);
    animation: gridMove 10s linear infinite;
    opacity: 0.5;
    pointer-events: none;
}

@keyframes gridMove {
    0% { transform: perspective(500px) rotateX(50deg) translateY(0); }
    100% { transform: perspective(500px) rotateX(50deg) translateY(40px); }
}

@keyframes aiFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ai-overlay__content {
    text-align: center;
    padding: 50px 60px;
    background: rgba(10, 15, 25, 0.6);
    border: 1px solid rgba(59, 130, 246, 0.2);
    box-shadow: 0 0 60px rgba(59, 130, 246, 0.05), inset 0 0 30px rgba(59, 130, 246, 0.05);
    border-radius: 20px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    z-index: 2;
}

.ai-overlay__icon {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-brain-icon {
    color: var(--accent);
    animation: aiFloat 2s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.5));
}

@keyframes aiFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.ai-pulse-ring {
    position: absolute;
    inset: 0;
    border: 2px solid var(--accent);
    border-radius: 50%;
    animation: aiPulse 2s ease-out infinite;
    opacity: 0;
}

.ai-pulse-ring--delay {
    animation-delay: 0.8s;
}

@keyframes aiPulse {
    0%   { transform: scale(0.5); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

.ai-overlay__title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.ai-overlay__sub {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

#aiSubText {
    transition: opacity 0.2s ease;
}

.ai-dots::after {
    content: '';
    animation: aiDots 1.5s steps(4, end) infinite;
}

@keyframes aiDots {
    0%  { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

.ai-overlay__bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 5px;
    height: 36px;
}

.ai-bar {
    width: 6px;
    background: var(--accent);
    border-radius: 3px;
    animation: aiBar 1s ease-in-out infinite;
}

.ai-bar:nth-child(1) { height: 12px; animation-delay: 0s; }
.ai-bar:nth-child(2) { height: 20px; animation-delay: 0.15s; }
.ai-bar:nth-child(3) { height: 28px; animation-delay: 0.3s; }
.ai-bar:nth-child(4) { height: 20px; animation-delay: 0.45s; }
.ai-bar:nth-child(5) { height: 12px; animation-delay: 0.6s; }

@keyframes aiBar {
    0%, 100% { transform: scaleY(0.5); opacity: 0.4; }
    50%      { transform: scaleY(1.2); opacity: 1; }
}

/* ===================================
   STEP 2 — RESULTS
   =================================== */
#stepResult {
    animation: fadeUp 0.4s ease;
}

.result-topbar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px 20px;
    margin: 0 auto;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
}
@media (min-width: 1024px) {
    .result-topbar {
        grid-template-columns: auto auto; /* Flow naturally on desktop */
        justify-content: space-between;
        padding: 24px 32px;
    }
}

.btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    width: 100%;
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-alt {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.08); /* Match btn-back */
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.15); /* Match btn-back */
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    width: 100%;
}

.btn-alt:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.result-topbar__actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* On smaller mobile screens, create a distinct grid structure */
@media (max-width: 1024px) {
    .result-topbar {
        grid-template-columns: 1fr; /* 1 column for the main topbar */
        gap: 12px;
        padding: 16px;
    }
    
    .btn-back {
        width: 100%;
        margin-bottom: 4px; /* Slight separation from the actions grid */
    }

    .result-topbar__actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr); /* Split the two action buttons 50/50 exactly */
        gap: 12px;
        width: 100%;
    }
    
    .btn-scroll-ai, .btn-alt {
        width: 100%;
        padding: 12px 0; /* Let grid handle width, keep height consistent */
    }
}

@media (min-width: 1024px) {
    .result-topbar__actions {
        display: flex;
        gap: 12px;
        width: auto;
    }
    .btn-alt, .btn-back {
        width: auto;
        padding: 12px 24px;
    }
}

.btn-scroll-ai {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgb(0, 255, 136); /* Match other buttons */
    color: black;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    width: 100%;
}

.btn-scroll-ai:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-text-short {
    display: none;
}

/* On very small mobile screens, show short text to save space */
@media (max-width: 450px) {
    .result-topbar {
        padding: 12px;
    }
    .btn-text-full {
        display: none;
    }
    .btn-text-short {
        display: inline;
    }
    .btn-scroll-ai, .btn-alt, .btn-back {
        font-size: 13px;
        gap: 4px; /* tighter icon gap */
    }
}

/* Hide the scroll to AI button completely on desktop since it's side-by-side */
@media (min-width: 1024px) {
    .btn-scroll-ai {
        display: none !important;
    }
}

/* ── Layout Step 2 ── */
.result-layout {
    display: flex;
    flex-direction: column;
    padding: 0;
    max-width: 1300px;
    margin: 0 auto;
    gap: 32px;
}
@media (min-width: 1024px) {
    .result-layout {
        flex-direction: row;
        align-items: flex-start;
        padding: 32px 24px;
    }
}

/* Pitch Section (Step 2) */
.result-pitch {
    flex: 1;
    padding: 0 0 60px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}
@media (min-width: 1024px) {
    .result-pitch {
        margin: 0;
    }
}

/* ── AI Analysis Card ── */
.ai-analysis-card {
    flex: 1;
    max-width: 650px;
    margin: 0 auto 60px;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2), inset 0 1px 1px rgba(255,255,255,0.05);
}

@media (min-width: 1024px) {
    .ai-analysis-card {
        margin: 65px 0 0 0;
        position: sticky;
        top: 80px;
        max-height: calc(100vh - 100px);
    }
}

.ai-card-header {
    background: linear-gradient(135deg, rgba(8, 14, 25, 0.95), rgba(15, 23, 42, 0.95));
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.ai-card-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.5;
}

.ai-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.ai-card-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.3px;
    background: linear-gradient(to right, #fff, #94a3b8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ai-card-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.ai-card-body::-webkit-scrollbar {
    width: 6px;
}
.ai-card-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.ai-content-loading, .ai-content-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.ai-content-error svg {
    color: #ef4444;
    margin-bottom: 10px;
}

.ai-content-error p {
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* Formatted Result Content */
.ai-content-result {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #d1d5db;
    animation: fadeUp 0.4s ease;
}

.ai-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin: 24px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.ai-section-title:first-child {
    margin-top: 0;
}

.ai-paragraph {
    margin-bottom: 16px;
}

.ai-list {
    margin: 0 0 16px;
    padding: 0 0 0 20px;
    list-style: disk;
}

html[dir="rtl"] .ai-list {
    padding: 0 20px 0 0;
}

.ai-list li {
    margin-bottom: 8px;
    padding-left: 4px;
}

html[dir="rtl"] .ai-list li {
    padding-left: 0;
    padding-right: 4px;
}

.ai-content-result strong {
    color: #fff;
    font-weight: 700;
}

.formation-badge {
    text-align: center;
    margin-bottom: 20px;
}

.formation-badge__label {
    display: inline-block;
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 3px;
    background: linear-gradient(135deg, var(--accent), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.formation-badge__sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Pitch */
.pitch {
    position: relative;
    width: 100%;
    max-width: 700px;
    aspect-ratio: 7 / 10;
    margin: 0 auto;
    background: radial-gradient(circle at center, #133a10 0%, #061f06 100%);
    border-radius: var(--radius-lg);
    border: 2px solid rgba(255, 255, 255, 0.4);
    overflow: hidden;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.5), inset 0 0 80px rgba(0, 0, 0, 0.15);
}

.pitch::before,
.pitch::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.pitch::before {
    top: 50%;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.4);
    transform: translateX(-50%) translateY(-50%);
}

.pitch::after {
    top: 50%;
    width: 140px;
    height: 140px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: transparent;
}

.pitch-marking {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border: 2px solid rgba(255, 255, 255, 0.4);
    background: transparent;
}

.pitch-marking--top       { top: 0; width: 55%; height: 16%; }
.pitch-marking--top-small { top: 0; width: 28%; height: 7%; }
.pitch-marking--bottom       { bottom: 0; width: 55%; height: 16%; }
.pitch-marking--bottom-small { bottom: 0; width: 28%; height: 7%; }

.pitch-centre-spot {
    position: absolute;
    top: 50%; left: 50%;
    width: 6px; height: 6px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Player Node on Pitch */
.player-node {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translate(-50%, -50%);
    z-index: 2;
    animation: playerPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes playerPop {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.player-card-pitch {
    width: 58px;
    height: 78px;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    box-shadow: 0 4px 10px rgba(0,0,0,0.6);
    border: 2px solid #555;
    background: #111;
}

/* Card glow tiers */
.player-node.rating-gold .player-card-pitch {
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.6), 0 4px 10px rgba(0,0,0,0.8);
}
.player-node.rating-silver .player-card-pitch {
    border-color: #4ade80;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.4), 0 4px 10px rgba(0,0,0,0.8);
}
.player-node.rating-bronze .player-card-pitch {
    border-color: #a1a1aa;
    box-shadow: 0 0 10px rgba(161, 161, 170, 0.3), 0 4px 10px rgba(0,0,0,0.8);
}
.player-node.rating-epic .player-card-pitch {
    border-color: #d946ef;
    box-shadow: 0 0 15px rgba(217, 70, 239, 0.7), 0 4px 10px rgba(0,0,0,0.8);
}

.pcp-img {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    z-index: 1;
}

.pcp-grad {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 65%;
    background: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0.6) 30%, rgba(0,0,0,0) 100%);
    z-index: 2;
}

.pcp-top-left {
    position: absolute;
    top: 3px;
    left: 3px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.9);
}

.pcp-pos {
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    margin-bottom: -2px;
    text-shadow: 1px 1px 2px #000, 0 0 4px #000;
}

.pcp-ovr {
    color: #fde047;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: -1px;
    text-shadow: 1px 1px 2px #000, 0 0 4px #000;
}

.pcp-name {
    position: relative;
    z-index: 3;
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    text-align: center;
    width: 100%;
    padding-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 2px;
    padding-right: 2px;
    text-shadow: 1px 1px 2px #000;
}

/* ===================================
   MOBILE FIXED BOTTOM BAR
   =================================== */
.mobile-bottom-bar {
    display: none;
}

/* ===================================
   RESPONSIVE
   =================================== */
@media (max-width: 1024px) {
    .tb-hero__inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .tb-hero__search {
        max-width: 100%;
        width: 100%;
    }

    .tb-layout {
        grid-template-columns: 1fr;
    }

    .tb-squad-sidebar {
        position: static;
        max-height: none;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .tb-browser {
        max-height: none;
    }

    .result-topbar {
        padding: 12px 16px;
    }
}

@media (max-width: 768px) {
    .tb-epics-grid {
        grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
        gap: 8px;
    }

    /* Show mobile fixed bottom bar */
    .mobile-bottom-bar {
        display: flex;
        gap: 8px;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        z-index: 100;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }
    
    .tb-btn-edit-values {
        flex: 1;
        background: rgba(255, 255, 255, 0.08);
        border: 1px solid rgba(255, 255, 255, 0.15);
        color: #fff;
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
        padding: 12px;
        transition: background 0.2s;
    }
    .tb-btn-edit-values:hover {
        background: rgba(255, 255, 255, 0.12);
    }
    
    .mobile-generate-btn {
        flex: 1;
        padding: 12px;
    }

    /* Hide the desktop sidebar generate button on mobile */
    .tb-squad__footer {
        display: none;
    }

    .tb-browser {
        padding: 12px 10px;
    }

    /* Add bottom padding for fixed bar */
    .tb-layout {
        padding-bottom: 80px;
    }

    .player-card-pitch {
        width: 36px;
        height: 50px;
    }

    .pcp-pos { font-size: 7px; }
    .pcp-ovr { font-size: 11px; }
    .pcp-name { font-size: 6px; }

    .pitch {
        max-width: 100%;
    }

    .result-topbar {
        flex-direction: column;
        gap: 8px;
    }

    .btn-back, .btn-alt {
        width: 100%;
        justify-content: center;
    }
}

/* Desktop workspace — formal, minimal and fully utilized. Mobile and tablet
   retain the compact flow above. */
@media (min-width: 1025px) {
    .teambuilder-page--2027 {
        background: #07101a;
    }

    .teambuilder-page--2027 > .site-header,
    .teambuilder-page--2027 .tb-hero {
        background: #080f19;
    }

    .teambuilder-page--2027 > .site-header {
        box-shadow: none;
    }

    .teambuilder-page--2027 .tb-hero {
        padding: 9px 0;
        border-bottom-color: rgba(148, 163, 184, 0.1);
    }

    .teambuilder-page--2027 .tb-hero::after {
        display: none;
    }

    .teambuilder-page--2027 .tb-hero__inner,
    .teambuilder-page--2027 .tb-layout {
        width: min(100%, 1760px);
        max-width: none;
        padding-right: 24px;
        padding-left: 24px;
    }

    .teambuilder-page--2027 .tb-hero__inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr) clamp(300px, 22vw, 340px);
        align-items: center;
        gap: 16px;
    }

    .teambuilder-page--2027 .tb-hero__search {
        grid-column: 1;
        grid-row: 1;
        width: 100%;
        max-width: none;
        padding: 8px 10px;
        border-radius: 14px;
        background: rgba(12, 21, 34, 0.82);
        box-shadow: none;
        backdrop-filter: none;
    }

    .teambuilder-page--2027 .tb-hero__text {
        grid-column: 2;
        grid-row: 1;
        max-width: none;
        min-width: 0;
    }

    .teambuilder-page--2027 .tb-hero__edition {
        margin-bottom: 4px;
        padding: 3px 7px;
        font-size: 0.56rem;
        letter-spacing: 0.09em;
    }

    .teambuilder-page--2027 .tb-hero__title {
        margin: 0 0 2px;
        font-size: clamp(1rem, 1.35vw, 1.22rem);
        line-height: 1.2;
        letter-spacing: -0.035em;
    }

    .teambuilder-page--2027 .tb-hero__sub {
        font-size: 0.72rem;
        line-height: 1.35;
    }

    .teambuilder-page--2027 .tb-search-bar .search-input {
        min-height: 38px;
        border-radius: 10px;
        font-size: 14px;
    }

    .teambuilder-page--2027 .tb-hero__info-row {
        margin-top: 3px;
    }

    .teambuilder-page--2027 .tb-results-info,
    .teambuilder-page--2027 .tb-players-counter {
        min-height: 0;
        font-size: 0.68rem;
    }

    .teambuilder-page--2027 .tb-layout {
        grid-template-columns: minmax(0, 1fr) clamp(300px, 22vw, 340px);
        gap: 16px;
        padding-top: 8px;
        padding-bottom: 10px;
    }

    .teambuilder-page--2027 .tb-browser,
    .teambuilder-page--2027 .tb-squad-sidebar {
        border: 1px solid rgba(148, 163, 184, 0.12);
        border-radius: 18px;
        background: rgba(9, 17, 28, 0.72);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
    }

    .teambuilder-page--2027 .tb-browser {
        display: flex;
        flex-direction: column;
        padding: 10px;
        overflow: hidden;
    }

    .teambuilder-page--2027 .tb-browser-tabs {
        position: relative;
        flex: 0 0 auto;
        top: auto;
        min-height: 0;
        margin-bottom: 8px;
        padding: 4px;
        border-radius: 13px;
        background: rgba(2, 8, 18, 0.7);
        backdrop-filter: none;
    }

    .teambuilder-page--2027 .tb-browser-tab {
        min-height: 36px;
        padding: 6px 12px;
        border-radius: 10px;
        font-size: 12px;
    }

    .teambuilder-page--2027 .tb-browser__viewport {
        flex: 1 1 auto;
        min-height: 0;
        padding: 1px 2px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        scrollbar-color: rgba(134, 239, 172, 0.28) transparent;
    }

    .teambuilder-page--2027 .tb-browser__viewport::-webkit-scrollbar {
        width: 5px;
    }

    .teambuilder-page--2027 .tb-browser__viewport::-webkit-scrollbar-thumb {
        border-radius: 999px;
        background: rgba(134, 239, 172, 0.28);
    }

    .teambuilder-page--2027 .tb-new-grid,
    .teambuilder-page--2027 .tb-epics-grid {
        grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
        gap: 10px;
        margin-bottom: 0;
    }

    @media (max-width: 1600px) {
        .teambuilder-page--2027 .tb-new-grid,
        .teambuilder-page--2027 .tb-epics-grid {
            grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
        }
    }

    .teambuilder-page--2027 .players-grid {
        margin-bottom: 0;
    }

    .teambuilder-page--2027 .tb-load-more {
        flex: 0 0 auto;
        padding: 8px 0 0;
    }

    .teambuilder-page--2027 .btn-load-more {
        width: min(100%, 280px);
        min-height: 40px;
        padding: 8px 24px;
        box-shadow: none;
    }

    .teambuilder-page--2027 .btn-draft-generate {
        min-height: 40px;
    }

    .teambuilder-page--2027 .tb-squad-sidebar {
        border-left: 1px solid rgba(148, 163, 184, 0.12);
    }

    .teambuilder-page--2027 .tb-squad__header {
        flex: 0 0 auto;
        padding: 12px 14px 10px;
        background: transparent;
    }

    .teambuilder-page--2027 .tb-squad__list {
        padding: 4px 12px;
    }

    .teambuilder-page--2027 .squad-item {
        min-height: 45px;
        padding: 6px 0;
    }

    .teambuilder-page--2027 .tb-sidebar-ad {
        margin-top: 0;
        padding: 0 10px;
    }

    .teambuilder-page--2027 .tb-squad__footer {
        flex: 0 0 auto;
        padding: 9px 12px 12px;
        background: transparent;
    }

    .teambuilder-page--2027 .tb-btn-generate {
        min-height: 42px;
        padding: 9px 16px;
        box-shadow: none;
    }
}

/* Viewport workspace: keep the complete Team Builder inside the visible screen.
   Long player and squad lists scroll inside their own workspace instead of
   increasing the document height. */
html {
    height: 100%;
}

body.teambuilder-page--2027 {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.teambuilder-page--2027 > .site-header {
    flex: 0 0 auto;
}

.teambuilder-page--2027 #stepSelect {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.teambuilder-page--2027 .tb-hero {
    flex: 0 0 auto;
    padding: 10px 0;
}

.teambuilder-page--2027 .tb-hero::after {
    height: 36px;
}

.teambuilder-page--2027 .tb-hero__inner {
    align-items: center;
    gap: clamp(18px, 3vw, 42px);
}

.teambuilder-page--2027 .tb-hero__edition {
    margin-bottom: 5px;
    padding: 4px 8px;
    font-size: 0.62rem;
}

.teambuilder-page--2027 .tb-hero__title {
    margin: 0 0 3px;
    font-size: clamp(1.15rem, 2vw, 1.65rem);
    letter-spacing: -0.035em;
}

.teambuilder-page--2027 .tb-hero__sub {
    font-size: 0.78rem;
    line-height: 1.4;
}

.teambuilder-page--2027 .tb-hero__search {
    padding: 8px 10px;
    border-radius: 16px;
}

.teambuilder-page--2027 .tb-search-bar .search-input {
    min-height: 40px;
    border-radius: 12px;
}

.teambuilder-page--2027 .tb-hero__info-row {
    margin-top: 4px;
}

.teambuilder-page--2027 .tb-top-ad {
    flex: 0 0 auto;
    margin-top: 0;
}

.teambuilder-page--2027 .tb-top-ad .pes-ad-wrapper {
    margin: 6px auto !important;
}

.teambuilder-page--2027 .tb-layout {
    flex: 1 1 auto;
    align-items: stretch;
    min-height: 0;
    height: auto;
    margin: 0 auto;
    padding-top: 8px;
    padding-bottom: 10px;
    overflow: hidden;
}

.teambuilder-page--2027 .tb-browser,
.teambuilder-page--2027 .tb-squad-sidebar {
    min-height: 0;
    height: 100%;
    max-height: none;
}

.teambuilder-page--2027 .tb-browser {
    padding-bottom: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.teambuilder-page--2027 .tb-browser-tabs {
    margin-bottom: 10px;
}

.teambuilder-page--2027 .tb-squad-sidebar {
    position: static;
    overflow: hidden;
}

.teambuilder-page--2027 .tb-squad__list {
    min-height: 0;
    overscroll-behavior: contain;
}

.teambuilder-page--2027 .tb-sidebar-ad {
    flex: 0 0 auto;
    margin-top: 4px;
}

.teambuilder-page--2027 .tb-sidebar-ad .pes-ad-wrapper {
    margin: 4px auto !important;
}

.teambuilder-page--2027 #stepResult {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
}

@media (max-width: 1024px) {
    .teambuilder-page--2027 .tb-hero__inner {
        display: grid;
        grid-template-columns: minmax(0, 0.8fr) minmax(280px, 1.2fr);
    }

    .teambuilder-page--2027 .tb-layout {
        display: block;
        padding: 8px 14px 92px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .teambuilder-page--2027 .tb-browser,
    .teambuilder-page--2027 .tb-squad-sidebar {
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .teambuilder-page--2027 .tb-squad-sidebar {
        margin-top: 12px;
    }

    .teambuilder-page--2027 .tb-squad__list {
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 768px) {
    .teambuilder-page--2027 .tb-hero {
        padding: 7px 0;
    }

    .teambuilder-page--2027 .tb-hero__inner {
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
        padding-right: 12px;
        padding-left: 12px;
    }

    .teambuilder-page--2027 .tb-hero__edition,
    .teambuilder-page--2027 .tb-hero__sub {
        display: none;
    }

    .teambuilder-page--2027 .tb-hero__title {
        margin: 0;
        font-size: 1.08rem;
        line-height: 1.25;
    }

    .teambuilder-page--2027 .tb-hero__search {
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        backdrop-filter: none;
    }

    .teambuilder-page--2027 .tb-search-bar .search-input {
        min-height: 38px;
        font-size: 16px;
    }

    .teambuilder-page--2027 .tb-hero__info-row {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        margin-top: 2px;
    }

    .teambuilder-page--2027 .tb-results-info,
    .teambuilder-page--2027 .tb-players-counter {
        font-size: 0.7rem;
    }

    .teambuilder-page--2027 .tb-top-ad .pes-ad-wrapper {
        margin: 3px auto !important;
    }

    .teambuilder-page--2027 .tb-layout {
        padding: 5px 8px calc(82px + env(safe-area-inset-bottom, 0px));
    }

    .teambuilder-page--2027 .tb-browser {
        padding-bottom: 6px;
    }

    .teambuilder-page--2027 .tb-browser-tabs {
        position: sticky;
        top: 0;
        margin-bottom: 7px;
    }
}

/* ===================================
   AD INTERSTITIAL OVERLAY
   =================================== */
.ad-interstitial {
    position: fixed;
    inset: 0;
    background: rgba(4, 9, 20, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: aiFadeIn 0.4s ease;
}

.ad-interstitial__content {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 20px;
    padding: 32px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 0 20px rgba(59, 130, 246, 0.1);
}

.ad-interstitial__title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.ad-interstitial__sub {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.ad-interstitial__ad-wrap {
    background: #000;
    width: 300px;
    height: 250px;
    margin: 0 auto 24px;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 25px rgba(0,0,0,0.4);
}

.ad-interstitial__footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-height: 44px;
}

.ad-countdown {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.ad-countdown span {
    color: var(--accent);
    font-weight: 800;
    display: inline-block;
    min-width: 14px;
}

.ad-skip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 32px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    animation: fadeUp 0.3s ease;
}

.ad-skip-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.4);
}

body.unlock-ad-open {
    overflow: hidden;
}

.unlock-ad-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    background: #000;
}

.unlock-ad-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: #000;
}

.unlock-ad-close {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.82);
    color: #fff;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    font: 700 32px/1 Arial, sans-serif;
    cursor: pointer;
}

.unlock-ad-close__icon {
    display: block;
    transform: translateY(-1px);
}

.unlock-ad-close__countdown {
    position: absolute;
    right: -5px;
    bottom: -5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border: 2px solid #000;
    border-radius: 999px;
    background: #f59e0b;
    color: #111827;
    font: 800 12px/1 Arial, sans-serif;
}

.unlock-ad-close:disabled {
    opacity: 0.72;
    cursor: not-allowed;
}

.unlock-ad-close:hover,
.unlock-ad-close:focus-visible {
    outline: none;
    background: #ef4444;
    border-color: #fff;
}

.unlock-ad-close:disabled:hover {
    transform: none;
    background: rgba(0, 0, 0, 0.82);
    border-color: rgba(255, 255, 255, 0.55);
}

/* Professional visual refresh: teambuilder only */
body {
    background:
        radial-gradient(circle at 8% 0%, rgba(59, 130, 246, 0.11), transparent 28%),
        radial-gradient(circle at 92% 12%, rgba(34, 197, 94, 0.09), transparent 30%),
        linear-gradient(180deg, #070b13 0%, #0a0f1a 42%, #080d16 100%);
}

.teambuilder-page--2027 {
    background:
        radial-gradient(circle at 6% 0%, rgba(57, 255, 20, 0.1), transparent 26%),
        radial-gradient(circle at 95% 16%, rgba(34, 211, 238, 0.075), transparent 27%),
        linear-gradient(180deg, #060c14 0%, #09111c 45%, #070c14 100%);
}

.site-header {
    background: rgba(6, 10, 18, 0.84);
    border-bottom: 1px solid rgba(148, 163, 184, 0.14);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.site-nav a {
    border: 1px solid transparent;
    border-radius: 999px;
}

.site-nav a:hover,
.site-nav a.active {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
}

.tb-hero {
    position: relative;
    overflow: hidden;
    padding: clamp(34px, 5vw, 58px) 0 clamp(28px, 4vw, 46px);
    background:
        linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px),
        radial-gradient(circle at 18% 18%, rgba(34, 197, 94, 0.14), transparent 32%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(8, 13, 24, 0.82));
    background-size: 64px 64px, 64px 64px, auto, auto;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.tb-hero::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 80px;
    background: linear-gradient(to bottom, transparent, rgba(8, 13, 22, 0.92));
    pointer-events: none;
}

.tb-hero__inner {
    position: relative;
    z-index: 1;
    align-items: flex-end;
    gap: clamp(24px, 5vw, 64px);
}

.tb-hero__text {
    max-width: 560px;
}

.tb-hero__edition {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 7px 11px;
    border: 1px solid rgba(57, 255, 20, 0.25);
    border-radius: 999px;
    background: rgba(4, 19, 13, 0.52);
    color: #b8ff7b;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.tb-hero__edition::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #39ff14;
    box-shadow: 0 0 13px rgba(57, 255, 20, 0.72);
}

.tb-hero__title {
    font-weight: 950;
    letter-spacing: -0.07em;
    margin-bottom: 14px;
    background: linear-gradient(120deg, #fff 0%, #dbeafe 38%, #bbf7d0 68%, #67e8f9 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tb-hero__sub {
    max-width: 520px;
    color: #aab8cc;
    font-size: clamp(0.95rem, 1.8vw, 1.12rem);
    line-height: 1.7;
}

.tb-hero__search {
    max-width: 680px;
    padding: 18px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 24px;
    background: rgba(15, 23, 42, 0.62);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.tb-search-bar .search-input {
    min-height: 54px;
    padding-left: 46px;
    background: rgba(2, 6, 23, 0.54);
    border-color: rgba(148, 163, 184, 0.18);
    border-radius: 16px;
    color: #f8fafc;
    font-size: 15px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tb-search-bar .search-input:focus {
    border-color: rgba(57, 255, 20, 0.5);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tb-search-bar .search-input-wrap svg {
    left: 17px;
    color: #94a3b8;
}

.tb-hero__info-row {
    margin-top: 12px;
}

.tb-players-counter__value,
.tb-results-info span {
    color: #86efac;
}

.tb-layout {
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 20px;
    width: min(100%, 1480px);
    min-height: calc(100vh - 198px);
    margin: 0 auto;
    padding: 22px 24px 54px;
}

.tb-browser,
.tb-squad-sidebar {
    border: 1px solid rgba(148, 163, 184, 0.13);
    border-radius: 26px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.72), rgba(10, 15, 26, 0.78));
    box-shadow: 0 22px 64px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.teambuilder-page--2027 .tb-browser,
.teambuilder-page--2027 .tb-squad-sidebar {
    border-color: rgba(123, 255, 92, 0.12);
}

.teambuilder-page--2027 .tb-squad-sidebar {
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3), 0 0 36px rgba(34, 197, 94, 0.045);
}

.tb-browser {
    padding: 18px;
    max-height: calc(100vh - 210px);
}

.tb-squad-sidebar {
    top: 84px;
    max-height: calc(100vh - 110px);
    border-left: 1px solid rgba(148, 163, 184, 0.13);
    overflow: hidden;
}

.tb-browser-tabs {
    gap: 8px;
    padding: 6px;
    margin-bottom: 18px;
    border-color: rgba(148, 163, 184, 0.14);
    border-radius: 18px;
    background: rgba(2, 6, 23, 0.42);
}

.tb-browser-tab {
    min-height: 42px;
    border-radius: 13px;
    color: #94a3b8;
    font-weight: 800;
}

.tb-browser-tab:hover:not(.active) {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.055);
}

.tb-browser-tab.active,
.tb-browser-tab--new.active,
.tb-browser-tab--epic.active {
    color: #06110a;
    background: linear-gradient(135deg, #e9ff73, #39ff14 45%, #14b8a6);
    box-shadow: 0 12px 28px rgba(34, 197, 94, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.players-grid {
    gap: 10px;
}

.tb-browser .player-card,
.squad-item {
    border-color: rgba(148, 163, 184, 0.12);
    background: rgba(15, 23, 42, 0.62);
    border-radius: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.tb-browser .player-card {
    padding: 11px 13px;
    border-left-width: 1px;
}

.tb-browser .player-card:hover:not(.is-selected) {
    transform: translateY(-2px);
    border-color: rgba(57, 255, 20, 0.28);
    border-left-color: rgba(57, 255, 20, 0.42);
    background: rgba(30, 41, 59, 0.72);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
}

.player-card-avatar,
.squad-item__img {
    border-color: rgba(148, 163, 184, 0.18);
    background: rgba(2, 6, 23, 0.5);
}

.player-card-name,
.squad-item__name {
    color: #eef2ff;
}

.pos-tag {
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.16);
}

.tb-epics-grid,
.tb-new-grid {
    gap: 14px;
}

.tb-epic-card,
.player-card-new {
    border: 1px solid rgba(148, 163, 184, 0.14);
    background: linear-gradient(180deg, rgba(20, 29, 47, 0.92), rgba(9, 14, 24, 0.96));
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
}

.tb-epic-card:hover,
.player-card-new:hover {
    transform: translateY(-5px);
    border-color: rgba(57, 255, 20, 0.34);
    box-shadow: 0 26px 62px rgba(0, 0, 0, 0.35), 0 0 26px rgba(34, 197, 94, 0.12);
}

.teambuilder-page--2027 .player-card-new--2027 {
    border-color: rgba(57, 255, 20, 0.18);
}

.teambuilder-page--2027 .player-card-new--2027:hover {
    border-color: rgba(57, 255, 20, 0.48);
}

.teambuilder-page--2027 .player-card-new__edition {
    position: absolute;
    z-index: 3;
    top: 8px;
    right: 8px;
    padding: 4px 7px;
    border: 1px solid rgba(217, 255, 108, 0.42);
    border-radius: 999px;
    background: rgba(3, 15, 10, 0.84);
    color: #d9ff6c;
    font-size: 8px;
    font-weight: 900;
    line-height: 1;
    backdrop-filter: blur(8px);
}


.tb-squad__header,
.tb-squad__footer,
.ai-card-header {
    border-color: rgba(148, 163, 184, 0.13);
    background: rgba(2, 6, 23, 0.26);
}

.tb-squad__title {
    font-size: 1.05rem;
    font-weight: 850;
}

.tb-squad__count span {
    color: #86efac;
}

.squad-item {
    padding: 9px 10px;
    margin-bottom: 7px;
}

.squad-item__ovr-input {
    width: 48px;
    min-height: 34px;
    border-color: rgba(148, 163, 184, 0.16);
    border-radius: 10px;
    background: rgba(2, 6, 23, 0.48);
    color: #86efac;
}

.tb-btn-generate,
.btn-load-more,
.btn-draft-generate,
.ad-skip-btn,
.btn-scroll-ai {
    min-height: 48px;
    border-radius: 999px;
    background: linear-gradient(135deg, #e9ff73 0%, #39ff14 45%, #14b8a6 100%);
    color: #041107;
    font-weight: 900;
    box-shadow: 0 16px 38px rgba(34, 197, 94, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.tb-btn-generate:hover:not(:disabled),
.btn-load-more:hover,
.btn-draft-generate:hover,
.ad-skip-btn:hover,
.btn-scroll-ai:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 50px rgba(34, 197, 94, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.tb-btn-generate:disabled {
    opacity: 0.42;
    filter: grayscale(0.55);
    box-shadow: none;
}

.result-topbar {
    border-bottom-color: rgba(148, 163, 184, 0.12);
    background: rgba(6, 10, 18, 0.42);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.btn-back,
.btn-alt,
.tb-btn-edit-values {
    border-color: rgba(148, 163, 184, 0.16);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.66);
    color: #e2e8f0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.btn-back:hover,
.btn-alt:hover,
.tb-btn-edit-values:hover {
    border-color: rgba(57, 255, 20, 0.28);
    background: rgba(30, 41, 59, 0.82);
}

.formation-badge__label {
    letter-spacing: 0.12em;
    background: linear-gradient(135deg, #fff, #86efac 42%, #67e8f9);
    -webkit-background-clip: text;
    background-clip: text;
}

.pitch {
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 50%, transparent 50%),
        radial-gradient(circle at center, #10401a 0%, #092a12 46%, #06180b 100%);
    background-size: 100% 10%, auto;
    border-color: rgba(209, 250, 229, 0.36);
    box-shadow: 0 36px 90px rgba(0, 0, 0, 0.42), inset 0 0 90px rgba(0, 0, 0, 0.24);
}

.ai-analysis-card,
.ad-interstitial__content,
.ai-overlay__content {
    border-color: rgba(148, 163, 184, 0.15);
    border-radius: 26px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.84), rgba(8, 13, 24, 0.9));
    box-shadow: 0 28px 82px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.ai-icon-wrap {
    border-color: rgba(57, 255, 20, 0.22);
    background: rgba(34, 197, 94, 0.1);
    box-shadow: 0 0 18px rgba(34, 197, 94, 0.14);
}

.mobile-bottom-bar {
    background: rgba(6, 10, 18, 0.88);
    border-top-color: rgba(148, 163, 184, 0.16);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

[dir="rtl"] .tb-hero__title {
    letter-spacing: -0.035em;
}

[dir="rtl"] .tb-search-bar .search-input {
    padding-right: 46px;
    padding-left: 16px;
}

[dir="rtl"] .tb-search-bar .search-input-wrap svg {
    right: 17px;
    left: auto;
}

@media (max-width: 1024px) {
    .tb-hero__inner {
        align-items: stretch;
    }

    .tb-layout {
        grid-template-columns: 1fr;
        padding: 18px 16px 92px;
    }

    .tb-browser,
    .tb-squad-sidebar {
        max-height: none;
        border-radius: 22px;
    }
}

@media (max-width: 768px) {
    .tb-hero {
        padding-top: 28px;
    }

    .tb-hero__title {
        font-size: clamp(2rem, 11vw, 3.2rem);
        letter-spacing: -0.055em;
    }

    .tb-hero__search {
        padding: 12px;
        border-radius: 20px;
    }

    .tb-hero__info-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .tb-layout {
        padding-left: 10px;
        padding-right: 10px;
    }

    .tb-browser {
        padding: 12px;
    }

    .tb-browser-tabs {
        gap: 5px;
        padding: 5px;
        width: fit-content;
        justify-self: center;
    }

    .tb-browser-tab {
        padding: 8px 6px;
        font-size: 12px;
    }
}

/* UX-focused refinements */
.tb-browser {
    scroll-padding-top: 14px;
}

.tb-browser-tabs {
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.tb-results-info {
    min-height: 22px;
}

.players-grid,
.tb-new-grid,
.tb-epics-grid {
    align-items: start;
}

.tb-new-grid,
.tb-epics-grid {
    grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
}

.player-card,
.player-card-new,
.tb-epic-card,
.squad-item,
.tb-browser-tab,
.tb-btn-generate,
.btn-load-more,
.tb-manual-card__btn {
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 520px) {
    .teambuilder-page--2027 .tb-load-more > span,
    .teambuilder-page--2027 .btn-load-more,
    .teambuilder-page--2027 .btn-draft-generate {
        width: 100%;
    }
}

.tb-browser .player-card,
.player-card-new,
.tb-epic-card {
    cursor: pointer;
}

.tb-browser .player-card.is-selected,
.player-card-new.is-selected,
.tb-epic-card.is-selected {
    outline: 2px solid rgba(34, 197, 94, 0.55);
    outline-offset: 2px;
}

.tb-empty {
    padding: 20px 0 8px;
}

.tb-manual-card {
    width: min(100%, 680px);
    margin: 0 auto;
    padding: 22px;
    text-align: left;
    border-radius: 22px;
}

.tb-manual-card__head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.tb-manual-card h3 {
    margin: 0 0 6px;
    color: #f8fafc;
    font-size: 1.15rem;
    font-weight: 850;
}

.tb-manual-card p {
    margin: 0;
    color: #94a3b8;
    font-size: 0.9rem;
}

.tb-manual-card__grid {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) 0.75fr 0.75fr;
    gap: 12px;
}

.tb-manual-card label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: #94a3b8;
    font-size: 0.78rem;
    font-weight: 800;
}

.tb-manual-card input,
.tb-manual-card select {
    width: 100%;
    min-height: 46px;
    padding: 0 13px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    background: rgba(2, 6, 23, 0.52);
    color: #f8fafc;
    font: inherit;
    outline: none;
}

.tb-manual-card input:focus,
.tb-manual-card select:focus {
    border-color: rgba(57, 255, 20, 0.48);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.1);
}

.tb-manual-card__btn {
    width: 100%;
    min-height: 48px;
    margin-top: 14px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #e9ff73 0%, #39ff14 45%, #14b8a6 100%);
    color: #041107;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.squad-item__epic-badge--manual {
    background: rgba(148, 163, 184, 0.16);
    color: #cbd5e1;
}

[dir="rtl"] .tb-manual-card {
    text-align: right;
}

@media (min-width: 1025px) {
    .tb-layout {
        align-items: start;
    }

    .tb-squad-sidebar {
        min-height: 520px;
    }
}

@media (max-width: 768px) {
    .tb-hero__title {
        margin-bottom: 8px;
    }

    .tb-search-bar .search-input {
        min-height: 50px;
        font-size: 16px;
    }

    .tb-browser-tabs {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .tb-browser-tabs::-webkit-scrollbar {
        display: none;
    }

    .tb-browser-tab {
        flex: 0 0 auto;
        min-width: 104px;
    }

    .tb-new-grid,
    .tb-epics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 9px;
    }

    .players-grid {
        grid-template-columns: 1fr;
    }

    .tb-manual-card {
        padding: 16px;
        border-radius: 18px;
    }

    .tb-manual-card__grid {
        grid-template-columns: 1fr;
    }

    .tb-squad-sidebar {
        margin-top: 0;
    }

    .tb-squad__list {
        max-height: 340px;
    }
}

@media (max-width: 420px) {
    .tb-new-grid,
    .tb-epics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Manual player card: clear card-first UX */
.tb-manual-card {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 22px;
    width: min(100%, 760px);
    align-items: stretch;
    padding: 18px;
    text-align: left;
}

.tb-manual-card__preview {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tb-manual-player-card {
    position: relative;
    width: 100%;
    min-height: 260px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background:
        radial-gradient(circle at 52% 28%, rgba(57, 255, 20, 0.16), transparent 38%),
        linear-gradient(180deg, rgba(18, 28, 47, 0.96), rgba(7, 11, 19, 0.98));
    box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tb-manual-player-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent 48%, rgba(255, 255, 255, 0.03));
    pointer-events: none;
}

.tb-manual-player-card__rating,
.tb-manual-player-card__position,
.tb-manual-player-card__name,
.tb-manual-player-card__avatar {
    position: absolute;
    z-index: 1;
}

.tb-manual-player-card__rating {
    top: 14px;
    left: 14px;
    color: #fff;
    font-size: 2.05rem;
    font-weight: 950;
    line-height: 1;
    letter-spacing: -0.07em;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.75);
}

.tb-manual-player-card__position {
    top: 50px;
    left: 15px;
    min-width: 42px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.62);
    color: #d9f99d;
    font-size: 0.78rem;
    font-weight: 900;
    text-align: center;
}

.tb-manual-player-card__avatar {
    inset: 62px 24px 62px;
    display: grid;
    place-items: center;
    color: rgba(203, 213, 225, 0.8);
}

.tb-manual-player-card__avatar svg {
    width: 86px;
    height: 86px;
    filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.35));
}

.tb-manual-player-card__name {
    right: 12px;
    bottom: 18px;
    left: 12px;
    color: #fff;
    font-size: 0.92rem;
    font-weight: 950;
    letter-spacing: 0.03em;
    text-align: center;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 3px 12px rgba(0, 0, 0, 0.85);
}

.tb-manual-card__body {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
}

.tb-manual-card__head {
    display: block;
    margin-bottom: 16px;
}

.tb-manual-card__head h3 {
    font-size: clamp(1.18rem, 2.4vw, 1.65rem);
    line-height: 1.15;
}

.tb-manual-card__head p {
    max-width: 460px;
    line-height: 1.55;
}

.tb-manual-card__grid {
    grid-template-columns: minmax(0, 1fr) 120px 116px;
    gap: 10px;
}

.tb-manual-card label span {
    color: #cbd5e1;
    font-size: 0.74rem;
    letter-spacing: 0.02em;
}

.tb-manual-card input,
.tb-manual-card select {
    min-height: 48px;
    border-radius: 13px;
    font-weight: 800;
}

.tb-manual-card__btn {
    min-height: 50px;
    margin-top: 12px;
    font-size: 0.98rem;
}

[dir="rtl"] .tb-manual-card {
    text-align: right;
}

[dir="rtl"] .tb-manual-player-card__rating,
[dir="rtl"] .tb-manual-player-card__position {
    right: 14px;
    left: auto;
}

@media (max-width: 768px) {
    .tb-manual-card {
        grid-template-columns: 132px minmax(0, 1fr);
        gap: 12px;
        padding: 12px;
    }

    .tb-manual-player-card {
        min-height: 206px;
        border-radius: 16px;
    }

    .tb-manual-player-card__rating {
        top: 11px;
        left: 11px;
        font-size: 1.55rem;
    }

    .tb-manual-player-card__position {
        top: 39px;
        left: 11px;
        min-width: 36px;
        font-size: 0.68rem;
    }

    .tb-manual-player-card__avatar {
        inset: 48px 18px 52px;
    }

    .tb-manual-player-card__avatar svg {
        width: 62px;
        height: 62px;
    }

    .tb-manual-player-card__name {
        bottom: 14px;
        font-size: 0.74rem;
    }

    .tb-manual-card__head {
        margin-bottom: 10px;
    }

    .tb-manual-card__head p {
        font-size: 0.82rem;
    }

    .tb-manual-card__grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .tb-manual-card input,
    .tb-manual-card select {
        min-height: 44px;
    }
}

@media (max-width: 520px) {
    .tb-manual-card {
        grid-template-columns: 1fr;
    }

    .tb-manual-player-card {
        width: min(180px, 100%);
        min-height: 248px;
        margin: 0 auto;
    }
}

/* Minimal Team Builder Refinements */
.tb-toast {
    position: fixed;
    top: 82px;
    left: 50%;
    z-index: 10000;
    width: min(420px, calc(100% - 28px));
    padding: 13px 16px;
    border: 1px solid rgba(248, 113, 113, 0.28);
    border-radius: 16px;
    background: rgba(127, 29, 29, 0.94);
    color: #fff;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.45;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -14px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tb-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.tb-layout {
    gap: 18px;
}

.tb-browser,
.tb-squad-sidebar {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.tb-browser {
    padding-inline: 8px 18px;
}

.tb-squad-sidebar {
    border-left: 1px solid rgba(148, 163, 184, 0.12);
}

.tb-squad__header,
.tb-squad__footer,
.ai-card-header {
    background: transparent;
}

.tb-error {
    display: none;
}

.squad-item {
    gap: 10px;
    padding: 9px 0;
    border: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    margin-bottom: 0;
}

.squad-item:last-child {
    border-bottom: 0;
}

.squad-item__remove {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.squad-item__remove:hover,
.squad-item__remove:focus-visible {
    outline: none;
    background: #ef4444;
    color: #fff;
    transform: scale(1.04);
}

@media (max-width: 768px) {
    .tb-toast {
        top: 14px;
    }

    .tb-browser,
    .tb-squad-sidebar {
        padding-inline: 0;
    }

    .tb-squad-sidebar {
        border-left: 0;
        border-top: 1px solid rgba(148, 163, 184, 0.12);
    }

    .squad-item__remove {
        width: 38px;
        height: 38px;
    }

    /* Keep the player-type tabs aligned to the mobile content width. */
    .tb-browser-tabs {
        width: 100%;
        max-width: 100%;
        margin-right: auto;
        margin-left: auto;
        overflow: hidden;
        justify-self: stretch;
    }

    .tb-browser-tab {
        flex: 1 1 0;
        min-width: 0;
        padding-right: 6px;
        padding-left: 6px;
        white-space: nowrap;
    }
}

/* Keep desktop actions inside the fixed-height workspace. Only the player and
   squad lists should scroll when their content grows. */
@media (min-width: 1025px) {
    .teambuilder-page--2027 .tb-layout {
        align-items: stretch;
        min-height: 0;
    }

    .teambuilder-page--2027 .tb-browser {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
        min-height: 0;
        overflow: hidden;
    }

    .teambuilder-page--2027 .tb-browser__viewport {
        min-height: 0;
        overflow-y: auto;
    }

    .teambuilder-page--2027 .tb-load-more {
        position: relative;
        z-index: 1;
    }

    .teambuilder-page--2027 .tb-squad-sidebar {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto auto;
        min-height: 0;
        overflow: hidden;
    }

    .teambuilder-page--2027 .tb-squad__list {
        min-height: 0;
        overflow-y: auto;
    }

    .teambuilder-page--2027 .tb-squad__footer {
        position: relative;
        z-index: 1;
    }
}

/* Final identity lock: flat editorial surfaces, restrained corners */
.teambuilder-page--2027,
.teambuilder-page--2027 button,
.teambuilder-page--2027 input,
.teambuilder-page--2027 select,
.teambuilder-page--2027 textarea {
    font-family: "IBM Plex Sans", Arial, sans-serif;
}

[dir="rtl"] .teambuilder-page--2027,
[dir="rtl"] .teambuilder-page--2027 button,
[dir="rtl"] .teambuilder-page--2027 input,
[dir="rtl"] .teambuilder-page--2027 select,
[dir="rtl"] .teambuilder-page--2027 textarea {
    font-family: "IBM Plex Sans Arabic", "IBM Plex Sans", Arial, sans-serif;
}

.teambuilder-page--2027 {
    background: #090c0b;
    background-image: none;
}

.teambuilder-page--2027 .site-header {
    min-height: 64px;
    border-bottom: 1px solid #303a34;
    background: #090c0b !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

.tb-hero {
    border-bottom: 1px solid #303a34;
    background: #0c110e;
    background-image: none;
}

.tb-hero::before,
.tb-hero::after {
    display: none;
}

.tb-hero__text {
    padding-inline-start: 22px;
    border-inline-start: 4px solid #83ff32;
}

.tb-hero__title {
    background: none;
    color: #f2f5f3;
    -webkit-text-fill-color: currentColor;
    font-weight: 700;
    letter-spacing: -0.035em;
    text-shadow: none;
}

[dir="rtl"] .tb-hero__title {
    letter-spacing: 0;
}

.tb-hero__edition,
.tb-hero__search,
.tb-search-bar,
.tb-browser,
.tb-squad-sidebar,
.tb-browser-tab,
.player-card,
.player-card-new,
.tb-epic-card,
.squad-item,
.tb-load-more,
.tb-btn-generate,
.btn-draft-generate,
.tb-btn-edit-values,
.tb-manual-card,
.tb-manual-player-card,
.tb-manual-card input,
.tb-manual-card select,
.tb-manual-card__btn,
.tb-toast,
.tb-empty,
.tb-error,
.ai-card,
.ai-interstitial,
.result-pitch,
.pitch {
    border-radius: 4px !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

.tb-hero__edition,
.tb-hero__search,
.tb-search-bar,
.tb-browser,
.tb-squad-sidebar,
.player-card,
.player-card-new,
.tb-epic-card,
.tb-manual-card,
.tb-manual-player-card,
.tb-empty,
.ai-card,
.ai-interstitial {
    border-color: #303a34;
    background: #101512;
    background-image: none;
}

.tb-browser,
.tb-squad-sidebar {
    border: 1px solid #303a34;
    padding: 18px;
}

.tb-squad-sidebar {
    border-left: 1px solid #303a34;
}

.tb-browser-tabs {
    gap: 0;
    border: 1px solid #303a34;
    border-radius: 4px;
    background: #0b0f0c;
}

.tb-browser-tab {
    border: 0;
    border-inline-end: 1px solid #303a34;
    background: transparent;
    color: #a8b2ac;
    font-weight: 600;
}

.tb-browser-tab:last-child {
    border-inline-end: 0;
}

.tb-browser-tab.active,
.tb-browser-tab[aria-selected="true"] {
    background: #83ff32;
    background-image: none;
    color: #071006;
}

.player-card-new,
.tb-epic-card,
.squad-item {
    border-color: #303a34;
}

.player-card-new:hover,
.tb-epic-card:hover {
    transform: translateY(-2px);
    border-color: #83ff32;
    box-shadow: none !important;
}

.player-card-new__edition,
.player-card-new .pos-tag,
.tb-epic-card__pos,
.tb-epic-card__ovr,
.squad-item__pos,
.squad-item__epic-badge,
.tb-players-counter,
.tb-hero__info-row > * {
    border-radius: 2px !important;
    box-shadow: none !important;
}

.tb-btn-generate,
.btn-draft-generate,
.tb-load-more,
.tb-manual-card__btn {
    border-color: #83ff32;
    background: #83ff32;
    background-image: none;
    color: #071006;
    font-weight: 700;
}

.tb-btn-generate:hover,
.btn-draft-generate:hover,
.tb-load-more:hover,
.tb-manual-card__btn:hover {
    transform: translateY(-1px);
    background: #9aff58;
    box-shadow: none;
}

.tb-squad__header,
.tb-squad__footer,
.ai-card-header {
    border-color: #303a34;
    background: #0c110e;
    background-image: none;
}

.squad-item {
    border: 0;
    border-bottom: 1px solid #303a34;
    border-radius: 0 !important;
    background: transparent;
}

.squad-item__remove {
    border-radius: 2px;
    box-shadow: none;
}

.pitch,
.result-pitch {
    border: 1px solid #53624f;
}

@media (max-width: 768px) {
    .tb-hero__text {
        padding-inline-start: 16px;
    }

    .tb-browser,
    .tb-squad-sidebar {
        padding: 14px;
    }

    .tb-squad-sidebar {
        border: 1px solid #303a34;
    }
}

/* Override older high-specificity pill rules inside the builder */
.teambuilder-page--2027 .tb-hero {
    background: #0c110e !important;
    background-image: none !important;
}

.teambuilder-page--2027 .tb-search-bar .search-input,
.teambuilder-page--2027 .tb-browser-tabs,
.teambuilder-page--2027 .btn-load-more,
.teambuilder-page--2027 .btn-back,
.teambuilder-page--2027 .btn-scroll-ai,
.teambuilder-page--2027 .btn-alt,
.teambuilder-page--2027 .ad-skip-btn,
.teambuilder-page--2027 .unlock-ad-close {
    border-radius: 4px !important;
    box-shadow: none !important;
}

.teambuilder-page--2027 .tb-browser-tabs {
    border: 1px solid #303a34 !important;
    background: #0b0f0c !important;
}

.teambuilder-page--2027 .tb-load-more {
    border: 0;
    background: transparent;
    box-shadow: none !important;
}

.teambuilder-page--2027 .btn-load-more,
.teambuilder-page--2027 .btn-scroll-ai {
    border-color: #83ff32;
    background: #83ff32;
    background-image: none;
    color: #071006;
}

.teambuilder-page--2027 .btn-back,
.teambuilder-page--2027 .btn-alt {
    border-color: #46534c;
    background: transparent;
    background-image: none;
    color: #f2f5f3;
}
