:root {
    --night: #07101d;
    --night-2: #101a2d;
    --ink: #172033;
    --paper: #f5efe2;
    --paper-soft: #fbf7ee;
    --gold: #d9ad59;
    --gold-soft: #f3dfb7;
    --jade: #2aa889;
    --jade-soft: #d9f0e8;
    --rose: #9f5f68;
    --muted: #69707d;
    --line: #e5d8bd;
    --white: #ffffff;
    --shadow: 0 22px 60px rgba(20, 24, 35, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.7;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

.topbar {
    position: fixed;
    top: 16px;
    left: 50%;
    z-index: 20;
    width: min(1180px, calc(100% - 32px));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(7, 16, 29, 0.74);
    color: var(--white);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-weight: 850;
    letter-spacing: 0.02em;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--gold), var(--jade));
    color: #08111d;
    font-size: 13px;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.topbar nav a {
    padding: 7px 11px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    font-size: 14px;
}

.topbar nav a:hover {
    background: rgba(255, 255, 255, 0.11);
    color: var(--white);
}

.hero {
    position: relative;
    min-height: 780px;
    overflow: hidden;
    color: var(--white);
    background: var(--night);
}

.hero-bg {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(90deg, rgba(5, 12, 24, 0.92) 0%, rgba(5, 12, 24, 0.72) 38%, rgba(5, 12, 24, 0.22) 70%), url("assets/fatespark-hero.png");
    background-size: cover;
    background-position: center;
}

.hero::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 160px;
    background: linear-gradient(0deg, var(--paper), rgba(245, 239, 226, 0));
}

.hero-inner {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(360px, 0.72fr);
    gap: 34px;
    align-items: center;
    min-height: 780px;
    padding: 116px 0 88px;
}

.hero-copy {
    min-width: 0;
}

.eyebrow,
.section-kicker,
.panel-kicker {
    margin: 0 0 10px;
    color: var(--gold);
    font-size: 13px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 720px;
    margin-bottom: 18px;
    font-size: clamp(48px, 8vw, 104px);
    line-height: 0.94;
    letter-spacing: 0;
}

.hero-subtitle {
    max-width: 700px;
    margin-bottom: 26px;
    color: rgba(255, 255, 255, 0.84);
    font-size: clamp(17px, 2vw, 22px);
}

.hero-points {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hero-points span {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    padding: 6px 12px;
    border: 1px solid rgba(217, 173, 89, 0.36);
    border-radius: 8px;
    background: rgba(7, 16, 29, 0.46);
    color: #f6e6bd;
    font-size: 13px;
}

.oracle-panel,
.result-panel,
.method-list article,
.scene-grid article,
.gua-grid article,
.faq-list details {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 251, 242, 0.94);
    box-shadow: var(--shadow);
}

.oracle-panel {
    min-width: 0;
    padding: 24px;
    color: var(--ink);
}

.panel-heading h2 {
    margin-bottom: 8px;
    font-size: 28px;
    line-height: 1.2;
}

.panel-heading p:last-child {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 14px;
}

.reading-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.cast-mode {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
    margin: 0;
    padding: 4px;
    border: 1px solid #d8c8a8;
    border-radius: 8px;
    background: #fffdf7;
}

.cast-mode legend {
    padding: 0 6px;
    color: #4c5362;
    font-size: 13px;
    font-weight: 750;
}

.cast-mode label {
    position: relative;
    display: grid;
    min-width: 0;
    cursor: pointer;
}

.cast-mode input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.cast-mode span {
    display: grid;
    min-height: 40px;
    place-items: center;
    border-radius: 7px;
    color: #4c5362;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
}

.cast-mode input:checked + span {
    background: var(--night);
    color: var(--gold-soft);
}

.cast-mode input:focus-visible + span {
    box-shadow: 0 0 0 3px rgba(42, 168, 137, 0.22);
}

.mode-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.mode-fields label:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.mode-fields.is-hidden {
    display: none;
}

