/* Mon Histoire magique: one DOM page for every phone. Children cannot read: shapes, colours, big pictures, motion.
   No scrolling, no text selection, no tap highlight; touch targets are at least 64 pt, the story arrow 96 pt. */
:root {
  /* Colour rules: cream and warm greys for everything, gold for the buttons of the adult and the arrow, and ONLY two meaningful
     colours: green = good answer, red = wrong answer. Nothing is coloured per child. */
  --bg: #f1e4cb;
  --bg2: #fbf3e2;
  --ink: #2f2418;
  --soft: #6f5f4d;
  --card: #ffffff;
  --accent: #f5b83d;
  --accent-dark: #b7791f;
  --ok: #22c55e;
  --bad: #ef4444;
  --dark: #2f2418;
  --panel: rgba(91, 70, 48, 0.1);
  --safe-top: 0px; --safe-right: 0px; --safe-bottom: 0px; --safe-left: 0px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--bg); color: var(--ink);
  font-family: ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Helvetica Neue', sans-serif; }
button { font: inherit; color: inherit; border: 0; padding: 0; cursor: pointer; }
.ico { display: block; width: 100%; height: 100%; overflow: visible; }

#app {
  position: fixed; inset: 0; overflow: hidden;
  padding: max(env(safe-area-inset-top), var(--safe-top)) max(env(safe-area-inset-right), var(--safe-right))
           max(env(safe-area-inset-bottom), var(--safe-bottom)) max(env(safe-area-inset-left), var(--safe-left));
  background: radial-gradient(120% 90% at 50% 0%, var(--bg2), var(--bg) 70%);
}
.screen { position: absolute; inset: 0; padding: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.screen > * { flex: none; }
.screen.fade { animation: fade-in 0.35s both; }

/* ---- adult screens (home, name, lobby): text allowed ---- */
.logo { width: 150px; height: 125px; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35)); animation: bob 3s ease-in-out infinite; }
.title { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 800; color: var(--ink); text-shadow: none; }
.hint { margin: 0; max-width: 300px; font-size: 16px; line-height: 1.35; color: var(--soft); font-weight: 600; }
.error { color: var(--ink); font-weight: 800; }
.btn { min-height: 64px; min-width: 240px; padding: 0 28px; border-radius: 999px; font-size: 22px; font-weight: 800; background: var(--accent); color: #3b1d06;
  box-shadow: 0 6px 0 var(--accent-dark), 0 12px 22px rgba(0, 0, 0, 0.3); transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s; }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--accent-dark), 0 6px 12px rgba(0, 0, 0, 0.3); }
