:root {
    /* Classical Cool Palette */
    --bg-color: #0d1b2a;
    --text-color: #e0e1dd;
    --primary-color: #ffd700;
    /* Gold */
    --secondary-color: #1b263b;
    /* Deep Blue */
    --accent-color: #778da9;
    /* Muted Blue-Grey */
    --border-color: #ffd700;
    --glass-bg: rgba(13, 27, 42, 0.7);
    --glass-border: 1px solid rgba(255, 215, 0, 0.3);
    --shadow-glow: 0 0 15px rgba(255, 215, 0, 0.2);
    --paper-texture: url('../assets/mystic_mountain_bg.webp');

    /* Spacing Scale (rem) */
    --spacing-xs: 0.25rem;   /* 4px */
    --spacing-sm: 0.5rem;    /* 8px */
    --spacing-md: 1rem;      /* 16px */
    --spacing-lg: 1.5rem;    /* 24px */
    --spacing-xl: 2rem;      /* 32px */
    --spacing-2xl: 2.5rem;   /* 40px */
    --spacing-3xl: 3.125rem; /* 50px */

    /* Font Size Scale (rem) */
    --font-xs: 0.75rem;      /* 12px */
    --font-sm: 0.875rem;     /* 14px */
    --font-base: 1rem;       /* 16px */
    --font-lg: 1.125rem;     /* 18px */
    --font-xl: 1.25rem;      /* 20px */
    --font-2xl: 1.5rem;      /* 24px */
    --font-3xl: 2rem;        /* 32px */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Serif SC', 'Songti SC', serif;
    background-color: var(--bg-color);
    background-image: var(--paper-texture);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    padding: 1.25rem;
    color: var(--text-color);
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: var(--spacing-2xl) auto;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    position: relative;
    padding: 1.25rem;
    overflow: hidden;
}

/* Decorative Corners - Updated to use new Gold Frame */
.corner-decoration {
    position: absolute;
    width: 9.375rem;
    height: 9.375rem;
    background-image: url('../assets/gold_frame_border.webp');
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 0;
    opacity: 1;
    filter: drop-shadow(0 0 2px gold);
}

.corner-tl {
    top: 0;
    left: 0;
    transform: rotate(0deg);
}

.corner-tr {
    top: 0;
    right: 0;
    transform: rotate(90deg);
}

.corner-bl {
    bottom: 0;
    left: 0;
    transform: rotate(-90deg);
}

.corner-br {
    bottom: 0;
    right: 0;
    transform: rotate(180deg);
}

.container::before {
    content: '';
    position: absolute;
    top: 0.9375rem;
    left: 0.9375rem;
    right: 0.9375rem;
    bottom: 0.9375rem;
    border: 1px solid rgba(255, 215, 0, 0.2);
    pointer-events: none;
    border-radius: var(--spacing-sm);
}

.header {
    text-align: center;
    padding: 3.75rem 0 var(--spacing-2xl);
    border-bottom: none;
    margin-bottom: 1.875rem;
    background: transparent;
    position: relative;
    z-index: 1;
}

.header::after {
    content: '';
    display: block;
    width: 60%;
    height: var(--spacing-2xl);
    margin: 1.25rem auto 0;
    background-image: url('../assets/gold_cloud_divider.webp');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.8;
}

.header h1 {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 4.5em;
    background: linear-gradient(to bottom, #ffd700, #b8860b);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.9375rem;
    text-shadow: 0 0 20px rgba(184, 134, 11, 0.3);
    letter-spacing: 0.3125rem;
}

.header p {
    font-size: 1.4em;
    color: var(--text-color);
    letter-spacing: var(--spacing-xs);
    opacity: 0.8;
    font-weight: 300;
}

.main-content {
    padding: 1.25rem var(--spacing-2xl);
    position: relative;
    z-index: 1;
}

.input-section {
    background: rgba(255, 255, 255, 0.05);
    padding: var(--spacing-3xl);
    border: 1px solid rgba(255, 215, 0, 0.2);
    max-width: 900px;
    margin: 0 auto var(--spacing-3xl);
    position: relative;
    border-radius: var(--spacing-sm);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.input-section h2 {
    font-family: 'Ma Shan Zheng', cursive;
    color: var(--primary-color);
    margin-bottom: 40px;
    font-size: 2.2em;
    text-align: center;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    padding-bottom: 15px;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: normal;
    color: var(--primary-color);
    font-size: 1.1em;
    font-family: 'Noto Serif SC', serif;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: none;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px 4px 0 0;
    font-family: 'Noto Serif SC', serif;
    font-size: 16px;
    color: #fff;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-bottom-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 4px 6px -6px var(--primary-color);
}

/* Custom Select Arrow */
.form-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='gold'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
}

/* Date Input Dark Mode Fix */
.form-group input[type="datetime-local"] {
    color-scheme: dark;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 30px;
}

.btn-generate {
    background: linear-gradient(135deg, #b8860b, #ffd700, #b8860b);
    background-size: 200% 200%;
    color: #0d1b2a;
    padding: 18px 40px;
    border: 1px solid #ffd700;
    border-radius: 50px;
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.5s ease;
    width: 100%;
    margin-top: 30px;
    letter-spacing: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(184, 134, 11, 0.4);
    animation: gradientMove 3s ease infinite;
}

@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.btn-generate:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
    border-color: #fff;
}

.btn-generate:active {
    transform: translateY(-1px);
}

.result-section {
    display: none;
    margin-top: 50px;
    animation: fadeInUp 0.8s ease;
}

.result-section.show {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-content {
    background: rgba(13, 27, 42, 0.6);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 12px;
    padding: 35px;
    max-height: 800px;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    color: #ccc;
}

/* Scrollbar Styling */
.result-content::-webkit-scrollbar {
    width: 8px;
}

.result-content::-webkit-scrollbar-track {
    background: #0d1b2a;
}

.result-content::-webkit-scrollbar-thumb {
    background: #b8860b;
    border-radius: 4px;
}

.basic-info {
    background: linear-gradient(135deg, rgba(27, 38, 59, 0.8), rgba(65, 90, 119, 0.8));
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 25px;
    border-left: 4px solid #ffd700;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.basic-info h3 {
    color: #ffd700;
    margin-bottom: 20px;
    font-size: 1.6em;
    font-weight: 600;
    font-family: 'Ma Shan Zheng', cursive;
    letter-spacing: 2px;
}

.basic-info p {
    margin: 10px 0;
    line-height: 1.7;
    color: #e0e1dd;
    font-size: 1.05em;
}

.basic-info strong {
    color: #ffd700;
    font-weight: 600;
}

.palace-info {
    margin-bottom: 30px;
    padding: 25px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.1);
    transition: all 0.3s ease;
}

.palace-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.1);
    background: rgba(255, 255, 255, 0.05);
}

