body { background-color: #060709; color: #f1f5f9; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
input, select, option { background-color: #000000 !important; color: #ffffff !important; color-scheme: dark !important; border: 1px solid #374151 !important; border-radius: 0.75rem; }
input:focus, select:focus { border-color: #fbbf24 !important; outline: none !important; box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.3); }
.qimen-card { background: #0f172a; border: 1px solid rgba(148, 163, 184, 0.14); border-left: 5px solid #fbbf24; border-radius: 20px; padding: 1.25rem; }
.qimen-card.good { border-left-color: #34d399; }
.qimen-card.risk { border-left-color: #fb7185; }
.qimen-grid { display: grid; grid-template-columns: repeat(1, minmax(0, 1fr)); gap: 1rem; }
@media (min-width: 768px) { .qimen-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mode-switch { display: inline-flex; gap: 6px; padding: 6px; border-radius: 14px; background: #020617; border: 1px solid rgba(148, 163, 184, 0.18); }
.print-btn { background: #facc15; color: #020617; border: 0; border-radius: 12px; padding: 0.72rem 1rem; font-weight: 950; cursor: pointer; }
.print-btn:hover { opacity: 0.9; }
.mode-btn { border: 0; border-radius: 10px; padding: 0.55rem 0.9rem; color: #cbd5e1; background: transparent; font-size: 0.85rem; font-weight: 800; cursor: pointer; }
.mode-btn:hover { color: #f8fafc; background: rgba(148, 163, 184, 0.12); }
.mode-btn.active { color: #020617; background: #facc15; }
.gate-row { display: flex; gap: 0.75rem; align-items: flex-start; background: rgba(15, 23, 42, 0.82); border: 1px solid rgba(148, 163, 184, 0.14); border-radius: 14px; padding: 0.8rem; }
.gate-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 3.3rem; padding: 0.25rem 0.7rem; border-radius: 9999px; font-size: 0.8rem; font-weight: 900; white-space: nowrap; }
.gate-good { color: #bbf7d0; background: rgba(34, 197, 94, 0.18); }
.gate-bad { color: #fecdd3; background: rgba(244, 63, 94, 0.18); }
.gate-neutral { color: #fef3c7; background: rgba(245, 158, 11, 0.18); }
.direction { color: #f8fafc; font-weight: 900; }
.insight-key { color: #facc15; font-weight: 800; }
.good-key { color: #34d399; font-weight: 800; }
.risk-key { color: #fb7185; font-weight: 800; }
.mini-card { background: #020617; border: 1px solid rgba(148, 163, 184, 0.14); border-radius: 16px; padding: 1rem; }
.mini-card p, .gate-row p { color: #cbd5e1; line-height: 1.65; }
.usage-list { display: grid; gap: 0.55rem; margin-top: 0.75rem; font-size: 0.88rem; }
.usage-list li { color: #cbd5e1; }
.help-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.15rem; height: 1.15rem; background-color: #334155; color: #fff; font-size: 0.75rem; font-weight: bold; border-radius: 9999px; margin-left: 0.25rem; cursor: help; }
.help-icon:hover { background-color: #facc15; color: #000; }
.palace-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; background: #020617; border: 1px solid rgba(250, 204, 21, 0.18); border-radius: 18px; padding: 12px; }
.palace-cell { min-height: 150px; border-radius: 14px; padding: 12px; border: 1px solid rgba(148, 163, 184, 0.16); background: #0f172a; display: flex; flex-direction: column; gap: 7px; }
.palace-good { border-color: rgba(52, 211, 153, 0.55); background: linear-gradient(135deg, rgba(22, 101, 52, 0.28), #0f172a 58%); }
.palace-risk { border-color: rgba(251, 113, 133, 0.58); background: linear-gradient(135deg, rgba(127, 29, 29, 0.32), #0f172a 58%); }
.palace-neutral { border-color: rgba(250, 204, 21, 0.34); }
.palace-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.palace-dir { color: #f8fafc; font-weight: 900; font-size: 1rem; }
.palace-badge { font-size: 0.7rem; font-weight: 900; border-radius: 999px; padding: 2px 8px; color: #020617; background: #facc15; }
.palace-good .palace-badge { background: #34d399; }
.palace-risk .palace-badge { background: #fb7185; color: #fff; }
.palace-gate { color: #facc15; font-size: 1.18rem; font-weight: 900; }
.palace-good .palace-gate { color: #86efac; }
.palace-risk .palace-gate { color: #fda4af; }
.palace-meta { color: #93c5fd; font-size: 0.78rem; font-weight: 700; }
.palace-note { color: #cbd5e1; font-size: 0.76rem; line-height: 1.45; margin-top: auto; }
.palace-legend { display: flex; flex-wrap: wrap; gap: 12px; color: #94a3b8; font-size: 0.78rem; margin-top: 12px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 999px; margin-right: 5px; }
.legend-dot.good { background: #34d399; }
.legend-dot.risk { background: #fb7185; }
.legend-dot.neutral { background: #facc15; }
.compare-titlebar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; border-bottom: 1px solid rgba(148, 163, 184, 0.18); padding-bottom: 14px; margin-bottom: 16px; }
.compare-titlebar h4 { color: #facc15; font-size: 1.08rem; font-weight: 900; margin: 0; }
.compare-titlebar p { color: #94a3b8; font-size: 0.78rem; margin: 4px 0 0; }
.compare-titlebar button { border: 1px solid rgba(250, 204, 21, 0.28); border-radius: 10px; background: #020617; color: #facc15; padding: 0.55rem 0.8rem; font-size: 0.78rem; font-weight: 800; cursor: pointer; }
.compare-titlebar button:hover { background: rgba(250, 204, 21, 0.12); }
.top-hours { display: grid; grid-template-columns: repeat(1, minmax(0, 1fr)); gap: 12px; }
.compare-grid { display: grid; grid-template-columns: repeat(1, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
@media (min-width: 900px) {
    .top-hours { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .compare-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen {
    body {
        background:
            radial-gradient(circle at 16% 8%, rgba(255, 255, 255, 0.92), transparent 34%),
            linear-gradient(180deg, #f9eee4 0%, #fffaf2 54%, #f9eee4 100%) !important;
        color: #2b2118 !important;
    }

    section,
    .bg-gray-900,
    .bg-gray-950,
    .bg-gray-800,
    .qimen-card,
    .mini-card,
    .gate-row,
    .palace-board,
    .palace-cell,
    .compare-card {
        background: rgba(255, 255, 255, 0.86) !important;
        background-image: none !important;
        color: #2b2118 !important;
        border-color: rgba(185, 127, 46, 0.22) !important;
        box-shadow: 0 16px 36px rgba(95, 58, 22, 0.08) !important;
    }

    section.bg-gray-900 {
        background: linear-gradient(135deg, #fffaf2, #fff7df) !important;
    }

    input,
    select,
    option {
        background: #fffaf2 !important;
        color: #2b2118 !important;
        color-scheme: light !important;
        border-color: rgba(185, 127, 46, 0.28) !important;
    }

    input:focus,
    select:focus {
        border-color: #d99a21 !important;
        box-shadow: 0 0 0 3px rgba(217, 154, 33, 0.18) !important;
    }

    h1,
    .text-yellow-500,
    .text-yellow-400,
    .insight-key,
    .palace-gate,
    .compare-titlebar h4 {
        color: #a7640b !important;
    }

    p,
    li,
    label,
    .text-gray-300,
    .text-gray-400,
    .usage-list li,
    .mini-card p,
    .gate-row p,
    .palace-note,
    .compare-card p {
        color: #654b34 !important;
    }

    .direction,
    .palace-dir,
    .compare-time,
    .text-gray-100,
    .text-white {
        color: #2b2118 !important;
    }

    .mode-switch {
        background: #fffaf2 !important;
        border-color: rgba(185, 127, 46, 0.22) !important;
    }

    .mode-btn {
        color: #654b34 !important;
    }

    .mode-btn.active,
    .mode-btn:hover,
    #compute-qimen,
    #compute-compare,
    .compare-score,
    .palace-badge {
        background: #d99a21 !important;
        color: #2b2118 !important;
    }

    .qimen-card.good,
    .palace-good,
    .compare-card.best,
    .compare-card.good {
        border-left-color: #22c55e !important;
        background: linear-gradient(135deg, #ecfdf5, #fffaf2 62%) !important;
    }

    .qimen-card.risk,
    .palace-risk,
    .compare-card.risk {
        border-left-color: #ef4444 !important;
        background: linear-gradient(135deg, #fff1f2, #fffaf2 62%) !important;
    }

    .gate-good,
    .good-key {
        color: #15803d !important;
    }

    .gate-bad,
    .risk-key {
        color: #b91c1c !important;
    }

    .palace-meta,
    .compare-sub {
        color: #1d4ed8 !important;
    }
}
.compare-card { background: #020617; border: 1px solid rgba(148, 163, 184, 0.16); border-left: 5px solid #94a3b8; border-radius: 16px; padding: 1rem; display: flex; flex-direction: column; gap: 0.7rem; min-height: 210px; }
.compare-card.best { border-left-color: #34d399; background: linear-gradient(135deg, rgba(20, 83, 45, 0.34), #020617 58%); }
.compare-card.good { border-left-color: #22c55e; }
.compare-card.neutral { border-left-color: #facc15; }
.compare-card.risk { border-left-color: #fb7185; background: linear-gradient(135deg, rgba(127, 29, 29, 0.24), #020617 58%); }
.compare-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.compare-time { color: #f8fafc; font-size: 1rem; font-weight: 900; }
.compare-sub { color: #93c5fd; font-size: 0.76rem; font-weight: 700; margin-top: 4px; }
.compare-score { min-width: 52px; height: 52px; border-radius: 14px; background: #facc15; color: #020617; display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; font-weight: 950; }
.compare-card.best .compare-score { background: #34d399; }
.compare-card.risk .compare-score { background: #fb7185; color: #fff; }
.compare-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.compare-tags span { color: #e2e8f0; background: rgba(148, 163, 184, 0.12); border: 1px solid rgba(148, 163, 184, 0.12); border-radius: 999px; padding: 3px 9px; font-size: 0.7rem; font-weight: 800; }
.compare-tags .compare-rank { color: #020617; background: #facc15; border-color: #facc15; }
.compare-card p { color: #cbd5e1; font-size: 0.82rem; line-height: 1.58; margin: 0; }
.compare-reason { color: #fef3c7 !important; border-top: 1px solid rgba(148, 163, 184, 0.14); padding-top: 0.65rem; margin-top: auto !important; }
@media screen {
    .compare-card {
        background: rgba(255, 255, 255, 0.86) !important;
        color: #2b2118 !important;
        border-color: rgba(185, 127, 46, 0.22) !important;
    }

    .compare-card.best,
    .compare-card.good {
        border-left-color: #22c55e !important;
        background: linear-gradient(135deg, #ecfdf5, #fffaf2 62%) !important;
    }

    .compare-card.neutral {
        border-left-color: #d99a21 !important;
        background: linear-gradient(135deg, #fff7df, #fffaf2 62%) !important;
    }

    .compare-card.risk {
        border-left-color: #ef4444 !important;
        background: linear-gradient(135deg, #fff1f2, #fffaf2 62%) !important;
    }

    .compare-time {
        color: #2b2118 !important;
    }

    .compare-sub {
        color: #1d4ed8 !important;
    }

    .compare-tags span {
        background: #fff1bd !important;
        color: #5c3808 !important;
        border-color: rgba(217, 154, 33, 0.38) !important;
    }

    .compare-tags .compare-rank {
        background: #facc15 !important;
        color: #2b2118 !important;
        border-color: #facc15 !important;
    }

    .compare-score {
        background: #d99a21 !important;
        color: #2b2118 !important;
    }

    .compare-card.best .compare-score,
    .compare-card.good .compare-score {
        background: #22c55e !important;
        color: #052e16 !important;
    }

    .compare-card.risk .compare-score {
        background: #ef4444 !important;
        color: #fff !important;
    }

    .compare-card p {
        color: #5f4934 !important;
    }

    .compare-card .compare-reason {
        color: #a7640b !important;
        border-top-color: rgba(185, 127, 46, 0.18) !important;
    }
}
@media (max-width: 640px) {
    .palace-board { gap: 6px; padding: 8px; }
    .palace-cell { min-height: 132px; padding: 9px; }
    .palace-dir { font-size: 0.88rem; }
    .palace-gate { font-size: 1rem; }
    .palace-note { font-size: 0.68rem; }
    .mode-switch { width: 100%; }
    .mode-btn { flex: 1; }
    .compare-card { min-height: auto; }
}
@media print {
    body { background: white !important; color: black !important; }
    section, main, .bg-gray-900, .bg-gray-950, .bg-gray-800 {
        background: #fff !important;
        background-image: none !important;
        color: #000 !important;
        border-color: #aaa !important;
        box-shadow: none !important;
    }
    .no-print,
    #single-controls,
    #compare-controls,
    #guide-toggle,
    #guide-content,
    .mode-switch,
    .help-icon,
    button {
        display: none !important;
    }
    .qimen-card, .mini-card, .gate-row, .palace-cell, .palace-board, .compare-card { background: #fff !important; background-image: none !important; color: #000 !important; border-color: #aaa !important; box-shadow: none !important; }
    .qimen-card { margin-bottom: 10px !important; padding: 12px !important; break-inside: auto !important; page-break-inside: auto !important; }
    .palace-board, .gate-row, .mini-card, .compare-card { break-inside: avoid !important; page-break-inside: avoid !important; }
    .palace-cell { min-height: 105px !important; padding: 8px !important; }
    .compare-card { min-height: 0 !important; }
    .top-hours, .compare-grid { display: block !important; }
    .compare-card { margin-bottom: 8px !important; }
    .gate-badge, .palace-badge, .compare-score, .compare-tags span, .legend-dot {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #999 !important;
    }
    p, span, h1, h2, h3, h4, div, li, strong { color: #000 !important; }
    .insight-key, .gate-neutral, .compare-card.neutral .compare-score {
        color: #b45309 !important;
    }
    .good-key, .gate-good, .palace-good .palace-gate, .compare-card.best .compare-score, .compare-card.good .compare-score {
        color: #15803d !important;
    }
    .risk-key, .gate-bad, .palace-risk .palace-gate, .compare-card.risk .compare-score {
        color: #b91c1c !important;
    }
    .palace-meta, .compare-sub { color: #1d4ed8 !important; }
    .gate-good, .palace-good .palace-badge, .legend-dot.good {
        background: #ecfdf5 !important;
        border-color: #22c55e !important;
    }
    .gate-bad, .palace-risk .palace-badge, .legend-dot.risk {
        background: #fef2f2 !important;
        border-color: #ef4444 !important;
    }
    .gate-neutral, .palace-neutral .palace-badge, .legend-dot.neutral, .compare-score {
        background: #fff7ed !important;
        border-color: #f59e0b !important;
    }
}
