:root {
  --theme-gold: #f2c86c;
  --theme-gold-bright: #ffe7a7;
  --theme-gold-deep: #9f6720;
  --theme-ink: #020806;
  --theme-ease-out: cubic-bezier(.23, 1, .32, 1);
  --theme-ease-move: cubic-bezier(.77, 0, .175, 1);
}

body[data-page="theme-draw"] {
  min-height: 100vh;
  color: #fff0c8;
  background: #020806;
}

body[data-page="theme-draw"]::before {
  opacity: .18;
}

.theme-page-shell {
  width: 100%;
  min-height: 100vh;
  padding: 0;
  background: linear-gradient(180deg, rgba(0, 5, 4, .98), rgba(2, 8, 6, .95));
}

.home-topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 18px);
  min-height: 74px;
  margin: 0 auto;
  padding: 0 clamp(24px, 3vw, 52px);
  border: 1px solid rgba(242, 200, 108, .72);
  background: linear-gradient(90deg, rgba(1, 8, 7, .98), rgba(5, 18, 15, .94), rgba(1, 8, 7, .98));
  box-shadow: inset 0 0 0 7px rgba(0, 0, 0, .28), 0 8px 34px rgba(0, 0, 0, .34);
}

.home-topbar::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--theme-gold);
  box-shadow: 0 0 16px rgba(242, 200, 108, .72);
  transform: translateX(-50%);
}

.home-brand {
  display: inline-flex;
  align-items: center;
  min-width: clamp(230px, 20vw, 310px);
  min-height: 50px;
  padding: 0 28px;
  color: #f7d77f;
  border: 1px solid rgba(242, 200, 108, .56);
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: clamp(1.65rem, 2.15vw, 2.25rem);
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1;
  text-decoration: none;
  text-shadow: 0 0 18px rgba(242, 200, 108, .32);
}

.home-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(22px, 2.8vw, 44px);
}

.home-nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 2px;
  color: rgba(255, 238, 197, .74);
  font: 700 clamp(.9rem, 1vw, 1.08rem) / 1.1 "Songti SC", "STSong", serif;
  letter-spacing: .02em;
  text-decoration: none;
  white-space: nowrap;
  transition: color 150ms ease;
}

.home-nav-link::after {
  content: "";
  position: absolute;
  right: 50%;
  bottom: 2px;
  left: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--theme-gold), #75bba9, transparent);
  box-shadow: 0 0 12px rgba(242, 200, 108, .5);
  transition: right 180ms var(--theme-ease-out), left 180ms var(--theme-ease-out);
}

.home-nav-link:hover,
.home-nav-link:focus-visible,
.home-nav-link.is-active {
  color: #f7d579;
  outline: none;
}

.home-nav-link:hover::after,
.home-nav-link:focus-visible::after,
.home-nav-link.is-active::after {
  right: 2px;
  left: 2px;
}

.theme-oracle-stage {
  position: relative;
  width: 100%;
  min-height: calc(100svh - 84px);
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(0, 5, 4, .12), transparent 28%),
    url("../home-stage-clean.jpg") center top / cover no-repeat;
}

.theme-oracle-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0, 5, 4, .24), transparent 17%, transparent 83%, rgba(0, 5, 4, .28)),
    radial-gradient(ellipse at 50% 43%, rgba(242, 200, 108, .06), transparent 43%);
}

.theme-controls {
  position: absolute;
  top: clamp(24px, 3.5vh, 42px);
  left: 50%;
  z-index: 12;
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(0, 430px);
  gap: 50px;
  align-items: center;
  width: min(1040px, calc(100% - 80px));
  transform: translateX(-50%);
}

.theme-control-group {
  display: block;
  min-width: 0;
}

.theme-control-index {
  color: #efc76d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.3rem, 1.8vw, 1.75rem);
  line-height: 1;
  text-align: center;
  text-shadow: 0 0 14px rgba(242, 200, 108, .32);
}

.theme-segmented {
  --segment-gap: 3px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--segment-gap);
  min-height: 50px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid rgba(188, 128, 39, .72);
  border-radius: 7px;
  background: rgba(0, 8, 6, .74);
  box-shadow: inset 0 1px 0 rgba(255, 226, 143, .04), 0 9px 24px rgba(0, 0, 0, .2);
}

.theme-segmented::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 12%, rgba(255, 230, 154, .035) 48%, transparent 74%);
}

