:root {
  --ink: #f7e9e8;
  --mute: #d6c0dc;
  --gold: #dfb879;
  --gold2: #ffe4b2;
  --line: #dfb87940;
}
body {
  background: #100a20;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(0deg, #0d0719 3%, #140a2370 45%, #140a2355 100%),
    radial-gradient(ellipse at 67% 31%, #7e4ab367, transparent 48%),
    radial-gradient(ellipse at 23% 8%, #3d235c9e, transparent 53%);
}
main { max-width: none; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 71px;
  padding: 0 clamp(20px, 5.3vw, 88px);
  border-bottom: 1px solid #d5ac801f;
  background: #120b21df;
}
.brand, .book-tool, .sound-tool {
  display: flex;
  align-items: center;
  gap: 11px;
  border: none;
  background: transparent;
  color: var(--gold2);
  min-height: 44px;
  cursor: pointer;
}
.brand { padding: 0; font: 700 15px Cinzel, Georgia, serif; letter-spacing: .17em; }
.brand svg { width: 36px; height: 36px; filter: drop-shadow(0 0 9px #ebb36e80); }
.nav-tools { display: flex; align-items: center; gap: 16px; }
.nav-tools svg { width: 19px; height: 19px; flex: none; }
.nav-tools i { height: 23px; width: 1px; background: var(--line); }
.book-tool { font: 600 14px "Noto Serif Thai", serif; padding: 0 5px; }
.book-tool small { color: #d7ba9a; font: 13px Cinzel, Georgia, serif; }
.sound-tool { width: 44px; justify-content: center; }
.sound-tool .on-mark, .sound-tool[data-on="true"] .off-mark { display: none; }
.sound-tool[data-on="true"] .on-mark { display: block; }
.nav-tools button:hover { color: white; }
.lobby {
  width: min(1240px, 100% - 104px);
  margin: auto;
  padding-bottom: 36px;
}
.hero {
  display: grid;
  grid-template-columns: .83fr 1.17fr;
  align-items: center;
  min-height: 482px;
  text-align: left;
  padding: 0;
}
.hero-copy { z-index: 2; padding-left: 24px; }
.overline {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 0 0 16px;
  color: #f3ce95;
  font: 700 12px Cinzel, Georgia, serif;
  letter-spacing: .26em;
}
.overline i { width: 40px; height: 1px; background: linear-gradient(90deg, #dfb87955, #dfb879); }
.hero h1 {
  position: relative;
  width: max-content;
  font: 700 clamp(74px, 8vw, 124px)/.78 "Cormorant Garamond", Georgia, serif;
  letter-spacing: -.065em;
  margin: 0;
  padding: 0 30px 15px 0;
  background-image: linear-gradient(#fff4d9 6%, #fee1ab 52%, #d69e69 97%);
  filter: drop-shadow(0 8px 24px #13091f);
}
.hero h1 em { font-weight: 600; }
.hero h1 sup {
  font: 25px/1 Georgia, serif;
  position: absolute;
  right: 4px;
  top: 13%;
  color: #ffe4af;
  filter: drop-shadow(0 0 15px #f5a8df);
}
.tagline {
  font-size: clamp(20px, 2.5vw, 29px);
  color: #f5d8ec;
  margin: 21px 0 6px;
}
.hero-meta { color: var(--mute); font-size: 14px; }
.hero-meta span, .hero-meta b { color: var(--gold2); margin-right: 6px; }
.hero-meta b { margin-left: 5px; }
.artstage { position: relative; isolation: isolate; height: 463px; }
.artstage::before {
  content: "";
  position: absolute;
  inset: 3% -9%;
  z-index: -1;
  background: radial-gradient(ellipse at 53% 53%, #c382da5e, #7c48aa40 34%, transparent 66%);
}
.astrolabe {
  position: absolute;
  top: 48%;
  left: 51%;
  width: min(99%, 464px);
  aspect-ratio: 1;
  color: #e1b7839b;
  translate: -50% -50%;
  filter: drop-shadow(0 0 10px #f0b5aa80);
}
.astrolabe svg { animation: astrolabe 115s infinite linear; }
@keyframes astrolabe { to { rotate: 1turn; } }
.showcard {
  --angle: 0deg;
  position: absolute;
  top: 47%;
  left: 50%;
  width: clamp(135px, 16.8vw, 229px);
  aspect-ratio: 200 / 340;
  padding: 0;
  border: none;
  border-radius: 6% / 4%;
  background: #352047;
  cursor: pointer;
  transform: translate(-50%, -50%) rotate(var(--angle));
  box-shadow: 0 16px 40px #090411c2, 0 0 28px #ffd1a535;
  transition: transform .4s ease, filter .4s ease;
}
.showcard svg { border-radius: inherit; }
.showcard::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(123deg, transparent 33%, #ffdf9e24 43%, transparent 56%);
  mix-blend-mode: screen;
}
.showcard.card0 { --angle: -16deg; left: 28%; top: 52%; scale: .9; z-index: 0; }
.showcard.card1 { z-index: 2; --angle: -2deg; box-shadow: 0 13px 45px #090411bd, 0 0 32px #fcbbe75c; }
.showcard.card2 { --angle: 15deg; left: 72%; top: 51%; scale: .9; z-index: 1; }
.showcard:hover, .showcard:focus-visible {
  transform: translate(-50%, -54%) rotate(calc(var(--angle) * .4));
  filter: brightness(1.13);
  z-index: 3;
}
.glint { position: absolute; color: #ffeab7; text-shadow: 0 0 16px #f0a5f2; pointer-events: none; }
.g1 { top: 11%; left: 21%; font-size: 27px; }.g2 { top: 10%; right: 17%; font-size: 34px; }.g3 { bottom: 14%; right: 4%; font-size: 20px; }
.spread { text-align: center; }
.section-heading { display: flex; align-items: center; justify-content: center; gap: 14px; color: #ecc894; margin: 0 auto 19px; }
.section-heading h2 { font-size: 19px; font-weight: 600; color: #f7dfc5; margin: 0; }
.rule { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #dfb87980); }
.rule:last-child { transform: rotate(180deg); }
.modes { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.mode-card.tab {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 107px;
  gap: 15px;
  text-align: left;
  padding: 14px clamp(10px,1.5vw,22px);
  border: 1px solid #c49ab548;
  border-radius: 8px;
  color: #f9e8f6;
  background: linear-gradient(125deg,#251732ef,#21112af2);
  transition: border-color .25s, background .25s, box-shadow .25s;
}
.mode-card.tab:hover, .mode-card.tab.on {
  border-color: #e1b67e;
  background: radial-gradient(ellipse at 4% 20%, #72428983, transparent 78%), #2c1a35;
  box-shadow: inset 0 0 0 3px #181020, inset 0 0 0 4px #e4bf7b45, 0 0 24px #9255a52b;
}
.mode-icon {
  display: grid;
  place-items: center;
  width: 46px;
  aspect-ratio: 1;
  flex-shrink: 0;
  color: #f1ce95;
  filter: drop-shadow(0 0 7px #e7bc8960);
}
.mode-copy { display: grid; gap: 2px; }
.mode-copy small { color: #f0c693; font: 700 10px Cinzel, Georgia, serif; letter-spacing: .17em; }
.mode-copy strong { font-size: 20px; line-height: 1.25; }
.mode-copy > span { font-size: 13px; color: #e0cae3; font-weight: 400; line-height: 1.3; }
.qty { align-self: start; margin-left: auto; color: #f2d499; background: #f4c98212; padding: 3px 7px; border: 1px solid #f4c98226; border-radius: 3px; white-space: nowrap; font-size: 12px; }
.selected-star { display: none; position: absolute; right: 9px; bottom: 1px; color: var(--gold2); }
.on .selected-star { display: block; }
.chips:empty { display: none; }
.launch {
  min-width: min(100%, 270px);
  min-height: 61px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 24px 0 0;
  padding: 7px 34px;
  border: 1px solid #ffe2a0;
  border-radius: 5px;
  outline-offset: 4px;
  background: linear-gradient(125deg,#ffe6ad 2%,#d5a365 53%,#fcdca1 100%);
  box-shadow: inset 0 0 0 3px #c59056, inset 0 0 0 4px #f8dcaa80, 0 0 28px #ecb36945;
  color: #312037;
  font: 700 19px "Noto Serif Thai",serif;
  cursor: pointer;
  transition: box-shadow .24s, filter .24s;
}
.launch:hover { box-shadow: inset 0 0 0 3px #c59056, inset 0 0 0 4px #f8dcaa80, 0 0 36px #ecb36980; filter: brightness(1.07); }
.launch svg { width: 24px; height: 24px; }
.button-star { color: #4f2f52; font-size: 21px; }
.stage { margin: auto; max-width: 1070px; padding-top: 24px; }
.game-head { position: relative; }
.game-head h2 { margin: 0 0 4px; color: var(--gold2); font-size: clamp(29px,4vw,44px); font-weight: 600; }
.game-kicker { margin: 0; font: 12px/1.6 Cinzel, Georgia, serif; color: #e9b988; letter-spacing: .2em; }
.backhome { position: absolute; left: 0; top: 3px; border: 1px solid var(--line); border-radius: 5px; padding: 8px 13px; color: #f6d4a7; background: #21122de6; font: inherit; cursor: pointer; }
.backhome:disabled { opacity: .45; cursor: default; }
.stage .period { color: var(--mute); font-size: 15px; }
.stage .table {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: radial-gradient(ellipse at 50% 44%, #5e347079, #1c0f2de3 70%);
  box-shadow: inset 0 0 0 5px #21112c, inset 0 0 0 6px #e8bd782a, 0 20px 75px #0c071995;
  min-height: 180px;
  padding: 25px 15px;
}
.stage[data-view="ritual"] .slots { display: none; }
.stage[data-view="ritual"] .table { min-height: 450px; }
.stage[data-view="ritual"] .holdbox {
  width: min(67vw,315px);
  background: radial-gradient(circle, #ca6cf42b, transparent 67%);
}
.stage[data-view="ritual"] .holdbox::before {
  content: "";
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  border: 1px solid #e3b77580;
  box-shadow: 0 0 18px #c789fd47, inset 0 0 23px #c789fd47;
}
.stage[data-view="ritual"] .incant { min-height: 86px; }
.stage[data-view="skipWrap"] .table { min-height: 94px; padding: 14px; }
.stage[data-complete="true"] .table { display: none; }
.stage[data-view="pickWrap"] .slots { max-height: 28vh; overflow-y: auto; padding: 9px; }
.stage[data-m="year"] .mg { max-width: 620px; }
.strip { padding-bottom: 24px; }
.sc { width: 88px; margin-left: -54px; }
.sc.gone { visibility: hidden; }
.mbox, .sum { background: #20122df5; }
.reading { padding-top: 20px; }
.reading .it { border-color: #dcb87c50; }
@media (max-width: 950px) {
  .lobby { width: calc(100% - 56px); }
  .hero-copy { padding-left: 4px; }
  .hero { min-height: 410px; }
  .artstage { height: 395px; }
  .modes { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .mode-card.tab { gap: 9px; }
  .mode-icon { width: 34px; }
}
@media (max-width: 680px) {
  .topbar { height: 59px; padding-inline: 13px; }
  .brand { font-size: 11px; gap: 6px; letter-spacing: .09em; white-space: nowrap; }
  .brand svg { width: 26px; height: 26px; }
  .book-tool { font-size: 12px; gap: 5px; white-space: nowrap; }
  .book-tool small { font-size: 10px; }
  .nav-tools { gap: 3px; }.nav-tools i { display: none; }
  .nav-tools svg { width: 16px; height: 16px; }
  .lobby { width: calc(100% - 28px); }
  .hero { display: block; text-align: center; min-height: 0; padding-top: 27px; }
  .hero-copy { padding: 0; }
  .hero h1 { margin: 0 auto; display: inline-block; font-size: clamp(53px, 12vw, 70px); padding: 0 13px 6px 0; line-height: .9; }
  .hero h1 br { display: none; }
  .hero h1 em { margin-left: .12em; }
  .hero h1 sup { font-size: 16px; right: -5px; }
  .overline { justify-content: center; font-size: 10px; margin-bottom: 10px; }
  .overline i { width: 23px; }
  .tagline { font-size: 19px; margin: 3px 0 2px; }
  .hero-meta { font-size: 12px; }
  .artstage { width: min(100%,440px); height: clamp(250px,67vw,340px); margin: 5px auto 0; }
  .artstage::before { inset: 3% 0; }
  .astrolabe { width: 82%; }
  .showcard { width: clamp(100px,30vw,147px); }
  .glint { font-size: 18px; }
  .modes { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
  .mode-card.tab { min-height: 120px; padding: 9px 4px 10px; flex-direction: column; justify-content: start; gap: 3px; text-align: center; }
  .mode-icon { width: 25px; }
  .mode-copy { gap: 1px; }
  .mode-copy small { font-size: 9px; letter-spacing: .09em; }
  .mode-copy strong { font-size: 16px; }
  .mode-copy > span { display: none; }
  .qty { align-self: center; margin-left: 0; padding: 0 5px; font-size: 11px; }
  .selected-star { right: 4px; top: 1px; bottom: auto; font-size: 10px; }
  .section-heading { gap: 7px; margin-bottom: 12px; }
  .section-heading h2 { font-size: 16px; }
  .launch { margin-top: 16px; min-height: 53px; }
  .backhome { position: static; display: block; width: max-content; font-size: 13px; margin-bottom: 14px; }
  .stage .table { padding-inline: 8px; }
  .stage[data-view="ritual"] .table { min-height: 407px; }
  .sc { width: 67px; margin-left: -42px; }
}
@media (max-width: 360px) {
  .hero h1 { font-size: 47px; }
  .book-tool small { display: none; }
}

.showcard {
  transform: perspective(850px) translate(-50%, -50%) rotate(var(--angle))
    rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
}
.showcard:hover, .showcard:focus-visible {
  transform: perspective(850px) translate(-50%, -54%) rotate(calc(var(--angle) * .58))
    rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
}
.showcard::after {
  background: linear-gradient(117deg, transparent, #ffedb832 48%, #e4b5f420 53%, transparent 65%);
  background-size: 215% 100%;
  background-position: var(--shine, 50%) 0;
  transition: background-position .22s ease-out;
}
.portrait-art { filter: saturate(1.06) contrast(1.08); }
.raised-symbol {
  filter: drop-shadow(0 -.65px .35px #fff9db) drop-shadow(0 2.15px 1.2px #26132a);
}
.c3 .in { transition: transform .69s cubic-bezier(.17,.71,.21,1.05); }
.c3.on .fr {
  box-shadow: 0 0 0 1px var(--tc), 0 0 21px var(--tc), 0 10px 29px #000a;
}
.c3.t4.on .fr { animation: prism 3s ease-out 1; }
.c3.tell .f.b { animation: tell .75s ease-in-out infinite alternate; }
.c3.land { animation: land .28s cubic-bezier(.22,.75,.33,1); }
.deck .holo { animation-duration: 8s; }
.holdbox:active .deck {
  filter: drop-shadow(0 0 calc(8px + var(--p, 0)*23px) #f2acf487);
}
.sc:disabled, .backhome:disabled { cursor: default; }
.strip { scroll-behavior: auto; }
.stage[data-view="sealWrap"] .slots .c3 { filter: drop-shadow(0 0 8px #ffd5a732); }
.seal .slit { box-shadow: 0 0 14px 3px var(--tc); }
.stage[data-view="skipWrap"] .table { margin-top: 12px; }
.stage[data-view="skipWrap"][data-complete="false"] #skipWrap {
  position: fixed;
  z-index: 5;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
}
#skip { color: #fce0b7; background: #24132df2; white-space: nowrap; }
.bond-badge { display: block; margin: 4px 0; color: var(--gold2); font-size: 13px; }
.form-picker { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }
.form-picker .chip:disabled { opacity: .46; cursor: default; }
.form-picker .chip { font-size: 13px; min-height: 34px; padding-inline: 11px; }
.unlock-box {
  text-align: center;
  max-width: 490px;
  background: radial-gradient(ellipse at 50% 48%, #5d3374, #231231 65%, #180d27);
}
.unlock-box h3 { margin-bottom: 11px; }
.unlock-card {
  width: min(52vw, 196px, 26vh);
  margin: 0 auto;
  position: relative;
  aspect-ratio: 200 / 340;
  border-radius: 6% / 4%;
  transform: perspective(720px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  box-shadow: 0 0 0 1px #e8c0ff, 0 0 34px #e1abf580, 0 18px 40px #11091a9c;
  transition: transform .2s ease-out;
}
.unlock-card .holo { animation-iteration-count: 2; animation-duration: 2.6s; }
#unlock[data-rank="3"] .unlock-box { background: radial-gradient(ellipse at 50% 48%, #6a3e75, #36203f 55%, #1e1131); border-color: #ffdb9b; }
#unlock[data-rank="3"] .unlock-card { box-shadow: 0 0 0 1px #ffdf9b, 0 0 51px 9px #eeb37989, 0 18px 40px #11091a9c; }
#unlockName { margin: 12px 0; }
.iinfo { padding: 0 12px; }
.stage:focus-within { outline: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .showcard:hover, .showcard:focus-visible { transform: translate(-50%, -50%) rotate(var(--angle)); }
}

/* ทำบุญ button: icon only on phones so the top bar keeps its room */
@media (max-width: 480px) {
  #meritBtn span { display: none; }
  .nav-tools { gap: 8px; }
}