.field-caption {
    grid-column: 1 / -1;
    color: #4c5362;
    font-size: 13px;
    font-weight: 750;
}

.number-inputs {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.random-fields {
    padding: 12px 14px;
    border: 1px solid #d8c8a8;
    border-radius: 8px;
    background: #fffdf7;
}

.random-fields p {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.reading-form label {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.reading-form label span {
    color: #4c5362;
    font-size: 13px;
    font-weight: 750;
}

.reading-form input,
.reading-form select,
.reading-form textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #d8c8a8;
    border-radius: 8px;
    background: #fffdf7;
    color: var(--ink);
    padding: 10px 12px;
    outline: none;
}

.reading-form input:focus,
.reading-form select:focus,
.reading-form textarea:focus {
    border-color: var(--jade);
    box-shadow: 0 0 0 3px rgba(42, 168, 137, 0.18);
}

.reading-form textarea {
    resize: vertical;
}

.reading-form .wide,
.reading-form button {
    grid-column: 1 / -1;
}

.reading-form button,
.footer a {
    min-height: 46px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--gold), #f1ce79 45%, var(--jade));
    color: #06101d;
    font-weight: 850;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
}

.reading-form button:hover,
.footer a:hover {
    filter: brightness(1.04);
}

.result-section {
    position: relative;
    z-index: 2;
    margin-top: -52px;
    padding: 0 16px 36px;
}

.container {
    width: min(1180px, 100%);
    margin: 0 auto;
}

.result-panel {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 22px;
    padding: 24px;
    background: var(--paper-soft);
}

.result-panel h2 {
    margin-bottom: 8px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.15;
}

.result-panel p {
    color: var(--muted);
}

.hexagram-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 3.4cm;
    row-gap: 12px;
    align-content: start;
    justify-self: center;
    width: min(620px, 100%);
}

.hexagram-pair > div {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.hexagram-pair > div > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}

.hexagram {
    display: grid;
    gap: 10px;
    align-content: center;
    justify-content: stretch;
    width: 100%;
    min-width: 0;
    padding: 16px;
    border: 1px solid #decc9d;
    border-radius: 8px;
    background: #fff9e9;
    overflow: visible;
}

.hexagram span {
    position: relative;
    display: block;
    height: 12px;
    border-radius: 7px;
    background: var(--gold);
}

.hexagram .broken {
    background: linear-gradient(90deg, var(--gold) 0 42%, transparent 42% 58%, var(--gold) 58% 100%);
}

.hexagram .moving {
    box-shadow: 0 0 0 3px rgba(42, 168, 137, 0.2), 0 0 18px rgba(42, 168, 137, 0.22);
}

.hexagram .moving::after {
    content: "动";
    position: absolute;
    right: -8px;
    top: 50%;
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 50%;
    background: var(--jade);
    box-shadow: 0 8px 18px rgba(42, 168, 137, 0.28);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    transform: translate(100%, -50%);
}

.result-grid {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.result-grid div,
.reading-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf7;
}

.result-grid span,
.element-row span:first-child,
.reading-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.result-grid strong {
    display: block;
    margin-top: 5px;
    font-size: 18px;
}

.reading-details {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.reading-card {
    min-width: 0;
    box-shadow: none;
}

.reading-card p {
    margin: 7px 0 0;
    color: var(--ink);
    font-size: 15px;
}

.reading-card p .explain-line {
    display: block;
}

.reading-card p .body-use-line,
.reading-card p .explain-line + .explain-line {
    display: block;
    margin-top: 7px;
}

.reading-card p .body-use-line {
    color: var(--ink);
    font-size: 15px;
    line-height: 1.72;
}

.reading-card p strong {
    color: #2d3547;
    font-weight: 850;
}

.reading-card p .body-use-line:first-child {
    margin-top: 0;
}

.reading-card p .body-use-title,
.reading-card p .body-use-relation {
    color: #151923;
    font-weight: 900;
}

.reading-card p .body-use-relation {
    padding: 1px 5px;
    margin-right: 4px;
    border-radius: 6px;
    background: rgba(42, 168, 137, 0.12);
    color: #126d5a;
}

.element-bars {
    grid-column: 1 / -1;
    display: grid;
    gap: 10px;
}

.element-row {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr) 48px;
    gap: 10px;
    align-items: center;
}

