:root {
    --bg-header-gradient: linear-gradient(to right, #5e35b1, #3949ab);
    --bg-body-gradient: linear-gradient(135deg, #1a237e, #4a148c);
    --color-primary: #5e35b1;
    --color-text-main: #333;

    --fs-header-title: 1.6rem;
    --fs-header-subtitle: 0.95rem;
    --fs-section-title: 1.3rem;
    --spacing-section: 30px;
    --spacing-gap-grid: 15px;

    --main-header-size: 1.1rem;
    --main-stem-shishen-size: 1.5rem;
    --main-stem-size: 3.8rem;
    --main-branch-size: 3.8rem;
    --main-hidden-size: 1.5rem;
    --main-other-size: 1.1rem;
    --main-label-size: 0.8rem;

    --dec-header-size: 1.0rem;
    --dec-cell-size: 1.0rem;
    --dec-stem-size: 2.2rem;
    --dec-stem-ss-size: 1rem;
    --dec-branch-size: 2.2rem;
    --dec-hidden-size: 1rem;

    --ann-header-size: 1.0rem;
    --ann-cell-size: 1.0rem;
    --ann-stem-size: 2.2rem;
    --ann-stem-ss-size: 1rem;
    --ann-branch-size: 2.2rem;
    --ann-hidden-size: 1rem;

    --mon-header-size: 0.95rem;
    --mon-cell-size: 0.95rem;
    --mon-stem-size: 2.2rem;
    --mon-stem-ss-size: 1rem;
    --mon-branch-size: 2.2rem;
    --mon-hidden-size: 1em;
    --mon-other-size: 0.9rem;

    --day-header-size: 0.9rem;
    --day-cell-size: 0.9rem;
    --day-stem-size: 1.2rem;
    --day-stem-ss-size: 0.7rem;
    --day-branch-size: 1.2rem;
    --day-hidden-size: 0.6rem;
}

@media (max-width: 1366px) {
    .luck-pillars-horizontal-table th:first-child { 
        display: none !important; 
    }
}

@media (max-width: 1024px) {
    :root {
        --main-header-size: 1.0rem;
        --main-stem-shishen-size: 1.2rem;
        --main-stem-size: 3.2rem;
        --main-branch-size: 3.2rem;
        --main-hidden-size: 1.2rem;
        --main-other-size: 1.0rem;
        --main-label-size: 0.75rem;

        --dec-header-size: 0.9rem;
        --dec-cell-size: 0.9rem;
        --dec-stem-size: 1.8rem;
        --dec-stem-ss-size: 1rem;
        --dec-branch-size: 1.8rem;
        --dec-hidden-size: 1rem;

        --ann-header-size: 0.9rem;
        --ann-cell-size: 0.9rem;
        --ann-stem-size: 1.8rem;
        --ann-stem-ss-size: 1rem;
        --ann-branch-size: 1.8rem;
        --ann-hidden-size: 1rem;

        --mon-header-size: 0.85rem;
        --mon-cell-size: 0.85rem;
        --mon-stem-size: 1.8rem;
        --mon-stem-ss-size: 0.8rem;
        --mon-branch-size: 1.8rem;
        --mon-hidden-size: 0.8rem;
        --mon-other-size: 0.75rem;

        --day-header-size: 0.8rem;
        --day-cell-size: 0.8rem;
        --day-stem-size: 1.2rem;
        --day-stem-ss-size: 0.65rem;
        --day-branch-size: 1.0rem;
        --day-hidden-size: 0.55rem;
    }
}

@media (max-width: 768px) {
    :root {
        --main-header-size: 0.8rem;
        --main-stem-shishen-size: 0.8rem;
        --main-stem-size: 2.5rem;
        --main-branch-size: 2.5rem;
        --main-hidden-size: 0.8rem;
        --main-other-size: 0.75rem;
        --main-label-size: 0.6rem;

        --dec-header-size: 0.8rem;
        --dec-cell-size: 0.8rem;
        --dec-stem-size: 1.2rem;
        --dec-stem-ss-size: 0.6rem;
        --dec-branch-size: 1.2rem;
        --dec-hidden-size: 0.5rem;

        --ann-header-size: 0.8rem;
        --ann-cell-size: 0.8rem;
        --ann-stem-size: 1.1rem;
        --ann-stem-ss-size: 0.6rem;
        --ann-branch-size: 1.1rem;
        --ann-hidden-size: 0.5rem;

        --mon-header-size: 0.75rem;
        --mon-cell-size: 0.75rem;
        --mon-stem-size: 1.0rem;
        --mon-stem-ss-size: 0.55rem;
        --mon-branch-size: 1.0rem;
        --mon-hidden-size: 0.45rem;
        --mon-other-size: 0.7rem;

        --day-header-size: 0.7rem;
        --day-cell-size: 0.7rem;
        --day-stem-size: 1.1rem;
        --day-stem-ss-size: 0.55rem;
        --day-branch-size: 1.1rem;
        --day-hidden-size: 0.45rem;
    }
}

.display-options-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90%;
    max-width: 380px;
    max-height: 80vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 3000;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    padding: 0;
    margin: 0;
    display: block !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.display-options-card.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

#options-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

#options-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.display-options-card .group-header-row {
    background-color: rgba(232, 234, 246, 0.85);
    position: sticky;
    top: 0;
    z-index: 10;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

.hidden { display: none !important; }
.font-bold { font-weight: bold; }
.text-center { text-align: center; }
.width-full { width: 100%; }
.mt-30 { margin-top: var(--spacing-section); }

#decade-section h3, #annual-section h3, #monthly-section h3, #day-section h3,
#decade-pillars-title, #annual-pillars-container h4, #monthly-pillars-container h4,
#day-pillars-container h4, #static-element-section h3,
.section-title-static { 
    display: none !important; 
}

body {
    background: var(--bg-body-gradient);
    color: var(--color-text-main);
    min-height: 100vh;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1.5;
    overflow-x: hidden;
}

body.is-fullscreen {
    padding: 0;
    background: #f0f3f5;
}

body.is-fullscreen .container {
    max-width: 100%;
    width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    min-height: 100vh;
    padding: 10px;
    aspect-ratio: auto;
    height: auto;
}

.container {
    width: 94%;             
    max-width: 500px;       
    height: auto;           
    min-height: 85vh;       
    margin: 20px auto;      
    background-color: rgba(255, 255, 255, 0.98);
    padding: 0;
    border-radius: 20px;    
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: max-width 0.3s ease, width 0.3s ease;
}

#landing-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px;
    width: 100%;
}

.intro-card {
    font-size: 0.95rem;
    line-height: 1.6;
    background: #fdfdfd;
}

.intro-content {
    padding: 20px 25px;
}

.warning-box {
    margin-top: 20px;
    padding: 15px;
    background-color: #ffebee;
    border-left: 5px solid #c62828;
    color: #b71c1c;
    border-radius: 6px;
    font-weight: bold;
    text-align: center;
    font-size: 0.9rem;
}

@media (min-width: 1025px) {
    body.landing-mode .container {
        width: 90%;
        max-width: 1000px;
        aspect-ratio: auto;
        height: auto;
        min-height: 80vh;
    }
    
    body.landing-mode #landing-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-items: stretch;
        gap: 20px;
        padding: 25px;
    }
    
    body.landing-mode .card {
        height: 100%;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
    }

    body.landing-mode #input-card form,
    body.landing-mode .intro-content {
        flex-grow: 1;
    }
}