.theme-segment-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  z-index: 1;
  width: calc((100% - 12px) / 3);
  border: 1px solid rgba(255, 218, 119, .9);
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(255, 229, 154, .28), rgba(196, 126, 30, .14)),
    rgba(111, 68, 16, .22);
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 198, .42),
    inset 0 -12px 24px rgba(118, 64, 9, .18),
    0 0 18px rgba(242, 186, 70, .22);
  transform: translateX(calc(var(--active-index) * (100% + var(--segment-gap))));
  transition: transform 220ms var(--theme-ease-move);
}

.theme-segmented.is-instant .theme-segment-indicator,
.theme-segmented.is-instant .theme-segment {
  transition-duration: 0ms;
}

.theme-segment {
  position: relative;
  z-index: 2;
  min-width: 0;
  min-height: 44px;
  padding: 0 9px;
  color: rgba(255, 232, 184, .74);
  border: 0;
  border-radius: 4px;
  background: transparent;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: clamp(.9rem, 1.15vw, 1.14rem);
  font-weight: 700;
  letter-spacing: .02em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .65);
  transition: color 150ms ease, transform 140ms var(--theme-ease-out), text-shadow 150ms ease;
}

.theme-segment.is-active {
  color: #ffe5a0;
  text-shadow: 0 0 12px rgba(255, 207, 99, .36);
}

.theme-segment:focus-visible {
  outline: 1px solid #ffe4a0;
  outline-offset: -5px;
}

.theme-segment:active {
  transform: scale(.97);
}

@media (hover: hover) and (pointer: fine) {
  .theme-segment:hover {
    color: #ffe9b1;
    transform: translateY(-1px);
  }
}

/* A · 双层金边玉匣 */
body[data-control-style="a"] .theme-segmented {
  min-height: 54px;
  padding: 5px;
  overflow: hidden;
  border: 1px solid rgba(242, 200, 108, .84);
  border-radius: 0;
  background: rgba(0, 9, 7, .76);
  box-shadow:
    inset 0 0 0 3px rgba(116, 72, 18, .48),
    inset 0 1px 0 rgba(255, 233, 164, .08),
    0 12px 26px rgba(0, 0, 0, .18);
  clip-path: polygon(11px 0, calc(100% - 11px) 0, 100% 11px, 100% calc(100% - 11px), calc(100% - 11px) 100%, 11px 100%, 0 calc(100% - 11px), 0 11px);
}

body[data-control-style="a"] .theme-segmented::before {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: 0;
  pointer-events: none;
  border: 1px solid rgba(242, 200, 108, .28);
  clip-path: inherit;
}

body[data-control-style="a"] .theme-segment-indicator {
  top: 5px;
  bottom: 5px;
  left: 5px;
  width: calc((100% - 16px) / 3);
  border: 1px solid rgba(255, 224, 135, .94);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 230, 153, .28), rgba(166, 101, 26, .32)),
    rgba(91, 54, 13, .54);
  box-shadow:
    inset 0 0 0 3px rgba(255, 224, 135, .12),
    inset 0 1px 0 rgba(255, 248, 218, .42),
    0 0 20px rgba(242, 190, 78, .2);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
}

body[data-control-style="a"] .theme-segment + .theme-segment::before,
body[data-control-style="c"] .theme-segment + .theme-segment::before {
  content: "";
  position: absolute;
  top: 24%;
  bottom: 24%;
  left: calc(var(--segment-gap) * -.5);
  width: 1px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(242, 200, 108, .36), transparent);
}

/* B · 六枚独立金签 */
body[data-control-style="b"] .theme-segmented {
  gap: 8px;
  min-height: 50px;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

body[data-control-style="b"] .theme-segmented::after,
body[data-control-style="b"] .theme-segment-indicator {
  display: none;
}

body[data-control-style="b"] .theme-segment {
  min-height: 50px;
  border: 1px solid rgba(188, 128, 39, .68);
  border-radius: 0;
  background:
    linear-gradient(145deg, rgba(255, 226, 143, .035), transparent 52%),
    rgba(0, 9, 7, .72);
  box-shadow: inset 0 0 0 3px rgba(86, 52, 13, .2), 0 10px 22px rgba(0, 0, 0, .16);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0 calc(100% - 8px), 0 8px);
}

body[data-control-style="b"] .theme-segment.is-active {
  color: #ffedb8;
  border-color: rgba(255, 224, 132, .96);
  background:
    radial-gradient(ellipse at 50% 18%, rgba(255, 241, 194, .28), transparent 52%),
    linear-gradient(180deg, rgba(223, 170, 76, .5), rgba(121, 72, 17, .62));
  box-shadow:
    inset 0 0 0 3px rgba(255, 225, 136, .12),
    inset 0 1px 0 rgba(255, 249, 222, .5),
    0 0 18px rgba(242, 190, 78, .24),
    0 12px 24px rgba(0, 0, 0, .22);
}

