@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;600;700&family=Yuji+Mai&family=Zhi+Mang+Xing&display=swap');

:root {
    --bg-color: #050202;
    --accent-gold: #d4af37;
    --accent-red: #b02525;
    --card-bg: #150b0b;
    --border-sr: #a020f0;
    --border-ssr: #ffd700;
    --ball-red-grad: radial-gradient(circle at 30% 20%, #fff7f7 0%, #ffb3b3 25%, #ff6b6b 55%, #8a0000 100%);
    --ball-blue-grad: radial-gradient(circle at 30% 20%, #f5fbff 0%, #a9d4ff 25%, #4da6ff 55%, #4a8fe0 65%, #003380 100%);
    --ball-green-grad: radial-gradient(circle at 30% 20%, #f5fff7 0%, #b7f0b7 25%, #5cd65c 55%, #0b7a0b 75%, #004d00 100%);
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Fixed: Prevent body scrollbar jitter */
    background-color: var(--bg-color);
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23d4af37' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
    color: var(--accent-gold);
    font-family: 'Noto Serif TC', serif;
}

/* SPA Transitions */
.view-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
    display: none; /* Initially hidden */
}

.view-section.active {
    opacity: 1;
    pointer-events: auto;
    display: flex; /* Or block, depending on layout */
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Home View Specifics */
#home-view.active {
    display: flex;
    height: 100%; /* Use 100% of viewport */
    overflow-y: auto; /* Internal scrolling */
    -webkit-overflow-scrolling: touch;
}

/* --- HOME VIEW STYLES --- */
.layout {
    width: 1180px;
    height: 640px;
    max-width: calc(100vw - 60px);
    max-height: calc(100vh - 60px);
    display: flex;
    gap: 10px;
    margin: auto; /* Center in SPA container */
}

.mobile-menu-wrapper {
    width: 260px;
    height: 100%;
    position: relative;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.pool-list {
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 0 0, rgba(212,175,55,0.2), transparent 55%),
                linear-gradient(180deg, #0c0c16, #05040a);
    border-radius: 6px;
    box-shadow: 0 0 26px rgba(0,0,0,0.8);
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.pool-list-title {
    font-family: 'Yuji Mai', 'Noto Serif TC', serif;
    font-size: 1.5rem;
    letter-spacing: 0.3rem;
    padding: 4px 8px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 8px;
}

.pool-btn {
    border: none;
    text-align: left;
    padding: 10px 10px;
    margin-bottom: 6px;
    border-radius: 4px;
    cursor: pointer;
    background: linear-gradient(90deg, #252435, #202338);
    color: #eae4ff;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-family: 'Noto Serif TC', serif;
}

.pool-btn span { pointer-events: none; }

.pool-btn-main {
    font-family: 'Yuji Mai', 'Noto Serif TC', serif;
    font-size: 1.3rem;
}

.pool-btn-sub {
    font-size: 0.75rem;
    letter-spacing: 0.2rem;
    opacity: 0.8;
}

.pool-btn.active {
    outline: 1px solid #ffd36e;
    box-shadow: 0 0 15px rgba(255, 211, 110, 0.6);
    background: linear-gradient(90deg, #5a3b23, #8f5d23);
}

.pool-btn.locked {
    background: linear-gradient(90deg, #181818, #111);
    color: #666;
    cursor: default;
}

.mobile-scroll-hint { display: none; }

.pool-main {
    flex: 1;
    height: 100%;
    background: radial-gradient(circle at 20% 0%, rgba(255,215,0,0.12), transparent 55%),
                radial-gradient(circle at 80% 100%, rgba(116,197,255,0.18), transparent 60%),
                linear-gradient(180deg, #0a0608, #090716);
    border-radius: 8px;
    padding: 18px 20px 30px;
    box-shadow: 0 0 30px rgba(0,0,0,0.85);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.pool-view { display: none; }

.pool-view.active { 
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    position: relative;
}

/* --- Game-like Transitions for Home Tabs --- */
@keyframes gameSlideIn {
    0% { opacity: 0; transform: translateX(30px); }
    100% { opacity: 1; transform: translateX(0); }
}

@keyframes gamePopIn {
    0% { opacity: 0; transform: scale(0.5); }
    60% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

.pool-view.active .home-header {
    animation: gameSlideIn 0.4s ease-out both;
    animation-delay: 0.05s;
}

.pool-view.active .pool-banner-top {
    animation: gameSlideIn 0.4s ease-out both;
    animation-delay: 0.15s;
}

.pool-view.active .intro {
    animation: gameSlideIn 0.4s ease-out both;
    animation-delay: 0.25s;
}

.pool-view.active .probability-note {
    animation: gameSlideIn 0.4s ease-out both;
    animation-delay: 0.3s;
}

.pool-view.active .enter-btn {
    /* Combine PopIn with the existing Breathe animation */
    animation: 
        gamePopIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both,
        btn-breathe 2.5s infinite ease-in-out 0.5s; /* Delay breathing until pop finishes */
}


.home-header { margin-bottom: 12px; }

.home-header h1 {
    margin: 0;
    font-size: 3rem;
    font-family: 'Yuji Mai', 'Noto Serif TC', serif;
    background: linear-gradient(180deg, #fff, #d4af37);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
}

.home-header .sub {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.9rem;
    letter-spacing: 0.4rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 4px;
    color: #aaa;
}

.pool-banner-top {
    position: relative;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.06);
    background: linear-gradient(90deg, #3c466a, #313b5f, #222437);
    overflow: hidden;
    padding: 18px 30px;
    margin-top: 6px;
    min-height: 80px;
}

.banner-text-main {
    font-family: 'Yuji Mai', 'Noto Serif TC', serif;
    font-size: 1.2rem;
    letter-spacing: 0.4rem;
    margin-bottom: 4px;
    position: relative; z-index: 2;
    text-shadow: 0 0 8px rgba(0,0,0,0.8);
}

.banner-text-sub {
    font-family: 'Noto Serif TC', serif;
    font-size: 0.8rem;
    color: #f1f1ff;
    line-height: 1.7;
    max-width: 70%;
    position: relative; z-index: 2;
    text-shadow: 0 0 5px rgba(0,0,0,0.9);
}

.banner-tag {
    position: absolute;
    top: 16px;
    right: 40px;
    padding: 4px 14px;
    font-size: 0.75rem;
    letter-spacing: 0.25rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.7);
    background: rgba(0,0,0,0.6);
    color: #ffeec3;
    z-index: 3;
}

.banner-orb {
    position: absolute;
    right: -20px;
    bottom: -50px;
    width: 210px;
    height: 210px;
    border-radius: 50%;
    border: 2px solid rgba(212,175,55,0.6);
    box-shadow: 0 0 40px rgba(212,175,55,0.6), 0 0 90px rgba(90, 140, 255, 0.7);
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.9), transparent 60%),
                radial-gradient(circle at 50% 80%, rgba(60, 90, 200, 0.8), rgba(10, 10, 30, 1));
    z-index: 1;
}

.intro {
    margin-top: 16px;
    font-size: 0.95rem;
    line-height: 1.8;
    color: #ddd;
}

.intro-quote {
    margin-top: 10px;
    padding-left: 10px;
    border-left: 2px solid rgba(212,175,55,0.5);
    font-size: 0.9rem;
    color: #c7a862;
}

.probability-note {
    margin-top: auto; 
    margin-bottom: 10px;
    max-width: 65%; 
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.75rem;
    color: #777;
    font-family: 'Noto Serif TC', serif;
    line-height: 1.6;
}

.probability-note span { display: inline-block; margin-right: 15px; }
.probability-title { color: #999; margin-bottom: 2px; display: block; }

.enter-btn {
    position: absolute; right: 26px; bottom: 26px;
    background: linear-gradient(90deg, #8b1111, #4c0000);
    border-radius: 6px; border: 2px solid rgba(255,221,150,0.9);
    color: #ffdba0; cursor: pointer;
    box-shadow: 0 0 18px rgba(255,215,120,0.6);
    background-size: 200% 100%; background-position: 0 0;
    transition: transform 0.15s ease-out, box-shadow 0.15s, background-position 0.5s;
    text-decoration: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 10px 40px;
    animation: btn-breathe 2.5s infinite ease-in-out;
}
.enter-btn:hover {
    box-shadow: 0 0 35px rgba(255,215,120,0.9); background-position: 100% 0;
    animation: none; transform: translateY(-2px);
}
.enter-btn:active { transform: scale(0.96); }

.btn-main-text {
    font-family: 'Yuji Mai', 'Noto Serif TC', serif;
    font-size: 1.4rem; letter-spacing: 0.35rem; line-height: 1.2;
}
.btn-sub-text {
    font-family: 'Noto Serif TC', serif; font-size: 0.75rem; opacity: 0.9;
    font-weight: normal; letter-spacing: 0.1rem; margin-top: 4px;
    color: #ffd; text-shadow: none;
}
@keyframes btn-breathe {
    0%, 100% { transform: scale(1); box-shadow: 0 0 18px rgba(255,215,120,0.6); }
    50% { transform: scale(1.02); box-shadow: 0 0 30px rgba(255,215,120,0.8); }
}

#view-history {
    overflow-y: auto; 
    justify-content: flex-start;
}
#view-history::-webkit-scrollbar { width: 6px; }
#view-history::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
#view-history::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }

.history-controls {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); 
    padding-bottom: 10px;
    flex-shrink: 0;
}
.history-title { font-size: 1.2rem; color: #d4af37; font-family: 'Yuji Mai', serif; }

.btn-clear-all {
    background: transparent; border: 1px solid #b02525; color: #b02525;
    padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 0.8rem;
    transition: 0.2s;
}
.btn-clear-all:hover { background: #b02525; color: #fff; }

.history-list {
    display: flex; flex-direction: column; gap: 15px;
    flex: 1; 
}

.history-item {
    background: rgba(20,20,30,0.6); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px; padding: 15px; display: flex; flex-direction: column; gap: 10px;
    position: relative; animation: fadeIn 0.4s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.h-item-header {
    display: flex; justify-content: space-between; font-size: 0.8rem; color: #888;
}
.h-date { font-family: 'Noto Serif TC', serif; }
.h-delete-btn {
    color: #666; cursor: pointer; font-size: 1.2rem; line-height: 0.8rem;
}
.h-delete-btn:hover { color: #b02525; }

.h-balls-row {
    display: flex; gap: 8px; justify-content: flex-start; align-items: center;
}

.mini-ball {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; font-weight: bold; color: #fff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.8);
    border: 1px solid rgba(255,255,255,0.2);
    font-family: 'Noto Serif TC', serif;
}
.mini-ball.red { background: var(--ball-red-grad); }
.mini-ball.blue { background: var(--ball-blue-grad); }
.mini-ball.green { background: var(--ball-green-grad); }

.mini-ball.r3 { border: 1px solid #ffd700; box-shadow: 0 0 8px rgba(255,215,0,0.6); }
.mini-ball.r4 { 
    background: radial-gradient(circle at 30% 20%, #fff 0%, #ffeb3b 30%, #aa00ff 100%);
    border: 1px solid #fff; box-shadow: 0 0 10px rgba(255,255,255,0.8); color: #000; text-shadow: none;
}

.h-quote {
    font-size: 0.85rem; color: #aaa; font-family: 'Yuji Mai', serif;
    border-left: 2px solid #555; padding-left: 8px; margin-top: 5px;
}

.empty-state-box {
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    padding: 40px 20px;
    border: 1px dashed rgba(212,175,55,0.3);
    border-radius: 8px;
    margin-top: 0; 
    background: rgba(0,0,0,0.2);
    animation: fadeIn 0.6s ease;
}

.empty-title {
    font-family: 'Yuji Mai', serif;
    font-size: 1.6rem;
    color: #777;
    margin-bottom: 12px;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

.empty-desc {
    font-family: 'Noto Serif TC', serif;
    font-size: 0.95rem;
    line-height: 1.8;
    color: #666;
    text-align: center;
    margin-bottom: 25px;
}

.empty-action-btn {
    background: linear-gradient(90deg, #333, #222);
    border: 1px solid #666;
    color: #aaa;
    padding: 10px 24px;
    border-radius: 4px;
    font-family: 'Yuji Mai', serif;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.3s;
}
.empty-action-btn:hover {
    border-color: #d4af37;
    color: #d4af37;
    background: linear-gradient(90deg, #1a1a1a, #000);
}

@media (max-width: 900px) {
    .layout {
        flex-direction: column; width: 100%; height: auto; max-width: 100%; max-height: none; padding: 10px; box-sizing: border-box;
    }

    .mobile-menu-wrapper { width: 100%; height: auto; }
    .pool-list {
        width: 100%; height: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden;
        align-items: center; position: relative; scrollbar-width: none; -ms-overflow-style: none;
    }
    .pool-list::-webkit-scrollbar { display: none; }
    .pool-list-title { font-size: 1.15rem; padding: 0 12px; border-bottom: none; border-right: 1px solid rgba(255,255,255,0.15); margin-bottom: 0; margin-right: 8px; line-height: 1.25; text-align: center; flex-shrink: 0; white-space: normal; }
    .pool-btn { min-width: 150px; margin-bottom: 0; margin-right: 8px; flex-shrink: 0; }
    .pool-btn:last-child { margin-right: 40px; }
    
    .mobile-scroll-hint {
        display: flex; align-items: center; justify-content: center; position: absolute; right: 0; top: 0; bottom: 0; width: 80px; 
        background: linear-gradient(to right, transparent, rgba(5, 4, 10, 0.8) 40%, #05040a 100%);
        pointer-events: none; z-index: 10; opacity: 1; transition: opacity 0.4s ease; border-radius: 0 6px 6px 0;
    }
    .mobile-scroll-hint.fade-out { opacity: 0; }
    .hint-arrow {
        color: #d4af37; font-size: 3rem; font-family: serif; animation: bounceRight 1.5s infinite ease-in-out; text-shadow: 0 0 10px rgba(0,0,0,1); padding-left: 20px; 
    }
    @keyframes bounceRight { 0%, 100% { transform: translateX(0); opacity: 0.6; } 50% { transform: translateX(10px); opacity: 1; } }

    .pool-main { 
        height: auto; 
        margin-top: 8px; 
        min-height: 700px; 
        display: flex;
        flex-direction: column;
    }
    .pool-view.active {
        flex: 1; 
    }

    .pool-banner-top { padding-right: 20px; min-height: auto; display: flex; flex-direction: column; justify-content: center; padding-top: 50px; }
    .banner-text-main { word-break: keep-all; }
    .banner-text-sub { max-width: 100%; }
    .banner-tag { top: 15px; right: 15px; }
    .banner-orb { width: 160px; height: 160px; right: -40px; bottom: -40px; opacity: 0.5; }
    .enter-btn { position: static; margin-top: 20px; align-self: flex-end; padding: 12px 30px; width: 100%; box-sizing: border-box; }
    .probability-note { max-width: 100%; margin-top: 20px; }
}

/* --- COMMON M1/M6 STYLES --- */
.view-header { text-align: center; margin-bottom: 20px; z-index: 10; flex-shrink: 0; }
.view-header h1 {
    font-size: 3.2rem; margin: 0;
    font-family: 'Yuji Mai', 'Noto Serif TC', serif;
    background: linear-gradient(180deg, #fff, #d4af37);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    text-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
}
.view-header h1.blue-theme {
    background: linear-gradient(180deg, #fff, #8be);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 5px 15px rgba(136, 187, 238, 0.3);
}

.view-header .sub {
    font-size: 0.9rem; letter-spacing: 4px; color: #888;
    border-top: 1px solid #444; padding-top: 5px; margin-top: 5px; display: inline-block;
}

.btn-row {
    display: flex; gap: 12px; justify-content: center; align-items: center; margin-top: 10px; z-index: 10; flex-shrink: 0;
}

#m1-backBtn, #m6-backBtn, #m6-saveBtn {
    background: transparent; border-radius: 5px; padding: 10px 22px;
    border: 1px solid #777; color: #bbb; font-size: 0.95rem; cursor: pointer;
    font-family: 'Noto Serif TC', serif; 
    user-select: none;
    transition: 0.2s;
}
#m1-backBtn:hover, #m6-backBtn:hover { border-color: #d4af37; color: #d4af37; }

#m6-saveBtn { border-color: #d4af37; color: #d4af37; margin-left: 5px; }
#m6-saveBtn:hover { background: rgba(212,175,55,0.1); }
#m6-saveBtn.saved { border-color: #5cb85c; color: #5cb85c; cursor: default; }

.destiny-quote {
    min-height: 2em; margin: 10px auto 20px; text-align: center;
    font-family: 'Yuji Mai', 'Noto Serif TC', serif; color: #d4af37; font-size: 1.1rem;
    opacity: 0; transition: opacity 1.5s ease; max-width: 90%;
    letter-spacing: 0.15em; text-shadow: 0 0 10px rgba(212, 175, 55, 0.3); z-index: 10;
}
.destiny-quote.blue-theme { color: #8be; text-shadow: 0 0 10px rgba(136, 187, 238, 0.4); }
.destiny-quote.show { opacity: 1; }

.god-rays {
    position: fixed; top: 50%; left: 50%; width: 200vw; height: 200vw;
    background: conic-gradient(from 0deg, transparent 0deg, rgba(255,255,255,0.15) 20deg, transparent 40deg, rgba(255,215,0,0.15) 60deg, transparent 80deg);
    transform: translate(-50%, -50%); animation: rotateRays 10s linear infinite;
    pointer-events: none; z-index: 1; opacity: 0; transition: opacity 0.5s;
}

.shockwave {
    position: absolute; top: 50%; left: 50%; width: 10px; height: 10px;
    border: 5px solid rgba(255, 255, 255, 0.8); border-radius: 50%;
    transform: translate(-50%, -50%); opacity: 0; pointer-events: none; z-index: 40;
}

.ur-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #000; z-index: 85; opacity: 0; pointer-events: none;
    display: flex; flex-direction: column; justify-content: center; overflow: hidden; transition: opacity 0.5s;
}
.ur-overlay.active { opacity: 1; }

.ur-stream {
    position: absolute;
    width: 400%; 
    left: -100%; 
    font-family: 'Zhi Mang Xing', serif;
    font-size: 3.5rem; 
    font-weight: bold; 
    color: rgba(255, 255, 255, 0.15); white-space: nowrap;
    opacity: 1; 
    transform: translateX(100%);
}
.ur-stream.anim { animation: textStream linear infinite; }

/* --- M1 VIEW SPECIFIC --- */
#m1-view .stage {
    display: flex; justify-content: center; align-items: center;
    margin-bottom: 30px; z-index: 10; height: 280px; 
}
#m1-view .card-slot { width: 200px; height: 260px; position: relative; transform-style: preserve-3d; }
#m1-view .card {
    width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 0%, #2e3b4e 0%, #0e1216 55%, #050202 100%);
    border-radius: 16px; display: flex; align-items: center; justify-content: center;
    position: relative; box-shadow: 0 15px 35px rgba(0,0,0,0.8);
    border: 1px solid rgba(255,255,255,0.1); transition: transform 0.1s;
}
#m1-view .ball {
    width: 130px; height: 130px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 4.5rem; font-weight: bold; color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    box-shadow: 0 10px 20px rgba(0,0,0,0.7), inset 0 -10px 15px rgba(0,0,0,0.9), inset 0 10px 15px rgba(255,255,255,0.5);
    border: 3px solid transparent; position: relative; z-index: 2;
    font-family: 'Noto Serif TC', serif;
}
#m1-view .ball::before {
    content: ""; position: absolute; top: 14%; left: 18%; width: 38%; height: 26%;
    border-radius: 50%; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.95), transparent 70%);
    opacity: 0.9; pointer-events: none;
}
#m1-summonBtn {
    background: radial-gradient(circle at 50% 0%, #1e3c72 0%, #2a5298 100%);
    border: 2px solid #8be; color: #dbeeff;
    font-family: 'Yuji Mai', 'Noto Serif TC', serif; font-size: 1.6rem;
    padding: 15px 50px; border-radius: 5px; cursor: pointer;
    box-shadow: 0 0 20px rgba(100, 200, 255, 0.3); position: relative; overflow: hidden; transition: 0.2s;
    user-select: none;
}
#m1-summonBtn:hover { transform: translateY(-2px); box-shadow: 0 0 30px rgba(100, 200, 255, 0.6); }
#m1-summonBtn:active { transform: scale(0.96); }
#m1-summonBtn::after {
    content: ""; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.2), transparent); animation: shine 3s infinite;
}

/* --- M6 VIEW SPECIFIC --- */
#m6-view .grid {
    display: grid; grid-template-columns: repeat(3, 110px); gap: 15px;
    margin-bottom: 20px; z-index: 10;
}
#m6-view .card-slot { width: 110px; height: 140px; position: relative; transform-style: preserve-3d; }
#m6-view .card {
    width: 100%; height: 100%;
    background: radial-gradient(circle at 50% 0%, #3b2620 0%, var(--card-bg) 45%, #050202 100%);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    position: relative; box-shadow: 0 10px 20px rgba(0,0,0,0.6);
    opacity: 0; transform: scale(0.8); border: 1px solid rgba(255,255,255,0.08);
}
#m6-view .card.final { box-shadow: 0 0 26px rgba(255, 255, 255, 0.5), 0 0 48px rgba(255, 215, 0, 0.5); }
#m6-view .ball {
    width: 72px; height: 72px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: bold; color: #ffffff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    box-shadow: 0 6px 10px rgba(0,0,0,0.7), inset 0 -7px 12px rgba(0,0,0,0.9), inset 0 7px 10px rgba(255,255,255,0.5);
    border: 2px solid transparent; position: relative; z-index: 2;
    font-family: 'Noto Serif TC', serif;
}
#m6-view .ball::before {
    content: ""; position: absolute; top: 14%; left: 18%; width: 38%; height: 26%;
    border-radius: 50%; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.95), transparent 70%);
    opacity: 0.9; pointer-events: none;
}
#m6-summonBtn {
    background: radial-gradient(circle at 50% 0%, #b02525 0%, #500000 45%, #2a0000 100%);
    border: 2px solid #d4af37; color: #d4af37;
    font-family: 'Yuji Mai', 'Noto Serif TC', serif; font-size: 1.5rem;
    padding: 15px 40px; border-radius: 5px; cursor: pointer;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3); position: relative; overflow: hidden; transition: 0.2s;
    user-select: none;
}
#m6-summonBtn:hover { transform: translateY(-1px); box-shadow: 0 0 22px rgba(212,175,55,0.5); }
#m6-summonBtn:active { transform: scale(0.95); }
#m6-summonBtn::after {
    content: ""; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.2), transparent); animation: shine 3s infinite;
}

.cutscene {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #000; z-index: 100; display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.5s;
}
.cutscene.active { opacity: 1; pointer-events: auto; }

.bagua-circle {
    width: 250px; height: 250px; border: 2px solid rgba(212, 175, 55, 0.5); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; position: relative;
    background: radial-gradient(circle at 50% 50%, rgba(0,0,0,0.2) 0%, transparent 55%),
                conic-gradient(from 0deg, rgba(212,175,55,0.1), transparent 25%, rgba(212,175,55,0.2), transparent 50%, rgba(212,175,55,0.1), transparent 75%, rgba(212,175,55,0.2), transparent);
    animation: spin 4s linear infinite;
}
.bagua-text {
    font-size: 8rem; font-family: 'Zhi Mang Xing', 'Yuji Mai', 'Noto Serif TC', serif;
    color: #d4af37; text-shadow: 0 0 20px #d4af37;
}

.cutin {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle at center, rgba(0,0,0,0.9), rgba(0,0,0,1));
    display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; z-index: 90; transition: opacity 0.2s;
}
.cutin.active { opacity: 1; pointer-events: auto; }
.cutin-content { text-align: center; transform: scale(0.8); opacity: 0; }
.cutin-circle {
    position: relative; width: 220px; height: 220px; border-radius: 50%;
    border: 1px solid rgba(212,175,55,0.3); display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 25px rgba(212,175,55,0.4), 0 0 55px rgba(212,175,55,0.2);
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.06), transparent 60%), conic-gradient(from 0deg, rgba(212,175,55,0.1), transparent 45%, rgba(212,175,55,0.25), transparent 80%, rgba(212,175,55,0.1));
}
.cutin-sigil {
    position: absolute; font-size: 3.2rem; font-family: 'Zhi Mang Xing', 'Yuji Mai', 'Noto Serif TC', serif;
    color: rgba(212,175,55,0.9); text-shadow: 0 0 16px rgba(212,175,55,0.7), 0 0 30px rgba(255,255,255,0.2);
    bottom: 8px; right: 14px;
}
.cutin-caption {
    margin-top: 16px; font-size: 1.1rem; letter-spacing: 0.4rem; color: #c9a04f;
    font-family: 'Zhi Mang Xing', 'Yuji Mai', 'Noto Serif TC', serif;
}
.cutin-ball { 
    width: 110px; height: 110px; font-size: 2.4rem; 
    border-radius: 50%; 
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; color: #ffffff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    box-shadow: 0 6px 10px rgba(0,0,0,0.7), inset 0 -7px 12px rgba(0,0,0,0.9), inset 0 7px 10px rgba(255,255,255,0.5);
    border: 2px solid transparent; 
    font-family: 'Noto Serif TC', serif;
    position: relative; z-index: 2;
}
.cutin-ball::before {
    content: ""; position: absolute; top: 14%; left: 18%; width: 38%; height: 26%;
    border-radius: 50%; background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.95), transparent 70%);
    opacity: 0.9; pointer-events: none;
}
.cutin-ball.r4 { width: 130px; height: 130px; font-size: 3rem; box-shadow: 0 0 50px rgba(255, 255, 255, 0.8); }

