/********** Template CSS **********/

.hero-section {
    width: 100%;
    height: 100vh; /* 關鍵：佔滿 100% 視埠高度 */
    background-size: cover;
    background-position: center;
}

.logo-fix img {
    height: 30vh !important; /* 使用 !important 確保覆蓋 Bootstrap 預設值 */
    width: auto !important;   /* 確保寬度隨高度等比例縮放 */
    max-width: 90vw;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.small-logo-fix img {
    height: 4vh !important; /* 使用 !important 確保覆蓋 Bootstrap 預設值 */
    width: 4vh !important;   /* 確保寬度隨高度等比例縮放 */
    max-width: 10vw;
    object-fit: contain;
    margin-bottom: 15px ;
    margin-right: 15px ;
}

.small-logo-fix2 img {
    height: 10vh !important; /* 使用 !important 確保覆蓋 Bootstrap 預設值 */
    width: 8vh !important;   /* 確保寬度隨高度等比例縮放 */
    max-width: 10vw;
    object-fit: contain;
    margin-bottom: 20px ;
    margin-right: 15px ;
}

    .back-to-top {
    position: fixed;
    display: none;
    right: 45px;
    bottom: 45px;
    z-index: 99;
}

/*** Spinner ***/
#spinner {
    opacity: 0;
    visibility: hidden;
    transition: opacity .8s ease-out, visibility 0s linear .5s;
    z-index: 99999;
}

#spinner.show {
    transition: opacity .8s ease-out, visibility 0s linear 0s;
    visibility: visible;
    opacity: 1;
}


/*** Button ***/
.btn {
    font-weight: 600;
    transition: .5s;
    border-radius: 50px;
}

.btn-square {
    width: 38px;
    height: 38px;
}

.btn-sm-square {
    width: 32px;
    height: 32px;
}

.btn-lg-square {
    width: 48px;
    height: 48px;
}

.btn-square,
.btn-sm-square,
.btn-lg-square {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: inherit;
}

.btn-primary {
    color: var(--bs-white);
}


/*** Navbar ***/
.navbar {
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 9;
    transition: .5s;
}

.navbar .navbar-nav .nav-link {
    margin-right: 25px;
    padding: 40px 0;
    color: var(--bs-white);
    font-size: 17px;
    text-transform: uppercase;
    outline: none;
    transition: .5s;
}

.navbar .navbar-nav .nav-link:hover,
.navbar .navbar-nav .nav-link.active {
    color: var(--bs-primary);
}

@media (max-width: 991.98px) {
    .navbar .navbar-nav .nav-link,
    .navbar.bg-dark .navbar-nav .nav-link {
        margin-right: 0;
        padding: 10px 0;
    }

    .navbar .navbar-nav {
        margin-top: 8px;
        border-top: 1px solid var(--bs-light);
    }
}

@media (min-width: 992px) {
    .navbar.bg-dark .navbar-nav .nav-link {
        padding: 20px 0;
    }

    .navbar .nav-item .dropdown-menu {
        display: block;
        border: none;
        margin-top: 0;
        top: 150%;
        opacity: 0;
        visibility: hidden;
        transition: .5s;
    }

    .navbar .nav-item:hover .dropdown-menu {
        top: 100%;
        visibility: visible;
        transition: .5s;
        opacity: 1;
    }
}

.navbar .dropdown-toggle::after {
    border: none;
    content: "\f107";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    vertical-align: middle;
    margin-left: 8px;
}

.navbar-brand{
    margin-right:0; !important;
}

.mx-fix{
    margin-right:auto !important;margin-left:600px !important
}


/*** Header ***/
.carousel-caption {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding-top: 100px;
    background: rgba(0, 0, 0, .5);
    z-index: 1;
}

.carousel-control-prev,
.carousel-control-next {
    width: 10%;
}

.carousel-control-prev-icon,
.carousel-control-next-icon {
    width: 3rem;
    height: 3rem;
}

