* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

:root {
    --primary-color: #5e35b1;
    --secondary-color: #3949ab;
    --accent-color: #00897b;
    --bg-body-gradient: linear-gradient(135deg, #1a237e, #4a148c);
    --bg-color: #f0f2f5;
    --correct-color: #4caf50;
    --wrong-color: #e74c3c;
    --text-color: #333;
    
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    
    --card-radius: 16px;
    --icon-radius: 20px;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-elegant: 0 10px 25px rgba(94, 53, 177, 0.1);
}

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; 
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-body-gradient);
    line-height: 1.5;
    color: var(--text-color);
    height: 100vh; 
    height: 100dvh; 
}

.d-none { display: none !important; }

.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #f8f9fc;
    margin: 0;
    position: relative;
    overflow: hidden;
}

.header {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    color: var(--primary-color); 
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 100;
    flex: 0 0 auto;
    width: 100%;
    height: 60px;
}

.header-branding { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; }
#app-title { font-size: 1.1rem; font-weight: 800; letter-spacing: 0.5px; color: var(--primary-color); }

.header-controls { display: flex; align-items: center; gap: 10px; }

.icon-btn {
    background: #f0f2f5;
    border: 1px solid #e1e4e8;
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    transition: all 0.2s;
}
.icon-btn:active {
    background: #e8eaf6;
    transform: scale(0.95);
}

.main-body {
    flex: 1 1 auto; 
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-y: auto; 
    overflow-x: hidden;
    scroll-behavior: smooth;
    scrollbar-width: thin; 
    scrollbar-color: rgba(94, 53, 177, 0.3) transparent;
    -webkit-overflow-scrolling: touch;
    height: 100%;
    min-height: 0;
}

.app-sidebar {
    display: contents; 
}

.sidebar-services-area {
    display: none; 
}

.mobile-only-service {
    display: flex; 
}

.app-container:has(#home-view.d-none) .app-sidebar {
    display: none;
}

.sidebar-content {
    order: 1; 
    width: 100%;
    padding: 16px 16px 0 16px;
}

.content-wrapper {
    flex: 1;
    overflow: visible; 
    padding: 16px;
    background: transparent;
    order: 2; 
}