/* C · 极简流光滑轨 */
body[data-control-style="c"] .theme-segmented {
  --segment-gap: 0px;
  gap: 0;
  min-height: 48px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(7, 19, 15, .72), rgba(0, 8, 6, .56));
  box-shadow: inset 0 0 0 1px rgba(242, 200, 108, .06), 0 12px 28px rgba(0, 0, 0, .16);
}

body[data-control-style="c"] .theme-segmented::after {
  opacity: .42;
}

body[data-control-style="c"] .theme-segment-indicator {
  top: auto;
  bottom: 2px;
  left: 0;
  width: calc(100% / 3);
  height: 2px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent 12%, #e7b94e 36%, #fff0b1 50%, #e7b94e 64%, transparent 88%);
  box-shadow: 0 -4px 15px rgba(242, 194, 82, .4), 0 0 4px rgba(255, 234, 168, .7);
  transform: translateX(calc(var(--active-index) * 100%));
}

body[data-control-style="c"] .theme-segment {
  min-height: 48px;
  color: rgba(255, 232, 184, .7);
}

body[data-control-style="c"] .theme-segment.is-active {
  color: #ffecb1;
  background: radial-gradient(ellipse at 50% 104%, rgba(242, 192, 73, .12), transparent 58%);
  text-shadow: 0 0 14px rgba(255, 213, 108, .4);
}

.theme-deck-fan {
  position: absolute;
  top: clamp(94px, 12vh, 118px);
  right: 3%;
  left: 3%;
  z-index: 5;
  height: clamp(330px, 42vh, 410px);
}

.theme-deck-card {
  position: absolute;
  top: var(--fan-top);
  left: var(--fan-left);
  width: var(--card-width);
  aspect-ratio: .63;
  padding: 4px;
  border: 1px solid rgba(242, 200, 108, .5);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(255, 230, 145, .16), rgba(0, 8, 6, .74));
  box-shadow: 0 18px 38px rgba(0, 0, 0, .42), inset 0 0 0 1px rgba(255, 232, 154, .07);
  transform: translate(-50%, -50%) rotate(var(--fan-rotate));
  transform-origin: 50% 86%;
  perspective: 900px;
  transition: transform 180ms var(--theme-ease-out), border-color 180ms ease, box-shadow 180ms ease, filter 180ms ease, opacity 180ms ease;
  animation: theme-card-deal 280ms var(--theme-ease-out) both;
  animation-delay: calc(var(--card-index) * 26ms);
}

.theme-deck-fan.is-static .theme-deck-card {
  animation: none;
}

.theme-deck-card::after {
  content: "";
  position: absolute;
  inset: 4px;
  pointer-events: none;
  border: 1px solid rgba(255, 221, 112, .22);
  border-radius: 4px;
  box-shadow: inset 0 0 18px rgba(242, 200, 108, .08);
}

.theme-deck-card-inner {
  position: absolute;
  inset: 4px;
  display: block;
  transform-style: preserve-3d;
  transition: transform 460ms var(--theme-ease-move);
}

