
.app {
  --machine-accent: #69d9ff;
  --machine-accent-2: #e46cff;
}

.cell.orb.amber, #tower .meter.amber {
  --nebula-gem-art: url("../art/nebula-empress/gems/amber.webp");
}
.cell.orb.sapphire, #tower .meter.sapphire {
  --nebula-gem-art: url("../art/nebula-empress/gems/sapphire.webp");
}
.cell.orb.jade, #tower .meter.jade {
  --nebula-gem-art: url("../art/nebula-empress/gems/jade.webp");
}
.cell.orb.ruby, #tower .meter.ruby {
  --nebula-gem-art: url("../art/nebula-empress/gems/ruby.webp");
}
.cell.orb {
  background: none;
  color: var(--text);
  font-size: max(.7rem, calc(var(--cell) * .27));
  text-shadow: -1px -1px 0 var(--bg-deep), 1px -1px 0 var(--bg-deep),
    -1px 1px 0 var(--bg-deep), 1px 1px 0 var(--bg-deep), 0 2px 2px var(--bg-deep);
}
.cell.orb::before {
  inset: 0;
  border: 0;
  clip-path: none;
  background: var(--nebula-gem-art) center / contain no-repeat;
}
.cell.orb::after { content: none; }
.cell.orb .orb-label {
  max-width: 94%;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  text-shadow: inherit;
}
.cell.orb.jp, .paytable .cell.orb { color: var(--text); }
.cell.orb.jp-grand, #tower .slot.filled.jp-grand { color: var(--jp-grand); }
.cell.orb.jp-major, #tower .slot.filled.jp-major { color: var(--jp-major); }
.cell.orb.jp-minor, #tower .slot.filled.jp-minor { color: var(--jp-minor); }
.cell.orb.jp-mini, #tower .slot.filled.jp-mini { color: var(--jp-mini); }
#tower .slot.filled {
  flex: none;
  border-color: transparent;
  background: var(--nebula-gem-art) center / contain no-repeat;
  background-origin: border-box;
  background-clip: border-box;
  box-shadow: none;
  color: var(--text);
  line-height: 1;
  text-align: center;
  text-shadow: -1px -1px 0 var(--bg-deep), 1px -1px 0 var(--bg-deep),
    -1px 1px 0 var(--bg-deep), 1px 1px 0 var(--bg-deep), 0 1px 2px var(--bg-deep);
}
#tower .tower-slot-label {
  flex: none;
  white-space: nowrap;
}
#tower .meters { margin-inline: 20px; }

.paytable .pt-gem-prizes .pt-row {
  grid-template-columns: minmax(80px, 30%) minmax(0, 1fr);
  column-gap: 12px;
}
.paytable .pt-gem-prizes .pt-gem { width: 100%; }
.paytable .pt-gem-prizes .cell.orb {
  width: 100%;
  height: auto;
  min-height: 60px;
  padding: 42px 0 2px;
  text-align: center;
  overflow-wrap: anywhere;
  line-height: 1.15;
}
.paytable .pt-gem-prizes .cell.orb::before {
  inset: 0 auto auto 50%;
  width: 40px;
  height: 40px;
  transform: translateX(-50%);
}

.nebula-tower-halo {
  position: absolute;
  inset: -5px;
  z-index: 6;
  border: 3px solid var(--gold-light);
  border-radius: 6px;
  box-shadow: 0 0 12px var(--gold), inset 0 0 8px var(--gold);
  opacity: 0;
  pointer-events: none;
}
#app[data-nebula-tower-phase] .nebula-tower-halo { opacity: .75; }
#app[data-nebula-tower-phase="reels"] .nebula-tower-halo {
  animation: nebula-tower-surround 620ms ease-in-out infinite alternate;
}

