/* --- 基礎設定 --- */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background-color: #111;
    font-family: 'Roboto', sans-serif;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    color: white;
    width: 100vw;
    height: 100dvh;
}

/* --- [修復] 預加載畫面樣式 --- */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: #000;
    z-index: 9999;
    /* 最高層級，蓋住一切 */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.loading-content {
    text-align: center;
    width: 80%;
    max-width: 400px;
}

.loading-text {
    font-family: 'Black Ops One';
    color: #ffcc00;
    font-size: 24px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px orange;
}

.progress-bar-bg {
    width: 100%;
    height: 20px;
    background: #333;
    border: 2px solid #555;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}

#progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #c0392b, #e74c3c);
    transition: width 0.2s linear;
}

/* --- 通用按鈕 --- */
.btn-action {
    display: flex;
    justify-content: center;
    align-items: center;
    width: auto;
    min-width: 180px;
    padding: 12px 24px;
    margin: 10px auto;
    font-size: 20px;
    font-family: 'Black Ops One';
    background: #c0392b;
    color: white;
    border: 2px solid #ffcc00;
    transform: skewX(-10deg);
    cursor: pointer;
    box-shadow: 0 0 15px #c0392b;
    transition: all 0.1s;
    text-transform: uppercase;
    position: relative;
    z-index: 100;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn-action:active {
    transform: skewX(-10deg) scale(0.95);
    background: #fff;
    color: #c0392b;
}

.btn-blue {
    background: #2980b9;
    box-shadow: 0 0 15px #2980b9;
}

.btn-green {
    background: #27ae60;
    box-shadow: 0 0 15px #27ae60;
}

.difficulty-group {
    display: flex;
    justify-content: center;
    gap: 5px;
    width: 95%;
    max-width: 400px;
    margin: 10px auto 20px auto;
    flex-shrink: 0;
}

.btn-diff {
    padding: 12px 0;
    font-size: 14px;
    font-family: 'Black Ops One';
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #555;
    color: #aaa;
    transform: skewX(-10deg);
    flex: 1;
    text-align: center;
    cursor: pointer;
    position: relative;
}

.btn-diff.selected {
    background: #c0392b;
    color: white;
    border-color: #ffcc00;
    opacity: 1;
    filter: grayscale(0);
    transform: skewX(-10deg) scale(1.05);
    box-shadow: 0 0 10px #c0392b;
    z-index: 2;
}

.btn-diff.locked {
    opacity: 0.3;
    filter: grayscale(1);
    cursor: not-allowed;
    pointer-events: none;
}

.btn-diff.locked::after {
    content: "🔒";
    position: absolute;
    top: -8px;
    right: -5px;
    font-size: 14px;
    text-shadow: 0 0 3px black;
}

/* --- App Layout --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: radial-gradient(circle at center, #222 0%, #000 90%);
    z-index: 200;
}

.screen.active {
    display: flex;
}

.screen-header {
    flex-shrink: 0;
    width: 100%;
    text-align: center;
    padding-top: 60px;
    padding-bottom: 10px;
    background: linear-gradient(to bottom, #000 0%, transparent 100%);
    z-index: 10;
}

.menu-title {
    font-family: 'Black Ops One';
    font-size: 40px;
    color: #ffcc00;
    text-shadow: 0 0 20px orange;
    margin: 0;
}

.screen-content {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.screen-footer {
    flex-shrink: 0;
    width: 100%;
    padding: 20px env(safe-area-inset-right) calc(20px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 60%, transparent);
    display: flex;
    justify-content: center;
    z-index: 20;
}

/* --- UI 元件 --- */
.coin-display {
    position: fixed;
    top: 15px;
    right: 15px;
    font-family: 'Black Ops One';
    font-size: 20px;
    color: #ffd700;
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 15px;
    border: 2px solid #ffd700;
    border-radius: 10px;
    z-index: 1000;
}

/* 商店 */
.card-pack {
    width: 220px;
    height: 300px;
    background: linear-gradient(135deg, #1a1a1a 0%, #444 100%);
    border: 5px solid #ffd700;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    transition: transform 0.1s;
    margin: auto;
}

.card-pack:active {
    transform: scale(0.95);
}

.pack-label {
    font-family: 'Black Ops One';
    font-size: 28px;
    color: #ffd700;
    text-align: center;
}

.pack-price {
    font-size: 20px;
    color: white;
    margin-top: 10px;
    font-weight: bold;
    font-family: 'Black Ops One';
}

/* 抽卡結果 */
#gacha-result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    z-index: 2000;
    display: none;
    flex-direction: column;
    padding-top: 60px;
    padding-bottom: env(safe-area-inset-bottom);
}

.gacha-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    width: 95%;
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 20px;
}

/* 卡牌 */
.card-container {
    width: 100%;
    aspect-ratio: 5/7;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
}

.card-container.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid #555;
    background: #333;
    overflow: hidden;
}

