:root {
    --ink: #18211f;
    --muted: #60706a;
    --paper: #fffaf0;
    --surface: #ffffff;
    --line: #e6dac4;
    --teal: #116a65;
    --teal-dark: #0b4c49;
    --red: #b64035;
    --gold: #d6a847;
    --shadow: 0 18px 50px rgba(24, 33, 31, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(214, 168, 71, 0.18), transparent 30rem),
        linear-gradient(180deg, #fff7e7 0%, #f6f0e4 52%, #edf5f2 100%);
    font-family: "Segoe UI", Tahoma, Arial, "Helvetica Neue", sans-serif;
    line-height: 1.6;
}

a {
    color: inherit;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(230, 218, 196, 0.8);
    background: rgba(255, 250, 240, 0.9);
    backdrop-filter: blur(14px);
}

.nav {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    gap: 18px;
}

.brand {
    font-weight: 800;
    text-decoration: none;
    color: var(--teal-dark);
}

.nav-links {
    display: flex;
    gap: 18px;
    font-size: 0.95rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--muted);
}

main {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.hero {
    min-height: calc(100vh - 64px);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    gap: 34px;
    align-items: center;
    padding: 54px 0 42px;
}

.hero-copy {
    position: relative;
    padding: 26px 0;
}

.hero-copy::before {
    content: "";
    display: block;
    width: 118px;
    height: 118px;
    margin-bottom: 24px;
    border: 12px solid rgba(182, 64, 53, 0.14);
    border-radius: 50%;
    background:
        linear-gradient(90deg, transparent 44%, rgba(17, 106, 101, 0.52) 44% 56%, transparent 56%),
        linear-gradient(0deg, transparent 44%, rgba(17, 106, 101, 0.52) 44% 56%, transparent 56%),
        #fffdf7;
    box-shadow: inset 0 0 0 2px rgba(17, 106, 101, 0.24), var(--shadow);
}

.eyebrow,
.card-kicker {
    margin: 0 0 10px;
    color: var(--red);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    max-width: 760px;
    font-size: clamp(2.4rem, 7vw, 5.4rem);
    line-height: 0.98;
    letter-spacing: 0;
}

h2 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.08;
}

h3 {
    margin: 0 0 8px;
    font-size: 1.25rem;
    line-height: 1.2;
}

.lead {
    max-width: 680px;
    margin: 22px 0 0;
    color: var(--muted);
    font-size: 1.1rem;
}

.casting-panel,
.hexagram-card,
.notice,
.steps article,
.warning-grid article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow);
}

.casting-panel {
    display: grid;
    gap: 14px;
    padding: 24px;
}

label {
    font-weight: 800;
}

textarea {
    width: 100%;
    min-height: 132px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    color: var(--ink);
    background: #fffdf7;
    font: inherit;
}

textarea:focus {
    outline: 3px solid rgba(17, 106, 101, 0.18);
    border-color: var(--teal);
}

.field-note,
.muted,
.section-heading p,
.site-footer {
    color: var(--muted);
}

.field-note {
    margin: 0;
    font-size: 0.95rem;
}

.casting-flow,
.casting-stage {
    display: grid;
    gap: 12px;
}

.casting-step-note {
    margin: 0;
    font-size: 0.95rem;
    color: var(--teal-dark);
    font-weight: 700;
}

.casting-lines-log {
    max-height: 180px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf7;
    padding: 12px;
}

.coin-tray {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 64px));
    gap: 10px;
}

.coin {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid rgba(17, 106, 101, 0.22);
    background: radial-gradient(circle at 30% 30%, #ffe49f 0%, #d6a847 68%, #b98a33 100%);
    display: grid;
    place-items: center;
    color: #3c2a0a;
    font-weight: 900;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.34);
    transform: translateY(0) rotateY(0deg);
}

.coin span {
    font-size: 0.95rem;
}

.coin.is-flipping {
    animation: coin-flip 0.7s ease-in-out;
}

.coin-status {
    margin: 0;
    min-height: 1.5em;
    font-size: 0.95rem;
    color: var(--teal-dark);
}

