/* Memory Match — game styles (builds on /assets/site.css) */
[hidden] { display: none !important; }

/* ---------- menu (fits on one screen: no scrolling) ---------- */
#menu { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  background: radial-gradient(ellipse at 50% 0%, #fff6d8 0%, var(--paper) 60%); }
#menu .site-header { flex: none; }
.menu-main {
  flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; align-items: center;
  gap: clamp(6px, 1.6vh, 18px); padding: clamp(6px, 1.5vh, 18px) 0 clamp(10px, 2vh, 20px);
}
.menu-head { text-align: center; }
.menu-head h1 {
  font-size: clamp(2rem, min(6vw, 6.5vh), 3.4rem); margin: 0 0 clamp(4px, 1vh, 10px);
  color: var(--red); text-shadow: 0 3px 0 #ffd23f;
}
.cast { display: flex; justify-content: center; gap: clamp(4px, 1.2vw, 14px); flex-wrap: nowrap; }
.cast figure { margin: 0; text-align: center; animation: castIn .5s cubic-bezier(.3,1.6,.5,1) both; animation-delay: calc(var(--k) * 60ms); }
.cast span {
  display: block; width: clamp(34px, min(8vw, 8vh), 66px); aspect-ratio: 1; border-radius: 50%; margin: 0 auto;
  background: var(--img) center / cover; border: 3px solid #fff; box-shadow: 0 3px 8px rgba(59,42,30,.2);
  transition: transform .2s;
}
.cast figure:hover span { transform: translateY(-6px) scale(1.12); }
.cast figcaption { font: 800 clamp(.62rem, 1.5vh, .85rem)/1.1 var(--font-display); margin-top: 3px; white-space: nowrap; }
@keyframes castIn { from { opacity: 0; transform: translateY(12px) scale(.6); } }

.music-toggle .mt-slash { display: none; }
.music-toggle[aria-pressed="false"] .mt-slash { display: inline; }
.music-toggle[aria-pressed="false"] { opacity: .75; }
.menu-music {
  display: inline-flex; align-items: center; gap: 8px; vertical-align: middle; margin-left: 10px;
  font: 800 .9rem var(--font-body); color: var(--ink); cursor: pointer;
  background: var(--card); border: 0; border-radius: 999px; padding: 8px 14px; box-shadow: 0 3px 0 rgba(59,42,30,.12);
}
.menu-music svg { width: 18px; height: 18px; }

.levels { display: flex; gap: 12px; justify-content: center; flex-wrap: nowrap; }
.level {
  font: inherit; cursor: pointer; border: 3px solid transparent;
  background: var(--card); color: var(--ink); border-radius: 20px;
  padding: clamp(6px, 1.2vh, 10px) 20px clamp(7px, 1.3vh, 12px); min-width: 150px; text-align: center;
  box-shadow: 0 4px 0 rgba(59,42,30,.12);
  display: flex; flex-direction: column; align-items: center; line-height: 1.15;
  transition: transform .12s ease;
}
.level:hover { transform: translateY(-2px); }
.level b { font-family: var(--font-display); font-size: 1.2rem; }
.level small { color: var(--ink-soft); font-weight: 700; }
.lv-stars { color: var(--yellow-deep); font-size: 1.1rem; letter-spacing: 2px; }
.level[aria-checked="true"] { border-color: var(--red); background: #fff3d6; box-shadow: 0 4px 0 var(--red-deep); }
.start-wrap { text-align: center; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }
.start-btn { font-size: clamp(1.2rem, 3vh, 1.5rem); padding: clamp(10px, 1.6vh, 14px) 40px; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.05); } }
.best { text-align: center; font-weight: 800; color: var(--ink-soft); min-height: 1.3em; margin: 0; font-size: .95rem; }