.theme-deck-card-back,
.theme-deck-card-face {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  object-fit: cover;
  pointer-events: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.theme-deck-card-face {
  transform: rotateY(180deg);
}

.theme-deck-card:focus-visible {
  outline: 2px solid #ffe29a;
  outline-offset: 5px;
}

.theme-deck-card:active {
  transform: translate(-50%, -50%) rotate(var(--fan-rotate)) scale(.97);
}

.theme-deck-card.is-selected {
  z-index: 40 !important;
  pointer-events: none;
  border-color: rgba(255, 231, 157, .94);
  opacity: 1;
  filter: none;
  box-shadow:
    0 20px 42px rgba(0, 0, 0, .46),
    0 0 24px rgba(242, 200, 108, .24),
    inset 0 0 0 1px rgba(255, 236, 178, .1);
}

.theme-deck-card.is-selected .theme-deck-card-inner {
  transform: rotateY(180deg);
}

.theme-deck-card.is-picked {
  pointer-events: none;
  opacity: .58 !important;
  filter: saturate(.92) brightness(.82) !important;
  border-color: rgba(242, 200, 108, .54);
  box-shadow:
    0 14px 30px rgba(0, 0, 0, .38),
    0 0 18px rgba(242, 200, 108, .14),
    inset 0 0 0 1px rgba(255, 232, 154, .05);
  transform: translate(-50%, -50%) rotate(var(--fan-rotate)) scale(.94);
}

.theme-deck-card.is-picked::after {
  content: "✓";
  inset: 7px 7px auto auto;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  color: #231405;
  border: 1px solid rgba(255, 235, 162, .9);
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe29a, #c98f2d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 226, .7),
    0 0 13px rgba(242, 200, 108, .48),
    0 4px 10px rgba(0, 0, 0, .36);
  font: 900 13px/1 system-ui, sans-serif;
}

.theme-selection-slots {
  --slot-count: 1;
  --slot-width: 86px;
  position: absolute;
  right: 0;
  bottom: clamp(122px, 15vh, 154px);
  left: 0;
  z-index: 11;
  display: flex;
  justify-content: center;
  gap: clamp(16px, 2.3vw, 34px);
  pointer-events: none;
}

.theme-selection-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--slot-width);
  aspect-ratio: .63;
  overflow: hidden;
  color: rgba(255, 224, 139, .58);
  border: 1px solid rgba(242, 200, 108, .62);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 50%, rgba(242, 200, 108, .1), transparent 40%),
    linear-gradient(145deg, rgba(255, 225, 137, .06), rgba(0, 8, 6, .72));
  box-shadow:
    inset 0 0 0 3px rgba(0, 7, 5, .42),
    inset 0 0 22px rgba(242, 200, 108, .07),
    0 0 22px rgba(242, 200, 108, .08);
}

.theme-selection-slot::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(255, 227, 145, .18);
  border-radius: 4px;
}

.theme-selection-slot i {
  font-style: normal;
  font-size: 1.25rem;
  text-shadow: 0 0 14px rgba(255, 216, 112, .42);
}

.theme-selection-slot img {
  position: absolute;
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  border-radius: 4px;
  object-fit: cover;
}

.theme-selection-slot.is-filled {
  border-color: rgba(255, 232, 166, .92);
  box-shadow:
    0 12px 26px rgba(0, 0, 0, .42),
    0 0 24px rgba(242, 200, 108, .24);
  animation: theme-slot-arrive 360ms var(--theme-ease-move) both;
}

@media (hover: hover) and (pointer: fine) {
  .theme-deck-card:not(.is-selected):hover {
    z-index: 30 !important;
    border-color: rgba(255, 231, 160, .94);
    filter: brightness(1.08);
    box-shadow: 0 28px 56px rgba(0, 0, 0, .5), 0 0 28px rgba(242, 200, 108, .26);
    transform: translate(-50%, calc(-50% - 12px)) rotate(var(--fan-rotate)) scale(1.035);
  }
}

.theme-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.theme-guide-button {
  position: absolute;
  bottom: clamp(34px, 5vh, 58px);
  left: 50%;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-width: min(400px, 76vw);
  min-height: 64px;
  padding: 12px 38px;
  color: #2b1907;
  border: 1px solid #f6d87d;
  border-radius: 0;
  background:
    radial-gradient(circle at 5.5% 50%, rgba(255, 230, 139, .72) 0 2px, transparent 3px),
    radial-gradient(circle at 94.5% 50%, rgba(255, 230, 139, .72) 0 2px, transparent 3px),
    linear-gradient(90deg, rgba(92, 51, 7, .24), transparent 15%, transparent 85%, rgba(92, 51, 7, .24)),
    linear-gradient(180deg, #c8922d 0%, #e2b54b 18%, #d19a32 72%, #a76718 100%);
  box-shadow:
    inset 0 0 0 3px #70430f,
    inset 0 0 0 5px rgba(255, 217, 112, .48),
    inset 0 2px 0 rgba(255, 244, 197, .7),
    inset 0 -5px 9px rgba(92, 47, 4, .3),
    0 0 20px rgba(220, 162, 49, .28),
    0 13px 30px rgba(0, 0, 0, .4);
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  font-weight: 700;
  letter-spacing: .05em;
  transform: translateX(-50%);
  clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px), 0 12px);
  transition: transform 140ms var(--theme-ease-out), filter 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
  overflow: hidden;
}

.theme-guide-button::before {
  content: "";
  position: absolute;
  top: -70%;
  bottom: -70%;
  left: -28%;
  width: 22%;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 250, 218, .72), transparent);
  transform: translateX(-160%) rotate(12deg);
}