.btn[disabled] { opacity: 0.35; pointer-events: none; }
.btn.green { background: var(--accent); color: #3b1d06; }
.btn.quiet { min-height: 48px; font-size: 16px; background: var(--panel); color: var(--soft); box-shadow: none; }
.btn.red { background: #d9cdb8; color: var(--ink); box-shadow: 0 6px 0 #a39580; }
.dots-wait { display: flex; gap: 10px; }
.dots-wait i { width: 14px; height: 14px; border-radius: 50%; background: var(--soft); animation: blink 1.2s infinite; }
.dots-wait i:nth-child(2) { animation-delay: 0.2s; } .dots-wait i:nth-child(3) { animation-delay: 0.4s; }

.name-form { display: flex; flex-direction: column; gap: 16px; width: min(320px, 86vw); align-items: stretch; }
.name-form label { font-size: 22px; font-weight: 800; line-height: 1.25; }
.name-form input { font: inherit; font-size: 30px; font-weight: 800; padding: 14px 16px; border: 4px solid var(--accent); border-radius: 22px; text-align: center; color: #3b1d06; background: #fff;
  -webkit-user-select: text; user-select: text; outline: none; }

.qr-card { background: #fff; border-radius: 18px; padding: 6px; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35); line-height: 0; }
.qr-card svg { display: block; width: 200px; height: 200px; }
.kids-row { display: flex; gap: 14px; align-items: flex-start; justify-content: center; min-height: 70px; }
.kid { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; max-width: 76px; }
.kid .disc { width: 44px; height: 44px; font-size: 22px; }
.kid.away { opacity: 0.4; }
.disc { display: grid; place-items: center; border-radius: 50%; background: #d9cdb8; color: var(--ink); font-weight: 900; box-shadow: 0 0 0 3px #fff; }

.story-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; width: min(340px, 92vw); }
.story-card { position: relative; display: flex; flex-direction: column; background: var(--card); color: #3b1d06; border-radius: 22px; overflow: hidden; text-align: center; font-weight: 800; font-size: 15px; line-height: 1.2;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3); transition: transform 0.15s, box-shadow 0.15s; }
.story-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: #e8dcc6; display: block; }
.story-card span { padding: 8px 6px 10px; }
.story-card small { display: block; margin-top: 2px; font-size: 13px; font-weight: 700; opacity: 0.6; }
.story-card.on { transform: scale(1.04); box-shadow: 0 0 0 6px var(--accent), 0 10px 22px rgba(0, 0, 0, 0.4); }
.story-card.on::after { content: ''; position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border-radius: 50%; background: var(--dark) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M26 52 L43 69 L76 32' fill='none' stroke='white' stroke-width='14' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 80% no-repeat; }

/* ---- the child's waiting screen ---- */
.kid-wait .disc { width: 128px; height: 128px; font-size: 64px; animation: bob 2.6s ease-in-out infinite; }
.kid-wait .who { font-size: 34px; font-weight: 800; }
.wait-book { width: 110px; height: 92px; opacity: 0.9; animation: bob 3.2s ease-in-out infinite 0.4s; }

/* ---- preload ---- */
.ring { position: relative; width: 250px; height: 250px; }
.ring svg.ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: rgba(91, 70, 48, 0.16); stroke-width: 16; }
.ring .bar { fill: none; stroke: var(--accent); stroke-width: 16; stroke-linecap: round; transition: stroke-dashoffset 0.3s linear, stroke 0.3s; }
.ring.failed .bar { stroke: #fb923c; }
.ring .center { position: absolute; inset: 22px; display: grid; place-items: center; }
.ring .center > * { grid-area: 1 / 1; }
.ring .book { width: 120px; height: 100px; animation: bob 2.4s ease-in-out infinite; }
.play-btn { width: 150px; height: 150px; border-radius: 50%; background: var(--accent); color: var(--dark); display: grid; place-items: center; padding: 0;
  box-shadow: 0 8px 0 var(--accent-dark), 0 14px 28px rgba(0, 0, 0, 0.4); animation: pulse 1.4s ease-in-out infinite; }
.play-btn .ico { width: 70px; height: 70px; margin-left: 8px; }
.play-btn.retry { background: #fb923c; box-shadow: 0 8px 0 #c2410c, 0 14px 28px rgba(0, 0, 0, 0.4); animation: none; }
.play-btn.retry .ico { margin: 0; }
.play-label { position: absolute; bottom: -34px; left: 0; right: 0; font-size: 20px; font-weight: 800; color: var(--ink); }
.kid-dots { display: flex; gap: 18px; min-height: 44px; margin-top: 30px; }
.kdot { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 5px solid var(--dark); background: transparent; transition: background 0.3s, transform 0.3s; animation: blink 1.6s ease-in-out infinite; }
.kdot.on { background: var(--dark); transform: scale(1.18); animation: none; }
.kdot.on::after { content: ''; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M26 52 L43 69 L76 32' fill='none' stroke='white' stroke-width='16' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 80% no-repeat; }

/* ---- the scene player ---- */
.player { position: absolute; inset: 0; padding: inherit; display: flex; flex-direction: column; gap: 8px; }
.player-in { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 6px 8px 8px; }
.scene { position: relative; flex: 0 0 62%; border-radius: 26px; overflow: hidden; background: #5b4630; box-shadow: 0 8px 22px rgba(60, 40, 10, 0.35); isolation: isolate; transition: flex-basis 0.35s ease; }
.scene img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.5s ease; transform: translateZ(0); will-change: opacity, filter, transform; pointer-events: none; }
.scene img.on { opacity: 1; }
.lower { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.choices { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.toprow { position: relative; flex: none; height: 50px; display: flex; align-items: center; justify-content: center; gap: 14px; }
.cards { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); gap: 14px; align-items: center; justify-items: center; padding: 6px 12px 8px; }
/* 4 cards: 2 x 2. 5 cards: 3 + 2 (six columns, each card two wide, the second row centred). The picture gives room (.rows2). */
.cards[data-n='4'] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.cards[data-n='5'] { grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 10px 10px; }
.cards[data-n='5'] .card { grid-column: span 2; }
.cards[data-n='5'] .card:nth-child(4) { grid-column: 2 / span 2; }
.cards[data-n='5'] .card:nth-child(5) { grid-column: 4 / span 2; }
.player.rows2 .scene { flex-basis: 44%; }
.player.rows2 .toprow { height: 34px; }
.player.rows2 .vdot { width: 20px; height: 20px; border-width: 3px; }
.player.rows2 .toprow .absent { position: absolute; left: 6px; top: 50%; width: 38px; height: 38px; margin-top: -19px; }
.player.rows2 .toprow .absent { width: 30px; height: 30px; margin-top: -15px; }
.toprow .speech { height: 34px; width: 46px; }
@media (min-height: 760px) { .player.rows2 .scene { flex-basis: 48%; } }
.status { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity 0.3s; }
.status.on { opacity: 1; }
.status .bubble { width: min(30vh, 128px); aspect-ratio: 1; max-height: 100%; border-radius: 50%; background: var(--panel); display: grid; place-items: center; padding: 18px; color: var(--soft); animation: breathe 2.4s ease-in-out infinite; }
.status .bubble.think { width: min(36vh, 160px); aspect-ratio: auto; height: 100%; max-height: 130px; border-radius: 40px; background: none; padding: 0; }
.status .bubble.think .ico { animation: wiggle 2.2s ease-in-out infinite; }
.status .ico .wave { animation: wave 1.4s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
.status .ico .w2 { animation-delay: 0.25s; }

.chip { position: absolute; left: 10px; top: 10px; z-index: 5; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: rgba(47, 36, 24, 0.12); }
.chip .ico { position: relative; width: 100%; height: 100%; opacity: 0.55; }
.chip .fill { position: absolute; inset: 0; background: rgba(251, 191, 36, 0.55); transform: scaleX(0); transform-origin: left; }
.chip.pressing .fill { animation: fill-bar 1.5s linear forwards; }
.conn { position: absolute; right: 10px; top: 10px; z-index: 5; width: 40px; height: 40px; border-radius: 50%; background: rgba(47, 36, 24, 0.62); display: grid; place-items: center; opacity: 0; transition: opacity 0.3s; }
.conn.on { opacity: 1; }
.conn i { width: 16px; height: 16px; border-radius: 50%; background: #fb923c; animation: blink 0.9s infinite; }

.arrow-zone { position: absolute; right: 14px; bottom: 14px; z-index: 4; }
.arrow-btn { width: 96px; height: 96px; border-radius: 50%; background: var(--accent); color: var(--dark); display: grid; place-items: center; padding: 0;
  box-shadow: 0 6px 0 var(--accent-dark), 0 12px 24px rgba(0, 0, 0, 0.45); animation: nudge 1.6s ease-in-out infinite; }
.arrow-btn .ico { width: 62px; height: 62px; }
.arrow-btn:active { transform: translateY(4px); }
.arrow-btn.gone { animation: out 0.25s forwards; pointer-events: none; }
.arrow-wait .vdot { border-color: #fff; } .arrow-wait .vdot.on { background: #fff; }
.arrow-wait { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-radius: 999px; background: rgba(47, 36, 24, 0.7); animation: pop-in 0.3s both; }

.vdot { width: 26px; height: 26px; border-radius: 50%; border: 4px solid var(--dark); background: transparent; transition: background 0.25s, transform 0.25s; }
.vdot.on { background: var(--dark); transform: scale(1.15); }
.toprow .speech { width: 66px; height: 50px; animation: breathe 1.6s ease-in-out infinite; }

.card { position: relative; width: 100%; max-width: 128px; aspect-ratio: 1; max-height: 100%; border-radius: 24px; background: var(--card); overflow: hidden; display: grid; place-items: center;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.28); transition: transform 0.18s, box-shadow 0.18s, opacity 0.45s, filter 0.3s; }
.card:active { transform: scale(0.96); }
.card img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; display: block; }
.card .glyph { font-size: min(15vh, 84px); line-height: 1; font-weight: 900; color: var(--dark); }
.card.enter { animation: pop-in 0.4s both; animation-delay: calc(var(--i, 0) * 90ms); }
.card.mine { transform: scale(1.05); box-shadow: 0 0 0 7px var(--dark), 0 0 0 10px rgba(255, 255, 255, 0.8), 0 8px 20px rgba(0, 0, 0, 0.3); z-index: 1; }
.card.gone { opacity: 0; transform: scale(0.55); pointer-events: none; }
.cards.locked .card, .cards.still .card { pointer-events: none; }
.cards.locked .card:not(.mine) { opacity: 0.55; filter: grayscale(0.5); }
.card.dim { opacity: 0.32; transform: scale(0.92); }
.card.right { box-shadow: 0 0 0 9px var(--ok), 0 0 28px 8px rgba(34, 197, 94, 0.55); animation: bounce 0.6s both; }
.card.wrong { box-shadow: 0 0 0 9px var(--bad); animation: shake 0.55s both; }
.card .mark { position: absolute; right: 6px; top: 6px; width: 44%; aspect-ratio: 1; animation: pop-in 0.35s both 0.1s; }
.card.wrong .mark { inset: 0; right: auto; top: auto; width: 100%; height: 100%; padding: 14%; background: rgba(239, 68, 68, 0.28); animation: pop-in 0.3s both; }
.card .pickdots { position: absolute; left: 0; right: 0; bottom: 6px; display: flex; justify-content: center; gap: 5px; }
.card .pd { width: 22px; height: 22px; border-radius: 50%; background: var(--dark); border: 3px solid #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); animation: pop-in 0.3s both; }

/* ---- the candy bag, always visible ---- */
.bagbar { flex: none; height: clamp(66px, 11vh, 96px); border-radius: 26px; background: var(--panel); display: flex; align-items: center; justify-content: center; padding: 4px 12px; }
.bag { display: flex; align-items: center; justify-content: center; gap: 14px; height: 100%; width: 100%; }
.jar { position: relative; height: 100%; aspect-ratio: 160 / 120; }
.jar-svg { width: 100%; height: 100%; overflow: visible; }
.count { min-width: 1.2em; text-align: center; font-size: clamp(40px, 7vh, 66px); line-height: 1; font-weight: 900; color: var(--dark); font-variant-numeric: tabular-nums; }
.candy.drop { animation: candy-drop 0.7s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
.candy.fly { animation: candy-fly 0.65s ease-in forwards; }
.candy { transform-box: fill-box; transform-origin: center; }
.jar.pop { animation: jar-pop 0.55s ease-out; }
.jar.shake { animation: shake 0.5s; }
.count.bump { animation: bump 0.5s ease-out; }
.delta { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); font-size: 34px; font-weight: 900; opacity: 0; pointer-events: none; text-shadow: 0 2px 0 rgba(255, 255, 255, 0.7); }
.delta.plus { color: #16a34a; } .delta.minus { color: #dc2626; }
.delta.float { animation: float-up 1s ease-out forwards; }

.player.end .choices { display: none; }
.player.end .bagbar { flex: 1; height: auto; }
.player.end .bag { flex-direction: column; gap: 2px; animation: fade-in 0.5s both; }
.player.end .jar { flex: 1 1 0; min-height: 0; width: 100%; aspect-ratio: auto; display: flex; justify-content: center; }
.player.end .jar-svg { height: 100%; width: auto; max-width: 100%; }
.player.end .count { flex: none; font-size: clamp(54px, 9vh, 92px); }

.unlock { position: absolute; inset: 0; z-index: 30; display: none; place-items: center; background: rgba(47, 36, 24, 0.6); }
.unlock.on { display: grid; }
.unlock button { width: 168px; height: 168px; border-radius: 50%; background: var(--accent); color: var(--dark); display: grid; place-items: center; padding: 32px; box-shadow: 0 8px 0 var(--accent-dark), 0 16px 30px rgba(0, 0, 0, 0.5); animation: pulse 1.2s infinite; }

.menu { position: absolute; inset: 0; z-index: 40; display: none; place-items: center; background: rgba(47, 36, 24, 0.8); padding: inherit; }
.menu.on { display: grid; }
.menu-box { display: flex; flex-direction: column; gap: 14px; align-items: stretch; width: min(320px, 86vw); padding: 22px; border-radius: 28px; background: var(--bg2); color: var(--ink); text-align: center; }
.menu-box h2 { margin: 0 0 4px; font-size: 24px; color: var(--ink); }

.toast { position: fixed; left: 50%; top: calc(max(env(safe-area-inset-top), var(--safe-top)) + 10px); transform: translateX(-50%); z-index: 60; max-width: 86vw; padding: 12px 20px; border-radius: 999px; background: rgba(47, 36, 24, 0.92); color: #fff;
  font-size: 15px; font-weight: 700; text-align: center; pointer-events: none; animation: fade-in 0.25s both; }
.toast[hidden] { display: none; }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 50; pointer-events: none; }

/* ---- browser mock: several phones side by side ---- */
.phones-page body, .phones-page { background: #3a2f22; }
.phones { position: fixed; inset: 0; display: flex; gap: 14px; align-items: center; justify-content: center; padding: 8px; }
.phones .slot { position: relative; flex: none; }
.phones iframe { position: absolute; left: 0; top: 0; width: 375px; height: 812px; border: 0; border-radius: 26px; background: #000; transform-origin: top left; }

/* ---- animations ---- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.4); } to { opacity: 1; transform: scale(1); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(3deg) translateY(-6px); } }
@keyframes wave { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@keyframes blink { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(7px); } }
@keyframes out { to { opacity: 0; transform: scale(0.3); } }
@keyframes bounce { 0% { transform: scale(1); } 40% { transform: scale(1.14); } 100% { transform: scale(1.06); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { translate: -10px 0; } 40% { translate: 10px 0; } 60% { translate: -7px 0; } 80% { translate: 7px 0; } }
@keyframes jar-pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.4); } 100% { transform: scale(1); } }
@keyframes candy-drop { 0% { transform: translateY(-90px) scale(1.2); opacity: 0; } 45% { opacity: 1; } 100% { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes candy-fly { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-110px) rotate(80deg) scale(0.6); opacity: 0; } }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.6); } 20% { opacity: 1; transform: translate(-50%, -8px) scale(1.2); } 100% { opacity: 0; transform: translate(-50%, -58px) scale(1); } }
@keyframes fill-bar { to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  .logo, .kid-wait .disc, .wait-book, .ring .book, .status .bubble, .arrow-btn, .play-btn { animation: none; }
}

/* ---- the RULES slideshow: pictograms drawn by the app, nothing to read, nothing to press ---- */
.rules { position: absolute; inset: 0; padding: inherit; }
.rules-in { position: relative; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 6px 8px; }
.rules-card { width: min(90vw, 54vh, 360px); aspect-ratio: 1; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 14px; border-radius: 40px; background: #fff; box-shadow: 0 10px 0 rgba(91, 70, 48, 0.14), 0 16px 30px rgba(91, 70, 48, 0.18); overflow: hidden; }
.rules-card > svg, .rules-card > .rp-combo { animation: pop-in 0.45s both; }
.rules-card .rp { width: 100%; height: 100%; overflow: visible; }
.rules-dots { display: flex; gap: 14px; min-height: 22px; }
.rdot { width: 20px; height: 20px; border-radius: 50%; border: 4px solid var(--accent); background: transparent; transition: background 0.3s, transform 0.3s; }
.rdot.on { background: var(--accent); transform: scale(1.15); }
.rp-combo { width: 100%; height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1.1fr); gap: 4px 6px; align-items: center; justify-items: center; }
.rp-combo > svg { min-height: 0; max-width: 100%; max-height: 100%; }
.rp-combo .rp-jar { grid-column: 1 / span 2; width: auto; height: 100%; }
.rp-combo .rp-talk, .rp-combo .rp-touch { width: 100%; height: 100%; }

.rp .rp-bubble { transform-box: fill-box; transform-origin: bottom center; animation: pop-in 0.5s both; }
.rp .b1 { animation-delay: 0.25s; } .rp .b2 { animation-delay: 1s; }
.rp .rp-face { animation: bob 2.4s ease-in-out infinite; }
.rp .rp-hand { animation: reach 0.9s ease-out both; }
.rp .h1 { --dx: -34px; } .rp .h2 { --dx: -34px; animation-delay: 0.15s; }
.rp-touch .rp-card { animation: tap 1.6s ease-in-out 1.1s infinite; transform-box: fill-box; transform-origin: center; }
.rp .rp-ring { stroke-dasharray: 1; animation: draw 0.9s ease-out 0.2s both; }
.rp .rp-badge { transform-box: fill-box; transform-origin: center; animation: pop-in 0.4s both 1s; }
.rp .rp-cross { transform-box: fill-box; transform-origin: center; animation: shake 0.6s both 0.3s; }
.rp .rp-candy { transform-box: fill-box; transform-origin: center; animation: pop-in 0.5s both 0.8s; }
.rp .rp-candy.minus { animation: candy-out 1.8s ease-in-out 0.8s infinite; }
.rp .rp-drop { transform-box: fill-box; transform-origin: center; animation: candy-drop 0.7s cubic-bezier(0.3, 1.4, 0.5, 1) both; animation-delay: calc(var(--i, 0) * 260ms); }
@keyframes reach { from { transform: translateX(var(--dx)); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes tap { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.06); } 30% { transform: scale(1); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes candy-out { 0% { opacity: 0; transform: translateY(0) scale(0.6); } 20% { opacity: 1; transform: translateY(0) scale(1); } 80% { opacity: 0.5; transform: translateY(28px) scale(0.85); } 100% { opacity: 0; transform: translateY(34px) scale(0.8); } }

/* ---- the catalogue (home), the QR screen, the waiting screens, the end buttons ---- */
.catalogue { justify-content: flex-start; gap: 6px; padding-top: max(env(safe-area-inset-top), var(--safe-top)); }
.catalogue .logo.small { width: 74px; height: 62px; margin-top: 10px; animation: none; }
.title-box { position: relative; padding: 2px 18px; border-radius: 999px; overflow: hidden; }
.title-box .title { position: relative; font-size: 28px; }
.title-box .fill { position: absolute; inset: 0; background: rgba(245, 184, 61, 0.45); transform: scaleX(0); transform-origin: left; }
.title-box.pressing .fill { animation: fill-bar 1.5s linear forwards; }
.catalogue .hint { margin: 0; max-width: 320px; }
.scroll { flex: 1; min-height: 0; width: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 10px 14px 24px; touch-action: pan-y; }
.cat-body { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 16px; }
.tiles { width: 100%; max-width: 420px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.tile { position: relative; aspect-ratio: 1; width: 100%; padding: 0; border-radius: 26px; overflow: hidden; background: #fff; box-shadow: 0 7px 0 rgba(91, 70, 48, 0.2), 0 12px 20px rgba(91, 70, 48, 0.14); display: block; transition: transform 0.12s; }
.tile:active { transform: scale(0.96); }
.tile img, .tile .blank { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #e8dcc6; pointer-events: none; }
.tile span { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 10px 10px; font-size: 16px; font-weight: 800; line-height: 1.15; color: #fff; text-align: center; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55); background: linear-gradient(to top, rgba(47, 36, 24, 0.78), rgba(47, 36, 24, 0)); }
.catalogue.busy .tiles { opacity: 0.5; pointer-events: none; }
.play-btn.small { width: 96px; height: 96px; }
.play-btn.small .ico { width: 52px; height: 52px; margin: 0; }
.play-btn.home { animation: none; background: var(--accent); color: var(--dark); box-shadow: 0 8px 0 var(--accent-dark), 0 14px 28px rgba(0, 0, 0, 0.3); }
.notice .logo { animation: none; }

.qr { gap: 14px; }
.back-btn { position: absolute; left: 12px; top: calc(max(env(safe-area-inset-top), var(--safe-top)) + 8px); width: 64px; height: 64px; border-radius: 50%; background: var(--panel); color: var(--ink); padding: 14px; }
.qr-card.empty { width: 200px; height: 200px; }
.phone-dots { display: flex; gap: 16px; }
.pdot { width: 30px; height: 30px; border-radius: 50%; border: 5px solid var(--accent); background: transparent; transition: background 0.3s, transform 0.3s, opacity 0.3s; }
.pdot.on { background: var(--accent); transform: scale(1.12); }
.pdot.off { opacity: 0.3; }
.pdot.away { border-style: dashed; }
.kid-wait .phone-dots { margin-top: 6px; }

.end-actions { position: absolute; left: 0; right: 0; bottom: 14px; z-index: 6; display: flex; justify-content: space-between; align-items: center; padding: 0 16px; pointer-events: none; }
.end-actions[data-role='guest'] { justify-content: space-between; }
.end-actions > * { pointer-events: auto; }
.end-btn { width: 84px; height: 84px; border-radius: 50%; padding: 18px; display: grid; place-items: center; background: var(--accent); color: var(--dark); box-shadow: 0 6px 0 var(--accent-dark), 0 10px 20px rgba(0, 0, 0, 0.3); animation: pop-in 0.5s both 0.8s; }
.end-btn.quit { background: #fff; box-shadow: 0 6px 0 rgba(91, 70, 48, 0.3), 0 10px 20px rgba(0, 0, 0, 0.25); }
.end-btn:active { transform: translateY(4px); }
.end-actions .choosing { background: rgba(255, 255, 255, 0.85); padding: 12px 16px; border-radius: 999px; }

.btn.go { display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 240px; }
.btn.go .ico { width: 50px; height: 50px; }
.btn.go .ico-play { width: 44px; height: 44px; }