@media (min-width: 1025px) and (min-height: 800px) {
    body:not(.landing-mode) .container {
        height: 92vh;
        width: auto;
        aspect-ratio: 9 / 16;
        max-width: none;      
        margin: auto;
    }
}

@media (min-width: 600px) and (max-width: 1024px) {
    .container {
        width: 85%;
        max-width: 750px;
        height: auto;
        min-height: 90vh;
        aspect-ratio: auto;
        margin: 30px auto;
    }
}

body.result-mode .container {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100vh !important;
    aspect-ratio: auto !important;
    display: block;
    overflow: visible;
    padding: 0;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

header {
    background: var(--bg-header-gradient);
    color: white;
    padding: 18px 22px;
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    border-radius: 0px;
}

.header-main-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 15px;
}

.header-text {
    flex-grow: 1;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.header-logo {
    width: 75px;
    height: 75px;
    object-fit: contain;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.2));
}

h1 {
    color: white;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
    font-size: var(--fs-header-title);
    font-weight: 600;
    line-height: 1.2;
}

.subtitle {
    font-size: var(--fs-header-subtitle);
    opacity: 0.9;
    max-width: 500px;
    margin: 0 auto;
}

h2 { font-size: 1.5em; margin-top: 25px; color: var(--color-primary); font-weight: 600; }
h3 { font-size: clamp(1rem, 2.5vw, var(--fs-section-title)); margin-top: 20px; color: var(--color-primary); font-weight: 600; }
h4 { font-size: clamp(0.9rem, 2vw, 1.1rem); margin: 20px 0 10px 0; color: var(--color-primary); font-weight: 600; }

