/* ═══════════════════════════════════════════════════════════════
   Fortune Sticks — Chinese Wind Style
   ═══════════════════════════════════════════════════════════════ */

:root {
  --red-deep:   #4A0A0A;
  --red:        #8B1A1A;
  --red-mid:    #A52020;
  --red-bright: #C0392B;
  --gold:       #C9A227;
  --gold-light: #F0D060;
  --gold-pale:  #FFF8DC;
  --cream:      #FDF6E3;
  --ink:        #2C1A0E;
  --wood:       #D4A96A;
  --wood-dark:  #8B6340;
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  font-family: 'Noto Serif SC', 'STSong', '华文宋体', serif;
  background: #0d0202;   /* letterbox colour on desktop */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

/* ── Game wrapper — matches horsehsg.com sizing ───────────────── */
#gameWrap {
  position: relative;
  width: 100%;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
  background: var(--red-deep);
}

@media (min-width: 600px) {
  #gameWrap {
    width: 400px;
    height: 711px;
  }
}

/* ── Particle canvas ──────────────────────────────────────────── */
#particleCanvas {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 0;
}

/* ── Pages ────────────────────────────────────────────────────── */
.page {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(180,40,20,0.6) 0%, transparent 100%),
    radial-gradient(ellipse 60% 50% at 50% 110%, rgba(80,5,5,0.9) 0%, transparent 100%),
    linear-gradient(175deg, #5A0E0E 0%, #7B1515 45%, #4A0A0A 100%);
  transition: opacity 0.5s ease;
}
.page.active { opacity: 1; pointer-events: all; }

.page-inner {
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
  width: 100%;
  height: 100%;
  justify-content: center;
  padding: max(70px, env(safe-area-inset-top)) 24px max(30px, env(safe-area-inset-bottom));
}

/* ── Lanterns ─────────────────────────────────────────────────── */
.lantern {
  position: absolute; top: 0;
  display: flex; flex-direction: column; align-items: center;
  transform-origin: top center;
  animation: lanternSway 3.5s ease-in-out infinite;
  z-index: 2;
}
.lantern-l { left: 12px; animation-delay: 0s; }
.lantern-r { right: 12px; animation-delay: -1.75s; }

