* { box-sizing: border-box; }

.ctft-wrap { display: flex; flex-direction: column; gap: 17px; }

/* Meta bar */
.ctft-meta-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctft-meta-pill {
    display: inline-flex; align-items: center; gap: 7px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 24px; padding: 6px 17px;
    font-size: 14px; color: #aaa; font-weight: 400;
}
.ctft-meta-pill strong { color: #fff; font-weight: 700; }

/* Playstyle filter bar */
.ctft-playstyle-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.ctft-ps-filter {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
    color: #aaa; font-size: 13px; font-weight: 700; padding: 6px 17px;
    border-radius: 24px; cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
    -webkit-appearance: none; outline: none; text-transform: uppercase; letter-spacing: 0.5px;
}
.ctft-ps-filter:hover { background: rgba(255,255,255,0.12); color: #fff; }
.ctft-ps-filter:focus { outline: none; }
.ctft-ps-filter.active { background: #e2b96f; border-color: #e2b96f; color: #000; }

.ctft-tierlist { width: 100%; display: flex; flex-direction: column; gap: 7px; }
.ctft-tier-row { display: flex; align-items: stretch; background: #111; border-radius: 12px; overflow: visible; border: 2px solid var(--tier-color); }
.ctft-tier-label { width: 84px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--tier-color); position: relative; gap: 5px; padding: 14px 0; }
.ctft-tier-letter { font-size: 43px; font-weight: 900; color: #fff; line-height: 1; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
.ctft-tier-sub { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.75); letter-spacing: 2px; }
.ctft-tier-label::before, .ctft-tier-label::after { content: ''; position: absolute; width: 12px; height: 12px; border-color: rgba(255,255,255,0.5); border-style: solid; }
.ctft-tier-label::before { top: 8px; left: 8px; border-width: 2px 0 0 2px; }
.ctft-tier-label::after { bottom: 8px; right: 8px; border-width: 0 2px 2px 0; }
.ctft-tier-comps { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; flex: 1; overflow: visible !important; }
.ctft-comp-trigger { cursor: pointer; overflow: visible !important; transition: transform 0.15s; position: relative; text-decoration: none; display: inline-block; }
.ctft-comp-trigger:hover { transform: scale(1.08); z-index: 10; }
.ctft-comp-trigger.ctft-ps-hidden { display: none; }
.ctft-comp-trigger .ctft-hex-name-overlay {
    display: none !important;
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.95);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
    z-index: 100;
}
.ctft-comp-trigger:hover .ctft-hex-name-overlay { display: block !important; }
.ctft-comp-trigger--active .ctft-hex-border { box-shadow: 0 0 0 3px #fff, 0 0 12px rgba(255,255,255,0.5); }

.ctft-hex-border { width: 74px; height: 84px; clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%) !important; display: flex; align-items: center; justify-content: center; overflow: visible !important; }
.ctft-hex-wrap { width: 62px; height: 70px; clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%) !important; background: #222; overflow: hidden; }
.ctft-hex-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ctft-hex-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; font-size: 22px; background: #333; }
.ctft-comp-panel { display: none; background: #161616; border-radius: 12px; border: 2px solid var(--tier-color); position: relative; }
.ctft-comp-panel.active { display: block; }
.ctft-comp-panel.ctft-ps-hidden { display: none !important; }
.ctft-comp-panel--single { display: block; }

.ctft-panel-close { position: absolute; top: 17px; right: 17px; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.2); color: #fff; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 14px; line-height: 1; transition: background 0.15s; z-index: 10; }
.ctft-panel-close:hover { background: rgba(0,0,0,0.9); }

.ctft-banner-frame { padding: 14px 14px 0; }
.ctft-banner { position: relative; width: 100%; overflow: hidden; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 2px 8px rgba(0,0,0,0.4); }
.ctft-banner-img-wrap { width: 100%; overflow: hidden; height: 0; padding-bottom: 28%; position: relative; }
.ctft-banner-img-wrap img { position: absolute; top: 0; left: 0; width: 100%; height: 115%; object-fit: cover; object-position: center top; display: block; }
.ctft-banner-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, rgba(0,0,0,0.5) 50%, rgba(0,0,0,0.05) 100%); display: flex; flex-direction: column; justify-content: flex-end; padding: 14px 19px; }
.ctft-banner-bottom { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.ctft-banner-row1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ctft-tier-badge-banner { padding: 4px 12px; border-radius: 5px; font-size: 13px; font-weight: 800; color: #fff; letter-spacing: 1px; flex-shrink: 0; }
.ctft-banner-overlay h1, .ctft-banner-overlay h2 { color: #fff; font-size: 34px; font-weight: 900; margin: 0; text-transform: uppercase; letter-spacing: 2.4px; text-shadow: 0 2px 12px rgba(0,0,0,0.9); line-height: 1; }
.ctft-tag { background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.25); border-radius: 5px; padding: 4px 10px; font-size: 12px; font-weight: 700; color: #e2b96f; letter-spacing: 1px; }
.ctft-banner-row2 { display: flex; justify-content: flex-start; padding-left: 2px; }
.ctft-traits-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.ctft-trait-badge { display: flex; align-items: center; gap: 5px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.15); border-radius: 7px; padding: 4px 9px; position: relative; cursor: default; }
.ctft-trait-badge img { width: 22px; height: 22px; object-fit: contain; }
.ctft-trait-count { font-size: 13px; font-weight: 800; color: #fff; }
.ctft-trait-tooltip { display: none; position: absolute; bottom: calc(100% + 10px); left: 0; background: #1e1e1e; border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 12px 14px; width: 264px; z-index: 100; pointer-events: none; }
.ctft-trait-tooltip strong { color: #fff; font-size: 14px; display: block; margin-bottom: 7px; }
.ctft-trait-tooltip p { color: #aaa; font-size: 13px; margin: 0; line-height: 1.5; }
.ctft-trait-badge:hover .ctft-trait-tooltip { display: block; }

.ctft-panel-body { display: flex; flex-direction: column; }
.ctft-panel-sections { display: flex; flex-direction: row; align-items: stretch; border-bottom: 1px solid rgba(255,255,255,0.07); flex-wrap: wrap; }
.ctft-section { display: flex; flex-direction: column; gap: 12px; padding: 17px 19px; }
.ctft-section h3 { color: #fff; font-size: 12px; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 7px; }
.ctft-section--units { flex: 1 1 420px; min-width: 360px; border-right: 1px solid rgba(255,255,255,0.07); }
.ctft-section--augments { width: 408px; flex-shrink: 0; border-right: 1px solid rgba(255,255,255,0.07); }
.ctft-section--gods { width: 156px; flex-shrink: 0; border-right: 1px solid rgba(255,255,255,0.07); }
.ctft-section--stats { width: 132px; flex-shrink: 0; }
.ctft-bordered-section { border-top: 1px solid rgba(255,255,255,0.07); padding: 17px 19px; display: flex; flex-direction: column; gap: 12px; }
.ctft-bordered-section h3 { color: #fff; font-size: 12px; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 7px; }

/* ============================================================
   UNIT BOARD - flat layout, 3 columns when narrow
   ============================================================ */
.ctft-board-units {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}
.ctft-units-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}

/* Single-comp page: ignore PHP row split, force a grid layout.
   Column count is determined by total unit count, with overflow protection */
.ctft-comp-panel--single .ctft-board-units {
    display: grid !important;
    /* default: level 8 = 4+4 */
    grid-template-columns: repeat(4, minmax(0, 91px));
    justify-content: center;
    gap: 12px 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.ctft-comp-panel--single .ctft-units-row {
    display: contents;
}

/* Level 9 (9 units total in the grid) → 5 columns (5 top, 4 bottom).
   Counts unit cards regardless of whether they're nested inside .ctft-units-row */
.ctft-comp-panel--single .ctft-board-units:has(.ctft-unit-card:nth-of-type(9)),
.ctft-comp-panel--single .ctft-board-units:has(.ctft-units-row:nth-of-type(2) .ctft-unit-card:nth-of-type(4)) {
    grid-template-columns: repeat(5, minmax(0, 91px));
}

/* Level 7 (exactly 7 units) → 4 columns (4 top, 3 bottom) */
.ctft-comp-panel--single .ctft-board-units:has(.ctft-unit-card:nth-of-type(7)):not(:has(.ctft-unit-card:nth-of-type(8))):not(:has(.ctft-units-row:nth-of-type(2) .ctft-unit-card:nth-of-type(4))) {
    grid-template-columns: repeat(4, minmax(0, 91px));
}

.ctft-units-row--centered { justify-content: center; }
.ctft-unit-card { display: flex; flex-direction: column; align-items: center; gap: 5px; position: relative; width: 91px; cursor: default; align-self: start; min-height: 138px; }
.ctft-unit-hex-outer { position: relative; width: 91px; flex-shrink: 0; overflow: visible; }
.ctft-three-star { position: absolute; top: -5px; left: 50%; transform: translateX(-50%); display: flex; gap: 2px; z-index: 10; background: rgba(20,20,20,0.82); border-radius: 5px; padding: 2px 5px; pointer-events: none; }
.ctft-three-star span { font-size: 17px; line-height: 1; color: #ffd700; text-shadow: -1px -1px 0 #333, 1px -1px 0 #333, -1px 1px 0 #333, 1px 1px 0 #333; }
.ctft-unit-hex-border { width: 91px; height: 103px; clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%) !important; display: flex; align-items: center; justify-content: center; }
.ctft-unit-hex { width: 79px; height: 91px; clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%) !important; overflow: hidden; position: relative; background: #333; }
.ctft-unit-hex img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ctft-unit-hex-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; font-size: 22px; }
.ctft-unit-name-overlay { position: absolute; bottom: 17px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,1), 0 0 8px rgba(0,0,0,1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; z-index: 2; }
.ctft-unit-items { display: flex; flex-wrap: nowrap; gap: 3px; justify-content: center; width: 100%; padding: 0; }
.ctft-item-wrap { position: relative; flex: 0 1 auto; min-width: 0; }
.ctft-item-icon { width: 100%; max-width: 30px; height: auto; aspect-ratio: 1 / 1; border-radius: 5px; display: block; outline: 1px solid rgba(255,255,255,0.35); box-shadow: 0 1px 4px rgba(0,0,0,0.8); cursor: default; object-fit: cover; }
.ctft-item-tooltip { display: none; position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%); background: #1a1a1a; border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; padding: 14px; width: 240px; z-index: 300; pointer-events: none; text-align: left; }
.ctft-item-wrap:hover .ctft-item-tooltip { display: block; }
.ctft-item-tooltip-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ctft-item-tooltip-header img { width: 36px; height: 36px; border-radius: 5px; flex-shrink: 0; }
.ctft-item-tooltip-header strong { color: #fff; font-size: 14px; font-weight: 800; }
.ctft-item-stats { font-size: 13px; color: #7ec8e3; margin-bottom: 7px; line-height: 1.5; }
.ctft-item-desc { font-size: 13px; color: #aaa; line-height: 1.5; margin: 0 0 10px; }
.ctft-item-components { display: flex; align-items: center; gap: 5px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 10px; }
.ctft-item-components img { width: 26px; height: 26px; border-radius: 4px; }
.ctft-item-plus { color: #666; font-size: 14px; font-weight: 700; }
.ctft-unit-tooltip { display: none; position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%); background: #1a1a1a; border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; padding: 14px; width: 264px; z-index: 200; pointer-events: none; text-align: left; }
.ctft-unit-card:hover .ctft-unit-tooltip { display: block; }
.ctft-unit-tooltip-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ctft-unit-tooltip-header img { width: 41px; height: 41px; border-radius: 5px; flex-shrink: 0; }
.ctft-unit-tooltip-header strong { color: #fff; font-size: 16px; font-weight: 800; display: block; }
.ctft-unit-cost-badge { font-size: 11px; font-weight: 800; padding: 2px 6px; border-radius: 4px; color: #000; display: inline-block; margin-top: 3px; }
.ctft-unit-tooltip-traits { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.ctft-unit-tooltip-trait { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,0.07); border-radius: 5px; padding: 3px 7px; font-size: 12px; color: #ccc; }
.ctft-unit-tooltip-trait img { width: 16px; height: 16px; object-fit: contain; }
.ctft-unit-tooltip-ability { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 10px; }
.ctft-ability-header { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.ctft-ability-img { width: 31px; height: 31px; border-radius: 5px; flex-shrink: 0; }
.ctft-ability-name { font-size: 13px; font-weight: 800; color: #e2b96f; }
.ctft-ability-desc { font-size: 13px; color: #aaa; line-height: 1.5; }

/* Variant tabs */
.ctft-units-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 7px; margin-bottom: 5px; }
.ctft-units-header h3 { border-bottom: none !important; padding-bottom: 0 !important; margin: 0 !important; }
.ctft-variant-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.ctft-variant-tab {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
    color: #aaa; font-size: 11px; font-weight: 700; padding: 4px 10px;
    border-radius: 5px; cursor: pointer; text-transform: uppercase; letter-spacing: 0.5px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    -webkit-appearance: none; outline: none;
}
.ctft-variant-tab:hover { background: rgba(255,255,255,0.12); color: #fff; }
.ctft-variant-tab.active { background: #e2b96f; border-color: #e2b96f; color: #000; }

/* Augments */
.ctft-aug-filters { display: flex; flex-direction: column; gap: 5px; }
.ctft-aug-filter-row { display: flex; flex-wrap: wrap; gap: 5px; }
.ctft-aug-filter { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #aaa; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 5px; cursor: pointer; text-transform: uppercase; letter-spacing: 0.5px; transition: background 0.15s, border-color 0.15s, color 0.15s; -webkit-appearance: none; outline: none; }
.ctft-aug-filter:hover { background: rgba(255,255,255,0.12); color: #fff; }
.ctft-aug-filter:focus { outline: none; }
.ctft-aug-filter.active { background: var(--tier-color); border-color: var(--tier-color); color: #fff; }
.ctft-aug-filter-silver.active { background: #555; border-color: #777; }
.ctft-aug-filter-gold.active { background: #b8860b; border-color: #b8860b; }
.ctft-aug-filter-prismatic.active { background: #6a0dad; border-color: #6a0dad; }
.ctft-augments-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ctft-augment-item { display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }
.ctft-augment-item.ctft-hidden { display: none; }
.ctft-augment-item img { width: 48px; height: 48px; border-radius: 6px; }
.ctft-aug-name { font-size: 10px; color: #ccc; text-align: center; line-height: 1.2; }
.ctft-aug-meta { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.ctft-aug-badge { font-size: 8px; font-weight: 800; padding: 1px 4px; border-radius: 4px; text-transform: uppercase; font-style: normal; }
.ctft-aug-style-economy { background: #b8860b; color: #fff; }
.ctft-aug-style-combat { background: #c0392b; color: #fff; }
.ctft-aug-style-item { background: #1a4a7a; color: #fff; }
.ctft-aug-style-trait { background: #4a2a7a; color: #fff; }
.ctft-aug-style-hero { background: #7a4a00; color: #fff; }
.ctft-aug-style-unique { background: #2a5a5a; color: #fff; }
.ctft-aug-stages { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; }
.ctft-aug-stage { font-size: 8px; color: #888; background: rgba(255,255,255,0.06); border-radius: 4px; padding: 1px 4px; }
.ctft-aug-tooltip { display: none; position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%); background: #1e1e1e; border: 1px solid rgba(255,255,255,0.15); border-radius: 10px; padding: 10px 12px; width: 216px; font-size: 13px; color: #aaa; line-height: 1.5; z-index: 100; pointer-events: none; text-align: left; }
.ctft-augment-item:hover .ctft-aug-tooltip { display: block; }
.ctft-aug-show-more { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #aaa; font-size: 11px; font-weight: 700; padding: 5px 12px; border-radius: 5px; cursor: pointer; text-transform: uppercase; transition: background 0.15s, color 0.15s; align-self: flex-start; -webkit-appearance: none; outline: none; }
.ctft-aug-show-more:hover { background: rgba(255,255,255,0.12); color: #fff; }
.ctft-aug-show-more:focus { outline: none; }

/* Gods */
.ctft-gods-grid { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.ctft-god-card { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: default; position: relative; }
.ctft-god-img-wrap { width: 77px; height: 77px; border-radius: 50%; overflow: hidden; background: #222; }
.ctft-god-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ctft-god-img-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 900; font-size: 26px; }
.ctft-god-name { font-size: 13px; font-weight: 700; color: #fff; text-align: center; line-height: 1.2; max-width: 120px; word-break: break-word; }
.ctft-god-tooltip { display: none; position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%); background: #1a1a1a; border: 1px solid rgba(255,255,255,0.15); border-radius: 12px; padding: 12px 14px; width: 264px; z-index: 250; pointer-events: none; text-align: left; }
.ctft-god-tooltip strong { color: #fff; font-size: 14px; display: block; margin-bottom: 7px; }
.ctft-god-tooltip p { color: #aaa; font-size: 13px; margin: 0; line-height: 1.5; }
.ctft-god-card:hover .ctft-god-tooltip { display: block; }

/* Stats */
.ctft-stats-grid { display: flex; flex-direction: column; gap: 8px; }
.ctft-stat-card { display: flex; flex-direction: column; align-items: center; gap: 5px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 9px 6px; }
.ctft-stat-label { font-size: 10px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: 1px; text-align: center; }
.ctft-stat-value { font-size: 12px; font-weight: 900; padding: 3px 8px; border-radius: 6px; border: 2px solid; text-transform: uppercase; letter-spacing: 1px; }

/* Gameplan */
.ctft-gameplan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ctft-gameplan-box { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 12px 15px; display: flex; flex-direction: column; gap: 7px; }
.ctft-gameplan-label { font-size: 12px; font-weight: 800; color: var(--tier-color); text-transform: uppercase; letter-spacing: 1px; }
.ctft-gameplan-content { font-size: 14px; color: #bbb; line-height: 1.6; }
.ctft-empty { color: #444; font-style: italic; }

/* Single comp page tier rows need overflow visible for hover names */
.ctft-single-wrap .ctft-tier-row,
.ctft-single-wrap .ctft-tier-comps,
.ctft-single-wrap .ctft-comp-trigger {
    overflow: visible !important;
}

/* Tablet/narrow desktop: when units section wraps to its own row, restore full-width grid */
@media (max-width: 980px) {
    .ctft-section--units {
        flex-basis: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.07);
    }
    /* Level 9: keep 5 cols when units row gets full width */
    .ctft-comp-panel--single .ctft-board-units:has(.ctft-unit-card:nth-of-type(9)),
    .ctft-comp-panel--single .ctft-board-units:has(.ctft-units-row:nth-of-type(2) .ctft-unit-card:nth-of-type(4)) {
        grid-template-columns: repeat(5, minmax(0, 91px));
    }
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 640px) {
    /* Tierlist hex bar */
    .ctft-tier-label { width: 58px; }
    .ctft-tier-letter { font-size: 31px; }
    .ctft-tier-sub { display: none; }
    .ctft-hex-border { width: 62px; height: 70px; }
    .ctft-hex-wrap { width: 53px; height: 60px; }
    .ctft-tier-comps { gap: 7px; padding: 10px 12px; }

    /* Banner */
    .ctft-banner-overlay h1, .ctft-banner-overlay h2 { font-size: 22px; }
    .ctft-banner-img-wrap { padding-bottom: 36%; }
    .ctft-comp-panel--single .ctft-banner-frame { padding: 8px 8px 0; }
    .ctft-comp-panel--single .ctft-banner-img-wrap { padding-bottom: 50%; }
    .ctft-comp-panel--single .ctft-banner-overlay { padding: 10px 12px; }
    .ctft-comp-panel--single .ctft-banner-row1 { gap: 6px; flex-wrap: wrap; }
    .ctft-comp-panel--single .ctft-banner-overlay h1 { font-size: 18px; letter-spacing: 1px; width: 100%; margin-bottom: 4px; }
    .ctft-comp-panel--single .ctft-tier-badge-banner { font-size: 11px; padding: 3px 8px; }
    .ctft-comp-panel--single .ctft-tag { font-size: 10px; padding: 3px 7px; }
    .ctft-comp-panel--single .ctft-banner-row2 { padding-left: 0; }
    .ctft-comp-panel--single .ctft-trait-badge { padding: 3px 6px; gap: 3px; }
    .ctft-comp-panel--single .ctft-trait-badge img { width: 16px; height: 16px; }
    .ctft-comp-panel--single .ctft-trait-count { font-size: 11px; }

    /* Sections stack vertically */
    .ctft-panel-sections { flex-direction: column; }
    .ctft-section--units { border-right: none; border-bottom: 1px solid rgba(255,255,255,0.07); }
    .ctft-section--augments { width: 100%; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.07); }
    .ctft-section--gods { width: 100%; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.07); }
    .ctft-section--stats { width: 100%; }
    .ctft-gods-grid { flex-direction: row; flex-wrap: wrap; justify-content: center; }
    .ctft-stats-grid { flex-direction: row; flex-wrap: wrap; }
    .ctft-stat-card { flex: 1; min-width: 84px; }
    .ctft-gameplan-grid { grid-template-columns: 1fr; }
    .ctft-comp-panel--single .ctft-section--units { padding: 12px 10px; }

/* MOBILE UNIT BOARD: 3 per row, big hexes filling the column */
    .ctft-comp-panel--single .ctft-board-units,
    .ctft-comp-panel--single .ctft-board-units:has(.ctft-unit-card:nth-of-type(9)),
    .ctft-comp-panel--single .ctft-board-units:has(.ctft-unit-card:nth-of-type(7)),
    .ctft-comp-panel--single .ctft-board-units:has(.ctft-units-row:nth-of-type(2) .ctft-unit-card:nth-of-type(4)) {
        gap: 12px !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        justify-content: center;
        width: 100%;
    }
    .ctft-comp-panel--single .ctft-unit-card {
        width: 88px;
        max-width: none;
    }
    .ctft-comp-panel--single .ctft-unit-hex-outer { width: 88px; }
    .ctft-comp-panel--single .ctft-unit-hex-border { width: 88px; height: auto; aspect-ratio: 91 / 103; }
    .ctft-comp-panel--single .ctft-unit-hex { width: 87%; height: auto; aspect-ratio: 79 / 91; }
    .ctft-comp-panel--single .ctft-unit-hex-outer {
        width: 100%;
    }
    .ctft-comp-panel--single .ctft-unit-hex-border {
        width: 100%;
        height: auto;
        aspect-ratio: 91 / 103;
    }
    .ctft-comp-panel--single .ctft-unit-hex {
        width: 87%;
        height: auto;
        aspect-ratio: 79 / 91;
    }
    .ctft-comp-panel--single .ctft-unit-name-overlay {
        font-size: 9px;
        bottom: 10px;
    }
    .ctft-comp-panel--single .ctft-item-icon {
        max-width: 28px;
    }
    .ctft-comp-panel--single .ctft-three-star {
        padding: 1px 4px;
        gap: 1px;
    }
    .ctft-comp-panel--single .ctft-three-star span {
        font-size: 12px;
    }

    /* Disable tooltips on mobile */
    .ctft-unit-tooltip, .ctft-item-tooltip, .ctft-trait-tooltip, .ctft-aug-tooltip, .ctft-god-tooltip { display: none !important; }
}

/* ============================================================
   AUGMENT BUDDY
   ============================================================ */
.caugm-wrap { display: flex; flex-direction: column; gap: 17px; }
.caugm-filters { display: flex; flex-direction: column; gap: 7px; }
.caugm-filter-row { display: flex; flex-wrap: wrap; gap: 7px; }
.caugm-filter { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #aaa; font-size: 12px; font-weight: 700; padding: 5px 14px; border-radius: 24px; cursor: pointer; text-transform: uppercase; letter-spacing: 0.5px; transition: background 0.15s, color 0.15s, border-color 0.15s; -webkit-appearance: none; outline: none; }
.caugm-filter:hover { background: rgba(255,255,255,0.12); color: #fff; }
.caugm-filter:focus { outline: none; }
.caugm-filter.active { background: #e2b96f; border-color: #e2b96f; color: #000; }
.caugm-filter-silver.active { background: #555; border-color: #777; color: #fff; }
.caugm-filter-gold.active { background: #b8860b; border-color: #b8860b; color: #fff; }
.caugm-filter-prismatic.active { background: #6a0dad; border-color: #6a0dad; color: #fff; }
.caugm-stylef-combat.active { background: #c0392b; border-color: #c0392b; color: #fff; }
.caugm-stylef-economy.active { background: #b8860b; border-color: #b8860b; color: #fff; }
.caugm-stylef-item.active { background: #1a4a7a; border-color: #1a4a7a; color: #fff; }
.caugm-stylef-trait.active { background: #4a2a7a; border-color: #4a2a7a; color: #fff; }
.caugm-stylef-unique.active { background: #2a5a5a; border-color: #2a5a5a; color: #fff; }
.caugm-stylef-hero.active { background: #7a4a00; border-color: #7a4a00; color: #fff; }
.caugm-tierlist { display: flex; flex-direction: column; gap: 7px; }
.caugm-tier-block.caugm-tier-hidden { display: none; }
.caugm-tier-row { display: flex; align-items: stretch; background: #111; border-radius: 12px; border: 2px solid var(--aug-tier-color); overflow: hidden; }
.caugm-tier-label { width: 84px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--aug-tier-color); gap: 5px; padding: 14px 0; position: relative; align-self: stretch; }
.caugm-tier-letter { font-size: 43px; font-weight: 900; color: #fff; line-height: 1; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
.caugm-tier-sub { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.75); letter-spacing: 2px; }
.caugm-tier-label::before, .caugm-tier-label::after { content: ''; position: absolute; width: 12px; height: 12px; border-color: rgba(255,255,255,0.5); border-style: solid; }
.caugm-tier-label::before { top: 8px; left: 8px; border-width: 2px 0 0 2px; }
.caugm-tier-label::after { bottom: 8px; right: 8px; border-width: 0 2px 2px 0; }
.caugm-tier-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; padding: 14px; flex: 1; align-content: start; }
.caugm-item { position: relative; }
.caugm-item.caugm-hidden { display: none; }
.caugm-card { background: #1a1a1a; border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; transition: border-color 0.15s, background 0.15s; width: 100%; height: 198px; }
.caugm-card:hover { border-color: rgba(255,255,255,0.2); background: #222; }
.caugm-card.active { border-color: #e2b96f; background: #222; }
.caugm-card-img { width: 67px; height: 67px; flex-shrink: 0; }
.caugm-card-img img { width: 67px; height: 67px; border-radius: 10px; object-fit: cover; display: block; }
.caugm-card-img-placeholder { width: 67px; height: 67px; border-radius: 10px; background: #333; }
.caugm-name { font-size: 11px; color: #ccc; text-align: center; line-height: 1.3; width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.caugm-badges { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.caugm-badge { font-size: 8px; font-weight: 800; padding: 1px 5px; border-radius: 4px; text-transform: uppercase; font-style: normal; }
.caugm-style-economy { background: #b8860b; color: #fff; }
.caugm-style-combat { background: #c0392b; color: #fff; }
.caugm-style-item { background: #1a4a7a; color: #fff; }
.caugm-style-trait { background: #4a2a7a; color: #fff; }
.caugm-style-hero { background: #7a4a00; color: #fff; }
.caugm-style-unique { background: #2a5a5a; color: #fff; }
.caugm-stages { display: flex; gap: 3px; justify-content: center; flex-wrap: wrap; }
.caugm-stage { font-size: 8px; color: #888; background: rgba(255,255,255,0.06); border-radius: 4px; padding: 1px 4px; }
.caugm-comp-count { font-size: 10px; color: #e2b96f; font-weight: 700; margin-top: auto; }
.caugm-panel { display: none; position: fixed; width: 432px; z-index: 99999; background: #161616; border: 1px solid rgba(255,255,255,0.12); border-radius: 14px; padding: 19px; box-shadow: 0 8px 40px rgba(0,0,0,0.9); }
.caugm-panel.active { display: block; }
.caugm-panel-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,0.07); padding-bottom: 10px; gap: 7px; }
.caugm-panel-header span { font-size: 12px; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: 1px; flex: 1; }
.caugm-panel-close { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); color: #aaa; width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-size: 12px; flex-shrink: 0; transition: background 0.15s; -webkit-appearance: none; outline: none; display: flex; align-items: center; justify-content: center; }
.caugm-panel-close:hover { background: rgba(255,255,255,0.18); color: #fff; }
.caugm-panel-desc { font-size: 13px; color: #aaa; margin: 5px 0 0; line-height: 1.5; width: 100%; }
.caugm-comp-list { display: flex; flex-direction: column; gap: 7px; max-height: 354px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }
.caugm-comp-list::-webkit-scrollbar { width: 5px; }
.caugm-comp-list::-webkit-scrollbar-track { background: transparent; }
.caugm-comp-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.caugm-comp-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(255,255,255,0.03); border-radius: 10px; border: 1px solid rgba(255,255,255,0.06); }
a.caugm-comp-row { text-decoration: none; color: inherit; transition: background 0.15s, border-color 0.15s, transform 0.15s; }
a.caugm-comp-row:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); transform: translateX(2px); }
.caugm-comp-tier-badge { width: 26px; height: 26px; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 900; color: #fff; flex-shrink: 0; }
.caugm-comp-hex { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; border: 2px solid; flex-shrink: 0; }
.caugm-comp-hex img { width: 100%; height: 100%; object-fit: cover; }
.caugm-comp-info { display: flex; flex-direction: column; gap: 1px; }
.caugm-comp-name { font-size: 14px; font-weight: 700; color: #fff; }
.caugm-comp-meta { font-size: 12px; color: #888; }

/* Augment search bar */
.caugm-search-bar { position: relative; width: 100%; max-width: 480px; margin-top: 4px; }
.caugm-search-input { width: 100%; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; color: #fff; font-size: 14px; font-weight: 500; padding: 12px 44px 12px 16px; outline: none; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s; }
.caugm-search-input::placeholder { color: #666; font-weight: 400; }
.caugm-search-input:focus { background: rgba(255,255,255,0.08); border-color: #e2b96f; box-shadow: 0 0 0 3px rgba(226, 185, 111, 0.15); }
.caugm-search-clear { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.1); border: none; color: #aaa; width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-size: 12px; display: none; align-items: center; justify-content: center; padding: 0; transition: background 0.15s, color 0.15s; }
.caugm-search-bar.has-value .caugm-search-clear { display: flex; }
.caugm-search-clear:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ============================================================
   HOMEPAGE TRENDING CARDS
   ============================================================ */
.cthp-wrap { display: flex; flex-direction: column; gap: 48px; }
.cthp-section { display: flex; flex-direction: column; gap: 20px; }
.cthp-heading { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.cthp-subhead { font-size: 12px; font-weight: 700; color: #e2b96f; text-transform: uppercase; letter-spacing: 3px; }
.cthp-title { font-size: 36px; font-weight: 900; color: #fff; margin: 0; text-transform: uppercase; letter-spacing: 1.5px; line-height: 1; }
.cthp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.cthp-comp-card { position: relative; display: block; height: 220px; border-radius: 14px; overflow: hidden; border: 2px solid var(--card-tier); text-decoration: none; transition: transform 0.2s, box-shadow 0.2s; cursor: pointer; }
.cthp-comp-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,0.6); }
.cthp-comp-banner { position: absolute; inset: 0; background-size: cover; background-position: center; }
.cthp-comp-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.5) 50%, rgba(0,0,0,0.2) 100%); display: flex; flex-direction: column; justify-content: space-between; padding: 14px; }
.cthp-comp-top { display: flex; justify-content: space-between; align-items: flex-start; }
.cthp-tier-badge { padding: 4px 10px; border-radius: 5px; font-size: 14px; font-weight: 900; color: #fff; letter-spacing: 1px; }
.cthp-comp-hex { width: 52px; height: 52px; border-radius: 50%; overflow: hidden; border: 3px solid; box-shadow: 0 2px 12px rgba(0,0,0,0.6); }
.cthp-comp-hex img { width: 100%; height: 100%; object-fit: cover; }
.cthp-comp-bottom { display: flex; flex-direction: column; gap: 6px; }
.cthp-comp-name { font-size: 20px; font-weight: 900; color: #fff; margin: 0; text-transform: uppercase; letter-spacing: 1px; line-height: 1.1; text-shadow: 0 2px 8px rgba(0,0,0,0.9); }
.cthp-comp-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.cthp-tag { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25); border-radius: 4px; padding: 3px 8px; font-size: 10px; font-weight: 700; color: #e2b96f; letter-spacing: 1px; }
.cthp-aug-card { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 20px 16px 16px; background: #161616; border: 2px solid var(--card-tier); border-radius: 14px; text-decoration: none; transition: transform 0.2s, box-shadow 0.2s; cursor: pointer; }
.cthp-aug-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,0.6); }
.cthp-aug-tier-badge { position: absolute; top: 10px; left: 10px; width: 26px; height: 26px; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 900; color: #fff; }
.cthp-aug-img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; }
.cthp-aug-name { font-size: 15px; font-weight: 800; color: #fff; margin: 0; text-align: center; line-height: 1.2; }
.cthp-aug-type { font-size: 9px; font-weight: 800; padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: 1px; color: #fff; }
.cthp-aug-type-silver { background: #777; }
.cthp-aug-type-gold { background: #b8860b; }
.cthp-aug-type-prismatic { background: #6a0dad; }
.cthp-aug-desc { font-size: 12px; color: #aaa; margin: 4px 0 0; text-align: center; line-height: 1.5; }

@media (max-width: 768px) {
    .cthp-grid { grid-template-columns: 1fr; }
    .cthp-title { font-size: 26px; }
}

/* Tooltips: keep within viewport regardless of which element triggers them */
.ctft-item-tooltip,
.ctft-unit-tooltip {
    max-width: min(240px, calc(100vw - 16px));
}

/* For tooltips inside .ctft-comp-panel--single, allow them to shift if needed */
.ctft-comp-panel--single .ctft-unit-card,
.ctft-comp-panel--single .ctft-item-wrap {
    position: relative;
}

/* When unit/item is in the LEFT half of viewport, anchor tooltip to LEFT */
.ctft-comp-panel--single .ctft-item-wrap:hover .ctft-item-tooltip,
.ctft-comp-panel--single .ctft-unit-card:hover .ctft-unit-tooltip {
    left: 50%;
    transform: translateX(-50%);
}

/* Use clamp to keep tooltip on screen no matter where the trigger is */
.ctft-comp-panel--single .ctft-item-tooltip,
.ctft-comp-panel--single .ctft-unit-tooltip {
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
}

/* Edge cases: first/last item in row */
.ctft-units-row > *:first-child .ctft-item-tooltip,
.ctft-units-row > *:first-child .ctft-unit-tooltip,
.ctft-board-units > *:first-child .ctft-item-tooltip,
.ctft-board-units > *:first-child .ctft-unit-tooltip {
    left: 0;
    transform: none;
}
.ctft-units-row > *:last-child .ctft-item-tooltip,
.ctft-units-row > *:last-child .ctft-unit-tooltip,
.ctft-board-units > *:last-child .ctft-item-tooltip,
.ctft-board-units > *:last-child .ctft-unit-tooltip {
    left: auto;
    right: 0;
    transform: none;
}

/* Stop tooltips overflowing left edge of container */
.ctft-comp-panel--single .ctft-item-tooltip,
.ctft-comp-panel--single .ctft-unit-tooltip {
    left: 0 !important;
    transform: none !important;
    right: auto !important;
}