.scene.lottery-scene {
  display: grid;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
  overflow: hidden;
  color: #fff0d6;
  background: #ffc2aa;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  pointer-events: none;
}
.lottery-card {
  position: relative;
  isolation: isolate;
  width: min(100%, 430px);
  height: 100%;
  overflow: hidden;
  border: 2px solid #eb8870;
  border-radius: 46px 40px 49px 42px;
  background: url("lottery-confetti.svg") repeat, radial-gradient(ellipse at 50% 0%, #ff6655 0%, #f4473b 48%, #ec382f 100%);
  background-size: 145px 190px, auto;
  box-shadow: 0 7px 18px rgba(143, 48, 38, .16);
}
.lottery-card::before,.lottery-card::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 2px solid rgba(255, 210, 148, .88);
  border-radius: 37px 32px 40px 34px;
  pointer-events: none;
}
.lottery-card::after { inset: 14px; border-width: 1px; opacity: .48; }
.lottery-header {
  position: absolute;
  z-index: 3;
  top: 24px;
  left: 30px;
  right: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #fff0d2;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
}
.lottery-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 42px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
}
.lottery-back svg { width: 16px; height: 16px; }
.lottery-back:focus-visible,.lottery-draw:focus-visible { outline: 3px solid #fff6e5; outline-offset: 4px; }
.lottery-clouds {
  position: absolute;
  z-index: 1;
  top: clamp(66px, 10dvh, 95px);
  left: 50%;
  width: min(72%, 290px);
  height: auto;
  opacity: 0;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity .5s ease .15s;
}
.lottery-card.has-result .lottery-clouds { opacity: .8; }
.lottery-main {
  position: absolute;
  z-index: 1;
  inset: 13% 6% 21%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2dvh, 18px);
  transition: opacity .45s ease, transform .55s ease;
}
.lottery-cake {
  display: block;
  width: min(95%, 320px);
  max-height: min(49dvh, 370px);
  object-fit: contain;
  animation: lottery-cake-float 4s ease-in-out infinite;
  filter: drop-shadow(0 9px 4px rgba(117, 27, 25, .21));
}
.lottery-cake-caption {
  color: #ffe1c7;
  font-size: clamp(13px, 3.5vw, 16px);
  font-weight: 500;
  letter-spacing: .16em;
  text-align: center;
  white-space: nowrap;
}
.lottery-cake-name {
  display: inline-block;
  margin-left: .18em;
  color: #fff4df;
  font-family: "Great Vibes Birthday", "Snell Roundhand", cursive;
  font-size: 1em;
  font-weight: 400;
  line-height: inherit;
  letter-spacing: 0;
  vertical-align: baseline;
}
@keyframes lottery-cake-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.lottery-cat-side {
  position: absolute;
  z-index: 1;
  top: 49%;
  width: calc(50% - var(--half-fortune-width, 77px));
  display: grid;
  place-items: center;
  pointer-events: none;
  transform: translateY(-50%);
}
.lottery-cat-side-left { left: 0; }
.lottery-cat-side-right { right: 0; }
.lottery-flank-cat {
  display: block;
  width: min(112px, calc(100% + 12px));
  height: auto;
  object-fit: contain;
  opacity: 0;
  transform: scale(.88);
  transition: opacity .5s ease .2s, transform .6s ease .2s;
}
.lottery-card.has-result .lottery-flank-cat {
  opacity: 1;
  transform: scale(1);
}
.lottery-fortune {
  --slat-width: 30px;
  position: absolute;
  z-index: 2;
  top: 47%;
  left: 50%;
  display: block;
  width: 244px;
  max-width: calc(100% - 30px);
  height: min(54dvh, 470px);
  border: 2px solid #8b5a34;
  border-radius: 8px 9px 11px 10px;
  color: #56371e;
  background: linear-gradient(90deg,rgba(89,52,23,.08),transparent 7%,rgba(255,244,195,.13) 48%,rgba(91,50,24,.07)),repeating-linear-gradient(90deg,#8c5b34 0 2px,#d7b577 2px 5px,#ecd69c 5px 25px,#d8b373 25px 28px,#8c5b34 28px var(--slat-width));
  box-shadow: inset 0 0 0 2px rgba(255,241,195,.34),0 10px 0 rgba(115, 43, 29, .19);
  opacity: 0;
  transform: translate(-50%, -39%) scaleY(.83);
  transform-origin: center bottom;
  transition: opacity .45s ease, transform .55s cubic-bezier(.2,.75,.2,1);
}
.lottery-fortune::before,.lottery-fortune::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: -3px;
  right: -3px;
  height: 8px;
  border-top: 1px solid #a9713e;
  border-bottom: 1px solid #714222;
  background: repeating-linear-gradient(0deg,#764629 0 2px,#a86a39 2px 4px,#724327 4px 6px);
  box-shadow: 0 2px 2px rgba(79,42,24,.28);
  pointer-events: none;
}
.lottery-fortune::before { top: 36px; }
.lottery-fortune::after { bottom: 37px; }
.lottery-fortune[hidden] { display: none; }
.lottery-slip-layout {
  position: absolute;
  inset: 57px 2px 62px;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 0;
}
.lottery-fortune-rank {
  display: block;
  flex: none;
  width: var(--slat-width);
  color: #a12f25;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "DFKai-SB", "楷体", serif;
  font-size: 26px;
  font-weight: 900;
  -webkit-text-stroke: .55px currentColor;
  letter-spacing: .18em;
  line-height: var(--slat-width);
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
.lottery-fortune-copy {
  flex: 1;
  min-width: 0;
  height: 100%;
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "DFKai-SB", "楷体", serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
.lottery-text-column {
  display: flex;
  flex: 0 0 calc(100% / var(--fortune-columns, 4));
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-width: 0;
}
.lottery-text-character {
  display: grid;
  flex: 0 0 var(--fortune-char-step, 25px);
  place-items: center;
  width: 100%;
  height: var(--fortune-char-step, 25px);
  font-size: var(--fortune-char-size, 20px);
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
.lottery-text-character.is-lead { color: #4c301d; font-weight: 600; }
.lottery-fortune.is-finished .lottery-slip-layout { justify-content: center; }
.lottery-fortune.is-finished .lottery-fortune-rank { display: none; }
.lottery-fortune.is-finished .lottery-fortune-copy { flex: none; width: var(--slat-width); max-width: 100%; color: #7b3b2a; }
.lottery-fortune.is-finished .lottery-text-character { font-weight: 600; }
.lottery-seal {
  position: absolute;
  z-index: 2;
  bottom: 4px;
  left: 18px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid #a54435;
  color: #a54435;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
  transform: rotate(-8deg);
}
.lottery-card.has-result .lottery-main { opacity: 0; transform: translateY(-13px) scale(.92); pointer-events: none; }
.lottery-card.has-result .lottery-fortune { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.lottery-fortune.is-popping { animation: lottery-slip-rise .55s cubic-bezier(.2,.75,.2,1); }
@keyframes lottery-slip-rise { from { opacity: .2; transform: translate(-50%, -36%) scaleY(.82); } to { opacity: 1; transform: translate(-50%, -50%) scaleY(1); } }
.lottery-draw {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 8%;
  width: min(64%, 260px);
  min-height: 55px;
  padding: 8px 14px;
  border: 2px solid #f6ce9d;
  border-radius: 11px;
  color: #ab4235;
  background: #ffcea0;
  box-shadow: 0 4px 0 rgba(150, 52, 42, .36);
  font-size: clamp(19px, 5vw, 23px);
  font-weight: 700;
  letter-spacing: .08em;
  white-space: nowrap;
  cursor: pointer;
  transform: translateX(-50%);
  transition: background .2s ease, box-shadow .2s ease;
}
.lottery-draw:hover { background: #ffe1b7; }
.lottery-draw:active { box-shadow: 0 1px 0 rgba(150,52,42,.36); }
.lottery-card.has-result .lottery-draw { width: min(54%, 220px); min-height: 48px; font-size: 18px; }
@media (max-height: 650px) {
  .lottery-header { top: 14px; }
  .lottery-clouds { top: 48px; width: min(65%, 245px); }
  .lottery-main { inset: 11% 5% 20%; gap: 4px; }
  .lottery-cake { max-height: 40dvh; }
  .lottery-fortune { top: 46%; height: min(57dvh, 350px); }
  .lottery-slip-layout { inset: 52px 2px 56px; }
  .lottery-draw { bottom: 6%; min-height: 47px; font-size: 18px; }
  .lottery-card.has-result .lottery-draw { min-height: 44px; font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .lottery-cake,.lottery-fortune.is-popping { animation: none; }
}