.lantern::before {       /* hanging thread */
  content: '';
  display: block;
  width: 2px; height: 28px;
  background: linear-gradient(var(--gold), #8B6914);
}

.lantern-body {
  width: 44px; height: 64px;
  background: linear-gradient(180deg,
    #E8A020 0%, #F0B830 20%,
    #C85010 50%,
    #F0B830 80%, #E8A020 100%);
  border-radius: 50% 50% 45% 45% / 35% 35% 25% 25%;
  box-shadow:
    0 0 24px rgba(255,160,20,0.7),
    0 0 48px rgba(255,100,0,0.3),
    inset 0 0 18px rgba(255,80,0,0.4);
  position: relative;
}
.lantern-body::after {   /* center ring */
  content: '';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 90%; height: 4px;
  background: rgba(0,0,0,0.2);
  border-radius: 2px;
}

.lantern-fringe {
  width: 32px; height: 18px;
  background: repeating-linear-gradient(
    90deg,
    #E8A020 0px, #E8A020 3px,
    transparent 3px, transparent 6px
  );
  mask-image: linear-gradient(180deg, black 0%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, black 0%, transparent 100%);
}

@keyframes lanternSway {
  0%,100% { transform: rotate(-6deg); }
  50%      { transform: rotate(6deg);  }
}

/* ── Title ────────────────────────────────────────────────────── */
.title-block { text-align: center; }

.title-sub {
  font-size: 0.78rem;
  letter-spacing: 0.4em;
  color: var(--gold);
  margin-bottom: 6px;
}

.title-main {
  font-size: 3.2rem; font-weight: 900;
  color: var(--gold-light);
  letter-spacing: 0.35em;
  text-shadow:
    0 0 30px rgba(240,208,96,0.8),
    0 0 60px rgba(201,162,39,0.4),
    0 3px 6px rgba(0,0,0,0.5);
  line-height: 1.1; margin-bottom: 8px;
}

.title-hint {
  font-size: 0.82rem;
  color: rgba(255,243,192,0.7);
  letter-spacing: 0.15em;
}

/* ── Tube scene ───────────────────────────────────────────────── */
.tube-scene {
  position: relative;
  width: 130px; height: 290px;
  display: flex; align-items: flex-end; justify-content: center;
  flex-shrink: 0;
}

/*
  Sticks layer sits ABOVE the vessel (z:4 > vessel z:3).
  mask-image fades the bottom portion transparent so sticks appear
  to vanish inside the tube and only poke out above the rim.
  Vessel rim bottom ≈ 60% up the sticks-layer → fade starts there.
*/
.sticks-layer {
  position: absolute;
  bottom: 38px;
  left: 50%; transform: translateX(-50%);
  width: 66px; height: 230px;
  display: flex; align-items: flex-end; justify-content: center;
  gap: 5px;
  z-index: 4;
  mask-image: linear-gradient(to top, transparent 0%, transparent 55%, black 68%);
  -webkit-mask-image: linear-gradient(to top, transparent 0%, transparent 55%, black 68%);
}

.stick {
  width: 8px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg,
    #F5E6C8 0%, #D4A96A 30%, #8B6340 100%);
  box-shadow: 1px 0 3px rgba(0,0,0,0.3);
  flex-shrink: 0;
  transform-origin: bottom center;
}

/* Vessel */
.vessel {
  position: absolute; bottom: 0;
  display: flex; flex-direction: column; align-items: center;
  z-index: 3;
  transform-origin: bottom center;
}

.vessel-rim {
  width: 90px; height: 14px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 50%, #8B6914);
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4), 0 0 8px rgba(201,162,39,0.3);
  z-index: 4;
}

.vessel-body {
  width: 76px; height: 140px;
  background: linear-gradient(90deg,
    #6B0F0F 0%, #9B1A1A 15%, #C03030 50%, #9B1A1A 85%, #6B0F0F 100%);
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}

.vessel-body::before {    /* lacquer shine */
  content: '';
  position: absolute; top: 0; left: 20%; width: 15%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}

.vessel-body::after {     /* cloud pattern stripe */
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px, transparent 22px,
    rgba(0,0,0,0.07) 22px, rgba(0,0,0,0.07) 24px
  );
}

.vessel-char {
  font-size: 2.2rem; font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(201,162,39,0.6);
  z-index: 1; letter-spacing: 0;
  opacity: 0.85;
}

.vessel-foot {
  width: 68px; height: 20px;
  background: linear-gradient(180deg, #8B6914, var(--gold) 50%, #8B6914);
  border-radius: 3px 3px 8px 8px;
  box-shadow: 0 5px 14px rgba(0,0,0,0.5);
}

/* Incense sticks */
.incense-wrap {
  position: absolute; bottom: 20px;
  display: flex; gap: 6px; align-items: flex-end;
  z-index: 1;
}

.incense {
  width: 3px; height: 50px;
  background: linear-gradient(180deg, #888 0%, #D4A96A 40%, #8B6340 100%);
  border-radius: 1px;
  position: relative;
}

.incense::before {    /* ember glow */
  content: '';
  position: absolute; top: -3px; left: -1px;
  width: 5px; height: 5px;
  background: radial-gradient(circle, #FF8C00, #FF4500);
  border-radius: 50%;
  box-shadow: 0 0 6px #FF8C00;
  animation: emberPulse 1.8s ease-in-out infinite;
}

.incense::after {    /* smoke */
  content: '';
  position: absolute; top: -20px; left: 1px;
  width: 2px; height: 18px;
  background: linear-gradient(180deg, transparent, rgba(200,200,200,0.3));
  border-radius: 1px;
  animation: smokeRise 2s ease-in-out infinite;
}

.incense:nth-child(2) { height: 40px; animation-delay: 0.6s; }
.incense:nth-child(3) { height: 55px; animation-delay: 1.2s; }

@keyframes emberPulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(0.8); }
}
@keyframes smokeRise {
  0%   { transform: translateY(0) scaleX(1);  opacity: 0.4; }
  100% { transform: translateY(-20px) scaleX(2); opacity: 0; }
}

/* ── Shake meter ──────────────────────────────────────────────── */
.shake-hint {
  font-size: 0.92rem;
  color: var(--gold-light);
  letter-spacing: 0.1em;
  text-align: center;
}

.shake-meter {
  width: 200px; height: 8px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--gold);
  border-radius: 4px; overflow: hidden;
}

.shake-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 100%);
  border-radius: 4px;
  transition: width 0.1s ease;
  box-shadow: 0 0 8px rgba(240,208,96,0.6);
}