#tower .slot { position: relative; }
#tower .slot::after {
  content: "";
  position: absolute;
  inset: -3px auto auto 50%;
  height: calc(100% + 6px);
  width: auto;
  aspect-ratio: 1;
  translate: -50% 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--text) 30%, var(--gold-light) 68%, transparent 74%);
  box-shadow: 0 0 8px var(--gold-light);
  opacity: 0;
  pointer-events: none;
}
#tower .slot.near:not(.filled)::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--gold-light);
  box-shadow: 0 0 10px var(--gold-light), 0 0 14px var(--c), inset 0 0 8px var(--gold-light);
  pointer-events: none;
  animation: nebula-slot-near 900ms ease-in-out infinite alternate;
}
#app[data-nebula-tower-phase="reset"] #tower .slot.near:not(.filled)::before {
  animation: none;
  opacity: 0;
}
#app[data-nebula-tower-phase="reset"] #tower .slot::after {
  animation: nebula-tower-reset 700ms ease-out both;
}
#app[data-nebula-tower-phase="reset"] .meters.fizzle .slot.filled {
  animation: none;
}
@keyframes nebula-slot-near {
  from { opacity: 0.35; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1.08); }
}
#app[data-nebula-tower-phase="reset"] #tower .meters.fizzle .slot::after {
  animation-duration: 350ms;
}
@keyframes nebula-tower-surround {
  from { opacity: .45; }
  to { opacity: 1; }
}
@keyframes nebula-tower-reset {
  0% { opacity: 1; transform: scale(1); }
  25% { opacity: .98; transform: scale(1.05); }
  70% { opacity: .94; transform: scale(1.02); }
  100% { opacity: 0; transform: scale(1); }
}
body.scene-motion-paused .nebula-tower-halo,
body.destination-active .nebula-tower-halo,
body.scene-motion-paused #tower .slot::after,
body.scene-motion-paused #tower .slot.near:not(.filled)::before,
body.destination-active #tower .slot.near:not(.filled)::before,
#app.nebula-entry-active #tower .slot.near:not(.filled)::before {
  animation-play-state: paused;
}
@media (prefers-reduced-motion: reduce) {
  #app[data-nebula-tower-phase="reels"] .nebula-tower-halo { animation: none; }
  #tower .slot.near:not(.filled)::before {
    animation: none;
    opacity: 0.85;
    transform: none;
  }
  #app[data-nebula-tower-phase="reset"] #tower .slot::after {
    animation: none;
    opacity: .65;
  }
}

:where(#deal, .nebula-entry, #app.nebula-entry-active) {
  --nebula-entry-glass: #351258;
  --nebula-entry-lit: #752ab2;
  --nebula-entry-shade: #120822;
  --nebula-entry-veil: #080413;
  --nebula-entry-halo: rgba(239, 52, 201, 0.28);
  --nebula-entry-dim: rgba(8, 4, 19, 0.78);
}

#app .tower-base:has(.chests.nebula-ready) .tower-sign-fill {
  animation: none;
  opacity: 0;
}
#app .tower-base:has(.chests.nebula-ready) .chest-text {
  animation: none;
  opacity: 1;
  color: var(--gold-light);
}
#app .chests.nebula-ready {
  animation: nebula-bank-ready 520ms ease-out both;
}

#deal-intro.nebula-entry {
  z-index: 50;
  display: block;
  background: none;
  opacity: 0;
  isolation: isolate;
}
#deal-intro.nebula-entry.show {
  animation: none;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
#deal-intro.nebula-entry::before {
  content: "";
  position: absolute;
  left: var(--nebula-stage-left, 0px);
  top: var(--nebula-stage-top, 0px);
  width: var(--nebula-stage-width, 100vw);
  height: var(--nebula-stage-height, 100vh);
  background: radial-gradient(ellipse at 50% 45%, var(--nebula-entry-halo), var(--nebula-entry-dim) 75%);
  opacity: 0;
  pointer-events: none;
}
#deal-intro.nebula-entry[data-entry-phase="announce"]::before {
  opacity: 1;
  animation: nebula-entry-dim var(--nebula-rise-ms, 425ms) ease-out both;
}