@media (max-width: 400px) {
    #m6-view .grid { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px; 
        margin-bottom: 10px;
        transform: scale(0.85); 
    }
    #m6-view .card-slot { width: 120px; height: 150px; }
    h1 { font-size: 2.5rem; }
    #m1-view h1 { font-size: 2.8rem; }
    #m1-view .stage { height: 220px; }
    #m1-view .card-slot { width: 160px; height: 210px; }
    #m1-view .ball { width: 100px; height: 100px; font-size: 3.5rem; }
}

/* --- ANIMATIONS --- */
@keyframes vibrate { 0% { transform: translate(0); } 20% { transform: translate(-2px, 2px); } 40% { transform: translate(-2px, -2px); } 60% { transform: translate(2px, 2px); } 80% { transform: translate(2px, -2px); } 100% { transform: translate(0); } }
@keyframes rotateRays { 100% { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes textStream { 0% { transform: translateX(50%); } 100% { transform: translateX(-50%); } }
@keyframes rainbowGlow { 0% { filter: hue-rotate(0deg); } 100% { filter: hue-rotate(30deg); } }
@keyframes pulseGold { 0% { box-shadow: 0 0 40px rgba(255,215,0,0.6); } 50% { box-shadow: 0 0 60px rgba(255,215,0,0.9); } 100% { box-shadow: 0 0 40px rgba(255,215,0,0.6); } }
@keyframes shakeHard { 0% { transform: translate(0, 0); } 25% { transform: translate(-5px, 5px); } 50% { transform: translate(5px, -5px); } 75% { transform: translate(-5px, -5px); } 100% { transform: translate(0, 0); } }
@keyframes waveExpand { 0% { width: 10px; height: 10px; opacity: 1; border-width: 50px; } 100% { width: 800px; height: 800px; opacity: 0; border-width: 0px; } }
@keyframes shine { 0% { left: -100%; } 100% { left: 100%; } }
@keyframes revealCard { 0% { transform: scale(0.5) rotateY(90deg); opacity: 0; } 100% { transform: scale(1) rotateY(0); opacity: 1; } }
@keyframes revealUR { 0% { transform: scale(0.1); opacity: 0; } 50% { transform: scale(1.5); opacity: 1; } 100% { transform: scale(1.1); opacity: 1; } }
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes cutinPop { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1.0); opacity: 1; } }
@keyframes cutinFinal { 0% { transform: scale(0.2); opacity: 0; } 50% { transform: scale(1.4); opacity: 1; } 100% { transform: scale(1.1); opacity: 1; } }

