/* =============================================================
   polish_final.css
   Cosmetic-only polish layer. Loaded AFTER style.css and
   menu_animations.css. Uses higher-specificity selectors so it
   never replaces existing rules — only enhances them.
   All animations use transform / opacity / box-shadow only.
   ============================================================= */

/* -------------------------------------------------------------
   1. HUD COHERENCE — glass blur + glow border (positioning-safe)
   IMPORTANT: do NOT set `position: relative` on these panels —
   their layout uses `position: absolute|fixed` via .hud-panel.
   We render the glow border via box-shadow only, which doesn't
   need a positioning context.
   ------------------------------------------------------------- */
html body #top-bar,
html body #wave-preview,
html body #build-panel,
html body #tower-info,
html body #ability-bar,
html body #mp-hud {
    backdrop-filter: blur(4px) saturate(1.1);
    -webkit-backdrop-filter: blur(4px) saturate(1.1);
    box-shadow:
        inset 0 0 0 1px rgba(0, 229, 255, 0.32),
        0 0 18px rgba(0, 180, 255, 0.10);
    transition: box-shadow 0.25s ease;
}

/* -------------------------------------------------------------
   2. TOWER CARD REFINEMENT — additive only, never resize children
   (the build panel is height-constrained; rewriting child sizes
   pushes labels off-screen.)
   ------------------------------------------------------------- */
html body .tower-card {
    transition: transform 0.18s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}

html body .tower-card .tower-card-cost {
    color: #ffd24a;
    text-shadow: 0 0 4px rgba(255, 196, 60, 0.35);
    font-weight: 700;
}

html body .tower-card.unaffordable .tower-card-cost {
    color: #c98b8b;
    text-shadow: none;
}

html body .tower-card:hover:not(.disabled):not(.locked) {
    transform: translateY(-2px);
    box-shadow:
        0 6px 18px rgba(0, 229, 255, 0.18),
        0 0 0 1px rgba(0, 229, 255, 0.35);
}

html body .tower-card.active,
html body .tower-card.selected {
    box-shadow:
        0 0 0 2px rgba(0, 229, 255, 0.85),
        0 0 18px rgba(0, 229, 255, 0.55),
        inset 0 0 12px rgba(0, 229, 255, 0.12);
    animation: pf-card-active-pulse 2.4s ease-in-out infinite;
}

@keyframes pf-card-active-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.85), 0 0 14px rgba(0, 229, 255, 0.45), inset 0 0 10px rgba(0, 229, 255, 0.10); }
    50%      { box-shadow: 0 0 0 2px rgba(0, 229, 255, 1.00), 0 0 22px rgba(0, 229, 255, 0.70), inset 0 0 14px rgba(0, 229, 255, 0.18); }
}

/* -------------------------------------------------------------
   3. ABILITY BAR — circular buttons + sweep-arc cooldown
   ------------------------------------------------------------- */
html body #ability-bar .ability-btn {
    border-radius: 50%;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    overflow: hidden;
}

html body #ability-bar .ability-btn:hover:not(:disabled):not(.on-cooldown) {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 6px 16px rgba(0, 229, 255, 0.30),
        0 0 0 1px rgba(0, 229, 255, 0.55),
        inset 0 0 10px rgba(0, 229, 255, 0.18);
    filter: saturate(1.15) brightness(1.05);
}

html body #ability-bar .ability-btn.active {
    box-shadow:
        0 0 0 2px rgba(255, 220, 80, 0.85),
        0 0 18px rgba(255, 200, 60, 0.55),
        inset 0 0 12px rgba(255, 220, 80, 0.20);
}

html body .ability-cooldown-overlay {
    border-radius: 50%;
    background: conic-gradient(
        from -90deg,
        rgba(0, 0, 0, 0.55) 0%,
        rgba(0, 0, 0, 0.55) calc(var(--cd-progress, 0) * 1%),
        rgba(0, 0, 0, 0.0)  calc(var(--cd-progress, 0) * 1%),
        rgba(0, 0, 0, 0.0)  100%);
    transition: background 0.15s linear;
    pointer-events: none;
}

html body .ability-cooldown-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: inset 0 0 6px rgba(0, 229, 255, 0.25);
    pointer-events: none;
}

/* -------------------------------------------------------------
   4. PILL ROW — neon tabs + slide-in indicator
   ------------------------------------------------------------- */