.desktop-note {
  font-size: 0.72rem;
  color: rgba(255,243,192,0.4);
  letter-spacing: 0.1em;
  margin-top: -10px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-gold {
  padding: 14px 44px;
  font-family: inherit; font-size: 1rem; font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--ink);
  background: linear-gradient(180deg, var(--gold-pale) 0%, var(--gold-light) 30%, var(--gold) 60%, #9A7A10 100%);
  border: none; border-radius: 3px;
  cursor: pointer;
  position: relative; overflow: hidden;
  box-shadow:
    0 5px 20px rgba(0,0,0,0.4),
    0 0 0 1px rgba(201,162,39,0.5),
    inset 0 1px 0 rgba(255,255,255,0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-gold::before {
  content: '';
  position: absolute; top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transition: left 0.4s ease;
}
.btn-gold:hover::before { left: 150%; }
.btn-gold:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.btn-shake { min-width: 180px; }

/* ── Flying stick ─────────────────────────────────────────────── */
.flying-stick {
  position: fixed;
  width: 10px; height: 150px;
  background: linear-gradient(180deg, #F5E6C8 0%, var(--wood) 50%, var(--wood-dark) 100%);
  border-radius: 4px 4px 2px 2px;
  z-index: 50; pointer-events: none;
  display: none;
  box-shadow:
    0 0 20px rgba(240,208,96,0.9),
    0 0 50px rgba(201,162,39,0.5),
    0 0 80px rgba(201,162,39,0.2);
}

/* ── Result overlay ───────────────────────────────────────────── */
.result-overlay {
  position: absolute; inset: 0; z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(40,0,0,0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.result-card {
  position: relative;
  width: 100%; max-width: 330px;
  background: linear-gradient(160deg, #FEFBF0 0%, var(--cream) 60%, #F5EDD0 100%);
  border-radius: 3px;
  padding: 36px 28px 28px;
  text-align: center;
  color: var(--ink);
  box-shadow:
    0 0 0 1px var(--gold),
    0 0 0 5px rgba(201,162,39,0.2),
    0 24px 64px rgba(0,0,0,0.7);
  /* paper texture */
  background-image:
    linear-gradient(160deg, #FEFBF0 0%, var(--cream) 60%, #F5EDD0 100%),
    url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

/* Gold corner ornaments */
.card-corner {
  position: absolute; width: 20px; height: 20px;
  border-color: var(--gold); border-style: solid;
  opacity: 0.7;
}
.card-corner-tl { top: 10px; left: 10px;  border-width: 2px 0 0 2px; }
.card-corner-tr { top: 10px; right: 10px; border-width: 2px 2px 0 0; }
.card-corner-bl { bottom: 10px; left: 10px;  border-width: 0 0 2px 2px; }
.card-corner-br { bottom: 10px; right: 10px; border-width: 0 2px 2px 0; }

.lot-no-wrap {
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: #7B4F2E;
  margin-bottom: 6px;
}

.lot-level {
  font-size: 1.55rem; font-weight: 900;
  color: var(--red-bright);
  letter-spacing: 0.25em;
  margin-bottom: 4px;
  text-shadow: 0 1px 3px rgba(192,57,43,0.3);
}

.lot-title {
  font-size: 1.15rem; font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.25em;
}

.divider {
  margin: 14px 0;
  display: flex; align-items: center; gap: 8px;
  color: var(--gold); font-size: 0.7rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.lot-poem {
  font-size: 0.95rem;
  line-height: 2.4;
  letter-spacing: 0.12em;
  color: var(--ink);
  white-space: pre-line;
  margin-bottom: 14px;
  font-family: inherit;
}

.lot-summary {
  font-size: 0.8rem;
  line-height: 1.8;
  color: #6B4020;
  letter-spacing: 0.06em;
  margin-bottom: 24px;
  padding: 10px 14px;
  background: rgba(201,162,39,0.08);
  border-left: 2px solid var(--gold);
  text-align: left;
}

.btn-cta {
  width: 100%; padding: 14px;
  font-family: inherit; font-size: 0.95rem; font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--gold-pale);
  background: linear-gradient(180deg, var(--red-mid) 0%, var(--red-deep) 100%);
  border: 1px solid rgba(201,162,39,0.5);
  border-radius: 2px; cursor: pointer;
  box-shadow: 0 3px 12px rgba(0,0,0,0.3);
  transition: transform 0.1s, opacity 0.1s;
}
.btn-cta:active { transform: scale(0.98); opacity: 0.9; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-height: 640px) {
  .page-inner { gap: 12px; }
  .title-main { font-size: 2.2rem; }
  .tube-scene { height: 210px; }
  .vessel-body { height: 100px; }
  .sticks-layer { height: 170px; bottom: 32px; }
  .incense-wrap { display: none; }
}
