:root {
  --night: #100925;
  --night-soft: #1b1037;
  --violet: #6f4de0;
  --gold: #e9c779;
  --gold-pale: #f6e7b9;
  --ink: #f8f4ff;
  --muted: #c6bada;
  --card: rgba(35, 20, 67, .78);
  --line: rgba(233, 199, 121, .24);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(111,77,224,.24), transparent 34rem),
    radial-gradient(circle at 90% 35%, rgba(82,45,156,.17), transparent 28rem),
    var(--night);
  font-family: "Noto Sans Thai", "Thonburi", "Tahoma", sans-serif;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .23;
  background-image: radial-gradient(#fff 0.7px, transparent 0.7px);
  background-size: 27px 27px;
  mask-image: linear-gradient(to bottom, #000, transparent 78%);
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.sky span {
  position: fixed;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--gold-pale);
  box-shadow: 18vw 12vh #fff, 71vw 17vh #fff, 86vw 43vh #e9c779, 13vw 64vh #fff, 54vw 78vh #fff;
  animation: twinkle 3.6s infinite alternate;
}
.sky span:nth-child(2) { left: 33vw; top: 7vh; animation-delay: 1s; opacity: .5; }
.sky span:nth-child(3) { left: 62vw; top: 28vh; animation-delay: 2s; opacity: .65; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
  background: rgba(16, 9, 37, .78);
  border-bottom: 1px solid rgba(255,255,255,.06);
  backdrop-filter: blur(18px);
}

.brand { display: flex; gap: 9px; align-items: center; color: var(--gold-pale); text-decoration: none; font-weight: 800; letter-spacing: .01em; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--gold); border-radius: 50%; }
.sound-button { border: 1px solid var(--line); color: var(--muted); background: transparent; border-radius: 999px; padding: 7px 11px; font-size: .75rem; }