.card-back {
    background: linear-gradient(135deg, #222 0%, #000 100%);
    color: #333;
    font-family: 'Black Ops One';
    font-size: 24px;
    border: 2px solid #444;
}

.card-back::after {
    content: "?";
    color: #444;
}

.card-front {
    transform: rotateY(180deg);
    overflow: visible;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    position: relative;
    z-index: 1;
}

.card-info {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 2px 0;
    z-index: 2;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

/* 稀有度特效 */
.rarity-SR .card-front {
    box-shadow: 0 0 15px #9b59b6;
    border: 2px solid #9b59b6;
    animation: shake-glow 2s infinite;
}

.rarity-SSR .card-front {
    box-shadow: 0 0 25px #e74c3c;
    border: 2px solid #e74c3c;
    animation: pulse-red 0.5s infinite alternate;
}

.rarity-UR .card-front {
    box-shadow: 0 0 50px #f1c40f, inset 0 0 20px #f1c40f;
    border: 3px solid #fff;
    animation: ur-rainbow 1s infinite linear;
    z-index: 100;
}

.rarity-UR .card-front::after {
    content: '';
    position: absolute;
    top: -100%;
    left: -100%;
    width: 300%;
    height: 300%;
    background: repeating-conic-gradient(from 0deg, rgba(255, 215, 0, 0.2) 0deg, transparent 20deg, rgba(255, 215, 0, 0.2) 40deg);
    animation: spin 10s linear infinite;
    pointer-events: none;
    z-index: -2;
}

/* 收藏冊 */
#collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    width: 90%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 20px;
    touch-action: pan-y;
}

.collection-card {
    width: 100%;
    aspect-ratio: 5/7;
    background: #333;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    border: 2px solid #555;
    transition: transform 0.1s;
}

.collection-card:active {
    transform: scale(0.95);
}

.collection-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: relative;
    z-index: 2;
}

.card-count {
    position: absolute;
    top: 5px;
    right: 5px;
    background: red;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    z-index: 5;
}

.unowned {
    filter: grayscale(100%) brightness(0.3);
    opacity: 0.6;
}

/* 同步收藏冊特效 */
.collection-card.rarity-UR::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, #ff0000, #ff7300, #ffff00, #00ff00, #0000ff, #8b00ff, #ff0000);
    animation: spin 4s linear infinite;
    z-index: 0;
    opacity: 0.5;
}

.collection-card.rarity-SR {
    box-shadow: 0 0 10px #9b59b6;
    border: 2px solid #9b59b6;
}

.collection-card.rarity-SSR {
    box-shadow: 0 0 15px #e74c3c;
    border: 2px solid #e74c3c;
}

.collection-card.rarity-UR {
    box-shadow: 0 0 20px #f1c40f;
    border: 2px solid #fff;
}

/* 卡牌詳情 */
#card-detail-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: popIn 0.4s forwards;
    pointer-events: auto;
}

.detail-card {
    width: 260px;
    height: 364px;
    border-radius: 15px;
    position: relative;
    overflow: visible;
    background: #333;
    margin-bottom: 20px;
    border: 3px solid #fff;
}

.detail-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

.detail-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-family: 'Black Ops One';
    font-size: 24px;
    text-align: center;
    padding: 10px 0;
    z-index: 3;
}

/* 詳情特效 */
.detail-rarity-UR::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -90%;
    width: 280%;
    height: 200%;
    background: conic-gradient(from 0deg, #ff0000, #ff7300, #ffff00, #00ff00, #0000ff, #8b00ff, #ff0000);
    animation: spin 4s linear infinite;
    z-index: 0;
    opacity: 0.6;
    border-radius: 50%;
    filter: blur(100px);
}

.detail-rarity-SR {
    box-shadow: 0 0 40px #9b59b6;
    border: 4px solid #9b59b6;
}

.detail-rarity-SSR {
    box-shadow: 0 0 60px #e74c3c;
    border: 4px solid #e74c3c;
}

.detail-rarity-UR {
    box-shadow: 0 0 80px #f1c40f;
    border: 4px solid #fff;
}

/* 彈窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
    touch-action: auto;
}

.modal-box {
    width: 85%;
    max-width: 500px;
    background: linear-gradient(135deg, #222 0%, #111 100%);
    border: 3px solid #ffcc00;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 0 30px rgba(255, 204, 0, 0.3);
    text-align: center;
    transform: scale(0.8);
    animation: popIn 0.3s forwards;
    max-height: 80dvh;
    overflow-y: auto;
}

.modal-title {
    font-family: 'Black Ops One';
    color: #ffcc00;
    font-size: 32px;
    margin: 0 0 20px 0;
}

.modal-content {
    font-size: 16px;
    color: #ddd;
    line-height: 1.5;
    margin-bottom: 30px;
    white-space: pre-line;
}

/* 戰鬥畫面 */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: radial-gradient(circle at center, #444 0%, #111 80%);
    overflow: hidden;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: crosshair;
    z-index: 100;
    touch-action: none;
}

#game-container.active {
    display: flex;
}

/* 戰鬥特效 */
.scene-3d {
    position: absolute;
    width: 100%;
    height: 100%;
    perspective: 800px;
    z-index: 1;
}

.floor {
    position: absolute;
    bottom: -20%;
    left: -50%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 100px 100px;
    background-color: #222;
    transform: rotateX(70deg);
    box-shadow: 0 0 100px #000 inset;
}

.ropes {
    position: absolute;
    bottom: 30%;
    width: 120%;
    left: -10%;
    height: 150px;
    border-top: 8px solid #c0392b;
    border-bottom: 8px solid #c0392b;
    transform: rotateX(10deg);
    z-index: 2;
    pointer-events: none;
    filter: drop-shadow(0 0 5px black);
}