/* Shared balls colors */
.ball.red { background: var(--ball-red-grad); }
.ball.blue { background: var(--ball-blue-grad); }
.ball.green { background: var(--ball-green-grad); }
.ball.r1 { border-color: rgba(255,255,255,0.35) !important; }
.ball.r2 { border-color: var(--border-sr) !important; box-shadow: 0 0 25px rgba(160,32,240,0.7), inset 0 0 20px rgba(160,32,240,0.5); }
.ball.r3 { border-color: var(--border-ssr) !important; box-shadow: 0 0 40px rgba(255,215,0,0.9), inset 0 0 20px rgba(255,215,0,0.6); animation: pulseGold 2s infinite; }
.ball.r4 {
    background: radial-gradient(circle at 30% 20%, #ffffff 0%, #fff0f0 15%, #ffeb3b 30%, #00e5ff 60%, #aa00ff 100%) !important;
    border-color: #fff !important;
    box-shadow: 0 0 50px rgba(255,255,255,0.9), 0 0 80px rgba(0,255,255,0.5);
    animation: rainbowGlow 2s infinite alternate;
    color: #fff !important; text-shadow: 0 2px 5px rgba(0,0,0,0.8) !important;
}

/* Sound Control */
.sound-control {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 12px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: opacity 0.3s;
}

.sound-control:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.8);
}

.sound-icon {
    font-size: 1.2rem;
    cursor: pointer;
    margin-right: 10px;
    user-select: none;
    color: var(--accent-gold);
}

.volume-slider-container {
    width: 0;
    overflow: hidden;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
}

.sound-control:hover .volume-slider-container {
    width: 100px;
}

.volume-slider {
    -webkit-appearance: none;
    width: 100px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent-gold);
    border-radius: 50%;
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--accent-gold);
    border-radius: 50%;
    cursor: pointer;
}

@media (max-width: 900px) {
    /* Move sound control to bottom-left on mobile to avoid blocking top selection bar */
    .sound-control {
        top: auto;
        bottom: 20px;
        left: 20px;
    }
}
