.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.bonus-total {
  margin-left: auto;
  color: #c8e4df;
  font-size: .78rem;
  flex: none;
  white-space: nowrap;
}
.bonus-total strong { color: #ffe0a4; margin-left: .25em; font-variant-numeric: tabular-nums; }
.bonus-total strong.bump { animation: total-bump .4s ease-out; }
@keyframes total-bump {
  35% { color: #fff4c6; text-shadow: 0 0 12px #ffb65e; }
}
.tile.bonus-hit {
  z-index: 3;
  animation: scatter-glow .62s ease-out both;
}
.tile.bonus-hit .glyph { animation: scatter-rise .62s ease-out both; }
@keyframes scatter-glow {
  35%, 78% {
    border-color: #d9ff9f;
    box-shadow: inset 0 0 19px #c2f2849e, 0 0 14px #b4ef84a1;
    background: radial-gradient(ellipse at center, #658b58, #3f5947);
  }
}
@keyframes scatter-rise {
  38% { transform: translateY(-5%) scale(1.24) rotate(-8deg); filter: drop-shadow(0 0 9px #c7ff8c); }
  77% { transform: scale(1.1) rotate(3deg); }
}
.round-banner {
  background: radial-gradient(ellipse at 40% 15%, #6d5834, #352d20);
  border-color: #f0c682;
  box-shadow: 0 0 25px #e0a45b74, 0 8px 26px #120f08b8;
}

.brew-dialog {
  --brew-gold: #ffd48e;
  --brew-scene: url("./assets/maomao-midnight.webp?v=liquid");
  position: fixed;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  isolation: isolate;
}
.brew-dialog[open] { display: grid; place-items: safe center; }
.brew-dialog::backdrop {
  background: radial-gradient(ellipse at 50% 48%, #253a52be, #071019ef 76%);
  backdrop-filter: blur(5px);
  animation: brew-fade .5s ease-out both;
}
.brew-card {
  --frame-depth: 26px;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(240px, .9fr) minmax(330px, 1.1fr);
  width: min(100%, 784px);
  min-height: 427px;
  border: 1px solid #704734;
  border-radius: 7px;
  overflow: hidden;
  background: var(--lacquer);
  box-shadow: 0 6px 0 #271819, 0 0 100px #7ec8dc59, 0 19px 70px #0c0613eb;
  animation: brew-arrive .8s cubic-bezier(.16, .8, .32, 1.12) both;
}
.brew-dialog[data-kind="payout"] .brew-card {
  --brew-scene: url("./assets/maomao-payout.webp");
  box-shadow: 0 0 100px #e99d4e5c, 0 19px 70px #0c0613eb;
}
.brew-dialog[data-no-win] .brew-card {
  --brew-scene: url("./assets/maomao-no-win.webp");
}
.brew-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, #fff1bb38 48%, transparent 65%);
  animation: brew-sheen 1.4s .18s ease-out both;
}
.brew-art {
  position: relative;
  display: grid;
  align-items: end;
  justify-items: center;
  min-height: 100%;
  overflow: hidden;
  background:
    linear-gradient(0deg, #211a13 0%, #211a164f 27%, transparent 50%),
    linear-gradient(90deg, transparent 83%, #1717135c),
    var(--brew-scene) 50% 50% / cover;
}
.brew-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 42px clamp(27px, 4.4vw, 53px);
  border-left: 9px ridge #895c43;
  text-align: center;
  background:
    radial-gradient(ellipse at 51% 10%, #86644355, transparent 77%),
    var(--lacquer);
  box-shadow: inset 3px 0 #241b12;
}
.brew-eyebrow {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 0 8px;
  color: #f5c09a;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  animation: brew-lift .58s .17s ease-out both;
}
.brew-eyebrow::before, .brew-eyebrow::after {
  content: "";
  width: 6px;
  height: 6px;
  border: 1px solid #d9a26c;
  background: #966746;
  transform: rotate(45deg);
}
.brew-content h2 {
  margin: 0 0 18px;
  color: #fff0e1;
  font: 400 clamp(2rem, 5.6vw, 3rem)/1.1 var(--display);
  text-wrap: balance;
  animation: brew-lift .64s .27s ease-out both;
}
.brew-amount {
  position: relative;
  display: grid;
  gap: 5px;
  width: 100%;
  justify-items: center;
  padding: 8px 0 12px;
  border: 1px solid #b5865f;
  border-radius: 3px;
  background: radial-gradient(ellipse at center, #71513a59, transparent 75%), #292016;
  box-shadow: inset 0 0 0 3px #3e2b21, inset 0 0 0 4px #7c554850, 0 4px 0 #1f160e;
  animation: brew-lift .7s .38s ease-out both;
}
.brew-amount::before, .brew-amount::after {
  content: "";
  position: absolute;
  top: calc(50% - 3px);
  width: 6px;
  height: 6px;
  border: 1px solid #deb181;
  border-radius: 50%;
  background: #a97449;
  box-shadow: inset 0 -2px #6c4533;
}
.brew-amount::before { left: 10px; }
.brew-amount::after { right: 10px; }
.brew-amount strong {
  color: var(--brew-gold);
  font: 400 clamp(2.7rem, 6vw, 4.25rem)/1.15 var(--display);
  font-variant-numeric: lining-nums tabular-nums;
  overflow-wrap: anywhere;
  text-shadow: 0 0 32px #ffa64670;
}
.brew-amount strong.brew-total-large { font-size: clamp(2rem, 4.6vw, 3.1rem); }
.brew-amount span { color: #fff0d8; font-size: .9rem; font-weight: 700; }
.brew-dialog[data-kind="payout"] .brew-amount {
  border-color: #c58f57;
  background:
    linear-gradient(0deg, #25190f75, transparent 38%),
    radial-gradient(ellipse at 50% 46%, #7954368f, #302118 79%);
  box-shadow: inset 0 0 0 2px #402a1e, inset 0 0 0 3px #ac764e9e, 0 4px 0 #21160d;
}
.brew-dialog[data-kind="payout"] .brew-amount::before,
.brew-dialog[data-kind="payout"] .brew-amount::after {
  top: calc(50% - 7px);
  width: 14px;
  height: 14px;
  border: 0;
  box-shadow: none;
  background: url("./assets/copper-cash.webp") center / contain no-repeat;
}
.brew-dialog[data-kind="payout"] .brew-amount strong {
  font-feature-settings: "lnum" 1, "tnum" 1;
  background: linear-gradient(#fff4c2 10%, #ffe19e 45%, #d2904d 59%, #f7c880 92%);
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px #5e352c) drop-shadow(0 0 8px #f0a84b5e);
  text-shadow: none;
}
.brew-dialog[data-kind="payout"] .brew-amount span {
  color: #ffe1ae;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: .8rem;
}
.brew-amount.payout-settled { animation: payout-plaque-shine 1.35s ease-out both; }
.brew-note {
  color: #edd8c5;
  min-height: 1.5em;
  margin: 15px 0 19px;
  font-size: .93rem;
  line-height: 1.45;
  animation: brew-lift .58s .49s ease-out both;
}
.brew-action {
  min-width: min(100%, 208px);
  min-height: 46px;
  padding: 9px 25px;
  font: 400 1.06rem/1.2 var(--display);
}

.brew-seal {
  position: relative;
  width: min(75%, 226px);
  aspect-ratio: 2;
  margin-bottom: 23px;
}
.brew-orbit, .brew-flare {
  position: absolute;
  left: 50%;
  top: 53%;
  width: 70%;
  aspect-ratio: 1;
  border-radius: 50%;
}
.brew-orbit {
  border: 1px solid #eebd89a6;
  outline: 1px dashed #f9d6a790;
  outline-offset: 7px;
  background: radial-gradient(circle, #efbd6c45, #bf7bc932 54%, transparent 70%);
  box-shadow: 0 0 23px #f0a9567d, inset 0 0 13px #e6ad6b;
  animation: brew-orbit 18s linear infinite;
}
.brew-flare { background: radial-gradient(ellipse, #ffedb8ab, #eba45233 42%, transparent 68%); animation: brew-flare 1.45s .11s ease-out both; }
.brew-vial {
  position: absolute;
  top: 53%;
  left: var(--vial-left);
  width: var(--vial-size);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px #130917) drop-shadow(0 0 10px #ffaa5d75);
  animation: brew-vial-arrive .9s var(--vial-delay) cubic-bezier(.16, .78, .25, 1.23) both,
             brew-vial-float 3.9s var(--vial-float) ease-in-out infinite;
}
.vial-left { --vial-left: 22%; --vial-size: 34%; --vial-delay: .13s; --vial-float: 1.03s; }
.vial-right { --vial-left: 78%; --vial-size: 34%; --vial-delay: .23s; --vial-float: 1.13s; }
.vial-main { --vial-left: 50%; --vial-size: 50%; --vial-delay: .31s; --vial-float: 1.21s; }
.brew-dialog[data-kind="payout"] .brew-seal { display: none; }
.brew-particles { position: fixed; z-index: 0; inset: 0; pointer-events: none; }
.payout-particles { position: fixed; z-index: 6; inset: 0; pointer-events: none; overflow: hidden; }
.payout-spark {
  position: absolute;
  top: var(--burst-y);
  left: var(--burst-x);
  width: var(--size);
  aspect-ratio: 1;
  opacity: 0;
  background: #ffdfa4;
  clip-path: polygon(50% 0, 63% 38%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0 50%, 37% 38%);
}
.payout-spark:not(.payout-cash):nth-child(4n) { background: #c7f4d1; }
.payout-cash {
  clip-path: none;
  background: url("./assets/copper-cash.webp") center / contain no-repeat;
  filter: drop-shadow(0 2px 2px #241616a6);
}
.brew-particle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--size);
  aspect-ratio: 1;
  border-radius: 2px;
  color: #ffe0a6;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
  animation: brew-particle 2.7s var(--delay) cubic-bezier(.1, .44, .19, 1) both;
}
.brew-particle:nth-child(3n) { color: #b3e7dd; }
.brew-dialog[data-kind="payout"] .brew-particle:nth-child(even) {
  border: 1px solid #ffe7a4;
  border-radius: 50%;
  background: radial-gradient(#ffe8b0 18%, #ba672e 27%, #ffbe67 66%);
}

@keyframes brew-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes brew-arrive {
  from { opacity: 0; transform: translateY(23px) scale(.82); }
  to { opacity: 1; transform: none; }
}
@keyframes brew-sheen { from { transform: translateX(-105%); } to { transform: translateX(105%); } }
@keyframes brew-lift {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes brew-orbit {
  from { transform: translate(-50%,-50%) rotate(0); }
  to { transform: translate(-50%,-50%) rotate(360deg); }
}
@keyframes brew-flare {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.45); }
  35% { opacity: .85; }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(2.1); }
}
@keyframes brew-vial-arrive {
  from { opacity: 0; transform: translate(-50%, 10%) scale(.42); }
  to { opacity: 1; transform: translate(-50%,-50%); }
}
@keyframes brew-vial-float {
  0%, 100% { transform: translate(-50%,-50%); }
  50% { transform: translate(-50%,-61%); }
}
@keyframes payout-plaque-shine {
  0% { transform: none; }
  27% {
    transform: scale(1.025);
    border-color: #ffe7ac;
    box-shadow: inset 0 0 0 2px #402a26, inset 0 0 0 3px #dfaa61, 0 0 23px #f2b86975;
  }
  100% { transform: none; }
}
@keyframes brew-particle {
  0% { opacity: 0; transform: translate(-50%,-50%) rotate(0); }
  21% { opacity: .92; }
  62% { opacity: .6; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(345deg) scale(.35); }
}

@media (max-width: 680px) {
  .brew-card { --frame-depth: 16px; grid-template-columns: 1fr; width: min(100%, 440px); min-height: 0; }
  .brew-art {
    min-height: 175px;
    background:
      linear-gradient(0deg, #24181d 0%, transparent 54%),
      var(--brew-scene) 50% 42% / cover;
  }
  .brew-dialog[data-no-win] .brew-art { background-position: center, 50% 60%; }
  .brew-content { padding: 13px 22px 22px; border-left: 0; border-top: 5px ridge #86593d; }
  .brew-content h2 { margin-bottom: 11px; }
  .brew-note { margin-block: 11px 15px; }
  .brew-seal { width: 127px; justify-self: end; margin: 0 14px 14px 0; }
  .bonus-total { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; white-space: normal; }
  .round-status:has(.bonus-total:not([hidden])) p { flex: 1 0 100%; order: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .brew-dialog::backdrop, .brew-dialog[open] *, .brew-card::after, .bonus-total strong.bump,
  .tile.bonus-hit, .tile.bonus-hit .glyph { animation: none !important; }
  .brew-card::after, .brew-flare, .brew-particles, .payout-particles { display: none; }
  .brew-orbit, .brew-vial { transform: translate(-50%,-50%); }
  .tile.bonus-hit { border-color: #d9ff9f; }
}
