/* ========================================
   五十音圖鑑 - 鳥居神殿風格（柱子間距版）
   ======================================== */



/* ========================================
   Loading 畫面
   ======================================== */
.zukan-loading {
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, #2a1f1a 0%, #1a1410 50%, #2a1f1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.zukan-loading.fade-out {
    opacity: 0;
    visibility: hidden;
}

.zukan-loading .loading-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.loading-hiogi {
    width: 150px;
    height: auto;
    animation: fan-swing 2s ease-in-out infinite;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

@keyframes fan-swing {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.zukan-loading .loading-info {
    text-align: center;
}

.zukan-loading .loading-text {
    color: #d4a574;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-family: 'Yuji Syuku', serif;
    letter-spacing: 0.1em;
}

.zukan-loading .loading-bar {
    width: 250px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(212, 165, 116, 0.3);
}

.zukan-loading .loading-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8B4513, #d4a574, #8B4513);
    border-radius: 4px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(212, 165, 116, 0.5);
}

/* 圖鑑頁面整體背景 - 米色和紙 */
body:has(.torii-shrine-page) {
    background: #FFFBF0;
}

/* 頁面容器 */
.torii-shrine-page {
    min-height: calc(100vh - 200px);
    padding: 2rem 1rem 4rem;
    font-family: serif;
    overflow-x: hidden;
}

/* ======================================== 
   鳥居神殿容器 - 寬度 = 柱子間距
   ======================================== */
.torii-shrine-container {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 8rem auto 3rem;
}

/* 鳥居頂部 - 比容器寬 126%，讓飛簷懸空 */
.torii-header {
    position: absolute;
    top: -140px;
    left: 50%;
    transform: translateX(-50%);
    width: 126%;
    z-index: 40;
    pointer-events: none;
    user-select: none;
}

.torii-header img {
    width: 100%;
    display: block;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
}

/* 導航層 - 浮在鳥居前面 z-50 */
.shrine-nav {
    position: absolute;
    top: -100px;
    left: 0;
    width: 100%;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 檜扇 */
.hiogi-container {
    position: relative;
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: transform 0.3s;
}

.hiogi-container:hover {
    transform: scale(1.05);
}

.hiogi-fan {
    width: 200px;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.4));
    transition: transform 0.3s;
}

/* 浮雕墨字 - 硬邊框描邊 */
.hiogi-text-ink {
    position: absolute;
    top: 42%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Yuji Syuku', serif;
    font-size: 5rem;
    color: #1a1a1a;
    text-shadow: 
        3px 0px 0px #FFFBF0, -3px 0px 0px #FFFBF0, 
        0px 3px 0px #FFFBF0, 0px -3px 0px #FFFBF0, 
        2px 2px 0px #FFFBF0, -2px -2px 0px #FFFBF0, 
        2px -2px 0px #FFFBF0, -2px 2px 0px #FFFBF0,
        0 5px 15px rgba(0,0,0,0.3);
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
    transition: opacity 0.15s;
}

/* 保留舊樣式相容 */
.hiogi-badge {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 55px;
    height: 55px;
    background: #FFFBF0;
    border-radius: 50%;
    border: 2px solid #eecfa1;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hiogi-text {
    font-size: 2.25rem;
    font-weight: 900;
    color: #881337;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: opacity 0.15s;
}

.hiogi-hint {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: #881337;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
    background: rgba(255, 251, 240, 0.95);
    padding: 2px 8px;
    border-radius: 4px;
}

/* 注連繩區塊 */
.shimenawa-section {
    position: relative;
    margin-top: 0.5rem;
}

/* 注連繩 */
.shimenawa-rope {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 85%;
    height: 14px;
    background: linear-gradient(180deg, #8d6e63 0%, #5d4037 50%, #4e342e 100%);
    border-radius: 7px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
    z-index: 0;
}

.shimenawa-rope::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 5%;
    right: 5%;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    border-radius: 3px;
}

/* 紙垂區塊 */
.shide-section {
    position: relative;
    margin-top: 0.5rem;
}

/* 紙垂飄動動畫 */
@keyframes shide-float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-3px) rotate(0.5deg);
    }
}

/* 紙垂按鈕 - 自然風場 */
.shide-tab {
    background: transparent !important;
    border: none;
    cursor: pointer;
    padding: 0;
    position: relative;
    transform-origin: top center;
    transition: all 0.2s ease-out;
    animation: shide-float 3s ease-in-out infinite;
}

/* 錯落的動畫時間 - 製造自然感 */
.shide-tab:nth-child(1) { animation-duration: 3s; }
.shide-tab:nth-child(2) { animation-duration: 3.5s; animation-delay: 0.5s; }
.shide-tab:nth-child(3) { animation-duration: 2.8s; animation-delay: 0.2s; }
.shide-tab:nth-child(4) { animation-duration: 3.2s; animation-delay: 0.7s; }

/* Hover: 暫停飄動，上浮發光 */
.shide-tab:hover {
    background: transparent !important;
    outline: none;
    animation-play-state: paused;
    transform: translateY(-4px) scale(1.05);
}

/* 各顏色紙垂的 Hover 光暈 */
.shide-tab[data-color="gold"]:hover .shide-paper {
    filter: sepia(80%) saturate(400%) brightness(125%) hue-rotate(5deg)
            drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
}
.shide-tab[data-color="white"]:hover .shide-paper {
    filter: brightness(150%) grayscale(20%)
            drop-shadow(0 0 15px rgba(255, 255, 255, 0.9));
}
.shide-tab[data-color="red"]:hover .shide-paper {
    filter: sepia(100%) saturate(600%) hue-rotate(320deg) brightness(90%)
            drop-shadow(0 0 8px rgba(255, 69, 0, 0.6));
}
.shide-tab[data-color="green"]:hover .shide-paper {
    filter: sepia(100%) saturate(400%) hue-rotate(80deg) brightness(90%)
            drop-shadow(0 0 8px rgba(50, 205, 50, 0.6));
}