html body .pill-row .pill,
html body .pill-row button {
    position: relative;
    transition: color 0.18s ease, transform 0.15s ease, background 0.2s ease;
    overflow: hidden;
}

html body .pill-row .pill::after,
html body .pill-row button::after {
    content: "";
    position: absolute;
    left: 12%;
    right: 12%;
    bottom: 2px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg,
        rgba(0, 229, 255, 0) 0%,
        rgba(0, 229, 255, 1) 50%,
        rgba(0, 229, 255, 0) 100%);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.28s cubic-bezier(0.22, 0.9, 0.32, 1.2), opacity 0.2s ease;
    opacity: 0.0;
    pointer-events: none;
}

html body .pill-row .pill.active::after,
html body .pill-row .pill[aria-selected="true"]::after,
html body .pill-row button.active::after,
html body .pill-row button[aria-selected="true"]::after {
    transform: scaleX(1);
    opacity: 1;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.85);
}

html body .pill-row .pill:hover:not(.active),
html body .pill-row button:hover:not(.active) {
    transform: translateY(-1px);
}

/* -------------------------------------------------------------
   5. TOP-BAR VALUE TICKERS — bumped state
   ------------------------------------------------------------- */
html body #top-bar .bumped,
html body .bumped {
    display: inline-block;
    transform: scale(1.18);
    color: #ffd24a;
    text-shadow:
        0 0 8px rgba(255, 200, 60, 0.85),
        0 0 16px rgba(255, 160, 40, 0.45);
    transition: transform 0.18s cubic-bezier(0.22, 0.9, 0.32, 1.4),
                color 0.25s ease,
                text-shadow 0.25s ease;
    will-change: transform;
}

/* Special tint when lives drop */
html body .bumped.bumped-down {
    color: #ff7a7a;
    text-shadow:
        0 0 8px rgba(255, 90, 90, 0.85),
        0 0 16px rgba(220, 50, 50, 0.45);
}

/* -------------------------------------------------------------
   6. CARD DRAFT — hover lift + rarity-tinted glow + pick anim
   ------------------------------------------------------------- */
html body .draft-card {
    transition:
        transform 0.22s cubic-bezier(0.22, 0.9, 0.32, 1.2),
        box-shadow 0.25s ease,
        filter 0.2s ease;
    will-change: transform;
}

html body .draft-card:hover:not(.selected) {
    transform: translateY(-6px) scale(1.02);
    filter: saturate(1.1) brightness(1.05);
}

/* Per-rarity glow on hover (matches existing rarity classes) */
html body .draft-card:hover {
    box-shadow:
        0 10px 28px rgba(180, 200, 220, 0.20),
        0 0 0 1px rgba(180, 200, 220, 0.35),
        0 0 24px rgba(180, 200, 220, 0.30);
}

html body .draft-card.rarity-common:hover,
html body .draft-card[data-rarity="common"]:hover {
    box-shadow:
        0 10px 26px rgba(200, 210, 220, 0.22),
        0 0 0 1px rgba(200, 210, 220, 0.45),
        0 0 22px rgba(200, 210, 220, 0.30);
}

html body .draft-card.rarity-rare:hover,
html body .draft-card[data-rarity="rare"]:hover {
    box-shadow:
        0 10px 28px rgba(80, 160, 255, 0.30),
        0 0 0 1px rgba(80, 160, 255, 0.55),
        0 0 26px rgba(80, 160, 255, 0.45);
}

html body .draft-card.rarity-epic:hover,
html body .draft-card[data-rarity="epic"]:hover {
    box-shadow:
        0 10px 30px rgba(180, 90, 230, 0.35),
        0 0 0 1px rgba(180, 90, 230, 0.60),
        0 0 28px rgba(180, 90, 230, 0.50);
}

html body .draft-card.rarity-legendary:hover,
html body .draft-card[data-rarity="legendary"]:hover {
    box-shadow:
        0 10px 32px rgba(255, 180, 60, 0.40),
        0 0 0 1px rgba(255, 200, 80, 0.70),
        0 0 32px rgba(255, 180, 60, 0.55);
}

/* Pick animation — scales up briefly before draft closes */
html body .draft-card.selected,
html body .draft-card.picked,
html body .draft-card.is-picked {
    animation: pf-card-pick 0.55s cubic-bezier(0.22, 0.9, 0.32, 1.2) forwards;
    z-index: 10;
}

