.lottery-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: end center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 70%, rgba(238, 211, 129, .22), transparent 42%),
    rgba(25, 49, 38, .43);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.lottery-sheet {
  box-sizing: border-box;
  position: relative;
  width: min(calc(100% - 12px), 468px);
  max-height: 92dvh;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px 18px 25px 29px;
  border: 1px solid rgba(83, 68, 37, .3);
  border-bottom: 0;
  border-radius: 7px 28px 0 0;
  color: #304b39;
  background:
    radial-gradient(circle at 76% 12%, rgba(207, 168, 76, .12), transparent 23%),
    repeating-linear-gradient(180deg, transparent 0 27px, rgba(85, 103, 78, .07) 28px),
    url("../../assets/runtime/ui/book/optimized/ui-book-page-oat-seamless.webp") center / 430px auto repeat;
  box-shadow:
    -12px -18px 50px rgba(22, 39, 28, .28),
    inset 3px 0 rgba(255, 255, 255, .52),
    inset 0 0 0 3px rgba(255, 255, 255, .16);
}

.lottery-binding {
  position: absolute;
  inset: 0 auto 0 0;
  width: 15px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.11) 0 1px, transparent 1px 4px),
    linear-gradient(90deg, #294735, #6d8160 52%, #284433);
  box-shadow: inset -4px 0 7px rgba(20, 42, 28, .42), 4px 0 7px rgba(55, 48, 29, .15);
}

.lottery-header {
  padding: 0 42px 10px 1px;
  border-bottom: 1px solid rgba(88, 71, 37, .24);
}

.lottery-header h2 {
  margin: 3px 0 2px;
  font: 700 1.65rem/1.2 "Noto Serif SC", "Songti SC", STSong, serif;
  letter-spacing: .04em;
}

.lottery-header > p:last-child {
  margin: 0;
  color: #69705e;
  font-size: .72rem;
}

.lottery-kicker {
  margin: 0;
  color: #987129;
  font: 700 .58rem/1.3 Georgia, serif;
  letter-spacing: .16em;
}

.lottery-close {
  position: absolute;
  z-index: 6;
  right: 13px;
  top: 13px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(48, 76, 57, .2);
  border-radius: 50%;
  color: #315440;
  background: rgba(255, 252, 233, .82);
  box-shadow: 0 4px 10px rgba(44, 56, 36, .12);
  font-size: 1.45rem;
}

.lottery-ritual {
  width: min(76vw, 292px);
  height: min(76vw, 292px);
  position: relative;
  display: grid;
  place-items: center;
  margin: 13px auto 10px;
}

.lottery-wheel-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 14px 18px rgba(61, 51, 27, .2));
}

.lottery-orbit {
  position: absolute;
  border: 1px solid rgba(173, 132, 48, .38);
  border-radius: 50%;
}

.orbit-one {
  inset: 8%;
  border-style: dashed;
  animation: lottery-orbit 22s linear infinite;
}

.orbit-two {
  inset: 24%;
  border-color: rgba(80, 116, 81, .33);
  animation: lottery-orbit 15s linear infinite reverse;
}

.lottery-selected-egg {
  z-index: 2;
  width: 62px;
  height: 76px;
  display: grid;
  place-content: center;
  gap: 1px;
  border: 1px solid rgba(134, 100, 37, .36);
  border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%;
  text-align: center;
  background:
    radial-gradient(circle at 37% 25%, rgba(255,255,255,.94), transparent 20%),
    linear-gradient(150deg, rgba(255,249,220,.94), rgba(232,213,154,.94));
  box-shadow:
    0 0 0 5px rgba(255, 247, 205, .28),
    inset -7px -8px 13px rgba(132, 92, 25, .12),
    0 9px 20px rgba(66, 60, 35, .18);
  animation: lottery-egg-float 3.6s ease-in-out infinite;
}

.lottery-selected-egg small {
  color: #8a6c2d;
  font-size: .54rem;
}

.lottery-selected-egg strong {
  color: #315440;
  font: 700 1.8rem/1 Georgia, serif;
}

.lottery-mote {
  --angle: calc(var(--mote) * 30deg);
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d5aa48;
  box-shadow: 0 0 8px rgba(213, 170, 72, .7);
  transform: rotate(var(--angle)) translateY(calc(min(76vw, 292px) * -.46));
  animation: lottery-mote 2.5s ease-in-out calc(var(--mote) * -120ms) infinite;
}

.lottery-instruction {
  display: grid;
  gap: 2px;
  margin: 1px 0 10px;
  text-align: center;
}

.lottery-instruction strong {
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
  font-size: .9rem;
}

.lottery-instruction span {
  color: #6d7463;
  font-size: .64rem;
}