/* Active: 拉鈴祈願 - 往下拉扯 */
.shide-tab:active {
    animation-play-state: paused;
    transform: translateY(1rem) scale(0.95) !important;
    transition-duration: 0.1s;
}

/* Focus 狀態 */
.shide-tab:focus {
    background: transparent !important;
    outline: none;
}

/* 選中狀態: 神力加持 - 強光發光 + 微幅下沉 */
.shide-tab.active {
    animation-play-state: paused;
    transform: translateY(0.5rem) scale(1.1);
}

.shide-tab.active .shide-paper {
    filter: brightness(1.5) grayscale(20%) 
            drop-shadow(0 0 15px rgba(255, 255, 255, 0.9));
}

.shide-tab.active:hover {
    transform: translateY(0.3rem) scale(1.12);
}

/* 繪馬內容區 - 有紅色柱子邊框 */
.ema-content-area {
    position: relative;
    z-index: 10;
    background: rgba(15, 23, 42, 0.95);
    border-left: 36px solid #C92A2A;
    border-right: 36px solid #C92A2A;
    border-radius: 0 0 8px 8px;
    padding: 6rem 2rem 3rem;
    min-height: 600px;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);
}


/* ========================================
   舊版樣式保留（相容性）
   ======================================== */

.zukan-page { display: none; }
.zukan-container { display: none; }
.zukan-corner-tl, .zukan-corner-tr, .zukan-corner-bl, .zukan-corner-br { display: none; }
.zukan-stitching { display: none; }
.zukan-cover { display: none; }

/* 第三層：深靛藍內頁 */
.zukan-inner {
    background: #0B101B;
    margin: 0 1rem 1rem;
    border-radius: 0.25rem;
    padding: 1.5rem;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
    border: 1px solid #1e293b;
    min-height: 500px;
    position: relative;
}

/* 內頁網格紋理（和室格子風） */
.zukan-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: 
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
    opacity: 0.5;
}

@media (min-width: 768px) {
    .zukan-inner {
        padding: 2rem;
    }
}

/* ========================================
   頁面標題
   ======================================== */

/* 書皮標題 - 神社風格 */
.zukan-header {
    text-align: center;
    padding: 0;
    margin: 0;
}

.zukan-icon {
    display: inline-block;
    position: relative;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px rgba(234, 179, 8, 0.5));
}

/* 鳥居圖標光暈 */
.zukan-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(234, 179, 8, 0.2);
    border-radius: 50%;
    filter: blur(15px);
    z-index: -1;
}

.zukan-header h1 {
    font-size: 2.25rem;
    font-family: serif;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: #e2e8f0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 0.5rem;
}

.zukan-header p {
    color: #64748b;
    font-size: 0.7rem;
    font-family: serif;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* ========================================
   未登入提示
   ======================================== */

.zukan-login-prompt {
    padding: 3rem 2rem;
    padding-top: 8rem;
    text-align: center;
    position: relative;
    z-index: 10;
}

.zukan-login-prompt h2 {
    font-size: 1.25rem;
    color: #d6d3d1;
    margin-bottom: 1rem;
}

.zukan-login-prompt p {
    color: #78716c;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.zukan-login-prompt .btn-login {
    display: inline-block;
    padding: 0.875rem 2.5rem;
    background: linear-gradient(135deg, #eab308 0%, #ca8a04 100%);
    color: #1c1917;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(234, 179, 8, 0.3);
}

.zukan-login-prompt .btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(234, 179, 8, 0.5);
}

/* ========================================
   進度條
   ======================================== */

/* 進度條 - 放在書皮標題下方 */
.zukan-progress {
    margin: 1.5rem auto 0;
    max-width: 280px;
}

.progress-header {
    display: none;
}

.progress-label {
    display: none;
}

.progress-stats {
    display: none;
}

.progress-stats .collected {
    color: #f472b6;
}

.progress-stats .mastered {
    color: #facc15;
}

.progress-bar {
    height: 8px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 9999px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
}

.progress-bar::before {
    content: '0%';
    position: absolute;
    left: -2rem;
    font-size: 0.65rem;
    color: rgba(148, 163, 184, 0.7);
    font-family: monospace;
}

.progress-bar::after {
    content: '100%';
    position: absolute;
    right: -2.5rem;
    font-size: 0.65rem;
    color: #eab308;
    font-family: monospace;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #eab308 0%, #fde047 100%);
    border-radius: 9999px;
    transition: width 1s ease-out;
}

/* ========================================
   類型切換標籤
   ======================================== */

/* 標籤切換 - 深色內頁風格 */
.zukan-tabs {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    position: relative;
    z-index: 10;
}

.tab-btn {
    background: transparent;
    border: 1px solid #475569;
    padding: 0.5rem 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: serif;
    letter-spacing: 0.15em;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 2px;
}

.tab-btn:hover {
    color: #94a3b8;
    border-color: #64748b;
}

/* 激活狀態：鳥居朱紅色 */
.tab-btn.active {
    background: #b91c1c;
    color: #ffffff;
    border-color: rgba(248, 113, 113, 0.3);
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.4);
}

/* ========================================
   神社導航組件 (Shrine Header)
   ======================================== */

.shrine-header {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto 2rem;
    padding-top: 1rem;
    text-align: center;
    z-index: 30;
}