.sidebar-footer {
    order: 3; 
    margin-top: auto;
    text-align: center;
    padding: 20px 16px 80px 16px; 
    width: 100%;
    border-top: 1px dashed rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.view-section {
    width: 100%;
    min-height: 100%;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.home-info-card {
    background: white;
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--shadow-elegant);
    border: 1px solid rgba(255,255,255,0.8);
    margin-bottom: 5px; 
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed #eee;
    padding-bottom: 10px;
    margin-bottom: 6px;
}
.info-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.info-label { font-size: 0.85rem; color: #666; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

.ganzhi-badge {
    background: #f3e5f5;
    color: #7b1fa2;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    border: 1px solid rgba(123, 31, 162, 0.1);
}

.time-display { font-family: 'Consolas', monospace; font-size: 1.1rem; color: #2c3e50; font-weight: 700; }
.weton-text { font-weight: 700; color: #2c3e50; font-size: 0.95rem; }

.lichun-card-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    background: linear-gradient(135deg, #f8f9fa, #e8eaf6);
    padding: 15px;
    border-radius: 16px;
    margin-top: 5px;
    text-align: center;
    border: 1px solid rgba(0,0,0,0.03);
}

.lichun-big-logo { width: 50px; height: 50px; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1)); }
.countdown-val {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1.2;
}
.next-lichun-label { font-size: 0.75rem; color: #888; text-transform: uppercase; font-weight: 600; }

.engine-version {
    display: inline-block; 
    font-size: 0.7rem;
    color: #999;
    margin-bottom: 8px;
    padding: 4px 10px;
    background: rgba(0,0,0,0.03);
    border-radius: 12px;
    font-weight: 600;
}
.engine-version span {
    font-family: 'Consolas', monospace;
    color: var(--primary-color);
    font-weight: 800;
    margin-left: 4px;
}

.copyright {
    text-align: center;
    font-size: 0.75rem;
    color: #888;
    line-height: 1.6;
}
.copyright a { color: var(--primary-color); font-weight: 700; text-decoration: none; opacity: 0.8; transition: opacity 0.2s; }
.copyright a:hover { opacity: 1; }

.menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px; 
    width: 100%;
    padding-bottom: 20px;
}

.menu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 6px; 
    border: 1px solid rgba(0,0,0,0.03);
    border-radius: var(--icon-radius);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-size: 0.75rem;
    font-weight: 600;
    background: #ffffff;
    color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    aspect-ratio: 1 / 1;
    width: 100%; 
    height: auto;
    min-height: 0;
    text-align: center;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.menu-card:hover { 
    transform: translateY(-5px); 
    box-shadow: 0 15px 30px rgba(94, 53, 177, 0.15);
    border-color: rgba(94, 53, 177, 0.2);
    background: #fafafa;
}

.menu-card:active { transform: scale(0.96); }

.menu-card .emoji { 
    font-size: 2.2rem !important;
    display: block; 
    margin-bottom: 8px; 
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
    transition: transform 0.3s;
}

.menu-card:hover .emoji { transform: scale(1.1); }

.menu-card span:not(.emoji) {
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
    color: #455a64; 
    font-weight: 700;
}

.menu-card.primary, .menu-card.secondary, .menu-card.accent, 
.menu-card.warning, .menu-card.dream, .menu-card.red {
    background: #ffffff;
    color: var(--primary-color);
}

.game-container, .dream-container, .glossary-container, .lichun-container, .tongshu-container {
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-elegant);
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0,0,0,0.02);
}

