/* Result-only viewport layout. Opening and rare-card ceremonies keep their own stage. */
#openingDialog.phase-result[open]{display:grid;grid-template-rows:auto auto minmax(0,1fr) auto;gap:0;height:100dvh;min-height:0;box-sizing:border-box;padding:16px 28px max(14px,env(safe-area-inset-bottom));overflow:hidden}
#openingDialog.phase-result .opening-top{min-height:30px;align-items:center}
#openingDialog.phase-result .opening-title{margin:8px 0 0;text-align:center}
#openingDialog.phase-result .opening-title .eyebrow{display:none}
#openingDialog.phase-result .opening-title h2{font:500 24px/1.4 var(--serif);letter-spacing:1px;margin:0}
#openingDialog.phase-result .opening-title p{font-size:11px;line-height:1.5;margin:6px 0;color:#9ca3af;letter-spacing:.3px}
#openingDialog.phase-result .reveal-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));align-items:center;gap:clamp(12px,2vw,28px);width:100%;height:100%;min-height:0;max-width:1400px;margin:0 auto;padding:14px 8px;box-sizing:border-box;container-type:size}
#openingDialog.phase-result .reveal-slot{display:flex;flex-direction:column;width:min(100%,calc((100cqh - 62px)*.7317));min-width:0;justify-self:center;margin:0;grid-column:auto}
#openingDialog.phase-result .flip-scene{width:100%;aspect-ratio:3/4.1;flex:none}
#openingDialog.phase-result .reveal-caption{order:-1;display:flex;align-items:center;gap:10px;margin:0 0 9px;font-size:10px;white-space:nowrap}
#openingDialog.phase-result .reveal-caption:after{content:'';height:1px;flex:1;background:#c9ae6b30}
#openingDialog.phase-result .reveal-keep{min-height:30px;margin:8px 0 0;text-align:center}
#openingDialog.phase-result .result-favorite{font-size:10px;min-height:28px;padding:5px 13px}
#openingDialog.phase-result #resultFooter{display:flex;flex-direction:column;gap:10px;width:100%;max-width:1400px;margin:0 auto;padding:10px 0 0;border-top:1px solid #ffffff12;animation:none}
#openingDialog.phase-result #resultSummary,#openingDialog.phase-result #resultFooter>small{display:none}
.result-attribution{margin:0;color:#a2a7b3;font-size:11px;line-height:1.5;text-align:center}
.result-attribution a{color:inherit;text-decoration:underline;text-underline-offset:2px}
#openingDialog.phase-result .result-insights{display:flex;flex-direction:column;gap:6px;width:100%;max-height:30dvh;overflow:auto;scrollbar-width:thin}
#openingDialog.phase-result #resultGains{max-width:none;margin:0}
#openingDialog.phase-result .pack-receipt{padding:0;border:0;border-radius:0;background:none;gap:6px 12px}
#openingDialog.phase-result .receipt-stats{width:auto;gap:6px 18px;font-size:11px}
#openingDialog.phase-result .receipt-stats b{font-size:16px}
#openingDialog.phase-result .receipt-unlocked{width:auto;font-size:10px}
#openingDialog.phase-result .receipt-claimed{font-size:10px}
#openingDialog.phase-result .pack-receipt button{min-height:32px;padding:5px 10px;font-size:10px}
#openingDialog.phase-result .pack-receipt>small{width:auto;font-size:9px;color:#858e9b}
#openingDialog.phase-result .receipt-replay{padding:0;font-size:11px}
#openingDialog.phase-result #resultDiscovery{display:flex;flex-wrap:nowrap;justify-content:center;gap:8px;margin:0;width:100%;min-height:0}
#openingDialog.phase-result .result-theme{display:flex;align-items:center;gap:10px;width:auto;flex:none;padding:6px 12px;border-radius:4px;background:none}
#openingDialog.phase-result .result-theme>span{font-size:9px;letter-spacing:0}
#openingDialog.phase-result .result-theme strong{font:12px/1.5 var(--serif);gap:10px;margin:0}
#openingDialog.phase-result .result-theme strong b{font-size:10px}
#openingDialog.phase-result .result-theme small{display:none}
#openingDialog.phase-result #resultFooter>.result-actions{display:flex;justify-content:center;flex-wrap:nowrap;gap:10px;width:100%;margin:0}
#openingDialog.phase-result .result-actions button{min-height:44px;padding:10px 24px;font-size:12px}
#openingDialog.phase-result #doneOpening{min-width:180px}
/* Keep all five cards and the completion action inside the mobile viewport. */
@media(max-width:700px), (max-height:500px) and (pointer:coarse){
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result)[open]{
  display:grid;
  grid-template-rows:auto auto minmax(0,1fr) auto;
  height:100dvh;
  max-height:100dvh;
  min-height:0;
  gap:0;
  box-sizing:border-box;
  padding:max(8px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
  overflow:hidden;
 }
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .opening-top{grid-row:1;min-height:36px;gap:6px;flex-wrap:nowrap}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .opening-controls{gap:4px;flex-wrap:nowrap}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .opening-controls button{min-height:44px}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .opening-title{grid-row:2;margin:2px 0 0}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .opening-title .eyebrow{display:none}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .opening-title h2{font:500 19px/1.4 var(--serif);letter-spacing:1px;margin:0}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .opening-title p{font-size:10px;line-height:1.5;margin:4px 0 0;letter-spacing:0}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) #revealGrid{
  grid-row:3;
  display:grid;
  grid-template-columns:repeat(6,minmax(0,1fr));
  grid-template-rows:repeat(2,minmax(0,1fr));
  grid-auto-flow:row;
  grid-auto-columns:auto;
  align-items:center;
  justify-items:center;
  width:100%;
  height:100%;
  min-height:0;
  max-width:560px;
  gap:10px 8px;
  margin:0 auto;
  padding:8px 10px;
  box-sizing:border-box;
  overflow:visible;
  container-type:size;
 }
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .reveal-slot{
  grid-column:span 2;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  justify-self:center;
  width:min(100%,calc((100cqh - 46px)*.36585));
  min-width:0;
  min-height:0;
  margin:0;
 }
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .reveal-slot:nth-child(4){grid-column:2 / span 2}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .reveal-slot:nth-child(5){grid-column:4 / span 2}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .flip-scene{width:100%;aspect-ratio:3/4.1;flex:none}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .encyclopedia-card .card-meta{padding-inline:4px;gap:3px}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .encyclopedia-card .card-meta h3{font-size:clamp(8px,5.6cqw,14px);-webkit-line-clamp:1}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .encyclopedia-card .card-rarity{font-size:clamp(8px,5.5cqw,14px)}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .encyclopedia-card .card-tagline{font-size:clamp(7px,4.5cqw,10px);padding:4px 4px 0}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .encyclopedia-card .card-stats>span{padding:3px 1px;gap:1px}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .encyclopedia-card .card-stats small{font-size:clamp(6px,3.7cqw,9px);letter-spacing:.5px}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .encyclopedia-card .card-stats b{font-size:clamp(10px,9.5cqw,19px);letter-spacing:-.25px}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .reveal-caption{
  order:-1;display:block;min-width:0;margin:0 0 4px;
  font-size:8px;line-height:12px;letter-spacing:0;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
 }
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .reveal-caption:after{display:none}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .reveal-keep{display:none}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) #revealActions{grid-row:4;margin:0}
 #openingDialog.phase-result #resultFooter{grid-row:4;gap:6px;padding:6px 0 0;margin:0;min-width:0}
 #openingDialog.phase-result .result-insights{max-height:100px;gap:4px;min-width:0;overflow:auto;overscroll-behavior:contain}
 #openingDialog.phase-result .pack-receipt{gap:4px 8px;min-width:0}
 #openingDialog.phase-result .receipt-stats{width:100%;gap:4px 12px;font-size:10px;line-height:16px}
 #openingDialog.phase-result .receipt-stats b{font-size:13px}
 #openingDialog.phase-result .pack-receipt>small{display:none}
 #openingDialog.phase-result .pack-receipt button{min-height:44px;padding:6px 12px;font-size:11px}
 #openingDialog.phase-result #resultDiscovery{flex-wrap:wrap;gap:4px;overflow:visible}
 #openingDialog.phase-result .result-theme{flex:1 1 auto;min-width:0;min-height:32px;max-width:100%;padding:4px 8px}
 #openingDialog.phase-result .result-theme>span{display:none}
 #openingDialog.phase-result .result-theme strong{min-width:0;font-size:10px;gap:6px;margin:0}
 #openingDialog.phase-result .result-theme strong b{white-space:nowrap;font-size:9px}
 #openingDialog.phase-result #resultFooter>.result-actions{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
 #openingDialog.phase-result .result-actions button{min-width:0;min-height:44px;padding:7px 4px;font-size:10px;line-height:1.3;letter-spacing:0}
 #openingDialog.phase-result #doneOpening{min-width:0}
}
@media(max-height:500px) and (min-width:601px) and (pointer:coarse){
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .opening-title h2{font-size:16px}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) #revealGrid{grid-template-columns:repeat(5,minmax(0,1fr));grid-template-rows:minmax(0,1fr);max-width:none}
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .reveal-slot,
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .reveal-slot:nth-child(4),
 #openingDialog:is(.phase-dealing,.phase-cards,.phase-result) .reveal-slot:nth-child(5){grid-column:auto;width:min(100%,calc((100cqh - 28px)*.7317))}
 #openingDialog.phase-result .result-insights{flex-direction:row;align-items:center;max-height:64px}
 #openingDialog.phase-result #resultDiscovery{width:auto;flex:0 1 35%}
 #openingDialog.phase-result #resultGains{flex:1;min-width:0}
}
/* Pack the portrait results in reading order, with scrolling on short screens. */
@media (max-width: 700px) and (orientation: portrait) {
  #openingDialog.phase-result[open] {
    grid-template-rows: auto auto min-content auto;
    align-content: start;
    gap: 10px;
    overflow-y: auto;
  }
  #openingDialog.phase-result .opening-title p {
    margin-bottom: 0;
  }
  #openingDialog.phase-result #revealGrid {
    grid-template-rows: repeat(2, min-content);
    height: auto;
    padding: 4px 6px 6px;
    gap: 10px 7px;
    container-type: inline-size;
  }
  #openingDialog.phase-result #revealGrid .reveal-slot {
    width: min(100%, max(74px, calc((100dvh - 226px) * .35)));
  }
  #openingDialog.phase-result #revealGrid .reveal-caption {
    min-height: 0;
    padding: 0;
  }
}
@media(max-height:550px) and (min-width:701px){
 #openingDialog.phase-result[open]{padding:8px 20px}
 #openingDialog.phase-result .opening-title h2{font-size:18px}
 #openingDialog.phase-result .opening-title p{margin:3px 0;font-size:10px}
 #openingDialog.phase-result .opening-top{min-height:24px}
 #openingDialog.phase-result #resultFooter{gap:5px;padding-top:5px}
 #openingDialog.phase-result .reveal-grid{padding-block:8px}
}