/* 檜扇 - 平/片假名切換 */
.hiogi-container {
    position: relative;
    z-index: 20;
    display: inline-block;
    cursor: pointer;
}

.hiogi-fan {
    width: 160px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: transform 0.3s;
}

.hiogi-container:hover .hiogi-fan {
    transform: scale(1.05);
}

.hiogi-container:active .hiogi-fan {
    transform: scaleX(0.1);
}

.hiogi-text {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 900;
    color: #881337;
    text-shadow: 0 2px 0 rgba(255, 255, 255, 0.5);
    font-family: serif;
    pointer-events: none;
    transition: opacity 0.15s;
}

.hiogi-hint {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: rgba(250, 204, 21, 0.7);
    white-space: nowrap;
    font-family: serif;
    opacity: 0;
    transition: opacity 0.3s;
}

.hiogi-container:hover .hiogi-hint {
    opacity: 1;
}

/* 注連繩 */
.shimenawa-rope {
    position: absolute;
    top: 55%;
    left: 0;
    width: 100%;
    height: 12px;
    background: linear-gradient(180deg, #8d6e63 0%, #5d4037 50%, #4e342e 100%);
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    z-index: 0;
}

.shimenawa-rope::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent 10%, rgba(255,255,255,0.2) 50%, transparent 90%);
    border-radius: 3px;
}

/* 紙垂 Tabs */
.shide-tabs {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding-top: 0.5rem;
}

.shide-tab {
    position: relative;
    width: 55px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    transition: transform 0.3s;
}

.shide-tab:hover {
    transform: translateY(-6px);
}

.shide-tab.active {
    transform: translateY(-10px);
}

.shide-paper {
    width: 100%;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
    transition: filter 0.3s;
}

/* 紙垂顏色 - CSS 濾鏡魔法 */
/* 金色 (全部) */
.shide-tab[data-color="gold"] .shide-paper {
    filter: sepia(80%) saturate(400%) hue-rotate(5deg) brightness(125%)
            drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}
.shide-tab[data-color="gold"].active .shide-paper {
    filter: sepia(80%) saturate(500%) hue-rotate(5deg) brightness(130%)
            drop-shadow(0 0 15px rgba(250, 204, 21, 0.7));
}

/* 白色 (清音) */
.shide-tab[data-color="white"] .shide-paper {
    filter: brightness(150%) grayscale(20%) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}
.shide-tab[data-color="white"].active .shide-paper {
    filter: brightness(160%) grayscale(10%) drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
}

/* 紅色 (濁音) */
.shide-tab[data-color="red"] .shide-paper {
    filter: sepia(100%) saturate(600%) hue-rotate(320deg) brightness(90%)
            drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}
.shide-tab[data-color="red"].active .shide-paper {
    filter: sepia(100%) saturate(700%) hue-rotate(320deg) brightness(100%)
            drop-shadow(0 0 15px rgba(239, 68, 68, 0.7));
}

/* 綠色 (拗音) */
.shide-tab[data-color="green"] .shide-paper {
    filter: sepia(100%) saturate(400%) hue-rotate(80deg) brightness(90%)
            drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}
.shide-tab[data-color="green"].active .shide-paper {
    filter: sepia(100%) saturate(500%) hue-rotate(80deg) brightness(100%)
            drop-shadow(0 0 15px rgba(34, 197, 94, 0.7));
}

/* 紙垂文字 - 毛筆書法字體 + 濃墨色 */
.shide-text {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    writing-mode: vertical-rl;
    font-family: 'Yuji Syuku', serif;
    text-orientation: upright;
    font-size: 1.5rem;
    letter-spacing: 0.1em;
    pointer-events: none;
    user-select: none;
}

/* 所有紙垂統一使用濃墨色 + 微光暈 */
.shide-tab .shide-text { 
    color: #1c1917;
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.6);
}

/* 白紙 - 光暈稍強 */
.shide-tab[data-color="white"] .shide-text { 
    text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.8);
}

/* ========================================
   響應式 - 柱子間距版
   ======================================== */

/* 手機版 */
@media (max-width: 640px) {
    .torii-shrine-container {
        margin-top: 5rem;
    }
    
    .torii-header {
        top: -80px;
        width: 130%;
    }
    
    .shrine-nav {
        top: -60px;
    }
    
    .hiogi-fan {
        width: 140px;
    }
    
    .hiogi-text-ink {
        font-size: 3.5rem;
        text-shadow: 
            2px 0px 0px #FFFBF0, -2px 0px 0px #FFFBF0, 
            0px 2px 0px #FFFBF0, 0px -2px 0px #FFFBF0, 
            1px 1px 0px #FFFBF0, -1px -1px 0px #FFFBF0, 
            1px -1px 0px #FFFBF0, -1px 1px 0px #FFFBF0,
            0 3px 10px rgba(0,0,0,0.3);
    }
    
    .shide-tab {
        width: 40px;
    }
    
    .shide-text {
        font-size: 1.5rem;
    }
    
    .shide-tabs {
        gap: 0.5rem;
    }
    
    .ema-content-area {
        border-left-width: 20px;
        border-right-width: 20px;
        padding: 4rem 1rem 2rem;
    }
}

/* 平板 */
@media (min-width: 768px) {
    .torii-header {
        width: 126%;
    }
    
    .hiogi-fan {
        width: 180px;
    }
    
    .hiogi-text-ink {
        font-size: 4rem;
    }
    
    .shide-tab {
        width: 50px;
    }
    
    .shide-tabs {
        gap: 1.5rem;
    }
    
    .shide-text {
        font-size: 1.5rem;
    }
    
    .ema-content-area {
        border-left-width: 30px;
        border-right-width: 30px;
    }
}