.speed-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-conic-gradient(from 0deg, transparent 0deg, transparent 10deg, rgba(255, 255, 255, 0.1) 10deg, rgba(255, 255, 255, 0.05) 20deg);
    opacity: 0;
    pointer-events: none;
    z-index: 90;
    mix-blend-mode: overlay;
    transition: opacity 0.1s;
}

#hud-header {
    position: absolute;
    top: 0;
    width: 100%;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40px;
    z-index: 100;
    font-family: 'Black Ops One', cursive;
    pointer-events: none;
}

.timer-box {
    position: absolute;
    top: 20px;
    background: #000;
    color: #fff;
    padding: 5px 20px;
    font-size: 36px;
    border: 2px solid #555;
    transform: skewX(-15deg);
    z-index: 102;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.timer-box span {
    display: block;
    transform: skewX(15deg);
}

.bars-wrapper {
    width: 95%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    top: 30px;
}

.stats-block {
    width: 35%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transform: skewX(-20deg);
}

.hp-container {
    width: 100%;
    height: 25px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #fff;
    position: relative;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    width: 100%;
    transform-origin: left;
    transform: scaleX(1);
    transition: transform 0.2s ease-out;
    will-change: transform;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.5);
}

.stamina-container {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #888;
    position: relative;
    overflow: hidden;
    margin-top: 2px;
}

.stamina-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ffd700, #ffaa00);
    box-shadow: inset 0 0 5px rgba(255, 255, 0, 0.5);
    transition: width 0.1s linear;
}

.stamina-counter-ready {
    background: linear-gradient(90deg, #00ffff, #0088ff) !important;
    box-shadow: 0 0 10px #00ffff !important;
}

.stamina-low {
    animation: blinkRed 0.2s 2;
}

#p-hp {
    background: linear-gradient(90deg, #00d2ff, #3a7bd5);
}

#e-hp {
    background: linear-gradient(90deg, #f85032, #e73827);
}

.name-tag {
    position: absolute;
    top: -25px;
    font-size: 16px;
    color: white;
    text-shadow: 2px 2px 0 #000;
    font-style: italic;
    width: 100%;
}

.p-name {
    left: 0;
    color: #00d2ff;
}

.e-name {
    right: 0;
    color: #e73827;
    text-align: right;
}

#enemy-layer {
    position: absolute;
    bottom: 0%;
    width: 100%;
    max-width: 500px;
    height: auto;
    z-index: 10;
    transition: transform 0.1s ease-out;
}

#enemy-img {
    width: 100%;
    height: auto;
    display: block;
    position: relative;
    animation: idleSway 2s infinite ease-in-out alternate;
    filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)) sepia(0) hue-rotate(0deg) saturate(1) brightness(0.9) contrast(1.1);
    transition: filter 0.2s linear;
}

.enemy-charging {
    filter: drop-shadow(0 0 50px #ff0000) sepia(1) hue-rotate(-50deg) saturate(5) brightness(1) contrast(1) !important;
}

.boss-berserk {
    filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)) sepia(1) hue-rotate(220deg) saturate(3) brightness(0.7) contrast(1.3) !important;
}

.boss-berserk.enemy-charging {
    filter: drop-shadow(0 0 80px #ff0000) sepia(1) hue-rotate(-50deg) saturate(6) brightness(1.2) contrast(1.3) !important;
}

.fist {
    position: absolute;
    bottom: -80px;
    width: 250px;
    height: 250px;
    background-image: url('https://cdn-icons-png.flaticon.com/512/11648/11648347.png');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 50;
    pointer-events: none;
    transform-origin: center bottom;
}

#fist-l {
    left: 0;
    transform: rotate(-10deg);
}

#fist-r {
    right: 0;
    transform: rotate(10deg) scaleX(-1);
}

.fist-crit {
    filter: drop-shadow(0 0 20px cyan);
}

.punch-l {
    animation: punchLeft 0.15s forwards;
}

.punch-r {
    animation: punchRight 0.15s forwards;
}

@keyframes punchLeft {
    0% {
        transform: rotate(-10deg) translate(0, 0) scale(1);
    }

    50% {
        transform: rotate(20deg) translate(80px, -150px) scale(1.3);
    }

    100% {
        transform: rotate(-10deg) translate(0, 0) scale(1);
    }
}

@keyframes punchRight {
    0% {
        transform: scaleX(-1) rotate(10deg) translate(0, 0) scale(1);
    }

    50% {
        transform: scaleX(-1) rotate(20deg) translate(80px, -150px) scale(1.3);
    }

    100% {
        transform: scaleX(-1) rotate(10deg) translate(0, 0) scale(1);
    }
}

.dmg-num {
    position: absolute;
    font-family: 'Black Ops One', cursive;
    font-size: 50px;
    color: #ffeb3b;
    text-shadow: 3px 3px 0 #000;
    pointer-events: none;
    z-index: 400;
    animation: popUp 0.8s forwards;
}

.crit-text {
    position: absolute;
    font-family: 'Black Ops One', cursive;
    font-size: 60px;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff, 3px 3px 0 #000;
    pointer-events: none;
    z-index: 410;
    animation: popUpCrit 0.8s forwards;
}