@media (max-width: 768px) {
    #header-carousel .carousel-item {
        position: relative;
        min-height: 550px;
    }
    
    #header-carousel .carousel-item img {
        width: 100%;
        height: 100%;
    }
}

.page-header {
    padding-top: 200px;
    background: linear-gradient(rgba(0, 0, 0, .7), rgba(0, 0, 0, .7)), url(../img/carousel-1.jpg) top center no-repeat;
    background-size: cover;
}

.page-header .breadcrumb-item + .breadcrumb-item::before {
    color: var(--bs-white);
}


/*** Title ***/
.title {
    margin-bottom: 2rem;
}

.title .title-left,
.title .title-center,
.title .title-right {
    display: inline-block;
    text-transform: uppercase;
    overflow: hidden;
}

.title .title-center {
    text-align: center;
}

.title .title-right {
    text-align: right;
}

.title .title-left h5,
.title .title-center h5,
.title .title-right h5 {
    position: relative;
    display: inline-block;
    font-size: 18px;
    font-weight: 300;
}

.title .title-left h5::after,
.title .title-center h5::before,
.title .title-center h5::after,
.title .title-right h5::before {
    position: absolute;
    content: "";
    width: 500%;
    height: 0;
    top: 9px;
    border-bottom: 1px solid var(--bs-white);
}

.title .title-left h5::after,
.title .title-center h5::after {
    left: calc(100% + 15px);
}

.title .title-right h5::before,
.title .title-center h5::before {
    right: calc(100% + 15px);
}

.title .title-left h1,
.title .title-center h1,
.title .title-right h1 {
    border-bottom: 1px solid var(--bs-white);
}

.title h1 {
    text-shadow: 3px 3px 0px var(--bs-primary), 6px 6px 0px #000;
    font-style: italic;
    letter-spacing: 2px;
}

/*** Service ***/
.service-item {
    position: relative;
    margin-top: 2.5rem;
    overflow: hidden;
    object-fit: scale-down;
}

.service-item .service-img {
    position: relative;
    display: inline-block;
}


.service-item.service-item-left {
    border-radius: 500px 500px 0 0;
    background: linear-gradient(to bottom, var(--bs-secondary), var(--bs-dark));
}

.service-item.service-item-right {
    border-radius: 0 500px 500px 0;
    background: linear-gradient(to left, var(--bs-secondary), var(--bs-dark));
}

@media (max-width: 767.98px) {
    .service-item.service-item-left,
    .service-item.service-item-right {
        border-radius: 500px 500px 0 0;
        background: linear-gradient(to bottom, var(--bs-secondary), var(--bs-dark));
        text-align: center;
    }
}


/*** Team ***/
.team-item {
    position: relative;
}

.team-item .team-name {
    position: absolute;
    width: 100%;
    height: 60px;
    left: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .7);
}

.team-item .team-body {
    position: relative;
    overflow: hidden;
}

.team-item .team-body .team-before,
.team-item .team-body .team-after {
    position: absolute;
    content: "";
    width: 0;
    height: calc(100% - 60px);
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, .7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: .5s;
}

.team-item .team-body .team-after {
    left: auto;
    right: 0;
}

.team-item .team-body .team-before {
    text-align: right;
}

.team-item:hover .team-body .team-before,
.team-item:hover .team-body .team-after {
    width: 50%;
}

.team-item .team-body .team-before span,
.team-item .team-body .team-after span {
    margin: 5px;
    color: var(--bs-white);
    opacity: 0;
    transition: .5s;
}

.team-item:hover .team-body .team-before span,
.team-item:hover .team-body .team-after span {
    opacity: 1;
    transition-delay: .2s;
}


/*** Testimonial ***/
.testimonial-carousel {
    max-width: 700px;
    margin: 0 auto;
}

.testimonial-carousel .owl-dots {
    margin-top: 35px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;

}

.testimonial-carousel .owl-dots .owl-dot {
    width: 60px;
    height: 60px;
    margin: 0 5px;
    padding: 10px;
    background: var(--bs-dark);
    border-radius: 100px;
    transition: .5s;
}