/* 桌面 */
@media (min-width: 1024px) {
    .hiogi-fan {
        width: 200px;
    }
    
    .hiogi-text-ink {
        font-size: 5rem;
    }
    
    .shide-tab {
        width: 55px;
    }
    
    .ema-content-area {
        border-left-width: 36px;
        border-right-width: 36px;
    }
    
    .shide-tabs {
        gap: 2rem;
    }
}

/* ========================================
   圖鑑區塊
   ======================================== */

/* 區塊 - 深色內頁風格 */
.zukan-section {
    margin-bottom: 2.5rem;
    position: relative;
    z-index: 10;
    transition: opacity 0.3s, transform 0.3s;
}

/* 區塊隱藏狀態 */
.zukan-section.hidden {
    display: none;
}

/* 繪馬掉落/飛入動畫 */
@keyframes ema-drop-in {
    0% {
        opacity: 0;
        transform: translateY(-30px) rotate(-5deg);
    }
    60% {
        transform: translateY(5px) rotate(2deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) rotate(0);
    }
}

@keyframes ema-drop-out {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(30px);
    }
}

.zukan-section.animating-in .ema-card {
    animation: ema-drop-in 0.4s ease-out forwards;
}

.zukan-section.animating-out .ema-card {
    animation: ema-drop-out 0.25s ease-in forwards;
}

/* 錯開動畫延遲 */
.zukan-section.animating-in .ema-card:nth-child(1) { animation-delay: 0ms; }
.zukan-section.animating-in .ema-card:nth-child(2) { animation-delay: 20ms; }
.zukan-section.animating-in .ema-card:nth-child(3) { animation-delay: 40ms; }
.zukan-section.animating-in .ema-card:nth-child(4) { animation-delay: 60ms; }
.zukan-section.animating-in .ema-card:nth-child(5) { animation-delay: 80ms; }
.zukan-section.animating-in .ema-card:nth-child(6) { animation-delay: 100ms; }
.zukan-section.animating-in .ema-card:nth-child(7) { animation-delay: 120ms; }
.zukan-section.animating-in .ema-card:nth-child(8) { animation-delay: 140ms; }
.zukan-section.animating-in .ema-card:nth-child(9) { animation-delay: 160ms; }
.zukan-section.animating-in .ema-card:nth-child(10) { animation-delay: 180ms; }

.section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.section-title {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 600;
    font-family: serif;
}

.section-count {
    font-size: 0.7rem;
    color: #64748b;
    font-weight: 500;
}

/* ========================================
   圖鑑網格 - 繪馬掛牆風格（放大版）
   ======================================== */

/* 清音/濁音 Grid - 5 列 (經典五十音順序) */
.zukan-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    padding: 0.5rem;
    max-width: 600px;
    margin: 0 auto;
}

@media (min-width: 640px) {
    .zukan-grid {
        gap: 1.25rem;
        max-width: 700px;
    }
}

@media (min-width: 1024px) {
    .zukan-grid {
        gap: 1.5rem;
        max-width: 800px;
    }
}

/* 拗音 Grid - 3 列 (きゃきゅきょ 一組) */
#grid-youon {
    grid-template-columns: repeat(3, 1fr);
    max-width: 400px;
}

@media (min-width: 640px) {
    #grid-youon {
        grid-template-columns: repeat(6, 1fr);
        max-width: 700px;
    }
}

@media (min-width: 1024px) {
    #grid-youon {
        max-width: 800px;
    }
}

/* ========================================
   繪馬卡片容器
   ======================================== */

.ema-card {
    position: relative;
    padding-top: 12px;
}

/* 掛繩 - 未解鎖用暗色 */
.ema-string {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 12px;
    background: #1e293b;
    border-radius: 3px;
    z-index: 0;
}

/* ========================================
   格子 - 未解鎖 (Locked) - 凹槽影子
   ======================================== */

.zukan-cell {
    aspect-ratio: 4/5;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: all 0.2s;
    position: relative;
    /* 完全透明背景 */
    background: transparent;
    border: none;
    box-shadow: none;
}

/* 未解鎖的繪馬剪影 */
.zukan-cell .ema-empty-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* 變成深灰色凹槽影子 */
    opacity: 0.25;
    filter: grayscale(100%) brightness(0.4) contrast(1.2);
    pointer-events: none;
}

.zukan-cell .cell-kana {
    position: relative;
    z-index: 2;
    margin-top: 20%;
    font-size: 1.75rem;
    font-weight: 700;
    font-family: serif;
    /* 石刻文字 - 像是刻在木頭深處，稍微亮一點增加可讀性 */
    color: #64748b;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8);
    transition: all 0.2s;
    user-select: none;
}

@media (min-width: 640px) {
    .zukan-cell .cell-kana {
        font-size: 2rem;
    }
}

@media (min-width: 1024px) {
    .zukan-cell .cell-kana {
        font-size: 2.25rem;
    }
}

.zukan-cell .cell-romaji {
    display: none;
}

/* 未解鎖格子的 hover 效果 */
.zukan-cell:not(.practiced):not(.mastered):hover .cell-kana {
    color: #475569;
}

/* ========================================
   格子 - 已獲得 (Collected) - 繪馬圖片版
   ======================================== */

/* 微風動畫 - 極其緩慢、角度很小 */
@keyframes shrine-wind {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(1.5deg); }
    75% { transform: rotate(-1.5deg); }
    100% { transform: rotate(0deg); }
}

/* 手撥動動畫 - 快速、幅度大、有彈性 */
@keyframes hand-push {
    0% { transform: rotate(0deg) scale(1); }
    15% { transform: rotate(-12deg) scale(1.05); }
    35% { transform: rotate(10deg) scale(1.08); }
    55% { transform: rotate(-5deg) scale(1.05); }
    75% { transform: rotate(3deg) scale(1.02); }
    100% { transform: rotate(0deg) scale(1); }
}

