/* Additive 3D V6.2. Shared home glass; existing admin controls stay in charge. */
:root[data-td3d-live]{--td3d-side:#c0d1e2;--td3d-depth:5px;--td3d-shadow:#304c6d1b;--td3d-top:#ffffffb3;--td3d-sweep:#ffffff54;--td3d-float:7px;--td3d-rock:.55deg;--td3d-sway:1.5px}
:root[data-theme=dark][data-td3d-live]{--td3d-side:#25374f;--td3d-shadow:#02060d70;--td3d-top:#91c7fa24;--td3d-sweep:#a3dbff30}
:root[data-td3d-live] body.admin-body{--td3d-side:#263a54;--td3d-shadow:#02060d60;--td3d-top:#a1c9f12b;--td3d-sweep:#93ceff24}
:root[data-td3d-live=soft]{--td3d-depth:3px;--td3d-float:4px;--td3d-rock:.3deg;--td3d-sway:1px}:root[data-td3d-live=bold]{--td3d-depth:8px;--td3d-float:10px;--td3d-rock:.75deg;--td3d-sway:2px}
:root[data-td3d-live] body .td3d-perspective{perspective:1100px}
:root[data-td3d-live] body .td3d-card{position:relative;transform-style:preserve-3d;transform:translateY(var(--td3d-touch-y,0px)) rotateX(var(--td3d-rx,0deg)) rotateY(var(--td3d-ry,0deg))!important;transition:transform .48s cubic-bezier(.2,.75,.2,1),scale .16s ease!important;box-shadow:0 var(--td3d-depth) 0 var(--td3d-side),0 14px 24px var(--td3d-shadow),inset 0 1px 0 var(--td3d-top)!important}
:root[data-td3d-live] body.home-page :is(.mod-card,.key-card,.modfile-card).td3d-card{overflow:clip}
:root[data-td3d-live] body .td3d-card[data-td3d-pointer]{transition:transform .13s ease-out,scale .16s ease!important}
:root[data-td3d-live] body :is(.cloud-button,.open-icon,.modfile-open,.custom-action-button).td3d-button{position:relative;box-shadow:0 0 13px var(--td3d-icon-glow,#2caef336)!important;transition:opacity .15s ease!important}
:root[data-td3d-live] body.game-detail .detail-card{box-shadow:0 4px 0 var(--td3d-side),0 15px 26px var(--td3d-shadow)!important}
:root[data-td3d-live] body.game-detail .detail-app-card{background:transparent!important;box-shadow:none!important}
/* Pause the former motion layer while comparing 3D; its CSS is retained for 2D. */
:root[data-td3d-live] :is(.td-edge-trace,.td-r1-rim,.td-r2-rim,.td-r3-rim,.td-r4-rim,.td-r5-rim,.td-r6-rim,.td-button-flare,.td-home-sheen){display:none!important}
:root[data-td3d-live] :is(.td-idle-float,.td-r1-icon,.td-r2-icon,.td-r3-icon,.td-r4-icon,.td-r5-icon,.td-r6-icon){animation:none!important}
/* Home only. Images inside the detail page never receive a sweeping layer. */
.td3d-live-sheen{display:none}
:root[data-td3d-live] .td3d-live-sheen{display:block;position:absolute;inset:0;border-radius:inherit;overflow:hidden;pointer-events:none;z-index:1;margin:0!important;padding:0!important;background:none!important}
:root[data-td3d-live] .td3d-live-sheen::after{content:"";position:absolute;top:-20%;bottom:-20%;left:-65%;width:42%;background:linear-gradient(110deg,transparent,var(--td3d-sweep),transparent);opacity:0;translate:0 0}
:root[data-td3d-live] body .td3d-card[data-td3d-animate=on]>.td3d-live-sheen::after{animation:td3d-live-sweep 6.8s ease-in-out infinite;animation-delay:var(--td3d-phase,0s)}
/* Keeping the same animation while paused avoids a reset to the initial position. */
:root[data-td3d-live] body .td3d-idle{animation:var(--td3d-idle-name,td3d-live-float) var(--td3d-idle-duration,5.8s) ease-in-out infinite!important;animation-delay:var(--td3d-idle-delay,0s)!important;animation-play-state:paused!important}
:root[data-td3d-live]:not([data-td3d-paused]):not([data-td3d-idle-off]):not([data-td3d-lite]) body .td3d-idle[data-td3d-animate=on]:not(.td3d-enter):not([data-td3d-pressed]){animation-play-state:running!important}
/* Existing sticky headers, drawers, dialogs and forms stay outside tilted groups. */
:root[data-td3d-live] body.admin-body :is(.admin-stat,.admin-content-tile){border-top-color:var(--td3d-top)!important}
@keyframes td3d-live-float{0%,100%{translate:0 0;rotate:0deg}25%{translate:var(--td3d-sway) calc(-.55 * var(--td3d-float));rotate:var(--td3d-rock)}50%{translate:0 calc(-1 * var(--td3d-float));rotate:0deg}75%{translate:calc(-1 * var(--td3d-sway)) calc(-.55 * var(--td3d-float));rotate:calc(-1 * var(--td3d-rock))}}
@keyframes td3d-live-sweep{0%,12%{translate:0 0;opacity:0}22%{opacity:.65}53%,100%{translate:400% 0;opacity:0}}
:root[data-td3d-paused] .td3d-live-sheen::after,:root[data-td3d-paused] body .td3d-idle,:root[data-td3d-paused] body .td3d-button>svg{animation-play-state:paused!important}
:root[data-td3d-lite] body .td3d-card{transform:none!important}
:root:not([data-td3d-live]) :is(.td3d-card,.td3d-button){--td3d-rx:0deg;--td3d-ry:0deg}
#td3dLiveBar{position:fixed;left:50%;bottom:calc(14px + env(safe-area-inset-bottom));translate:-50% 0;z-index:998;display:flex;align-items:center;gap:5px;max-width:calc(100vw - 24px);padding:6px 8px;border:1px solid #627c9d;border-radius:15px;background:#102039;color:#f0f7ff;box-shadow:0 6px 22px #0004;font:11px/1.3 system-ui,sans-serif;white-space:nowrap}
#td3dLiveBar :is(button,a){display:inline-flex;align-items:center;justify-content:center;margin:0;padding:8px;border-radius:9px;background:transparent;color:#c9d8ee;border:0;font:inherit;text-decoration:none;cursor:pointer}
#td3dLiveBar button[aria-pressed=true]{background:#2a496c;color:#fff}#td3dLiveBar .td3d-bar-label{padding:0 5px;font-weight:750;color:#8cd8ff}#td3dLiveBar a{color:#c7dbf6}#td3dLiveBar form{display:contents}#td3dLiveBar .td3d-stop{color:#ffbaba}#td3dLiveBar :is(button,a):focus-visible{outline:2px solid #8ad9ff;outline-offset:2px}
:root[data-td3d-toolbar] body:not(.admin-body){padding-bottom:80px}
@media(prefers-reduced-motion:reduce){:root[data-td3d-live] body .td3d-card{transform:none!important;transition:none!important}:root[data-td3d-live] body .td3d-idle,:root[data-td3d-live] body .td3d-button>svg,:root[data-td3d-live] .td3d-live-sheen::after{animation:none!important}}

:root[data-td3d-live] body.home-page .profile-stats>div:last-of-type::after{content:none!important;display:none!important}
/* V6: foreground movement and button light, without running colored borders. */
.td3d-button-sheen{display:none}
:root[data-td3d-live] .td3d-button-sheen{display:block;position:absolute!important;inset:0!important;overflow:hidden;pointer-events:none;border-radius:inherit;margin:0!important;padding:0!important;background:none!important;z-index:1}
:root[data-td3d-live] .td3d-button-sheen::after{content:"";position:absolute;top:-25%;bottom:-25%;left:-70%;width:50%;background:linear-gradient(110deg,transparent,#ffffff18,#ffffff88,#ffffff18,transparent);opacity:0}
:root[data-td3d-live] body :is(.td3d-button,.td3d-icon-tile)[data-td3d-animate=on]>.td3d-button-sheen::after{animation:td3d-button-sweep 5s ease-in-out infinite;animation-delay:var(--td3d-phase,0s)}
:root[data-td3d-live] body .td3d-enter{animation-play-state:paused!important;will-change:opacity,translate}
:root[data-td3d-live] body :is(.gallery-modal.show .gallery-dialog,.warning-modal.show>div,.guide-content-modal.show .guide-content-dialog,.download-choice-modal.show .download-choice-dialog,.site-notice.is-show .site-notice-card){animation:td3d-dialog .28s cubic-bezier(.2,.8,.2,1)!important}

@keyframes td3d-dialog{from{translate:0 12px;scale:.97;opacity:.5}to{translate:0 0;scale:1;opacity:1}}
@keyframes td3d-button-sweep{0%,10%{translate:0 0;opacity:0}20%{opacity:.7}50%,100%{translate:390% 0;opacity:0}}
:root[data-td3d-paused] .td3d-button-sheen::after,:root[data-td3d-paused] body .td3d-card :is(svg,.hero-shop-arrow){animation-play-state:paused!important}

@media(prefers-reduced-motion:reduce){:root[data-td3d-live] body .td3d-enter,:root[data-td3d-live] .td3d-button-sheen::after,:root[data-td3d-live] body .td3d-card :is(svg,.hero-shop-arrow),:root[data-td3d-live] body :is(.gallery-dialog,.warning-modal>div,.guide-content-dialog,.download-choice-dialog,.site-notice-card){animation:none!important}}

:root[data-td3d-live] :is(.td-r1-enter,.td-r2-enter,.td-r3-enter,.td-r4-enter,.td-r5-enter,.td-r6-enter){animation:none!important;scale:1!important}
:root[data-td3d-live] body .td3d-idle.td3d-enter{animation-play-state:paused!important}
:root[data-td3d-live] body.admin-body{--td3d-float:4px;--td3d-rock:.3deg;--td3d-sway:1px}
/* Close remains tappable and hidden state wins over the older display:flex rule. */
#td3dLiveBar[hidden],:root[data-td3d-toolbar-hidden] #td3dLiveBar{display:none!important;pointer-events:none!important}
#td3dLiveBar .td3d-hide-toolbar{width:44px;min-width:44px;min-height:44px;padding:0!important;font-size:23px;line-height:1;background:#ffffff0d;touch-action:manipulation;pointer-events:auto;position:relative;z-index:2}
#td3dLiveBar{z-index:9998;pointer-events:auto}
/* Limited liquid glass: soft static transparency and a slow specular reflection. */
.td3d-glass-optics{display:none}
:root[data-td3d-live][data-td3d-glass] body.home-page .td3d-glass-host{background:linear-gradient(130deg,#ffffffd9,#ffffff8f 52%,#edf7ffb8)!important;border-top-color:#fffffff0!important;box-shadow:0 3px 0 #b7cddd8c,0 11px 25px #3d68831c,inset 0 1px 0 #fff,inset 0 -1px 0 #ffffff88!important}
:root[data-theme=dark][data-td3d-live][data-td3d-glass] body.home-page .td3d-glass-host{background:linear-gradient(130deg,#284362c9,#142a40b8 52%,#17364acf)!important;border-top-color:#c7e7ff30!important;box-shadow:0 3px 0 #0a1d30ad,0 12px 24px #0003,inset 0 1px 0 #d2efff36,inset 0 -1px 0 #b6daee0e!important}
:root[data-td3d-live][data-td3d-glass] body.home-page .td3d-glass-optics{display:block;position:absolute!important;inset:0!important;margin:0!important;padding:0!important;overflow:hidden;border-radius:inherit;pointer-events:none;z-index:1;background:radial-gradient(ellipse at 12% 0,#ffffff45,transparent 58%)}
:root[data-td3d-live][data-td3d-glass] .td3d-glass-optics::after{content:"";position:absolute;top:-55%;left:-55%;width:44%;height:210%;border-radius:48%;background:linear-gradient(110deg,transparent,#ffffff0a 25%,#ffffff60 50%,#ffffff0a 75%,transparent);opacity:0;translate:0 0;rotate:14deg}
:root[data-td3d-live][data-td3d-glass] body.home-page .td3d-glass-host[data-td3d-animate=on]>.td3d-glass-optics::after{animation:td3d-glass-caustic 8.5s cubic-bezier(.4,0,.2,1) infinite;animation-delay:var(--td3d-phase,0s)}
:root[data-td3d-live][data-td3d-glass] body.home-page .td3d-glass-host>.td3d-live-sheen{display:none!important}
@supports ((backdrop-filter:blur(5px)) or (-webkit-backdrop-filter:blur(5px))){:root[data-td3d-live][data-td3d-glass]:not([data-td3d-lite]) body.home-page .hero-social.td3d-glass-host{-webkit-backdrop-filter:blur(5px) saturate(1.08);backdrop-filter:blur(5px) saturate(1.08)}}
@keyframes td3d-glass-caustic{0%,12%{translate:0 0;opacity:0}25%{opacity:.42}57%,100%{translate:370% 0;opacity:0}}
:root[data-td3d-paused] .td3d-glass-optics::after{animation-play-state:paused!important}
@media(prefers-reduced-motion:reduce){:root[data-td3d-live] .td3d-glass-optics::after{animation:none!important}}
@media(prefers-reduced-transparency:reduce){:root[data-td3d-live][data-td3d-glass] body.home-page .td3d-glass-host{background:var(--td-surface,var(--paper,#fff))!important;-webkit-backdrop-filter:none!important;backdrop-filter:none!important}.td3d-glass-optics{display:none!important}}

/* V6: independent social motion; a press pauses at its current phase. */
@keyframes td3d-social-rise{0%,100%{translate:0 0;rotate:-.3deg}45%{translate:1px calc(-1 * var(--td3d-float));rotate:.65deg}}
@keyframes td3d-social-sway{0%,100%{translate:-2px -2px;rotate:.55deg}50%{translate:2px calc(-.8 * var(--td3d-float));rotate:-.6deg}}
@keyframes td3d-social-orbit{0%,100%{translate:1px calc(-.7 * var(--td3d-float));rotate:.4deg}35%{translate:-2px 0;rotate:-.55deg}70%{translate:2px -3px;rotate:0deg}}
/* Restore a legible rim around TD MOD; retain its original text and dimensions. */
:root[data-td3d-live] body.home-page .profile-handle.td3d-brand{position:relative;isolation:isolate;overflow:hidden;border:1px solid #79bde4!important;background:linear-gradient(125deg,#ffffffed,#e8f7ffc2 50%,#fff9)!important;color:#286fa9!important;box-shadow:0 0 16px #44aef226,inset 0 1px 0 #fff,inset 0 -1px 0 #78bce84a!important;transition:transform .2s ease,scale .2s ease}
:root[data-theme=dark][data-td3d-live] body.home-page .profile-handle.td3d-brand{border-color:#68b6df!important;background:linear-gradient(125deg,#284662e8,#102e45b3 52%,#274762cf)!important;color:#a9dfff!important;box-shadow:0 0 17px #32b5ed28,inset 0 1px 0 #c5efff5c,inset 0 -1px 0 #71c9f526!important}
:root[data-td3d-live][data-td3d-glass] body.home-page .td3d-brand>.td3d-glass-optics{background:radial-gradient(ellipse at 15% 0,#fff9,transparent 65%)}
:root[data-td3d-live][data-td3d-glass] body.home-page .td3d-brand[data-td3d-animate=on]>.td3d-glass-optics::after{animation-duration:5.8s;animation-delay:-1.2s}
@supports ((backdrop-filter:blur(5px)) or (-webkit-backdrop-filter:blur(5px))){:root[data-td3d-live][data-td3d-glass]:not([data-td3d-lite]) body.home-page .td3d-brand{-webkit-backdrop-filter:blur(5px) saturate(1.12);backdrop-filter:blur(5px) saturate(1.12)}}
/* Icon faces remain flat. Only their reflection and rim opacity move. */
:root[data-td3d-live] body :is(.td3d-card svg,.td3d-button svg,.td3d-icon-tile svg,.hero-shop-arrow){animation:none!important;translate:none!important;rotate:none!important;transform:none!important}
:root[data-td3d-live] body .td3d-icon-tile{position:relative;transform:none!important;box-shadow:0 0 14px var(--td3d-icon-glow,#32acec30)!important}
:root[data-td3d-live] body :is(.cloud-button,.key-card .open-icon,.modfile-open).td3d-button{transform:none!important;translate:none!important;scale:1!important;animation:none!important}
:root[data-td3d-live] body :is(.cloud-button.android,.square-icon.green){--td3d-icon-glow:#35de985e}
:root[data-td3d-live] body .key-card:has(.square-icon.green) .open-icon{--td3d-icon-glow:#35de985e}
:root[data-td3d-live] body .modfile-open{--td3d-icon-glow:#35cbe66b}
.td3d-icon-halo{display:none}
:root[data-td3d-live] body .td3d-icon-halo{display:block;position:absolute!important;inset:0!important;margin:0!important;padding:0!important;pointer-events:none;border-radius:inherit;border:0!important;background:none!important;box-shadow:0 0 11px 2px var(--td3d-icon-glow,#39b9ff4a);opacity:.28;z-index:1}
:root[data-td3d-live] body :is(.td3d-button,.td3d-icon-tile)[data-td3d-animate=on]>.td3d-icon-halo{animation:td3d-icon-breathe 4.8s ease-in-out infinite;animation-delay:var(--td3d-phase,0s)}
@keyframes td3d-icon-breathe{0%,100%{opacity:.25}50%{opacity:.85}}
/* A clear, brief lift for the touched surface, without delaying actions. */
:root[data-td3d-live] body .td3d-touch-surface{transition:transform .2s cubic-bezier(.2,.7,.2,1),scale .2s ease!important}
:root[data-td3d-live] body .td3d-card[data-td3d-pressed]{--td3d-touch-y:-5px;scale:1.015!important;opacity:1!important;animation-play-state:paused!important;box-shadow:0 calc(var(--td3d-depth) + 3px) 0 var(--td3d-side),0 20px 30px var(--td3d-shadow),inset 0 1px 0 var(--td3d-top)!important;z-index:3}
:root[data-td3d-live] body .td3d-touch-surface[data-td3d-pressed]:not(.td3d-card){transform:translateY(-4px)!important;scale:1.015!important;opacity:1!important;box-shadow:0 12px 24px var(--td3d-shadow)!important;z-index:3}
:root[data-td3d-live] body :is(.hero-social,.hero-shop-card).td3d-card:focus-visible{--td3d-touch-y:-4px;outline:2px solid #62b9f0;outline-offset:3px}
:root[data-td3d-live] body .td-r6-tapped:not(.td3d-idle){animation:none!important}
:root[data-td3d-paused] .td3d-icon-halo{animation-play-state:paused!important}
@media(prefers-reduced-motion:reduce){:root[data-td3d-live] body .td3d-touch-surface{transition:none!important}:root[data-td3d-live] body .td3d-icon-halo{animation:none!important}}

:root[data-td3d-live][data-td3d-glass] body.home-page .td3d-glass-host[data-td3d-pressed]{box-shadow:0 6px 0 var(--td3d-side),0 20px 30px var(--td3d-shadow),inset 0 1px 0 var(--td3d-top)!important}

/* V6.1: no browser tap wash. Keyboard focus remains visible. */
:root body:is(.home-page,.game-detail){-webkit-tap-highlight-color:transparent}
:root body:is(.home-page,.game-detail) :is(a,button,summary,[role=button],[tabindex]){-webkit-tap-highlight-color:transparent!important}
/* Real icon borders are transparent without changing button dimensions. */
:root[data-td3d-live] body.home-page :is(.cloud-button,.key-card .open-icon,.modfile-open,.hero-shop-icon,.square-icon.key-download){border-color:transparent!important;overflow:visible!important}
/* The replacement sheen clips itself; suppress the old oversized hover layer. */
:root[data-td3d-live] body.home-page .cloud-button.td3d-button::after{display:none!important}
@media(hover:none){:root[data-td3d-live] body.home-page .game-card-clickable::before{display:none!important}}

/* Lower home cards share the Shop Key surface in both live themes. */
:root[data-td3d-live][data-td3d-glass] body.home-page :is(.mod-card,.key-card,.modfile-card,.guide-video-card,.profile-stats).td3d-glass-host{isolation:isolate}
:root[data-td3d-live][data-td3d-glass] body.home-page :is(.modfile-main,.guide-video-main){background-color:transparent!important;background-image:none!important}
/* The light is a non-interactive, self-clipped layer; it cannot change media sizing. */
:root[data-td3d-live][data-td3d-glass] body.home-page .td3d-glass-host>.td3d-glass-optics::before{content:"";position:absolute;inset:0;border-radius:inherit;box-shadow:inset 0 1px 0 #ffffffa6,inset 0 0 16px #9edaff28;opacity:.36;pointer-events:none}
:root[data-theme=dark][data-td3d-live][data-td3d-glass] body.home-page .td3d-glass-host>.td3d-glass-optics::before{box-shadow:inset 0 1px 0 #d8f0ff70,inset 0 0 16px #94d4ff22}
:root[data-td3d-live][data-td3d-glass] body.home-page .td3d-glass-host[data-td3d-animate=on]>.td3d-glass-optics::before{animation:td3d-glass-highlight 6.4s ease-in-out infinite;animation-delay:var(--td3d-phase,0s)}
@keyframes td3d-glass-highlight{0%,100%{opacity:.36}50%{opacity:.8}}
:root[data-td3d-paused] .td3d-glass-optics::before{animation-play-state:paused!important}
@media(prefers-reduced-motion:reduce){:root[data-td3d-live] .td3d-glass-optics::before{animation:none!important}}