.testimonial-carousel .owl-dots .owl-dot.active {
    width: 100px;
    height: 100px;
}

.testimonial-carousel .owl-dots .owl-dot img {
    opacity: .1;
    transition: .5s;
    border-radius: 100px;
}

.testimonial-carousel .owl-dots .owl-dot.active img {
    opacity: 1;
}

/* 手機 / 平板主視覺滿版高度 */
@media (max-width: 991.98px) {
    #header-carousel .carousel-item {
        min-height: 100vh;  /* 基本滿版 */
    }

    /* 支援新 viewport 單位時，改善手機瀏覽器上方網址列高度變動問題 */
    @supports (height: 100dvh) {
        #header-carousel .carousel-item {
            min-height: 100dvh;
        }
    }

    /* 圖片等比例填滿整個畫面 */
    #header-carousel .carousel-item > img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* 文字區垂直置中 */
    #header-carousel .carousel-caption {
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 1.5rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
}

/*** Footer ***/
@keyframes footerAnimatedBg {
	0% {
        background-position: 0 0;
    }

	100% {
        background-position: -1000px 0;
    }
}

.footer {
	background-image: url(../img/footer-bg.png);
	background-position: 0px 0px;
    background-repeat: repeat-x;
	animation: footerAnimatedBg 50s linear infinite;
}

/* =========================
   For Some Optimized
   ========================= */

.add-padding{
    padding-top: 80px;
    padding-bottom: 80px;
}

.img-fix {
    width: 100%;             /* 隨父容器寬度縮放 */
    max-width: 400px;        /* 限制最大尺寸 */
    aspect-ratio: 1 / 1;    /* 關鍵：強制維持 1:1 正方形 */
    object-fit: cover;      /* 關鍵：確保圖片填滿正圓且不變形 */
    border-radius: 50% !important; /* 強制圓形 */
    display: block;
    margin: 0 auto;
}

.img-fix2 {
    width: 200px;
    height: 200px;
    overflow: hidden;
    object-fit: cover;
}

.img-fix img {
    object-fit: scale-down;
}

/* 移除超連結預設顏色 */
.team-link {
    display: block;
    color: inherit;
}

/* 確保圖片放大的容器不會破圖 */
.team-body {
    overflow: hidden;
    border-radius: 8px; /* 可選：讓圖片轉角圓滑點 */
}

/* 圖片初始狀態 */
.team-item img {
    transition: transform 0.5s ease; /* 控制縮放速度與平滑度 */
}

/* 當滑鼠懸停在 team-link 時，縮放內部的圖片 */
.team-link:hover .team-item img {
    transform: scale(1.1); /* 放大 1.1 倍 */
}

/* 可選：增加整體卡片的陰影或位移感 */
.team-item {
    transition: all 0.3s ease;
}

.team-link:hover .team-item {
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    transform: translateY(-5px); /* 輕微上浮 */
}

/* ========= Custom Cursor: Spaceship ========= */

/* 只在桌機隱藏原游標，避免手機版怪異 */
@media (hover: hover) and (pointer: fine) {
    body {
        cursor: none;
    }
}

/* 太空船本體 */
.cursor-ship {
    position: fixed;
    left: 0;
    top: 0;
    width: 40px;     /* 太空船寬度 */
    height: 40px;    /* 太空船高度 */
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.2s ease-out;}