.crit-dmg-num {
    position: absolute;
    font-family: 'Black Ops One', cursive;
    font-size: 100px;
    color: #ffffff;
    text-shadow: 0 0 15px #ff0000, 5px 5px 0 #000;
    pointer-events: none;
    z-index: 420;
    animation: popUpCritDmg 0.8s forwards;
}

.miss-text {
    position: absolute;
    font-family: 'Black Ops One', cursive;
    font-size: 40px;
    color: #00d2ff;
    font-style: italic;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    z-index: 400;
    animation: fadeUp 0.5s forwards;
}

.block-text {
    position: absolute;
    font-family: 'Black Ops One', cursive;
    font-size: 40px;
    color: #aaaaff;
    font-style: italic;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    z-index: 400;
    animation: fadeUp 0.5s forwards;
}

#red-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: red;
    opacity: 0;
    pointer-events: none;
    z-index: 95;
    mix-blend-mode: multiply;
    transition: opacity 0.1s;
}

#dodge-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 100px #00d2ff;
    opacity: 0;
    pointer-events: none;
    z-index: 96;
    mix-blend-mode: screen;
    transition: opacity 0.1s;
}

#block-shield {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 80%, rgba(0, 100, 255, 0.3) 0%, transparent 60%);
    opacity: 0;
    pointer-events: none;
    z-index: 80;
    transition: opacity 0.1s;
    border-bottom: 10px solid rgba(0, 100, 255, 0.5);
}

.shield-active {
    opacity: 1 !important;
}

#mobile-controls {
    display: none;
    position: absolute;
    bottom: 30px;
    width: 100%;
    justify-content: space-between;
    padding: 0 30px;
    box-sizing: border-box;
    z-index: 150;
    pointer-events: none;
}

.control-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    font-family: 'Black Ops One';
    font-size: 16px;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    backdrop-filter: blur(2px);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    text-align: center;
}

#btn-block {
    border-color: #00d2ff;
    color: #00d2ff;
}

#btn-dodge {
    border-color: #ffd700;
    color: #ffd700;
}

#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    color: #fff;
}

#result-text {
    font-size: 50px;
    font-family: 'Black Ops One';
    text-shadow: 0 0 20px currentColor;
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 20px;
    font-family: 'Roboto', sans-serif;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border: 1px solid #555;
    width: 90%;
    max-width: 400px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #ddd;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-val {
    color: #00d2ff;
    font-weight: bold;
    font-family: 'Black Ops One';
}

.final-score {
    font-size: 36px;
    color: #00ff00;
    font-family: 'Black Ops One';
    margin-top: 5px;
    text-shadow: 0 0 15px #00ff00;
}

.rank-badge {
    font-size: 60px;
    font-family: 'Black Ops One';
    color: #ffd700;
    text-shadow: 0 0 30px orange;
    position: absolute;
    right: 5%;
    top: 10%;
    transform: rotate(15deg);
    border: 3px solid #fff;
    padding: 0 10px;
    background: rgba(0, 0, 0, 0.5);
}

#progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #c0392b, #e74c3c);
    transition: width 0.2s linear;
}

/* --- 通用按鈕 --- */
.btn-action {
    display: flex;
    justify-content: center;
    align-items: center;
    width: auto;
    min-width: 180px;
    padding: 12px 24px;
    margin: 10px auto;
    font-size: 20px;
    font-family: 'Black Ops One';
    background: #c0392b;
    color: white;
    border: 2px solid #ffcc00;
    transform: skewX(-10deg);
    cursor: pointer;
    box-shadow: 0 0 15px #c0392b;
    transition: all 0.1s;
    text-transform: uppercase;
    position: relative;
    z-index: 100;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn-action:active {
    transform: skewX(-10deg) scale(0.95);
    background: #fff;
    color: #c0392b;
}

.btn-blue {
    background: #2980b9;
    box-shadow: 0 0 15px #2980b9;
}

.btn-green {
    background: #27ae60;
    box-shadow: 0 0 15px #27ae60;
}

.difficulty-group {
    display: flex;
    justify-content: center;
    gap: 5px;
    width: 95%;
    max-width: 400px;
    margin: 10px auto 20px auto;
    flex-shrink: 0;
}

.btn-diff {
    padding: 12px 0;
    font-size: 14px;
    font-family: 'Black Ops One';
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #555;
    color: #aaa;
    transform: skewX(-10deg);
    flex: 1;
    text-align: center;
    cursor: pointer;
    position: relative;
}

.btn-diff.selected {
    background: #c0392b;
    color: white;
    border-color: #ffcc00;
    opacity: 1;
    filter: grayscale(0);
    transform: skewX(-10deg) scale(1.05);
    box-shadow: 0 0 10px #c0392b;
    z-index: 2;
}

.btn-diff.locked {
    opacity: 0.3;
    filter: grayscale(1);
    cursor: not-allowed;
    pointer-events: none;
}

.btn-diff.locked::after {
    content: "🔒";
    position: absolute;
    top: -8px;
    right: -5px;
    font-size: 14px;
    text-shadow: 0 0 3px black;
}

/* --- App Layout --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    background: radial-gradient(circle at center, #222 0%, #000 90%);
    z-index: 200;
}

.screen.active {
    display: flex;
}

.screen-header {
    flex-shrink: 0;
    width: 100%;
    text-align: center;
    padding-top: 60px;
    padding-bottom: 10px;
    background: linear-gradient(to bottom, #000 0%, transparent 100%);
    z-index: 10;
}

.menu-title {
    font-family: 'Black Ops One';
    font-size: 40px;
    color: #ffcc00;
    text-shadow: 0 0 20px orange;
    margin: 0;
}

.screen-content {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.screen-footer {
    flex-shrink: 0;
    width: 100%;
    padding: 20px 0 calc(20px + env(safe-area-inset-bottom)) 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 60%, transparent);
    display: flex;
    justify-content: center;
    z-index: 20;
}

/* --- UI 元件 --- */
.coin-display {
    position: fixed;
    top: 15px;
    right: 15px;
    font-family: 'Black Ops One';
    font-size: 20px;
    color: #ffd700;
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 15px;
    border: 2px solid #ffd700;
    border-radius: 10px;
    z-index: 1000;
}

/* 商店 */
.card-pack {
    width: 220px;
    height: 300px;
    background: linear-gradient(135deg, #1a1a1a 0%, #444 100%);
    border: 5px solid #ffd700;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
    transition: transform 0.1s;
    margin: auto;
}

.card-pack:active {
    transform: scale(0.95);
}

.pack-label {
    font-family: 'Black Ops One';
    font-size: 28px;
    color: #ffd700;
    text-align: center;
}

.pack-price {
    font-size: 20px;
    color: white;
    margin-top: 10px;
    font-weight: bold;
    font-family: 'Black Ops One';
}

/* 抽卡結果 */
#gacha-result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.98);
    z-index: 2000;
    display: none;
    flex-direction: column;
    padding-top: 60px;
    padding-bottom: env(safe-area-inset-bottom);
}

.gacha-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    width: 95%;
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 20px;
}