@keyframes pf-card-pick {
    0%   { transform: scale(1)    translateY(0); }
    35%  { transform: scale(1.10) translateY(-8px); box-shadow: 0 14px 36px rgba(0, 229, 255, 0.55), 0 0 0 2px rgba(0, 229, 255, 0.85); }
    100% { transform: scale(1.06) translateY(-4px); box-shadow: 0 10px 28px rgba(0, 229, 255, 0.45), 0 0 0 2px rgba(0, 229, 255, 0.70); }
}

/* -------------------------------------------------------------
   7. TOAST CONTAINER — neon outline + glass + slide-in
   ------------------------------------------------------------- */
html body .toast-container .toast,
html body .toast-container .toast-item {
    backdrop-filter: blur(6px) saturate(1.1);
    -webkit-backdrop-filter: blur(6px) saturate(1.1);
    background: linear-gradient(180deg,
        rgba(20, 30, 50, 0.78),
        rgba(15, 22, 40, 0.78));
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(0, 229, 255, 0.35),
        inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    animation: pf-toast-in 0.32s cubic-bezier(0.22, 0.9, 0.32, 1.2);
}

html body .toast-container .toast.success,
html body .toast-container .toast-item.toast-success {
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(80, 220, 140, 0.55),
        0 0 18px rgba(80, 220, 140, 0.25);
}

html body .toast-container .toast.error,
html body .toast-container .toast-item.toast-error {
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 90, 90, 0.55),
        0 0 18px rgba(255, 90, 90, 0.25);
}

html body .toast-container .toast.warning,
html body .toast-container .toast-item.toast-warning,
html body .toast-container .toast-item.toast-warn {
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 220, 90, 0.55),
        0 0 18px rgba(255, 200, 60, 0.25);
}

@keyframes pf-toast-in {
    0%   { opacity: 0; transform: translateX(24px) translateY(-4px) scale(0.96); }
    60%  { opacity: 1; transform: translateX(-2px) translateY(0)    scale(1.01); }
    100% { opacity: 1; transform: translateX(0)    translateY(0)    scale(1); }
}

/* -------------------------------------------------------------
   8. GAME OVER PANEL — bigger reveal + win/lose theme
   ------------------------------------------------------------- */
html body #game-over {
    animation: pf-gameover-in 0.55s cubic-bezier(0.22, 0.9, 0.32, 1.15);
}

html body #game-over .game-over-content,
html body #game-over .panel,
html body #game-over > div {
    animation: pf-gameover-content-in 0.7s 0.1s cubic-bezier(0.22, 0.9, 0.32, 1.2) backwards;
}

@keyframes pf-gameover-in {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes pf-gameover-content-in {
    0%   { opacity: 0; transform: scale(0.86) translateY(20px); }
    60%  { opacity: 1; transform: scale(1.03) translateY(-2px); }
    100% { opacity: 1; transform: scale(1)    translateY(0); }
}

/* Win theme */
html body #game-over.win,
html body #game-over[data-result="win"],
html body #game-over.victory {
    box-shadow:
        inset 0 0 120px rgba(0, 229, 200, 0.20),
        inset 0 0 0 2px rgba(0, 229, 255, 0.45);
}

html body #game-over.win .title,
html body #game-over.win h1,
html body #game-over.win h2,
html body #game-over[data-result="win"] h1,
html body #game-over[data-result="win"] h2 {
    color: #6ef0c8;
    text-shadow:
        0 0 14px rgba(110, 240, 200, 0.65),
        0 0 28px rgba(60, 220, 180, 0.45);
}

/* Lose theme */
html body #game-over.lose,
html body #game-over[data-result="lose"],
html body #game-over.defeat {
    box-shadow:
        inset 0 0 120px rgba(220, 60, 60, 0.18),
        inset 0 0 0 2px rgba(220, 70, 70, 0.40);
}

html body #game-over.lose .title,
html body #game-over.lose h1,
html body #game-over.lose h2,
html body #game-over[data-result="lose"] h1,
html body #game-over[data-result="lose"] h2 {
    color: #ff8080;
    text-shadow:
        0 0 14px rgba(255, 100, 100, 0.65),
        0 0 28px rgba(220, 50, 50, 0.45);
}