.theme-guide-button.is-ready::before {
  animation: theme-guide-ready 560ms var(--theme-ease-out) both;
}

.theme-guide-button.is-ready {
  background:
    radial-gradient(circle at 5.5% 50%, #ffe6a1 0 2px, transparent 3px),
    radial-gradient(circle at 94.5% 50%, #ffe6a1 0 2px, transparent 3px),
    linear-gradient(90deg, rgba(91, 47, 5, .26), transparent 14%, transparent 86%, rgba(91, 47, 5, .26)),
    linear-gradient(180deg, #c38a26 0%, #ecc55d 18%, #d9a53a 70%, #a76516 100%);
  box-shadow:
    inset 0 0 0 3px #68400f,
    inset 0 0 0 5px rgba(255, 225, 133, .65),
    inset 0 2px 0 rgba(255, 247, 208, .88),
    inset 0 -6px 10px rgba(91, 45, 3, .34),
    0 0 26px rgba(224, 165, 48, .46),
    0 14px 32px rgba(0, 0, 0, .42);
}

.theme-guide-button > span {
  position: relative;
  z-index: 1;
}

.theme-guide-button span:first-child,
.theme-guide-button span:last-child {
  color: #ffe5a0;
  font-size: .88em;
  text-shadow: 0 0 10px rgba(255, 246, 208, .72);
}

.theme-guide-button:disabled {
  cursor: default;
  opacity: .84;
  filter: saturate(.76) brightness(.76);
}

.theme-guide-button:not(:disabled):active {
  transform: translateX(-50%) scale(.97);
}

.theme-guide-button:focus-visible {
  outline: 2px solid #fff0bd;
  outline-offset: 5px;
}

@media (hover: hover) and (pointer: fine) {
  .theme-guide-button:not(:disabled):hover {
    filter: brightness(1.08);
    box-shadow:
      inset 0 0 0 4px rgba(111, 62, 11, .16),
      inset 0 1px 0 rgba(255, 250, 222, .82),
      0 0 34px rgba(242, 200, 108, .34),
      0 18px 40px rgba(0, 0, 0, .38);
    transform: translateX(-50%) translateY(-2px);
  }
}

.theme-result {
  width: min(1180px, calc(100% - 36px));
  margin: 38px auto 70px;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid rgba(242, 200, 108, .28);
  border-radius: 12px;
  background:
    radial-gradient(ellipse at 50% 0, rgba(242, 200, 108, .13), transparent 42%),
    rgba(4, 13, 10, .94);
  box-shadow: 0 28px 76px rgba(0, 0, 0, .4);
}

.theme-result[hidden] {
  display: none;
}

.theme-result-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.theme-result-heading h1 {
  margin: 0;
  color: #ffe2a0;
  font-size: clamp(2.1rem, 4vw, 3.7rem);
  font-weight: 500;
  line-height: 1.1;
}

.theme-redraw-button {
  min-height: 44px;
  padding: 0 20px;
  color: #f5d684;
  border: 1px solid rgba(242, 200, 108, .44);
  border-radius: 7px;
  background: rgba(242, 200, 108, .06);
  transition: color 150ms ease, background 150ms ease, transform 140ms var(--theme-ease-out);
}

.theme-redraw-button:active {
  transform: scale(.97);
}

.theme-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.theme-result-card {
  display: grid;
  grid-template-columns: minmax(105px, .42fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 14px;
  color: inherit;
  border: 1px solid rgba(242, 200, 108, .22);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(242, 200, 108, .075), transparent 48%), rgba(1, 8, 6, .76);
  cursor: pointer;
  transition: transform 180ms var(--theme-ease-out), border-color 180ms ease, box-shadow 180ms ease;
  animation: theme-result-in 320ms var(--theme-ease-out) both;
  animation-delay: calc(var(--card-index) * 55ms);
}

.theme-result-card:focus-visible {
  outline: 2px solid #ffe29a;
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .theme-result-card:hover {
    border-color: rgba(242, 200, 108, .55);
    box-shadow: 0 18px 38px rgba(0, 0, 0, .28);
    transform: translateY(-3px);
  }
}

.theme-result-art img {
  display: block;
  width: 100%;
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .4);
}

.theme-result-copy > span {
  color: #72b9a8;
  font-size: .74rem;
  letter-spacing: .08em;
}

.theme-result-copy h2 {
  margin: 5px 0 9px;
  color: #ffe4a2;
  font-size: clamp(1.45rem, 2vw, 1.9rem);
  font-weight: 500;
}

.theme-result-copy p {
  margin: 0;
  color: rgba(255, 239, 207, .7);
  font-size: .86rem;
  line-height: 1.72;
}

.theme-result-meta {
  margin-bottom: 9px !important;
  color: #e6bd68 !important;
  font-size: .76rem !important;
}

.theme-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.theme-keywords i {
  padding: 3px 8px;
  color: #e4bf71;
  border: 1px solid rgba(242, 200, 108, .24);
  border-radius: 999px;
  font-size: .7rem;
  font-style: normal;
}

.dialog-body .dialog-art {
  border-radius: 8px;
}

@keyframes theme-card-deal {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 18px)) rotate(var(--fan-rotate)) scale(.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(var(--fan-rotate)) scale(1);
  }
}