/* 如果你有自己的太空船圖片（推薦） */
/* 把 img/spaceship.png 換成你的圖路徑 */
.cursor-ship {
    background-image: url("../img/cursor.png");
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

.cursor-boost {
    /*
    transform: translate(-50%, -50%) scale(1.5) rotate(15deg) !important;
    */
    filter: drop-shadow(0 0 15px var(--bs-primary)); /* 增加發光感模擬噴射火光 */
}

/* 針對所有按鈕類別加入按下狀態 */
.btn:active,
.project-item:active,
.nav-link:active {
    transform: scale(0.95) !important;
    transition: transform 0.1s ease; /* 縮放速度要快，才有打擊感 */
}

a,
button,
.btn,
.nav-link,
.team-item,
.project-item,
[role="button"] {
    cursor: none !important;
}

/* 如果你的作品卡片也有點擊功能，建議一併加入 */
.team-link:active .team-item {
    transform: scale(0.98);
}

/* 雲霧拖尾（粒子） */
.cursor-trail {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 10px;
    width: 26px;
    height: 26px;
    pointer-events: none;
    z-index: 9998;

    /* 關鍵：同時引用旋轉與縮放變數 */
    --trail-rot: 0deg;
    --trail-scale: 1;

    /* 初始狀態需包含 translate(-50%, -50%) */
    transform: translate(-50%, -50%) rotate(var(--trail-rot)) scale(var(--trail-scale));

    background-image: url("../img/smoke.PNG");
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;

    animation: cursor-trail-fade 0.6s ease-out forwards;
}

/* 確保動畫每一幀都保留這些變數，否則縮放會失效 */
@keyframes cursor-trail-fade {
    0% {
        opacity: 0.9;
        transform: translate(-50%, -50%) rotate(var(--trail-rot)) scale(var(--trail-scale));
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) rotate(var(--trail-rot)) scale(calc(var(--trail-scale) * 0.3));
    }
}

.margin-zero {
    margin: 0;
}

