@font-face { font-family: "Sarabun"; src: url("fonts/Sarabun-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Sarabun"; src: url("fonts/Sarabun-Medium.ttf") format("truetype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Sarabun"; src: url("fonts/Sarabun-SemiBold.ttf") format("truetype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Sarabun"; src: url("fonts/Sarabun-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Kanit"; src: url("fonts/Kanit-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Kanit"; src: url("fonts/Kanit-Medium.ttf") format("truetype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Kanit"; src: url("fonts/Kanit-SemiBold.ttf") format("truetype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Kanit"; src: url("fonts/Kanit-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Charm"; src: url("fonts/Charm-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Charm"; src: url("fonts/Charm-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Noto Serif CJK TC"; src: url("fonts/NotoSerifCJKtc-Bold-subset.otf") format("opentype"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --bg-0: #2a0808;
  --bg-1: #5c1212;
  --gold: #e4c36a;
  --gold-2: #c9a227;
  --gold-line: #d4a937;
  --gold-deep: #8a6414;
  --cream: #f6ecd7;
  --cream-2: #efe1c0;
  --red: #9e1b1b;
  --red-deep: #7a1414;
  --ink: #3a1a10;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Sarabun", "Noto Sans Thai", sans-serif;
  color: var(--cream);
  background:
    radial-gradient(ellipse 90% 55% at 50% 28%, rgba(228, 195, 106, 0.22), transparent 68%),
    radial-gradient(ellipse 80% 40% at 50% 100%, rgba(20, 0, 0, 0.55), transparent 70%),
    linear-gradient(180deg, #4a1010 0%, #6b1616 28%, #3a0c0c 100%);
  overflow-wrap: anywhere;
  line-break: auto;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  z-index: 0;
  background-image:
    repeating-linear-gradient(45deg, #e4c36a 0 2px, transparent 2px 14px),
    repeating-linear-gradient(-45deg, #e4c36a 0 2px, transparent 2px 14px);
  mask-image: radial-gradient(ellipse at 50% 40%, #000 30%, transparent 75%);
}
body.home { height: 100%; height: 100dvh; overflow: hidden; }
body.fortune, body.all { overflow: auto; }

.app {
  position: relative;
  z-index: 1;
  max-width: 430px;
  margin: 0 auto;
}
body.home .app {
  min-height: 100dvh;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) 20px calc(16px + var(--safe-bottom));
}
body:not(.home) .app { display: none; }

.view[hidden] { display: none !important; }

/* ===== Home / box / stick ===== */
.home-header { text-align: center; flex: 0 0 auto; }
.mock-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: linear-gradient(180deg, #f3e2a8, #d4b24a);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 14px;
}
h1.brand {
  font-family: "Charm", "Kanit", serif;
  font-weight: 700;
  font-size: 40px;
  line-height: 1.25;
  padding-top: 4px;
  color: #ffe39a;
  text-shadow: 0 2px 0 #5a0a0a, 0 8px 24px rgba(0,0,0,0.35);
}
.flourish {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 2px;
  color: var(--gold-2);
  opacity: 0.9;
}
.flourish span { font-size: 13px; letter-spacing: 0.4em; }
.flourish i {
  display: block;
  width: 48px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.subtitle {
  font-size: 14px;
  font-weight: 500;
  color: var(--cream-2);
  opacity: 0.92;
}

.stage {
  flex: 1 1 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.cylinder-wrap {
  width: min(268px, 72vw);
  position: relative;
  overflow: visible;
}
.cylinder-wrap svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 16px 16px rgba(0,0,0,0.42));
}
.stage { overflow: visible; }
#drawnStick { display: none; }
#drawnStick.is-visible { display: block; }
#drawnStick { cursor: pointer; }

.hint {
  margin-top: 10px;
  min-height: 22px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--gold);
  text-shadow: 0 1px 8px rgba(0,0,0,0.5);
  max-width: 280px;
}

.controls {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
}
.btn-draw {
  width: 100%;
  max-width: 280px;
  height: 56px;
  border: 0;
  border-radius: 999px;
  font-family: "Kanit", "Sarabun", sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.06em;
  color: #4a0c0c;
  background: linear-gradient(180deg, #f4e09a 0%, #e4c36a 42%, #c9a227 100%);
  box-shadow:
    0 3px 0 #7a5a10,
    0 10px 22px rgba(0,0,0,0.35),
    0 0 24px rgba(228, 195, 106, 0.28);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-draw:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a5a10, 0 4px 12px rgba(0,0,0,0.3); }
.btn-draw:disabled { opacity: 0.65; cursor: default; }
.link-all {
  border: 0;
  background: none;
  color: var(--gold);
  font-family: "Sarabun", sans-serif;
  font-weight: 600;
  font-size: 15px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 6px 8px;
  -webkit-tap-highlight-color: transparent;
}
.note {
  font-size: 11.5px;
  color: rgba(246, 236, 215, 0.62);
  text-align: center;
  line-height: 1.45;
  max-width: 300px;
}

/* ===== Shared top bar for fortune / all ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) 12px 8px;
  background: linear-gradient(180deg, #5c1212 0%, #4a1010 100%);
  border-bottom: 1px solid rgba(212, 169, 55, 0.45);
  max-width: 430px;
  margin: 0 auto;
}
.topbar .btn-back,
.topbar .btn-text {
  border: 1px solid rgba(228, 195, 106, 0.55);
  background: transparent;
  color: var(--gold);
  font-family: "Sarabun", sans-serif;
  font-weight: 600;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.topbar h2 {
  flex: 1;
  text-align: center;
  font-family: "Kanit", sans-serif;
  font-weight: 500;
  font-size: 15px;
  color: #ffe39a;
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-pill {
  text-align: center;
  padding: 8px 0 0;
}
.topbar .spacer { width: 72px; flex: none; }
.topbar .mock-pill { margin: 0 0 0 0; }

/* ===== Fortune sheet — book style, white + red-gold frame ===== */
.fortune-wrap {
  padding: 10px 10px calc(20px + var(--safe-bottom));
  max-width: 430px;
  margin: 0 auto;
}
.sheet {
  position: relative;
  background: #ffffff;
  color: var(--ink);
  border-radius: 8px;
}
.sheet .frame {
  background: #9e1b1b;
  border-radius: 6px;
  padding: 7px;
  box-shadow: inset 0 0 0 2px #9e1b1b, inset 0 0 0 3.5px #d4a937;
}
.sheet .inner {
  background: #ffffff;
  border: 1.5px solid #d4a937;
  outline: 1px solid #d4a937;
  outline-offset: -4px;
  padding: 16px 14px 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.corner {
  position: absolute;
  width: 36px;
  height: 36px;
  z-index: 3;
  pointer-events: none;
}
.corner.tl { top: 8px; left: 8px; }
.corner.tr { top: 8px; right: 8px; transform: scaleX(-1); }
.corner.bl { bottom: 8px; left: 8px; transform: scaleY(-1); }
.corner.br { bottom: 8px; right: 8px; transform: scale(-1,-1); }

.ftop { display: flex; align-items: center; gap: 8px; }
.seal {
  width: 64px; height: 64px; flex: none;
  border-radius: 50%;
  background: #9e1b1b;
  color: #f6e2a8;
  border: 2.5px double #d4a937;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.seal .s1 { font-family: "Kanit", sans-serif; font-size: 10px; line-height: 1; }
.seal .s2 { font-family: "Kanit", sans-serif; font-weight: 600; font-size: 22px; line-height: 1.05; color: #ffe9a8; }
.seal .s3 { font-size: 8px; line-height: 1.15; opacity: .9; text-align: center; padding: 0 2px; }
.title { flex: 1; text-align: center; min-width: 0; }
.title .zh {
  font-family: "Noto Serif CJK TC", "Noto Serif CJK", serif;
  font-weight: 700;
  font-size: 36px;
  color: #9e1b1b;
  line-height: 1.08;
  letter-spacing: 2px;
}
.title .th { font-family: "Kanit", sans-serif; font-weight: 500; font-size: 18px; color: #7a1414; line-height: 1.2; }
.title .mean { font-family: "Sarabun", sans-serif; font-weight: 600; font-size: 12.5px; color: #8a5a12; line-height: 1.3; margin-top: 1px; }
.hexbox { flex: none; width: 78px; text-align: center; }
.hx { display: block; margin: 0 auto; width: 62px; height: auto; }
.hx .ln { fill: #9e1b1b; }
.tri { display: flex; flex-direction: column; font-size: 9.5px; color: #6a3a1a; margin-top: 3px; line-height: 1.35; }

.verdict {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 8px 6px 6px;
  border-radius: 6px;
  border: 1px solid #d4a937;
}
.verdict .vb {
  flex: none;
  font-family: "Kanit", sans-serif;
  font-weight: 500;
  font-size: 13px;
  line-height: 1.3;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}
.verdict .vw { font-size: 13.5px; line-height: 1.4; }

.v-yes { background: #9e1b1b; border-color: #d4a937; }
.v-yes .vb { background: #7a1414; color: #ffe39a; }
.v-yes .vw { color: #ffe39a; }
.v-wait { background: #d4a937; border-color: #b8862b; }
.v-wait .vb { background: #e8c46a; color: #9e1b1b; }
.v-wait .vw { color: #7a1414; }
.v-maybe { background: #fbf3df; border-color: #d4a937; }
.v-maybe .vb { background: #fff8e6; color: #6a3a1a; border: 1px solid #d4a937; }
.v-maybe .vw { color: #6a3a1a; }
.v-no { background: #4a2a18; border-color: #c79a3a; }
.v-no .vb { background: #5a3320; color: #fff4d6; }
.v-no .vw { color: #fff4d6; }

.meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 7px 0;
  border-top: 1px solid #d4a937;
  border-bottom: 1px solid #d4a937;
}
.meta .img { flex: 1; font-size: 13px; font-weight: 600; color: #5a2a10; min-width: 0; line-height: 1.35; }
.meta .k {
  display: inline-block;
  font-family: "Kanit", sans-serif;
  font-weight: 400;
  font-size: 11px;
  color: #fff;
  background: #9e1b1b;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
}
.meta .calc { display: none; }
.luck {
  text-align: center;
  padding: 3px 8px 4px;
  border: 1.5px solid #d4a937;
  border-radius: 6px;
  min-width: 78px;
  background: #ffffff;
  flex: none;
}
.luck .lt { font-size: 9px; color: #8a6a3a; line-height: 1.1; }
.luck .lv { font-family: "Kanit", sans-serif; font-weight: 500; font-size: 13px; line-height: 1.2; }
.luck.good .lv { color: #9e1b1b; }
.luck.bad .lv { color: #5a3320; }
.dots { display: flex; justify-content: center; gap: 3px; margin-top: 2px; }
.dots .d { width: 7px; height: 7px; border-radius: 50%; border: 1px solid #b8862b; box-sizing: border-box; }
.dots .d.on { background: #d4a937; }

.cloud { display: block; width: 140px; height: 16px; margin: 8px auto 6px; }

.main, .sec, .adv { overflow-wrap: break-word; }
.main {
  background: #ffffff;
  border: 1px solid #d4a937;
  border-radius: 6px;
  padding: 8px 12px 10px;
}
.main h3, .adv h3 {
  font-family: "Kanit", sans-serif;
  font-weight: 500;
  font-size: 14px;
  color: #9e1b1b;
  line-height: 1.3;
}
.main h3::before, .adv h3::before { content: "◆ "; color: #d4a937; }
.main p { font-size: 14.5px; line-height: 1.55; text-indent: 1.5em; margin-top: 2px; color: #3a1a10; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(5, auto);
  grid-auto-flow: column;
  column-gap: 12px;
  row-gap: 8px;
  margin-top: 12px;
}
.sec h4 {
  font-family: "Kanit", sans-serif;
  font-weight: 500;
  font-size: 13px;
  color: #7a1414;
  border-bottom: 1px dotted #c79a3a;
  line-height: 1.35;
  margin-bottom: 2px;
}
.sec p { font-size: 13px; line-height: 1.48; color: #3a1a10; }

.adv {
  margin-top: 12px;
  background: #9e1b1b;
  color: #fff4d6;
  border-radius: 6px;
  padding: 8px 12px 10px;
  border: 1.5px solid #d4a937;
}
.adv h3 { color: #ffe39a; }
.adv p { font-size: 14px; line-height: 1.5; margin-top: 2px; text-indent: 0; }

.sheet-foot {
  text-align: center;
  font-size: 10px;
  color: #8a6a3a;
  margin-top: 12px;
}

.fortune-actions {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.btn-again {
  width: 100%;
  max-width: 280px;
  height: 50px;
  border: 0;
  border-radius: 999px;
  font-family: "Kanit", "Sarabun", sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: #4a0c0c;
  background: linear-gradient(180deg, #f4e09a 0%, #e4c36a 42%, #c9a227 100%);
  box-shadow: 0 3px 0 #7a5a10, 0 8px 18px rgba(0,0,0,0.25);
  cursor: pointer;
}

/* ===== All list ===== */
.all-wrap {
  padding: 10px 12px calc(24px + var(--safe-bottom));
  max-width: 430px;
  margin: 0 auto;
}
.all-intro {
  text-align: center;
  font-size: 13px;
  color: var(--cream-2);
  margin: 4px 0 12px;
  line-height: 1.45;
}
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 8px 10px;
  align-items: start;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(212, 169, 55, 0.55);
  background: linear-gradient(180deg, rgba(255,253,247,0.97), rgba(251,243,223,0.96));
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 10px 9px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-family: "Sarabun", sans-serif;
}
.item:active { transform: scale(0.99); }
.item .num {
  font-family: "Kanit", sans-serif;
  font-weight: 600;
  font-size: 22px;
  color: #9e1b1b;
  line-height: 1.1;
  text-align: center;
  padding-top: 2px;
}
.item .names { min-width: 0; }
.item .nm {
  font-size: 15px;
  line-height: 1.3;
  color: #3a1a10;
}
.item .nm .zh {
  font-family: "Noto Serif CJK TC", serif;
  font-weight: 700;
  font-size: 18px;
  color: #9e1b1b;
  margin-right: 4px;
}
.item .nm .pin { font-family: "Kanit", sans-serif; font-weight: 500; color: #7a1414; }
.item .m { font-size: 12.5px; color: #6a3a1a; line-height: 1.35; margin-top: 1px; }
.item .badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}
.tag {
  font-family: "Kanit", sans-serif;
  font-weight: 500;
  font-size: 11px;
  line-height: 1.2;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.tag.v-yes { background: #9e1b1b; color: #ffe39a; }
.tag.v-wait { background: #d4a937; color: #7a1414; }
.tag.v-maybe { background: #fbf3df; color: #6a3a1a; border: 1px solid #d4a937; }
.tag.v-no { background: #4a2a18; color: #fff4d6; }
.tag.luck { background: transparent; color: #8a5a12; border: 1px solid #d4a937; padding: 1px 6px; }

html.shot * { animation: none !important; transition: none !important; }