#deal-intro.nebula-entry .intro-dragon {
  position: absolute;
  left: calc(var(--nebula-stage-left, 0px) + var(--nebula-stage-width, 100vw) / 2);
  top: calc(var(--nebula-stage-top, 0px) + var(--nebula-stage-height, 100vh) / 2 - 24px);
  width: min(calc(var(--nebula-stage-width, 100vw) * .82), calc((var(--nebula-stage-height, 100vh) - 108px) * .8), 300px);
  max-width: calc(100vw - 36px);
  transform: translate(-50%, -50%);
  transform-origin: 50% 80%;
  visibility: hidden;
  pointer-events: none;
}
#deal-intro.nebula-entry.show .intro-dragon { animation: none; }
#deal-intro.nebula-entry[data-entry-phase="announce"] .intro-dragon {
  visibility: visible;
  animation: nebula-collector-rise var(--nebula-rise-ms, 425ms) cubic-bezier(.16, .75, .24, 1) both;
}
#deal-intro.nebula-entry .intro-dragon-art {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1.04;
  padding: 3px;
  margin: 0 0 -4px;
  filter: none;
  background: var(--gold-bevel);
  clip-path: polygon(19% 0, 81% 0, 96% 13%, 100% 32%, 100% 86%, 88% 100%, 12% 100%, 0 86%, 0 32%, 4% 13%);
}
#deal-intro.nebula-entry .intro-dragon-art .empress-crop {
  position: absolute;
  inset: 3px;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  clip-path: polygon(19% 0, 81% 0, 96% 13%, 100% 32%, 100% 86%, 88% 100%, 12% 100%, 0 86%, 0 32%, 4% 13%);
}
#deal-intro.nebula-entry .intro-dragon-art::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: linear-gradient(180deg, transparent 65%, var(--nebula-entry-shade));
  pointer-events: none;
}
#deal-intro.nebula-entry .intro-sign {
  width: min(calc(var(--nebula-stage-width, 100vw) * .84), 324px);
  min-height: 74px;
  gap: 4px;
  padding: 12px 10px 10px;
  border: 3px solid var(--gold);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .14), transparent 35%),
    linear-gradient(180deg, var(--nebula-entry-glass), var(--nebula-entry-shade));
  box-shadow: 0 0 0 2px var(--gold-deep), inset 0 -3px 0 var(--gold-dark), 0 8px 24px rgba(0, 0, 0, .65), 0 0 24px var(--nebula-entry-halo);
}
#deal-intro.nebula-entry .intro-sign::before,
#deal-intro.nebula-entry .intro-sign::after {
  top: -8px;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: var(--gold-bevel);
  transform: rotate(45deg);
  box-shadow: 0 2px 3px rgba(0, 0, 0, .5);
}
#deal-intro.nebula-entry .intro-sign::before { left: 10px; }
#deal-intro.nebula-entry .intro-sign::after { right: 10px; }
#deal-intro.nebula-entry .intro-sign-title {
  font-family: var(--display);
  font-weight: normal;
  font-size: clamp(22px, 6.8vw, 30px);
  line-height: 1;
  letter-spacing: .025em;
  white-space: nowrap;
  background-image: var(--gold-bevel);
  filter: drop-shadow(0 2px 0 var(--gold-deep));
}
#deal-intro.nebula-entry .intro-sign-text {
  color: var(--text);
  font-family: var(--display);
  font-size: clamp(15px, 4.6vw, 19px);
  line-height: 1.25;
  letter-spacing: .055em;
  text-shadow: 0 1px 0 var(--bg-deep);
}
#nebula-entry-skip {
  position: absolute;
  z-index: 2;
  left: calc(var(--nebula-stage-left, 0px) + var(--nebula-stage-width, 100vw) - 76px);
  top: calc(var(--nebula-stage-top, 0px) + var(--nebula-stage-height, 100vh) - 52px);
  width: 64px;
  min-height: 44px;
  padding: 6px 8px;
  border: 2px solid var(--gold-dark);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--nebula-entry-glass), var(--nebula-entry-shade));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 3px 0 rgba(0, 0, 0, .75);
  color: var(--text);
  font-family: var(--display);
  font-weight: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: .08em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .8);
  touch-action: manipulation;
  pointer-events: auto;
}
#nebula-entry-skip:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 3px; }
#nebula-entry-skip[data-quiet-focus]:focus-visible,
.deal-chest[data-quiet-focus]:focus-visible { outline: none; }
#nebula-entry-skip:active { transform: translateY(2px); }

#deal-intro[data-entry-phase="opening"] #nebula-entry-skip,
#deal-intro[data-entry-phase="available"] #nebula-entry-skip {
  left: calc(50% - 32px);
  top: auto;
  bottom: max(12px, calc(var(--safe-bottom) + 2px));
}

#deal-doors.nebula-entry {
  display: block;
  isolation: isolate;
  overflow: hidden;
  pointer-events: none;
}
#deal-doors.nebula-entry::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--nebula-entry-veil);
  opacity: 0;
  pointer-events: none;
}
#deal-doors.nebula-entry[data-entry-mask="true"]::before { opacity: 1; }
#deal-doors.nebula-entry.opening[data-entry-mask="true"]::before {
  clip-path: polygon(evenodd,
    0 0, 100% 0, 100% 100%, 0 100%, 0 0,
    var(--nebula-stage-left, 0px) var(--nebula-stage-top, 0px),
    var(--nebula-stage-left, 0px) calc(var(--nebula-stage-top, 0px) + var(--nebula-stage-height, 100vh)),
    calc(var(--nebula-stage-left, 0px) + var(--nebula-stage-width, 100vw)) calc(var(--nebula-stage-top, 0px) + var(--nebula-stage-height, 100vh)),
    calc(var(--nebula-stage-left, 0px) + var(--nebula-stage-width, 100vw)) var(--nebula-stage-top, 0px),
    var(--nebula-stage-left, 0px) var(--nebula-stage-top, 0px));
}
#deal-doors.nebula-entry .door {
  position: absolute;
  top: var(--nebula-stage-top, 0px);
  width: calc(var(--nebula-stage-width, 100vw) / 2 + 1px);
  height: var(--nebula-stage-height, 100vh);
  background: var(--nebula-entry-shade) url("../art/nebula-empress/vault-doors.webp") no-repeat;
  background-size: var(--nebula-stage-width, 100vw) var(--nebula-stage-height, 100vh);
  pointer-events: none;
}
#deal-doors.nebula-entry .door.left {
  left: var(--nebula-stage-left, 0px);
  background-position: 0 0;
}
#deal-doors.nebula-entry .door.right {
  left: calc(var(--nebula-stage-left, 0px) + var(--nebula-stage-width, 100vw) / 2);
  background-position: calc(0px - var(--nebula-stage-width, 100vw) / 2) 0;
}
#deal-doors.nebula-entry.closed .door {
  animation: nebula-shutter-close var(--nebula-close-ms, 350ms) cubic-bezier(.5, 0, .8, 1) both;
}
#deal-doors.nebula-entry.opening .door {
  animation: nebula-shutter-open var(--nebula-open-ms, 600ms) cubic-bezier(.3, 0, .5, 1) both;
}
#deal-doors.nebula-entry::after {
  content: "";
  position: absolute;
  top: var(--nebula-stage-top, 0px);
  left: var(--nebula-stage-left, 0px);
  width: var(--nebula-stage-width, 100vw);
  height: var(--nebula-stage-height, 100vh);
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 242, 175, .8), rgba(255, 212, 90, .22) 35%, transparent 74%);
  opacity: 0;
  pointer-events: none;
}
#deal-doors.nebula-entry.closed::after {
  animation: nebula-seam-light var(--nebula-close-ms, 350ms) var(--nebula-close-ms, 350ms) ease-out both;
}

