:root {
  color-scheme: dark;
  --ink: #eef2e8;
  --muted: #aab9ae;
  --dim: #72847b;
  --jade: #8ebfa4;
  --jade-bright: #c2dbc9;
  --gold: #c7ad72;
  --water: #102b2c;
  --deep: #071617;
  --panel: rgba(12, 32, 32, 0.82);
  --line: rgba(184, 207, 191, 0.16);
  --serif: Iowan Old Style, Palatino Linotype, Book Antiqua, Palatino, Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--sans);
  background: var(--deep);
  color: var(--ink);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; scroll-behavior: smooth; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(73, 125, 108, 0.13), transparent 31rem),
    radial-gradient(circle at 84% 68%, rgba(33, 88, 91, 0.17), transparent 35rem),
    linear-gradient(145deg, #071516, #0a1e1e 56%, #071416);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  opacity: 0.23;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.34'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

button, textarea, input { font: inherit; }
button { color: inherit; }
button, label, summary { -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--jade-bright);
  outline-offset: 4px;
}

.water-light {
  position: fixed;
  inset: auto -10vw -26vh;
  z-index: -1;
  height: 54vh;
  overflow: hidden;
  pointer-events: none;
  filter: blur(1px);
}

.water-light i {
  position: absolute;
  left: 50%;
  bottom: -10%;
  width: 85vw;
  height: 22vw;
  border: 1px solid rgba(103, 172, 161, 0.12);
  border-radius: 50%;
  transform: translateX(-50%) scale(0.7);
  animation: ripple 13s ease-out infinite;
}

.water-light i:nth-child(2) { animation-delay: -4.3s; }
.water-light i:nth-child(3) { animation-delay: -8.6s; }

@keyframes ripple {
  0% { opacity: 0; transform: translateX(-50%) scale(0.45); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1.3); }
}

.site-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand .seal {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 1px solid rgba(199, 173, 114, 0.6);
  color: var(--gold);
  font-family: var(--serif);
  font-size: 22px;
  transform: rotate(-2deg);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 12px; letter-spacing: 0.28em; }
.brand small { margin-top: 3px; color: var(--dim); font-family: var(--serif); font-size: 12px; font-style: italic; }

.sound-toggle, .back-button, .text-button {
  border: 0;
  background: none;
  cursor: pointer;
}

.sound-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 0 10px 14px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sound-toggle span { color: var(--jade); font-size: 20px; }