.mode-selector {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mode-btn {
    padding: 8px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    background: #f9f9f9;
    color: #666;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
}

.mode-btn.active { 
    background: var(--primary-color); 
    color: white !important; 
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(94, 53, 177, 0.3);
}

.game-area {
    padding: 20px;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stem-card {
    font-size: 5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #333, #666);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 20px 0;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    max-width: 500px;
}

.option-btn {
    background: white;
    border: 1px solid #e0e0e0;
    color: #555;
    padding: 16px;
    font-size: 1rem;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.option-btn:hover {
    background: #f8f9fa;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.option-btn:active { background: #f0f0f0; transform: scale(0.98); }
.option-btn.correct { background: var(--correct-color) !important; border-color: var(--correct-color) !important; color: white !important; box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4); }
.option-btn.wrong { background: var(--wrong-color) !important; border-color: var(--wrong-color) !important; color: white !important; opacity: 0.9; }

.score-board { padding: 15px; background: white; border-top: 1px solid #f0f0f0; text-align: center; font-weight: 700; font-size: 1rem; color: var(--primary-color); letter-spacing: 0.5px; }

#wuxing-image { max-width: 100%; height: auto; margin: 0 auto; display: block; }
.wuxing-svg-text { font-family: ui-sans-serif, system-ui; font-weight: 600; fill: white; text-anchor: middle; pointer-events: none; }
.wuxing-svg-text-title { font-size: 20px; }
.wuxing-svg-text-hanzi { font-size: 32px; }
.wuxing-svg-text-char { font-size: 18px; pointer-events: auto; }
.clickable-stem { cursor: pointer; transition: fill 0.2s; }
.clickable-stem:hover { fill: #ffd700; }
.clickable-wuxing { cursor: pointer; transition: opacity 0.2s; }
.clickable-wuxing:hover { opacity: 0.85; }
.clickable-neptu { cursor: pointer; font-weight: bold; color: var(--secondary-color); font-size: 1.5rem; transition: transform 0.2s; }
.clickable-neptu:hover { transform: scale(1.1); color: var(--primary-color); }
.wuxing-path-sheng { fill: none; stroke: #2E7D32; stroke-width: 3; cursor: pointer; transition: stroke-width 0.2s; }
.wuxing-path-sheng:hover { stroke-width: 5; }
.wuxing-path-kelelahan { fill: none; stroke: #9E9E9E; stroke-width: 2; cursor: pointer; transition: stroke-width 0.2s; }
.wuxing-path-kelelahan:hover { stroke-width: 4; }
.wuxing-path-ke { fill: none; stroke: #C62828; stroke-width: 2; cursor: pointer; transition: stroke-width 0.2s; }
.wuxing-path-ke:hover { stroke-width: 4; }

.dream-search-area {
    background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px);
    padding: 16px; border-bottom: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 4px 10px rgba(0,0,0,0.03); position: sticky;
    top: 0; z-index: 50; border-radius: 0 0 16px 16px; margin-bottom: 15px;
}
#dream-search-input {
    width: 100%; padding: 12px 15px; border: 1px solid #e0e0e0;
    border-radius: 12px; font-size: 1rem; margin-bottom: 12px;
    background: #f9f9f9; transition: all 0.2s;
}
#dream-search-input:focus { background: white; border-color: var(--primary-color); outline: none; box-shadow: 0 0 0 3px rgba(94, 53, 177, 0.1); }
.dream-quick-tags { display: flex; gap: 8px; margin-bottom: 5px; overflow-x: auto; padding-bottom: 5px; scrollbar-width: none; }
.dream-quick-tags button {
    background: #f0f2f5; border: none; padding: 8px 16px;
    border-radius: 20px; font-size: 0.8rem; cursor: pointer; color: #555;
    white-space: nowrap; font-weight: 600;
}
.dream-quick-tags button:hover { background: var(--primary-color); color: white; }
.dream-item-card {
    background: white; border-radius: 16px; padding: 20px;
    margin-bottom: 16px; box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.03); border-left: 5px solid var(--primary-color);
}
.dream-card-header { display: flex; justify-content: space-between; margin-bottom: 10px; border-bottom: 1px dashed #eee; padding-bottom: 8px; }
.dream-title { font-weight: 800; font-size: 1.05rem; color: #333; }
.dream-num-badge {
    background: linear-gradient(135deg, #5e35b1, #3949ab); color: white;
    font-size: 0.8rem; font-weight: 700; padding: 4px 10px; border-radius: 8px; margin-left: 8px;
}
.dream-meaning { color: #555; line-height: 1.6; text-align: justify; font-size: 0.95rem; }

.tongshu-container { padding: 16px; background: #fff; border-radius: var(--card-radius); }
.tongshu-nav-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; color: var(--primary-color); padding: 12px;
    background: #f8f9fa; border-radius: 12px;
}
.nav-arrow { background: white; border: 1px solid #eee; width: 32px; height: 32px; border-radius: 50%; display:flex; align-items:center; justify-content:center; font-size: 1.2rem; cursor: pointer; color: var(--primary-color); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.nav-date-display { font-weight: 800; font-size: 1.1rem; color: #333; }
.tongshu-result-container { position: relative; margin-top: 10px; }
.tongshu-watermark {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 50; pointer-events: none; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
}
.tongshu-watermark img { width: 200px; opacity: 0.05; }
.tongshu-compact-card {
    background: white; border-radius: 20px; padding: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04); margin-bottom: 20px;
    border: 1px solid #f0f0f0; display: flex; align-items: center;
    justify-content: space-between; min-height: 100px;
    position: relative; z-index: 6;
}
.ts-section { display: flex; flex-direction: column; justify-content: center; }
.ts-divider { width: 1px; min-height: 60px; background-color: #eee; margin: 0 12px; }
.ts-date-section { align-items: center; min-width: 60px; text-align: center; }
.ts-day-big { font-size: 2.2rem; font-weight: 800; line-height: 1; color: var(--primary-color); }
.ts-month-small { font-size: 0.8rem; color: #8e8e93; font-weight: 700; text-transform: uppercase; margin-bottom: 2px; }
.ts-dayname-small { font-size: 0.75rem; color: #555; background: #eee; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.ts-hanzi-section { align-items: center; min-width: 50px; }
.ts-hanzi-char { font-size: 2rem; font-weight: bold; color: #333; line-height: 1; }
.ts-info-section { flex: 1; align-items: flex-start; padding-left: 8px; overflow: hidden; }
.ts-status-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; white-space: nowrap; color: #222; }
.ts-status-desc { font-size: 0.9rem; color: #666; line-height: 1.4; }
.activity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; position: relative; z-index: 6; margin-top: 15px; }
.activity-col { background: white; border-radius: 16px; padding: 12px; font-size: 0.85rem; box-shadow: 0 2px 8px rgba(0,0,0,0.03); border: 1px solid #eee; }
.activity-col.good { border-top: 4px solid #4caf50; }
.activity-col.bad { border-top: 4px solid #e53935; }
.act-header { font-weight: 800; margin-bottom: 10px; text-align: center; font-size: 0.95rem; padding-bottom: 6px; border-bottom: 1px solid #eee; letter-spacing: 0.5px; }
.activity-col ul { list-style: none; padding: 0; margin: 0; }
.activity-col li { padding: 6px 0; border-bottom: 1px dashed #f0f0f0; text-align: center; color: #555; }
.activity-col li:last-child { border-bottom: none; }
.javanese-info-card { margin-top: 20px; background: #fff; border: 1px solid #eee; border-radius: 16px; padding: 20px; font-size: 0.9rem; box-shadow: var(--shadow-soft); }
.javanese-title { font-weight: 800; color: var(--primary-color); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #eee; text-align: center; }
.javanese-row { display: flex; justify-content: space-between; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px dashed #f5f5f5; }
.javanese-row:last-child { border-bottom: none; margin-bottom: 0; }
.tongshu-disclaimer { text-align: center; font-size: 0.7rem; color: #999; margin-top: 20px; font-weight: 600; }

.lichun-header { padding: 20px; background: white; border-bottom: 1px solid #f0f0f0; text-align: center; flex-shrink: 0; }
.lichun-header h3 { margin: 0 0 6px 0; color: #333; font-size: 1.2rem; font-weight: 800; }
.lichun-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 15px; }
.lichun-btn { padding: 8px 16px; font-size: 0.85rem; border: none; background: #f0f2f5; border-radius: 20px; cursor: pointer; color: #555; transition: all 0.2s; font-weight: 600; }
.lichun-btn:hover { background: #e0e0e0; }
.lichun-btn.active { background: var(--primary-color); color: white; box-shadow: 0 4px 10px rgba(94, 53, 177, 0.3); }

.glossary-container, .lichun-container { background: white; border-radius: var(--card-radius); overflow: hidden; height: 100%; display: flex; flex-direction: column; }
.glossary-tabs { display: flex; background: white; border-bottom: 1px solid #eee; }
.tab-btn { flex: 1; padding: 16px; border: none; background: none; font-weight: 700; color: #999; cursor: pointer; font-size: 0.95rem; transition: color 0.2s; }
.tab-btn:hover { color: var(--primary-color); }
.tab-btn.active { color: var(--primary-color); border-bottom: 3px solid var(--primary-color); background: #fafafa; }
.glossary-content { padding: 20px; overflow-y: auto; flex: 1; }
.glossary-table { width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 10px; font-size: 0.95rem; }
.glossary-table th { background: #f8f9fa; color: #333; padding: 12px; border: 1px solid #eee; text-align: left; font-weight: 700; }
.glossary-table td { padding: 12px; border: 1px solid #eee; vertical-align: top; color: #555; }
.col-hanzi { font-size: 1.4rem; font-weight: bold; color: var(--primary-color); }

.modal, .modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(255, 255, 255, 0.6); z-index: 1000; justify-content: center;
    align-items: center; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.modal[style*="block"], .modal[style*="flex"] { display: flex !important; }
.modal-content, .info-modal-content {
    background: white; padding: 30px; border-radius: 24px; text-align: center;
    max-width: 90%; width: 400px; box-shadow: 0 25px 50px rgba(0,0,0,0.1);
    position: relative; animation: zoomIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(0,0,0,0.05);
}
.restart-btn { margin-top: 25px; padding: 14px 32px; background: var(--primary-color); color: white; border: none; border-radius: 30px; font-weight: 800; cursor: pointer; font-size: 1rem; box-shadow: 0 5px 15px rgba(94, 53, 177, 0.3); transition: transform 0.2s; }
.restart-btn:hover { transform: scale(1.05); }
.modal-close-button { position: absolute; top: 15px; right: 20px; font-size: 1.8rem; cursor: pointer; color: #ccc; transition: color 0.2s; }
.modal-close-button:hover { color: #333; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes zoomIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.sidebar-service-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 8px;
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #444;
    transition: all 0.2s;
    text-align: left;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.sidebar-service-btn:hover {
    transform: translateX(4px);
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #fafafa;
}
.sidebar-service-btn.primary { border-left: 3px solid var(--primary-color); }
.sidebar-service-btn.dream { border-left: 3px solid var(--secondary-color); }

@media (min-width: 1024px) {
    .main-body {
        flex-direction: row;
        overflow: hidden; 
        position: relative;
        flex: 1;
        min-height: 0;
    }

    .app-container {
        background: #f4f6f9;
        max-width: 100%;
        margin: 0;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        box-shadow: none;
        border: none;
        overflow: hidden;
    }
    
    .header {
        background: transparent;
        color: #333;
        border-bottom: 1px solid #e0e0e0;
        border-radius: 0;
        flex-shrink: 0;
    }
    
    .icon-btn {
        background: white;
        border: 1px solid #ddd;
        color: #333;
    }
    
    #app-title { color: #333; }

    .app-sidebar {
        width: 380px;
        border-right: 1px solid #eee;
        background: white;
        overflow-y: auto; 
        height: 100%;
        display: flex !important;
        flex-direction: column;
        padding: 25px;
        padding-bottom: env(safe-area-inset-bottom, 20px);
        gap: 10px;
        order: 1;
        flex-shrink: 0;
    }

    .sidebar-content {
        order: unset;
        padding: 0;
    }

    .sidebar-footer {
        order: unset;
        margin-top: auto; 
        border-top: 1px solid #f5f5f5;
        padding: 20px 0 0 0;
        text-align: center;
        flex-shrink: 0;
    }
    
    .sidebar-services-area {
        display: block; 
        margin-top: 10px;
    }

    .mobile-only-service {
        display: none !important;
    }

    .engine-version {
        display: inline-block;
        width: auto;
        margin: 0 auto 8px auto;
    }
    
    .copyright {
        text-align: center;
    }

    .app-container:has(#home-view.d-none) .app-sidebar {
        display: flex !important;
    }

    .content-wrapper {
        padding: 30px 40px; 
        background: #fcfcfc;
        overflow-y: auto;
        height: 100%;
        border-radius: 0;
        flex: 1;
        min-height: 0;
    }

    .view-section {
        max-width: 1100px;
        margin: 0 auto;
        padding-bottom: 100px;
    }

    .menu-grid {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 12px;
        justify-content: start;
        padding-bottom: 0;
    }
    
    .menu-card {
        padding: 10px;
        font-size: 0.8rem;
        width: auto; 
        aspect-ratio: 1 / 1;
        height: auto; 
    }
    
    .menu-card .emoji {
        font-size: 1.8rem !important;
        margin-bottom: 6px;
    }
    .menu-card span:not(.emoji) {
        -webkit-line-clamp: 2; 
    }
    
    .home-info-card {
        flex-direction: column;
        gap: 15px;
        border: none;
        box-shadow: none;
        padding: 0;
        margin-bottom: 0;
        background: transparent;
    }
    
    .info-row { border-bottom: 1px solid #eee; }

    #glossary-content:has(#wuxing-image) {
        display: grid;
        grid-template-columns: 60% 35%;
        gap: 5%;
        align-items: center;
    }
    
    #glossary-content:has(#wuxing-image) > div:has(#wuxing-image),
    #glossary-content:has(#wuxing-image) > #wuxing-image {
        width: 100%;
    }

    #glossary-content:has(#wuxing-image) > table,
    #glossary-content:has(#wuxing-image) > .glossary-table {
        width: 100%;
    }

    #glossary-content:has(#wuxing-image) > h3,
    #glossary-content:has(#wuxing-image) > h2,
    #glossary-content:has(#wuxing-image) > p {
        grid-column: 1 / -1;
        margin-bottom: 15px;
    }
}

@media (min-width: 1400px) {
    .menu-grid { grid-template-columns: repeat(6, 1fr); }
    .view-section { max-width: 1300px; }
}

.bone-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(94, 53, 177, 0.1);
}

.bone-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 16px;
    line-height: 1.5;
    background-color: #ffffff;
    color: #333;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: none;
    min-height: 48px;
    display: block;
    margin-top: 8px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.bone-input::-webkit-date-and-time-value {
    text-align: left;
    min-height: 1.5em;
}

.tarot-scene {
    width: 260px;
    height: 380px;
    perspective: 1000px;
    cursor: pointer;
}

.tarot-card {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.tarot-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    border-radius: 16px;
}

.tarot-card-inner.is-flipped {
    transform: rotateY(180deg);
}

.tarot-card-front, .tarot-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0,0,0,0.1);
}

.tarot-card-front {
    background: linear-gradient(135deg, #311b92, #673ab7);
    color: white;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(255,255,255,0.1) 10%, transparent 10%),
        radial-gradient(circle at 0% 0%, rgba(255,255,255,0.1) 20%, transparent 20%),
        radial-gradient(circle at 100% 100%, rgba(255,255,255,0.1) 20%, transparent 20%);
    background-size: 20px 20px, 100% 100%, 100% 100%;
}

.tarot-card-back {
    background: white;
    color: #333;
    transform: rotateY(180deg);
    padding: 20px;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.tarot-content {
    border: 2px solid #f3e5f5;
    padding: 15px;
    height: 90%;
    width: 90%;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.tarot-board {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 15px;
    width: 100%;
    transition: all 0.3s;
    min-height: 420px;
    padding: 10px 0;
}

.tarot-board.single-mode .tarot-scene {
    width: 260px;
    height: 400px;
}

.tarot-board.spread-mode {
    flex-wrap: wrap;
    justify-content: center;
}

.tarot-board.spread-mode .tarot-slot {
    flex: 0 1 auto;
    width: 140px;
    margin-bottom: 10px;
}

.tarot-board.spread-mode .tarot-scene {
    width: 100%; 
    aspect-ratio: 2 / 3.5; 
    height: auto;
}

.tarot-board.five-cards .tarot-slot {
    width: 130px;
}

.tarot-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.tarot-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #7b1fa2;
    background: #f3e5f5;
    padding: 4px 8px;
    border-radius: 12px;
    margin-bottom: 4px;
    text-align: center;
    line-height: 1.2;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}

.card-meta-top {
    position: absolute;
    top: 8px;
    left: 8px;
}

.card-element-badge {
    font-size: 0.55rem;
    color: white;
    background: #ccc;
    padding: 2px 5px;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 700;
}

.card-icon-display { font-size: 2.5rem; margin-bottom: 5px; transition: transform 0.3s; }
.card-icon-display.reversed-icon { transform: rotate(180deg); }

.card-name-display { margin: 4px 0; font-size: 0.85rem; line-height: 1.2; text-align: center; font-weight: 700; }

.card-keywords {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    margin-top: 5px;
}

.kwd {
    font-size: 0.55rem;
    background: #f0f0f0;
    color: #666;
    padding: 2px 5px;
    border-radius: 4px;
}

#tarot-card-descriptions {
    animation: fadeIn 0.5s ease-out;
}

.iching-lines-container {
    display: flex;
    flex-direction: column-reverse; 
    gap: 12px;
    margin-bottom: 25px;
    padding: 25px;
    background: #ffffff;
    border-radius: 16px;
    width: 260px; 
    align-items: center;
    justify-content: center;
    border: 1px solid #e0e0e0;
    box-shadow: var(--shadow-soft);
    margin-left: auto;
    margin-right: auto;
}

.iching-line {
    width: 180px;
    height: 20px;
    border-radius: 4px;
    position: relative; 
    transition: all 0.3s;
    margin: 0 auto; 
}

.line-placeholder {
    width: 180px;
    height: 20px;
    background: #f0f0f0;
    border-radius: 4px;
    border: 1px dashed #ccc; 
    margin: 0 auto; 
}

.line-yang {
    background: linear-gradient(to right, #2e7d32, #43a047);
    box-shadow: 0 2px 5px rgba(46, 125, 50, 0.2);
}

.line-yin {
    display: flex;
    justify-content: space-between;
    background: transparent;
}
.line-yin::before, .line-yin::after {
    content: '';
    display: block;
    width: 42%; 
    height: 100%;
    background: linear-gradient(to right, #2e7d32, #43a047);
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(46, 125, 50, 0.2);
}

.iching-line.changing::after {
    content: '●'; 
    position: absolute;
    right: -30px; 
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #e53935; 
    animation: pulseRed 2s infinite;
}

@keyframes pulseRed {
    0% { opacity: 0.6; transform: translateY(-50%) scale(1); }
    50% { opacity: 1; transform: translateY(-50%) scale(1.2); }
    100% { opacity: 0.6; transform: translateY(-50%) scale(1); }
}

.coins-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    height: 80px;
    align-items: center;
    perspective: 1000px;
    margin-bottom: 10px;
}

.coin {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.coin-face {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    position: absolute;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.coin-face.head { 
    background: radial-gradient(circle at 30% 30%, #ffd54f, #f57f17); 
    border: 2px solid #f9a825; 
    color: #fff; 
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.coin-face.tail { 
    background: radial-gradient(circle at 30% 30%, #eeeeee, #bdbdbd); 
    border: 2px solid #9e9e9e; 
    color: #616161; 
    text-shadow: 0 1px 1px rgba(255,255,255,0.5);
}

.coin.spinning {
    animation: spinCoin 0.6s infinite linear;
}

@keyframes spinCoin {
    0% { transform: rotateX(0deg); }
    100% { transform: rotateX(720deg); } 
}

#iching-result {
    text-align: center;
}

#iching-result h4 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
    padding-bottom: 10px;
}

@media (max-width: 768px) {
    .tarot-board {
        min-height: auto;
    }

    .tarot-board.single-mode .tarot-scene {
        width: 220px;
        height: 340px;
    }

    .tarot-board.spread-mode .tarot-slot {
        width: 30%;
        max-width: 110px;
        min-width: 80px;
    }

    .tarot-board.five-cards .tarot-slot {
        width: 30%;
        max-width: 100px;
        min-width: 80px;
    }

    .tarot-board.spread-mode .card-name-display {
        font-size: 0.7rem;
        margin: 2px 0;
    }
    .tarot-board.spread-mode .card-icon-display {
        font-size: 1.8rem;
        margin-bottom: 2px;
    }
    .tarot-board.spread-mode .card-keywords {
        display: none;
    }
    .tarot-label {
        font-size: 0.65rem;
        padding: 3px 6px;
        height: 40px;
        min-height: 0;
    }
    .card-meta-top {
        top: 4px; left: 4px;
    }
    .card-element-badge {
        font-size: 0.5rem;
        padding: 1px 4px;
    }
}

@media (max-width: 360px) {
    .tarot-board.five-cards .tarot-slot {
        width: 45%;
    }
}

.iching-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05);
    animation: fadeIn 0.5s ease-out;
}

.iching-card-header {
    padding: 12px 15px;
    text-align: center;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.iching-card-body {
    padding: 20px;
    text-align: center;
}

.card-present .iching-card-header { background: #e8f5e9; color: #2e7d32; border-bottom: 1px solid #c8e6c9; }
.card-future .iching-card-header { background: #e3f2fd; color: #1565c0; border-bottom: 1px solid #bbdefb; }
.card-changing .iching-card-header { background: #fff3e0; color: #e65100; border-bottom: 1px solid #ffe0b2; }
.card-nuclear .iching-card-header { background: #f3e5f5; color: #7b1fa2; border-bottom: 1px solid #e1bee7; }

.hex-number {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 5px;
    opacity: 0.1;
    position: absolute;
    right: 15px;
    top: 15px;
    color: #000;
}

.hex-visual {
    display: flex;
    flex-direction: column-reverse; 
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 15px auto 20px auto;
    width: 100px;
}

.hex-line-segment {
    height: 8px;
    width: 100%;
    border-radius: 2px;
    flex-shrink: 0; 
}

.hex-line-yang { background: #333; }
.hex-line-yin {
    display: flex;
    justify-content: space-between;
    background: transparent;
}
.hex-line-yin::before, .hex-line-yin::after {
    content: '';
    display: block;
    width: 42%;
    height: 100%;
    background: #333;
    border-radius: 2px;
}

.hex-visual.future-style .hex-line-yang { background: #1565c0; }
.hex-visual.future-style .hex-line-yin::before, 
.hex-visual.future-style .hex-line-yin::after { background: #1565c0; }

.hex-name { font-size: 1.4rem; font-weight: 800; color: #333; margin-bottom: 4px; }
.hex-title { font-size: 1rem; color: #666; font-style: italic; margin-bottom: 15px; }
.hex-desc { font-size: 0.95rem; line-height: 1.6; color: #444; text-align: justify; }

.changing-list { list-style: none; padding: 0; margin: 0; text-align: left; }
.changing-item { 
    padding: 10px 0; 
    border-bottom: 1px dashed #ffe0b2; 
    font-size: 0.9rem; 
    color: #bf360c; 
}
.changing-item:last-child { border-bottom: none; }
.changing-label { font-weight: 800; display: block; margin-bottom: 4px; color: #e65100; }

.trigram-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 12px;
}
.trigram-box { text-align: center; }
.trigram-icon { font-size: 2rem; display: block; line-height: 1; margin: 5px 0; }
.trigram-label { font-size: 0.7rem; color: #888; text-transform: uppercase; font-weight: bold; }
.trigram-name { font-weight: 700; color: #555; font-size: 0.9rem; }

.form-group {
    margin-bottom: 20px;
    width: 100%;
}

.form-label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    color: #455a64;
    font-size: 0.9rem;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #fff3e0;
    border: 1px dashed #ffb74d;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    box-sizing: border-box;
    width: 100%;
}

.checkbox-wrapper:active {
    background: #ffe0b2;
}

.custom-checkbox {
    width: 22px;
    height: 22px;
    margin-right: 12px;
    accent-color: #e65100;
    flex-shrink: 0;
    cursor: pointer;
}

.checkbox-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: #5d4037;
}