/* One central stack during the reveal. The results keep their existing grid. */
#openingDialog:is(.phase-dealing,.phase-cards)[open] {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}
#openingDialog:is(.phase-dealing,.phase-cards) #revealGrid {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  gap: 0;
  overflow: visible;
  container-type: size;
  isolation: isolate;
}
#openingDialog:is(.phase-dealing,.phase-cards) #revealGrid .reveal-slot {
  grid-area: 1 / 1;
  width: min(290px, 78%, calc((100cqh - 24px) * .73));
  min-width: 0;
  margin: 0;
  visibility: hidden;
  pointer-events: none;
  animation: none;
}
#openingDialog.phase-dealing #revealGrid .reveal-slot:first-child,
#openingDialog.phase-cards #revealGrid .reveal-slot.stack-current,
#openingDialog.phase-cards #revealGrid .reveal-slot.stack-under {
  visibility: visible;
}
#openingDialog:is(.phase-dealing,.phase-cards) .reveal-slot .flip-scene {
  aspect-ratio: 3 / 4.1;
}
#openingDialog:is(.phase-dealing,.phase-cards) .reveal-slot :is(.reveal-caption,.reveal-keep) {
  display: none;
}
#openingDialog.phase-cards #revealGrid .stack-current {
  z-index: 3;
  animation: stack-card-enter .35s cubic-bezier(.16,.8,.22,1) both;
}
#openingDialog.phase-cards #revealGrid .stack-under {
  z-index: calc(3 - var(--stack-depth));
  transform: translate(calc(var(--stack-depth) * -8px), calc(var(--stack-depth) * 5px))
    rotate(calc(var(--stack-depth) * -3deg)) scale(.96);
  filter: brightness(.62);
}
@keyframes stack-card-enter {
  from { transform: translate(14px, -16px) rotate(3deg) scale(.94); }
  to { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  #openingDialog.phase-cards #revealGrid .stack-current { animation: none; }
}

.opening-stack-stage { display: contents; }
.opening-card-previews { display: none; }
#openingDialog:is(.phase-dealing,.phase-cards) .opening-stack-stage {
  grid-row: 3;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  min-height: 0;
  max-height: calc(min(290px, 73vw) * 1.367 + min(56dvh, 440px) * .2734 + 62px);
}
#openingDialog:is(.phase-dealing,.phase-cards) .opening-title {
  margin: 6px 0 0;
}
#openingDialog:is(.phase-dealing,.phase-cards) #revealGrid {
  grid-row: 1;
  align-items: center;
  margin: 0 auto;
  padding-top: clamp(10px, 3.5dvh, 34px);
}
#openingDialog:is(.phase-dealing,.phase-cards) .opening-card-previews {
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-self: end;
  justify-self: center;
  gap: clamp(5px, 1.5vw, 14px);
  width: min(100%, 440px, 56dvh);
  margin: 9px 0 clamp(8px, 2dvh, 20px);
}
.opening-card-preview {
  position: relative;
  min-width: 0;
  aspect-ratio: 3 / 4.1;
  border-radius: 6px;
}
.opening-card-preview.is-current {
  outline: 2px solid var(--card-accent, var(--gold));
  outline-offset: 3px;
}
.opening-preview-back {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5%;
  height: 100%;
  border: 1px solid #9b8bb258;
  border-radius: inherit;
  background: repeating-linear-gradient(135deg, #a498d00a 0 1px, transparent 1px 9px), #171527;
  color: #ac9bbf;
}
.opening-preview-back > span { font-size: clamp(14px, 4vw, 26px); }
.opening-preview-back > small { font-size: 10px; }
#openingDialog .opening-card-preview > .physical-card {
  width: 100%;
  height: 100%;
  margin: 0;
  border-width: 2px;
  border-radius: inherit;
  box-shadow: none;
}
#openingDialog .opening-card-preview .card-meta { padding-inline: 2px; gap: 2px; }
#openingDialog .opening-card-preview :is(.card-meta h3,.card-rarity,.card-tagline) { font-size: 7cqw; }
#openingDialog .opening-card-preview :is(.card-category,.card-number,.card-knowledge) { display: none; }
#openingDialog .opening-card-preview .card-tagline { padding: 2px 3px 0; }
#openingDialog .opening-card-preview .card-stats > span { padding: 1px 0; gap: 0; }
#openingDialog .opening-card-preview .card-stats small { font-size: 6cqw; letter-spacing: 0; }
#openingDialog .opening-card-preview .card-stats b { font-size: 11cqw; letter-spacing: 0; }

#openingDialog.phase-result #openAnotherPack{min-width:140px}
#openingDialog.phase-result #doneOpening{min-width:130px}
#openingDialog.phase-result #openAnotherPack[hidden]{display:none}
@media(max-width:700px),(max-height:500px) and (pointer:coarse){#openingDialog.phase-result #openAnotherPack,#openingDialog.phase-result #doneOpening{min-width:0}#openingDialog.phase-result .result-actions:has(#openAnotherPack[hidden]){grid-template-columns:1fr 1fr 1.4fr}}

/* Complete exploration is the primary result action. */
#openingDialog.phase-result #doneOpening{background:#e7cb8b;border:1px solid #f1dca9;color:#272115;font-weight:650;box-shadow:0 3px 12px #0003}
#openingDialog.phase-result #doneOpening:hover{background:#f2dca8;border-color:#ffe8b8}
#openingDialog.phase-result #openAnotherPack{background:#e7cb8b0a;border:1px solid #d4b87888;color:#e3ca97;box-shadow:none}
#openingDialog.phase-result #openAnotherPack:hover:not(:disabled){background:#e7cb8b18;border-color:#e7cb8b}