/* 卡牌 */
.card-container {
    width: 100%;
    aspect-ratio: 5/7;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
}

.card-container.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid #555;
    background: #333;
    overflow: hidden;
}

.card-back {
    background: linear-gradient(135deg, #222 0%, #000 100%);
    color: #333;
    font-family: 'Black Ops One';
    font-size: 24px;
    border: 2px solid #444;
}

.card-back::after {
    content: "?";
    color: #444;
}

.card-front {
    transform: rotateY(180deg);
    overflow: visible;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    position: relative;
    z-index: 1;
}

.card-info {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 10px;
    text-align: center;
    padding: 2px 0;
    z-index: 2;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
}

/* 稀有度特效 */
.rarity-SR .card-front {
    box-shadow: 0 0 15px #9b59b6;
    border: 2px solid #9b59b6;
    animation: shake-glow 2s infinite;
}

.rarity-SSR .card-front {
    box-shadow: 0 0 25px #e74c3c;
    border: 2px solid #e74c3c;
    animation: pulse-red 0.5s infinite alternate;
}

.rarity-UR .card-front {
    box-shadow: 0 0 50px #f1c40f, inset 0 0 20px #f1c40f;
    border: 3px solid #fff;
    animation: ur-rainbow 1s infinite linear;
    z-index: 100;
}

.rarity-UR .card-front::after {
    content: '';
    position: absolute;
    top: -100%;
    left: -100%;
    width: 300%;
    height: 300%;
    background: repeating-conic-gradient(from 0deg, rgba(255, 215, 0, 0.2) 0deg, transparent 20deg, rgba(255, 215, 0, 0.2) 40deg);
    animation: spin 10s linear infinite;
    pointer-events: none;
    z-index: -2;
}

/* 收藏冊 */
#collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
    width: 90%;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-bottom: 20px;
    touch-action: pan-y;
}

.collection-card {
    width: 100%;
    aspect-ratio: 5/7;
    background: #333;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    border: 2px solid #555;
    transition: transform 0.1s;
}

.collection-card:active {
    transform: scale(0.95);
}

.collection-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: relative;
    z-index: 2;
}

.card-count {
    position: absolute;
    top: 5px;
    right: 5px;
    background: red;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    z-index: 5;
}

.unowned {
    filter: grayscale(100%) brightness(0.3);
    opacity: 0.6;
}

/* 同步收藏冊特效 */
.collection-card.rarity-UR::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, #ff0000, #ff7300, #ffff00, #00ff00, #0000ff, #8b00ff, #ff0000);
    animation: spin 4s linear infinite;
    z-index: 0;
    opacity: 0.5;
}

.collection-card.rarity-SR {
    box-shadow: 0 0 10px #9b59b6;
    border: 2px solid #9b59b6;
}

.collection-card.rarity-SSR {
    box-shadow: 0 0 15px #e74c3c;
    border: 2px solid #e74c3c;
}

.collection-card.rarity-UR {
    box-shadow: 0 0 20px #f1c40f;
    border: 2px solid #fff;
}

/* 卡牌詳情 */
#card-detail-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: popIn 0.4s forwards;
    pointer-events: auto;
}

.detail-card {
    width: 260px;
    height: 364px;
    border-radius: 15px;
    position: relative;
    overflow: visible;
    background: #333;
    margin-bottom: 20px;
    border: 3px solid #fff;
}

.detail-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

.detail-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-family: 'Black Ops One';
    font-size: 24px;
    text-align: center;
    padding: 10px 0;
    z-index: 3;
}

