/* Loot event overlay — stage-sized (--gs-*); no in-stage scroll. */

.loot-event-overlay {
  position: absolute;
  inset: 0;
  z-index: 42;
  display: none;
  background: rgba(6, 3, 10, 0.82);
  backdrop-filter: blur(2px);
}
.loot-event-overlay[data-open="1"] {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--gs-u-h) * 1.2);
  box-sizing: border-box;
}
/* Reveal/exit phase: pass clicks through tiles (disabled buttons swallow them) so
   "click anywhere" hits the overlay and dismisses. */
.loot-event-overlay[data-reveal="1"] {
  cursor: pointer;
}
.loot-event-overlay[data-reveal="1"] .loot-event-overlay__board-host,
.loot-event-overlay[data-reveal="1"] .loot-event-overlay__board {
  overflow: visible;
}
.loot-event-overlay[data-reveal="1"] .loot-event-overlay__panel,
.loot-event-overlay[data-reveal="1"] .loot-event-overlay__panel * {
  pointer-events: none;
}
.loot-event-overlay [hidden] {
  display: none !important;
}
.loot-event-overlay__panel {
  position: relative;
  box-sizing: border-box;
  width: min(100%, calc(var(--gs-u-w) * 90));
  max-height: min(100%, calc(var(--gs-u-h) * 92));
  padding: calc(var(--gs-u-h) * 1.1);
  display: flex;
  flex-direction: column;
  /* Ornate corners overhang; clip inner body instead. */
  overflow: visible;
}