#deal .deal-scroll {
  gap: 2px;
  padding: 14px 28px 12px;
  border: 3px solid var(--gold);
  border-left-width: 6px;
  border-right-width: 6px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .12), transparent 32%),
    linear-gradient(180deg, var(--nebula-entry-glass), var(--nebula-entry-shade));
  box-shadow: 0 0 0 2px var(--gold-deep), inset 0 -3px 0 var(--gold-dark), 0 10px 30px rgba(0, 0, 0, .7);
}
#deal.intro .deal-scroll { animation-name: nebula-board-arrival; }
#deal.intro .deal-prompt { visibility: hidden; }
#deal .deal-scroll-count,
#deal .deal-scroll-text {
  color: var(--text);
  font-family: var(--display);
  font-weight: normal;
  background: none;
  filter: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .85);
}
#deal .deal-scroll-count { color: var(--gold-light); font-size: 44px; }
#deal .deal-scroll-count strong { font-weight: normal; }
#deal .deal-scroll-text { font-size: 28px; letter-spacing: .08em; }

@keyframes nebula-bank-ready {
  0%, 100% { opacity: 1; }
  40% { opacity: .7; }
}
@keyframes nebula-entry-dim { from { opacity: 0; } to { opacity: 1; } }
@keyframes nebula-collector-rise {
  from { transform: translate(-50%, -32%) scale(.3); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
@keyframes nebula-shutter-close {
  from { transform: translateX(var(--open)); }
  to { transform: translateX(0); }
}
@keyframes nebula-shutter-open {
  from { transform: translateX(0); }
  to { transform: translateX(var(--open)); }
}
@keyframes nebula-seam-light {
  0%, 100% { opacity: 0; }
  22% { opacity: 1; }
}
@keyframes nebula-board-arrival {
  0% { transform: translate(-50%, -50%) scale(.85); opacity: 0; }
  12%, 86% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

#app.nebula-entry-active .machine-scene-motion,
#app.nebula-entry-active [data-parallax],
#app.nebula-entry-active .reel-shine,
#app.nebula-entry-active .spin-count.hot,
#app.nebula-entry-active .spin-count.hot::before,
#app.nebula-entry-active .tower-sign-fill,
#app.nebula-entry-active .chest-text {
  animation-play-state: paused;
}
body.scene-motion-paused #deal-intro.nebula-entry .intro-dragon,
body.scene-motion-paused #deal-intro.nebula-entry::before,
body.scene-motion-paused #deal-doors.nebula-entry .door,
body.scene-motion-paused #deal-doors.nebula-entry::after,
body.scene-motion-paused #app .chests.nebula-ready,
body.scene-motion-paused #deal.intro .deal-scroll {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  #app .chests.nebula-ready,
  #deal-intro.nebula-entry[data-entry-phase="announce"]::before,
  #deal-intro.nebula-entry[data-entry-phase="announce"] .intro-dragon,
  #deal-doors.nebula-entry.closed .door,
  #deal-doors.nebula-entry.opening .door,
  #deal-doors.nebula-entry.closed::after,
  #deal.intro .deal-scroll { animation: none; }
  #deal-intro.nebula-entry .intro-dragon { transform: translate(-50%, -50%); }
  #deal-doors.nebula-entry.closed .door { transform: translateX(0); }
  #deal-doors.nebula-entry.opening .door { transform: translateX(var(--open)); }
  #deal-doors.nebula-entry.closed::after { opacity: 0; }
  #deal.intro .deal-scroll { transform: translate(-50%, -50%); opacity: 1; }
}