/* 詳情特效 */
.detail-rarity-UR::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -90%;
    width: 280%;
    height: 200%;
    background: conic-gradient(from 0deg, #ff0000, #ff7300, #ffff00, #00ff00, #0000ff, #8b00ff, #ff0000);
    animation: spin 4s linear infinite;
    z-index: 0;
    opacity: 0.6;
    border-radius: 50%;
    filter: blur(100px);
}

.detail-rarity-SR {
    box-shadow: 0 0 40px #9b59b6;
    border: 4px solid #9b59b6;
}

.detail-rarity-SSR {
    box-shadow: 0 0 60px #e74c3c;
    border: 4px solid #e74c3c;
}

.detail-rarity-UR {
    box-shadow: 0 0 80px #f1c40f;
    border: 4px solid #fff;
}

/* 彈窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: none;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease-out;
    touch-action: auto;
}

.modal-box {
    width: 85%;
    max-width: 500px;
    background: linear-gradient(135deg, #222 0%, #111 100%);
    border: 3px solid #ffcc00;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 0 30px rgba(255, 204, 0, 0.3);
    text-align: center;
    transform: scale(0.8);
    animation: popIn 0.3s forwards;
    max-height: 80dvh;
    overflow-y: auto;
}

.modal-title {
    font-family: 'Black Ops One';
    color: #ffcc00;
    font-size: 32px;
    margin: 0 0 20px 0;
}

.modal-content {
    font-size: 16px;
    color: #ddd;
    line-height: 1.5;
    margin-bottom: 30px;
    white-space: pre-line;
}

/* 戰鬥畫面 */
#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: radial-gradient(circle at center, #444 0%, #111 80%);
    overflow: hidden;
    display: none;
    justify-content: center;
    align-items: center;
    cursor: crosshair;
    z-index: 100;
    touch-action: none;
}

#game-container.active {
    display: flex;
}

/* 戰鬥特效 */
.scene-3d {
    position: absolute;
    width: 100%;
    height: 100%;
    perspective: 800px;
    z-index: 1;
}

.floor {
    position: absolute;
    bottom: -20%;
    left: -50%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px), linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 100px 100px;
    background-color: #222;
    transform: rotateX(70deg);
    box-shadow: 0 0 100px #000 inset;
}

.ropes {
    position: absolute;
    bottom: 30%;
    width: 120%;
    left: -10%;
    height: 150px;
    border-top: 8px solid #c0392b;
    border-bottom: 8px solid #c0392b;
    transform: rotateX(10deg);
    z-index: 2;
    pointer-events: none;
    filter: drop-shadow(0 0 5px black);
}

.speed-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-conic-gradient(from 0deg, transparent 0deg, transparent 10deg, rgba(255, 255, 255, 0.1) 10deg, rgba(255, 255, 255, 0.05) 20deg);
    opacity: 0;
    pointer-events: none;
    z-index: 90;
    mix-blend-mode: overlay;
    transition: opacity 0.1s;
}

#hud-header {
    position: absolute;
    top: 0;
    width: 100%;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 40px;
    z-index: 100;
    font-family: 'Black Ops One', cursive;
    pointer-events: none;
}

.timer-box {
    position: absolute;
    top: 20px;
    background: #000;
    color: #fff;
    padding: 5px 20px;
    font-size: 36px;
    border: 2px solid #555;
    transform: skewX(-15deg);
    z-index: 102;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.timer-box span {
    display: block;
    transform: skewX(15deg);
}

.bars-wrapper {
    width: 95%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    top: 30px;
}

.stats-block {
    width: 35%;
    display: flex;
    flex-direction: column;
    gap: 5px;
    transform: skewX(-20deg);
}

.hp-container {
    width: 100%;
    height: 25px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #fff;
    position: relative;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    width: 100%;
    transition: width 0.2s ease-out;
    box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.5);
}

.stamina-container {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #888;
    position: relative;
    overflow: hidden;
    margin-top: 2px;
}

.stamina-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ffd700, #ffaa00);
    box-shadow: inset 0 0 5px rgba(255, 255, 0, 0.5);
    transition: width 0.1s linear;
}

.stamina-counter-ready {
    background: linear-gradient(90deg, #00ffff, #0088ff) !important;
    box-shadow: 0 0 10px #00ffff !important;
}

.stamina-low {
    animation: blinkRed 0.2s 2;
}

#p-hp {
    background: linear-gradient(90deg, #00d2ff, #3a7bd5);
}

#e-hp {
    background: linear-gradient(90deg, #f85032, #e73827);
}

.name-tag {
    position: absolute;
    top: -25px;
    font-size: 16px;
    color: white;
    text-shadow: 2px 2px 0 #000;
    font-style: italic;
    width: 100%;
}

.p-name {
    left: 0;
    color: #00d2ff;
}

.e-name {
    right: 0;
    color: #e73827;
    text-align: right;
}

#enemy-layer {
    position: absolute;
    bottom: 0%;
    width: 100%;
    max-width: 500px;
    height: auto;
    z-index: 10;
    transition: transform 0.1s ease-out;
}

#enemy-img {
    width: 100%;
    height: auto;
    display: block;
    position: relative;
    animation: idleSway 2s infinite ease-in-out alternate;
    filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)) sepia(0) hue-rotate(0deg) saturate(1) brightness(0.9) contrast(1.1);
    transition: filter 0.2s linear;
}

