/* Fortune festival overlay — Thai Kawaii Festival, reusing the site palette */
body.fest-open { overflow: hidden; }
.fest { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; padding: 14px;
  background: radial-gradient(circle at 50% 0, rgba(201, 162, 255, .55), rgba(33, 27, 83, .88) 60%); backdrop-filter: blur(6px); animation: fadeIn .3s; }
.fest-shell { position: relative; width: 100%; max-width: 980px; background: linear-gradient(180deg, #fff8f0, #fff2f7); color: var(--ink); border-radius: 32px;
  padding: 18px 20px 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .4); animation: popin .4s cubic-bezier(.3, 1.4, .5, 1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fest-shell { background: linear-gradient(180deg, #221b4a, #2a2159); } }
.fest-top { display: flex; gap: 12px; align-items: flex-start; }
.fest-head { flex: 1; min-width: 0; }
.fest-head h2 { margin: 0; font: 700 1.4rem "Mali", sans-serif; color: #51417e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fest-head h2 { color: var(--ink); } }
.fest-head p { margin: 2px 0 0; font-size: .86rem; color: var(--muted); }
.fest-back, .fest-close { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--chip); color: var(--ink); font-size: 1.2rem; cursor: pointer; }
.fest-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 10px; }
.fest-tabs { display: flex; gap: 4px; background: var(--chip); padding: 4px; border-radius: 16px; }
.fest-tabs button { border: 0; background: transparent; border-radius: 12px; padding: 7px 14px; font: 700 .86rem "Mali", sans-serif; color: var(--muted); cursor: pointer; }
.fest-tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px rgba(61, 43, 79, .12); }
.fest-tabs b { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #ff83a9; color: #fff; font-size: .7rem; line-height: 18px; text-align: center; }
.fest-name { display: flex; align-items: center; gap: 8px; font: 600 .8rem "Mali", sans-serif; color: var(--muted); }
.fest-name input { width: 150px; padding: 6px 12px; border-radius: 999px; }
.fest-note { margin: 10px 0 0; text-align: center; font-size: .7rem; color: var(--muted); }

/* menu grid */
.fest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.fest-card { position: relative; overflow: hidden; border: 0; border-radius: 26px; padding: 14px 16px 16px; text-align: left; cursor: pointer; color: #3d2b4f;
  display: grid; grid-template-columns: 96px 1fr; grid-template-rows: auto auto 1fr; column-gap: 12px; min-height: 140px;
  box-shadow: 0 10px 24px rgba(81, 65, 126, .14); transition: transform .2s, box-shadow .2s; animation: cardIn .45s both; animation-delay: calc(var(--i) * 60ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.fest-card:hover { transform: translateY(-4px); box-shadow: 0 16px 30px rgba(81, 65, 126, .2); }
.fest-card .fc-art { grid-row: 1 / 4; display: grid; place-items: center; }
.fest-card .fc-art svg { width: 92px; height: 100px; }
.fest-card b { font: 700 1.05rem "Mali", sans-serif; align-self: end; }
.fest-card small { font-size: .78rem; color: #6b5a7a; }
.fest-card .fc-go { align-self: end; justify-self: start; font: 700 .76rem "Mali", sans-serif; color: #fff; background: rgba(61, 43, 79, .55); padding: 3px 10px; border-radius: 999px; margin-top: 6px; }
.t-gold { background: linear-gradient(135deg, #fff1c9, #ffd9a0); }
.t-peach { background: linear-gradient(135deg, #ffe6cf, #ffc9a8); }
.t-lavender { background: linear-gradient(135deg, #efe7ff, #d9c7ff); }
.t-night { background: linear-gradient(135deg, #4a3c8f, #211b53); color: #fff; }
.t-night small { color: #d9ccff; }
.t-river { background: linear-gradient(135deg, #dff3ff, #b8e0ff); }
.t-pink { background: linear-gradient(135deg, #ffe3ee, #ffc2d8); }
.menu-star { font-size: 3.2rem; filter: drop-shadow(0 0 10px #f2c14e); }

/* play area */
.fest-play { border-radius: 28px; padding: 16px; text-align: center; }
.fest-play h3 { margin: 0; font: 700 1.2rem "Mali", sans-serif; }
.fp-desc { margin: 2px 0 10px; font-size: .84rem; opacity: .8; }
.fp-stage { position: relative; min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.fp-actions { display: flex; justify-content: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.fp-btn { min-width: 220px; font-size: 1.05rem; padding: 12px 22px; }
.fp-hint { margin: 10px 0 0; font: 600 .95rem/1.5 "Mali", sans-serif; min-height: 1.5em; }

/* 1. siamsee */
.siam { position: relative; display: flex; flex-direction: column; align-items: center; }
.siam-cyl svg { width: 150px; height: 236px; transform-origin: 50% 90%; }
.siam-cyl.shake svg { animation: siamShake .14s ease-in-out infinite alternate; }
.siam-cyl.shake .sticks { animation: sticksJiggle .1s linear infinite alternate; }
@keyframes siamShake { from { transform: rotate(-9deg) translateX(-4px); } to { transform: rotate(9deg) translateX(4px); } }
@keyframes sticksJiggle { to { transform: translateY(-4px); } }
.siam-stick { position: absolute; top: 20px; left: 50%; width: 40px; margin-left: 52px; opacity: 0; pointer-events: none; }
.siam-stick svg { width: 40px; height: 200px; }
.siam-stick.drop { animation: stickDrop 1s cubic-bezier(.3, 1.3, .5, 1) forwards; }
@keyframes stickDrop { 0% { opacity: 0; transform: translate(-60px, 0) rotate(0); } 30% { opacity: 1; transform: translate(-40px, -40px) rotate(-30deg); } 100% { opacity: 1; transform: translate(10px, 60px) rotate(62deg); } }

/* 2. cookie */
.cookies { display: grid; grid-template-columns: repeat(3, 110px); gap: 14px; justify-content: center; }
.ck { position: relative; border: 0; background: rgba(255, 255, 255, .6); border-radius: 22px; padding: 10px; cursor: pointer; transition: transform .25s, opacity .25s; animation: cardIn .4s both; animation-delay: calc(var(--i) * 50ms); }
.ck svg { width: 88px; height: 70px; display: block; }
.ck:hover { transform: translateY(-3px) rotate(-3deg); }
.ck.dim { opacity: .25; transform: scale(.9); }
.ck.picked { transform: scale(1.35); z-index: 2; box-shadow: 0 0 0 4px #ffb45d, 0 10px 24px rgba(201, 143, 46, .4); animation: wobble .6s ease-in-out infinite alternate; }
@keyframes wobble { from { rotate: -3deg; } to { rotate: 3deg; } }
.ck.cracked { animation: none; width: 330px; grid-column: 1 / -1; justify-self: center; height: 120px; display: flex; align-items: center; justify-content: center; transform: scale(1); background: transparent; box-shadow: none; }
.ck-l, .ck-r { position: absolute; top: 20px; }
.ck-l { left: 70px; animation: halfL .5s ease-out forwards; } .ck-r { right: 70px; animation: halfR .5s ease-out forwards; }
.ck-l svg, .ck-r svg { width: 50px; height: 80px; }
@keyframes halfL { to { transform: translate(-50px, 10px) rotate(-28deg); } }
@keyframes halfR { to { transform: translate(50px, 10px) rotate(28deg); } }
.ck-paper { position: relative; z-index: 1; max-width: 240px; padding: 10px 14px; background: #fff; border: 2px dashed #f2c14e; border-radius: 6px; font: 700 .9rem/1.45 "Mali", sans-serif; color: #5a3a2a;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .12); animation: paperOut .9s .25s cubic-bezier(.3, 1.3, .5, 1) both; }
@keyframes paperOut { from { transform: scaleX(.1); opacity: 0; } }

/* 3. tarot */
.tarot { display: flex; justify-content: center; align-items: flex-end; gap: 0; padding: 20px 0; perspective: 900px; }
.tcard { width: 110px; height: 165px; margin: 0 -8px; border: 0; background: none; padding: 0; cursor: pointer; transform: rotate(var(--r)); transition: transform .3s, opacity .3s; animation: cardIn .4s both; animation-delay: calc(var(--i) * 70ms); }
.tcard:hover { transform: rotate(var(--r)) translateY(-14px); }
.tc-inner { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .8s cubic-bezier(.3, 1.2, .5, 1); }
.tc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; filter: drop-shadow(0 8px 14px rgba(33, 27, 83, .3)); }
.tc-face svg { width: 100%; height: 100%; }
.tc-front { transform: rotateY(180deg); }
.tcard.flipped { transform: rotate(0) translateY(-10px) scale(1.25); z-index: 3; }
.tcard.flipped .tc-inner { transform: rotateY(180deg); }
.tcard.dim { opacity: .2; }

/* 4. stars */
.sky-box { position: relative; width: 100%; height: 320px; border-radius: 22px; overflow: hidden;
  background: radial-gradient(2px 2px at 20% 30%, #fff, transparent), radial-gradient(2px 2px at 70% 20%, #fff, transparent), radial-gradient(1.5px 1.5px at 40% 70%, #fff, transparent), radial-gradient(1.5px 1.5px at 85% 60%, #fff, transparent), linear-gradient(#120e3a, #3b2f86); }
.sky-moon { position: absolute; right: 8%; top: 12%; width: 54px; height: 54px; border-radius: 50%; background: #fff4cc; box-shadow: 0 0 30px 8px rgba(255, 244, 204, .4); }
.shoot { position: absolute; width: 150px; height: 40px; border: 0; background: none; padding: 0; cursor: pointer; transform: rotate(18deg); animation: shootAcross var(--dur) linear forwards; }
.shoot .tail { position: absolute; left: 0; top: 50%; width: 120px; height: 3px; margin-top: -1.5px; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--c)); }
.shoot .head { position: absolute; right: 0; top: 50%; transform: translateY(-50%); font-size: 30px; color: var(--c); text-shadow: 0 0 12px var(--c), 0 0 24px var(--c); }
.shoot.s-gold .head { font-size: 38px; }
@keyframes shootAcross { from { translate: 0 0; opacity: 0; } 10% { opacity: 1; } to { translate: 560px 180px; opacity: 0; } }
.shoot.caught { animation: none; z-index: 3; }
.shoot.caught .tail { opacity: 0; transition: opacity .3s; }
.shoot.caught .head { animation: starGrow 1.1s ease-out forwards; }
@keyframes starGrow { to { font-size: 120px; text-shadow: 0 0 40px var(--c), 0 0 80px var(--c); } }
.star-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 10px; font-size: .76rem; }
.star-legend i, .rates i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }

/* 5. krathong */
.kt-pick { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ktp { width: 120px; border: 2px solid var(--line); border-radius: 18px; background: var(--card); padding: 6px; cursor: pointer; font: 600 .78rem "Mali", sans-serif; color: var(--ink); }
.ktp svg { width: 100%; height: auto; display: block; }
.ktp[aria-pressed="true"] { border-color: #3a9ad9; box-shadow: 0 0 0 3px rgba(58, 154, 217, .25); }
.kt-wish { display: block; width: min(420px, 100%); margin: 12px auto 0; text-align: left; font-size: .78rem; color: var(--muted); }
.kt-wish input { margin-top: 4px; }
.mini-river { position: relative; width: 100%; height: 130px; margin-top: 14px; border-radius: 22px; overflow: hidden;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .12) 0 30px, transparent 30px 60px) 0 70% / 60px 6px no-repeat, linear-gradient(#2a2466, #1a1650); }
.mini-river::before { content: ""; position: absolute; inset: 60% -50% auto; height: 14px; background: radial-gradient(ellipse 18px 3px, #8fa8ff 60%, transparent 62%) 0 0 / 60px 14px repeat-x; opacity: .35; animation: wave 6s linear infinite; }
.mr-kt { position: absolute; left: 4%; bottom: 14px; width: 110px; filter: drop-shadow(0 0 10px rgba(255, 210, 94, .6)); }
.mr-kt svg { width: 100%; height: auto; display: block; }
.mr-kt.float { animation: ktFloat 2.6s ease-in-out forwards; }
@keyframes ktFloat { 0% { transform: translateX(0) rotate(0); } 25% { transform: translateX(15vw) rotate(-3deg); } 50% { transform: translateX(30vw) rotate(3deg); } 100% { transform: translateX(calc(min(980px, 100vw) - 260px)) rotate(0); } }
.mr-goal { position: absolute; right: 4%; bottom: 40px; font-size: 2rem; filter: drop-shadow(0 0 12px #ffcf6b); }
.mini-river.arrived .mr-goal { animation: glowPulse .6s ease-in-out 3; }
@keyframes glowPulse { 50% { transform: scale(1.4); filter: drop-shadow(0 0 22px #ffcf6b); } }

/* 6. gacha */
.gacha-wrap { position: relative; display: flex; justify-content: center; }
.gacha-m svg { width: 170px; height: 255px; }
.gacha-m.spin svg { animation: siamShake .12s ease-in-out infinite alternate; }
.gacha-m.spin .knob { animation: knob 1s linear; transform-box: fill-box; transform-origin: center; }
@keyframes knob { to { transform: rotate(720deg); } }
.cap-out { position: absolute; left: calc(50% + 60px); bottom: 0; width: 84px; border: 0; background: none; padding: 0; cursor: pointer; }
.cap-out svg { width: 84px; height: 84px; display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25)); }
.cap-out.drop { animation: capDrop .8s cubic-bezier(.3, 1.5, .5, 1) both; }
@keyframes capDrop { from { transform: translate(-60px, -60px) scale(.5); opacity: 0; } }
.cap-out.r-epic svg, .cap-out.r-secret svg { filter: drop-shadow(0 0 16px #f2c14e); }
.cap-out.open .ctop { animation: capTop .5s ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes capTop { to { transform: translateY(-14px) rotate(-18deg); } }
.rates { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; margin-top: 10px; font-size: .76rem; }

/* result card */
.fres { display: flex; flex-direction: column; align-items: center; }
.fcard { position: relative; width: min(560px, 100%); border-radius: 30px; padding: 22px 22px 16px; background: #fff8ef; color: #3d2b4f; border: 3px solid var(--fc);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, .6), 0 20px 50px rgba(33, 27, 83, .25); overflow: hidden; animation: cardReveal .7s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes cardReveal { from { opacity: 0; transform: scale(.7) rotate(-4deg); } }
.fc-sparkles { position: absolute; inset: 0; pointer-events: none; background:
  radial-gradient(3px 3px at 12% 18%, #f2c14e, transparent), radial-gradient(2px 2px at 88% 12%, #ff83a9, transparent), radial-gradient(3px 3px at 92% 70%, #c9a2ff, transparent), radial-gradient(2px 2px at 6% 80%, #8fd3ff, transparent);
  animation: tw 2s ease-in-out infinite; }
.fc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.fc-act { font: 700 .82rem "Mali", sans-serif; color: var(--fc); }
.fc-badge { font: 700 .72rem "Mali", sans-serif; color: #fff; background: var(--fc); padding: 2px 10px; border-radius: 999px; }
.fc-badge.r-secret, .fc-badge.r-epic { background: linear-gradient(135deg, #f2c14e, #ff9f43); }
.fc-top { display: grid; grid-template-columns: 100px 1fr; gap: 14px; align-items: center; margin-top: 8px; }
.fc-art svg { width: 100px; height: 120px; display: block; margin: 0 auto; }
.art-star { display: block; font-size: 84px; line-height: 1; text-align: center; text-shadow: 0 0 20px currentColor; }
.fc-label { margin: 0; font: 700 1.2rem "Mali", sans-serif; }
.fc-title { margin: 2px 0 0; font: 700 1.35rem "Mali", sans-serif; color: var(--fc); }
.fc-name { margin: 2px 0 0; font-size: .82rem; color: #8d7a90; }
.fc-msg { margin: 14px 0 6px; padding: 12px 14px; border-radius: 18px; background: #fff; font: 700 1.12rem/1.55 "Mali", sans-serif; text-align: center; overflow-wrap: anywhere; }
.fc-sub { margin: 0 0 6px; text-align: center; font-size: .86rem; color: #7a5a48; }
.fc-scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 10px 0 6px; }
.fc-scores div { text-align: center; background: #fff; border-radius: 14px; padding: 6px 4px; }
.fc-scores dt { font: 700 .76rem "Mali", sans-serif; color: #51417e; }
.fc-scores dd { margin: 0; color: #f2b632; letter-spacing: 1px; font-size: .95rem; }
.fc-lucky { text-align: center; margin: 6px 0; font: 600 .9rem "Mali", sans-serif; }
.fc-lucky b { display: inline-block; min-width: 34px; padding: 1px 8px; border-radius: 999px; background: var(--fc); color: #fff; }
.fc-mascot { display: grid; grid-template-columns: 70px 1fr; gap: 10px; align-items: center; margin-top: 8px; }
.fc-mimg svg { width: 70px; height: 70px; display: block; }
.fc-mascot p { margin: 0; padding: 8px 12px; border-radius: 16px; background: #fff; border: 2px solid var(--fc); font: 600 .86rem/1.45 "Mali", sans-serif; }
.fc-mascot small { display: block; font: 400 .7rem "IBM Plex Sans Thai", sans-serif; color: #8d7a90; }
.fc-foot { margin-top: 10px; text-align: center; font-size: .7rem; color: #a08fae; }
.fres-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: min(560px, 100%); margin-top: 14px; }
.fres-actions .btn { padding: 11px 10px; }
.btn.fav[aria-pressed="true"] { background: linear-gradient(135deg, #fff1c9, #ffd96b); color: #7a5a00; }

/* book */
.fb-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fb-filters .chip { background: var(--card); font-size: .78rem; padding: 4px 12px; }
.fb-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.fb-item { display: flex; align-items: stretch; background: var(--card); border-radius: 18px; border: 1px solid var(--line); overflow: hidden; }
.fb-open { flex: 1; display: flex; gap: 10px; text-align: left; border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--ink); min-width: 0; }
.fb-dot { flex: none; width: 10px; border-radius: 999px; background: var(--fc); }
.fb-text { min-width: 0; display: grid; gap: 2px; }
.fb-text b { font: 700 .88rem "Mali", sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-text small { font-size: .72rem; color: var(--muted); }
.fb-text em { font-style: normal; font-size: .8rem; color: #6b5a7a; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.fb-fav { flex: none; width: 46px; border: 0; background: var(--chip); color: #f2b632; font-size: 1.3rem; cursor: pointer; }
.fb-empty { text-align: center; padding: 20px; }
.fb-empty svg { width: 110px; height: 110px; }

/* entry buttons on the main page */
.fest-entry { height: 42px; border: 0; border-radius: 999px; padding: 0 14px 0 10px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: linear-gradient(135deg, #c9a2ff, #ff83a9); color: #fff; font: 700 .82rem "Mali", sans-serif; box-shadow: 0 6px 16px rgba(201, 162, 255, .45); }
.fest-link { display: block; margin: 8px auto 0; }

@media (max-width: 640px) {
  .fest { padding: 0; }
  .fest-shell { border-radius: 0; min-height: 100%; padding: 14px 12px 12px; }
  .fest-head h2 { font-size: 1.15rem; }
  .fest-name input { width: 120px; }
  .fest-card { grid-template-columns: 80px 1fr; min-height: 120px; }
  .fest-card .fc-art svg { width: 76px; height: 86px; }
  .cookies { grid-template-columns: repeat(3, 92px); gap: 10px; }
  .ck svg { width: 72px; height: 58px; }
  .tcard { width: 78px; height: 117px; margin: 0 -6px; }
  .fc-top { grid-template-columns: 76px 1fr; }
  .fc-art svg { width: 76px; height: 92px; }
  .fp-btn { min-width: 0; width: 100%; }
  .cap-out { left: calc(50% + 40px); }
  .fest-entry .lbl { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fest *, .fest *::before, .fest *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .shoot { animation-duration: 6s !important; }
}