.sound-panel {
  position: absolute;
  top: 76px;
  right: 0;
  width: min(330px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(7, 22, 23, 0.97);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(18px);
}

.sound-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.sound-heading strong, .sound-heading small { display: block; }
.sound-heading strong { font-family: var(--serif); font-size: 18px; font-weight: 400; }
.sound-heading small { margin-top: 3px; color: var(--dim); font-size: 11px; }
.sound-panel label { display: grid; grid-template-columns: 54px 1fr; gap: 12px; align-items: center; margin: 12px 0; color: var(--muted); font-size: 12px; }
.sound-panel input { width: 100%; accent-color: var(--jade); }
.mini-button { padding: 7px 12px; border: 1px solid var(--jade); border-radius: 2px; background: transparent; color: var(--jade-bright); cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.text-button { padding: 7px 0 0; color: var(--jade); font-size: 12px; }
.text-button:disabled { color: var(--dim); cursor: not-allowed; }

main { width: 100%; }
.screen { width: min(1040px, calc(100% - 48px)); min-height: calc(100vh - 92px); margin: 0 auto; padding: 92px 0 110px; }
.intention-screen { width: min(760px, calc(100% - 48px)); text-align: center; }

.eyebrow {
  margin: 0 0 19px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 0.95;
}

h1 { font-size: clamp(55px, 9vw, 92px); }
h2 { font-size: clamp(48px, 7vw, 78px); }
h1 em, h2 em { color: var(--jade-bright); font-weight: 400; }

.lede {
  width: min(600px, 100%);
  margin: 32px auto 52px;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.65;
}

.intro-mark { display: flex; flex-direction: column-reverse; gap: 6px; width: 42px; margin: 0 auto 34px; }
.intro-mark span { display: block; height: 3px; background: var(--jade); opacity: 0.68; }
.intro-mark span:nth-child(2), .intro-mark span:nth-child(5) { background: linear-gradient(90deg, var(--jade) 0 43%, transparent 43% 57%, var(--jade) 57%); }

.intention-form { text-align: left; }
.question-label, .method-picker legend { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; }
.question-label { display: block; margin-bottom: 10px; }

textarea {
  display: block;
  width: 100%;
  min-height: 128px;
  resize: vertical;
  padding: 22px 24px;
  border: 1px solid rgba(168, 196, 179, 0.26);
  border-radius: 2px;
  background: rgba(4, 16, 17, 0.48);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(20px, 4vw, 27px);
  line-height: 1.45;
  transition: border-color 180ms ease, background 180ms ease;
}

textarea:focus { border-color: rgba(142, 191, 164, 0.78); background: rgba(7, 22, 22, 0.72); outline: none; }
textarea::placeholder { color: #61746b; }
.hint { margin: 9px 2px 34px; color: var(--dim); font-size: 11px; }

.method-picker { display: grid; gap: 10px; margin: 0 0 20px; padding: 0; border: 0; }
.method-picker legend { margin-bottom: 12px; }
.method-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr 24px;
  gap: 16px;
  align-items: center;
  min-height: 78px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(9, 27, 27, 0.58);
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease;
}
.method-card:hover { transform: translateY(-1px); border-color: rgba(142, 191, 164, 0.4); }
.method-card:has(input:checked) { border-color: rgba(142, 191, 164, 0.7); background: rgba(19, 49, 45, 0.58); }
.method-card input { position: absolute; opacity: 0; }
.method-card strong, .method-card small { display: block; }
.method-card strong { font-family: var(--serif); font-size: 19px; font-weight: 400; }
.method-card small { margin-top: 4px; color: var(--dim); font-size: 11px; }
.method-card .check { color: transparent; }
.method-card:has(input:checked) .check { color: var(--jade); }
.method-icon { color: var(--gold); }
.coin-icon { display: grid; height: 42px; place-items: center; border: 1px solid rgba(199, 173, 114, 0.55); border-radius: 50%; font-family: var(--serif); font-size: 14px; }
.stalk-icon { display: flex; align-items: center; justify-content: center; height: 44px; }
.stalk-icon i { width: 1px; height: 38px; margin: 0 2px; background: var(--gold); transform: rotate(var(--r, -5deg)); }
.stalk-icon i:nth-child(2) { --r: 3deg; height: 43px; }.stalk-icon i:nth-child(3) { --r: -2deg; }.stalk-icon i:nth-child(4) { --r: 6deg; height: 41px; }.stalk-icon i:nth-child(5) { --r: 0deg; }

.primary-button, .secondary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 60px;
  padding: 0 22px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: transform 180ms ease, filter 180ms ease, background 180ms ease;
}
.primary-button { border: 1px solid #9bc7ac; background: #9bc7ac; color: #09201c; }
.primary-button:hover { filter: brightness(1.09); transform: translateY(-1px); }
.primary-button:active { transform: translateY(1px); }
.secondary-button { justify-content: center; border: 1px solid var(--line); background: transparent; color: var(--muted); }

.about-ritual { width: min(560px, 100%); margin: 34px auto 0; color: var(--dim); font-family: var(--serif); font-size: 13px; line-height: 1.6; }
.about-ritual summary { cursor: pointer; color: var(--muted); font-family: var(--sans); font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; }

.casting-header, .reading-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 62px; color: var(--dim); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; }
.back-button { padding: 10px 10px 10px 0; color: var(--muted); font-size: 11px; }
.casting-screen > h2, .reading-screen > h2 { max-width: 720px; }
.question-echo, .reading-question { max-width: 690px; margin: 26px 0 54px; padding-left: 18px; border-left: 1px solid var(--gold); color: var(--muted); font-family: var(--serif); font-size: 17px; font-style: italic; line-height: 1.55; }
.casting-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; align-items: stretch; }
.ritual-stage, .forming-card { border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(8px); }
.ritual-stage { min-height: 430px; padding: clamp(26px, 5vw, 48px); }
.ritual-instruction { margin: 0 0 35px; color: var(--jade-bright); font-family: var(--serif); font-size: 22px; }
.stalk-field { display: grid; grid-template-columns: var(--left, 50fr) 30px var(--right, 50fr); align-items: center; height: 138px; margin: 0 0 28px; }
.stalk-pile { height: 112px; opacity: 0.76; background: repeating-linear-gradient(93deg, transparent 0 5px, var(--gold) 5px 6px, transparent 6px 9px); transition: flex 200ms ease; mask-image: linear-gradient(to bottom, transparent, black 14%, black 88%, transparent); }
.stalk-pile.left { transform: skewY(-2deg); }.stalk-pile.right { transform: skewY(2deg); }
.stalk-gap { position: relative; height: 100%; }
.stalk-gap::before { position: absolute; top: 50%; left: 50%; width: 1px; height: 82%; content: ""; background: rgba(142, 191, 164, 0.38); transform: translate(-50%, -50%); }
.split-control { display: grid; gap: 12px; color: var(--dim); font-size: 11px; }
.split-control input { width: 100%; accent-color: var(--jade); cursor: ew-resize; }
.cast-button { margin-top: 28px; }
.ritual-note { min-height: 18px; margin: 16px 0 0; color: var(--dim); font-family: var(--serif); font-size: 12px; font-style: italic; text-align: center; }