.loot-event-overlay__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: calc(var(--gs-u-h) * 0.45);
  overflow: hidden;
}
.loot-event-overlay__controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: calc(var(--gs-u-h) * 0.4) calc(var(--gs-u-w) * 0.6);
  color: var(--gs-text-muted);
  font-size: var(--gs-text-xs);
  margin: 0;
}
.loot-event-overlay__counter {
  display: inline-flex;
  align-items: center;
  border: var(--gs-hairline) solid var(--gs-border-gold-soft);
  border-radius: var(--gs-radius-sm);
  padding: calc(var(--gs-u-h) * 0.34) calc(var(--gs-u-w) * 0.65);
  background: rgba(14, 9, 22, 0.82);
}
.loot-event-overlay__main {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, calc(var(--gs-u-w) * 18));
  gap: calc(var(--gs-u-w) * 0.7);
  align-items: stretch;
  justify-items: center;
}
.loot-event-overlay__main:has(> .loot-event-overlay__specials[hidden]) {
  grid-template-columns: minmax(0, 1fr);
}
.loot-event-overlay__board-host {
  min-width: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loot-event-overlay__board {
  --loot-grid-cols: 10;
  --loot-grid-rows: 6;
  --loot-board-gap: calc(var(--gs-u-h) * 0.35);
  /* Height budget leaves room for controls + panel padding inside the stage. */
  --loot-board-max-h: calc(var(--gs-u-h) * 78);
  display: grid;
  grid-template-columns: repeat(var(--loot-grid-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--loot-grid-rows), minmax(0, 1fr));
  gap: var(--loot-board-gap);
  /* Tile aspect 5∶7 → board aspect ≈ (cols×5)∶(rows×7). */
  aspect-ratio: calc(var(--loot-grid-cols) * 5) / calc(var(--loot-grid-rows) * 7);
  /* Fit both axes from shell units — no px floors, no in-stage scroll. */
  width: min(
    100%,
    calc(var(--gs-u-w) * 68),
    calc(
      var(--loot-board-max-h) * (var(--loot-grid-cols) * 5) /
        (var(--loot-grid-rows) * 7)
    )
  );
  max-height: var(--loot-board-max-h);
  height: auto;
}
.loot-event-overlay__specials {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: calc(var(--gs-u-h) * 0.35);
  border: var(--gs-hairline) solid var(--gs-border-gold-bright-soft);
  border-radius: var(--gs-radius-md);
  background: rgba(14, 9, 22, 0.85);
  padding: calc(var(--gs-u-h) * 0.5);
  overflow: hidden;
}
.loot-event-overlay__specials h3 {
  flex: 0 0 auto;
  margin: 0;
  font-size: var(--gs-text-xs);
  color: var(--gs-text-label);
}
.loot-event-overlay__specials ul {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: calc(var(--gs-u-h) * 0.4);
  overflow: hidden;
}
.loot-event-overlay__special-tile {
  display: grid;
  gap: calc(var(--gs-u-h) * 0.25);
  border: var(--gs-hairline) solid rgba(218, 172, 96, 0.5);
  border-radius: var(--gs-radius-md);
  padding: calc(var(--gs-u-h) * 0.28);
  background:
    radial-gradient(90% 90% at 50% 10%, rgba(255, 205, 126, 0.12), transparent 70%),
    linear-gradient(180deg, rgba(32, 18, 12, 0.66), rgba(18, 11, 22, 0.92));
  box-shadow:
    0 calc(var(--gs-u-h) * 0.4) calc(var(--gs-u-h) * 1.1) rgba(0, 0, 0, 0.35),
    inset 0 0 0 var(--gs-hairline) rgba(255, 215, 156, 0.08);
  min-width: 0;
}
.loot-event-overlay__catalog-tile {
  display: grid;
  gap: calc(var(--gs-u-h) * 0.25);
  border: var(--gs-hairline) solid rgba(90, 70, 110, 0.35);
  border-radius: var(--gs-radius-md);
  padding: calc(var(--gs-u-h) * 0.28);
  background: rgba(18, 12, 28, 0.86);
  min-width: 0;
}
.loot-event-overlay__special-figure {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 5 / 7;
  min-height: 0;
  overflow: hidden;
}
.loot-event-overlay__special-art {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--gs-radius-xs);
  border: var(--gs-hairline) solid rgba(235, 190, 114, 0.55);
  background: rgba(10, 6, 16, 0.85);
}
.loot-event-overlay__special-qty {
  position: absolute;
  right: calc(var(--gs-u-w) * 0.2);
  bottom: calc(var(--gs-u-h) * 0.2);
  z-index: 1;
  font-size: var(--gs-text-2xs);
  color: #fff2d8;
  border: var(--gs-hairline) solid rgba(255, 218, 156, 0.45);
  border-radius: var(--gs-radius-lg);
  padding: calc(var(--gs-u-h) * 0.08) calc(var(--gs-u-w) * 0.35);
  background: rgba(25, 13, 31, 0.92);
  box-shadow: 0 calc(var(--gs-u-h) * 0.15) calc(var(--gs-u-h) * 0.4) rgba(0, 0, 0, 0.35);
}
.loot-event-overlay__card-render {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  --game-card-width: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.loot-event-overlay__card-render .game-card-sizing:not(.game-card-sizing--dialog) {
  width: 100% !important;
  max-width: 100%;
  max-height: 100%;
  height: auto;
}
.loot-event-overlay__tile .loot-event-overlay__card-render,
.loot-event-overlay__special-figure .loot-event-overlay__card-render {
  max-width: 100%;
}
.loot-event-overlay__tile .armory-equip__tile-wrap,
.loot-event-overlay__special-figure .armory-equip__tile-wrap {
  width: 72%;
  max-width: 100%;
  max-height: 100%;
}
.loot-event-overlay__tile .armory-equip__tile-icon,
.loot-event-overlay__special-figure .armory-equip__tile-icon {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  object-fit: contain;
}
.loot-event-overlay__cell {
  border: var(--gs-hairline) solid transparent;
  border-radius: var(--gs-radius-sm);
  background: rgba(18, 12, 28, 0.86);
  color: var(--gs-text-body);
  min-height: 0;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: calc(var(--gs-u-h) * 0.2);
  cursor: pointer;
  text-align: center;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.loot-event-overlay__cell[disabled] {
  cursor: default;
  opacity: 0.88;
}
.loot-event-overlay__cell--hidden {
  background: rgba(12, 8, 18, 0.9);
}
.loot-event-overlay__cell--picked {
  border-color: rgba(230, 185, 110, 0.7);
  box-shadow: 0 0 0 var(--gs-hairline) rgba(255, 223, 164, 0.28);
}
/* Unpicked faces: ash-dissolve (combat death language), then empty slot. */
.loot-event-overlay__cell--ash-death {
  pointer-events: none;
  overflow: visible;
  z-index: 3;
  border-color: transparent;
  background: transparent;
}
.loot-event-overlay__cell--ash-death .loot-event-overlay__tile {
  overflow: visible;
  animation: loot-miss-ash-death 900ms cubic-bezier(0.33, 0, 0.55, 1) forwards;
  transform-origin: center bottom;
}
.loot-event-overlay__cell--dissolved {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}
.loot-event-overlay__cell--gathering {
  z-index: 5;
  transition: transform 720ms cubic-bezier(0.22, 0.82, 0.28, 1);
  transform: translate3d(var(--loot-gather-x, 0px), var(--loot-gather-y, 0px), 0);
  will-change: transform;
}
@media (prefers-reduced-motion: reduce) {
  .loot-event-overlay__cell--gathering {
    transition: none;
  }
}
.loot-event-overlay__death-ash {
  position: absolute;
  inset: -24% -14% -14% -14%;
  z-index: 6;
  pointer-events: none;
  overflow: visible;
}
.loot-event-overlay__death-ash--west {
  inset: -24% -14% -14% -36%;
}
.loot-event-overlay__death-ash--east {
  inset: -24% -36% -14% -14%;
}
.loot-event-overlay__death-ash-fleck {
  position: absolute;
  width: var(--ash-size, 3px);
  height: calc(var(--ash-size, 3px) * 0.72);
  margin: 0;
  border-radius: 40% 60% 55% 45%;
  background: radial-gradient(
    ellipse at 40% 35%,
    rgba(196, 184, 168, 0.95) 0%,
    rgba(120, 110, 98, 0.85) 55%,
    rgba(72, 66, 58, 0.55) 100%
  );
  box-shadow: 0 0 1px rgba(40, 36, 32, 0.35);
  animation: loot-miss-death-ash 860ms cubic-bezier(0.2, 0.55, 0.35, 1) forwards;
  animation-delay: var(--ash-delay, 0ms);
  transform-origin: center center;
  opacity: 0;
}
@keyframes loot-miss-death-ash {
  0% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg) scale(0.55);
  }
  12% {
    opacity: 0.9;
    transform: translate(calc(var(--ash-x, 36px) * 0.08), calc(var(--ash-y, -12px) * 0.1))
      rotate(calc(var(--ash-rot, 12deg) * 0.15)) scale(1);
  }
  55% {
    opacity: 0.65;
    transform: translate(
        calc(var(--ash-x, 36px) * 0.55),
        calc(var(--ash-y, -12px) * 0.55 + var(--ash-drift, 0px))
      )
      rotate(calc(var(--ash-rot, 12deg) * 0.6)) scale(0.85);
  }
  100% {
    opacity: 0;
    transform: translate(var(--ash-x, 36px), calc(var(--ash-y, -12px) + var(--ash-drift, 0px)))
      rotate(var(--ash-rot, 12deg)) scale(0.25);
  }
}
@keyframes loot-miss-ash-death {
  0% {
    opacity: 1;
    filter: grayscale(0) sepia(0) brightness(1) blur(0);
    transform: translate(0, 0) scale(1);
  }
  28% {
    opacity: 0.88;
    filter: grayscale(0.45) sepia(0.25) brightness(0.92) contrast(1.05) blur(0.3px);
    transform: translate(0, -3%) scale(1);
  }
  62% {
    opacity: 0.4;
    filter: grayscale(0.85) sepia(0.35) brightness(0.7) contrast(0.95) blur(1px);
    transform: translate(calc(3% * var(--ash-wind-sign, 1)), -6%) scale(0.97);
  }
  100% {
    opacity: 0;
    filter: grayscale(1) sepia(0.4) brightness(0.55) blur(2px);
    transform: translate(calc(6% * var(--ash-wind-sign, 1)), -8%) scale(0.94);
  }
}
@media (prefers-reduced-motion: reduce) {
  .loot-event-overlay__cell--ash-death .loot-event-overlay__tile {
    animation: none;
    opacity: 0;
  }
  .loot-event-overlay__death-ash-fleck {
    animation: none;
    opacity: 0;
  }
}
.loot-event-overlay__tile {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.loot-event-overlay__tile-art {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  border-radius: var(--gs-radius-xs);
  border: none;
  background: rgba(10, 6, 16, 0.85);
}
.loot-event-overlay__tile--revealed .loot-event-overlay__tile-art {
  box-shadow: 0 calc(var(--gs-u-h) * 0.7) calc(var(--gs-u-h) * 1.5) rgba(0, 0, 0, 0.42);
}
.loot-event-overlay__tile-qty {
  position: absolute;
  right: calc(var(--gs-u-w) * 0.15);
  bottom: calc(var(--gs-u-h) * 0.15);
  z-index: 1;
  font-size: var(--gs-text-2xs);
  color: #ecd7ae;
  border: var(--gs-hairline) solid rgba(255, 218, 156, 0.35);
  border-radius: var(--gs-radius-lg);
  padding: calc(var(--gs-u-h) * 0.06) calc(var(--gs-u-w) * 0.3);
  background: rgba(25, 13, 31, 0.88);
}
.loot-event-overlay__premium-toggle {
  display: inline-flex;
  align-items: center;
  gap: calc(var(--gs-u-w) * 0.35);
  flex-wrap: wrap;
  padding: calc(var(--gs-u-h) * 0.34) calc(var(--gs-u-w) * 0.65);
  border-radius: var(--gs-radius-sm);
  border: var(--gs-hairline) solid var(--gs-border-gold-soft);
  background: rgba(14, 9, 22, 0.82);
  color: #e9d6b4;
  font-size: var(--gs-text-xs);
}
.loot-event-overlay__premium-cost {
  font-size: 0.92em;
  color: #f0e6d0;
}
.loot-event-overlay__premium-toggle--disabled {
  opacity: 0.7;
}
.loot-event-overlay__status {
  flex: 0 0 auto;
  margin: 0;
  min-height: calc(var(--gs-u-h) * 1.8);
  color: #ffe0be;
  font-size: var(--gs-text-xs);
}
.loot-event-overlay__exit-hint {
  margin: 0;
  color: #f1dfc0;
  font-size: var(--gs-text-xs);
  padding: calc(var(--gs-u-h) * 0.34) calc(var(--gs-u-w) * 0.2);
}