.palace-title {
    font-size: 1.4em;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    font-family: 'Ma Shan Zheng', cursive;
}

.palace-content {
    line-height: 1.8;
    color: #ccc;
}

.palace-content p {
    margin: 8px 0;
    font-size: 1.05em;
}

.palace-content strong {
    color: #b8860b;
    font-weight: 600;
}

.copy-section {
    position: fixed;
    bottom: 2px;
    left: 2px;
    z-index: 9999;
    opacity: 0.1;
    transition: opacity 0.3s;
    margin: 0;
    padding: 0;
}

.copy-section:hover {
    opacity: 1;
}

.btn-copy {
    background: transparent;
    color: #ccc;
    padding: 0;
    border: none;
    cursor: pointer;
    font-size: 8px;
    font-weight: normal;
    transition: all 0.3s ease;
    margin: 0;
    box-shadow: none;
}

.btn-copy:hover {
    color: #999;
    text-decoration: underline;
}

.btn-ai-diagnosis {
    background: linear-gradient(45deg, var(--primary-color), #ff4d4d);
    color: white;
    padding: 15px 50px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 28px;
    font-weight: bold;
    font-family: 'Ma Shan Zheng', cursive;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(139, 0, 0, 0.4);
    animation: pulse-glow 2s infinite;
    display: block;
    margin: 30px auto;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    border: 2px solid gold;
}

.btn-ai-diagnosis:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.6);
    filter: brightness(1.2);
}

@keyframes pulse-glow {
    0% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(139, 0, 0, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(255, 69, 0, 0.8), 0 0 10px gold;
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(139, 0, 0, 0.4);
    }
}

.loading {
    text-align: center;
    padding: 50px;
    display: none;
}

.loading.show {
    display: block;
}

.spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 25px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading p {
    font-size: 1.2em;
    color: #6c757d;
    margin-top: 15px;
}

.error-message {
    background: linear-gradient(135deg, #f8d7da, #ffe6e6);
    color: #721c24;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid #f5c6cb;
    display: none;
    font-size: 1.1em;
    text-align: center;
}

.error-message.show {
    display: block;
}

.success-message {
    background: linear-gradient(135deg, #d4edda, #e8f5e8);
    color: #155724;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid #c3e6cb;
    display: none;
    font-size: 1.1em;
    text-align: center;
}

.success-message.show {
    display: block;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* 特殊标记样式 */
.special-mark {
    color: #e74c3c;
    font-weight: bold;
}

.star-brightness {
    color: #8e44ad;
    font-weight: 600;
}

.mutagen {
    color: #d35400;
    font-weight: bold;
}

/* 测试信息显示区域 */
.test-info {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    max-height: 300px;
    overflow-y: auto;
}

.test-info h4 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.test-button {
    background: #6c757d;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin: 5px;
    font-size: 14px;
}

/* Visual Chart Styles */
.ziwei-chart-container {
    margin-top: 50px;
    overflow-x: auto;
    padding: 20px;
}

.ziwei-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, minmax(200px, auto));
    gap: 15px;
    /* Increased gap for card look */
    background-color: transparent;
    border: none;
    margin: 0 auto;
    max-width: 1300px;
    font-family: 'Noto Serif SC', serif;
}

.palace-cell {
    background-color: rgba(13, 27, 42, 0.6);
    background-image: none;
    /* Removed paper texture for glass look */
    backdrop-filter: blur(5px);
    padding: 15px;
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    /* Rounded corners */
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    color: #e0e1dd;
}

.palace-cell:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.6);
    z-index: 10;
}

.center-cell {
    grid-column: 2 / 4;
    grid-row: 2 / 4;
    background: radial-gradient(circle, rgba(27, 38, 59, 0.9), rgba(13, 27, 42, 0.95));
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    /* Rounded center */
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.15);
}

.center-cell h2,
.center-cell h3,
.center-cell p {
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
}


/* Earthly Branch positions */
.cell-si {
    grid-area: 1 / 1 / 2 / 2;
}