main { width: min(100%, 720px); margin: 0 auto; }
.hero { min-height: calc(100svh - 57px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 46px 22px 36px; text-align: center; }
.eyebrow { margin: 0 0 10px; color: var(--gold); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 17px; font-family: Georgia, "Noto Serif Thai", serif; font-size: clamp(2.15rem, 10vw, 4.3rem); line-height: 1.06; letter-spacing: -.035em; }
h1 em { color: var(--gold-pale); font-weight: 500; }
.intro { max-width: 470px; color: var(--muted); line-height: 1.75; font-size: .97rem; }

.oracle-wrap { position: relative; display: grid; place-items: center; width: 286px; height: 286px; margin: 18px auto 11px; }
.orbit { position: absolute; border: 1px solid var(--line); border-radius: 50%; }
.orbit-one { inset: 5px; animation: spin 22s linear infinite; }
.orbit-one::before, .orbit-two::after { content: "✦"; position: absolute; color: var(--gold); font-size: 13px; }
.orbit-one::before { top: 18px; left: 43px; }
.orbit-two { inset: 26px; border-style: dashed; animation: spin 18s linear infinite reverse; }
.orbit-two::after { right: 12px; bottom: 44px; }
.oracle {
  position: relative;
  z-index: 2;
  width: 196px;
  height: 196px;
  border-radius: 50%;
  border: 1px solid rgba(246,231,185,.7);
  color: var(--ink);
  background: radial-gradient(circle at 35% 25%, #7d5ae7, #3a226e 46%, #170d31 74%);
  box-shadow: 0 0 0 10px rgba(233,199,121,.04), 0 20px 70px rgba(111,77,224,.38), inset 0 0 34px rgba(255,255,255,.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.oracle:active { transform: scale(.96); }
.oracle-stars { color: var(--gold); font-size: .7rem; letter-spacing: .2em; }
.oracle strong { margin: 4px 0 -2px; font-family: Georgia, serif; color: var(--gold-pale); font-size: 4rem; line-height: 1; }
.oracle span:last-child { color: #e5dcf4; font-size: .8rem; }
.oracle.drawing { animation: pulse .65s ease; }
.hint { color: #8f82a8; font-size: .75rem; }

.result, .recent, .about { margin: 0 16px 24px; border: 1px solid var(--line); border-radius: 26px; background: var(--card); backdrop-filter: blur(14px); }
.result { padding: 26px 20px 20px; box-shadow: 0 18px 70px rgba(0,0,0,.2); }
.result-heading { display: flex; gap: 16px; align-items: center; justify-content: space-between; }
.result-heading h2 { margin: 0; font-family: Georgia, "Noto Serif Thai", serif; color: var(--gold-pale); font-size: 1.72rem; line-height: 1.25; }
.number-seal { flex: 0 0 auto; display: grid; place-items: center; width: 62px; height: 62px; border: 1px solid var(--gold); border-radius: 50%; color: var(--gold-pale); font-family: Georgia, serif; font-size: 1.55rem; box-shadow: inset 0 0 18px rgba(233,199,121,.1); }
.message { margin: 22px 0; padding-left: 14px; border-left: 2px solid var(--gold); color: #e4daf2; line-height: 1.75; }
.reading-grid { display: grid; gap: 10px; }
.reading-grid article { padding: 15px; border: 1px solid rgba(255,255,255,.07); border-radius: 16px; background: rgba(255,255,255,.035); }
.reading-grid span { float: right; color: var(--gold); }
.reading-grid h3 { margin-bottom: 6px; font-size: .9rem; color: var(--gold-pale); }
.reading-grid p, .story-card p { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.65; }
.story-card { margin-top: 14px; padding: 18px; border-radius: 18px; color: #211537; background: linear-gradient(145deg, #f2dfaa, #caa55c); }
.story-card .story-label { margin-bottom: 6px; color: #684f20; font-size: .67rem; font-weight: 800; letter-spacing: .14em; }
.story-card h3 { margin-bottom: 7px; font-family: Georgia, "Noto Serif Thai", serif; font-size: 1.2rem; }
.story-card p:last-child { color: #503b24; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 15px; }
.actions button { min-height: 48px; border-radius: 14px; cursor: pointer; }
.primary-action { border: 0; background: var(--gold); color: #24183e; font-weight: 800; }
.secondary-action { border: 1px solid var(--line); background: transparent; color: var(--ink); }

.recent { padding: 20px; }
.section-title { display: flex; justify-content: space-between; align-items: center; }
.section-title h2 { margin: 0; font-size: 1rem; }
.section-title button { border: 0; background: transparent; color: #9b8caf; font-size: .75rem; }
.history { display: flex; gap: 10px; margin-top: 13px; overflow-x: auto; scrollbar-width: none; }
.history button { min-width: 55px; height: 55px; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.04); color: var(--gold-pale); font: 1.1rem Georgia, serif; }
.about { position: relative; overflow: hidden; padding: 34px 24px; text-align: center; }
.about h2 { font: 1.75rem/1.25 Georgia, "Noto Serif Thai", serif; color: var(--gold-pale); }
.about > p:not(.eyebrow), .story-index p { color: var(--muted); font-size: 1rem; line-height: 1.85; }
.story-index { display: grid; gap: 14px; margin: 26px 0; text-align: left; }
.story-index article { padding: 18px; border: 1px solid rgba(255,255,255,.09); border-radius: 16px; background: rgba(255,255,255,.035); }
.story-index h3 { margin-bottom: 8px; color: var(--gold-pale); font-size: 1.1rem; }
.story-index p { margin: 0; }
.editorial-note { margin: 0; text-align: left; }
.moon { display: inline-grid; place-items: center; width: 52px; height: 52px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 50%; color: var(--gold); font-size: 1.7rem; }

footer { padding: 30px 24px calc(30px + env(safe-area-inset-bottom)); text-align: center; color: #887b9f; font-size: .72rem; line-height: 1.6; }
footer strong { display: block; margin-bottom: 5px; color: var(--gold-pale); font-size: .9rem; }
footer p { max-width: 500px; margin: 0 auto; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 20px); opacity: 0; padding: 10px 16px; border-radius: 999px; color: #24183e; background: var(--gold-pale); font-size: .82rem; transition: .25s ease; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
[hidden] { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes twinkle { to { opacity: .15; transform: scale(.75); } }
@keyframes pulse { 50% { transform: scale(.91); filter: brightness(1.35); } }

@media (min-width: 660px) {
  .reading-grid { grid-template-columns: repeat(3, 1fr); }
  .hero { padding-top: 70px; }
  .result, .recent, .about { margin-left: 0; margin-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