#decade-pillars-title { font-size: 1.0em; }

.content {
    padding: 5px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
}

body.result-mode .content {
    display: block;
    justify-content: flex-start;
    overflow-y: visible;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 0; 
    margin-bottom: 18px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
    overflow: hidden; 
}

.card-title {
    color: var(--color-primary);
    background-color: #f8f9fa; 
    padding: 12px 20px;
    margin-bottom: 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#bazi-form {
    padding: 20px 25px;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-gap-grid);
    margin-bottom: 25px;
    text-align: left;
}

body.result-mode .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.form-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600; 
    color: #344767;
    font-size: 0.85rem;
    text-align: left;
    width: 100%;
    letter-spacing: 0.3px;
}

input, select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da; 
    border-radius: 8px; 
    font-size: 1rem; 
    transition: all 0.2s ease-in-out;
    max-width: 100%;
    background-color: #f8f9fa; 
    color: #495057;
}

input:focus, select:focus {
    background-color: #fff;
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(94, 53, 177, 0.15); 
}

input[type="date"], input[type="time"] {
    -webkit-appearance: none;
    font-family: inherit;
    color: #495057;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

button[type="submit"], #reset-button, #now-button, #new-input-button {
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    flex-grow: 1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button[type="submit"] {
    background: linear-gradient(to right, #ff9800, #f57c00);
    color: white;
    box-shadow: 0 3px 8px rgba(245, 124, 0, 0.2);
}

button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(245, 124, 0, 0.3);
    background: #f57c00;
}

#reset-button {
    background-color: #95a5a6;
    color: white;
}

#reset-button:hover { background-color: #7f8c8d; }

#now-button, #new-input-button {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: white;
    flex-grow: 0;
}

#now-button { background-color: var(--color-primary); }
#now-button:hover { background-color: #3949ab; }
#new-input-button { background-color: #00897b; }
#new-input-button:hover { background-color: #00695c; }

.main-result-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
    align-items: start;
}

.left-result-panel { height: auto; }

.right-result-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    position: relative;
}

.watermark-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('wm.png');
    background-position: center;
    background-repeat: no-repeat;
    background-size: 60%;
    opacity: 0.04;
    pointer-events: none;
    z-index: 999;
}

@media (max-width: 1000px) {
    .main-result-layout { display: flex; flex-direction: column; }
    .right-result-panel { order: 1; width: 100%; max-width: 100%; }
    .left-result-panel { order: 2; width: 100%; max-width: 100%; }
}

#results {
    margin-top: 0px;
    padding-top: 0;
    border-top: none;
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 2px;
}

.info-box {
    background: #f0f7ff;
    padding: 15px;
    border-radius: 9px;
    font-size: 0.9em;
    line-height: 1.6;
    height: 100%;
}

.info-box-content {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-start;
}

.info-column { flex: 1; min-width: 200px; }
.info-box strong { color: var(--color-primary); }

#age-display { font-weight: bold; color: var(--color-primary); }
.lunar-info-wrapper { margin-top: 5px; }
.lunar-info-wrapper.lunar-no-margin { margin-top: 0; }
.lunar-highlight { font-weight: bold; color: #3949ab; }

.dashed-border-top {
    margin-top: 8px;
    border-top: 1px dashed #c0d9fa;
    padding-top: 8px;
}

#fengshui-info, #kongwang-info {
    margin-top: 10px;
    border-top: 1px dashed #c0d9fa;
    padding-top: 10px;
}

.element-count-container-wrapper {
    margin-top: 8px;
    border-top: 1px dashed #c0d9fa;
    padding-top: 10px;
    display: block;
    grid-template-columns: 1fr;
}