.cast-entry {
    margin: 0;
    font-size: 0.95rem;
}

.cast-entry + .cast-entry {
    margin-top: 8px;
}

.primary-button {
    min-height: 52px;
    border: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #fff;
    background: var(--teal);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.primary-button:hover {
    background: var(--teal-dark);
}

.primary-button.is-final {
    background: var(--red);
}

.primary-button.is-final:hover {
    background: #972d25;
}

.button-coins {
    width: 28px;
    height: 18px;
    position: relative;
}

.button-coins::before,
.button-coins::after,
.button-coins {
    border-radius: 50%;
    background: var(--gold);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
}

.button-coins::before,
.button-coins::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 0;
}

.button-coins::before {
    left: -8px;
}

.button-coins::after {
    right: -8px;
}

.reading,
.info-band,
.clear-eyes {
    padding: 58px 0;
}

.section-heading {
    max-width: 760px;
    margin-bottom: 24px;
}

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

.hexagram-card {
    display: grid;
    gap: 18px;
    align-content: start;
    padding: 24px;
}

.hexagram-lines {
    display: grid;
    gap: 10px;
    width: min(100%, 260px);
    padding: 18px;
    border-radius: 8px;
    background: #fff8ea;
}

.line {
    position: relative;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
}

.line span:not(.line-marker) {
    display: block;
    height: 10px;
    border-radius: 999px;
    background: var(--ink);
}

.line-yang span:not(.line-marker) {
    width: 100%;
}

.line-yin span:not(.line-marker) {
    width: calc(50% - 14px);
}

.line-marker {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 24px;
    height: 24px;
    transform: translate(-50%, -50%);
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--red);
    background: #fff8ea;
    font-weight: 900;
    line-height: 1;
}

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

.trigram-list div {
    padding: 12px;
    border-radius: 8px;
    background: #f5fbf8;
}

dt {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

dd {
    margin: 2px 0 0;
    font-weight: 800;
}

.advice {
    margin: 0;
    padding: 14px;
    border-left: 4px solid var(--teal);
    background: #f5fbf8;
    font-weight: 700;
}

.lines-table-wrap {
    margin-top: 20px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.lines-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
}

.lines-table th,
.lines-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.lines-table th {
    background: #fff8ea;
    font-size: 0.9rem;
}

.lines-table tr:last-child td {
    border-bottom: 0;
}

.notice {
    margin-top: 20px;
    padding: 18px;
    background: #fff8ea;
}

.notice-guidance {
    border-left: 4px solid #1f9d45 !important;
    background: #dcfce7 !important;
    color: #14532d;
}

.steps,
.warning-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.steps article,
.warning-grid article {
    padding: 18px;
    box-shadow: none;
}

.steps span {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    margin-bottom: 14px;
    border-radius: 50%;
    color: #fff;
    background: var(--red);
    font-weight: 800;
}

.warning-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.site-footer {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 40px;
    border-top: 1px solid var(--line);
    text-align: center;
}

.is-casting .button-coins {
    animation: coin-wobble 0.5s ease-in-out infinite;
}

@keyframes coin-wobble {
    0%,
    100% {
        transform: rotate(0deg);
    }
    50% {
        transform: rotate(16deg);
    }
}

@keyframes coin-flip {
    0% {
        transform: translateY(0) rotateY(0deg);
    }
    50% {
        transform: translateY(-10px) rotateY(360deg);
    }
    100% {
        transform: translateY(0) rotateY(720deg);
    }
}

@media (max-width: 860px) {
    .hero,
    .result-grid,
    .steps,
    .warning-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        min-height: auto;
        padding-top: 36px;
    }

    .trigram-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .nav {
        align-items: flex-start;
        flex-direction: column;
        padding: 12px 0;
    }

    .nav-links {
        width: 100%;
        justify-content: space-between;
    }

    .casting-panel,
    .hexagram-card {
        padding: 18px;
    }

    .hero-copy::before {
        width: 86px;
        height: 86px;
        border-width: 9px;
    }
}