.enemy-charging {
    filter: drop-shadow(0 0 50px #ff0000) sepia(1) hue-rotate(-50deg) saturate(5) brightness(1) contrast(1) !important;
}

.boss-berserk {
    filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0)) sepia(1) hue-rotate(220deg) saturate(3) brightness(0.7) contrast(1.3) !important;
}

.boss-berserk.enemy-charging {
    filter: drop-shadow(0 0 80px #ff0000) sepia(1) hue-rotate(-50deg) saturate(6) brightness(1.2) contrast(1.3) !important;
}

.fist {
    position: absolute;
    bottom: -80px;
    width: 250px;
    height: 250px;
    background-image: url('https://cdn-icons-png.flaticon.com/512/11648/11648347.png');
    background-size: contain;
    background-repeat: no-repeat;
    z-index: 50;
    pointer-events: none;
    transform-origin: center bottom;
}

#fist-l {
    left: 0;
    transform: rotate(-10deg);
}

#fist-r {
    right: 0;
    transform: rotate(10deg) scaleX(-1);
}

.fist-crit {
    filter: drop-shadow(0 0 20px cyan);
}

.punch-l {
    animation: punchLeft 0.15s forwards;
}

.punch-r {
    animation: punchRight 0.15s forwards;
}

@keyframes punchLeft {
    0% {
        transform: rotate(-10deg) translate(0, 0) scale(1);
    }

    50% {
        transform: rotate(20deg) translate(80px, -150px) scale(1.3);
    }

    100% {
        transform: rotate(-10deg) translate(0, 0) scale(1);
    }
}

@keyframes punchRight {
    0% {
        transform: scaleX(-1) rotate(10deg) translate(0, 0) scale(1);
    }

    50% {
        transform: scaleX(-1) rotate(20deg) translate(80px, -150px) scale(1.3);
    }

    100% {
        transform: scaleX(-1) rotate(10deg) translate(0, 0) scale(1);
    }
}

.dmg-num {
    position: absolute;
    font-family: 'Black Ops One', cursive;
    font-size: 50px;
    color: #ffeb3b;
    text-shadow: 3px 3px 0 #000;
    pointer-events: none;
    z-index: 400;
    animation: popUp 0.8s forwards;
}

.crit-text {
    position: absolute;
    font-family: 'Black Ops One', cursive;
    font-size: 60px;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff, 3px 3px 0 #000;
    pointer-events: none;
    z-index: 410;
    animation: popUpCrit 0.8s forwards;
}

.crit-dmg-num {
    position: absolute;
    font-family: 'Black Ops One', cursive;
    font-size: 100px;
    color: #ffffff;
    text-shadow: 0 0 15px #ff0000, 5px 5px 0 #000;
    pointer-events: none;
    z-index: 420;
    animation: popUpCritDmg 0.8s forwards;
}

.miss-text {
    position: absolute;
    font-family: 'Black Ops One', cursive;
    font-size: 40px;
    color: #00d2ff;
    font-style: italic;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    z-index: 400;
    animation: fadeUp 0.5s forwards;
}

.block-text {
    position: absolute;
    font-family: 'Black Ops One', cursive;
    font-size: 40px;
    color: #aaaaff;
    font-style: italic;
    text-shadow: 2px 2px 0 #000;
    pointer-events: none;
    z-index: 400;
    animation: fadeUp 0.5s forwards;
}

#red-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: red;
    opacity: 0;
    pointer-events: none;
    z-index: 95;
    mix-blend-mode: multiply;
    transition: opacity 0.1s;
}

#dodge-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 100px #00d2ff;
    opacity: 0;
    pointer-events: none;
    z-index: 96;
    mix-blend-mode: screen;
    transition: opacity 0.1s;
}

#block-shield {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 80%, rgba(0, 100, 255, 0.3) 0%, transparent 60%);
    opacity: 0;
    pointer-events: none;
    z-index: 80;
    transition: opacity 0.1s;
    border-bottom: 10px solid rgba(0, 100, 255, 0.5);
}

.shield-active {
    opacity: 1 !important;
}

#mobile-controls {
    display: none;
    position: absolute;
    bottom: 30px;
    width: 100%;
    justify-content: space-between;
    padding: 0 30px;
    box-sizing: border-box;
    z-index: 150;
    pointer-events: none;
}

.control-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    font-family: 'Black Ops One';
    font-size: 16px;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    backdrop-filter: blur(2px);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    text-align: center;
}

#btn-block {
    border-color: #00d2ff;
    color: #00d2ff;
}

#btn-dodge {
    border-color: #ffd700;
    color: #ffd700;
}

#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    color: #fff;
}

#result-text {
    font-size: 50px;
    font-family: 'Black Ops One';
    text-shadow: 0 0 20px currentColor;
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 20px;
    font-family: 'Roboto', sans-serif;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border: 1px solid #555;
    width: 90%;
    max-width: 400px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #ddd;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-val {
    color: #00d2ff;
    font-weight: bold;
    font-family: 'Black Ops One';
}

.final-score {
    font-size: 36px;
    color: #00ff00;
    font-family: 'Black Ops One';
    margin-top: 5px;
    text-shadow: 0 0 15px #00ff00;
}

.rank-badge {
    font-size: 60px;
    font-family: 'Black Ops One';
    color: #ffd700;
    text-shadow: 0 0 30px orange;
    position: absolute;
    right: 5%;
    top: 10%;
    transform: rotate(15deg);
    border: 3px solid #fff;
    padding: 0 10px;
    background: rgba(0, 0, 0, 0.5);
}