/* -------------------------------------------------------------
   9. WAVE BANNER — diagonal sheen
   IMPORTANT: do NOT override position — the banner uses absolute
   transform-based centering. Just add overflow + isolate stacking.
   ------------------------------------------------------------- */
html body #wave-banner {
    overflow: hidden;
    isolation: isolate;
}

html body #wave-banner::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -60%;
    width: 40%;
    height: 200%;
    background: linear-gradient(115deg,
        rgba(255, 255, 255, 0)   0%,
        rgba(255, 255, 255, 0)   35%,
        rgba(255, 255, 255, 0.18) 50%,
        rgba(0, 229, 255, 0.10)   55%,
        rgba(255, 255, 255, 0)   70%,
        rgba(255, 255, 255, 0)   100%);
    transform: translateX(0) skewX(-12deg);
    animation: pf-wave-sheen 2.6s ease-in-out infinite;
    pointer-events: none;
    mix-blend-mode: screen;
}

@keyframes pf-wave-sheen {
    0%   { transform: translateX(0)    skewX(-12deg); opacity: 0; }
    25%  { opacity: 1; }
    100% { transform: translateX(420%) skewX(-12deg); opacity: 0; }
}

html body #wave-banner.hiding::after {
    animation: none;
}

/* -------------------------------------------------------------
   10. SETTINGS PANEL — row hover + slider thumb glow
   ------------------------------------------------------------- */
html body .settings-panel .settings-row {
    transition: background 0.18s ease, transform 0.15s ease;
    border-radius: 6px;
}

html body .settings-panel .settings-row:nth-child(even):hover,
html body .settings-panel .settings-row:hover {
    background: linear-gradient(90deg,
        rgba(0, 229, 255, 0.06),
        rgba(0, 229, 255, 0.02) 60%,
        transparent);
}

/* Neon slider thumb */
html body .settings-panel input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

html body .settings-panel input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #aef4ff 0%, #00e5ff 50%, #0088aa 100%);
    box-shadow:
        0 0 10px rgba(0, 229, 255, 0.85),
        0 0 0 2px rgba(0, 0, 0, 0.35);
    transition: transform 0.15s ease, box-shadow 0.18s ease;
    cursor: pointer;
    border: none;
}

html body .settings-panel input[type="range"]::-webkit-slider-thumb:hover,
html body .settings-panel input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.18);
    box-shadow:
        0 0 16px rgba(0, 229, 255, 1),
        0 0 0 2px rgba(0, 0, 0, 0.40);
}

html body .settings-panel input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #aef4ff 0%, #00e5ff 50%, #0088aa 100%);
    box-shadow:
        0 0 10px rgba(0, 229, 255, 0.85),
        0 0 0 2px rgba(0, 0, 0, 0.35);
    border: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.18s ease;
}

html body .settings-panel input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.18);
    box-shadow:
        0 0 16px rgba(0, 229, 255, 1),
        0 0 0 2px rgba(0, 0, 0, 0.40);
}

html body .settings-panel input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg,
        rgba(0, 229, 255, 0.55),
        rgba(0, 229, 255, 0.18));
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.45);
}

html body .settings-panel input[type="range"]::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg,
        rgba(0, 229, 255, 0.55),
        rgba(0, 229, 255, 0.18));
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.45);
}

/* -------------------------------------------------------------
   REDUCED MOTION — disable heavy effects
   ------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    html body .tower-card.active,
    html body .tower-card.selected {
        animation: none !important;
    }
    html body .draft-card.selected,
    html body .draft-card.picked,
    html body .draft-card.is-picked {
        animation: none !important;
        transform: scale(1.02) !important;
    }
    html body .toast-container .toast,
    html body .toast-container .toast-item {
        animation: none !important;
    }
    html body #game-over,
    html body #game-over .game-over-content,
    html body #game-over .panel,
    html body #game-over > div {
        animation: none !important;
    }
    html body #wave-banner::after {
        animation: none !important;
        opacity: 0 !important;
    }
    html body .bumped {
        transition: none !important;
        transform: none !important;
    }
    html body #ability-bar .ability-btn:hover:not(:disabled):not(.on-cooldown) {
        transform: none !important;
    }
    html body .draft-card:hover:not(.selected) {
        transform: none !important;
    }
    html body .pill-row .pill::after,
    html body .pill-row button::after {
        transition: opacity 0.1s linear !important;
    }
}
