.fortune-library { margin-top: 36px; }
.game-grid.fortune-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fortune-grid .game-tile { grid-column: auto; }
.game-tarot .tile-art { background: #dfc0c3; }
.game-saju .tile-art { background: #d4d7be; }
.fortune-grid .tile-art::before {
  background: radial-gradient(#523b5135 1px, transparent 1px) center / 15px 15px;
}
.fortune-art-tarot {
  position: relative;
  width: clamp(64px, 9vw, 102px);
  aspect-ratio: 2 / 3;
  transform: rotate(-10deg);
}
.fortune-art-tarot i { position: absolute; inset: 0; border-radius: 8px; box-shadow: 6px 7px #49323848; }
.fortune-art-tarot span { position: absolute; top: -.05em; left: 120%; color: #7a4352; font: 32px/1 Georgia, serif; }
.fortune-art-saju { display: flex; gap: clamp(3px, 1vw, 8px); transform: rotate(6deg); }
.fortune-art-saju span {
  display: grid;
  width: clamp(24px, 5vw, 49px);
  aspect-ratio: 3 / 4;
  place-items: center;
  border: 1px solid #726958;
  border-radius: 6px;
  background: #fff6d8;
  box-shadow: 3px 4px #62553b42;
  color: #474c39;
  font: 700 clamp(14px, 3vw, 30px)/1 Georgia, "Songti SC", serif;
}
.fortune-art-saju span:nth-child(even) { transform: translateY(12%); color: #834e45; }

.game-view-tarot, .game-view-saju { max-width: 900px; }
.fortune-workbench {
  --fortune-ink: #4e3241;
  --fortune-line: #dfd0cd;
  display: grid;
  min-width: 0;
  gap: 13px;
}
.fortune-workbench-saju { --fortune-ink: #3e523d; --fortune-line: #d5d9ca; }
.fortune-panel {
  min-width: 0;
  padding: clamp(13px, 2.3vw, 21px);
  border: 1px solid var(--fortune-line);
  border-radius: 13px;
  background: var(--surface);
}
.fortune-workbench [hidden] { display: none; }
.fortune-toolbar {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
}
.fortune-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.fortune-fieldset legend, .fortune-field > span, .saju-time-label { margin-bottom: 6px; padding: 0; color: var(--subtle); font-size: 13px; font-weight: 760; }
.fortune-field { display: grid; min-width: 0; align-content: start; }
.fortune-field select, .fortune-field input:not([type="checkbox"]) {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9f6ed;
  color: var(--ink);
  font: 650 16px/1.25 system-ui, sans-serif;
}
.fortune-field select {
  height: 44px;
  padding-right: 28px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 48%, #5c544c 52%),
    linear-gradient(135deg, #5c544c 48%, transparent 52%);
  background-position: right 13px center, right 8px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.fortune-field :is(input, select):focus-visible { outline: 2px solid var(--fortune-ink); outline-offset: 2px; }
.fortune-toolbar .level-options { min-height: 44px; }
.fortune-toolbar .level-options button { white-space: nowrap; }
.fortune-workbench .primary-button { min-height: 44px; background: var(--fortune-ink); }
.fortune-workbench .primary-button:not(:disabled):hover { filter: brightness(1.18); }
.fortune-ai-header, .tarot-stage-top { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.fortune-workbench h2 { color: var(--fortune-ink); font-size: 19px; font-weight: 850; letter-spacing: -.035em; }
.fortune-text { margin-top: 4px; color: var(--subtle); font-size: 14px; line-height: 1.55; }
.fortune-status { margin-top: 8px; }
.fortune-status:empty { display: none; }
.fortune-answer {
  margin-top: 12px;
  padding: 14px;
  border-left: 3px solid var(--fortune-ink);
  border-radius: 0 8px 8px 0;
  background: #f4efe5;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tarot-stage {
  min-width: 0;
  padding: clamp(13px, 2.8vw, 24px);
  border: 1px solid #5b3b46;
  border-radius: 14px;
  background: radial-gradient(ellipse at center 26%, #684653, #3c2b37 78%);
  color: #f7e9d9;
  box-shadow: inset 0 0 0 3px #5e434b;
}
.tarot-stage-top { min-height: 34px; font-size: 13px; font-weight: 630; }
.tarot-stage-top .secondary-button {
  min-height: 34px;
  padding-inline: 9px;
  border-color: #be9e70;
  background: #f8e7ce;
  color: #4e3241;
}
.tarot-spread {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-content: center;
  gap: clamp(7px, 3vw, 27px);
  max-width: 605px;
  margin: 15px auto 4px;
}
.tarot-spread.is-single { grid-template-columns: minmax(0, 185px); }
.tarot-slot { min-width: 0; }
.tarot-position { display: block; margin-bottom: 7px; color: #ffefd9; text-align: center; font-size: 13px; font-weight: 750; line-height: 1.2; }
.tarot-card {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 2 / 3;
  place-items: center;
  padding: 0;
  overflow: hidden;
  border: 1px solid #ba9d70;
  border-radius: clamp(5px, 1vw, 10px);
  box-shadow: 0 4px 8px #21131c62;
}
.tarot-back {
  background:
    url("../assets/tarot-card-back.webp") center / cover,
    repeating-conic-gradient(from 45deg, #493140 0 12deg, #664355 12deg 24deg);
}
button.tarot-back:hover { box-shadow: 0 4px 12px #1c121d, 0 0 0 2px #e9c383; }
button.tarot-back:focus-visible { outline-color: #f7d491; outline-offset: -4px; }
.tarot-back span {
  align-self: end;
  margin: 0 3px 10%;
  padding: 4px 8px;
  border: 1px solid #efc285;
  border-radius: 99px;
  background: #422f39;
  color: #ffe9c8;
  font-size: 11px;
  font-weight: 780;
  white-space: nowrap;
}
.tarot-face {
  grid-template-rows: auto 1fr auto auto;
  gap: 5px;
  padding: 8% 4%;
  background: radial-gradient(ellipse at 50% 41%, #fff7df, #ead7b1);
  color: #604334;
  text-align: center;
}
.tarot-face::before {
  position: absolute;
  inset: 5px;
  border: 1px solid #8d674857;
  border-radius: 5px;
  content: "";
  pointer-events: none;
}
.tarot-numeral, .tarot-orientation { font-size: clamp(9px, 1.75vw, 12px); font-weight: 750; }
.tarot-numeral { font-family: Georgia, serif; }
.tarot-face strong { font-size: clamp(11px, 2.1vw, 17px); font-weight: 850; }
.tarot-symbol { color: #814756; font: 400 clamp(24px, 7vw, 66px)/1 Georgia, "Apple Symbols", serif; }
.tarot-face.is-reversed .tarot-symbol { transform: rotate(180deg); }
.tarot-basic { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 215px), 1fr)); gap: 10px; }
.tarot-note { display: grid; align-content: start; gap: 6px; }
.tarot-note h2 { font-size: 15px; }
.tarot-note p { color: var(--subtle); font-size: 14px; line-height: 1.55; }
.tarot-keywords { color: #855145; font-size: 12px; font-weight: 760; }

.saju-form, .saju-result { display: grid; gap: 12px; }
.saju-form > .primary-button { justify-self: start; }
.saju-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.saju-time-label { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.saju-time-label label:last-child { display: flex; align-items: center; gap: 3px; font-size: 11px; white-space: nowrap; }
.saju-time-label input { width: 13px; height: 13px; margin: 0; accent-color: var(--fortune-ink); }
.saju-fields input[type="time"]:disabled { opacity: .55; }
.saju-privacy { color: var(--subtle); font-size: 12px; line-height: 1.45; }
.saju-pillars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.saju-pillar {
  display: grid;
  min-width: 0;
  gap: 7px;
  justify-items: center;
  align-content: start;
  min-height: 127px;
  padding: 9px 4px;
  border: 1px solid #d8d9c9;
  border-radius: 9px;
  background: #f8f2e4;
}
.saju-pillar h3, .saju-pillar span { font-size: 13px; font-weight: 760; white-space: nowrap; }
.saju-pillar strong { font: 700 clamp(24px, 5vw, 40px)/1 Georgia, "Songti SC", serif; }
.saju-pillar p { align-self: center; color: var(--subtle); font-size: 12px; }
.saju-unknown { grid-template-rows: auto 1fr; border-style: dashed; background: #f5f3ea; }
.saju-elements { display: flex; flex-wrap: wrap; gap: 6px; }
.saju-elements span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 3px 8px;
  border: 1px solid currentColor;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 760;
}
[data-element="목"] { color: #35644f; }
[data-element="화"] { color: #984a3f; }
[data-element="토"] { color: #835625; }
[data-element="금"] { color: #5c625e; }
[data-element="수"] { color: #345772; }

@media (max-width: 620px) {
  .fortune-library { margin-top: 27px; }
  .game-grid.fortune-grid { grid-template-columns: minmax(0, 1fr); }
  .fortune-art-tarot { width: 66px; }
  .fortune-toolbar { grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 9px; }
  .fortune-toolbar > .primary-button { grid-column: 1 / -1; }
  .saju-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .saju-fields > :last-child { grid-column: 1 / -1; }
  .fortune-ai-header { align-items: flex-start; }
}
@media (max-width: 360px) {
  .tarot-position { font-size: 11px; }
  .tarot-spread { gap: 5px; }
  .tarot-face { gap: 3px; }
  .tarot-face::before { inset: 3px; }
  .tarot-back span { padding-inline: 5px; }
  .saju-pillars { gap: 4px; }
}