/* 確保父容器佔滿全螢幕 */
.hero-section, .carousel-item {
    height: 100vh;
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* 覆寫 Bootstrap 預設 caption 樣式 */
.carousel-caption {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0 !important; /* 移除 padding-top 避免內容下偏 */
    background: rgba(0, 0, 0, .3); /* 降低遮罩感 */
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center; /* 確保垂直水平絕對居中 */
    z-index: 2;
}

.carousel-caption p {
    font-size: 2.5vh; /* 字體大小隨高度縮放 */
    margin-top: 2vh;
    line-height: 1.5;
    text-align: center;
}

/* 針對 homeslide-1.png 所在的 img */
.carousel-item > img {
    width: 100%;
    height: 100vh;
    object-fit: cover; /* 確保背景圖完整覆蓋且不變形 */
}

.custom-filter {
    justify-content: center;      /* 置中對齊 */
}

@media (max-width: 576px) {
/* 1. 容器設定：強制不換行，且寬度剛好等於螢幕寬 */
.custom-filter {
    display: flex !important;
    flex-wrap: nowrap !important; /* 核心：禁止換行 */
    width: 100%;                  /* 寬度不超出父層 */
    padding: 0;
    margin: 0;
}

/* 2. 項目設定：允許內容隨比例縮小 */
.custom-filter .nav-item {
    flex: 1 1 auto;              /* 核心：允許縮小 (shrink) 並平分空間 */
    min-width: 0;                /* 允許項目縮小到小於內容寬度 */
    text-align: center;
    margin: 0 0.5vw !important;  /* 間距改用 vw，隨螢幕縮小而變窄 */
}

/* 3. 按鈕文字設定：隨比例縮放字體 */
.custom-filter .btn {
    width: 100%;                 /* 撐滿 nav-item */
    padding: 0.5vh 1vw !important; /* 內距隨比例縮放 */
    font-size: 1.8vw !important;  /* 核心：字體隨寬度縮放，確保不擠壓變形 */
    white-space: nowrap;          /* 避免按鈕內文字斷行 */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 針對極小螢幕（手機）的微調 */
    .custom-filter .btn {
        font-size: 3vw !important; /* 手機端字體稍微放大以維持可讀性 */
        padding: 5px 2px !important;
    }
}

/* 煙霧容器層 */
.smoke-wrap {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none; /* 確保不影響滑鼠點擊 */
    z-index: 1;
}

/* 煙霧粒子本體 */
.smoke-particle {
    position: absolute;
    bottom: -50px; /* 從螢幕下方外開始 */
    width: 60px;
    height: 60px;
    background-image: url('../img/smoke.PNG');
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0;
    animation: smokeRise 3s infinite linear;
}

/* 核心動畫：上升、飄移、縮放、淡出 */
@keyframes smokeRise {
    0% {
        transform: translateY(0) translateX(0) rotate(10rad) scale(0.5);
        opacity: 0;
    }
    1% {
        opacity: 1;
    }
    30%{
        transform: translateY(-60vh) translateX(0px)  rotate(5rad) scale(1.0)
    }
    45%{
        transform: translateY(-100vh) translateX(0px)  rotate(1rad) scale(1.5)
    }
    58%{
        transform: translateY(-80vh) translateX(0px) rotate(1.5rad) scale(1.4)
    }
    70%{
        transform: translateY(-60vh) translateX(0px) rotate(2.3rad) scale(1.0)
    }
    80%{
        transform: translateY(-30vh) translateX(0px) rotate(5rad) scale(0.8)
    }
    99% {
        opacity: 1;
    }
    100% {
        transform: translateY(20vh) translateX(0px) rotate(10rad) scale(0.5);
        opacity: 0;
    }
}

/* 隨機化：為每個粒子設定不同的位置與延遲，營造自然感 */
.smoke-particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 4s; }
.smoke-particle:nth-child(2) { left: 20%; animation-delay: 2s; animation-duration: 5s; }
.smoke-particle:nth-child(3) { left: 40%; animation-delay: 1s; animation-duration: 3.5s; }
.smoke-particle:nth-child(4) { left: 55%; animation-delay: 3s; animation-duration: 6s; }
.smoke-particle:nth-child(5) { left: 70%; animation-delay: 0.8s; animation-duration: 4.5s; }
.smoke-particle:nth-child(6) { left: 85%; animation-delay: 1.5s; animation-duration: 5.5s; }
.smoke-particle:nth-child(7) { left: 5%; animation-delay: 2.3s; animation-duration: 3s; }
.smoke-particle:nth-child(8) { left: 100%; animation-delay: 2.8s; animation-duration: 4s; }

.comic-bubble-dynamic {
    position: absolute;
    background: #fffb00;
    border: 4px solid #000;
    padding: 10px 18px;
    border-radius: 40px;
    box-shadow: 6px 6px 0px #000;
    z-index: 10;
    pointer-events: none;
    user-select: none;

    --bubble-rot: 0deg;

    /* 初始狀態：移除 translateX(-50%)，改用簡單的縮放旋轉 */
    transform: scale(0) rotate(var(--bubble-rot)) !important;
    opacity: 0 !important;

    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    opacity 0.4s ease;
    will-change: transform, opacity;
}

.comic-bubble-dynamic img {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(2px 2px 0px #000); /* 增加漫畫感 */
}

/* 出現後的狀態：必須保留 translate(-50%, 0) 並強制覆蓋初始狀態 */
.bubble-visible {
    transform: scale(1) rotate(var(--bubble-rot)) !important;
    opacity: 1 !important;
}

/* 消失的狀態 */
.bubble-fade-out {
    opacity: 0 !important;
    transform: scale(0.2) rotate(var(--bubble-rot)) translateY(-40px) !important;
}

.bubble-text-dynamic {
    color: #000;
    font-weight: 900;
    font-size: 1.1rem;
    white-space: nowrap;
}

.inspiration-core {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 20px auto;
    background: #333;
    border: 4px solid #fff;
    border-radius: 50%;
    cursor: none; /* 讓太空船游標顯示 */
    transition: transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    /*
    box-shadow: 0 0 20px var(--core-glow, #fff);
    */
}

.inspiration-core:active {
    transform: scale(0.9); /* 點擊縮放回饋 */
}

.core-inner {
    width: 60%;
    height: 60%;
    /*
    background: var(--core-color, #555);
    */
    border-radius: 50%;
    filter: blur(5px);
    transition: background 0.3s;
}

.click-hint {
    position: absolute;
    bottom: -30px;
    white-space: nowrap;
    font-weight: bold;
    color: #fffb00;
}

/* 全螢幕震動類別 (當過載時觸發) */
.screen-shake {
    animation: shake 0.2s infinite;
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    50% { transform: translate(-1px, -2px) rotate(-1deg); }
    100% { transform: translate(1px, 1px) rotate(0deg); }
}

/* 核心容器需要有相對定位，以便內部的 click-hint 定位 */
.inspiration-core {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto;
    background: #222;
    border: 5px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, box-shadow 0.3s;
    user-select: none;
}

/* 故障狀態：套用於 body */
.system-glitch {
    animation: glitch-mild-filter 3s infinite steps(2);
    position: relative;
    cursor: auto !important;
}

/* 產生隨機切片的色彩錯位層 */
.system-glitch::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    z-index: 9999;
    pointer-events: none; /* 關鍵：確保滑鼠可以穿透點擊下方內容 */
    opacity: 0.5;
    mix-blend-mode: difference;
    animation: glitch-slice 0.5s infinite steps(2);
}

/* 濾鏡故障動畫 */
@keyframes glitch-filter {
    0% { filter: contrast(120%) hue-rotate(0deg); }
    20% { filter: contrast(150%) hue-rotate(90deg) brightness(1.2); }
    40% { filter: contrast(200%) sepia(1) invert(1); }
    60% { filter: contrast(110%) hue-rotate(270deg); }
    80% { filter: contrast(150%) saturate(3); }
    100% { filter: contrast(120%) hue-rotate(360deg); }
}

/* 畫面切片位移動畫 */
@keyframes glitch-slice {
    0% { clip-path: inset(80% 0 0 0); transform: translateX(-10px); }
    20% { clip-path: inset(10% 0 70% 0); transform: translateX(10px); }
    40% { clip-path: inset(50% 0 30% 0); transform: translateX(-5px); }
    60% { clip-path: inset(30% 0 50% 0); transform: translateX(5px); }
    80% { clip-path: inset(0 0 80% 0); transform: translateX(-2px); }
    100% { clip-path: inset(80% 0 0 0); transform: translateX(0); }
}

/* 警告文字層 */
.glitch-warning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* 半透明黑，降低背景亮度 */
    z-index: 10005;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    text-align: center;
    font-family: 'Noto Sans TC', sans-serif;
}