/* 巳 */
.cell-wu {
    grid-area: 1 / 2 / 2 / 3;
}

/* 午 */
.cell-wei {
    grid-area: 1 / 3 / 2 / 4;
}

/* 未 */
.cell-shen {
    grid-area: 1 / 4 / 2 / 5;
}

/* 申 */

.cell-chen {
    grid-area: 2 / 1 / 3 / 2;
}

/* 辰 */
.cell-you {
    grid-area: 2 / 4 / 3 / 5;
}

/* 酉 */

.cell-mao {
    grid-area: 3 / 1 / 4 / 2;
}

/* 卯 */
.cell-xu {
    grid-area: 3 / 4 / 4 / 5;
}

/* 戌 */

.cell-yin {
    grid-area: 4 / 1 / 5 / 2;
}

/* 寅 */
.cell-chou {
    grid-area: 4 / 2 / 5 / 3;
}

/* 丑 */
.cell-zi {
    grid-area: 4 / 3 / 5 / 4;
}

/* 子 */
.cell-hai {
    grid-area: 4 / 4 / 5 / 5;
}

/* 亥 */

/* Palace Cell Layout Refactor */
.palace-cell {
    position: relative;
    background: rgba(255, 255, 255, 0.4);
    /* padding: 8px; Removed padding to allow full edge control, will use internal padding */
    padding: 5px;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    /* Prevent spillover */
}

/* Top Section: Stars */
.stars-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
    /* Take up available space */
    overflow-y: auto;
    /* Scroll if absolutely too many stars, though rare */
    padding-right: 30px;
    /* Avoid overlap with top-right Stage badge */
}

.stars-major {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 2px;
    font-weight: bold;
    font-size: 1.1em;
    line-height: 1.2;
}


/* [EXTRACTED] Lines 773-849 → separate CSS file */


.star-major {
    color: #ff4d4d;
    /* Red for major stars to pop */
    font-weight: bold;
    text-shadow: 0 0 2px rgba(255, 77, 77, 0.5);
}

.stars-minor {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.85em;
    color: #ccc;
    line-height: 1.2;
}

.brightness {
    font-size: 0.7em;
    color: var(--primary-color);
    margin-left: 1px;
    vertical-align: super;
}

.mutagen-label {
    background-color: var(--primary-color);
    color: #0d1b2a;
    border-radius: 2px;
    padding: 0 2px;
    font-size: 0.7em;
    margin-left: 1px;
    vertical-align: middle;
    font-weight: bold;
}

/* Bottom Section: Info Grid */
.palace-bottom-info {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
        "gods gods gods"
        "stem spacer name";
    align-items: end;
    margin-top: 5px;
    min-height: 40px;
    /* Ensure space for bottom elements */
}

/* 12 Gods Row */
.gods-row {
    grid-area: gods;
    display: flex;
    justify-content: space-between;
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.9);
    /* Brightened for dark background */
    border-top: 1px dashed rgba(255, 215, 0, 0.3);
    padding-top: 2px;
    margin-bottom: 2px;
}

.gods-item {
    margin-right: 4px;
}

/* Stem/Branch (Bottom Left) */
.palace-stem-branch {
    grid-area: stem;
    font-size: 1.2em;
    font-weight: bold;
    color: #e0e1dd;
    font-family: 'Ma Shan Zheng', cursive;
    line-height: 1;
}

/* Palace Name (Bottom Right) */
.palace-name {
    grid-area: name;
    background-color: var(--primary-color);
    color: #0d1b2a;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 1.1em;
    writing-mode: vertical-rl;
    text-orientation: upright;
    margin-left: auto;
    /* Push to right */
    box-shadow: 0 0 5px var(--primary-color);
}

/* Top Right Badge: Stage/Limit */
.palace-stage {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.8em;
    color: #fff;
    background: var(--secondary-color);
    padding: 1px 4px;
    border-radius: 3px;
    z-index: 10;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Center Cell Styles */
.chart-logo {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 2.2em;
    color: var(--primary-color);
    margin-bottom: 15px;
    border-bottom: 2px solid var(--accent-color);
    display: inline-block;
    padding-bottom: 5px;
}

.user-info-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    text-align: left;
    font-size: 0.95em;
}

.user-info-label {
    color: var(--primary-color);
    font-weight: bold;
    text-align: right;
    white-space: nowrap;
}

/* Minimal Footer Attribution */
.footer-attribution {
    position: fixed;
    bottom: 5px;
    right: 10px;
    font-size: 0.7em;
    color: rgba(255, 255, 255, 0.2);
    pointer-events: none;
    /* Let clicks pass through */
}

.header h1 {
    margin-bottom: 5px;
}

.header p {
    font-size: 0.8em;
    opacity: 0.6;
    margin: 0;
    display: none;
    /* Hide original header attribution */
}

.copy-btn-container {
    margin-top: 15px;
}

/* Responsive adjustments */
/* Battle Mode Layout */

/* [EXTRACTED] Lines 1670-1712 → separate CSS file */

/* ===== Tablet Responsive (≤1024px) ===== */
@media (max-width: 1024px) {
    .container {
        margin: 20px auto;
        padding: 15px;
    }

    .ziwei-grid {
        gap: 6px;
        max-width: 100%;
    }

    .palace-cell {
        padding: 6px;
    }

    .stars-major {
        font-size: 1em;
    }

    .center-cell {
        padding: 12px;
    }

    .chart-logo {
        font-size: 1.6em;
    }

    .user-info-grid {
        font-size: 0.85em;
        gap: 4px 8px;
    }

    .battle-row {
        gap: 10px;
    }
}

