/* CP-ENGAGE visual polish (candidate only). Loaded AFTER the protected styles.css and never edits it:
   golden premium layer, larger 3D tiles, and a rocket launch on genuine solves. The 17 approved
   @keyframes in styles.css are untouched; the rocket uses its own new keyframes below. */
:root {
  --cpg-gold: #E9B949;
  --cpg-gold-soft: #F6D98A;
  --cpg-gold-bright: #FFD45A;
  --cpg-gold-deep: #A8720E;
  --cpg-gold-line: rgba(233, 185, 73, 0.55);
}

/* ---- Golden premium page + card ---- */
body {
  background:
    radial-gradient(ellipse at 10% 8%, rgba(236, 72, 153, 0.55), transparent 46%),
    radial-gradient(ellipse at 94% 18%, rgba(108, 59, 255, 0.42), transparent 44%),
    radial-gradient(ellipse at 50% 0%, rgba(255, 212, 90, 0.55), transparent 42%),
    radial-gradient(ellipse at 50% 100%, #FFD98A, transparent 62%),
    linear-gradient(145deg, #6D367C, #F2A6C8 40%, #FFE3A8 78%, #FFF2D2);
}
.game {
  border: 2px solid transparent;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.98), transparent 55%) padding-box,
    linear-gradient(150deg, #FFF8F0, #FCE6EC 45%, #FFF0CF) padding-box,
    linear-gradient(140deg, #FFF1BF, var(--cpg-gold) 30%, #F3CF6A 55%, var(--cpg-gold-deep) 80%, #FFE7A0) border-box;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.6), inset 0 0 0 6px rgba(233, 185, 73, 0.25),
    0 12px 0 -6px #C9973A, 0 24px 60px -20px rgba(42, 27, 61, 0.5);
}
.eyebrow { color: #FFE7A0; } /* light gold on the dark eyebrow pill (≥4.5:1) */
.mode-badge, .phase-badge {
  border-color: var(--cpg-gold-line);
  background: linear-gradient(180deg, #FFFDF4, #FFF1C8);
  box-shadow: inset 0 1px 0 #FFFFFF, 0 2px 0 rgba(168, 114, 14, 0.25);
}
#cleared-count { color: #5A3D07; border-color: var(--cpg-gold); background: linear-gradient(180deg, #FFF6D6, #FFDF85); }
.stats div { border-color: var(--cpg-gold-line); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 3px 0 rgba(168, 114, 14, 0.35); }
.chapter-card { border-color: var(--cpg-gold-line); }
.pattern {
  border: 1.5px solid var(--cpg-gold-line);
  background: linear-gradient(180deg, rgba(255, 252, 240, 0.85), rgba(255, 238, 210, 0.7));
  box-shadow: inset 0 2px 0 #FFFFFF, inset 0 -6px 14px rgba(201, 151, 58, 0.18), 0 4px 0 rgba(201, 151, 58, 0.35);
}
.palette {
  border-color: var(--cpg-gold-line);
  background: linear-gradient(180deg, rgba(255, 253, 246, 0.7), rgba(255, 241, 214, 0.55));
}
.result.is-win {
  border: 2px solid var(--cpg-gold);
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 212, 90, 0.28), transparent 60%), linear-gradient(135deg, #502461, #2B193E);
  box-shadow: inset 0 1px 0 rgba(255, 241, 191, 0.5), 0 4px 0 #8C5F0A, 0 14px 26px -10px rgba(42, 27, 61, 0.6);
}
.result.is-win .result-title {
  background: linear-gradient(180deg, #FFF4C7, var(--cpg-gold-bright) 55%, #E9A82C);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---- Candy-style premium environment (BACKGROUND ONLY: tiles, slots and choices are not restyled here) ---- */
body {
  background:
    radial-gradient(ellipse 55% 42% at 50% 40%, rgba(255, 246, 222, 0.75), transparent 72%),
    radial-gradient(ellipse 45% 35% at 6% 4%, rgba(236, 72, 153, 0.75), transparent 70%),
    radial-gradient(ellipse 45% 38% at 96% 10%, rgba(124, 77, 255, 0.62), transparent 70%),
    radial-gradient(ellipse 50% 40% at 10% 96%, rgba(255, 190, 70, 0.7), transparent 70%),
    radial-gradient(ellipse 50% 40% at 92% 94%, rgba(219, 39, 119, 0.55), transparent 70%),
    linear-gradient(160deg, #4E2177 0%, #9B3596 26%, #E46BAE 52%, #FFB070 80%, #FFD98F 100%);
  background-attachment: fixed;
}
/* Phase wash kept, but lighter so the candy colours glow through. */
body[data-phase="curiosity"] .backdrop { background-color: rgba(253, 242, 248, 0.16); }
body[data-phase="discovery"] .backdrop { background-color: rgba(253, 243, 208, 0.16); }
body[data-phase="challenge"] .backdrop { background-color: rgba(237, 233, 254, 0.16); }
body[data-phase="mastery"] .backdrop { background-color: rgba(231, 250, 247, 0.16); }

.cpg-ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.cpg-ambient * { pointer-events: none; }
.cpg-light { position: absolute; left: 50%; top: 40%; width: min(1100px, 140vw); height: min(820px, 120vh); translate: -50% -50%;
  background: radial-gradient(ellipse at center, rgba(255, 250, 236, 0.85) 0%, rgba(255, 232, 196, 0.45) 38%, rgba(255, 210, 160, 0) 70%); }
.cpg-sheen { position: absolute; inset: -20% -10%;
  background:
    linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.16) 36%, transparent 42%),
    linear-gradient(115deg, transparent 58%, rgba(255, 255, 255, 0.1) 62%, transparent 66%); }
.cpg-vignette { position: absolute; inset: 0; background: radial-gradient(ellipse 85% 80% at 50% 45%, transparent 55%, rgba(48, 14, 70, 0.42) 100%); }
.cpg-orb { position: absolute; border-radius: 50%;
  box-shadow: inset -6px -10px 18px rgba(80, 20, 90, 0.35), inset 6px 8px 12px rgba(255, 255, 255, 0.55), 0 14px 26px -12px rgba(48, 14, 70, 0.5); }
.cpg-orb::after { content: ''; position: absolute; left: 22%; top: 14%; width: 34%; height: 24%; border-radius: 50%; background: rgba(255, 255, 255, 0.8); filter: blur(1px); }
.cpg-orb.o1 { left: 3%; top: 22%; width: 74px; height: 74px; background: radial-gradient(circle at 35% 30%, #FFC2E0, #EC4899 55%, #9D1C5E); }
.cpg-orb.o2 { right: 4%; top: 58%; width: 96px; height: 96px; background: radial-gradient(circle at 35% 30%, #E2D4FF, #8A5CFF 55%, #4C278F); }
.cpg-orb.o3 { left: 6%; bottom: 8%; width: 58px; height: 58px; background: radial-gradient(circle at 35% 30%, #FFF4C7, #F6C94C 55%, #B07A12); }
.cpg-orb.o4 { right: 9%; top: 9%; width: 44px; height: 44px; background: radial-gradient(circle at 35% 30%, #FFE0C2, #FB923C 55%, #C2410C); }
.cpg-ring { position: absolute; left: 50%; top: 40%; width: min(980px, 130vw); aspect-ratio: 1; translate: -50% -50%; border-radius: 50%;
  border: 1.5px dashed rgba(255, 231, 160, 0.35); }
.cpg-star { position: absolute; color: #FFE7A0; line-height: 1; text-shadow: 0 0 8px rgba(255, 212, 90, 0.85), 0 0 18px rgba(255, 180, 60, 0.45);
  animation: cpg-twinkle 2.6s ease-in-out 6 alternate both; }
.cpg-star.s1 { left: 9%; top: 12%; font-size: 22px; }
.cpg-star.s2 { right: 14%; top: 26%; font-size: 16px; animation-delay: 0.6s; }
.cpg-star.s3 { left: 13%; top: 64%; font-size: 14px; animation-delay: 1.2s; }
.cpg-star.s4 { right: 7%; bottom: 14%; font-size: 24px; animation-delay: 0.3s; }
.cpg-star.s5 { left: 46%; top: 3%; font-size: 12px; animation-delay: 0.9s; }
.cpg-star.s6 { left: 30%; bottom: 3%; font-size: 14px; animation-delay: 1.5s; }
@keyframes cpg-twinkle { from { opacity: 0.55; scale: 0.9; } to { opacity: 1; scale: 1.08; } }
@media (max-width: 600px) {
  .cpg-orb.o1 { width: 48px; height: 48px; left: -10px; }
  .cpg-orb.o2 { width: 60px; height: 60px; right: -14px; }
  .cpg-orb.o3 { width: 40px; height: 40px; left: -8px; }
  .cpg-orb.o4 { width: 32px; height: 32px; right: -6px; }
}

/* Board backdrop: layered glossy card with golden edge highlights (card + panels only). */
.game {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 18%) padding-box,
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(255, 255, 255, 0.95), transparent 60%) padding-box,
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(255, 214, 150, 0.45), transparent 70%) padding-box,
    linear-gradient(150deg, #FFF9F2, #FDE8F0 45%, #FFF1D6) padding-box,
    linear-gradient(140deg, #FFF1BF, var(--cpg-gold) 28%, #FFF4CF 46%, #E9B949 62%, var(--cpg-gold-deep) 82%, #FFE7A0) border-box;
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.6), inset 0 0 0 6px rgba(233, 185, 73, 0.3), inset 0 -14px 30px rgba(201, 151, 58, 0.12),
    0 12px 0 -6px #B9893A, 0 26px 60px -18px rgba(48, 14, 70, 0.6), 0 0 0 1px rgba(255, 241, 191, 0.4);
}
.pattern {
  border: 1.5px solid rgba(233, 185, 73, 0.7);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 30%),
    linear-gradient(180deg, #FFFCF2, #FFEFD6);
  box-shadow: inset 0 2px 0 #FFFFFF, inset 0 -8px 16px rgba(201, 151, 58, 0.2), 0 5px 0 rgba(201, 151, 58, 0.45), 0 14px 22px -12px rgba(74, 30, 83, 0.35);
}
.palette {
  border: 1.5px solid rgba(233, 185, 73, 0.6);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 30%), linear-gradient(180deg, #FFFDF6, #FFF2DE);
  box-shadow: inset 0 2px 0 #FFFFFF, inset 0 -6px 12px rgba(201, 151, 58, 0.14), 0 4px 0 rgba(201, 151, 58, 0.3);
}

/* ---- Premium arcade-toy 3D tiles (slots + palette choices), ~15% larger ---- */
.slot { width: 82px; height: 82px; border-radius: 20px; }
.tile:not(:where(.m-wrong, .deny)), .choice {
  position: relative;
  border: 2px solid #FFFFFF;
  background:
    radial-gradient(ellipse 85% 55% at 50% 0%, rgba(255, 255, 255, 1), transparent 70%),
    radial-gradient(ellipse 70% 40% at 50% 105%, rgba(255, 212, 90, 0.28), transparent 70%),
    linear-gradient(165deg, #FFFFFF 0%, #FFF4F9 38%, #F1DEEE 74%, #DFC2DD 100%);
  box-shadow:
    inset 0 3px 0 #FFFFFF,
    inset 0 -7px 10px rgba(120, 70, 140, 0.26),
    inset 0 0 0 1.5px rgba(233, 185, 73, 0.55),
    inset 4px 0 6px -4px rgba(255, 255, 255, 0.9),
    0 6px 0 #B98CB4,
    0 8px 0 rgba(168, 114, 14, 0.45),
    0 18px 18px -8px rgba(74, 30, 83, 0.5);
}
.tile:not(:where(.m-wrong, .deny))::after, .choice::after {
  content: '';
  position: absolute;
  top: 4px; left: 10%; right: 10%; height: 36%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0));
  pointer-events: none;
}
/* Vivid, clearly separated colours (same hues/names; shape + letter mark unchanged) */
.face { position: relative; z-index: 1; filter: saturate(1.35) contrast(1.12) drop-shadow(0 2px 0 rgba(42, 27, 61, 0.3)) drop-shadow(0 4px 4px rgba(42, 27, 61, 0.22)); }
.tile.locked {
  border-color: #14B8A6;
  box-shadow: inset 0 3px 0 #FFFFFF, inset 0 -7px 10px rgba(11, 140, 128, 0.2), inset 0 0 0 1.5px rgba(233, 185, 73, 0.6),
    0 6px 0 #0B8C80, 0 8px 0 rgba(168, 114, 14, 0.35), 0 18px 18px -8px rgba(74, 30, 83, 0.45);
}
/* Inviting destination slots: recessed well with gold/pink 3D edging (no hint of the answer) */
.socket {
  border: 2px dashed rgba(168, 114, 14, 0.6);
  background:
    radial-gradient(ellipse 70% 60% at 50% 40%, rgba(255, 255, 255, 0.95), transparent 75%),
    linear-gradient(180deg, rgba(255, 246, 222, 0.95), rgba(255, 228, 236, 0.85));
  box-shadow: inset 0 4px 8px rgba(168, 114, 14, 0.22), inset 0 -2px 0 rgba(255, 255, 255, 0.9), 0 2px 0 rgba(236, 72, 153, 0.25);
}
.socket.selected {
  border: 2.5px solid var(--wp-pink-deep);
  background: radial-gradient(ellipse 70% 60% at 50% 40%, #FFFFFF, rgba(255, 238, 245, 0.95) 80%);
  box-shadow: inset 0 4px 8px rgba(190, 24, 93, 0.16), 0 0 0 4px rgba(255, 212, 90, 0.45), 0 3px 0 rgba(168, 114, 14, 0.4);
}
.choice { min-width: 124px; min-height: 120px; border-radius: 22px; }
.choice .face { width: 58px; height: 58px; }
/* Premium 3D symbols: ~23% larger in total (tighter SVG viewBox in app.ts + this face size); tile boxes unchanged. */
.tile .face, .cpg-flier .face { width: 75%; height: 75%; }
@media (hover: hover) {
  .choice:hover:not(:disabled) { transform: translateY(-3px); box-shadow: inset 0 3px 0 #FFFFFF, inset 0 -7px 10px rgba(120, 70, 140, 0.26), inset 0 0 0 1.5px rgba(233, 185, 73, 0.8), 0 9px 0 #B98CB4, 0 11px 0 rgba(168, 114, 14, 0.5), 0 22px 20px -8px rgba(74, 30, 83, 0.5); }
}
@media (max-width: 600px) {
  .slot { width: 66px; height: 66px; border-radius: 17px; }
  .choice { min-width: 0; min-height: 118px; } /* keep the original 3-per-row phone layout */
  .choice .face { width: 54px; height: 54px; }
}
@media (max-width: 359px) {
  .slot { width: 60px; height: 60px; border-radius: 15px; }
  .choice .face { width: 47px; height: 47px; }
}
@media (max-width: 480px) and (max-height: 640px) {
  .slot { width: 52px; height: 52px; }
  .choice { min-width: 52px; min-height: 60px; }
  .choice .face { width: 36px; height: 36px; }
}

/* ---- Accepted-tile flight (Web Animations API drives the transform) ---- */
.cpg-flier {
  position: fixed; left: 0; top: 0; z-index: 25;
  width: 82px; height: 82px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #FFF6D6; border-radius: 20px;
  background: radial-gradient(ellipse 85% 55% at 50% 0%, #FFFFFF, transparent 70%), linear-gradient(165deg, #FFFFFF, #FFF1D2 60%, #F6D98A);
  box-shadow: inset 0 3px 0 #FFFFFF, inset 0 -6px 10px rgba(168, 114, 14, 0.28), 0 6px 0 #C9973A, 0 0 0 3px rgba(255, 212, 90, 0.55), 0 18px 22px -8px rgba(74, 30, 83, 0.5);
  pointer-events: none; will-change: transform;
}

.cpg-trail {
  position: fixed; left: 0; top: 0; z-index: 24;
  width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: radial-gradient(circle, #FFFBE6 0, #FFD45A 45%, rgba(236, 72, 153, 0) 72%);
  pointer-events: none; opacity: 0;
}
.tile.cpg-awaiting { visibility: hidden; }
.tile.cpg-landed { animation: cpg-land 480ms cubic-bezier(0.34, 1.56, 0.64, 1) 1; }
@keyframes cpg-land {
  0% { transform: translateY(5px) scale(0.86); box-shadow: 0 0 0 0 rgba(255, 212, 90, 0.95), 0 6px 0 #0B8C80; }
  45% { transform: translateY(-4px) scale(1.08); box-shadow: 0 0 0 7px rgba(255, 212, 90, 0.55), 0 6px 0 #0B8C80; }
  100% { transform: none; box-shadow: 0 0 0 0 rgba(255, 212, 90, 0), 0 6px 0 #0B8C80; }
}
@media (max-width: 600px) { .cpg-flier { width: 66px; height: 66px; border-radius: 17px; } }

/* ---- Difficulty: visible selected state (aria-pressed already set by the app) ---- */
#difficulty-easy[aria-pressed="true"], #difficulty-medium[aria-pressed="true"], #difficulty-hard[aria-pressed="true"] {
  border-color: var(--cpg-gold);
  box-shadow: inset 0 0 0 2px rgba(255, 212, 90, 0.85), 0 4px 0 var(--cpg-gold-deep);
}
@media (max-width: 600px) { [id^="difficulty-"] { white-space: nowrap; padding-left: 10px; padding-right: 10px; } }

/* ---- Rocket launch on a genuine solve ---- */
.rocket-stage { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; visibility: hidden; }
.rocket-stage.launch { visibility: visible; }
.rocket { position: absolute; left: 84%; bottom: -120px; width: 64px; height: 120px; margin-left: -32px; }
.rocket svg { width: 64px; height: 96px; display: block; filter: drop-shadow(0 6px 8px rgba(42, 27, 61, 0.35)); }
.rocket-flame { position: absolute; left: 50%; top: 84px; width: 22px; height: 34px; margin-left: -11px; border-radius: 50% 50% 50% 50% / 30% 30% 70% 70%;
  background: radial-gradient(ellipse at 50% 20%, #FFFBE6, #FFD45A 40%, #F59E0B 70%, rgba(236, 72, 153, 0) 100%); }
.rocket-trail { position: absolute; left: 50%; top: 104px; width: 10px; height: 160px; margin-left: -5px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 212, 90, 0.9), rgba(236, 72, 153, 0.45) 45%, rgba(255, 255, 255, 0)); }
.rocket-spark { position: absolute; width: 12px; height: 12px; color: var(--cpg-gold-bright); font-size: 14px; line-height: 12px; opacity: 0; }
.rocket-stage.launch .rocket { animation: cpg-rocket-rise 1500ms cubic-bezier(0.45, 0, 0.2, 1) 1 both; }
.rocket-stage.launch .rocket-flame { animation: cpg-flame-flicker 120ms ease-in-out 12 alternate; }
.rocket-stage.launch .rocket-spark { animation: cpg-spark 900ms ease-out 1 both; }
.rocket-stage.launch .s1 { left: 76%; bottom: 18%; animation-delay: 300ms; }
.rocket-stage.launch .s2 { left: 90%; bottom: 30%; animation-delay: 480ms; }
.rocket-stage.launch .s3 { left: 79%; bottom: 46%; animation-delay: 650ms; }
.rocket-stage.launch .s4 { left: 88%; bottom: 62%; animation-delay: 820ms; }
@keyframes cpg-rocket-rise {
  0% { transform: translate(0, 0) rotate(-6deg); opacity: 0; }
  12% { opacity: 1; }
  70% { transform: translate(-10px, -78vh) rotate(-3deg); opacity: 1; }
  100% { transform: translate(-16px, -118vh) rotate(-5deg); opacity: 0; }
}
@keyframes cpg-flame-flicker { from { transform: scaleY(0.85); } to { transform: scaleY(1.15); } }
@keyframes cpg-spark { 0% { opacity: 0; transform: scale(0.4); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-40px) scale(1.2); } }

/* Phones: a smaller rocket flies in the right margin so it never crosses the puzzle tiles. */
@media (max-width: 600px) {
  .rocket { left: auto; right: -22px; margin-left: 0; scale: 0.42; transform-origin: 50% 100%; }
  .rocket-stage.launch .s1, .rocket-stage.launch .s2, .rocket-stage.launch .s3, .rocket-stage.launch .s4 { left: auto; right: 4px; }
}

/* Reduced motion: no flight. A small static golden rocket badge appears briefly near the result. */
@media (prefers-reduced-motion: reduce) {
  .rocket-stage.launch .rocket, .rocket-stage.launch .rocket-flame, .rocket-stage.launch .rocket-spark { animation: none !important; }
  .rocket-stage.launch .rocket { bottom: 18vh; transform: none; opacity: 1; }
  .rocket-stage .rocket-trail, .rocket-stage .rocket-spark { display: none; }
  .choice:hover:not(:disabled) { transform: none; }
  .tile.cpg-landed { animation: none !important; }
  .cpg-flier, .cpg-trail { display: none; }
  .cpg-star { animation: none !important; opacity: 0.85; }
}

/* ---- Practice stages: progress bar, auto-advance controls, all-stages-complete panel ---- */
.cpg-stagebar {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 14px;
  width: 100%; padding: 12px 16px; border: 1.5px solid rgba(233, 185, 73, 0.7); border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 22%), linear-gradient(135deg, #4A2366, #2B193E); /* subtle gloss: keeps text ≥4.5:1 */
  color: #FFF4D6; box-shadow: inset 0 1px 0 rgba(255, 241, 191, 0.5), 0 4px 0 #8C5F0A, 0 12px 18px -10px rgba(48, 14, 70, 0.6);
}
.cpg-stage-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.cpg-stage-head strong { text-shadow: 0 1px 0 rgba(20, 6, 30, 0.6); color: #FFE7A0; font-size: 1.05rem; font-weight: 900; letter-spacing: 0.01em; }
.cpg-stage-head span { color: #F7E8FF; font-size: 0.9rem; font-weight: 700; }
.cpg-pips { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cpg-pips span { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35); }
.cpg-pips span.on { background: linear-gradient(180deg, #FFF1BF, #F6C94C 55%, #D49A1E); box-shadow: inset 0 1px 0 #FFFFFF, 0 0 0 1px rgba(255, 212, 90, 0.4); }
.cpg-stage-controls { grid-row: 1; grid-column: 2; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; min-width: 0; }
.cpg-auto { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px; color: #FFF4D6; font-weight: 800; font-size: 0.875rem; cursor: pointer; }
.cpg-auto input { width: 20px; height: 20px; accent-color: #E9B949; }
.cpg-stage-controls .btn { min-height: 44px; }
.cpg-stage-note { grid-column: 1 / -1; margin: 0; color: #FFF4D6; font-size: 0.875rem; font-weight: 700; }
.cpg-stage-note:empty { display: none; }
.cpg-stages-done {
  width: 100%; padding: 18px; border: 2px solid #E9B949; border-radius: 22px; text-align: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 212, 90, 0.3), transparent 60%), linear-gradient(135deg, #502461, #2B193E);
  color: #FFF1FA; box-shadow: 0 4px 0 #8C5F0A, 0 14px 26px -10px rgba(42, 27, 61, 0.6);
}
.cpg-stages-done[hidden] { display: none; }
.cpg-done-title { margin: 0 0 6px; color: #FFE7A0; font-size: 1.4rem; font-weight: 900; }
.cpg-done-text { margin: 0 0 12px; color: #FFF1FA; font-size: 0.9rem; }
#stage-next[hidden], #stage-pause[hidden] { display: none; }
@media (max-width: 600px) {
  .cpg-stagebar { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .cpg-stage-controls { grid-row: auto; grid-column: 1; justify-content: space-between; }
}

/* ---- Puzzles 1–4: compact glossy "Correct!" badge (over the pattern area, never over controls) ---- */
.cpg-success {
  position: absolute; left: 50%; top: -6px; z-index: 4; translate: -50% 0;
  display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 22px 9px; border: 2px solid #E9B949; border-radius: 999px;
  background: radial-gradient(ellipse 80% 70% at 50% 0%, rgba(255, 255, 255, 0.35), transparent 70%), linear-gradient(135deg, #DB2777, #8A3FD1);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), inset 0 -3px 6px rgba(60, 10, 70, 0.35), 0 4px 0 #8C5F0A, 0 12px 20px -8px rgba(48, 14, 70, 0.6);
  color: #FFFFFF; text-align: center; pointer-events: none; white-space: nowrap;
}
.cpg-success[hidden] { display: none; }
.cpg-success-title { font-size: 1.15rem; font-weight: 900; letter-spacing: 0.01em; text-shadow: 0 1px 0 rgba(60, 10, 70, 0.6); }
.cpg-success-text { font-size: 0.85rem; font-weight: 800; color: #FFF1BF; }
.cpg-success.show { animation: cpg-pop 320ms cubic-bezier(0.34, 1.56, 0.64, 1) 1 both; }
@keyframes cpg-pop { from { scale: 0.6; opacity: 0; } to { scale: 1; opacity: 1; } }

/* ---- Fifth puzzle: grand Stage Complete celebration ---- */
.cpg-celebrate {
  position: fixed; left: 50%; top: 50%; z-index: 28; translate: -50% -50%;
  width: min(520px, calc(100vw - 32px)); padding: 22px 22px 20px; text-align: center;
  border: 3px solid transparent; border-radius: 28px;
  background:
    radial-gradient(ellipse 80% 45% at 50% 0%, rgba(255, 212, 90, 0.4), transparent 70%) padding-box,
    linear-gradient(160deg, #5A2470, #2B193E 70%) padding-box,
    linear-gradient(140deg, #FFF1BF, #E9B949 35%, #A8720E 65%, #FFE7A0) border-box;
  box-shadow: inset 0 2px 0 rgba(255, 241, 191, 0.4), 0 8px 0 #8C5F0A, 0 30px 60px -10px rgba(30, 8, 45, 0.7);
  color: #FFF1FA; animation: cpg-celebrate-in 520ms cubic-bezier(0.34, 1.56, 0.64, 1) 1 both;
}
.cpg-celebrate[hidden] { display: none; }
.cpg-celebrate-kicker { margin: 0; color: #FFE7A0; letter-spacing: 0.5em; font-size: 0.9rem; }
.cpg-celebrate-title { margin: 4px 0 6px; font-size: clamp(1.7rem, 6vw, 2.4rem); font-weight: 900; color: #FFE7A0; text-shadow: 0 2px 0 #6B3A0A, 0 4px 10px rgba(0, 0, 0, 0.35); }
.cpg-celebrate-count { margin: 0; font-size: 1.1rem; font-weight: 900; color: #FFFFFF; }
.cpg-celebrate-streak { display: inline-block; margin: 10px 0 4px; padding: 6px 14px; border-radius: 999px; background: linear-gradient(180deg, #FFF1BF, #F6C94C 60%, #D49A1E); color: #3B2604; font-weight: 900; box-shadow: inset 0 1px 0 #FFFFFF, 0 3px 0 #8C5F0A; }
.cpg-celebrate-next { margin: 8px 0 2px; font-weight: 800; color: #FFF1FA; }
.cpg-celebrate-note { margin: 0 0 14px; font-size: 0.8rem; color: #F3DDF2; }
.cpg-celebrate .btn { min-height: 44px; }
@keyframes cpg-celebrate-in { from { scale: 0.7; opacity: 0; } to { scale: 1; opacity: 1; } }

/* ---- Confetti pieces (Web Animations API positions them; finite) ---- */
.cpg-confetti-layer { position: fixed; inset: 0; z-index: 31; overflow: hidden; pointer-events: none; }
.cpg-confetti { position: fixed; left: 0; top: 0; z-index: 31; width: 9px; height: 13px; margin: -6px 0 0 -4px; border-radius: 2px; pointer-events: none; }
.cpg-confetti.gold { width: 10px; height: 10px; border-radius: 50%; }
.cpg-confetti.c0 { background: #EC4899; } .cpg-confetti.c1 { background: #F6C94C; } .cpg-confetti.c2 { background: #8A62FF; }
.cpg-confetti.c3 { background: #14B8A6; } .cpg-confetti.c4 { background: #FFE7A0; } .cpg-confetti.c5 { background: #E9B949; }
.cpg-confetti.gold.c0, .cpg-confetti.gold.c2 { background: radial-gradient(circle at 35% 30%, #FFFFFF, #F6C94C 55%, #B07A12); }

@media (prefers-reduced-motion: reduce) {
  .cpg-success.show, .cpg-celebrate { animation: none !important; }
  .cpg-confetti { display: none; }
}

/* Compact practice controls and board-local feedback. */
.cp-ui #round[hidden] { display: none; }
.cp-ui .cpg-stagebar { padding: 8px 10px; gap: 4px 10px; }
.cp-ui .cpg-stage-head { gap: 2px 8px; }
.cp-ui .cpg-stage-head strong { font-size: 0.9rem; }
.cp-ui .cpg-stage-head span, .cp-ui .cpg-stage-note { font-size: 0.75rem; }
.cp-stage-track {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.cp-stage-track li {
  display: grid;
  place-items: center;
  width: min(100%, 30px);
  aspect-ratio: 1;
  border: 1px solid #c29cdb;
  border-radius: 50%;
  background: #422656;
  color: #fff4ff;
  font-size: 0.75rem;
  font-weight: 800;
}
.cp-stage-track li.is-complete { background: #784e90; border-color: #ffe299; }
.cp-stage-track li[aria-current="step"] {
  background: linear-gradient(#fff5ca, #f7c848);
  color: #381e42;
  border-color: #fff4c6;
  box-shadow: 0 2px 0 #ad7721;
}
.cp-ui .cpg-pips span { height: 4px; }
.cp-ui .cpg-auto { font-size: 0.75rem; }
.cp-ui .stage { isolation: isolate; }
/* The drag guide lives inside the isolated board but starts over a palette tile below it: lift the board above the palette while it plays. */
.cp-ui .stage:has(> .cp-drag-demo:not([hidden])) { z-index: 7; }
.cp-ui .stage .result.is-win:not([hidden]),
.cp-ui .stage .cpg-success:not([hidden]),
.cp-ui .stage .cpg-celebrate:not([hidden]) {
  position: absolute;
  inset: auto auto 50% 50%;
  translate: -50% 50%;
  width: max-content;
  max-width: calc(100% - 16px);
  z-index: 5;
  padding: 8px 12px;
  border: 1.5px solid #f1cc65;
  border-radius: 16px;
  background: linear-gradient(150deg, #542969, #271737);
  color: #fff4de;
  text-align: center;
  animation: cp-board-popup 180ms cubic-bezier(.2,.65,.3,1) both;
}
.cp-ui .stage:has(.cpg-celebrate:not([hidden])) { min-height: 205px; }
.cp-ui .stage .cpg-celebrate-title { font-size: 1.05rem; }
.cp-ui .stage .cpg-celebrate .result-actions { gap: 4px; }
.cp-ui .stage .result.is-win .result-title { font-size: 0.95rem; }
.cp-ui .stage .result.is-win .result-explain { font-size: 0.75rem; }
.cp-ui .stage .cpg-success-title { color: #ffe284; }
.cp-ui #cp-board-next { pointer-events: auto; min-height: 44px; }
.cp-drag-tip { margin: 0; color: #48284e; font-size: 0.8rem; text-align: center; }
.cp-drag-demo {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 6;
  width: 0;
  height: 0;
  pointer-events: none;
}
.cp-drag-demo .face { position: absolute; width: var(--cp-guide-tile-size, 32px); height: var(--cp-guide-tile-size, 32px); translate: -50% -50%; }
.cp-drag-demo > span:last-child { position: absolute; left: -8px; top: 2px; font-size: clamp(2.6rem, 10vw, 3rem); line-height: 1; filter: drop-shadow(0 2px 2px #2b193e70); }
.cp-drag-demo:not([hidden]) > span:last-child { animation: cp-guide-hand 1850ms ease-out 2; }
@keyframes cp-guide-hand {
  0%, 70% { transform: translate(0, 0); opacity: 1; }
  88%, 100% { transform: translate(9px, 12px); opacity: 0; }
}
@keyframes cp-board-popup { from { opacity: 0; transform: translateY(7px); } }

@media (max-width: 600px) {
  .cp-ui .game { padding-top: 12px; gap: 8px; }
  .cp-ui .game-header .eyebrow,
  .cp-ui .game-header .mode-badge,
  .cp-ui .game-header #phase-badge,
  .cp-ui .game-header .demo-note { display: none; }
  .cp-ui #game-title { margin-top: 0; font-size: clamp(1.75rem, 7vw, 2.4rem); }
  .cp-ui .lab-name { margin: 4px auto 0; padding: 3px 10px; font-size: 0.8rem; }
  .cp-ui .header-meta { margin-top: 4px; }
  .cp-ui .cpg-stagebar { grid-template-columns: minmax(0, 1fr) auto; }
  .cp-ui .cpg-stage-controls { grid-row: 1; grid-column: 2; justify-content: flex-end; gap: 4px; }
  .cp-ui .cpg-auto { gap: 4px; padding: 0; }
  .cp-ui .cpg-auto input { width: 16px; height: 16px; margin: 0; }
  .cp-ui .cpg-stage-controls .btn { padding-inline: 6px; font-size: 0.75rem; }
  .cp-ui .stage { padding: 8px; }
  .cp-ui .pattern, .cp-ui .palette { gap: 7px; padding: 8px; }
  .cp-ui .slot { width: clamp(44px, 12vw, 52px); height: clamp(44px, 12vw, 52px); }
  .cp-ui .choice { min-height: 64px; padding-block: 5px; }
}
/* Compact bottom selection palette on phones: four ~64x64 tile buttons in one row, 28px icons, visible labels.
   Palette only; the puzzle board (.pattern/.slot) and score cards keep their own sizes. */
@media (max-width: 600px) {
  .cp-ui .palette { flex-wrap: wrap; justify-content: center; gap: 8px; padding: 8px 6px; }
  .cp-ui .palette .choice {
    flex: 0 0 64px; width: 64px; min-width: 44px; height: 64px; min-height: 44px;
    padding: 4px 2px 3px; gap: 2px; border-radius: 16px; justify-content: center;
  }
  .cp-ui .palette .choice .face { width: 28px; height: 28px; flex: none; }
  /* Letter mark beside the icon (not under it) so it never covers the label text. */
  .cp-ui .palette .choice .mark { right: -13px; bottom: 0; min-width: 14px; height: 14px; padding: 0 2px; border-radius: 7px; font-size: 9px; line-height: 12px; }
  .cp-ui .palette .choice-label {
    position: static; width: auto; height: auto; max-width: 100%; clip: auto; overflow: hidden; white-space: normal;
    font-size: 0.625rem; line-height: 1.15; font-weight: 800; text-align: center; overflow-wrap: normal; word-break: normal;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  }
}
@media (max-width: 359px) {
  .cp-ui .palette { gap: 5px; padding: 8px 4px; }
  /* Keep the 64px height so the two-line label (2 x 10px x 1.15) has room for descenders (g, q, y). */
  .cp-ui .palette .choice { flex-basis: 60px; width: 60px; height: 64px; padding-inline: 1px; }
}
@media (prefers-reduced-motion: reduce) {
  .cp-drag-demo { display: none !important; }
  .cp-ui .stage .result.is-win:not([hidden]),
  .cp-ui .stage .cpg-success:not([hidden]),
  .cp-ui .stage .cpg-celebrate:not([hidden]) { animation: none; }
}


/* ==== CP-COMBINED-01 additions (client/combined.css) ==== */
/* CP-COMBINED-01: board-layout additions only, appended after the approved 4520 engagement.css (unchanged above).
   The approved tile, socket, palette, label, button and panel styles are reused as-is; this file only lays the 1–3
   rows of 5 out as a grid that fits a 320px phone, and sizes the 3-stage track. */
.cp-ui .pattern.cp-board {
  --cp-gap: 8px;
  --cp-cell: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--cp-gap);
  container-type: inline-size;
}
.cp-ui .cp-board .cp-row {
  display: flex;
  justify-content: center;
  gap: var(--cp-gap);
  width: 100%;
}
.cp-ui .cp-board .slot {
  flex: none;
  width: min(var(--cp-cell), calc((100cqi - 4 * var(--cp-gap)) / 5));
  height: auto;
  aspect-ratio: 1;
}
@media (max-width: 600px) {
  .cp-ui .pattern.cp-board { --cp-gap: 6px; --cp-cell: 54px; padding: 8px 6px; }
  .cp-ui .cp-board .slot { border-radius: 14px; }
}
@media (max-width: 359px) {
  .cp-ui .pattern.cp-board { --cp-gap: 5px; padding: 7px 4px; }
  .cp-ui .cp-board .slot { border-radius: 12px; }
}
/* CP-GLASS-UI — owner-approved compact liquid-glass layout (model: color-puzzle-glass-review, approved 2026-11-19).
   Glass, thin gold edges and soft glow are on PANELS ONLY; button surfaces keep the approved styles (AGENTS.md D-023).
   Targets: levels panel 70–76px; Level/Round + controls 52–56px on desktop (buttons ≥44px; controls wrap to a second
   line on phones); counter cards 60–64px, labels 12–13px, numbers ~24px, one row at 320/390px. */
.cp-ui {
  --cp-glass-edge: linear-gradient(135deg, rgba(255, 241, 191, 0.95), rgba(233, 185, 73, 0.9) 40%, rgba(255, 226, 153, 0.75) 70%, rgba(201, 148, 52, 0.9));
}
.cp-ui .cp-glass {
  position: relative;
  isolation: isolate;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 20px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.72), rgba(255, 238, 248, 0.42) 52%, rgba(240, 226, 255, 0.5)) padding-box,
    var(--cp-glass-edge) border-box;
  -webkit-backdrop-filter: blur(14px) saturate(1.45);
  backdrop-filter: blur(14px) saturate(1.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(233, 185, 73, 0.35),
    0 0 0 1px rgba(255, 231, 160, 0.18),
    0 0 16px -4px rgba(246, 201, 76, 0.45),
    0 10px 22px -14px rgba(108, 59, 255, 0.5);
  color: #2A1B3D;
}
.cp-ui .cp-glass::before {
  content: '';
  position: absolute; z-index: -1; inset: 1px 1px 52% 1px;
  border-radius: 19px 19px 50% 50% / 19px 19px 12px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.cp-ui .cp-glass-dark {
  background:
    linear-gradient(160deg, rgba(110, 52, 150, 0.82), rgba(60, 30, 90, 0.78) 55%, rgba(43, 25, 62, 0.84)) padding-box,
    var(--cp-glass-edge) border-box;
  color: #FFF4D6;
}
.cp-ui .cp-glass-dark::before { background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0)); }

/* 1. Levels panel: 1 + 6 + 44 (levels) + 4 + 6 (round indicators) + 8 + 1 = 70px */
.cp-ui .cp-levels { padding: 6px 0 8px; }
.cp-ui .cp-strip-wrap { position: relative; }
.cp-ui .cp-strip-wrap::before, .cp-ui .cp-strip-wrap::after {
  content: ''; position: absolute; z-index: 2; top: 0; bottom: 0; width: 22px; pointer-events: none; opacity: 0; transition: opacity 160ms;
}
.cp-ui .cp-strip-wrap::before { left: 0; border-radius: 19px 0 0 19px; background: linear-gradient(90deg, rgba(60, 30, 90, 0.95), rgba(60, 30, 90, 0)); }
.cp-ui .cp-strip-wrap::after { right: 0; border-radius: 0 19px 19px 0; background: linear-gradient(270deg, rgba(60, 30, 90, 0.95), rgba(60, 30, 90, 0)); }
.cp-ui .cp-strip-wrap.fade-left::before, .cp-ui .cp-strip-wrap.fade-right::after { opacity: 1; }
.cp-ui .cp-strip {
  position: relative;
  display: flex; gap: 4px;
  margin: 0; padding: 0 10px; list-style: none;
  overflow-x: auto; overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: none; /* no snapping: manual scrolling is never pulled back */
  scrollbar-width: none;
  touch-action: pan-x pan-y;
  cursor: grab;
}
.cp-ui .cp-strip::-webkit-scrollbar { display: none; }
.cp-ui .cp-strip.is-dragging { cursor: grabbing; user-select: none; }
/* Few levels fit without scrolling (desktop): keep them centred. */
.cp-ui .cp-strip > li:first-child { margin-left: auto; }
.cp-ui .cp-strip > li:last-child { margin-right: auto; }
.cp-ui .cp-strip li { flex: none; }
.cp-ui .cp-level {
  position: relative;
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%; background: none; color: inherit; font: inherit; cursor: pointer;
}
.cp-ui .cp-level-num {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 1.5px solid #C29CDB; border-radius: 50%;
  background: #422656; color: #FFF4FF;
  font-size: 0.95rem; font-weight: 800;
}
.cp-ui .cp-level.is-complete .cp-level-num { background: #784E90; border-color: #FFE299; }
.cp-ui .cp-level.is-complete:not([aria-current])::after {
  content: '✓'; position: absolute; right: 1px; bottom: 1px;
  display: grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  background: #0B8C80; color: #FFFFFF; font-size: 9px; font-weight: 900;
}
.cp-ui .cp-level[aria-current="step"] { cursor: default; }
.cp-ui .cp-level[aria-current="step"] .cp-level-num {
  width: 40px; height: 40px;
  border-color: #FFF4C6; background: linear-gradient(#FFF5CA, #F7C848); color: #381E42;
  box-shadow: 0 2px 0 #AD7721, 0 0 0 3px rgba(255, 231, 160, 0.28);
}
.cp-ui .cp-level.is-locked { cursor: not-allowed; }
.cp-ui .cp-level.is-locked .cp-level-num { border-style: dashed; border-color: rgba(194, 156, 219, 0.75); background: #33203F; color: rgba(255, 244, 255, 0.62); }
.cp-ui .cp-level.is-locked::after { content: '🔒'; position: absolute; right: 0; bottom: 0; font-size: 11px; line-height: 1; }
.cp-ui .cp-level:focus-visible { outline: none; }
.cp-ui .cp-level:focus-visible .cp-level-num { outline: 3px solid #FFE7A0; outline-offset: 1px; }
/* three round indicators: solved = gold, round in play (or just completed) = ringed */
.cp-ui .cp-levels .cpg-pips.cp-round-pips { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }
.cp-ui .cp-levels .cpg-pips.cp-round-pips span {
  width: 22px; height: 6px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.22); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}
.cp-ui .cp-levels .cpg-pips.cp-round-pips span.on { background: linear-gradient(180deg, #FFF1BF, #F6C94C 55%, #D49A1E); box-shadow: 0 0 0 1px rgba(255, 212, 90, 0.4); }
.cp-ui .cp-levels .cpg-pips.cp-round-pips span.is-current:not(.on) { background: rgba(255, 231, 160, 0.35); box-shadow: 0 0 0 1.5px #FFE7A0; }
.cp-ui .cp-levels .cpg-pips.cp-round-pips span.on.is-current { box-shadow: 0 0 0 1.5px #FFE7A0; }

/* 2. Level / Round + controls (desktop 52–56px; phones: controls on a second line in the same panel) */
.cp-ui .cp-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px;
  min-height: 54px; padding: 4px 5px 4px 16px;
}
.cp-ui .cp-where { margin: 0; flex: 1 1 auto; min-width: 0; font-size: 1rem; font-weight: 700; color: #48284E; white-space: nowrap; }
.cp-ui .cp-where strong { color: #2A1B3D; font-weight: 900; }
.cp-ui .cp-actions { display: flex; flex: none; gap: 6px; }
.cp-ui .cp-actions .btn { min-height: 44px; padding: 0 14px; font-size: 0.9rem; white-space: nowrap; }
@media (max-width: 520px) {
  .cp-ui .cp-bar { padding: 6px; gap: 4px 6px; }
  .cp-ui .cp-where { flex-basis: 100%; padding: 0 8px; text-align: center; font-size: 0.95rem; }
  .cp-ui .cp-actions { flex: 1 1 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .cp-ui .cp-actions .btn { padding: 0 8px; }
}

/* 3. Counters: Moves left | Mistakes split card + Practice score card, one row */
.cp-ui .cp-counters { width: 100%; display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 8px; }
.cp-ui .cp-card { height: 62px; display: grid; align-items: center; border-radius: 18px; }
.cp-ui .cp-card::before { border-radius: 17px 17px 50% 50% / 17px 17px 10px 10px; }
.cp-ui .cp-split { grid-template-columns: 1fr 1fr; }
.cp-ui .cp-split .cp-mistakes { position: relative; }
.cp-ui .cp-split .cp-mistakes::before {
  content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 1px;
  background: linear-gradient(180deg, rgba(233, 185, 73, 0), rgba(233, 185, 73, 0.9), rgba(233, 185, 73, 0));
}
.cp-ui .cp-cell { display: flex; flex-direction: column; align-items: center; min-width: 0; margin: 0; padding: 0 6px; text-align: center; }
.cp-ui .cp-label { font-size: 0.78rem; font-weight: 800; line-height: 1.15; color: #5B3B66; white-space: nowrap; }
.cp-ui .cp-value { margin-top: 1px; font-size: 1.5rem; font-weight: 900; line-height: 1.25; font-variant-numeric: tabular-nums; }
.cp-ui .cp-moves .cp-value { color: #0B6B63; }
.cp-ui .cp-mistakes .cp-value { color: #BE185D; }
.cp-ui .cp-score .cp-value { color: #5B21B6; }
@media (max-width: 359px) {
  .cp-ui .cp-counters { gap: 6px; }
  .cp-ui .cp-cell { padding: 0 3px; }
  .cp-ui .cp-label { font-size: 0.75rem; }
}

/* Auto-advance / Pause / Next round + stage note: a slim row under the palette (light background, dark text). */
.cp-ui .cp-advance-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; width: 100%; }
.cp-ui .cp-advance-row .cpg-auto { min-height: 44px; color: #48284E; font-size: 0.85rem; }
.cp-ui .cp-advance-row .btn { min-height: 44px; padding-inline: 14px; font-size: 0.85rem; }
.cp-ui .cpg-stage-note { margin: 0; color: #48284E; font-size: 0.85rem; font-weight: 700; text-align: center; }

/* Short phones (< 600px tall): drop the one-line drag tip (How to play explains it) so the tallest board and the
   palette fit one screen together (approved with the model). */
@media (max-height: 599px) {
  .cp-ui .cp-drag-tip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cp-ui .cp-strip-wrap::before, .cp-ui .cp-strip-wrap::after { transition: none; }
}

/* Taller boards (Levels 5–7) use slightly smaller cells so the board and the palette fit one phone screen. */
.cp-ui .pattern.cp-board[data-rows="5"] { --cp-cell: 58px; }
.cp-ui .pattern.cp-board:is([data-rows="6"], [data-rows="7"]) { --cp-cell: 52px; }
@media (max-width: 600px) {
  .cp-ui .pattern.cp-board[data-rows="5"] { --cp-cell: 52px; }
  .cp-ui .pattern.cp-board:is([data-rows="6"], [data-rows="7"]) { --cp-cell: 48px; }
}
/* The 2×5 choice panel holds two buttons side by side (approved .btn styles). */
.cp-ui .stage .cpg-celebrate .result-actions { flex-wrap: wrap; justify-content: center; }


/* UX #2 — answers shown without the player filling them (after Reveal answer or Out of moves) carry a visible
   "Answer revealed" label, so they never look like tiles the player placed. Text on solid plum: high contrast at 320px. */
.cp-ui .cp-board .tile.cp-revealed {
  border: 2px dashed #7A3E86;
  opacity: 1;
  flex-direction: column;
  justify-content: flex-start;
  padding-top: 3px;
}
.cp-ui .cp-board .tile.cp-revealed .face { width: 52%; height: 52%; flex: none; opacity: 0.9; }
.cp-ui .cp-board .tile.cp-revealed::after { display: none; }
.cp-ui .cp-board .cp-revealed-label {
  position: absolute;
  z-index: 2;
  left: 2px;
  right: 2px;
  bottom: 2px;
  padding: 1px 1px 2px;
  border-radius: 7px;
  background: #4A1E53;
  color: #FFFFFF;
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0;
  text-align: center;
  white-space: normal;
  pointer-events: none;
}
@media (max-width: 359px) {
  /* 320px tiles are ~44px: the label spans the dashed border too, so 9px text still fits on two lines. */
  .cp-ui .cp-board .cp-revealed-label { left: -1px; right: -1px; bottom: -1px; padding: 1px 0 2px; font-size: 9px; letter-spacing: -0.2px; border-radius: 0 0 12px 12px; }
}

/* UX #4 (header) — compact header: "AmzingCoupon Games" · Color Puzzle · "Pattern Logic Lab" in ONE row, in that order.
   Same wording and pill styles as before; only layout, sizes, padding and margins change. Color Puzzle stays the <h1>
   (its accessible name still includes the lab name); the two labels are small supporting pills. On narrow phones each
   label may wrap its own text to two lines so all three stay in one row without clipping or horizontal scroll. */
.cp-ui .game-header {
  /* a grid (not flex-wrap) so narrow screens wrap the labels' own text instead of moving a label to another line */
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, max-content);
  align-items: center;
  justify-content: center;
  column-gap: clamp(5px, 1.6vw, 14px);
  row-gap: 4px;
  margin: 0;
  padding: 0;
}
.cp-ui .game-header .eyebrow {
  display: inline-block;
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  padding: 4px clamp(6px, 1.6vw, 14px);
  border-radius: 10px;
  font-size: clamp(0.5625rem, 2.5vw, 0.8rem);
  line-height: 1.15;
  letter-spacing: 0.08em;
  text-align: center;
  white-space: normal;
}
.cp-ui .game-header #game-title {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  gap: clamp(5px, 1.6vw, 14px);
  min-width: 0;
  margin: 0;
  max-width: 100%;
  font-size: clamp(1rem, 5.2vw, 2.6rem);
  line-height: 1.15;
  white-space: nowrap;
}
.cp-ui .game-header .lab-name {
  display: inline-block;
  flex: 0 1 auto;
  overflow-wrap: normal;
  min-width: 0;
  width: auto;
  margin: 0;
  padding: 4px clamp(6px, 1.6vw, 16px);
  font-size: clamp(0.5625rem, 2.5vw, 0.95rem);
  line-height: 1.15;
  text-align: center;
  white-space: normal;
}
.cp-ui .game-header .header-meta { grid-column: 1 / -1; margin: 2px 0 0; }
.cp-ui .game { padding-top: 10px; }
@media (max-width: 600px) {
  .cp-ui .game { padding-top: 8px; }
  /* narrow phones: each label wraps to two short lines ("AMZINGCOUPON / GAMES", "Pattern Logic / Lab") */
  .cp-ui .game-header { grid-template-columns: max-content max-content; }
  .cp-ui .game-header .eyebrow { max-width: min-content; }
  .cp-ui .game-header .lab-name { max-width: 7.6em; }
}
@media (max-width: 359px) {
  .cp-ui .game-header { column-gap: 4px; }
  .cp-ui .game-header #game-title { gap: 4px; font-size: 5vw; }
  .cp-ui .game-header .eyebrow, .cp-ui .game-header .lab-name { padding-inline: 5px; }
  /* the title keeps its gold letters; a lighter shadow fits the smaller size */
  .cp-ui .game-header #game-title {
    text-shadow: 1px 0 #632354, -1px 0 #632354, 0 -1px #632354, 0 2px #632354, 0 3px #A43A76;
  }
}

/* ---- Visual batch 2026-11-19 (e): gold glass tile backing, bordered Level/Round badge, per-round board themes ---- */
/* Tile backing: light gold liquid glass behind every board tile and palette tile (same shape, lip and highlight as
   before; light enough that the Gold circle keeps its outline). Locked (teal) and revealed (dashed plum) edges are kept.
   Palette tiles are buttons: gold glass fill only, no added glow (AGENTS.md D-023). */
.cp-ui .cp-board .slot.tile:not(:where(.m-wrong, .deny)),
.cp-ui .palette .choice {
  background:
    radial-gradient(ellipse 85% 55% at 50% 0%, rgba(255, 255, 255, 0.95), transparent 70%),
    radial-gradient(ellipse 70% 40% at 50% 105%, rgba(233, 185, 73, 0.32), transparent 70%),
    linear-gradient(165deg, rgba(255, 253, 244, 0.97) 0%, rgba(255, 244, 212, 0.92) 42%, rgba(252, 230, 172, 0.88) 76%, rgba(240, 206, 128, 0.88) 100%);
  -webkit-backdrop-filter: blur(6px) saturate(1.25);
  backdrop-filter: blur(6px) saturate(1.25);
}
.cp-ui .cp-board .slot.tile:not(:where(.m-wrong, .deny, .locked, .cp-revealed)),
.cp-ui .palette .choice {
  border-color: rgba(255, 249, 226, 0.98);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.95),
    inset 0 -7px 10px rgba(201, 151, 58, 0.24),
    inset 0 0 0 1.5px rgba(233, 185, 73, 0.75),
    inset 4px 0 6px -4px rgba(255, 255, 255, 0.9),
    0 6px 0 #D2A85A,
    0 8px 0 rgba(168, 114, 14, 0.45),
    0 18px 18px -8px rgba(74, 30, 83, 0.45);
}

/* Level / Round: a bordered badge inside the controls panel. */
.cp-ui .cp-where {
  flex: 0 1 auto;
  padding: 3px 14px;
  border: 1.5px solid #D4AF37;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 241, 205, 0.75));
  box-shadow: inset 0 1px 0 #FFFFFF, 0 2px 0 rgba(201, 151, 58, 0.35);
  line-height: 1.3;
}
@media (max-width: 520px) {
  .cp-ui .cp-bar { padding: 5px 6px 6px; }
  /* never wider than the panel: a long label (e.g. the Level 9 test fixture) wraps inside the badge */
  .cp-ui .cp-where { flex: 0 1 auto; max-width: 100%; margin-inline: auto; padding: 2px 14px; text-align: center; white-space: normal; }
}

/* Round themes on the board panel: Round 1 gold, Round 2 rose, Round 3 lavender (body[data-round] = the round shown
   in the labels: the round in play, or the round just completed while its popup is open). The inner board is
   translucent so the theme shows behind the tiles. */
.cp-ui .stage { transition: border-color 240ms ease; }
.cp-ui[data-round] .pattern.cp-board { background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.28)); }
.cp-ui[data-round="1"] .stage { border-color: #D9A93F; background: linear-gradient(145deg, #FFFBEA, #FCE9B0 55%, #F5D27C); }
.cp-ui[data-round="2"] .stage { border-color: #D98AA5; background: linear-gradient(145deg, #FFF5F8, #FAD3DF 55%, #F1ADC2); }
.cp-ui[data-round="3"] .stage { border-color: #A88BD6; background: linear-gradient(145deg, #FAF6FF, #E8DCFA 55%, #CFBDF0); }
@media (prefers-reduced-motion: reduce) { .cp-ui .stage { transition: none; } }

/* ---- Feedback batch 2026-11-19 (f): board transition + level-complete firecracker celebration ---- */
/* Transition (New puzzle / Next round / Next Level / Replay): the board dims slightly while inputs are locked. */
.cp-ui .pattern.cp-board { transition: opacity 600ms ease, filter 600ms ease; }
.cp-ui .pattern.cp-board.cp-board-out { opacity: 0.55; filter: saturate(0.85); }
.cp-ui .pattern.cp-board[aria-busy] .socket { cursor: progress; }
/* Celebration particles: a fixed, non-interactive layer removed the moment the celebration ends. */
.cp-fireworks { position: fixed; inset: 0; z-index: 40; overflow: hidden; pointer-events: none; contain: strict; }
.cp-fireworks .cp-spark {
  position: absolute; left: 0; top: 0;
  width: 14px; height: 4px; margin: -2px 0 0 -7px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(122, 40, 90, 0.55), 0 0 8px rgba(255, 214, 90, 0.95);
  will-change: transform, opacity;
}
.cp-fireworks .cp-spark-dot { width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; }
.cp-fireworks .cp-spark-flash {
  position: absolute; left: 0; top: 0;
  width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 214, 90, 0.85) 30%, rgba(236, 72, 153, 0.5) 55%, transparent 72%);
  will-change: transform, opacity;
}
/* Reduced motion: no moving sparks; a soft static gold glow on the completed tiles for the celebration time. */
.cp-ui .cp-board .slot.cp-celebrate-glow {
  box-shadow: 0 0 0 3px rgba(255, 231, 160, 0.95), 0 0 14px 4px rgba(246, 201, 76, 0.75);
}
@media (prefers-reduced-motion: reduce) {
  .cp-ui .pattern.cp-board { transition: none; }
  .cp-fireworks { display: none; }
}

/* Timing batch 2026-11-19 (h): reduced motion gets a brief static outline on the new board instead of the 250 ms fade. */
.cp-ui .pattern.cp-board.cp-board-fresh { box-shadow: 0 0 0 3px rgba(255, 231, 160, 0.95), 0 0 0 6px rgba(233, 185, 73, 0.45); }

/* Popup batch 2026-11-19 (i): the dark blue-purple in-board popups (round "Correct!" and level complete) get a background
   SURFACE at alpha 0.40 (60% transparent). The container itself keeps full opacity, so text, buttons and the gold border
   stay fully opaque. To keep text readable over the light board, what shows through is blurred and darkened
   (backdrop-filter) and the text gets a thin dark shadow. */
.cp-ui .stage .cpg-success:not([hidden]),
.cp-ui .stage .cpg-celebrate:not([hidden]) {
  background: linear-gradient(150deg, rgba(84, 41, 105, 0.4), rgba(39, 23, 55, 0.4));
  -webkit-backdrop-filter: blur(6px) brightness(0.35) saturate(1.2);
  backdrop-filter: blur(6px) brightness(0.35) saturate(1.2);
}
.cp-ui .stage .cpg-success:not([hidden]) :is(.cpg-success-title, .cpg-success-text),
.cp-ui .stage .cpg-celebrate:not([hidden]) :is(.cpg-celebrate-kicker, .cpg-celebrate-title, .cpg-celebrate-count, .cpg-celebrate-next, .cpg-celebrate-note) {
  text-shadow: 0 1px 2px rgba(20, 6, 30, 0.85), 0 0 1px rgba(20, 6, 30, 0.9);
}

/* Levels 8–9 batch 2026-11-19 (k): Level 8 twin rows. Every row of a twin group gets the same coloured ◆ badge and a
   tinted outline band (box-shadow, so row heights do not change); the hint above the board names the twin rows.
   Pair colours: 0 = gold, 1 = pink. */
.cp-ui .cp-board .cp-row.cp-twin { position: relative; border-radius: 14px; }
.cp-ui .cp-board .cp-row.cp-twin-0 { background: rgba(246, 201, 76, 0.22); box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.85); }
.cp-ui .cp-board .cp-row.cp-twin-1 { background: rgba(236, 72, 153, 0.16); box-shadow: 0 0 0 3px rgba(219, 39, 119, 0.8); }
.cp-ui .cp-board .cp-twin-mark {
  position: absolute; z-index: 3; left: -6px; top: 50%; translate: 0 -50%;
  display: grid; place-items: center; width: 18px; height: 18px;
  border: 1.5px solid #FFFFFF; border-radius: 50%;
  color: #FFFFFF; font-size: 10px; font-weight: 900; line-height: 1;
  box-shadow: 0 1px 3px rgba(42, 27, 61, 0.45);
  pointer-events: none;
}
.cp-ui .cp-board .cp-twin-0 .cp-twin-mark { background: #B7860B; }
.cp-ui .cp-board .cp-twin-1 .cp-twin-mark { background: #BE185D; }
.cp-ui .cp-twin-hint {
  width: 100%; margin: 0; padding: 4px 8px;
  border: 1.5px solid rgba(212, 160, 23, 0.7); border-radius: 12px;
  background: rgba(255, 249, 230, 0.85);
  color: #48284E; font-size: 0.8rem; font-weight: 700; line-height: 1.35; text-align: center;
}
.cp-ui .cp-twin-hint[hidden] { display: none; }
.cp-ui .cp-twin-chip { display: inline-block; margin: 0 2px; padding: 0 6px; border-radius: 999px; color: #FFFFFF; font-weight: 900; white-space: nowrap; }
.cp-ui .cp-twin-chip.cp-twin-0 { background: #B7860B; }
.cp-ui .cp-twin-chip.cp-twin-1 { background: #BE185D; }