@keyframes theme-guide-ready {
  0% { opacity: 0; transform: translateX(-160%) rotate(12deg); }
  22% { opacity: .82; }
  100% { opacity: 0; transform: translateX(760%) rotate(12deg); }
}

@keyframes theme-slot-arrive {
  from { opacity: 0; transform: translateY(-18px) scale(.92) rotateY(16deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotateY(0); }
}

@keyframes theme-result-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .theme-controls {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    width: min(860px, calc(100% - 44px));
  }

  .theme-control-group {
    min-width: 0;
  }

  .theme-segmented {
    min-height: 52px;
  }

  .theme-segment {
    min-height: 44px;
    padding: 0 7px;
  }

  .theme-deck-fan {
    right: 0;
    left: 0;
  }
}

@media (min-width: 1600px) {
  .home-topbar {
    min-height: 78px;
    padding-inline: clamp(42px, 3.2vw, 68px);
  }

  .home-brand {
    min-width: clamp(280px, 19vw, 380px);
    min-height: 54px;
    font-size: clamp(2rem, 2.05vw, 2.55rem);
  }

  .home-nav {
    gap: clamp(34px, 3.2vw, 64px);
  }

  .home-nav-link {
    font-size: clamp(1rem, 1.08vw, 1.28rem);
  }

  .theme-oracle-stage {
    min-height: calc(100svh - 88px);
  }

  .theme-controls {
    top: clamp(30px, 3.8vh, 48px);
    grid-template-columns: minmax(0, 680px) minmax(0, 500px);
    gap: clamp(60px, 4vw, 82px);
    width: min(1260px, calc(100% - 160px));
  }

  body[data-control-style="c"] .theme-segmented,
  body[data-control-style="c"] .theme-segment {
    min-height: 54px;
  }

  .theme-segment {
    font-size: 1.16rem;
  }

  .theme-deck-fan {
    top: clamp(112px, 12.5vh, 148px);
    height: clamp(390px, 44vh, 500px);
  }

  .theme-selection-slots {
    bottom: clamp(138px, 15vh, 174px);
  }

  .theme-guide-button {
    bottom: clamp(38px, 5vh, 64px);
    min-width: min(440px, 76vw);
    min-height: 68px;
  }
}