/* ---------- how to play ---------- */
.howto { width: 100%; max-width: 1000px; padding: 0; }
.howto h2 { text-align: center; font-size: clamp(1.2rem, 3vh, 1.6rem); margin: 0 0 8px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.steps li {
  background: var(--card); border-radius: 16px; padding: 8px 10px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 8px; text-align: left;
}
.steps li > div:last-child { min-width: 0; }
.steps b { display: block; font-family: var(--font-display); font-size: 1.02rem; line-height: 1.1; }
.steps span { color: var(--ink-soft); font-weight: 700; font-size: .82rem; line-height: 1.25; }
.step-art { position: relative; flex: none; height: 60px; width: 76px; display: flex; align-items: center; justify-content: center; gap: 3px; }
.step-art.trophy { font-size: 2.6rem; }
.mini { width: 34px; height: 51px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(59,42,30,.2); display: block; }
.back-mini {
  position: relative; border-color: #fff;
  background: radial-gradient(circle at 50% 45%, #fff3a8 0 18%, #ffd23f 45%, #f0a818 100%);
}
.back-mini::after { content: "★"; position: absolute; inset: 0; display: grid; place-items: center; color: #e3321f; font-size: 1.35rem; text-shadow: 0 0 0 #fff, 0 0 6px rgba(255,255,255,.9); }
.face-mini { background: var(--img) center / cover; }
.steps .tap { position: absolute; right: 2px; bottom: -4px; font-size: 1.4rem; animation: tap 1.2s ease-in-out infinite; color: inherit; }
@keyframes tap { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-3px, -6px); } }
.badge { position: absolute; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; font-weight: 900; display: grid; place-items: center; border: 2px solid #fff; }
.steps .badge { color: #fff; font-size: .85rem; line-height: 1; }
.steps .badge.again { font-size: 1.05rem; }
.badge.ok { background: #2fbf4a; }
.badge.again { background: var(--red); }

@media (max-width: 900px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) {
  .levels { gap: 6px; width: 100%; }
  .level { min-width: 0; flex: 1 1 0; padding: 6px 4px 8px; }
  .level b { font-size: 1rem; }
  .level small { font-size: .68rem; }
  .menu-music .mt-text { display: none; }
  .menu-music { padding: 10px; margin-left: 0; }
  .steps { gap: 6px; }
  .steps li { padding: 6px 6px; gap: 4px; flex-direction: column; text-align: center; }
  .step-art { height: 46px; width: auto; }
  .mini { width: 28px; height: 42px; }
  .step-art.trophy { font-size: 2rem; }
  .steps b { font-size: .92rem; }
  .steps span { font-size: .74rem; }
  .cast figcaption { display: none; }
}
@media (max-height: 640px) and (max-width: 520px) { .steps span { display: none; } }

/* ---------- play ---------- */
#play {
  position: relative; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(180deg, #79c6f2 0%, #a9dcf7 38%, #ffe3a8 78%, #ffc27a 100%);
}
.sky { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cloud {
  position: absolute; width: 220px; height: 70px; border-radius: 999px; background: rgba(255,255,255,.85);
  animation: drift linear infinite;
}
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 110px; height: 110px; left: 30px; top: -55px; }
.cloud::after { width: 80px; height: 80px; left: 115px; top: -38px; }
.c1 { top: 12%; animation-duration: 70s; animation-delay: -10s; }
.c2 { top: 34%; scale: .7; animation-duration: 90s; animation-delay: -55s; opacity: .8; }
.c3 { top: 62%; scale: 1.2; animation-duration: 110s; animation-delay: -30s; opacity: .7; }
.c4 { top: 84%; scale: .85; animation-duration: 80s; animation-delay: -70s; opacity: .75; }
@keyframes drift { from { left: -300px; } to { left: 110%; } }
.tw { position: absolute; width: 18px; height: 18px; animation: twinkle 3.2s ease-in-out infinite; }
.tw::before { content: "✦"; position: absolute; inset: 0; color: #fff; font-size: 18px; line-height: 18px; text-shadow: 0 0 8px #fff6b0; }
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.4) rotate(0deg); } 50% { opacity: 1; transform: scale(1.1) rotate(40deg); } }

.toolbar {
  position: relative; z-index: 2; flex: none; display: flex; align-items: center; gap: 8px;
  padding: 10px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
}
.tb-btn {
  flex: none; height: 46px; min-width: 46px; border-radius: 999px; border: 0; cursor: pointer;
  background: #fffaf0; color: var(--ink); box-shadow: 0 3px 0 rgba(59,42,30,.2);
  display: inline-flex; align-items: center; justify-content: center; padding: 0 11px;
}
.tb-btn svg { width: 24px; height: 24px; }
.tb-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(59,42,30,.2); }
.help-btn { font: 900 1.4rem/1 var(--font-display); background: var(--yellow); box-shadow: 0 3px 0 var(--yellow-deep); }
#soundBtn .snd-off { display: none; }
#soundBtn[aria-pressed="false"] .snd-on { display: none; }
#soundBtn[aria-pressed="false"] .snd-off { display: block; }
.tb-title { flex: 1; min-width: 0; text-align: center; line-height: 1.1; }
.tb-title > span {
  display: block; font-family: var(--font-display); font-weight: 800; font-size: 1.55rem; color: #fff;
  text-shadow: 0 2px 0 #d8432b, 0 3px 8px rgba(120,40,0,.35); letter-spacing: .5px;
}
.moves-badge {
  display: inline-block; margin-top: 3px; background: rgba(255,255,255,.92); color: var(--ink); border-radius: 999px;
  padding: 2px 12px; font-weight: 800; font-size: .9rem; box-shadow: 0 2px 0 rgba(59,42,30,.15);
}
.moves-badge b { color: var(--red); font-size: 1.05rem; }
.moves-badge.bump { animation: bump .35s ease-out; }
@keyframes bump { 50% { transform: scale(1.18); } }

/* found-pairs tray: a face fills each slot as its pair is found */
.tray { position: relative; z-index: 2; flex: none; display: flex; justify-content: center; gap: 8px; padding: 2px 10px 8px; flex-wrap: wrap; }
.slot {
  width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.55); border: 3px dashed rgba(255,255,255,.95);
  display: grid; place-items: center; color: rgba(120,80,40,.55); font: 800 1.1rem var(--font-display);
}
.slot.filled { border: 3px solid #fff; background: var(--img) center / cover; color: transparent; box-shadow: 0 0 0 3px #2fbf4a, 0 4px 10px rgba(0,0,0,.2); animation: slotpop .55s cubic-bezier(.3,1.8,.5,1); }
@keyframes slotpop { from { transform: scale(0) rotate(-40deg); } }

.board-wrap { position: relative; z-index: 1; flex: 1; min-height: 0; display: grid; place-items: center; padding: 4px 10px max(14px, env(safe-area-inset-bottom)); }
.table {
  padding: var(--pad, 14px); border-radius: 26px;
  background: linear-gradient(160deg, rgba(255,255,255,.55), rgba(255,244,214,.45));
  border: 3px solid rgba(255,255,255,.9); box-shadow: 0 10px 30px rgba(120,60,0,.18), inset 0 0 0 2px rgba(245,185,46,.35);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.board { display: grid; gap: var(--gap, 10px); }

/* cards: a 3D flip between the back and the face (picture) */
.card {
  position: relative; width: var(--cw, 100px); height: var(--ch, 150px);
  border: 0; padding: 0; background: none; cursor: pointer; perspective: 900px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: transform .2s ease;
}
@media (hover: hover) { .card:not(.up):not(.matched):hover { transform: translateY(-8px) scale(1.04); } }
.card:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; border-radius: 14px; }
.card .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3, 1.3, .5, 1); }
.card.up .inner, .card.matched .inner { transform: rotateY(180deg); }
.card .face, .card .back {
  position: absolute; inset: 0; border-radius: 14px; overflow: hidden;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  box-shadow: 0 5px 0 rgba(120,50,10,.25), 0 10px 20px rgba(120,50,10,.2);
}
.card .back {
  background:
    radial-gradient(circle at 50% 50%, #fff8c8 0 16%, rgba(255,236,140,.0) 42%),
    repeating-conic-gradient(from 0deg at 50% 50%, #ffd23f 0 9deg, #ffc62a 9deg 18deg),
    #ffd23f;
  border: 4px solid #fff; display: grid; place-items: center;
}
.card .back::before {           /* gold inner frame */
  content: ""; position: absolute; inset: 6px; border-radius: 9px;
  border: 2px solid rgba(214,140,10,.55); box-shadow: inset 0 0 0 2px rgba(255,255,255,.55), inset 0 0 22px rgba(214,120,0,.25);
}
.card .back::after {            /* shine that sweeps across now and then */
  content: ""; position: absolute; top: -20%; bottom: -20%; width: 45%; left: -70%; z-index: 3;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.75), transparent);
  transform: skewX(-15deg); animation: shine 5s ease-in-out infinite; animation-delay: calc(var(--i) * .3s);
}
@keyframes shine { 0%, 72% { left: -70%; } 100% { left: 140%; } }
.card .rays {                   /* slowly turning sunburst behind the star */
  position: absolute; left: 50%; top: 50%; width: 150%; height: auto; aspect-ratio: 1; translate: -50% -50%;
  background: repeating-conic-gradient(rgba(255,255,255,.35) 0 6deg, transparent 6deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 0 30%, transparent 62%); mask: radial-gradient(circle, #000 0 30%, transparent 62%);
  animation: spin 18s linear infinite;
}
@keyframes spin { to { rotate: 360deg; } }
.card .glow {
  position: absolute; left: 50%; top: 50%; width: 70%; height: auto; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.9) 0 20%, rgba(255,240,170,.6) 40%, transparent 70%);
  animation: pulse 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * -.2s);
}
@keyframes pulse { 50% { scale: 1.15; opacity: .7; } }
.card .star {
  /* always dead centre, on every screen size (absolute + fixed square box, so iPhone sizes the SVG correctly) */
  position: absolute; z-index: 2; left: 50%; top: 50%; width: 62%; height: auto; aspect-ratio: 1; translate: -50% -50%; margin: 0;
  filter: drop-shadow(0 4px 0 rgba(150,30,10,.35)) drop-shadow(0 0 10px rgba(255,120,60,.55));
  animation: bob 3s ease-in-out infinite; animation-delay: calc(var(--i) * -.23s);
}
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-4px) rotate(4deg); } }
@media (hover: hover) { .card:not(.up):not(.matched):hover .star { animation: glowUp .5s ease-out forwards; } }
@keyframes glowUp { to { transform: scale(1.18); filter: drop-shadow(0 4px 0 rgba(150,30,10,.35)) drop-shadow(0 0 16px rgba(255,255,255,.95)); } }
.card .spark { position: absolute; z-index: 2; color: #fff; font-size: calc(var(--cw, 100px) / 7); line-height: 1;
  text-shadow: 0 0 6px #fff, 0 0 10px #ffb300; animation: twinkle 2.4s ease-in-out infinite; }
.card .s1 { top: 10%; left: 12%; animation-delay: calc(var(--i) * -.37s); }
.card .s2 { top: 16%; right: 12%; font-size: calc(var(--cw, 100px) / 10); animation-delay: calc(var(--i) * -.37s - .8s); }
.card .s3 { bottom: 12%; left: 16%; font-size: calc(var(--cw, 100px) / 10); animation-delay: calc(var(--i) * -.37s - 1.6s); }
.card .s4 { bottom: 9%; right: 13%; animation-delay: calc(var(--i) * -.37s - 1.2s); }
.card .face { transform: rotateY(180deg); background: #fff; border: 4px solid #fff; }
.card .face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .face .name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 4px 6px; text-align: center;
  font: 800 clamp(.72rem, calc(var(--cw, 100px) / 8.5), 1.25rem)/1.1 var(--font-display); color: #fff;
  background: linear-gradient(transparent, rgba(40,24,10,.75)); text-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.card.matched .face { border-color: #ffd23f; box-shadow: 0 0 0 3px #2fbf4a, 0 0 22px rgba(255,220,90,.95), 0 8px 18px rgba(120,50,10,.25); }
.card.matched .inner { animation: matched .7s ease-out .35s; }
@keyframes matched { 0%, 100% { scale: 1; } 35% { scale: 1.12; } 60% { scale: .97; } }
.card.matched { cursor: default; }
.card.wrong .inner { animation: wobble .45s ease-in-out; }
@keyframes wobble { 0%, 100% { translate: 0 0; } 20% { translate: -7px 0; } 40% { translate: 6px 0; } 60% { translate: -4px 0; } 80% { translate: 3px 0; } }
.card.nudge .inner { animation: nudge .8s cubic-bezier(.3,1.6,.5,1); }
@keyframes nudge { 25% { translate: 0 -14px; rotate: -5deg; } 50% { translate: 0 0; rotate: 4deg; } 70% { rotate: -2deg; } }
.board.dealing .card { animation: deal .55s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: calc(var(--i) * 55ms); }
@keyframes deal { from { opacity: 0; transform: translateY(-60px) rotate(-12deg) scale(.6); } }

/* sparkle burst on a match */
.burst { position: absolute; left: 50%; top: 45%; width: 0; height: 0; pointer-events: none; z-index: 3; }
.burst i { position: absolute; left: -10px; top: -10px; width: 20px; height: 20px; font-style: normal; font-size: 20px; line-height: 20px; color: var(--c);
  animation: fly .85s ease-out forwards; text-shadow: 0 0 6px rgba(255,255,255,.9); }
@keyframes fly { from { transform: translate(0, 0) scale(.3); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1.2) rotate(180deg); opacity: 0; } }

/* Yang Yang the coach, with a speech bubble */
.coach {
  position: absolute; left: max(8px, env(safe-area-inset-left)); bottom: max(8px, env(safe-area-inset-bottom)); z-index: 4;
  display: flex; align-items: flex-end; gap: 4px; pointer-events: none;
  transition: opacity .4s, transform .4s;
}
.coach.hide { opacity: 0; transform: translateY(20px); }
.coach img { width: 96px; height: auto; animation: hover 2.6s ease-in-out infinite; filter: drop-shadow(0 6px 6px rgba(0,0,0,.2)); }
@keyframes hover { 50% { transform: translateY(-8px) rotate(-3deg); } }
.bubble {
  position: relative; margin: 0 0 58px; max-width: 230px; background: #fff; color: var(--ink);
  font-weight: 800; font-size: 1rem; line-height: 1.25; padding: 10px 14px; border-radius: 18px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.bubble::before { content: ""; position: absolute; left: -9px; bottom: 12px; border: 10px solid transparent; border-right-color: #fff; border-left: 0; }
.bubble.pop { animation: pop .4s cubic-bezier(.3,1.6,.5,1); }
@media (max-width: 520px) {
  .toolbar { gap: 6px; }
  .tb-title > span { font-size: 1.25rem; }
  .coach img { width: 72px; }
  .bubble { font-size: .9rem; max-width: 190px; margin-bottom: 42px; }
  .slot { width: 36px; height: 36px; }
}

/* ---------- win & help ---------- */
.win { position: fixed; inset: 0; z-index: 50; background: rgba(40, 24, 10, .45); display: grid; place-items: center; padding: 16px; animation: fade .3s; }
@keyframes fade { from { opacity: 0; } }
.win-card {
  background: var(--card); border-radius: 30px; padding: 26px 26px 22px; text-align: center;
  width: min(440px, 100%); box-shadow: 0 10px 0 rgba(59,42,30,.18), 0 30px 60px rgba(0,0,0,.25);
  animation: pop .5s cubic-bezier(.3,1.6,.5,1);
}
@keyframes pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.help-card { width: min(780px, 100%); max-height: 92dvh; overflow: auto; }
.help-card .steps { margin: 10px 0 18px; }
.help-card .steps li { box-shadow: 0 3px 0 rgba(59,42,30,.1); background: #fff8e8; }
.win-card h2 { font-size: 2.2rem; margin: 4px 0 2px; color: var(--red); }
.win-card p { font-weight: 700; color: var(--ink-soft); }
.win-faces { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 6px 0 4px; }
.win-faces span { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; background: var(--img) center / cover; box-shadow: 0 0 0 2px #2fbf4a; animation: pop .4s cubic-bezier(.3,1.8,.5,1) both; }
.win-stars { font-size: 3.4rem; line-height: 1; letter-spacing: 6px; }
.win-stars span { color: #eadcc0; display: inline-block; }
.win-stars span.on { color: var(--yellow); text-shadow: 0 3px 0 var(--yellow-deep); animation: pop .5s cubic-bezier(.3,1.8,.5,1) both; }
.win-stars span.on:nth-child(2) { animation-delay: .25s; }
.win-stars span.on:nth-child(3) { animation-delay: .5s; }
.win-buttons { display: flex; flex-direction: column; gap: 12px; align-items: stretch; margin-top: 8px; }
.win-links { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.btn-link { background: none; border: 0; font: 800 1rem var(--font-body); color: var(--ink-soft); cursor: pointer; padding: 6px; text-decoration: underline; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }


/* wide screens: Yang Yang talks from the free space top-left, clear of the cards */
@media (min-aspect-ratio: 1/1) {
  .coach { top: 68px; bottom: auto; align-items: center; }
  .coach img { width: 74px; }
  .bubble { margin: 0; max-width: 240px; }
  .bubble::before { bottom: auto; top: 50%; margin-top: -10px; }
}

/* Yang Yang the coach never covers a card: he gets his own space.
   Phones (portrait): a strip under the board, which the cards are sized around.
   Wide screens: the free toolbar space beside the back button. */
.coach {
  position: relative; left: auto; bottom: auto; top: auto; flex: none; align-self: flex-start;
  margin: 0 0 max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); z-index: 4;
}
.coach img { width: 70px; }
.bubble { margin: 0 0 30px; }
@media (min-aspect-ratio: 1/1) {
  .coach { position: absolute; top: 10px; left: 66px; margin: 0; align-items: center; }
  .coach img { width: 58px; }
  .bubble { margin: 0; max-width: max(130px, calc(50vw - 230px)); font-size: .92rem; padding: 8px 12px; }
}
@media (max-aspect-ratio: 1/1) and (max-height: 620px) {
  .coach img { width: 48px; }
  .bubble { margin-bottom: 16px; font-size: .8rem; padding: 6px 10px; }
}

/* phones: a slim header and a slim coach, so the cards get as much room as possible */
@media (max-width: 619px) {
  .toolbar { padding-top: 8px; padding-bottom: 2px; }
  .toolbar .tb-title { display: flex; justify-content: center; align-items: center; gap: 8px; }
  .toolbar .tb-title > small { display: inline; margin: 0; }
  .toolbar .moves-badge { margin: 0; }
  .tray { gap: 5px; padding: 4px 8px 2px; flex-wrap: nowrap; }
  .slot { width: 30px; height: 30px; border-width: 2px; font-size: .85rem; }
  .slot.filled { border-width: 2px; }
  .board-wrap { padding: 4px 6px 4px; }
  .table { border-radius: 20px; }
  .coach img { width: 58px; }
  .bubble { margin-bottom: 22px; font-size: .88rem; padding: 7px 12px; }
}
@media (max-width: 619px) and (max-height: 620px) {
  .coach img { width: 46px; }
  .bubble { margin-bottom: 14px; font-size: .8rem; padding: 5px 10px; }
}

/* the found-pairs tray sits on a soft panel so the slots stay clear even when a cloud drifts behind */
.tray {
  width: fit-content; margin: 0 auto; border-radius: 999px; padding: 6px 12px;
  background: rgba(255, 255, 255, .5); box-shadow: 0 4px 14px rgba(40, 90, 150, .15), inset 0 0 0 2px rgba(255, 255, 255, .8);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.slot { background: rgba(255, 255, 255, .9); border-color: #f0c24a; color: #d49a1e; }
@media (max-width: 619px) { .tray { padding: 4px 8px; margin-top: 2px; } }

/* iPhone Safari lets the animated star/sparkles on the card back show through a flipped card.
   Hide the back half-way through the flip (when it turns edge-on), and bring it back the same way. */
.card .back { transition: visibility 0s .22s; }
.card.up .back, .card.matched .back { visibility: hidden; }
.card .back > * { -webkit-backface-visibility: hidden; backface-visibility: hidden; }