/* 已獲得的繪馬容器 */
.ema-card:has(.practiced) {
    padding-top: 0;
}

/* 隱藏掛繩（圖片自帶） */
.ema-card:has(.practiced) .ema-string {
    display: none;
}

.zukan-cell.practiced {
    /* 完全透明容器 - 強制覆蓋 */
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    cursor: pointer;
    aspect-ratio: 4/5;
    position: relative;
    /* 從頂部為支點擺動 */
    transform-origin: top center;
    /* 常態微風動畫 - 由 JS 設定隨機延遲和持續時間 */
    animation: shrine-wind var(--wind-duration, 4s) infinite ease-in-out;
    animation-delay: var(--wind-delay, 0s);
}

/* 底部陰影 */
.zukan-cell.practiced::before {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 66%;
    height: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    filter: blur(6px);
    transition: all 0.3s;
    z-index: 0;
}

/* Hover 時：手撥動效果 */
.zukan-cell.practiced:hover {
    animation: hand-push 0.8s ease-in-out;
    z-index: 20;
}

.zukan-cell.practiced:hover::before {
    transform: translateX(-50%) scale(0.75);
    opacity: 0.3;
}

/* ========================================
   普通繪馬 - 3D 翻轉效果
   ======================================== */

.ema-card:has(.practiced) {
    perspective: 1000px;
}

.zukan-cell.practiced {
    transform-style: preserve-3d;
}

.zukan-cell.practiced.flipped {
    animation: shrine-wind-flipped var(--wind-duration, 4s) infinite ease-in-out;
    animation-delay: var(--wind-delay, 0s);
}

/* 翻轉後的微風動畫（基礎 180 度 + 擺動） */
@keyframes shrine-wind-flipped {
    0%, 100% { transform: rotateY(180deg) rotate(-1.5deg); }
    50% { transform: rotateY(180deg) rotate(1.5deg); }
}

/* 繪馬正面 */
.zukan-cell.practiced .ema-front {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.zukan-cell.practiced .ema-front .ema-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.zukan-cell.practiced .ema-front .cell-kana {
    position: relative;
    z-index: 2;
    margin-top: 25%;
}

/* 繪馬背面 - 鏡像圖片 */
.zukan-cell.practiced .ema-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.zukan-cell.practiced .ema-back .ema-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    /* 左右鏡像 */
    transform: scaleX(-1);
}

.ema-back-romaji {
    position: relative;
    z-index: 2;
    margin-top: 25%;
    font-size: 1.75rem;
    font-weight: 700;
    color: #78350f;
    font-family: serif;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

@media (min-width: 640px) {
    .ema-back-romaji {
        font-size: 2rem;
    }
}

@media (min-width: 1024px) {
    .ema-back-romaji {
        font-size: 2.25rem;
    }
}

/* 繪馬背景圖 - 撐滿格子 */
.zukan-cell.practiced .ema-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    z-index: 1;
}

/* 文字定位 - 往下推到繪馬書寫區（視覺中心） */
.zukan-cell.practiced .cell-kana {
    color: #3e2723;
    font-size: 2rem;
    font-weight: 700;
    font-family: serif;
    position: relative;
    z-index: 2;
    /* 往下推到書寫區，用百分比適應不同尺寸 */
    margin-top: 25%;
    mix-blend-mode: multiply;
    opacity: 0.9;
}

@media (min-width: 640px) {
    .zukan-cell.practiced .cell-kana {
        font-size: 2.25rem;
    }
}

@media (min-width: 1024px) {
    .zukan-cell.practiced .cell-kana {
        font-size: 2.5rem;
    }
}

.zukan-cell.practiced .cell-romaji {
    display: none;
}

/* 移除偽元素 after */
.zukan-cell.practiced::after {
    display: none;
}

/* ========================================
   格子 - 已精通 (Mastered) - 黑金繪馬圖片版
   ======================================== */

/* 已精通的繪馬容器 */
.ema-card:has(.mastered) {
    padding-top: 0;
}

/* 隱藏掛繩（圖片自帶） */
.ema-card:has(.mastered) .ema-string {
    display: none;
}

.zukan-cell.mastered {
    /* 完全透明容器 - 強制覆蓋所有背景樣式 */
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    cursor: pointer;
    aspect-ratio: 4/5;
    position: relative;
    overflow: visible;
    /* 從頂部為支點擺動 */
    transform-origin: top center;
    /* 常態微風動畫 */
    animation: shrine-wind var(--wind-duration, 4s) infinite ease-in-out;
    animation-delay: var(--wind-delay, 0s);
    transition: filter 0.5s;
}

/* 移除方框光暈，改用圖片的 drop-shadow */
.zukan-cell.mastered::before {
    display: none;
}

/* Hover 時：手撥動效果 */
.zukan-cell.mastered:hover {
    animation: hand-push 0.8s ease-in-out;
    z-index: 20;
}

/* 黑金繪馬背景圖 - 沿著形狀發光 */
.zukan-cell.mastered .ema-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* drop-shadow 會沿著 PNG 透明邊緣發光 */
    filter: drop-shadow(0 0 12px rgba(250, 204, 21, 0.5))
            drop-shadow(0 0 25px rgba(250, 204, 21, 0.3))
            drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    z-index: 1;
    transition: filter 0.5s;
}

/* Hover 時加強發光 */
.zukan-cell.mastered:hover .ema-bg {
    filter: drop-shadow(0 0 20px rgba(250, 204, 21, 0.8))
            drop-shadow(0 0 40px rgba(250, 204, 21, 0.5))
            drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}

