* {
    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;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-body-gradient);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh; 
    margin: 0;
    line-height: 1.5;
    overflow: hidden; 
}

.d-none {
    display: none !important;
}

.phone-container {
    max-width: 480px;
    width: 100%;
    height: 100vh;
    height: 100dvh; 
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

@media (min-width: 500px) {
    .phone-container {
        height: 90vh;
        max-height: 850px;
        border-radius: 18px;
    }
}

.header {
    padding: 12px 15px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
    flex-shrink: 0;
}

.header-branding {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

#app-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    white-space: nowrap;
}

.lang-select {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 5px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.lang-select option {
    color: black;
}

.view-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background-color: var(--bg-color);
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.menu-container {
    width: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-content: flex-start;
    padding-top: 25px; 
}

.home-info-card {
    background: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #eee;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.ganzhi-badge {
    background: var(--primary-color);
    color: white;
    padding: 3px 10px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 0.9rem;
}

.time-display {
    font-family: monospace;
    font-size: 0.9rem;
    color: #555;
    font-weight: 600;
}

.lichun-card-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 5px 0;
    flex-grow: 1;
}

.lichun-big-logo {
    width: 65px;
    height: 65px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.lichun-text-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    text-align: left;
}

.next-lichun-label {
    font-size: 0.8rem;
    color: #555;
    font-weight: 600;
    text-transform: uppercase;
}

.countdown-val {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--accent-color);
    line-height: 1.2;
}

.lichun-date-small {
    font-size: 0.8rem;
    color: #888;
    font-weight: 500;
}

#current-neptu {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(94, 53, 177, 0.3);
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
}

.menu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    position: relative;
}

.menu-card.square {
    aspect-ratio: 1 / 1;
    width: 100%;
    height: auto;
}

.menu-card:active {
    transform: scale(0.96);
}

.menu-card .emoji {
    font-size: 1.5rem;
    margin-bottom: 3px;
}

.menu-card.primary { background: linear-gradient(135deg, #667eea, #764ba2); }
.menu-card.secondary { background: linear-gradient(135deg, #ff9a9e, #fecfef); color: #c0392b; }
.menu-card.accent { background: linear-gradient(135deg, #4db6ac, #00897b); color: white; }
.menu-card.warning { background: linear-gradient(135deg, #ff9800, #f57c00); color: white; }
.menu-card.dream { background: linear-gradient(135deg, #7e57c2, #512da8); color: white; }

.game-area {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.question-text {
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 10px;
}

.sub-question-text {
    font-size: 0.9rem;
    color: #999;
    margin-top: -8px;
}

.stem-card {
    font-size: 5rem;
    font-weight: bold;
    color: var(--text-color);
    margin: 15px 0;
    animation: fadeIn 0.5s;
}

.stem-card.shishen-question {
    font-size: 3rem;
    margin: 25px 0;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
    margin-top: 10px;
}

.option-btn {
    background: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 10px;
    font-size: 1rem;
    border-radius: 9px;
    cursor: pointer;
    font-weight: 600;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-btn.hanzi-option {
    font-size: 1.4rem;
}

.option-btn.correct { background: var(--correct-color) !important; border-color: var(--correct-color) !important; color: white !important; }
.option-btn.wrong { background: var(--wrong-color) !important; border-color: var(--wrong-color) !important; color: white !important; opacity: 0.7; }

.mode-selector {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    padding: 8px;
    background: #eef;
    border-bottom: 1px solid #ddd;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
}
.mode-selector::-webkit-scrollbar { display: none; }

.mode-btn {
    padding: 6px 2px;
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    background: white;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: bold;
    white-space: nowrap;
}

.mode-btn.active {
    background: var(--primary-color);
    color: white !important;
}

.score-board {
    padding: 15px;
    text-align: center;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.glossary-tabs {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    font-weight: bold;
    color: #777;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}

.glossary-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.glossary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-top: 20px;
}

.glossary-table th, .glossary-table td {
    border: 1px solid #e0e0e0;
    padding: 10px;
    text-align: center;
}

.glossary-table th {
    background: #f5f5f5;
    color: var(--primary-color);
}

.glossary-table tr:nth-child(even) { background-color: #fafafa; }

.col-hanzi {
    font-size: 1.2rem;
    font-weight: bold;
}

.lichun-header {
    padding: 15px 10px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    text-align: center;
    flex-shrink: 0;
}

.lichun-header h3 {
    margin: 0 0 5px 0;
    color: var(--primary-color);
}

.lichun-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
}

.lichun-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
    border: 1px solid #ccc;
    background: white;
    border-radius: 15px;
    cursor: pointer;
    color: #555;
    transition: all 0.2s;
}

.lichun-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: bold;
}

.tongshu-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.nav-arrow {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #888;
}

.nav-date-display {
    font-weight: bold;
    font-size: 1.1rem;
}

.tongshu-result-container {
    position: relative;
}

.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: 250px;
    opacity: 0.08; 
}

.tongshu-compact-card {
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    margin-bottom: 15px;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: auto;
    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: #e0e0e0;
    margin: 0 10px;
}

.ts-date-section {
    align-items: center;
    min-width: 60px;
    text-align: center;
}

.ts-day-big {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    color: #333;
}

.ts-month-small {
    font-size: 0.75rem;
    color: #777;
    font-weight: 600;
    text-transform: uppercase;
}

.ts-dayname-small {
    font-size: 0.75rem;
    color: var(--primary-color);
    margin-top: 2px;
}

.ts-hanzi-section {
    align-items: center;
    min-width: 50px;
}

.ts-hanzi-char {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    line-height: 1;
}

.ts-info-section {
    flex: 1;
    align-items: flex-start;
    padding-left: 5px;
    overflow: hidden;
}

.ts-status-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
}

.ts-status-desc {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.activity-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    position: relative;
    z-index: 6;
}

.activity-col {
    background: white;
    border-radius: 12px;
    padding: 12px;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.activity-col.good { border-top: 4px solid #4caf50; }
.activity-col.bad { border-top: 4px solid #e53935; }

.act-header {
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
    font-size: 0.95rem;
    padding-bottom: 5px;
    border-bottom: 1px solid #f0f0f0;
}

.activity-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.activity-col li {
    padding: 5px 0;
    border-bottom: 1px dashed #f0f0f0;
    text-align: center;
    color: #444;
}

.activity-col li:last-child { border-bottom: none; }

.tongshu-disclaimer {
    text-align: center;
    font-size: 0.7rem;
    color: #d32f2f;
    margin-top: 20px;
    font-weight: bold;
    opacity: 0.8;
}

.javanese-info-card {
    margin-top: 15px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    font-size: 0.85rem;
}

.javanese-title {
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
}

.javanese-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px dashed #eee;
}

.javanese-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

#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; }

.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; }

.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);
}

.modal, .modal-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 100;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-content, .info-modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 15px;
    width: 85%;
    max-width: 350px;
    animation: popUpAnim 0.3s ease-out;
    position: relative;
    text-align: center;
}

.info-modal-content { text-align: left; }

.modal-close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}

.restart-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
}

.copyright {
    text-align: center;
    padding: 10px;
    font-size: 0.75rem;
    color: #888;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
    width: 100%;
}

.copyright a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes popUpAnim {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}