.glitch-warning-text {
    color: #000000;
    font-size: 2.5rem;
    font-weight: 900;
    text-shadow: 3px 3px 0px #21ca0a;
    margin-bottom: 20px;
    animation: text-blink 0.5s infinite alternate;
}

/* 溫和一點的故障濾鏡 */
@keyframes glitch-mild-filter {
    0% { filter: contrast(110%) saturate(1.2); }
    33% { filter: contrast(125%) saturate(1.5) hue-rotate(10deg); }
    66% { filter: contrast(115%) brightness(1.1) hue-rotate(-10deg); }
    100% { filter: contrast(110%) saturate(1.2); }
}

/* 警告文字閃爍 */
@keyframes text-blink {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0.8; transform: scale(1.05); }
}

/* 畫面切片保持，但降低頻率與位移量 */
.system-glitch::after {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10004;
    pointer-events: none;
    opacity: 0.2; /* 降低蓋板透明度 */
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.05), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.05));
    background-size: 100% 2px, 3px 100%;
    animation: glitch-slice-mild 1s infinite steps(4);
}

@keyframes glitch-slice-mild {
    0% { clip-path: inset(10% 0 80% 0); transform: translateX(-2px); }
    50% { clip-path: inset(60% 0 20% 0); transform: translateX(2px); }
    100% { clip-path: inset(30% 0 50% 0); transform: translateX(0); }
}

/* 鎖定在螢幕玻璃上的警告層 */
.glitch-overlay-mask {
    /* 強制固定在視窗，不隨捲動移動 */
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;

    /* 視覺設定 */
    width: 90vw;
    max-width: 500px;
    min-height: 250px;
    background: rgba(0, 0, 0, 0.95);
    border: 5px solid #fffb00;
    box-shadow: 0 0 50px rgba(255, 251, 0, 0.6);
    border-radius: 20px;

    /* 層級與互動 */
    z-index: 999999 !important; /* 絕對最高層級 */
    pointer-events: none;      /* 讓滑鼠點擊與捲動穿透到下方網頁 */

    /* 內容排版 */
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;

    /* 故障抖動動畫 */
    animation: viewport-glitch 0.2s infinite;
}

