/* ==========================================================================
   The Balloon Shoppe — games.html ("The back room")
   Pop Parade + Twist & Match. Shared components come from styles.css;
   everything here is page-scoped.
   ========================================================================== */

/* ---------- 1. Head ---------- */
.games-head { padding-bottom: clamp(24px, 1vw + 20px, 40px); }
.games-head__inner { display: grid; gap: clamp(28px, 4vw, 64px); align-items: end; }
@media (min-width: 900px) {
  .games-head__inner { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
}
.games-head__intro { margin-bottom: 0; gap: var(--s-5); }
.game-picker { justify-self: start; }

.prize-list__title {
  font-family: var(--font-body); font-size: var(--fs-eyebrow); font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-ink-soft);
  margin-bottom: var(--s-3);
}
.prize-list ul { list-style: none; margin: 0; padding: 0; }
.prize-list li {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: var(--s-4); align-items: center;
  padding: 14px 0; border-top: 1px solid var(--c-line);
}
.prize-list li:last-child { border-bottom: 1px solid var(--c-line); }
.prize-list__mark { width: 18px; height: 32px; }
.prize-list__game { font-weight: 700; line-height: 1.3; }
.prize-list .small { line-height: 1.4; }
.prize-list__prize { font-family: var(--font-display); font-size: 1.125rem; line-height: 1.2; color: var(--c-raspberry); text-align: right; max-width: 19ch; }

/* ---------- 2. Arcade: HUD + stage ---------- */
.arcade { max-width: 960px; margin-inline: auto; }

.hud { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-4); padding-bottom: var(--s-3); }
.hud__stats { display: flex; gap: clamp(14px, 3.5vw, 40px); margin: 0; min-width: 0; }
.hud__stat { display: grid; gap: 2px; min-width: 0; }
.hud__stat dt { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--c-ink-soft); }
.hud__stat dd {
  margin: 0; display: flex; align-items: baseline; gap: 3px;
  font-family: var(--font-display); font-size: clamp(1.45rem, 1.15rem + 1vw, 2rem); line-height: 1.05; white-space: nowrap;
}
.hud__num { display: inline-block; font-variant-numeric: tabular-nums; transition: color var(--dur-2); }
.hud__of { font-family: var(--font-body); font-size: 0.9375rem; font-weight: 600; color: var(--c-ink-soft); }
.hud__stat dd.is-goal .hud__num { color: var(--c-success); }
.hud__stat dd.is-over .hud__num { color: var(--c-ink-soft); }
.game.is-hurry [data-pp-time] { color: var(--c-raspberry); }
.hud__num.is-bump { animation: hud-bump 0.32s var(--ease-spring); }
@keyframes hud-bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
.hud__tools { display: flex; align-items: center; gap: var(--s-2); flex: none; }
.hud__peek { padding-inline: 0.9em; }

.stage {
  position: relative;
  display: grid;
  aspect-ratio: 16 / 10;
  border-radius: var(--r-lg);
  isolation: isolate; /* no overflow clip here: the in-flow screens may grow the stage past its ratio */
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.stage--sky { background: var(--c-sky); }
.stage--blush { background: var(--c-blush); }
/* 24 cards need more floor than 12 balloons do, so the match stage is the taller of the two. */
.game--match .stage { aspect-ratio: 16 / 11; }
@media (max-width: 700px) {
  .stage { aspect-ratio: 3 / 4; }
  .game--match .stage { aspect-ratio: 2 / 3; }
}

.stage__bar { position: absolute; inset: 0 0 auto 0; height: 5px; background: rgba(15, 77, 74, 0.1); z-index: 2; }
.stage__bar span { display: block; height: 100%; background: var(--c-shopfront); transform-origin: 0 50%; transform: scaleX(1); }
.game.is-hurry .stage__bar span { background: var(--c-raspberry); }

/* Start / pause / end screens: in normal flow so the stage grows if a panel needs more room. */
.screen {
  position: relative; z-index: 4;
  display: grid; place-items: center;
  padding: clamp(14px, 3vw, 32px);
  border-radius: inherit;
  background: rgba(221, 234, 246, 0.55);
}
.stage--blush .screen { background: rgba(252, 228, 225, 0.6); }
.screen__panel {
  width: min(100%, 540px);
  display: grid; gap: var(--s-3); justify-items: start;
  padding: clamp(20px, 3vw, 36px);
  background: var(--c-paper);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.screen__panel--sm { width: min(100%, 440px); }
.screen__title { font-size: clamp(1.45rem, 1.15rem + 1.1vw, 2rem); line-height: 1.12; }
.screen__title:focus { outline: none; }
.screen__stats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: var(--fs-small); color: var(--c-ink-soft); }
.screen__goal { width: 100%; padding: 10px 14px; border-radius: var(--r-sm); background: var(--c-butter); font-size: var(--fs-small); line-height: 1.45; }
.screen__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-1); }
.screen .ticket { width: 100%; }
.screen__keys { margin-top: calc(var(--s-1) * -1); }
@media (hover: none) and (pointer: coarse) { .screen__keys { display: none; } }