/* ===== Mobile Responsive (≤768px) ===== */
@media (max-width: 768px) {
    body {
        padding: 8px;
    }

    .container {
        margin: 10px auto;
        padding: 10px;
        border-radius: 8px;
    }

    .corner-decoration {
        width: 60px;
        height: 60px;
    }

    .container::before {
        top: 5px;
        left: 5px;
        right: 5px;
        bottom: 5px;
    }

    /* Header */
    .header {
        padding: 30px 10px 20px;
        margin-bottom: 15px;
    }

    .header h1 {
        font-size: 1.6em;
        letter-spacing: 2px;
    }

    .header h1 img {
        height: 0.9em !important;
        margin-right: 8px !important;
    }

    .header p {
        font-size: 0.9em;
        letter-spacing: 1px;
    }

    .header::after {
        width: 80%;
        height: 25px;
        margin-top: 10px;
    }

    /* Form */
    .main-content {
        padding: 10px;
    }

    .input-section {
        padding: 15px;
    }

    .input-section h2 {
        font-size: 1.2em;
    }

    .form-group label {
        font-size: 0.9em;
    }

    .form-group input,
    .form-group select {
        font-size: 16px; /* Prevent iOS zoom on focus */
        padding: 8px;
    }

    .btn-generate {
        font-size: 1.1em;
        padding: 12px;
    }

    /* Ziwei Chart Grid — horizontal scroll on mobile */
    .ziwei-chart-container {
        padding: 5px;
        margin-top: 20px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }

    .ziwei-grid {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(4, minmax(120px, auto));
        gap: 3px;
        font-size: 0.65em;
        min-width: 520px; /* Wider for better readability */
    }

    .palace-cell {
        padding: 4px;
        min-width: 0;
        overflow: hidden;
    }

    .stars-major {
        font-size: 1em;
        gap: 2px;
    }

    .stars-minor {
        font-size: 0.8em;
        gap: 1px;
    }

    .stars-container {
        padding-right: 20px;
    }

    .center-cell {
        padding: 10px;
    }

    .chart-logo {
        font-size: 1.5em;
        margin-bottom: 8px;
    }

    .user-info-grid {
        font-size: 0.85em;
        gap: 3px 6px;
    }

    .user-info-label {
        font-size: 0.85em;
    }

    .copy-btn-container {
        margin-top: 8px;
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: center;
    }

    .btn-copy,
    .btn-ai-diagnosis {
        font-size: 0.85em;
        padding: 6px 12px;
    }

    .palace-name {
        font-size: 0.95em;
        padding: 1px 4px;
    }

    .palace-stem-branch {
        font-size: 1em;
    }

    .palace-stage {
        font-size: 0.7em;
    }

    .gods-row {
        font-size: 0.7em;
    }

    /* 提示滚动 */
    .ziwei-chart-container::after {
        content: '← 左右滑动查看完整命盘 →';
        display: block;
        text-align: center;
        font-size: 0.8em;
        color: rgba(255, 215, 0, 0.5);
        padding: 8px 0 2px;
        font-family: 'Noto Serif SC', serif;
    }

    /* AI Section */
    .ai-section {
        padding: 10px;
        margin-top: 20px;
    }

    .ai-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
        padding-bottom: 10px;
        margin-bottom: 10px;
    }

    .ai-title {
        font-size: 1.3em;
    }

    .model-controls {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
    }

    .model-select {
        width: 100%;
        font-size: 0.9em;
    }

    .battle-switch {
        font-size: 0.85em;
    }

    .battle-switch .label-text {
        font-size: 0.85em;
    }

    /* Battle Config */
    .battle-config {
        padding: 10px;
    }

    .battle-checkboxes {
        gap: 6px;
    }

    .immortal-option {
        padding: 6px 10px;
        font-size: 0.85em;
    }

    /* AI Chat Container */
    .ai-container {
        height: auto;
        min-height: 400px;
    }

    .ai-chat-window {
        padding: 10px;
        min-height: 300px;
        max-height: 60vh;
    }

    .ai-controls-area {
        padding: 10px;
    }

    .quick-actions {
        gap: 6px;
        margin-bottom: 10px;
    }

    .action-btn {
        padding: 6px 10px;
        font-size: 0.8em;
    }

    /* Input Group */
    .ai-input-group {
        gap: 8px;
        flex-direction: column;
    }

    .ai-input {
        padding: 10px;
        min-height: 50px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .ai-btn-group {
        flex-direction: row !important;
        width: 100%;
    }

    .ai-send-btn {
        flex: 1;
        font-size: 0.85em;
        padding: 10px 8px;
    }

    .ai-debate-btn {
        flex: 1;
        font-size: 0.8em;
        padding: 10px 8px;
    }

    .ai-oneclick-btn {
        flex: 1;
        font-size: 0.8em;
        padding: 10px 8px;
    }

    /* Debate Bottom Config - Mobile */
    .debate-config-row {
        flex-direction: column;
        gap: 10px;
    }

    .debate-bottom-header {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    .debate-bottom-body {
        padding: 10px 12px;
    }

    .debate-config-title {
        font-size: 0.85em;
    }

    .judge-hint {
        display: block;
        font-size: 0.85em;
        margin-top: 2px;
    }

    .debate-config-checkboxes {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .debate-cost-estimate {
        font-size: 0.8em;
        padding: 8px 10px;
    }

    .debate-bottom-input-row {
        flex-direction: column;
        gap: 8px;
    }

    .debate-bottom-input-row .ai-input {
        height: 45px;
        font-size: 16px;
    }

    .debate-go-btn {
        width: 100% !important;
        min-width: unset;
        padding: 10px !important;
    }

    .ai-debate-btn::after {
        display: none;
    }

    /* Start Overlay */
    .start-ai-overlay p {
        font-size: 0.9em;
        padding: 0 10px;
    }

    .start-buttons {
        flex-direction: column;
        gap: 12px;
    }

    .btn-start-ai,
    .btn-start-debate {
        padding: 12px 30px;
        font-size: 1em;
    }

    /* Messages */
    .message {
        max-width: 95%;
        padding: 10px 12px;
        font-size: 0.9em;
    }

    .message .content-text {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .message .content-text pre {
        overflow-x: auto;
        max-width: 100%;
        font-size: 0.85em;
    }

    .message .content-text table {
        display: block;
        overflow-x: auto;
        max-width: 100%;
    }

    /* Battle Row */
    .battle-row {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .battle-col {
        padding: 10px;
    }

    .battle-col-header {
        font-size: 1em;
    }

    .battle-col .content-text {
        font-size: 0.85em;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Debate Inline Config */
    .debate-inline-config {
        padding: 12px;
    }

    .debate-inline-config-header {
        font-size: 1.1em;
    }

    .debate-config-checkboxes {
        gap: 6px;
    }

    .debate-question-area {
        flex-direction: column;
        gap: 10px;
    }

    .debate-question-input {
        height: 60px;
    }

    .debate-start-btn {
        width: 100%;
    }

    .debate-inline-config-summary {
        font-size: 0.85em;
    }

    .debate-inline-footer {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .debate-round-header {
        font-size: 1.1em;
        letter-spacing: 2px;
    }

    /* 辩论现场折叠 - 手机端 */
    .debate-scene-toggle {
        font-size: 1em;
        padding: 10px 14px;
        letter-spacing: 1px;
    }

    .scene-toggle-hint {
        font-size: 0.7em;
    }

    /* Settings Modal */
    .settings-content {
        width: 95%;
        padding: 15px;
    }

    .settings-title {
        font-size: 1.2em;
    }

    /* Thinking Process */
    .thinking-process {
        font-size: 0.85em;
    }

    .thinking-content {
        max-height: 200px;
        overflow-y: auto;
    }
}

/* ===== Small Phone (≤480px) ===== */
@media (max-width: 480px) {
    body {
        padding: 4px;
    }

    .container {
        margin: 5px auto;
        padding: 6px;
    }

    .corner-decoration {
        width: 40px;
        height: 40px;
    }

    .header h1 {
        font-size: 1.3em;
        letter-spacing: 1px;
    }

    .header h1 img {
        height: 0.8em !important;
        margin-right: 5px !important;
    }

    .input-section {
        padding: 10px;
    }

    .input-section h2 {
        font-size: 1em;
    }

    .form-row {
        grid-template-columns: 1fr !important;
    }

    /* ===== Chart: 手机端重排为可滚动但更大的格子 ===== */
    .ziwei-chart-container {
        padding: 2px;
        margin-top: 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ziwei-grid {
        font-size: 0.7em;
        gap: 2px;
        min-width: 560px;
        grid-template-rows: repeat(4, minmax(120px, auto));
    }

    .palace-cell {
        padding: 4px;
    }

    .stars-major {
        font-size: 1em;
        gap: 2px;
    }

    .stars-minor {
        font-size: 0.8em;
        gap: 1px;
    }

    .stars-container {
        padding-right: 22px;
    }

    .center-cell {
        padding: 8px;
    }

    .chart-logo {
        font-size: 1.3em;
        margin-bottom: 5px;
    }

    .user-info-grid {
        font-size: 0.75em;
        gap: 1px 4px;
    }

    .copy-btn-container {
        margin-top: 5px;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
    }

    .btn-copy,
    .btn-ai-diagnosis {
        font-size: 0.8em;
        padding: 5px 10px;
    }

    .palace-name {
        font-size: 0.9em;
        padding: 1px 3px;
    }

    .palace-stem-branch {
        font-size: 1em;
    }

    .palace-stage {
        font-size: 0.7em;
    }

    .gods-row {
        font-size: 0.7em;
    }

    /* AI */
    .ai-title {
        font-size: 1.1em;
    }

    .ai-container {
        min-height: 350px;
    }

    .ai-chat-window {
        min-height: 250px;
        max-height: 50vh;
        padding: 8px;
    }

    .ai-send-btn,
    .ai-debate-btn,
    .ai-oneclick-btn {
        font-size: 0.75em;
        padding: 8px 6px;
    }

    .ai-debate-btn::after {
        display: none;
    }

    .btn-cost {
        display: none;
    }

    .debate-bottom-header span {
        font-size: 0.85em;
    }

    .debate-bottom-body {
        padding: 8px 10px;
    }

    .debate-config-title {
        font-size: 0.8em;
        margin-bottom: 4px;
    }

    .debate-cost-estimate {
        font-size: 0.75em;
        padding: 6px 8px;
        line-height: 1.5;
    }

    .debate-cancel-btn {
        font-size: 0.8em;
        padding: 3px 10px;
    }

    .action-btn {
        padding: 5px 8px;
        font-size: 0.75em;
    }

    /* 仙人选择项：手机上两列排列 */
    .battle-checkboxes,
    .debate-config-checkboxes {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .immortal-option {
        padding: 5px 8px;
        font-size: 0.8em;
        justify-content: flex-start;
    }

    .battle-col {
        padding: 8px;
    }

    .debate-inline-config {
        padding: 8px;
    }

    .debate-inline-config-header {
        font-size: 1em;
        letter-spacing: 2px;
    }

    .message {
        max-width: 98%;
        padding: 8px 10px;
        font-size: 0.85em;
    }

    .chat-container {
        width: calc(100% - 20px);
        right: 10px;
        bottom: 80px;
        height: 450px;
    }

}

/* ===== Very Small Phone (≤380px) ===== */
@media (max-width: 380px) {
    .header h1 {
        font-size: 1.1em;
    }

    .ziwei-grid {
        font-size: 0.5em;
        min-width: 380px;
    }

    .ai-send-btn,
    .ai-debate-btn {
        width: 45px;
        font-size: 0.8em;
    }

    .debate-config-checkboxes {
        grid-template-columns: 1fr !important;
    }

    .debate-bottom-config {
        font-size: 0.9em;
    }

    .btn-generate {
        font-size: 1em;
        padding: 10px;
    }
}
/* 通知铃铛动画 */
@keyframes bellShake {
    0%, 100% { transform: rotate(0); }
    15% { transform: rotate(12deg); }
    30% { transform: rotate(-10deg); }
    45% { transform: rotate(8deg); }
    60% { transform: rotate(-6deg); }
    75% { transform: rotate(3deg); }
}
#notifBell.has-unread {
    animation: bellShake 0.8s ease-in-out;
    animation-iteration-count: 3;
}

/* 书记员配置区域 */
#clerkSection .debate-config-checkboxes label {
    border-color: rgba(100, 200, 255, 0.3);
}
#clerkSection .debate-config-checkboxes input:checked + span {
    color: #64c8ff;
}

/* 复制按钮成功状态 */
.debate-export-btn.copied {
    background: rgba(76, 175, 80, 0.3) !important;
    border-color: #4CAF50 !important;
}

/* 移动端辩论配置优化 */
@media (max-width: 768px) {
    .debate-config-row {
        flex-direction: column !important;
        gap: 8px !important;
    }
    .debate-config-section {
        width: 100% !important;
    }
    .debate-config-checkboxes {
        gap: 4px !important;
    }
    .debate-config-checkboxes label {
        font-size: 0.8em !important;
        padding: 4px 8px !important;
    }
    #userInfoBar {
        padding: 6px 10px !important;
        gap: 8px !important;
        font-size: 12px !important;
        right: 8px !important;
        top: 8px !important;
    }
    .debate-inline-footer {
        flex-wrap: wrap;
        gap: 6px !important;
    }
    .debate-export-btn {
        font-size: 0.8em !important;
        padding: 6px 10px !important;
    }
}

/* 快捷按钮滚动 */
.quick-actions {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.quick-actions::-webkit-scrollbar {
    display: none;
}

/* 分段式进度导航 */
.debate-stepper {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(13, 13, 26, 0.97);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    backdrop-filter: blur(10px);
}
.debate-stepper-warning {
    text-align: center;
    color: #ff6b6b;
    font-size: 0.75em;
    margin-bottom: 8px;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.debate-stepper-stages {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.debate-stepper-stages::-webkit-scrollbar { display: none; }
.debate-stage {
    flex: 1;
    min-width: 80px;
    padding: 8px 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}
.debate-stage:hover {
    background: rgba(255, 215, 0, 0.08);
    border-color: rgba(255, 215, 0, 0.3);
}
.debate-stage.active {
    background: rgba(255, 215, 0, 0.1);
    border-color: #ffd700;
    animation: stageGlow 1.5s infinite;
}
@keyframes stageGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.2); }
    50% { box-shadow: 0 0 15px rgba(255, 215, 0, 0.4); }
}
.debate-stage.done {
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.4);
}
.stage-label {
    font-size: 0.8em;
    font-weight: bold;
    color: #ddd;
    margin-bottom: 2px;
}
.debate-stage.active .stage-label { color: #ffd700; }
.debate-stage.done .stage-label { color: #4CAF50; }
.stage-hint {
    font-size: 0.6em;
    color: #888;
    line-height: 1.3;
}
.stage-status {
    font-size: 0.65em;
    color: #666;
    margin-top: 3px;
}
.debate-stage.active .stage-status { color: #ffd700; }
.debate-stage.done .stage-status { color: #4CAF50; }
.debate-stepper-time {
    text-align: center;
    font-size: 0.7em;
    color: #888;
    margin-top: 8px;
}

@media (max-width: 480px) {
    .debate-stage {
        min-width: 65px;
        padding: 6px 4px;
    }
    .stage-label { font-size: 0.7em; }
    .stage-hint { font-size: 0.55em; }
}


/* 价值主张区域 */
.start-value-prop {
    text-align: center;
    margin-bottom: 15px;
}
.value-prop-title {
    font-size: 1.3em;
    color: #ffd700;
    font-weight: bold;
    margin-bottom: 8px;
}
.value-prop-desc {
    color: #ccc;
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 10px;
}
.value-prop-features {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8em;
    color: #aaa;
}

/* 按钮组 */
.ai-btn-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
}
.ai-oneclick-btn {
    padding: 10px 16px;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    border: none;
    border-radius: 8px;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s;
    white-space: nowrap;
}
.ai-oneclick-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}
.btn-cost {
    font-size: 0.75em;
    opacity: 0.7;
    font-weight: normal;
}

/* 辩论模式下按钮组调整 */
.ai-input-group.debate-mode .ai-btn-group {
    flex-direction: row;
}

@media (max-width: 768px) {
    .ai-btn-group {
        min-width: 100px;
    }
    .ai-oneclick-btn {
        font-size: 0.8em;
        padding: 8px 12px;
    }
}

/* 移动端价值主张和用户栏优化 */
@media (max-width: 480px) {
    .value-prop-title {
        font-size: 1.1em;
    }
    .value-prop-desc {
        font-size: 0.8em;
    }
    .value-prop-features {
        font-size: 0.7em;
    }
    .privacy-notice {
        font-size: 0.75em !important;
    }
    .start-buttons {
        gap: 8px !important;
    }
    .btn-start-ai,
    .btn-start-debate {
        padding: 10px 20px !important;
        font-size: 0.9em !important;
    }
    #userInfoBar {
        padding: 4px 8px !important;
        gap: 6px !important;
        font-size: 11px !important;
        border-radius: 8px !important;
        max-width: calc(100vw - 16px) !important;
        flex-wrap: wrap !important;
    }
}


/* [EXTRACTED] Lines 3359-3726 → separate CSS file */

/* ===== 命盘输入区手机端间距收紧 ===== */
@media (max-width: 768px) {
    .form-group {
        margin-bottom: 12px;
    }
    .form-group label {
        margin-bottom: 4px;
    }
    .input-section h2 {
        margin-bottom: 15px;
        padding-bottom: 8px;
        font-size: 1.15em;
    }
    .form-row {
        gap: 0 !important;
    }
    .input-section {
        margin-bottom: 20px;
    }
    .btn-generate {
        margin-top: 5px;
    }
    .form-tip {
        margin-top: 6px;
        font-size: 0.75em;
    }
}
@media (max-width: 480px) {
    .form-group {
        margin-bottom: 8px;
    }
    .form-group label {
        margin-bottom: 2px;
        font-size: 0.85em;
    }
    .form-group input,
    .form-group select {
        padding: 6px 8px;
    }
    .input-section {
        padding: 8px;
        margin-bottom: 15px;
    }
    .input-section h2 {
        margin-bottom: 10px;
        padding-bottom: 6px;
        font-size: 1em;
    }
    .btn-generate {
        padding: 10px;
        font-size: 1em;
    }
    .form-tip {
        margin-top: 4px;
        padding: 3px;
        font-size: 0.72em;
    }
}

/* ===== 横屏优化 ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 10px 10px 8px;
        margin-bottom: 8px;
    }
    .header h1 {
        font-size: 1.2em;
    }
    .header p {
        font-size: 0.75em;
        margin-top: 2px;
    }
    .header::after {
        height: 15px;
        margin-top: 5px;
    }
    .input-section {
        padding: 8px;
        margin-bottom: 10px;
    }
    .input-section h2 {
        font-size: 0.95em;
        margin-bottom: 8px;
        padding-bottom: 4px;
    }
    .form-group {
        margin-bottom: 6px;
    }
    .form-group label {
        margin-bottom: 2px;
        font-size: 0.8em;
    }
    .form-group input,
    .form-group select {
        padding: 5px 8px;
        font-size: 14px;
    }
    .form-row {
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 8px !important;
    }
    .btn-generate {
        padding: 8px;
        font-size: 0.95em;
    }
    /* 横屏时 debate-stepper 绝对不能 sticky */
    .debate-stepper {
        position: relative !important;
        top: auto !important;
    }
    /* 横屏时快捷按钮更紧凑 */
    .quick-actions-btns {
        gap: 4px;
    }
    .action-btn {
        padding: 4px 8px;
        font-size: 0.75em;
    }
    .quick-actions-hint {
        font-size: 0.7em;
        margin-bottom: 3px;
    }
    /* 横屏时 AI 区域更紧凑 */
    .ai-controls-area {
        padding: 8px;
    }
    .ai-chat-window {
        max-height: 50vh;
    }
    /* 横屏时 userInfoBar 更紧凑 */
    #userInfoBar {
        padding: 3px 8px !important;
        gap: 6px !important;
        font-size: 11px !important;
    }
    .topbar-debate-progress {
        margin-top: 3px;
        padding-top: 3px;
    }
    .topbar-stage {
        font-size: 10px;
        padding: 1px 4px;
    }
    /* 横屏时浮动帮助按钮更小 */
    .floating-help {
        width: 32px;
        height: 32px;
        font-size: 14px;
        bottom: 8px;
        right: 8px;
    }
    body {
        padding: 4px;
    }
    .container {
        padding: 6px;
        margin: 4px auto;
    }
}

/* ===== 移动端快捷按钮优化 ===== */
@media (max-width: 480px) {
    .quick-actions-btns {
        gap: 5px;
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .quick-actions-btns::-webkit-scrollbar { display: none; }
    .action-btn {
        flex-shrink: 0;
        padding: 5px 10px;
        font-size: 0.78em;
    }
    .quick-actions-hint {
        font-size: 0.72em;
        margin-bottom: 4px;
    }
    .rotating-tip-bar {
        font-size: 0.72em;
        padding: 4px 8px;
    }
}

/* ===== 命盘手机端优化 - 完整显示无需横向滚动 ===== */

/* 平板及手机 (≤768px) - 命盘自适应 */
@media (max-width: 768px) {
    /* 命盘结果区减少内边距，给命盘更多空间 */
    .result-section .result-content {
        padding: 8px !important;
    }

    /* 命盘容器：禁止横向滚动 */
    .ziwei-chart-container {
        overflow-x: hidden !important;
        overflow-y: visible !important;
        padding: 0 !important;
        margin-top: 15px !important;
    }

    /* 移除"左右滑动查看完整命盘"提示 */
    .ziwei-chart-container::after {
        display: none !important;
    }

    /* 命盘网格：移除最小宽度，完全自适应屏幕 */
    .ziwei-chart-container .ziwei-grid {
        min-width: unset !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 2px !important;
        grid-template-rows: repeat(4, minmax(90px, auto)) !important;
        font-size: 0.58em !important;
    }

    /* 宫位单元格紧凑化 */
    .ziwei-chart-container .palace-cell {
        padding: 3px !important;
        overflow: hidden !important;
    }

    .ziwei-chart-container .stars-container {
        padding-right: 16px !important;
        overflow: hidden !important;
    }

    .ziwei-chart-container .stars-major {
        gap: 1px !important;
        margin-bottom: 1px !important;
        font-size: 1em !important;
    }

    .ziwei-chart-container .stars-minor {
        gap: 1px !important;
        font-size: 0.8em !important;
    }

    /* 中宫紧凑化 */
    .ziwei-chart-container .center-cell {
        padding: 6px !important;
    }

    .ziwei-chart-container .chart-logo {
        font-size: 1.4em !important;
        margin-bottom: 4px !important;
        padding-bottom: 3px !important;
    }

    .ziwei-chart-container .user-info-grid {
        font-size: 0.85em !important;
        gap: 2px 4px !important;
    }

    .ziwei-chart-container .copy-btn-container {
        margin-top: 4px !important;
    }

    .ziwei-chart-container .btn-copy,
    .ziwei-chart-container .btn-ai-diagnosis {
        font-size: 0.8em !important;
        padding: 4px 8px !important;
    }

    /* 底部信息紧凑化 */
    .ziwei-chart-container .palace-bottom-info {
        margin-top: 2px !important;
        min-height: 26px !important;
    }

    .ziwei-chart-container .gods-row {
        font-size: 0.7em !important;
    }

    .ziwei-chart-container .palace-stem-branch {
        font-size: 0.95em !important;
    }

    .ziwei-chart-container .palace-name {
        font-size: 0.85em !important;
        padding: 1px 2px !important;
    }

    .ziwei-chart-container .palace-stage {
        font-size: 0.65em !important;
        padding: 1px 2px !important;
    }

    .ziwei-chart-container .brightness {
        font-size: 0.65em !important;
    }

    .ziwei-chart-container .mutagen-label {
        font-size: 0.6em !important;
        padding: 0 1px !important;
    }
}

/* 手机竖屏 (≤480px) - 命盘进一步紧凑 */
@media (max-width: 480px) {
    .result-section .result-content {
        padding: 4px !important;
    }

    .ziwei-chart-container {
        margin-top: 10px !important;
    }

    .ziwei-chart-container .ziwei-grid {
        min-width: unset !important;
        width: 100% !important;
        gap: 1px !important;
        grid-template-rows: repeat(4, minmax(78px, auto)) !important;
        font-size: 0.52em !important;
    }

    .ziwei-chart-container .palace-cell {
        padding: 2px !important;
    }

    .ziwei-chart-container .stars-container {
        padding-right: 14px !important;
    }

    .ziwei-chart-container .center-cell {
        padding: 4px !important;
    }

    .ziwei-chart-container .chart-logo {
        font-size: 1.2em !important;
        margin-bottom: 2px !important;
    }

    .ziwei-chart-container .user-info-grid {
        font-size: 0.78em !important;
        gap: 1px 3px !important;
    }

    .ziwei-chart-container .palace-name {
        font-size: 0.8em !important;
        padding: 1px 2px !important;
    }

    .ziwei-chart-container .palace-stem-branch {
        font-size: 0.85em !important;
    }

    .ziwei-chart-container .gods-row {
        font-size: 0.62em !important;
    }

    .ziwei-chart-container .palace-stage {
        font-size: 0.58em !important;
    }

    .ziwei-chart-container .btn-ai-diagnosis {
        font-size: 0.75em !important;
        padding: 3px 6px !important;
    }
}

/* 超小屏手机 (≤360px) - 命盘极致紧凑 */
@media (max-width: 360px) {
    .ziwei-chart-container .ziwei-grid {
        min-width: unset !important;
        font-size: 0.46em !important;
        gap: 1px !important;
        grid-template-rows: repeat(4, minmax(68px, auto)) !important;
    }

    .ziwei-chart-container .stars-container {
        padding-right: 12px !important;
    }

    .ziwei-chart-container .center-cell {
        padding: 3px !important;
    }

    .ziwei-chart-container .chart-logo {
        font-size: 1em !important;
    }

    .ziwei-chart-container .user-info-grid {
        font-size: 0.7em !important;
    }

    .ziwei-chart-container .palace-name {
        font-size: 0.75em !important;
    }
}


/* [EXTRACTED] Lines 4677-4904 → separate CSS file */