.text-auspicious { color: #2E7D32; font-weight: bold; }
.text-inauspicious { color: #C62828; font-weight: bold; }
.void-branch-highlight { font-weight: bold; }

.warning {
    background-color: #fee; border-left: 6px solid #e74c3c;
    color: #c0392b; padding: 15px; margin-top: 15px;
    border-radius: 6px;
}

.display-options-card {
    background: #f7f9fb;
    border-radius: 9px;
    padding: 0;
    margin: 15px 0;
    border: 1px solid #e0e0e0;
    overflow: hidden;
}

.group-header-row { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    margin-bottom: 0; 
    background-color: #e8eaf6; 
    padding: 12px 20px;
    border-bottom: 1px solid #c5cae9;
}

.options-section-group { 
    margin-bottom: 0; 
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0; 
}

.options-section-group.no-border { 
    border-bottom: none; 
    padding-bottom: 15px;
    margin-bottom: 0; 
}

.options-section-group .group-header-row {
    background: transparent;
    border-bottom: none;
    padding: 0;
    margin-bottom: 10px;
}

.group-title { font-size: 0.95rem; color: var(--color-primary); font-weight: 600; }

.options-top-row { 
    display: flex; 
    gap: 20px; 
    margin-bottom: 0; 
    padding: 15px 20px 10px 20px;
    border-bottom: 1px solid #e0e0e0; 
}

.display-options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 15px; }
.compact-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
.display-options-grid label, .standard-label, .select-all-sub { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; color: #333; font-weight: 500; }
.display-options-card input[type="checkbox"] { margin: 0; padding: 0; height: 16px; width: 16px; accent-color: var(--color-primary); cursor: pointer; }

.bazi-table-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.bazi-header-row { display: flex; align-items: center; gap: 8px; flex-grow: 1; }
.bazi-header-title { margin-top: 0; margin-bottom: 0; font-size: clamp(1.1rem, 2.5vw, 1.3rem); }
.bazi-controls-wrapper { display: flex; align-items: center; gap: 10px; }
.bazi-chart-datetime-info { font-size: 0.85rem; color: #555; margin-bottom: 5px; margin-top: -5px; text-align: right; }

.bazi-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 2px;
}

.bazi-table {
    width: 100%;
    border-collapse: collapse;
    text-align: center;
    margin-bottom: 2px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid #e0e0e0;
    table-layout: fixed;
    --visible-cols: 8;
    position: relative;
    min-width: 0;
}

.bazi-table th {
    border: 1px solid #f0f3f5;
    padding: 0;
    vertical-align: middle;
    word-wrap: break-word;
    position: relative;
    z-index: 1;
}

.bazi-table thead th div { 
    padding: 10px 8px; 
    font-size: var(--main-header-size); 
}

.bazi-table thead th {
    background-color: rgba(236, 240, 241, 0.9);
    font-weight: bold;
    color: #34495e;
}

.bazi-table tbody th { background-color: rgba(255, 255, 255, 0.85); font-weight: normal; }
.bazi-table .pillar-label {
    color: #7f8c8d;
    background-color: rgba(247, 249, 251, 0.9);
    border-right: 1px solid #dfe6e9;
    font-size: var(--main-label-size);
}

.stem-display, .branch-display { font-weight: bold; line-height: 1.2; }

.bazi-table .stem-display .stem-char-large { font-size: var(--main-stem-size); }
.bazi-table .branch-display .stem-char-large { font-size: var(--main-branch-size); }
.bazi-table .branch-main { font-size: var(--main-branch-size); }

.stem-char-large { font-weight: 700; line-height: 1.1; }
#day-master .stem-char-large { font-size: 1.1em !important; vertical-align: baseline; }
.branch-main { font-weight: bold; }

.bazi-table .shi-shen-small {
    display: block;
    margin-top: 2px;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    font-size: var(--main-stem-shishen-size);
}

.hidden-stems-horizontal, .branch-shishen-horizontal {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    width: 100%;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
}

.bazi-table .hidden-stems-horizontal span, 
.bazi-table .hidden-char-horiz {
    font-weight: normal;
    flex: 0 1 auto;
    margin: 0 3px;
    font-size: var(--main-hidden-size);
}

.bazi-table .branch-shishen-horizontal span,
.bazi-table .shishen-char-horiz {
    font-weight: normal;
    flex: 0 1 auto;
    margin: 0 3px;
    font-size: var(--main-hidden-size);
}

.luck-pillars-horizontal-table {
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    text-align: center;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    border: 1px solid #e0e0e0;
    position: relative;
    margin-bottom: 2px;
}

.luck-pillars-horizontal-table th, .luck-pillars-horizontal-table td {
    border: 1px solid #f0f3f5;
    padding: 6px 4px !important;
    background-color: #fff;
    min-width: 50px;
    cursor: pointer;
    vertical-align: middle;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 0.2s;
}

.luck-pillars-horizontal-table th {
    background-color: #ecf0f1; font-weight: bold; color: #34495e; padding: 10px 8px !important;
}

.luck-pillars-horizontal-table td:hover { background-color: #f0f7ff; }

#decade-section .luck-pillars-horizontal-table th { font-size: var(--dec-header-size); }
#decade-section .luck-pillars-horizontal-table td { font-size: var(--dec-cell-size); }
#decade-section .luck-pillars-horizontal-table .luck-pillar-char { font-size: var(--dec-stem-size); }
#decade-section .luck-pillars-horizontal-table .luck-pillar-shishen-style { font-size: var(--dec-stem-ss-size); }
#decade-section .luck-pillars-horizontal-table .branch-main span[class^="element-"],
#decade-section .luck-pillars-horizontal-table .branch-main { font-size: var(--dec-branch-size); }
#decade-section .luck-pillars-horizontal-table .hidden-stems-vertical { font-size: var(--dec-hidden-size); }

#annual-pillars-container .luck-pillars-horizontal-table th { font-size: var(--ann-header-size); }
#annual-pillars-container .luck-pillars-horizontal-table td { font-size: var(--ann-cell-size); }
#annual-pillars-container .luck-pillars-horizontal-table .luck-pillar-char { font-size: var(--ann-stem-size); }
#annual-pillars-container .luck-pillars-horizontal-table .luck-pillar-shishen-style { font-size: var(--ann-stem-ss-size); }
#annual-pillars-container .luck-pillars-horizontal-table .branch-main span[class^="element-"],
#annual-pillars-container .luck-pillars-horizontal-table .branch-main { font-size: var(--ann-branch-size); }
#annual-pillars-container .luck-pillars-horizontal-table .hidden-stems-vertical { font-size: var(--ann-hidden-size); }

#monthly-pillars-container .luck-pillars-horizontal-table th { font-size: var(--mon-header-size); }
#monthly-pillars-container .luck-pillars-horizontal-table td { font-size: var(--mon-cell-size); }
#monthly-pillars-container .luck-pillars-horizontal-table .luck-pillar-char { font-size: var(--mon-stem-size); }
#monthly-pillars-container .luck-pillars-horizontal-table .luck-pillar-shishen-style { font-size: var(--mon-stem-ss-size); }
#monthly-pillars-container .luck-pillars-horizontal-table .branch-main span[class^="element-"],
#monthly-pillars-container .luck-pillars-horizontal-table .branch-main { font-size: var(--mon-branch-size); }
#monthly-pillars-container .luck-pillars-horizontal-table .hidden-stems-vertical { font-size: var(--mon-hidden-size); }

#day-pillars-container .luck-pillars-horizontal-table th { font-size: var(--day-header-size); }
#day-pillars-container .luck-pillars-horizontal-table td { font-size: var(--day-cell-size); }
#day-pillars-container .luck-pillars-horizontal-table .luck-pillar-char { font-size: var(--day-stem-size); }
#day-pillars-container .luck-pillars-horizontal-table .luck-pillar-shishen-style { font-size: var(--day-stem-ss-size); }
#day-pillars-container .luck-pillars-horizontal-table .branch-main span[class^="element-"],
#day-pillars-container .luck-pillars-horizontal-table .branch-main { font-size: var(--day-branch-size); }
#day-pillars-container .luck-pillars-horizontal-table .hidden-stems-vertical { font-size: var(--day-hidden-size); }


.gp-suffix { font-size: 0.8em; opacity: 0.8; }
.hidden-stems { font-size: 0.85em !important; color: #333; text-align: center; padding: 8px 10px; line-height: 1.5; }
.pillar-divider { border-left: 3px solid #bdc3c7 !important; }
.luck-pillar-stem-wrapper { display: flex; align-items: center; justify-content: center; gap: 3px; }
.luck-pillar-char { font-weight: bold; }
.luck-pillar-shishen-style { display: inline-block; font-weight: normal; }
.branch-compound-cell { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px; }
.hidden-stems-vertical { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; font-size: 0.75rem; line-height: 1.2; color: #555; }
.hidden-stem-item { white-space: nowrap; text-align: left; }
.stem-char-large, .branch-main { border: 1px solid transparent; border-radius: 4px; padding: 0 2px; display: inline-block; }
.void-border { border: 1px solid #d32f2f !important; border-radius: 4px; padding: 1px 01px; margin: 0 1px; box-shadow: 0 0 2px rgba(211, 47, 47, 0.2); }

.growth-phase-cell { font-weight: normal; padding: 6px 4px; text-align: center; vertical-align: middle; line-height: 1.3; } 
.nayin-cell { font-weight: normal; padding: 6px 4px; text-align: center; vertical-align: middle; line-height: 1.3; } 
.nayin-cell span { font-weight: normal; font-size: 1.1em; } 
.bazi-table .growth-phase-cell { padding: 4px 2px; font-size: var(--main-other-size); }
.bazi-table .nayin-cell { padding: 4px 2px; font-size: var(--main-other-size); }
.bazi-table .nayin-cell span { font-size: 1.0em; }
.shensha-cell { padding: 6px 4px; min-height: 50px; vertical-align: top; line-height: 1.3; text-align: center; }
.shensha-cell span { display: block; margin-bottom: 2px; }
.element-wood, .element-木, .element-count-table .element-木 { color: #2E7D32 !important; }
.element-fire, .element-火, .element-count-table .element-火 { color: #C62828 !important; }
.element-earth, .element-土, .element-count-table .element-土 { color: #5D4037 !important; }
.element-metal, .element-金, .element-count-table .element-金 { color: #B8860B !important; }
.element-water, .element-水, .element-count-table .element-水 { color: #1565C0 !important; }
.shensha-good { color: #2E7D32; }
.shensha-bad { color: #C62828; }
.shensha-special { color: #B8860B; }
.element-count-table { width: 100%; border-collapse: collapse; margin-top: 15px; border-radius: 8px; table-layout: fixed; box-shadow: 0 1px 4px rgba(0,0,0,0.05); overflow: hidden; }
.element-count-table th, .element-count-table td { padding: 8px 2px; border: 1px solid #e0e0e0; text-align: center; font-size: 0.8em; }
.element-count-header-cell { font-weight: bold; background-color: #f7f9fb; }
.element-count-table .count-val { font-size: 1.1em; font-weight: bold; color: #2c3e50; background-color: #fff; }
.element-totals { margin-top: 15px; padding: 10px; background-color: #f7f9fb; border-radius: 8px; text-align: center; font-size: 0.85em; }
.element-totals span { margin: 0 8px; font-weight: bold; }
.positive-rel { color: #2E7D32; font-weight: bold; font-size: 1.4em; }
.negative-rel { color: #C62828; font-weight: bold; font-size: 1.4em; }
.col-day-master, .dm-highlight { background-color: #fffde7 !important; border: 1px solid #f0f3f5 !important; }
.bazi-table th.col-day-master { background-color: #fffde7 !important; color: #34495e; }
.selected-decade-column, .selected-year-column, .selected-month-column, .selected-day-column { background-color: #e3f2fd !important; border: 2px solid var(--color-primary) !important; transition: background-color 0.3s ease; }
.selected-decade-column .stem-char-large, .selected-year-column .stem-char-large, .selected-month-column .stem-char-large, .selected-day-column .stem-char-large { color: var(--color-primary); }
.luck-pillars-horizontal-table .selected-decade-column, .luck-pillars-horizontal-table .selected-year-column, .luck-pillars-horizontal-table .selected-month-column, .luck-pillars-horizontal-table .selected-day-column { border: 1px solid #f0f3f5 !important; }
.bazi-nav-controls { display: flex; flex-direction: column; gap: 5px; margin-bottom: 15px; margin-top: 5px; }
.nav-row { display: flex; gap: 5px; width: 100%; }
.bazi-nav-button { flex: 1; background-color: #f0f4f8; border: 1px solid #dcdfe3; border-radius: 6px; padding: 6px 4px; cursor: pointer; font-size: 0.85rem; transition: background-color 0.2s; }
.bazi-nav-button:hover { background-color: #e3e9ef; }

.fab-container { position: fixed; bottom: 30px; right: 30px; z-index: 2000; display: flex; flex-direction: column; align-items: center; gap: 15px; pointer-events: none; }
.fab-container > * { pointer-events: auto; }
.fab-options { display: flex; flex-direction: column-reverse; align-items: center; gap: 12px; transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); opacity: 0; transform: translateY(20px) scale(0.8); pointer-events: none; margin-bottom: 5px; visibility: hidden; }
.fab-container.active .fab-options { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; visibility: visible; }
.fab-button, .fab-main-button { border-radius: 50%; border: none; color: white; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.3); display: flex; justify-content: center; align-items: center; line-height: 1; padding: 0; font-weight: bold; transition: all 0.3s ease; user-select: none; -webkit-tap-highlight-color: transparent; position: relative; }
.fab-main-button { width: 60px; height: 60px; background: linear-gradient(135deg, #5e35b1, #4527a0); font-size: 26px; z-index: 2001; transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), background-color 0.3s; }
.fab-main-button:hover { transform: scale(1.08); box-shadow: 0 8px 25px rgba(94, 53, 177, 0.5); }
.fab-container.active .fab-main-button { transform: rotate(135deg); background: #d32f2f; box-shadow: 0 8px 25px rgba(211, 47, 47, 0.5); }
.fab-button { width: 45px; height: 45px; font-size: 18px; transition: transform 0.2s; }
.fab-button:hover { transform: scale(1.15); filter: brightness(1.1); z-index: 2002; }
.fab-button:active { transform: scale(0.95); }
@media (min-width: 1025px) {
    .fab-button::after { content: attr(title); position: absolute; right: 55px; top: 50%; transform: translateY(-50%) translateX(10px); background: rgba(0, 0, 0, 0.75); color: white; padding: 5px 12px; border-radius: 6px; font-size: 0.8rem; white-space: nowrap; opacity: 0; pointer-events: none; transition: all 0.2s ease; box-shadow: 0 2px 8px rgba(0,0,0,0.2); backdrop-filter: blur(4px); }
    .fab-button:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }
}
#font-increase { background-color: #7e57c2; }
#font-decrease { background-color: #5c6bc0; }
#font-reset { background-color: #ff9800; }
#toggle-options-fab { background-color: #607d8b; }
#save-mobile-button { background-color: #e91e63; }
#save-jpeg-button { background-color: #4caf50; }
#save-pdf-button { background-color: #f44336; }
#fullscreen-toggle { background-color: #009688; }

.scroll-container { overflow-x: auto; }
.section-hidden { display: none !important; }

body.hide-col-decade .col-decade,
body.hide-col-year .col-year,
body.hide-col-month .col-month,
body.hide-col-day .col-day { display: none !important; }

body.hide-monthly-shensha #monthly-pillars-container .row-shensha { display: none !important; }

body.hide-monthly-details #monthly-pillars-container .row-shensha { display: none !important; }

#day-pillars-container { width: 100%; font-size: 1rem; }
#day-pillars-container .luck-pillars-horizontal-table th, #day-pillars-container .luck-pillars-horizontal-table td { padding: 6px 4px !important; }
#day-pillars-container .row-12p, #day-pillars-container .row-nayin, #day-pillars-container .row-shensha { display: none !important; }

#luck-pillars-table-horizontal .row-12p, #luck-pillars-table-horizontal .row-nayin, #luck-pillars-table-horizontal .row-shensha,
#annual-pillars-container .row-12p, #annual-pillars-container .row-nayin, #annual-pillars-container .row-shensha { display: none !important; }

#monthly-pillars-container .row-shensha { display: table-row !important; }

body.hide-main-nayin .row-main-nayin { display: none !important; }
body.hide-main-12p .row-main-12p { display: none !important; }
body.hide-main-shensha .row-main-shensha { display: none !important; }

@media (max-width: 1399px) {
    #annual-pillars-container th, 
    #monthly-pillars-container th, 
    #day-pillars-container th { 
        display: none !important; 
    }
}

#report-footer { text-align: center; margin-top: 30px; padding-top: 15px; border-top: 1px dashed #ccc; font-size: 0.9rem; color: #666; width: 100%; }
.footer-link-highlight { text-decoration: none; color: var(--color-primary); font-weight: bold; }
.footer-brand { font-weight: bold; }
.copyright-input { text-align: center; font-size: 0.85rem; color: #888; margin-top: 10px; }
.copyright-input a { color: var(--color-primary); text-decoration: none; font-weight: bold; }

@media (min-width: 769px) and (max-width: 1024px) {
    .container { height: 90vh; width: auto; aspect-ratio: 9 / 16; margin: auto; max-width: 100%; max-height: 100%; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
    .content { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; overflow-y: auto; }
    #input-card { width: 100%; max-width: 100%; box-sizing: border-box; }
}

@media (max-width: 768px) {
    .bazi-table-container { flex-wrap: wrap; }
    .bazi-table { --visible-cols: 4; }
    .bazi-table th { padding: 0 !important; height: auto; }
    .bazi-table th div { padding: 4px 1px !important; }
    .bazi-table th.col-decade, .bazi-table th.col-year, .bazi-table th.col-month, .bazi-table th.col-day { display: none !important; }
    body.show-col-decade .col-decade { display: table-cell !important; }
    body.show-col-year .col-year { display: table-cell !important; }
    body.show-col-month .col-month { display: table-cell !important; }
    body.show-col-day .col-day { display: table-cell !important; }
    body.hide-col-decade .col-decade { display: none !important; }
    .bazi-table .pillar-label { display: none !important; }
    .luck-pillars-horizontal-table th:first-child { display: none !important; }
    .bazi-table th:first-child { display: table-cell !important; }
    .header-logo { width: 60px; height: 60px; }
    .header-main-title { gap: 8px; }
    .display-options-grid { grid-template-columns: 1fr 1fr; }
    .result-grid { grid-template-columns: 1fr !important; }
    .info-box { margin-bottom: 15px; }
    .bazi-nav-button { padding: 8px 4px; }
}

@media (min-width: 769px) {
    #day-pillars-container .scroll-container { overflow-x: hidden !important; width: 100%; }
    #day-pillars-container .luck-pillars-horizontal-table { width: 100%; table-layout: fixed; }
    #day-pillars-container .luck-pillars-horizontal-table th,
    #day-pillars-container .luck-pillars-horizontal-table td { padding: 2px 0 !important; white-space: nowrap; overflow: hidden; text-overflow: clip; }
    #day-pillars-container .luck-pillars-horizontal-table th:first-child { width: 50px !important; white-space: normal !important; line-height: 1.1; }
}

.capture-header { background: linear-gradient(to right, #5e35b1, #3949ab) !important; padding: 40px !important; width: 100%; box-sizing: border-box; display: flex; justify-content: space-between; align-items: center; }
.capture-header h1 { color: #fff; line-height: 1.2; margin: 0; }
.capture-header p { color: rgba(255,255,255,0.9); margin: 0; }
.capture-header img { width: 140px; height: auto; }
.capture-footer { text-align: center; margin-top: auto; padding: 15px; border-top: 2px solid #eee; width: 100%; font-weight: bold; color: #000; background: #fff; font-size: 2.0rem !important; }

.capture-mode-mobile { width: 1080px; min-height: 1920px; background-color: #ffffff; font-family: ui-sans-serif, system-ui, -apple-system, sans-serif; display: flex; flex-direction: column; }
.capture-mode-mobile .capture-header h1 { font-size: 3.8rem; }
.capture-mode-mobile .capture-header p { font-size: 2.2rem; }

.capture-mode-mobile {
    --main-header-size: 1.9rem;
    --main-stem-shishen-size: 2.25rem;
    --main-stem-size: 2.5rem;
    --main-branch-size: 2.5rem;
    --main-hidden-size: 2.25rem;
    --main-other-size: 1.8rem;
    
    --dec-header-size: 1.4rem;
    --dec-cell-size: 1.4rem;
    --dec-stem-size: 1.9rem;
    --dec-branch-size: 1.9rem;
    --dec-stem-ss-size: 0.9rem;
    --dec-hidden-size: 0.9rem;
    
    --ann-stem-size: 1.9rem;
    --ann-branch-size: 1.9rem;
    --mon-stem-size: 1.9rem;
    --mon-branch-size: 1.9rem;
}

.capture-mode-mobile .info-box { background: #f0f7ff; border-radius: 20px; padding: 25px; font-size: 2.0em !important; line-height: 1.6; }

.capture-mode-desktop { width: 2480px; min-height: 1754px; background-color: #ffffff; display: flex; flex-direction: column; }
.capture-mode-desktop .capture-header { padding: 40px 50px !important; }
.capture-mode-desktop .capture-header h1 { font-size: 4.5rem; }
.capture-mode-desktop .capture-header p { font-size: 2.5rem; }
.capture-mode-desktop .capture-header img { width: 150px; }

.capture-mode-desktop {
    --main-header-size: 2rem;
    --main-stem-shishen-size: 2.4rem;
    --main-stem-size: 2.2rem;
    --main-branch-size: 2.2rem;
    --main-hidden-size: 2.4rem;
    --main-other-size: 1.8rem;
    
    --dec-header-size: 1.4rem;
    --dec-cell-size: 1.4rem;
    --dec-stem-size: 3.2rem;
    --dec-branch-size: 3.2rem;
    --dec-stem-ss-size: 1.2rem;
    --dec-hidden-size: 1.2rem;
    
    --ann-stem-size: 3.2rem;
    --ann-branch-size: 3.2rem;
    --mon-stem-size: 3.2rem;
    --mon-branch-size: 3.2rem;
}

.capture-mode-desktop .info-box { font-size: 1.8em !important; padding: 40px; border-radius: 20px; background: #f0f7ff; }

#chart-img-fallback { display: none; margin-top: 20px; width: 100%; height: auto; }

.capture-mode-mobile #elementChart,
.capture-mode-desktop #elementChart { display: none !important; }

.capture-mode-mobile #chart-img-fallback,
.capture-mode-desktop #chart-img-fallback { display: block !important; }