.element-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #eadfca;
}

.element-fill {
    height: 100%;
    border-radius: inherit;
}

.advice-list {
    grid-column: 1 / -1;
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 20px;
}

.section {
    padding: 74px 16px;
}

.section.muted {
    background: #efe6d2;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 0.82fr) minmax(360px, 1fr);
    gap: 34px;
    align-items: start;
}

.split > * {
    min-width: 0;
}

.section h2 {
    margin-bottom: 14px;
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1.16;
}

.section p {
    color: var(--muted);
}

.method-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.method-list article,
.scene-grid article,
.gua-grid article {
    min-width: 0;
    padding: 20px;
}

.method-list span,
.gua-grid span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 32px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: var(--night);
    color: var(--gold-soft);
    font-weight: 850;
}

.method-list h3,
.scene-grid h3,
.gua-grid h3 {
    margin-bottom: 8px;
    font-size: 21px;
}

.method-list p,
.scene-grid p,
.gua-grid p {
    margin-bottom: 0;
    font-size: 15px;
}

.section-heading {
    max-width: 820px;
    margin-bottom: 28px;
}

.section-heading.compact {
    margin-bottom: 22px;
}

.scene-grid,
.gua-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.scene-grid article {
    background: #fffaf0;
}

.gua-grid article {
    background: var(--paper-soft);
}

.gua-grid span {
    width: 46px;
    font-size: 18px;
}

.faq-list {
    display: grid;
    gap: 12px;
}

.faq-list details {
    padding: 18px 20px;
}

.faq-list summary {
    cursor: pointer;
    font-weight: 850;
}

.faq-list p {
    margin: 10px 0 0;
}

.footer {
    padding: 36px 16px;
    background: var(--night);
    color: rgba(255, 255, 255, 0.78);
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.footer strong {
    display: block;
    color: var(--white);
    font-size: 20px;
}

.footer p {
    margin: 4px 0 0;
}

@media (max-width: 980px) {
    .topbar {
        position: absolute;
    }

    .hero-inner,
    .split {
        grid-template-columns: 1fr;
    }

    .hero-inner {
        align-items: end;
        padding-top: 112px;
    }

    .oracle-panel {
        max-width: 680px;
    }

    .result-panel {
        grid-template-columns: 1fr;
    }

    .hexagram-pair {
        column-gap: 48px;
        width: min(620px, 100%);
    }

    .hexagram {
        padding: 14px;
    }

    .scene-grid,
    .gua-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar nav {
        justify-content: flex-start;
    }

    .hero {
        min-height: auto;
    }

    .hero-bg {
        background-image: linear-gradient(180deg, rgba(5, 12, 24, 0.9), rgba(5, 12, 24, 0.72)), url("assets/fatespark-hero.png");
        background-position: center right;
    }

    .hero-inner {
        min-height: auto;
        padding: 152px 0 84px;
    }

    .reading-form,
    .mode-fields,
    .method-list,
    .scene-grid,
    .gua-grid,
    .reading-details,
    .result-grid {
        grid-template-columns: 1fr;
    }

    .cast-mode {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .result-section {
        margin-top: -36px;
    }

    .result-panel,
    .oracle-panel {
        padding: 18px;
    }

    .hexagram-pair {
        width: 100%;
        column-gap: 18px;
        row-gap: 10px;
    }

    .hexagram {
        gap: 8px;
        padding: 12px;
    }

    .element-row {
        grid-template-columns: 112px minmax(0, 1fr) 42px;
    }

    .footer-inner {
        align-items: flex-start;
        flex-direction: column;
    }
}