.forming-card { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 430px; padding: 30px; }
.card-kicker { color: var(--dim); font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; }
.forming-card p { margin: 24px 0 0; color: var(--dim); font-family: var(--serif); font-size: 12px; font-style: italic; text-align: center; }
.forming-hexagram { display: flex; flex-direction: column; gap: 11px; width: 122px; min-height: 176px; margin-top: 28px; justify-content: flex-end; }
.hex-line { position: relative; display: flex; gap: 15px; align-items: center; height: 10px; animation: receive-line 500ms ease both; }
.hex-line::before, .hex-line::after { height: 8px; content: ""; background: var(--jade-bright); box-shadow: 0 0 18px rgba(142, 191, 164, 0.12); }
.hex-line.yang::before { width: 100%; }.hex-line.yang::after { display: none; }
.hex-line.yin::before, .hex-line.yin::after { width: calc(50% - 7.5px); }
.hex-line.changing::before, .hex-line.changing::after { background: var(--gold); }
.hex-line .change-mark { position: absolute; left: calc(100% + 10px); color: var(--gold); font-size: 12px; }
.hex-line.placeholder::before { width: 100%; height: 1px; background: rgba(184, 207, 191, 0.09); }.hex-line.placeholder::after { display: none; }
@keyframes receive-line { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.live-status { min-height: 20px; margin-top: 16px; color: var(--muted); font-size: 11px; text-align: center; }

.coins { display: flex; justify-content: center; gap: clamp(12px, 4vw, 30px); margin: 50px auto 58px; perspective: 800px; }
.coins span { display: grid; width: clamp(72px, 13vw, 100px); aspect-ratio: 1; place-items: center; border: 2px solid var(--gold); border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ddcb95, #92753e 70%, #5d4826); box-shadow: inset 0 0 0 7px rgba(45, 31, 14, 0.34), 0 16px 30px rgba(0, 0, 0, 0.25); color: #392a17; font-family: var(--serif); font-size: 25px; }
.coins.throwing span { animation: coin-toss 700ms cubic-bezier(.2,.8,.2,1); }
.coins.throwing span:nth-child(2) { animation-delay: 80ms; }.coins.throwing span:nth-child(3) { animation-delay: 140ms; }
@keyframes coin-toss { 0% { transform: translateY(0) rotateX(0); } 48% { transform: translateY(-70px) rotateX(620deg); } 100% { transform: translateY(0) rotateX(1080deg); } }

.reading-screen { width: min(960px, calc(100% - 48px)); }
.reading-hero { display: grid; grid-template-columns: 190px 1fr; gap: clamp(28px, 7vw, 72px); align-items: center; margin: 20px 0 44px; padding: clamp(28px, 6vw, 56px); border: 1px solid var(--line); background: var(--panel); }
.big-hex { text-align: center; }
.big-hex .unicode { display: block; color: var(--jade-bright); font-size: 126px; line-height: 0.82; text-shadow: 0 0 45px rgba(142, 191, 164, 0.12); }
.big-hex small { display: block; margin-top: 18px; color: var(--dim); font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; }
.reading-identity .number { color: var(--gold); font-size: 10px; letter-spacing: 0.23em; text-transform: uppercase; }
.reading-identity h3 { margin: 10px 0 3px; font-family: var(--serif); font-size: clamp(34px, 6vw, 55px); font-weight: 400; line-height: 1; }
.reading-identity .han { color: var(--muted); font-family: var(--serif); font-size: 20px; }
.reading-values { margin-top: 22px; color: var(--dim); font-size: 10px; }
.reading-block { display: grid; grid-template-columns: 132px 1fr; gap: 28px; padding: 34px 0; border-top: 1px solid var(--line); }
.reading-block h4 { margin: 3px 0 0; color: var(--gold); font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; }
.reading-block p { margin: 0; color: #c6d0c7; font-family: var(--serif); font-size: 18px; line-height: 1.7; }
.moving-lines { margin-top: 12px; }
.moving-line { padding: 26px 0; border-top: 1px solid rgba(184, 207, 191, 0.1); }
.moving-line:first-child { padding-top: 0; border-top: 0; }
.moving-line strong { display: block; margin-bottom: 7px; color: var(--jade); font-family: var(--sans); font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; }
.relating-card { display: grid; grid-template-columns: 72px 1fr; gap: 22px; align-items: start; margin-top: 20px; padding: 24px; border: 1px solid var(--line); background: rgba(6, 20, 20, 0.48); }
.relating-card .unicode { color: var(--jade); font-size: 64px; line-height: 1; }
.relating-card h4 { margin: 1px 0 5px; color: var(--ink); font-family: var(--serif); font-size: 23px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.relating-card p { color: var(--muted); font-size: 15px; }
.reflection-card { margin: 28px 0 54px; padding: clamp(28px, 6vw, 48px); border: 1px solid rgba(199, 173, 114, 0.32); background: linear-gradient(135deg, rgba(91, 74, 40, 0.11), rgba(14, 39, 36, 0.43)); }
.reflection-card .eyebrow { margin-bottom: 14px; }
.reflection-card > p { margin: 0; color: var(--ink); font-family: var(--serif); font-size: 22px; line-height: 1.55; }
.reflection-card ul { margin: 24px 0 0; padding: 0 0 0 20px; color: var(--muted); font-family: var(--serif); line-height: 1.6; }
.reflection-card li + li { margin-top: 9px; }

.save-panel { display: grid; grid-template-columns: 1fr minmax(250px, 360px); gap: 12px 34px; align-items: center; margin-top: 30px; padding: clamp(24px, 5vw, 38px); border: 1px solid var(--line); background: rgba(13, 36, 34, 0.66); }
.save-panel strong { font-family: var(--serif); font-size: 24px; font-weight: 400; }
.save-panel p { margin: 7px 0 0; color: var(--dim); font-size: 12px; line-height: 1.5; }
.save-panel code { color: var(--muted); }
.save-panel .secondary-button { grid-column: 2; min-height: 46px; }
.save-status { grid-column: 1 / -1; min-height: 0; text-align: right; }
.source-note { margin-top: 42px; color: var(--dim); font-family: var(--serif); font-size: 12px; font-style: italic; line-height: 1.6; text-align: center; }

@media (max-width: 760px) {
  .site-header, .screen, .intention-screen, .reading-screen { width: min(100% - 32px, 760px); }
  .site-header { padding: 18px 0; }
  .brand small { display: none; }
  .sound-toggle { font-size: 10px; }
  .screen { min-height: calc(100vh - 76px); padding: 66px 0 80px; }
  .lede { margin: 26px auto 40px; font-size: 17px; }
  .casting-header, .reading-topbar { margin-bottom: 42px; }
  .casting-layout { grid-template-columns: 1fr; }
  .forming-card { min-height: 280px; }
  .ritual-stage { min-height: 390px; }
  .reading-hero { grid-template-columns: 1fr; text-align: center; }
  .big-hex .unicode { font-size: 100px; }
  .reading-block { grid-template-columns: 1fr; gap: 14px; }
  .save-panel { grid-template-columns: 1fr; }
  .save-panel .secondary-button { grid-column: 1; }
  .save-status { text-align: left; }
}

@media (max-width: 430px) {
  .method-card { grid-template-columns: 40px 1fr 18px; gap: 12px; padding: 13px; }
  .method-card small { line-height: 1.4; }
  .question-echo, .reading-question { margin-bottom: 40px; }
  .ritual-stage { padding: 24px 18px; }
  .coins span { width: 72px; }
  .relating-card { grid-template-columns: 56px 1fr; padding: 18px; }
  .relating-card .unicode { font-size: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