@media (max-width: 680px) {
  .theme-page-shell {
    padding-top: 0;
  }

  .home-topbar {
    flex-direction: column;
    gap: 6px;
    width: 100%;
    min-height: 82px;
    padding: 6px 8px;
    border-width: 0 0 1px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .32);
  }

  .home-topbar::after {
    display: none;
  }

  .home-brand {
    justify-content: center;
    min-width: 0;
    min-height: 30px;
    padding: 0 18px;
    border: 0;
    font-size: clamp(1.36rem, 6.3vw, 1.72rem);
  }

  .home-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    gap: 0;
    border-top: 1px solid rgba(242, 200, 108, .2);
  }

  .home-nav-link {
    justify-content: center;
    min-width: 0;
    min-height: 30px;
    padding: 0 2px;
    font-size: clamp(.68rem, 3vw, .82rem);
  }

  .home-nav-link + .home-nav-link {
    box-shadow: -1px 0 0 rgba(242, 200, 108, .18);
  }

  .theme-oracle-stage {
    min-height: max(720px, calc(100svh - 82px));
    background:
      linear-gradient(180deg, rgba(0, 8, 6, .44) 0%, rgba(0, 7, 5, .08) 38%, rgba(0, 5, 4, .26) 100%),
      url("../theme-mobile-table-velvet-v4.jpg") center 50% / cover no-repeat;
    transition: background-image 220ms ease;
  }

  body[data-table-skin="a"] .theme-oracle-stage {
    background-image:
      linear-gradient(180deg, rgba(0, 7, 5, .42) 0%, rgba(0, 5, 4, .06) 42%, rgba(0, 4, 3, .24) 100%),
      url("../theme-mobile-table-walnut-v3.jpg");
  }

  body[data-table-skin="b"] .theme-oracle-stage {
    background-image:
      linear-gradient(180deg, rgba(0, 8, 6, .44) 0%, rgba(0, 7, 5, .08) 38%, rgba(0, 5, 4, .26) 100%),
      url("../theme-mobile-table-velvet-v4.jpg");
  }

  body[data-table-skin="c"] .theme-oracle-stage {
    background-image:
      linear-gradient(180deg, rgba(0, 7, 5, .4) 0%, rgba(0, 6, 4, .04) 40%, rgba(0, 4, 3, .22) 100%),
      url("../theme-mobile-table-lacquer-v3.jpg");
  }

  .theme-oracle-stage[data-theme="energy"],
  .theme-oracle-stage[data-theme="chakra"] {
    min-height: max(720px, calc(100svh - 82px));
  }

  .theme-controls {
    top: 12px;
    grid-template-columns: minmax(0, 1.45fr) minmax(0, .95fr);
    gap: 6px;
    width: calc(100% - 16px);
  }

  .theme-control-group {
    min-width: 0;
  }

  .theme-control-index {
    font-size: 1rem;
  }

  .theme-segmented {
    min-height: 38px;
    border-radius: 5px;
  }

  .theme-segment-indicator {
    border-radius: 3px;
  }

  .theme-segment {
    min-height: 32px;
    padding: 0 2px;
    font-size: clamp(.68rem, 3vw, .82rem);
  }

  body[data-control-style="a"] .theme-segmented {
    min-height: 40px;
    padding: 3px;
    clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px), calc(100% - 7px) 100%, 7px 100%, 0 calc(100% - 7px), 0 7px);
  }

  body[data-control-style="a"] .theme-segment-indicator {
    top: 3px;
    bottom: 3px;
    left: 3px;
    width: calc((100% - 12px) / 3);
  }

  body[data-control-style="b"] .theme-segmented {
    gap: 3px;
    min-height: 38px;
  }

  body[data-control-style="b"] .theme-segment {
    min-height: 38px;
    clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  }

  body[data-control-style="c"] .theme-segmented,
  body[data-control-style="c"] .theme-segment {
    min-height: 38px;
  }

  .theme-deck-fan {
    top: 84px;
    height: 486px;
  }

  .theme-deck-fan[data-theme="energy"] {
    height: 650px;
  }

  .theme-deck-fan[data-theme="chakra"] {
    height: 490px;
  }

  .theme-deck-fan::before {
    content: "";
    position: absolute;
    inset: 4% 8%;
    z-index: -1;
    pointer-events: none;
    opacity: .42;
  }

  .theme-deck-fan[data-theme="chakra"]::before {
    opacity: 0;
    background:
      radial-gradient(circle at 50% 50%, transparent 0 22%, rgba(242, 200, 108, .12) 22.4% 22.8%, transparent 23.2% 41%, rgba(242, 200, 108, .08) 41.4% 41.8%, transparent 42.2%),
      conic-gradient(from 0deg at 50% 50%, transparent 0 10%, rgba(242, 200, 108, .09) 10.3% 10.7%, transparent 11% 24%, rgba(242, 200, 108, .08) 24.3% 24.7%, transparent 25% 100%);
  }

  .theme-deck-fan[data-theme="energy"]::before {
    left: 30%;
    right: 30%;
    background:
      radial-gradient(circle at 50% 8%, rgba(255, 218, 112, .7) 0 2px, transparent 3px),
      radial-gradient(circle at 50% 39%, rgba(255, 218, 112, .56) 0 2px, transparent 3px),
      radial-gradient(circle at 50% 62%, rgba(255, 218, 112, .56) 0 2px, transparent 3px),
      radial-gradient(circle at 50% 92%, rgba(255, 218, 112, .7) 0 2px, transparent 3px),
      linear-gradient(90deg, transparent 49.6%, rgba(242, 200, 108, .18) 49.8% 50.2%, transparent 50.4%);
  }

  .theme-deck-fan[data-theme="energy"][data-energy-layout="a"]::before {
    opacity: 0;
    border: 0;
    background: none;
  }

  .theme-deck-fan[data-theme="energy"][data-energy-layout="b"]::before {
    inset: 8% 24%;
    opacity: .3;
    background:
      radial-gradient(circle at 25% 17%, rgba(255, 218, 112, .6) 0 2px, transparent 3px),
      radial-gradient(circle at 75% 17%, rgba(255, 218, 112, .6) 0 2px, transparent 3px),
      radial-gradient(circle at 25% 50%, rgba(255, 218, 112, .46) 0 2px, transparent 3px),
      radial-gradient(circle at 75% 50%, rgba(255, 218, 112, .46) 0 2px, transparent 3px),
      radial-gradient(circle at 25% 83%, rgba(255, 218, 112, .6) 0 2px, transparent 3px),
      radial-gradient(circle at 75% 83%, rgba(255, 218, 112, .6) 0 2px, transparent 3px),
      linear-gradient(90deg, transparent 24.7%, rgba(242, 200, 108, .15) 25%, transparent 25.3% 74.7%, rgba(242, 200, 108, .15) 75%, transparent 75.3%);
  }

  .theme-deck-fan[data-theme="energy"][data-energy-layout="c"]::before {
    opacity: 0;
    background: none;
  }

  .theme-deck-card {
    padding: 2px;
    border-radius: 5px;
  }

  .theme-deck-card-inner {
    inset: 2px;
  }

  .theme-deck-card::after {
    inset: 2px;
  }

  .theme-guide-button {
    bottom: 80px;
    z-index: 50;
    gap: 10px;
    min-width: min(330px, calc(100% - 34px));
    min-height: 56px;
    padding: 10px 20px;
    border-radius: 9px;
    font-size: clamp(1.1rem, 5.5vw, 1.42rem);
  }

  .theme-guide-button > span:nth-child(2) {
    transform: translateY(-2px);
  }

  .theme-selection-slots {
    display: none;
  }

  .theme-result {
    width: calc(100% - 18px);
    margin-top: 22px;
    padding: 18px;
  }

  .theme-result-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .theme-redraw-button {
    width: 100%;
  }

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

  .theme-result-card {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 12px;
    padding: 11px;
  }
}