/* 移除偽元素 */
.zukan-cell.mastered::after {
    display: none;
}

/* ========================================
   封印繪馬 (Sealed) - 待開光狀態
   ======================================== */

/* 封印繪馬容器 */
.ema-card:has(.sealed) {
    padding-top: 0;
}

.ema-card:has(.sealed) .ema-string {
    display: none;
}

.zukan-cell.sealed {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    cursor: pointer;
    aspect-ratio: 4/5;
    position: relative;
    overflow: visible;
    transform-origin: top center;
    /* 脈動動畫 - 提示待開光 */
    animation: sealed-pulse 2s ease-in-out infinite;
}

/* 封印脈動動畫 */
@keyframes sealed-pulse {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.2);
    }
}

/* 封印繪馬圖片 */
.zukan-cell.sealed .ema-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.6))
            drop-shadow(0 0 30px rgba(255, 215, 0, 0.4))
            drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
    z-index: 1;
    transition: filter 0.3s ease;
}

/* 封印狀態 Hover：金光加強 */
.zukan-cell.sealed:hover {
    animation: none;
}

.zukan-cell.sealed:hover .ema-bg {
    filter: drop-shadow(0 0 25px rgba(255, 215, 0, 0.9))
            drop-shadow(0 0 50px rgba(255, 215, 0, 0.7))
            drop-shadow(0 0 80px rgba(255, 215, 0, 0.5))
            drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

/* 符咒 */
.seal-ofuda {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 36px;
    background: linear-gradient(180deg, #fef3c7 0%, #fcd34d 100%);
    border: 1px solid #b45309;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 900;
    color: #7c2d12;
    font-family: serif;
    z-index: 5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    /* 輕微擺動 */
    animation: ofuda-sway 3s ease-in-out infinite;
}

@keyframes ofuda-sway {
    0%, 100% { transform: translateX(-50%) rotate(-2deg); }
    50% { transform: translateX(-50%) rotate(2deg); }
}

/* 符咒燃燒動畫 */
.seal-ofuda.burning {
    animation: ofuda-burn 0.8s ease-out forwards !important;
}

@keyframes ofuda-burn {
    0% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
        filter: brightness(1);
    }
    30% {
        filter: brightness(2) sepia(1);
        transform: translateX(-50%) scale(1.1);
    }
    60% {
        opacity: 0.5;
        filter: brightness(3) sepia(1) saturate(2);
        transform: translateX(-50%) scale(0.8) rotate(10deg);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) scale(0) rotate(30deg);
        filter: brightness(5);
    }
}

/* 封印繪馬文字 */
.zukan-cell.sealed .cell-kana {
    font-size: 2rem;
    font-family: serif;
    font-weight: 700;
    color: #78716c;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 3;
    margin-top: 35%;
    opacity: 0.7;
}

/* 開光完成瞬間的閃光 */
.zukan-cell.just-opened {
    animation: kaigen-flash 1s ease-out forwards !important;
}

@keyframes kaigen-flash {
    0% {
        filter: brightness(3);
    }
    100% {
        filter: brightness(1);
    }
}

/* ========================================
   SSR 覺醒儀式動畫
   ======================================== */

/* 蓄力抖動 - 高頻震動 */
@keyframes intense-shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.zukan-cell.mastered.rumbling {
    animation: intense-shake 0.5s cubic-bezier(.36,.07,.19,.97) both !important;
}

/* 覺醒儀式遮罩層 */
.awakening-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 100;
    pointer-events: none;
    transition: background 0.3s;
}

.awakening-overlay.active {
    background: rgba(0, 0, 0, 0.85);
    pointer-events: auto;
}

/* 聚光燈效果 */
.awakening-spotlight {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    background: radial-gradient(ellipse at center, 
        rgba(250, 204, 21, 0.3) 0%, 
        rgba(250, 204, 21, 0.1) 30%,
        transparent 70%);
    border-radius: 50%;
    z-index: 101;
    opacity: 0;
    transition: all 0.5s;
}

.awakening-spotlight.active {
    width: 500px;
    height: 500px;
    opacity: 1;
}

/* 展示中的 SSR 繪馬 */
.awakening-ema {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    z-index: 102;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.awakening-ema.active {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.awakening-ema img {
    width: 200px;
    height: auto;
    filter: drop-shadow(0 0 30px rgba(250, 204, 21, 0.8))
            drop-shadow(0 0 60px rgba(250, 204, 21, 0.5));
    animation: ssr-float 3s ease-in-out infinite;
}

@keyframes ssr-float {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-10px) rotate(2deg); }
}

.awakening-ema .awakening-kana {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -30%);
    font-size: 4rem;
    font-family: serif;
    font-weight: 700;
    color: transparent;
    background: linear-gradient(180deg, #fef08a 0%, #eab308 50%, #b45309 100%);
    -webkit-background-clip: text;
    background-clip: text;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

.awakening-ema .awakening-romaji {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.25rem;
    color: #fbbf24;
    font-family: serif;
    letter-spacing: 0.1em;
}

/* 文字定位 - 金色漸層，往下推到視覺中心 */
.zukan-cell.mastered .cell-kana {
    font-size: 2rem;
    font-family: serif;
    font-weight: 700;
    /* 金色漸層文字 */
    color: transparent;
    background: linear-gradient(180deg, #fef08a 0%, #eab308 50%, #b45309 100%);
    -webkit-background-clip: text;
    background-clip: text;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
    position: relative;
    z-index: 3;
    /* 往下推到繪馬書寫區 */
    margin-top: 25%;
}

@media (min-width: 640px) {
    .zukan-cell.mastered .cell-kana {
        font-size: 2.25rem;
    }
}

@media (min-width: 1024px) {
    .zukan-cell.mastered .cell-kana {
        font-size: 2.5rem;
    }
}

.zukan-cell.mastered .cell-romaji {
    display: none;
}

/* ========================================
   詳情 Modal - 賞玩模式
   ======================================== */

.zukan-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.zukan-modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    max-width: 320px;
    width: 90%;
    animation: modalZoomIn 0.4s ease-out;
}

@keyframes modalZoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: -3rem;
    right: 0;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    background: rgba(71, 85, 105, 0.5);
    border-radius: 50%;
    font-size: 1.5rem;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(100, 116, 139, 0.5);
    color: #f1f5f9;
}