.howto { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; width: 100%; }
.howto li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px; align-items: center; font-size: var(--fs-small); line-height: 1.42; }
.howto li > svg:not(.icon) { width: 18px; height: 32px; justify-self: center; }
.howto li > .icon { width: 20px; height: 20px; justify-self: center; color: var(--c-shopfront); }
.howto__num {
  display: grid; place-items: center; width: 20px; height: 25px; justify-self: center;
  border-radius: 5px; background: var(--c-shopfront); color: var(--c-paper);
  font-family: var(--font-display); font-size: 0.875rem; line-height: 1;
}

/* ---------- 3. Pop Parade ---------- */
.pp-field { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; }
.pp-field:focus { outline: none; }
.pp-field:focus-visible { box-shadow: inset 0 0 0 3px var(--c-raspberry); }

.pp-balloon {
  position: absolute; left: 0; top: 0;
  padding: 0; margin: 0;
  transform-origin: 50% 58%;
  will-change: transform;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pp-balloon svg {
  display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none;
  filter: drop-shadow(0 8px 9px rgba(43, 27, 36, 0.14));
  transform-origin: 50% 30%;
  transition: transform var(--dur-2) var(--ease-spring);
}
@media (hover: hover) { .pp-balloon:hover svg { transform: scale(1.07); } }
.pp-balloon:focus { outline: none; }
.pp-balloon:focus-visible::after {
  content: ""; position: absolute; left: -12%; top: -6%; width: 124%; height: 68%;
  border-radius: 50%; border: 3px solid var(--c-raspberry);
  box-shadow: 0 0 0 2px var(--c-white), inset 0 0 0 2px var(--c-white);
  pointer-events: none;
}
.pp-balloon--gold svg { filter: drop-shadow(0 0 10px rgba(242, 198, 75, 0.65)) drop-shadow(0 8px 9px rgba(43, 27, 36, 0.14)); }
.pp-balloon.is-popping { pointer-events: none; }
.pp-balloon.is-popping svg { animation: pp-pop 0.24s ease-out forwards; }
.pp-balloon.is-popping::after { display: none; }
.pp-balloon.is-leaving { pointer-events: none; opacity: 0; transition: opacity 0.4s ease; }
@keyframes pp-pop {
  0% { transform: scale(1); opacity: 1; }
  35% { transform: scale(1.2, 0.84); opacity: 1; }
  100% { transform: scale(1.55); opacity: 0; }
}

.pp-idle { position: absolute; pointer-events: none; opacity: 0.92; }
.pp-idle svg { width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 8px 9px rgba(43, 27, 36, 0.12)); }

.pp-target {
  position: absolute; top: 16px; left: 50%; z-index: 3;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 14px 5px 12px;
  background: var(--c-white); border-radius: var(--r-pill); box-shadow: var(--sh-1);
  font-weight: 700; font-size: var(--fs-small); line-height: 1.2; white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}
.pp-target__label { font-size: 0.6875rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--c-ink-soft); }
.pp-target__swatch { width: 14px; height: 25px; }
.pp-target__pts { margin-left: 2px; padding-left: 10px; border-left: 1.5px dashed var(--c-line); color: var(--c-raspberry); }
.pp-target.is-new { animation: pp-swing 0.7s var(--ease-spring); }
@keyframes pp-swing {
  0% { transform: translateX(-50%) translateY(-14px) rotate(-5deg); opacity: 0; }
  60% { transform: translateX(-50%) translateY(2px) rotate(2deg); opacity: 1; }
  100% { transform: translateX(-50%); }
}

.pp-float {
  position: absolute; z-index: 2;
  font-family: var(--font-display); font-size: 1.375rem; line-height: 1; white-space: nowrap; color: var(--c-ink);
  text-shadow: 0 1px 0 var(--c-white), 0 0 8px rgba(255, 255, 255, 0.8);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: pp-float 0.85s var(--ease-out) forwards;
}
.pp-float--big { font-size: 1.75rem; color: var(--c-raspberry); }
@keyframes pp-float {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -70%) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