/* Mobile portrait composition: keep the full draw table inside the live viewport.
   Desktop rules are intentionally untouched. */
@media (max-width: 680px) {
  html,
  body[data-page="theme-draw"] {
    height: 100%;
    overscroll-behavior: none;
  }

  body[data-page="theme-draw"] {
    min-height: 100svh;
    height: 100svh;
    overflow: hidden;
  }

  body[data-page="theme-draw"] .theme-page-shell {
    min-height: 100svh;
    height: 100svh;
    overflow: hidden;
  }

  body[data-page="theme-draw"] .theme-oracle-stage,
  body[data-page="theme-draw"] .theme-oracle-stage[data-theme="energy"],
  body[data-page="theme-draw"] .theme-oracle-stage[data-theme="chakra"] {
    box-sizing: border-box;
    min-height: 0;
    height: calc(100vh - 126px);
    height: calc(100svh - 126px);
    overflow: hidden;
    background-position: center 48%;
  }

  body[data-page="theme-draw"] .theme-controls {
    top: 8px;
  }

  body[data-page="theme-draw"] .theme-deck-fan,
  body[data-page="theme-draw"] .theme-deck-fan[data-theme="energy"],
  body[data-page="theme-draw"] .theme-deck-fan[data-theme="chakra"] {
    top: 58px;
    right: 2%;
    left: 2%;
    height: calc(100% - 128px);
  }

  body[data-page="theme-draw"] .theme-guide-button {
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 10px));
    min-height: 52px;
    padding-block: 8px;
  }
}

@media (max-width: 680px) and (max-height: 760px) {
  body[data-page="theme-draw"] .theme-deck-fan,
  body[data-page="theme-draw"] .theme-deck-fan[data-theme="energy"],
  body[data-page="theme-draw"] .theme-deck-fan[data-theme="chakra"] {
    top: 54px;
    height: calc(100% - 118px);
  }

  body[data-page="theme-draw"] .theme-deck-card {
    width: min(var(--card-width), 18.2vw);
  }

  body[data-page="theme-draw"] .theme-guide-button {
    min-height: 48px;
    font-size: clamp(1.04rem, 5vw, 1.28rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .theme-segment-indicator,
  .theme-segment,
  .theme-deck-card,
  .theme-deck-card-inner,
  .theme-guide-button,
  .theme-result-card {
    animation: none !important;
    transition-duration: .01ms !important;
  }

  .theme-guide-button::before {
    display: none;
  }
}
