:root {
  color-scheme: dark;
  --page: #0b1020;
  --surface: #121a2d;
  --surface-deep: #0d1424;
  --ink: #f0ede5;
  --muted: #b6bbcb;
  --gold: #d9bc79;
  --gold-ink: #171b25;
  --rule: #35405a;
  --soft-rule: #28344c;
  --error: #ffc2b9;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif; line-height: 1.75; }
button, textarea { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; }
a { color: var(--gold); text-underline-offset: 4px; }
button { cursor: pointer; }
button:disabled { cursor: default; }
::selection { background: #695933; color: #fff; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 5px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; left: 18px; top: -90px; z-index: 10; padding: 10px 18px; background: var(--gold); color: var(--gold-ink); }
.skip-link:focus { top: 14px; }
.wrap { width: min(100% - 40px, 820px); margin: 0 auto; }
.site-nav { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 16px; padding: 24px 0; border-bottom: 1px solid var(--soft-rule); font-size: 13px; }
.site-nav a { text-decoration: none; }
.site-name { color: var(--ink); }
.module-nav { display: flex; flex-wrap: wrap; gap: 10px 17px; }
.intro { padding: 43px 0 28px; }
h1, h2, h3, p { margin: 0; }
h1 { font-family: 'Nanum Myeongjo', 'Batang', serif; font-size: clamp(38px, 7vw, 54px); line-height: 1.35; font-weight: 600; }
h1 span { margin-left: 14px; color: var(--gold); font-size: clamp(19px, 3.4vw, 26px); font-weight: 400; }
.lead { margin-top: 17px; font-size: 18px; color: var(--ink); }
.intro-copy { margin-top: 7px; max-width: 62ch; color: var(--muted); font-size: 14px; }
.draw-panel { padding: 28px; border: 1px solid var(--rule); border-radius: 16px; background: var(--surface); }
.draw-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.stage { width: 100%; max-width: 400px; margin-inline: auto; }
.question-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 16px; font-weight: 600; }
.optional { font-size: 12px; color: var(--muted); font-weight: 400; }
textarea { width: 100%; min-height: 108px; margin-top: 10px; padding: 13px 15px; background: var(--surface-deep); border: 1px solid var(--rule); border-radius: 9px; color: var(--ink); resize: vertical; font-size: 14px; line-height: 1.7; caret-color: var(--gold); }
textarea::placeholder { color: #a2aabc; opacity: 1; }
textarea:read-only { color: var(--muted); }
.privacy-copy { font-size: 12px; color: var(--muted); margin-top: 7px; line-height: 1.7; }
.draw-instruction { max-width: 54ch; margin: 0 auto; font-size: 13px; color: var(--muted); text-align: center; }
.draw-instruction strong { color: var(--ink); font-weight: 500; }
.stage-heading { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; gap: 12px; }
.stage-heading strong { font-weight: 500; }
.progress-count { color: var(--gold); font-variant-numeric: tabular-nums; font-size: 12px; }
.line-stack { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.line-row { display: grid; grid-template-columns: 37px 1fr 51px; gap: 10px; align-items: center; min-height: 23px; font-size: 11px; font-variant-numeric: tabular-nums; }
.line-number { color: var(--muted); }
.line-shape { display: flex; gap: 13px; height: 8px; align-items: stretch; }
.line-shape span { flex: 1; background: var(--ink); border-radius: 1px; }
.line-row.moving .line-shape span { background: var(--gold); }
.line-state { text-align: right; color: var(--muted); white-space: nowrap; }
.line-row.moving .line-state { color: var(--gold); }
.stage-caption { margin-top: 13px; font-size: 11px; color: var(--muted); text-align: center; }
.coin-result { display: flex; align-items: center; justify-content: center; min-height: 41px; margin-top: 13px; gap: 8px; }
.coin { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid #968258; border-radius: 50%; font-size: 12px; color: var(--gold); font-variant-numeric: tabular-nums; }
.coin-sum { margin-left: 4px; font-size: 12px; color: var(--muted); }
.coin-toss { display: block; width: 100%; margin-top: 16px; padding: 4px 12px 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface-deep); color: var(--ink); text-align: center; transition: border-color .15s, background .15s; touch-action: manipulation; }
.coin-toss:hover:not(:disabled) { border-color: var(--gold); background: var(--surface); }
.coin-toss:active:not(:disabled) { background: var(--soft-rule); }
.coin-toss:disabled { cursor: default; }
.coin-toss .coin-result { margin-top: 0; }
.coin-prompt { margin-top: 16px; color: var(--gold); text-align: center; font-size: 15px; font-weight: 600; }
.coin-prompt.is-idle { animation: coinPromptPulse 1.8s ease-in-out infinite; }
.coin-prompt + .coin-toss { margin-top: 8px; }
@keyframes coinPromptPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.coin-toss-label, .coin-toss-step { display: block; }
.coin-toss-label { color: var(--gold); font-size: 15px; font-weight: 600; line-height: 1.6; }
.coin-toss-step { margin-top: 3px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#draw-lines { min-height: 0; justify-content: flex-end; margin-top: 24px; }
#draw-lines:empty, #draw-lines:empty + .stage-caption { display: none; }
.draw-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 25px; }
.btn { min-height: 47px; padding: 10px 18px; border: 1px solid var(--rule); border-radius: 8px; background: transparent; color: var(--ink); font-size: 14px; font-weight: 500; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { background: #263149; border-color: #747d91; }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: #e7ce97; border-color: #e7ce97; }
.btn:disabled { color: #a3aabd; background: #20293e; border-color: #344058; }
.reset-btn { margin-left: 0; font-size: 12px; padding-inline: 12px; }
.status { margin-top: 14px; font-size: 13px; color: var(--muted); min-height: 23px; }
#coin-draw:not([hidden]) ~ .status { text-align: center; }
.error-message { margin-top: 9px; color: var(--error); font-size: 13px; }
.reading { margin-top: 43px; }
.reading-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 17px; border-bottom: 1px solid var(--rule); }
h2 { font-size: 23px; line-height: 1.5; font-weight: 600; }
.reading-heading .btn { min-height: 40px; padding-block: 7px; font-size: 12px; flex-shrink: 0; }
.question-echo { margin-top: 21px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }
.question-echo b { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 500; }
.hexagrams { display: grid; grid-template-columns: 1fr; gap: 32px; margin-top: 25px; }
.hexagrams.has-change { grid-template-columns: 1fr 1fr; }
.hex-kind { display: flex; align-items: baseline; gap: 10px; font-size: 13px; color: var(--muted); }
.hex-kind strong { color: var(--gold); font-weight: 500; }
.hex-name { margin-top: 6px; font-size: 25px; font-weight: 600; line-height: 1.6; }
.hex-name span { margin-left: 8px; font-size: 16px; font-weight: 400; color: var(--muted); }
.hex-image { display: flex; align-items: center; gap: 25px; margin-top: 19px; padding: 19px 0; border-top: 1px solid var(--soft-rule); border-bottom: 1px solid var(--soft-rule); }
.hex-image .line-stack { width: 145px; margin-top: 0; gap: 8px; }
.hex-image .line-row { grid-template-columns: 23px 1fr 48px; gap: 8px; min-height: 19px; }
.hex-image .line-shape { height: 7px; gap: 10px; }
.trigram-info { font-size: 12px; color: var(--muted); line-height: 1.85; }
.trigram-info span { display: block; }
.trigram-info b { font-weight: 500; color: var(--ink); }
.hex-theme { margin-top: 21px; color: var(--gold); font-weight: 500; font-size: 18px; }
.hex-summary { margin-top: 8px; font-size: 14px; color: var(--ink); line-height: 1.9; max-width: 70ch; }
.advice-label { margin-top: 19px; color: var(--muted); font-size: 12px; }
.hex-advice { margin-top: 4px; font-size: 14px; line-height: 1.9; }
.no-change { margin-top: 24px; color: var(--muted); font-size: 13px; }
.reflection-area { margin-top: 35px; padding-top: 25px; border-top: 1px solid var(--rule); }
h3 { font-size: 18px; font-weight: 600; line-height: 1.6; }
.section-note { margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.85; }
.coin-overall p { margin-top: 15px; max-width: 70ch; font-size: 15px; line-height: 1.9; }
.coin-overall p:last-child { color: var(--gold); }
.draw-record { margin-top: 29px; border-top: 1px solid var(--soft-rule); padding-top: 16px; }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); width: fit-content; }
.table-wrap { overflow-x: auto; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 400; padding: 9px 10px; border-bottom: 1px solid var(--rule); }
td { padding: 9px 10px; border-bottom: 1px solid var(--soft-rule); }
th:first-child, td:first-child { padding-left: 0; }
.about { margin-top: 38px; padding-top: 21px; border-top: 1px solid var(--rule); }
.about-content { color: var(--muted); font-size: 12px; line-height: 1.9; max-width: 70ch; }
.about-content p { margin-top: 12px; }
.rules { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; font-size: 12px; }
.rules div { padding-bottom: 11px; border-bottom: 1px solid var(--soft-rule); }
.rules b, .rules span { display: block; }
.rules b { color: var(--ink); font-weight: 500; }
.rules span { color: var(--muted); }
.sources { padding-left: 18px; margin-top: 12px; }
.sources li { margin-top: 6px; }
footer { padding: 35px 0 30px; color: var(--muted); font-size: 11px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
@media (max-width: 600px) {
  .wrap { width: min(100% - 32px, 820px); }
  .site-nav { padding: 19px 0; font-size: 12px; }
  .module-nav { flex-basis: 100%; }
  .intro { padding-top: 32px; }
  .lead { font-size: 17px; }
  .draw-panel { padding: 21px 19px; }
  .draw-grid { gap: 24px; }
  .stage { max-width: 340px; width: 100%; margin-inline: auto; }
  .draw-actions { gap: 8px; margin-top: 20px; }
  .draw-actions .btn-primary { width: 100%; }
  .draw-actions .btn-secondary { flex: 1; }
  .reset-btn { margin-left: 0; }
  .hexagrams.has-change { grid-template-columns: 1fr; }
  .hexagrams.has-change .hex-card + .hex-card { border-top: 1px solid var(--rule); padding-top: 25px; }
  .hex-name { font-size: 24px; }
  .hex-image { gap: 20px; }
  .hex-image .line-stack { width: 148px; }
  .reading { margin-top: 33px; }
  .rules { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
  .coin-toss { padding-inline: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .coin-prompt.is-idle { animation: none; }
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* The user's existing 64-card deck, with a shared v3 back. */
.question-area textarea { min-height: 74px; }
.draw-modes { display: flex; gap: 8px; padding: 24px 0 20px; margin-bottom: 22px; border-bottom: 1px solid var(--soft-rule); }
.mode-btn { min-height: 44px; padding: 9px 17px; border: 1px solid var(--rule); border-radius: 8px; background: transparent; color: var(--muted); font-size: 14px; }
.mode-btn[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 600; }
.mode-btn:hover:not([aria-pressed="true"]) { color: var(--ink); border-color: var(--gold); }
.deck-heading { text-align: center; margin-bottom: 24px; }
.deck-heading h2 { font-family: 'Nanum Myeongjo', 'Batang', serif; font-size: 22px; font-weight: 500; }
.deck-heading p { margin-top: 6px; font-size: 13px; color: var(--muted); }
.card-actions { display: flex; justify-content: center; margin-top: 20px; }
.card-actions .btn { min-width: 164px; }
.orbit-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }
.orbit-controls .btn { min-height: 44px; font-size: 12px; }
.selection-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--soft-rule); }
.selection-heading h3 { font-size: 15px; }
#selected-count { font-size: 13px; color: var(--gold); font-variant-numeric: tabular-nums; }
.selection-empty { margin-top: 9px; color: var(--muted); font-size: 13px; }
.chosen-cards { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px 14px; list-style: none; padding: 0; margin: 15px 0 0; }
.chosen-cards:empty { display: none; }
.chosen-cards li { min-width: 0; text-align: center; }
.chosen-card { display: block; position: relative; width: 76px; max-width: 100%; padding: 0; border: 0; border-radius: 6px; margin: 0 auto; background: var(--surface-deep); }
.chosen-card img { display: block; width: 100%; height: auto; border-radius: inherit; }
.chosen-order { position: absolute; top: -7px; right: -7px; display: grid; place-items: center; min-width: 23px; height: 23px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); font-size: 12px; font-weight: 600; }
.chosen-name { display: block; margin-top: 7px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.reading-overview, .long-card-reading, .final-advice { margin-top: 32px; padding-top: 26px; }
.long-card-reading, .final-advice { border-top: 1px solid var(--rule); }
.long-card-reading { scroll-margin-top: 26px; }
.reading-overview h3, .long-card-reading h3, .final-advice h3 { font-family: 'Nanum Myeongjo', 'Batang', serif; font-size: 23px; line-height: 1.6; color: var(--ink); }
.reading-overview p, .long-card-reading > p, .final-advice > p { max-width: 70ch; margin-top: 14px; font-size: 15px; line-height: 1.95; }
.long-card-reading > .hex-theme { color: var(--gold); font-size: 17px; margin-top: 8px; }
.section-hanja { color: var(--muted); font-size: 15px; font-weight: 400; margin-left: 10px; }
.long-card-reading > .advice-label { font-size: 12px; color: var(--gold); margin-top: 22px; }
.long-card-reading > .hex-advice { margin-top: 3px; }
.long-card-reading > .section-reflection { color: var(--muted); font-size: 14px; }
.reading-overview > .reading-method, .final-advice > .reading-method { font-size: 12px; color: var(--muted); }
.final-advice { padding-bottom: 15px; }
.final-advice h3 { color: var(--gold); }
.final-advice h4 { margin: 26px 0 0; font-size: 16px; font-weight: 600; }
.final-advice ol { padding-left: 24px; margin: 13px 0 0; }
.final-advice li { padding-left: 6px; margin-top: 12px; font-size: 15px; line-height: 1.9; max-width: 70ch; }
.final-advice .btn { margin-top: 24px; }
.reading-summary { margin-top: 25px; }
.reading-summary h3 { font-family: 'Nanum Myeongjo', 'Batang', serif; font-size: 27px; line-height: 1.6; color: var(--gold); }
.summary-point { margin-top: 22px; max-width: 68ch; }
.summary-point h4 { margin: 0 0 5px; font-size: 14px; font-weight: 600; }
.summary-point p { font-size: 16px; line-height: 1.85; }
.detail-heading { margin-top: 28px; margin-bottom: 14px; font-size: 16px; font-weight: 500; color: var(--muted); }
details.long-card-reading { margin-top: 0; padding: 13px 0; border-top: 1px solid var(--soft-rule); }
details.long-card-reading > summary { width: auto; font-size: 14px; color: var(--ink); min-height: 25px; line-height: 1.8; }
details.long-card-reading .section-hanja { font-size: 12px; }
details.long-card-reading > p { font-size: 15px; }
@media (max-width: 600px) {
  .question-area textarea { min-height: 92px; }
  .draw-modes { padding-top: 20px; gap: 7px; }
  .mode-btn { flex: 1; padding-inline: 8px; font-size: 13px; }
  .deck-heading h2 { font-size: 19px; }
  .deck-heading p { font-size: 12px; }
  .chosen-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 17px 10px; }
  .chosen-card { width: 60px; }
  .reading-overview h3, .long-card-reading h3, .final-advice h3 { font-size: 21px; }
  .orbit-controls .btn { padding-inline: 12px; }
  .reading-summary h3 { font-size: 23px; }
  .summary-point p { font-size: 15px; }
  .reading-heading { align-items: start; gap: 12px; }
  .reading-heading h2 { font-size: 20px; }
  .reading-heading .btn { min-height: 44px; padding: 8px 10px; }
}

/* A selected thumbnail opens its original front in a focused, larger view. */
body.card-preview-open { overflow: hidden; }
.card-preview { width: min(400px, calc(100% - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); margin: auto; padding: 0; border: 1px solid var(--rule); border-radius: 16px; background: var(--surface-deep); color: var(--ink); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--rule) var(--surface-deep); }
.card-preview[open] { animation: cardPreviewReveal 280ms cubic-bezier(.16, 1, .3, 1); }
.card-preview::backdrop { background: rgba(3, 7, 16, .78); }
.card-preview[open]::backdrop { animation: cardPreviewBackdrop 180ms ease-out; }
.card-preview-content { padding: 20px; }
.card-preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-preview-heading h2 { font-family: 'Nanum Myeongjo', 'Batang', serif; font-size: 24px; font-weight: 500; color: var(--gold); }
.card-preview-close { flex-shrink: 0; min-height: 44px; padding: 8px 12px; font-size: 13px; }
.card-preview-image { display: block; width: min(100%, 264px); height: auto; max-height: min(56vh, 450px); max-height: min(56dvh, 450px); margin: 16px auto 0; border-radius: 8px; object-fit: contain; }
.card-preview-description { margin-top: 14px; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.final-advice > .consultation-hook { margin-top: 30px; color: var(--ink); font-size: 18px; font-weight: 600; }
.final-advice > .consultation-support { margin-top: 6px; color: var(--muted); font-size: 14px; }
.consultation-link { display: inline-flex; align-items: center; justify-content: center; max-width: 100%; text-align: center; text-decoration: none; }
.final-advice .consultation-link { margin-top: 14px; }
@keyframes cardPreviewReveal { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cardPreviewBackdrop { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 380px) {
  .card-preview-content { padding: 16px; }
  .card-preview-heading h2 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .card-preview[open], .card-preview[open]::backdrop { animation: none; }
}