/* --- Animations --- */
@keyframes floatCard {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

@keyframes pulse-purple {
    0% {
        box-shadow: 0 0 20px #9b59b6;
    }

    50% {
        box-shadow: 0 0 50px #9b59b6;
    }

    100% {
        box-shadow: 0 0 20px #9b59b6;
    }
}

@keyframes shake-aggressive {
    0% {
        transform: rotate(1deg);
    }

    100% {
        transform: rotate(-1deg);
    }
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

@keyframes glow-purple {
    from {
        box-shadow: 0 0 10px #9b59b6;
    }

    to {
        box-shadow: 0 0 25px #9b59b6;
    }
}

@keyframes glow-red {
    from {
        box-shadow: 0 0 15px #e74c3c;
    }

    to {
        box-shadow: 0 0 40px #e74c3c, 0 0 10px #fff;
    }
}

@keyframes glow-gold {
    from {
        box-shadow: 0 0 30px #f1c40f;
    }

    to {
        box-shadow: 0 0 60px #f1c40f, 0 0 20px #fff;
    }
}

@keyframes rainbow-border {
    0% {
        background-position: 0 0;
    }

    50% {
        background-position: 100% 0;
    }

    100% {
        background-position: 0 0;
    }
}

/* --- Card Skill & Equip --- */
.detail-skill-info {
    position: absolute;
    bottom: 60px;
    left: 0;
    width: 100%;
    text-align: center;
    padding: 5px;
    background: rgba(0, 0, 0, 0.6);
    z-index: 4;
}

.skill-name {
    color: #00ffff;
    font-family: 'Black Ops One';
    font-size: 18px;
    text-shadow: 0 0 5px #00ffff;
    margin-bottom: 2px;
}

.skill-desc {
    color: #ddd;
    font-size: 12px;
    font-family: 'Roboto', sans-serif;
}

.btn-equip {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    background: #27ae60;
    color: white;
    border: 2px solid #2ecc71;
    padding: 8px 20px;
    font-family: 'Black Ops One';
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 0 10px #27ae60;
    transition: all 0.2s;
    z-index: 10;
}

.btn-equip:hover {
    background: #2ecc71;
    transform: translateX(-50%) scale(1.1);
}

.btn-equip.equipped {
    background: #555;
    border-color: #777;
    color: #aaa;
    cursor: default;
    box-shadow: none;
}

.btn-equip.equipped:hover {
    transform: translateX(-50%);
}

/* --- In-Game Skill Button --- */
#skill-btn-container {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 80px;
    z-index: 150;
    pointer-events: auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

#skill-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: #000;
    border: 3px solid #fff;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: transform 0.1s;
}

#skill-btn:active {
    transform: scale(0.95);
}

#skill-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#skill-cooldown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-family: 'Black Ops One';
    font-size: 24px;
    pointer-events: none;
}

.skill-ready-glow {
    animation: pulse-gold 1s infinite;
    border-color: #ffd700 !important;
    box-shadow: 0 0 30px #ffd700 !important;
}

@keyframes pulse-gold {
    0% {
        box-shadow: 0 0 15px #ffd700;
    }

    50% {
        box-shadow: 0 0 30px #ffd700, 0 0 10px #fff;
    }

    100% {
        box-shadow: 0 0 15px #ffd700;
    }
}

/* Skill Effects */
.skill-effect-text {
    position: absolute;
    font-family: 'Black Ops One';
    font-size: 40px;
    color: #ffd700;
    text-shadow: 0 0 10px #ff0000;
    z-index: 500;
    animation: popUp 1s forwards;
}

/* --- Mobile Media Query --- */
@media (max-width: 768px) {
    .gacha-grid {
        grid-template-columns: repeat(3, 1fr);
        width: 95%;
        gap: 8px;
    }

    .btn-action {
        font-size: 18px;
        width: 80%;
        max-width: none;
        margin: 5px auto;
    }

    #collection-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 10px;
    }

    #hud-header {
        padding-top: 50px;
    }

    .bars-wrapper {
        width: 98%;
    }

    .stats-block {
        width: 40%;
    }

    .hp-container {
        height: 18px;
    }

    .name-tag {
        font-size: 14px;
        top: -20px;
    }

    #mobile-controls {
        bottom: 40px;
        padding: 0 20px;
    }

    .control-btn {
        width: 80px;
        height: 80px;
        font-size: 14px;
    }
}
/* --- Mobile Fixes & Optimizations --- */
.screen-header { padding-top: calc(60px + env(safe-area-inset-top)); padding-bottom: 10px; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.screen-footer { padding: 20px env(safe-area-inset-right) calc(20px + env(safe-area-inset-bottom)) env(safe-area-inset-left); }
#game-container { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.hp-fill { transform-origin: left; transform: scaleX(1); transition: transform 0.2s ease-out; will-change: transform; width: 100%; }
.stamina-fill { transform-origin: left; transform: scaleX(1); transition: transform 0.1s linear; will-change: transform; width: 100%; }
#e-hp { transform-origin: right; }
@media (max-width: 768px) { .enemy-charging, .boss-berserk { filter: brightness(1.5) !important; animation: none !important; } .dmg-num, .crit-text, .miss-text, .block-text { will-change: transform, opacity; } }