.pp-banner, .pp-keyhint {
  position: absolute; left: 50%; z-index: 3;
  max-width: calc(100% - 32px); width: max-content;
  padding: 9px 18px; border-radius: var(--r-pill);
  font-size: var(--fs-small); font-weight: 700; line-height: 1.35; text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}
.pp-banner { bottom: 18px; background: var(--c-shopfront); color: var(--c-paper); }
.pp-banner.is-in { animation: pp-rise 0.45s var(--ease-spring); }
.pp-keyhint { top: 60px; background: rgba(43, 27, 36, 0.82); color: var(--c-white); font-weight: 600; }
@keyframes pp-rise { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translateX(-50%); } }

.stage.is-paused .pp-field { opacity: 0.4; }

/* ---------- 4. Twist & Match ---------- */
.tm-pips { position: absolute; top: 14px; left: 50%; z-index: 2; display: flex; gap: 3px; margin: 0; padding: 0; list-style: none; transform: translateX(-50%); }
.tm-pips li { width: 10px; }
.tm-pips svg { display: block; width: 10px; height: 17.5px; color: var(--c-shopfront); transition: opacity var(--dur-2), transform var(--dur-2) var(--ease-spring); }
.tm-pips li.is-spent svg { opacity: 0.2; transform: translateY(3px) scale(0.7); }
.tm-pips.is-over svg { color: var(--c-ink-soft); }

.tm-board-wrap {
  position: absolute; inset: 0; overflow: hidden; border-radius: inherit;
  padding: 46px clamp(12px, 3%, 36px) clamp(12px, 3%, 28px);
  container-type: size;
}
.tm-board {
  --cols: 6; --rows: 4;
  --gap: clamp(6px, 1.5cqw, 16px);
  --cw: min((100cqw - (var(--cols) - 1) * var(--gap)) / var(--cols), (100cqh - (var(--rows) - 1) * var(--gap)) / var(--rows) * 0.8);
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cw));
  gap: var(--gap);
  justify-content: center; align-content: center;
  height: 100%;
}
@media (max-width: 700px) { .tm-board { --cols: 4; --rows: 6; } }
.stage.is-paused .tm-board { visibility: hidden; }

.tm-card {
  position: relative; display: block; width: var(--cw); aspect-ratio: 4 / 5;
  padding: 0; border-radius: 14px;
  perspective: 900px;
  container-type: inline-size;
  -webkit-tap-highlight-color: transparent;
}
.tm-card:focus { outline: none; }
.tm-card:focus-visible { outline: 3px solid var(--c-raspberry); outline-offset: 3px; }
.tm-card__inner {
  position: absolute; inset: 0; border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 0.5s var(--ease-out);
}
.tm-card.is-up .tm-card__inner, .tm-card.is-matched .tm-card__inner { transform: rotateY(180deg); }
@media (hover: hover) {
  .tm-card:not(.is-up):not(.is-matched):hover .tm-card__inner { transform: translateY(-4px); }
}
.tm-card__back, .tm-card__face {
  position: absolute; inset: 0; border-radius: inherit; overflow: hidden;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.tm-card__back {
  display: grid; place-items: center;
  background-color: var(--c-shopfront);
  background-image: radial-gradient(rgba(255, 250, 246, 0.09) 1.2px, transparent 1.4px);
  background-size: 12px 12px;
  box-shadow: inset 0 0 0 6px var(--c-shopfront), inset 0 0 0 7px rgba(255, 250, 246, 0.3);
}
.tm-card__back svg { width: 26%; height: auto; color: var(--c-on-dark-accent); }
.tm-card__face { aspect-ratio: auto; transform: rotateY(180deg); box-shadow: inset 0 0 0 1px rgba(43, 27, 36, 0.06); }
.tm-card__face img { position: absolute; inset: 0; }
.tm-card__name {
  position: absolute; left: 6%; right: 6%; bottom: 6%;
  padding: 3px 6px; border-radius: var(--r-pill);
  background: rgba(255, 250, 246, 0.94);
  font-size: clamp(10px, 11cqi, 15px); font-weight: 700; line-height: 1.25; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tm-card__check {
  position: absolute; top: -6px; right: -6px; z-index: 2;
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--c-success); color: var(--c-white); box-shadow: 0 0 0 2px var(--c-blush);
  opacity: 0; transform: scale(0.4);
  transition: opacity var(--dur-2), transform var(--dur-2) var(--ease-spring);
}
.tm-card__check .icon { width: 15px; height: 15px; stroke-width: 2.6; }
.tm-card.is-matched { cursor: default; animation: tm-bob 0.9s var(--ease-out) 0.25s; }
.tm-card.is-matched .tm-card__check { opacity: 1; transform: none; transition-delay: 0.35s; }
.tm-card.is-miss { animation: tm-wobble 0.42s ease-in-out 0.45s; }
.tm-board.is-dealing .tm-card { animation: tm-deal 0.5s var(--ease-spring) both; animation-delay: calc(var(--i) * 35ms); }
.tm-board.is-peeking .tm-card { cursor: progress; }
@keyframes tm-bob {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-10px) rotate(-1.5deg); }
  55% { transform: translateY(0); }
  75% { transform: translateY(-4px) rotate(1deg); }
}
@keyframes tm-wobble {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-3deg); }
  75% { transform: rotate(3deg); }
}
@keyframes tm-deal { from { opacity: 0; transform: translateY(16px) scale(0.9); } to { opacity: 1; transform: none; } }

