/* The progress-card rhythm adapts the compact Uiverse card pattern inspected for
   this flow; all colors, semantics and controls stay native to panXy. */
.px-wait {
  --wr-blue: var(--blue, #285fac);
  --wr-line: var(--line, #dce4ee);
  --wr-ink: var(--ink, #24374e);
  --wr-muted: var(--muted, #65788e);
  --wr-ease-out: cubic-bezier(.23, 1, .32, 1);
  --wr-board-size: clamp(230px, calc(100dvh - 330px), 340px);
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(205px, .58fr) minmax(0, 1.42fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  height: 440px;
  min-height: 410px;
  max-height: 470px;
  padding: 14px;
  overflow: visible;
  color: var(--wr-ink);
  border: 1px solid #d7e3f3;
  border-radius: 14px;
  background:
    radial-gradient(circle at 88% 8%, #dcecff 0, transparent 27%),
    linear-gradient(135deg, #f1f6ff, #fbfdff 52%, #eef6ff);
  box-shadow: inset 0 1px 0 #fff, 0 14px 34px #264d7a0b;
}

.px-wait[hidden] { display: none !important; }
.px-wait * { box-sizing: border-box; }
.px-wait button { font: inherit; cursor: pointer; touch-action: manipulation; }
.px-wait button:disabled { cursor: default; opacity: .48; }
.px-wait button:focus-visible,
.px-wait .wr-game-board:focus-visible { outline: 3px solid #85aeed; outline-offset: 2px; }

.wr-status-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  overflow: visible;
  border: 1px solid #d6e3f3;
  border-radius: 12px;
  background: linear-gradient(155deg, #fff 0%, #f7fbff 64%, #edf5ff 100%);
  box-shadow: 0 8px 24px #234d7d0b, inset 0 1px 0 #fff;
}
.wr-status-panel::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 84px;
  height: 84px;
  border: 16px solid #dcecff70;
  border-radius: 50%;
  pointer-events: none;
}
.px-wait .wr-progress { position: relative; z-index: 1; display: block; min-width: 0; }
.wr-progress-kicker {
  display: block;
  margin-bottom: 11px;
  color: #47709f;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .13em;
}
.wr-progress-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.wr-stage { min-width: 0; font-size: 17px; font-weight: 750; line-height: 1.35; }
.wr-stage::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: #3b82d0;
  box-shadow: 0 0 0 4px #dfeeff;
  vertical-align: 2px;
  animation: wr-status-pulse 2.4s ease-in-out infinite;
}
.px-wait[data-paused="true"] .wr-stage::before {
  background: #91a2b7;
  box-shadow: 0 0 0 4px #e9eef4;
  animation: none;
}
.wr-percent {
  flex-shrink: 0;
  color: var(--wr-blue);
  font-size: 34px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1.5px;
  line-height: 1;
}
.wr-percent small { margin-left: 2px; font-size: 14px; letter-spacing: 0; }
.wr-progress-track {
  height: 8px;
  margin-top: 15px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce7f5;
  box-shadow: inset 0 1px 2px #31578018;
}
.wr-progress-bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3276d6, #62a4ea);
  box-shadow: 0 0 10px #397ed738;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 300ms var(--wr-ease-out);
}
.px-wait[data-paused="true"] .wr-progress-bar { background: #7b90ac; box-shadow: none; }
.wr-progress-caption {
  display: grid;
  gap: 6px;
  margin-top: 9px;
  color: var(--wr-muted);
  font-size: 11px;
  line-height: 1.55;
}
.wr-progress-caption > span:first-child { color: #4f7097; font-weight: 650; }
.wr-progress-caption [data-progress-detail] { overflow-wrap: anywhere; }

.px-wait .wr-copy {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 0;
  margin: auto 0 0;
  color: #516885;
  font-size: 12px;
  line-height: 1.6;
}
.wr-copy-label {
  flex-shrink: 0;
  padding: 2px 5px;
  color: #3a6797;
  font-size: 10px;
  line-height: 1.45;
  border: 1px solid #d7e3f3;
  border-radius: 5px;
  background: #fff;
}
.wr-copy-text {
  display: block;
  min-width: 0;
  overflow: visible;
}

.wr-games {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  gap: 9px;
}
.wr-tabs {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid #d9e5f5;
  border-radius: 11px;
  background: #e7effa;
}
.wr-tabs button {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px;
  color: var(--wr-muted);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 160ms var(--wr-ease-out);
}
.wr-tabs button::after {
  content: "";
  position: absolute;
  right: 18%;
  bottom: 2px;
  left: 18%;
  height: 2px;
  border-radius: 2px;
  background: #3f82d3;
  opacity: 0;
  transform: scaleX(.45);
  transition: opacity 160ms ease, transform 220ms var(--wr-ease-out);
}
.wr-tabs button[aria-pressed="true"] {
  color: #245ec8;
  font-weight: 700;
  border-color: #c4d8f3;
  background: #fff;
  box-shadow: 0 2px 5px #244f8112;
}
.wr-tabs button[aria-pressed="true"]::after { opacity: 1; transform: scaleX(1); }
.wr-tabs svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.px-wait .wr-games > .wr-game {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 176px;
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}
.px-wait .wr-game > .wr-game-board {
  position: relative;
  place-self: center;
  width: auto;
  height: min(100%, var(--wr-board-size));
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  outline-offset: -3px;
  border: 1px solid #cbdcf0;
  border-radius: 13px;
  background: radial-gradient(circle at 50% 0, #fff 8%, #eff6ff 90%);
  box-shadow: inset 0 1px 0 #fff, 0 10px 24px #244f8112;
  isolation: isolate;
  transform-origin: center;
}
.wr-game-board canvas { display: block; width: 100%; height: 100%; border-radius: 12px; object-fit: contain; touch-action: none; }

.px-wait .wr-game > .wr-game-side {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px;
}
.wr-game-score {
  min-height: 38px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 9px;
  color: var(--wr-muted);
  font-size: 12px;
  border: 1px solid #dfe8f6;
  border-radius: 8px;
  background: #fff;
}
.wr-game-score strong { color: var(--wr-blue); font-size: 22px; font-weight: 780; font-variant-numeric: tabular-nums; line-height: 1; }
.wr-game-status { min-height: 34px; flex-shrink: 0; margin: 0; color: #556d89; font-size: 11px; line-height: 1.5; }
.wr-main-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.wr-control {
  min-width: 44px;
  min-height: 44px;
  padding: 6px;
  color: var(--wr-blue);
  font-size: 12px;
  border: 1px solid #c7d8ee;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 0 #dce7f580;
  transition: transform 140ms var(--wr-ease-out), background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}
.wr-primary { color: #fff; border-color: #245ec8; background: linear-gradient(180deg, #3778d5, #245ec8); box-shadow: 0 2px 0 #1b4b9c; }
.wr-control:active { transform: translateY(1px) scale(.985); box-shadow: none; }
.wr-game-actions { display: grid; gap: 4px; margin-top: auto; }
.px-wait .wr-game-side .wr-direction {
  display: grid;
  grid-template-columns: repeat(4, minmax(44px, 1fr));
  grid-template-rows: 44px;
  gap: 3px;
  justify-content: center;
}
.px-wait .wr-direction [data-game-action] { grid-column: auto !important; grid-row: 1 !important; min-height: 44px; padding: 0; }
.wr-hint { margin: 0; color: var(--wr-muted); font-size: 10px; line-height: 1.4; }

.wr-board-message {
  position: absolute;
  inset: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  color: #25456d;
  text-align: center;
  pointer-events: none;
  border: 1px solid #ffffffb3;
  border-radius: 10px;
  background: #f9fcfff2;
  backdrop-filter: blur(3px);
  animation: wr-overlay-in 240ms var(--wr-ease-out) both;
}
.wr-board-message[hidden] { display: none; }
.wr-board-message::before {
  content: "✦";
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin-bottom: 3px;
  color: #3777c6;
  font-size: 22px;
  border: 1px solid #c9dcf4;
  border-radius: 11px;
  background: #e9f2ff;
}
.wr-board-message strong { font-size: 18px; letter-spacing: .02em; }
.wr-board-message span { max-width: 25em; color: var(--wr-muted); font-size: 11px; line-height: 1.6; }

.wr-tiles,
.wr-memory,
.wr-stars {
  width: min(100%, 310px);
  max-width: 100%;
  aspect-ratio: 1;
  display: grid;
}
.wr-tiles { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: 6px; padding: 8px; }
.wr-tile {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  color: #244a81;
  font-size: clamp(17px, 3.1vmin, 23px);
  font-weight: 750;
  border: 1px solid #dae6f4;
  border-radius: 8px;
  background: #eff3f9;
  box-shadow: inset 0 1px 0 #ffffff9c, 0 2px 1px #23589112;
  transition: background-color 160ms ease, transform 160ms var(--wr-ease-out);
}
.wr-tile[data-value="0"] { background: #eaf0f8; border-color: #e2eaf5; box-shadow: inset 0 1px 3px #31537a0a; }
.wr-tile[data-value="2"] { background: #e4eefc; }
.wr-tile[data-value="4"] { background: #cedff9; }
.wr-tile[data-value="8"] { color: #174a8b; background: #b0cdf5; }
.wr-tile[data-value="16"] { color: #fff; background: #629bdd; }
.wr-tile[data-value="32"] { color: #fff; background: #3f7aca; }
.wr-tile[data-large="true"] { color: #fff; font-size: clamp(15px, 2.7vmin, 20px); border-color: #2460ad; background: #285fac; }

.wr-memory { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: 5px; padding: 7px; }
.wr-memory button {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  color: #45658f;
  font-size: clamp(18px, 3.2vmin, 24px);
  font-weight: 650;
  border: 1px solid #bed3ee;
  border-radius: 8px;
  background: linear-gradient(145deg, #e4f0ff, #c9def8);
  box-shadow: 0 2px 1px #23589112;
  transition: transform 180ms var(--wr-ease-out), background-color 180ms ease, border-color 180ms ease;
}
.wr-memory button[data-open="true"] { border-color: #76a2dc; background: #fff; box-shadow: inset 0 0 0 1px #b9d2f1; transform: rotateY(180deg); }
.wr-memory button[data-matched="true"] { color: #237c61; border-color: #b9dccd; background: #e7f5ef; box-shadow: none; transform: scale(.96); opacity: 1; }

.wr-stars { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 7px; padding: 9px; }
.wr-stars button {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  color: #7395be;
  font-size: clamp(24px, 4.4vmin, 34px);
  border: 1px solid #d4e3f6;
  border-radius: 11px;
  background: #ecf3fc;
  box-shadow: inset 0 1px 0 #fff;
  transition: transform 140ms var(--wr-ease-out), background-color 140ms ease, border-color 140ms ease;
}
.wr-stars button[data-active="true"] { color: #df8b1d; border-color: #ecc77c; background: #fff6df; box-shadow: 0 2px 8px #c18b2424; animation: wr-star-pop 260ms var(--wr-ease-out) both; }
.wr-stars button:active { transform: scale(.96); }

.wr-reward {
  position: absolute;
  z-index: 3;
  left: calc(50% - 3px);
  top: calc(50% - 3px);
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: #eaa23d;
  opacity: 0;
  pointer-events: none;
}
.wr-reward:nth-of-type(even) { background: #4387d8; }

@keyframes wr-status-pulse {
  0%, 100% { box-shadow: 0 0 0 4px #dfeeff; }
  50% { box-shadow: 0 0 0 7px #dfeeff55; }
}
@keyframes wr-overlay-in {
  from { opacity: 0; transform: scale(.975); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes wr-star-pop {
  0% { transform: scale(.82); }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@media (hover: hover) and (pointer: fine) {
  .wr-tabs button:hover { color: #315f96; background: #f7fbff; transform: translateY(-1px); }
  .wr-control:hover { border-color: #729cd3; box-shadow: 0 4px 10px #2f5d9220; transform: translateY(-1px); }
  .wr-memory button:not(:disabled):hover { border-color: #729cd3; transform: translateY(-1px); }
}

@media (max-height: 650px) and (min-width: 701px) {
  .px-wait { --wr-board-size: clamp(220px, calc(100dvh - 330px), 290px); gap: 10px; padding: 10px; }
  .wr-status-panel { gap: 10px; padding: 12px; }
  .wr-progress-kicker { margin-bottom: 6px; }
  .wr-stage { font-size: 15px; }
  .wr-percent { font-size: 28px; }
  .wr-progress-track { margin-top: 9px; }
  .wr-progress-caption { gap: 3px; margin-top: 5px; font-size: 10px; line-height: 1.4; }
  .px-wait .wr-copy { font-size: 10px; line-height: 1.45; }
  .wr-copy-text { display: block; overflow: visible; }
  .wr-games { grid-template-rows: 46px minmax(0, 1fr); gap: 6px; }
  .wr-tabs { padding: 1px; }
  .wr-tabs button { min-height: 44px; }
  .px-wait .wr-games > .wr-game { grid-template-columns: minmax(0, 1fr) 168px; gap: 8px; }
  .px-wait .wr-game > .wr-game-side { gap: 5px; padding: 0; }
  .wr-game-score { min-height: 30px; padding: 3px 7px; }
  .wr-game-status { min-height: 28px; font-size: 10px; }
  .wr-hint { display: none; }
}

@media (max-width: 700px) {
  .px-wait {
    --wr-board-size: clamp(210px, calc(100dvh - 590px), 260px);
    height: 470px;
    min-height: 450px;
    max-height: 500px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }
  .wr-status-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(104px, .55fr);
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
  }
  .wr-status-panel::after { display: none; }
  .wr-progress-kicker { margin-bottom: 3px; font-size: 9px; }
  .wr-progress-head { align-items: center; }
  .wr-stage { font-size: 13px; }
  .wr-stage::before { width: 6px; height: 6px; margin-right: 6px; }
  .wr-percent { font-size: 24px; }
  .wr-progress-track { height: 6px; margin-top: 6px; }
  .wr-progress-caption { display: block; margin-top: 4px; font-size: 9px; line-height: 1.35; }
  .wr-progress-caption > span:first-child { display: none; }
  .px-wait .wr-copy { margin: 0; font-size: 10px; line-height: 1.4; }
  .wr-copy-label { display: none; }
  .wr-copy-text { display: block; overflow: visible; }
  .wr-games { grid-template-rows: 44px minmax(0, 1fr); gap: 6px; }
  .wr-tabs { padding: 0; border: 0; background: transparent; }
  .wr-tabs button { min-height: 44px; flex-direction: column; gap: 1px; padding: 3px 2px; font-size: 9px; border-color: #d8e4f4; background: #edf4fe; }
  .wr-tabs svg { width: 15px; height: 15px; }
  .px-wait .wr-games > .wr-game {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 84px;
    gap: 5px;
  }
  .px-wait .wr-game > .wr-game-side {
    display: grid;
    grid-template-columns: minmax(82px, .68fr) minmax(176px, 1.32fr);
    grid-template-rows: 28px 50px;
    align-items: center;
    gap: 3px 6px;
    padding: 0;
  }
  .wr-game-score { grid-column: 1; grid-row: 1; min-height: 28px; justify-content: flex-start; padding: 3px 6px; }
  .wr-game-score strong { margin-left: auto; font-size: 18px; }
  .wr-game-status { grid-column: 2; grid-row: 1; min-height: 0; font-size: 9px; line-height: 1.25; }
  .wr-main-actions { grid-column: 1; grid-row: 2; }
  .wr-game-actions { grid-column: 2; grid-row: 2; height: 100%; margin: 0; display: flex; align-items: center; justify-content: center; }
  .px-wait .wr-game-side .wr-direction { width: 100%; grid-template-columns: repeat(4, minmax(44px, 1fr)); gap: 0; }
  .wr-game-actions:has(.wr-direction) .wr-hint { display: none; }
  .wr-hint { font-size: 9px; }
  .wr-board-message { inset: 5px; padding: 8px; }
  .wr-board-message::before { width: 28px; height: 28px; margin: 0; font-size: 18px; }
  .wr-board-message strong { font-size: 15px; }
  .wr-board-message span { font-size: 10px; }
  .wr-tiles, .wr-memory, .wr-stars { width: min(100%, var(--wr-board-size)); }
  .wr-memory { gap: 4px; padding: 6px; }
  .wr-stars { gap: 5px; padding: 7px; }
}

@media (max-width: 350px) {
  .px-wait { padding: 8px; }
  .wr-status-panel { grid-template-columns: minmax(0, 1fr); }
  .px-wait .wr-copy { display: none; }
  .px-wait .wr-game > .wr-game-side { grid-template-columns: minmax(76px, .6fr) minmax(176px, 1.4fr); gap: 3px; }
  .wr-tabs button { font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .px-wait *, .px-wait *::before, .px-wait *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition-duration: .01ms !important;
  }
  .wr-tabs button:hover,
  .wr-control:hover,
  .wr-control:active,
  .wr-memory button:not(:disabled):hover,
  .wr-memory button[data-open="true"],
  .wr-memory button[data-matched="true"],
  .wr-stars button:active { transform: none; }
  .wr-progress-bar { transition: none !important; }
}