/* 展示卡片 */
.modal-card {
    aspect-ratio: 3/4;
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* 未精通卡片 */
.modal-card.common {
    background: linear-gradient(135deg, #be185d 0%, #9d174d 100%);
    border: 2px solid rgba(244, 114, 182, 0.5);
    box-shadow: 0 20px 60px rgba(236, 72, 153, 0.4);
}

/* 精通卡片 - 黑金風格 */
.modal-card.legendary {
    background: linear-gradient(135deg, #262626 0%, #171717 50%, #0a0a0a 100%);
    border: 2px solid #eab308;
    box-shadow: 0 0 60px rgba(234, 179, 8, 0.5);
}

.modal-card.legendary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    transform: skewX(-15deg);
    animation: modalShimmer 3s infinite;
}

@keyframes modalShimmer {
    0% { left: -100%; }
    100% { left: 200%; }
}

.modal-card.legendary::after {
    content: '👑';
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    filter: drop-shadow(0 0 10px rgba(250, 204, 21, 0.8));
}

.modal-kana-char {
    font-size: 6rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.modal-card.common .modal-kana-char {
    color: #ffffff;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-card.legendary .modal-kana-char {
    color: transparent;
    background: linear-gradient(180deg, #fde047 0%, #eab308 100%);
    -webkit-background-clip: text;
    background-clip: text;
    filter: drop-shadow(0 0 15px rgba(250, 204, 21, 0.6));
}

.modal-romaji {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 0.5rem;
    position: relative;
    z-index: 1;
}

.modal-card.common .modal-romaji {
    color: rgba(255, 255, 255, 0.9);
}

.modal-card.legendary .modal-romaji {
    color: #fbbf24;
}

/* 播放按鈕 */
.modal-play-btn {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
}

.modal-card.common .modal-play-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    backdrop-filter: blur(4px);
}

.modal-card.common .modal-play-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-card.legendary .modal-play-btn {
    background: linear-gradient(135deg, #ca8a04 0%, #a16207 100%);
    color: #fef3c7;
    box-shadow: 0 0 15px rgba(202, 138, 4, 0.5);
}

.modal-card.legendary .modal-play-btn:hover {
    box-shadow: 0 0 25px rgba(202, 138, 4, 0.7);
}

/* ========================================
   響應式設計
   ======================================== */

@media (max-width: 768px) {
    .zukan-container {
        border-radius: 0.375rem;
    }
    
    .zukan-corner-tl,
    .zukan-corner-tr,
    .zukan-corner-bl,
    .zukan-corner-br {
        width: 24px;
        height: 24px;
    }
    
    .zukan-cover {
        padding: 2rem 1.5rem 1rem;
    }
    
    .zukan-inner {
        margin: 0 0.75rem 0.75rem;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .zukan-page {
        padding: 1rem 0.5rem;
    }
    
    .zukan-container {
        border-radius: 0.25rem;
        border-top-width: 6px;
        border-bottom-width: 6px;
    }
    
    .zukan-corner-tl,
    .zukan-corner-tr,
    .zukan-corner-bl,
    .zukan-corner-br {
        width: 20px;
        height: 20px;
    }
    
    .zukan-cover {
        padding: 1.5rem 1rem 0.75rem;
    }
    
    .zukan-header h1 {
        font-size: 1.5rem;
        letter-spacing: 0.2em;
    }
    
    .zukan-icon {
        font-size: 2rem;
        margin-bottom: 0.75rem;
    }
    
    .zukan-inner {
        margin: 0 0.5rem 0.5rem;
        padding: 1rem;
    }

    .zukan-grid {
        gap: 0.5rem;
        max-width: 100%;
    }
    
    #grid-youon {
        max-width: 100%;
    }

    .zukan-cell .cell-kana {
        font-size: 1.25rem;
    }
    
    .zukan-cell.practiced .cell-kana {
        font-size: 1.25rem;
    }
    
    .zukan-cell.mastered .cell-kana {
        font-size: 1.25rem;
    }

    .zukan-cell.mastered::after {
        font-size: 0.5rem;
    }

    .modal-kana-char {
        font-size: 4rem;
    }
    
    .tab-btn {
        padding: 0.4rem 1rem;
        font-size: 0.8rem;
    }
}

/* 圖鑑頁面 Footer - 統一米色背景 */
body:has(.torii-shrine-page) footer {
    background: #FFFBF0;
    border-top-color: #e8dcc8;
}

/* ========================================
   社務所入口燈籠 - 掛在鳥居右側橫樑
   ======================================== */

.office-lantern {
    position: absolute;
    right: 2%;
    top: 38%;
    z-index: 100;
    text-decoration: none;
    transform-origin: top center;
    animation: lantern-swing 4s ease-in-out infinite;
    transition: filter 0.3s ease;
    cursor: pointer;
}

.office-lantern:hover {
    filter: brightness(1.15);
    animation-play-state: paused;
}

/* 繩子 */
.lantern-rope {
    position: absolute;
    top: -80px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 85px;
    background: linear-gradient(180deg, #1f2937, #4b5563);
    border-radius: 2px;
}

.office-lantern img {
    width: 220px;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.4));
    pointer-events: auto;
}

/* 搖擺動畫 */
@keyframes lantern-swing {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(3deg); }
    75% { transform: rotate(-3deg); }
}

@media (max-width: 768px) {
    .office-lantern {
        right: -8%;
        top: 50%;
    }
    
    .office-lantern img {
        width: 70px;
    }
    
    .lantern-rope {
        height: 35px;
        top: -32px;
    }
}

/* ========================================
   開光儀式 - 全螢幕朵朵演出
   ======================================== */

.kaigen-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.kaigen-fullscreen.active {
    opacity: 1;
    pointer-events: auto;
}

.kaigen-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
}

/* 對話內容區 */
.kaigen-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    max-width: 90vw;
}