/* ---------- 5. Prize shelf + tie-in ---------- */
.shelf__grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); }
.shelf__empty { padding-block: var(--s-6); }

.tiein__inner { display: grid; gap: clamp(28px, 4vw, 64px); align-items: center; }
@media (min-width: 900px) { .tiein__inner { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }
.tiein__text { display: grid; gap: var(--s-4); justify-items: start; }
.tiein__list { display: grid; padding: var(--s-2) var(--s-5); background: var(--c-paper); border-radius: var(--r-lg); }
.tiein__list .mini { padding-block: var(--s-4); }
.tiein__list .mini + .mini { border-top: 1px solid var(--c-line); }

/* ---------- 6. Small screens ---------- */
@media (max-width: 700px) {
  .prize-list { display: none; } /* the start screens carry the same goals + prizes, right above the Start button */
  /* 24 cards at phone width: smaller trim so the plate and its name still read. */
  .tm-card { border-radius: 10px; }
  .tm-card__back { box-shadow: inset 0 0 0 4px var(--c-shopfront), inset 0 0 0 5px rgba(255, 250, 246, 0.3); }
  .tm-card__back svg { width: 30%; }
  .tm-card__check { top: -5px; right: -5px; width: 20px; height: 20px; }
  .tm-card__check .icon { width: 12px; height: 12px; }
  /* Tiny cards: let the name take two lines rather than ellipsing the word that identifies the pair. */
  .tm-card__name {
    left: 4%; right: 4%; bottom: 5%; padding: 2px 4px;
    font-size: clamp(9px, 15cqi, 12px); line-height: 1.12;
    white-space: normal; overflow: hidden; text-overflow: clip;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  }
  .tm-pips { gap: 2px; }
  .tm-pips li, .tm-pips svg { width: 9px; }
  .tm-pips svg { height: 15.75px; }
}
@media (max-width: 560px) {
  .hud__stat--time, .hud__stat--opt { display: none; }
  .hud__peek { padding-inline: 0.75em; }
  .pp-target { top: 14px; padding: 4px 12px 4px 10px; gap: 6px; }
  .pp-target__label { display: none; }
  .tm-board-wrap { padding-top: 40px; }
  .tiein__list { padding-inline: var(--s-4); }
}
@media (max-width: 400px) {
  .screen .ticket__stub { padding-inline: var(--s-3); gap: var(--s-1); }
  .screen .ticket__stub .btn--sm { padding-inline: 0.8em; }
}
@media (max-width: 380px) {
  .hud__stats { gap: 12px; }
  .hud__peek { width: 44px; padding: 0; font-size: 0; gap: 0; }
  .hud__peek .icon { width: 1.25rem; height: 1.25rem; }
}

/* ---------- 7. Reduced motion: calmer, still playable ---------- */
@media (prefers-reduced-motion: reduce) {
  .pp-balloon.is-popping svg { animation: none !important; opacity: 0; }
  .pp-float { animation: none !important; transform: translate(-50%, -80%); }
  .tm-card__inner, .tm-card.is-up .tm-card__inner, .tm-card.is-matched .tm-card__inner { transform: none !important; }
  .tm-card__face { transform: none; opacity: 0; transition: opacity 0.25s ease !important; }
  .tm-card__back { transition: opacity 0.25s ease !important; }
  .tm-card.is-up .tm-card__face, .tm-card.is-matched .tm-card__face { opacity: 1; }
  .tm-card.is-up .tm-card__back, .tm-card.is-matched .tm-card__back { opacity: 0; }
  .tm-card.is-matched, .tm-card.is-miss, .tm-board.is-dealing .tm-card { animation: none !important; }
}