.lottery-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.lottery-grid button,
.lottery-draw b {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(99, 124, 86, .35);
  border-radius: 50% 50% 46% 46% / 57% 57% 43% 43%;
  color: #315944;
  background: rgba(255, 253, 235, .76);
  box-shadow: inset -2px -3px 5px rgba(95, 90, 47, .08), 0 2px 5px rgba(59, 70, 46, .08);
  font: 700 .68rem/1 Georgia, serif;
}

.lottery-grid button.selected {
  border-color: #b88628;
  color: #fff;
  background: linear-gradient(145deg, #d8ad4e, #af7824);
  box-shadow: 0 0 0 3px rgba(216, 173, 78, .22), 0 5px 12px rgba(104, 73, 25, .22);
  transform: translateY(-2px);
}

.lottery-grid button.is-pulsing {
  animation: lottery-select .48s ease-out;
}

.lottery-draw {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
  margin: 8px 0 13px;
}

.lottery-draw b.first {
  border-color: #b78325;
  color: #fff;
  background: #c99838;
}

.lottery-result {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid rgba(79, 105, 74, .16);
  border-radius: 5px 13px 6px 11px;
  background: rgba(127, 151, 111, .1);
}

.lottery-result strong {
  font-family: "Noto Serif SC", "Songti SC", STSong, serif;
}

.lottery-result span,
.lottery-claimed {
  color: #69705e;
  font-size: .7rem;
}

.lottery-result.is-hit {
  background: rgba(211, 170, 72, .13);
}

.lottery-claim {
  width: 100%;
  min-height: 44px;
  margin-top: 11px;
  border: 0;
  border-radius: 4px 13px 5px 11px;
  color: #fff;
  background: linear-gradient(180deg, #557760, #315440);
  box-shadow: inset 0 1px rgba(255,255,255,.2), 0 7px 14px rgba(38, 67, 48, .2);
  font-weight: 800;
}

.lottery-footnote {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 13px;
  padding-top: 7px;
  border-top: 1px solid rgba(92, 72, 38, .2);
  color: #82765b;
  font: .5rem/1.3 Georgia, serif;
  letter-spacing: .05em;
}

.lottery-celebration {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.lottery-celebration i {
  --index: 0;
  position: absolute;
  left: 50%;
  top: 48%;
  width: 18px;
  height: 28px;
  opacity: 0;
  border-radius: 90% 10% 80% 20%;
  background: linear-gradient(145deg, #fffdf1, #e4dcae);
}

.lottery-celebration i:nth-child(3n) { background: #d6ab45; }
.lottery-celebration i:nth-child(1) { --index: 1; }
.lottery-celebration i:nth-child(2) { --index: 2; }
.lottery-celebration i:nth-child(3) { --index: 3; }
.lottery-celebration i:nth-child(4) { --index: 4; }
.lottery-celebration i:nth-child(5) { --index: 5; }
.lottery-celebration i:nth-child(6) { --index: 6; }
.lottery-celebration i:nth-child(7) { --index: 7; }
.lottery-celebration i:nth-child(8) { --index: 8; }
.lottery-celebration i:nth-child(9) { --index: 9; }
.lottery-celebration i:nth-child(10) { --index: 10; }
.lottery-celebration i:nth-child(11) { --index: 11; }
.lottery-celebration i:nth-child(12) { --index: 12; }
.lottery-celebration i:nth-child(13) { --index: 13; }
.lottery-celebration i:nth-child(14) { --index: 14; }
.lottery-celebration i:nth-child(15) { --index: 15; }
.lottery-celebration i:nth-child(16) { --index: 16; }
.lottery-celebration i:nth-child(17) { --index: 17; }
.lottery-celebration i:nth-child(18) { --index: 18; }

.lottery-backdrop.is-celebrating .lottery-celebration i {
  animation: lottery-petal-burst 1.25s cubic-bezier(.18,.72,.2,1) calc(var(--index) * 22ms) both;
}

@keyframes lottery-orbit { to { transform: rotate(360deg); } }
@keyframes lottery-egg-float { 50% { transform: translateY(-4px) rotate(1deg); } }
@keyframes lottery-mote { 50% { opacity: .3; transform: rotate(var(--angle)) translateY(-84px) scale(.65); } }
@keyframes lottery-select { 50% { transform: translateY(-5px) scale(1.16); } }
@keyframes lottery-petal-burst {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(0) translateY(0) scale(.2); }
  18% { opacity: .95; }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(calc(var(--index) * 55deg)) translateY(-220px) scale(.8); }
}

@media (max-height: 720px) {
  .lottery-ritual { width: 174px; height: 174px; margin-block: 6px; }
  .lottery-selected-egg { width: 54px; height: 66px; }
  .orbit-one { inset: 4px; }
  .orbit-two { inset: 17px; }
  .lottery-mote { transform: rotate(var(--angle)) translateY(-55px); }
}

@media (prefers-reduced-motion: reduce) {
  .lottery-orbit,
  .lottery-selected-egg,
  .lottery-mote,
  .lottery-grid button,
  .lottery-celebration i {
    animation: none !important;
  }
}