/* 朵朵大圖 */
.kaigen-duoduo {
    width: 280px;
    height: 280px;
    animation: duoduo-appear 0.5s ease-out;
}

@media (min-width: 768px) {
    .kaigen-duoduo {
        width: 350px;
        height: 350px;
    }
}

@keyframes duoduo-appear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.kaigen-duoduo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.3));
}

.kaigen-duoduo img.casting-intense {
    animation: casting-glow 0.5s ease-in-out infinite alternate;
}

@keyframes casting-glow {
    from {
        filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.3));
    }
    to {
        filter: drop-shadow(0 0 50px rgba(250, 204, 21, 0.8))
                drop-shadow(0 0 80px rgba(250, 204, 21, 0.5));
    }
}

/* 對話氣泡 */
.kaigen-bubble {
    background: white;
    border-radius: 20px;
    padding: 1.5rem 2rem;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: bubble-appear 0.4s ease-out 0.2s both;
    transition: opacity 0.3s ease;
}

@keyframes bubble-appear {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kaigen-text {
    font-family: 'Yuji Syuku', serif;
    font-size: 1.3rem;
    color: #1c1917;
    line-height: 1.6;
    min-height: 2.5rem;
}

@media (min-width: 768px) {
    .kaigen-text {
        font-size: 1.5rem;
    }
}

.kaigen-hint {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #9ca3af;
}

/* 慶祝狀態 */
.kaigen-content.celebrate .kaigen-duoduo {
    animation: celebrate-bounce 0.6s ease-out;
}

@keyframes celebrate-bounce {
    0% { transform: scale(0.5); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* 展示模式 */
.kaigen-reveal {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.kaigen-reveal.active {
    opacity: 1;
    transform: scale(1);
}

.kaigen-spotlight {
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(
        circle at center,
        rgba(250, 204, 21, 0.3) 0%,
        rgba(250, 204, 21, 0.1) 40%,
        transparent 70%
    );
    animation: spotlight-pulse 2s ease-in-out infinite;
}

@keyframes spotlight-pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
}

.kaigen-ema-display {
    position: relative;
    animation: ema-reveal 0.8s ease-out;
}

@keyframes ema-reveal {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    60% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0);
    }
}

.kaigen-ema-display img {
    width: 200px;
    height: auto;
    filter: drop-shadow(0 0 40px rgba(250, 204, 21, 0.8))
            drop-shadow(0 0 80px rgba(250, 204, 21, 0.5));
    animation: ssr-float 3s ease-in-out infinite;
}

@media (min-width: 768px) {
    .kaigen-ema-display img {
        width: 250px;
    }
}

.kaigen-ema-kana {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -30%);
    font-size: 4rem;
    font-weight: 700;
    color: transparent;
    background: linear-gradient(180deg, #fde047 0%, #d97706 100%);
    -webkit-background-clip: text;
    background-clip: text;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

@media (min-width: 768px) {
    .kaigen-ema-kana {
        font-size: 5rem;
    }
}

/* ========================================
   神社封印狀態（Q北擋路）
   ======================================== */

.shrine-locked-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 2rem;
    text-align: center;
}

.shrine-locked-avatar {
    width: 180px;
    height: 180px;
    margin-bottom: 1.5rem;
}

.shrine-locked-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.shrine-locked-dialog {
    background: linear-gradient(180deg, #fdfbf7 0%, #f5f0e8 100%);
    border: 2px solid #8B0000;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.shrine-locked-text {
    font-size: 1rem;
    line-height: 1.8;
    color: #3d3425;
    margin-bottom: 1.5rem;
    white-space: pre-line;
    font-family: 'Yuji Syuku', serif;
}

.shrine-locked-btn {
    display: inline-block;
    padding: 0.8rem 2rem;
    background: linear-gradient(135deg, #8B0000 0%, #6B0000 100%);
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(139, 0, 0, 0.3);
}

.shrine-locked-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 0, 0, 0.4);
}

/* 深色模式 */
[data-theme="dark"] .shrine-locked-dialog {
    background: linear-gradient(180deg, #2a2520 0%, #1f1a16 100%);
    border-color: #8B0000;
}

[data-theme="dark"] .shrine-locked-text {
    color: #e8e0d5;
}

/* ========================================
   前往神社 Toast
   ======================================== */
.goto-shrine-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, #8B0000 0%, #6B0000 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(139, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.goto-shrine-toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.goto-shrine-toast span {
    font-family: 'Yuji Syuku', serif;
    font-size: 1rem;
}

.goto-shrine-toast a {
    color: #fbbf24;
    text-decoration: none;
    font-weight: bold;
    padding: 0.4rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    transition: background 0.2s ease;
}

.goto-shrine-toast a:hover {
    background: rgba(255, 255, 255, 0.2);
}