/* 警告文字 */
.glitch-warning-text {
    color: #ffffff;
    font-size: 2rem;
    font-weight: 900;
    line-height: 1.5;
    text-shadow: 4px 4px 0px #e82121;
    font-family: 'Noto Sans TC', sans-serif;
    margin: 0;
}

/* 視窗抖動動畫 (僅針對警告框) */
@keyframes viewport-glitch {
    0% { transform: translate(-50%, -50%) skew(0deg); }
    25% { transform: translate(-51%, -49%) skew(1deg); }
    50% { transform: translate(-49%, -50%) skew(-1deg); }
    75% { transform: translate(-50%, -51%) skew(0deg); }
    100% { transform: translate(-50%, -50%) skew(0deg); }
}

/* --- 1. 全螢幕故障遮罩層 (濾鏡與切片都在這層) --- */
.global-glitch-overlay {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    z-index: 99998; /* 低於警告框 */
    pointer-events: none;

    /* 這裡跑你最喜歡的色彩故障動畫 */
    animation: glitch-filter-global 2s infinite steps(1);
}

/* 產生隨機切片 (利用偽元素) */
.global-glitch-overlay::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: inherit;
    backdrop-filter: contrast(150%); /* 增加對底層的干擾 */
    mix-blend-mode: difference;
    animation: glitch-slice-global 0.5s infinite steps(2);
}

/* 警告框：獨立定位，不受 body 濾鏡影響 */
.glitch-overlay-mask {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90vw;
    max-width: 500px;
    background: rgba(0, 0, 0, 0.95);
    border: 5px solid #53ff00;
    box-shadow: 0 0 50px rgba(133, 255, 53, 0.6);
    border-radius: 20px;
    z-index: 999999 !important; /* 最高層級 */
    pointer-events: none;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    animation: mask-vibration-fixed 0.1s infinite;
}

/* --- 動畫定義 --- */
@keyframes glitch-filter-global {
    0% { backdrop-filter: contrast(120%) hue-rotate(0deg); }
    20% { backdrop-filter: contrast(150%) hue-rotate(90deg) brightness(1.2); }
    40% { backdrop-filter: contrast(200%) sepia(1) invert(1); }
    60% { backdrop-filter: contrast(110%) hue-rotate(270deg); }
    80% { backdrop-filter: contrast(150%) saturate(3); }
    100% { backdrop-filter: contrast(120%) hue-rotate(360deg); }
}

@keyframes glitch-slice-global {
    0% { clip-path: inset(80% 0 0 0); transform: translateX(-15px); }
    50% { clip-path: inset(10% 0 70% 0); transform: translateX(15px); }
    100% { clip-path: inset(40% 0 40% 0); transform: translateX(0); }
}

@keyframes mask-vibration-fixed {
    0%, 100% { transform: translate(-50%, -50%); }
    50% { transform: translate(-50.5%, -49.5%) rotate(0.5deg); }
}

/* 核心內部的發光體 */
.core-inner {
    width: 70%;
    height: 70%;
    /* 確保使用了 JS 傳入的變數 */
    /*
    background-color: var(--core-color, #555);
    */
    border-radius: 50%;
    filter: blur(4px);
    transition: background-color 0.3s ease;
}

/* 全域故障層：必須透明，否則會遮住按鈕顏色 */
.global-glitch-overlay {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent !important; /* 必須透明 */
    z-index: 99998;
    pointer-events: none;
    animation: glitch-filter-global 2s infinite steps(1);
}

/* 過載後的按鈕動畫 (可選) */
@keyframes core-burnt {
    0% { filter: brightness(1) sepia(1) hue-rotate(-50deg); }
    100% { filter: brightness(0.5) grayscale(1); }
}

@media (max-width: 576px) {
    .btn {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        font-size: 0.9rem;
    }
}