/* Premium animated trade-result dialog. The result is announced only after Check Trade. */
.result-pop {
  width: min(500px, calc(100% - 24px));
  max-width: 500px;
  /* Keep the whole card (plus the mascot above it) inside the viewport; scroll if it still doesn't fit. */
  max-height: calc(100vh - 16px);
  max-height: calc(100dvh - 16px);
  padding: 80px 0 4px;
  border: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  background: transparent;
  color: var(--text);
}
.result-pop::backdrop {
  background: rgba(18, 25, 62, .58);
  -webkit-backdrop-filter: blur(7px) saturate(.9);
  backdrop-filter: blur(7px) saturate(.9);
  animation: result-backdrop-in .24s ease both;
}
.result-pop[open] { animation: result-dialog-in .42s cubic-bezier(.18,.82,.28,1.08) both; }

.result-pop-inner {
  --result-accent: #6c55f5;
  --result-accent-2: #55bdf7;
  --result-soft: #f4f1ff;
  position: relative;
  isolation: isolate;
  overflow: visible;
  padding: 84px 24px 22px;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 32px;
  background:
    radial-gradient(circle at 50% 4%, color-mix(in srgb, var(--result-accent) 16%, transparent), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,.985), rgba(249,251,255,.975));
  box-shadow:
    0 30px 90px rgba(21, 32, 82, .28),
    inset 0 1px 0 rgba(255,255,255,.95);
  text-align: center;
}
.result-pop-inner::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 10px;
  border-radius: 24px;
  border: 1px solid color-mix(in srgb, var(--result-accent) 20%, #fff);
  pointer-events: none;
}
.result-pop-inner.big-win { --result-accent:#28b85f; --result-accent-2:#67d98c; --result-soft:#ecfbf2; }
.result-pop-inner.win { --result-accent:#32bb6b; --result-accent-2:#55c98d; --result-soft:#eefbf3; }
.result-pop-inner.fair { --result-accent:#e3ac19; --result-accent-2:#ffd95b; --result-soft:#fff9e8; }
.result-pop-inner.lose { --result-accent:#f26476; --result-accent-2:#ff9a77; --result-soft:#fff0f2; }
.result-pop-inner.big-lose { --result-accent:#e23f5a; --result-accent-2:#ff6b7d; --result-soft:#ffedf0; }

.result-pop-halo {
  position: absolute;
  z-index: -1;
  top: -76px;
  left: 50%;
  width: 190px;
  height: 190px;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--result-accent-2) 48%, #fff) 0 22%, color-mix(in srgb, var(--result-accent) 20%, transparent) 45%, transparent 70%);
  filter: blur(.2px);
  animation: result-halo 2.8s ease-in-out infinite;
}
.result-pop-rays {
  position: absolute;
  z-index: -2;
  top: -96px;
  left: 50%;
  width: 238px;
  height: 238px;
  transform: translateX(-50%);
  border-radius: 50%;
  opacity: .35;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--result-accent-2) 52%, transparent) 0 8deg, transparent 8deg 20deg);
  -webkit-mask-image: radial-gradient(circle, transparent 0 32%, #000 34% 67%, transparent 70%);
  mask-image: radial-gradient(circle, transparent 0 32%, #000 34% 67%, transparent 70%);
  animation: result-rays 18s linear infinite;
}
.result-pop-art-wrap {
  position: absolute;
  top: -72px;
  left: 50%;
  width: 160px;
  height: 160px;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.result-pop-art {
  width: 150px;
  height: 150px;
  object-fit: contain;
  filter: drop-shadow(0 12px 16px rgba(31, 42, 91, .18));
  transform-origin: 50% 85%;
  animation: result-mascot-arrive .55s cubic-bezier(.18,.9,.28,1.22) both .05s,
             result-mascot-float 3.2s ease-in-out .7s infinite;
}
.result-pop-inner.lose .result-pop-art,
.result-pop-inner.big-lose .result-pop-art {
  animation: result-mascot-arrive .5s cubic-bezier(.18,.9,.28,1.14) both .05s,
             result-mascot-sway 3.2s ease-in-out .7s infinite;
}

.result-pop-kicker {
  margin: 0 0 4px;
  color: var(--text-soft);
  font: 700 11px/1.2 var(--font-body);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.result-pop-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 210px;
  margin: 0 0 8px;
  padding: 10px 26px 11px;
  border: 3px solid rgba(255,255,255,.95);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--result-accent-2), var(--result-accent));
  color: #fff;
  box-shadow:
    0 10px 24px color-mix(in srgb, var(--result-accent) 28%, transparent),
    inset 0 2px 0 rgba(255,255,255,.38);
  font-family: var(--font-game);
  font-size: clamp(1.55rem, 6vw, 2.05rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: .025em;
  text-shadow: 0 2px 2px rgba(31,43,70,.18);
  animation: result-badge-pop .55s cubic-bezier(.2,.9,.26,1.28) both .18s;
}
.result-pop-inner.fair .result-pop-badge { color: #5b4200; text-shadow: 0 1px #fff8; }
.result-pop-lead {
  margin: 0 auto 15px;
  max-width: 36ch;
  color: #25305f;
  font: 700 15px/1.45 var(--font-heading);
}

.result-pop-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 13px;
  padding: 11px 4px;
  overflow: hidden;
  border: 1px solid #e3eaf7;
  border-radius: 18px;
  background: rgba(255,255,255,.88);
  box-shadow: inset 0 1px 0 #fff;
}
.result-pop-stats > div { padding: 1px 9px; min-width: 0; }
.result-pop-stats > div + div { border-left: 1px solid #e3eaf7; }
.result-pop-stats dt {
  color: #68718f;
  font: 700 11px/1.25 var(--font-body);
}
.result-pop-stats dd {
  margin: 4px 0 0;
  color: #11184d;
  font: 800 21px/1.15 var(--font-body);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.result-pop-stats dd.positive { color: #178b49; }
.result-pop-stats dd.negative { color: #ca324d; }

.result-pop-note {
  margin: 0 auto 9px;
  max-width: 39ch;
  color: #475271;
  font: 500 13px/1.6 var(--font-body);
}
.result-pop-tip {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  max-width: 39ch;
  margin: 0 auto 16px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--result-accent) 15%, #e5eaf5);
  border-radius: 15px;
  background: var(--result-soft);
  color: #3d4769;
  text-align: left;
  font: 600 12px/1.5 var(--font-body);
}
.result-pop-tip::before { content: '✦'; flex: none; color: var(--result-accent); font-size: 15px; }

.result-pop-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin: 0 0 12px;
}
.result-pop-actions .btn {
  min-height: 43px;
  margin: 0;
  padding: 9px 11px;
  border-radius: 13px;
  font-size: 13px;
}
.result-pop-actions .btn.primary { background: linear-gradient(135deg,#8c64ff,#6845ee); }
.result-pop-actions .btn.danger { color:#b73047; background:#fff3f5; border-color:#ffd0d8; }
.result-pop-actions .trade-icon { width: 18px; height: 18px; }

.result-pop-cta {
  width: min(250px, 100%);
  min-height: 49px;
  margin: 0 auto;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--result-accent-2), var(--result-accent));
  color: #fff;
  box-shadow: 0 9px 20px color-mix(in srgb, var(--result-accent) 24%, transparent);
  font: 700 15px/1.2 var(--font-heading);
}
.result-pop-inner.fair .result-pop-cta { color:#493600; }
.result-pop-cta:hover { transform: translateY(-1px); filter: saturate(1.05); }

.result-pop-close,
.result-pop-sound {
  position: absolute;
  z-index: 8;
  top: 12px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid #e0e7f4;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  color: #4d5675;
  box-shadow: 0 5px 14px rgba(31,43,86,.12);
  cursor: pointer;
}
.result-pop-close { right: 12px; }
.result-pop-sound { left: 12px; font-size: 15px; }
.result-pop-close:hover,.result-pop-sound:hover { color:#17214d; transform: translateY(-1px); }
.result-pop-sound[aria-pressed="false"] { opacity: .72; }

.result-pop-confetti,
.result-pop-sparkles {
  position: absolute;
  inset: -80px -18px auto;
  height: 320px;
  overflow: hidden;
  pointer-events: none;
  border-radius: 34px;
}
.result-pop-confetti i {
  position: absolute;
  top: -16px;
  opacity: .96;
  border-radius: 2px;
  animation: result-confetti-fall var(--dur, 2.2s) cubic-bezier(.15,.65,.34,1) var(--delay,0s) both;
}
.result-pop-sparkles i {
  position: absolute;
  width: var(--size,8px);
  height: var(--size,8px);
  border-radius: 50%;
  background: color-mix(in srgb, var(--result-accent-2) 75%, #fff);
  box-shadow: 0 0 12px color-mix(in srgb, var(--result-accent-2) 65%, transparent);
  animation: result-sparkle 1.7s ease-in-out var(--delay,0s) infinite;
}

@keyframes result-dialog-in { from { opacity:0; transform:translateY(24px) scale(.93); } to { opacity:1; transform:none; } }
@keyframes result-backdrop-in { from { opacity:0; } to { opacity:1; } }
@keyframes result-badge-pop { 0% { opacity:0; transform:scale(.68) rotate(-2deg); } 70% { opacity:1; transform:scale(1.05) rotate(1deg); } 100% { transform:none; } }
@keyframes result-mascot-arrive { from { opacity:0; transform:translateY(28px) scale(.72) rotate(-5deg); } to { opacity:1; transform:none; } }
@keyframes result-mascot-float { 0%,100% { transform:translateY(0) rotate(-1deg); } 50% { transform:translateY(-7px) rotate(1deg); } }
@keyframes result-mascot-sway { 0%,100% { transform:translateY(0) rotate(-2deg); } 50% { transform:translateY(-4px) rotate(2deg); } }
@keyframes result-halo { 0%,100% { transform:translateX(-50%) scale(.96); opacity:.7; } 50% { transform:translateX(-50%) scale(1.05); opacity:1; } }
@keyframes result-rays { to { transform:translateX(-50%) rotate(360deg); } }
@keyframes result-confetti-fall { 0% { transform:translate3d(0,-15px,0) rotate(0deg); opacity:0; } 10% { opacity:1; } 100% { transform:translate3d(var(--drift,0px),330px,0) rotate(var(--rot,460deg)); opacity:.16; } }
@keyframes result-sparkle { 0%,100% { transform:scale(.5); opacity:.18; } 50% { transform:scale(1.1); opacity:.92; } }

@media (max-width: 520px) {
  .result-pop { width: min(94vw, 460px); padding-top: 66px; }
  .result-pop-inner { padding: 74px 15px 16px; border-radius: 26px; }
  .result-pop-inner::before { border-radius: 20px; }
  .result-pop-art-wrap { top:-61px; width:136px; height:136px; }
  .result-pop-art { width:128px; height:128px; }
  .result-pop-halo { top:-62px; width:162px; height:162px; }
  .result-pop-rays { top:-80px; width:204px; height:204px; }
  .result-pop-badge { min-width:170px; padding-inline:20px; }
  .result-pop-stats dd { font-size:18px; }
  .result-pop-actions { grid-template-columns:1fr 1fr; }
  .result-pop-actions .btn { font-size:12px; padding-inline:7px; }
}

@media (max-width: 360px) {
  .result-pop-inner { padding-inline:12px; }
  .result-pop-stats > div { padding-inline:5px; }
  .result-pop-stats dt { font-size:10px; }
  .result-pop-stats dd { font-size:16px; }
  .result-pop-actions { grid-template-columns:1fr; }
}

/* Short viewports (laptops, zoomed-in browsers, landscape phones): tighten vertical rhythm. */
@media (max-height: 780px) {
  .result-pop { padding-top: 62px; }
  .result-pop-inner { padding-top: 64px; padding-bottom: 16px; }
  .result-pop-art-wrap { top:-56px; width:124px; height:124px; }
  .result-pop-art { width:116px; height:116px; }
  .result-pop-halo { top:-56px; width:150px; height:150px; }
  .result-pop-rays { top:-72px; width:188px; height:188px; }
  .result-pop-badge { padding-block: 8px 9px; font-size: clamp(1.4rem, 5vw, 1.8rem); }
  .result-pop-lead { margin-bottom: 10px; font-size: 14px; }
  .result-pop-stats { margin-bottom: 10px; padding-block: 8px; }
  .result-pop-note { margin-bottom: 7px; font-size: 12px; line-height: 1.5; }
  .result-pop-tip { margin-bottom: 12px; padding: 8px 11px; }
  .result-pop-actions { gap: 8px; margin-bottom: 10px; }
  .result-pop-actions .btn { min-height: 40px; padding-block: 7px; }
  .result-pop-cta { min-height: 44px; }
}

@media (max-height: 640px) {
  .result-pop { padding-top: 46px; }
  .result-pop-inner { padding-top: 50px; padding-bottom: 12px; }
  .result-pop-close, .result-pop-sound { top: 10px; width: 34px; height: 34px; }
  .result-pop-art-wrap { top:-44px; width:96px; height:96px; }
  .result-pop-art { width:90px; height:90px; }
  .result-pop-halo { top:-44px; width:116px; height:116px; }
  .result-pop-rays { top:-56px; width:144px; height:144px; }
  .result-pop-kicker { margin-bottom: 3px; font-size: 10px; }
  .result-pop-badge { min-width: 160px; margin-bottom: 6px; padding-block: 6px 7px; font-size: 1.4rem; }
  .result-pop-lead { margin-bottom: 8px; font-size: 13px; line-height: 1.35; }
  .result-pop-stats { margin-bottom: 8px; padding-block: 6px; }
  .result-pop-stats dd { margin-top: 2px; font-size: 17px; }
  .result-pop-tip { display: none; }
  .result-pop-actions { margin-bottom: 8px; }
  .result-pop-actions .btn { min-height: 36px; padding-block: 5px; font-size: 12px; }
  .result-pop-cta { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .result-pop[open],
  .result-pop::backdrop,
  .result-pop-art,
  .result-pop-badge,
  .result-pop-halo,
  .result-pop-rays,
  .result-pop-confetti i,
  .result-pop-sparkles i { animation:none !important; }
  .result-pop-confetti,.result-pop-sparkles { display:none; }
  .result-pop-close:hover,.result-pop-sound:hover,.result-pop-cta:hover { transform:none; }
}
