/* Free to play: one section, a game picker, then Runner and Catch in identical blocks that fit the viewport.
   Never #FFE600 / #FFE500. */
.games-sec { --gc: 224, 168, 120; --hdr: 68px; --ghead: 76px; }
#games .sec-head { margin-bottom: 18px; }

/* ---------- picker ---------- */
.game-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 0 0 30px; }
.game-pick { display: grid; grid-template-columns: 64px minmax(0, 1fr) 24px; align-items: center; gap: 14px; padding: 12px 16px 12px 12px; border-radius: 20px; background: var(--navy-2); color: var(--cream); text-decoration: none;
  box-shadow: 0 0 0 1.5px rgba(var(--gc), .55) inset, 0 0 0 1px rgba(var(--gc), .22), 0 0 14px rgba(var(--gc), .22), 0 10px 26px rgba(0,0,0,.3); transition: transform .2s, box-shadow .2s, background .2s; }
.game-pick:hover { transform: translateY(-2px); background: #2b343d; }
.game-pick.is-active { background: #2b343d; box-shadow: 0 0 0 2px rgba(var(--gc), 1) inset, 0 0 0 1px rgba(var(--gc), .45), 0 0 18px rgba(var(--gc), .5), 0 0 40px rgba(var(--gc), .24), 0 10px 26px rgba(0,0,0,.3); }
.game-pick img { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,.4)); }
.gp-txt { display: grid; gap: 3px; min-width: 0; }
.gp-txt b { font-family: Marimpa, sans-serif; font-weight: 400; font-size: 26px; line-height: 1.05; color: var(--white); white-space: nowrap; }
.gp-txt small { font-size: 13px; font-weight: 700; color: var(--blue); line-height: 1.25; }
.gp-go { width: 24px; height: 24px; color: var(--tan); }

/* ---------- identical game blocks ---------- */
.game-block { scroll-margin-top: calc(var(--hdr) + 10px); }
.game-block + .game-block { margin-top: 40px; }
.game-head { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 14px; height: var(--ghead); margin: 0 0 12px; }
.game-head-icon { width: 52px; height: 52px; object-fit: contain; filter: drop-shadow(0 3px 6px rgba(0,0,0,.4)); }
.game-title { margin: 0; font-family: Marimpa, sans-serif; font-weight: 400; font-size: 30px; line-height: 1.05; color: var(--white); }
.game-sub { margin: 4px 0 0; max-width: 900px; color: var(--blue); font-size: 14px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.game-block .catch-card { padding: 18px 20px; }
.game-block .catch-idle { grid-template-columns: minmax(0, 1.08fr) minmax(300px, .92fr); gap: 0 28px; align-items: stretch; }
.game-block .catch-card-art { height: auto; min-height: 260px; border-radius: 18px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(var(--gc), .3); background: #121a22; padding: 0; display: block; }
.game-block .catch-card-body { justify-content: center; min-height: 0; }
.game-block .catch-oneline { font-size: 15px; margin-bottom: 12px; }
.game-block .catch-legend { margin-bottom: 12px; padding: 10px 12px 8px; }
.game-block .catch-legend-title { margin-bottom: 6px; }
.game-block .catch-legend-list { gap: 4px 12px; }
.game-block .catch-legend-list li { grid-template-columns: 28px 1fr auto; min-height: 28px; }
.game-block .catch-legend-list img { width: 28px; height: 28px; border-radius: 0; }
.game-block .catch-meters { gap: 6px; margin-bottom: 14px; }
.game-block .catch-card .fine { margin-top: 10px; }
.game-block .catch-play, .game-block .catch-how-btn { min-height: 50px; }
.game-block .catch-scores { margin-bottom: 12px; padding: 8px 12px; }

/* desktop / laptop: the card is sized to the viewport so title + summary + board (and the how-to) fit on one screen */
@media (min-width: 861px) {
  .game-block .catch-card { --fit: clamp(400px, calc(100vh - var(--hdr) - var(--ghead) - 40px), 620px); --fit: clamp(400px, calc(100dvh - var(--hdr) - var(--ghead) - 40px), 620px); height: var(--fit); display: flex; flex-direction: column; }
  .game-block .catch-idle { flex: 1 1 auto; min-height: 0; }
  .game-block .catch-card-art { min-height: 0; }
  .game-block .catch-card.is-playing { padding: 14px 16px 16px; }
  .game-block .catch-card.is-playing .catch-stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
  .game-block .catch-playcol, .game-block .catch-playwrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .game-block .catch-field, .game-block .runner-field { flex: 1 1 auto; height: auto; min-height: 0; }
  .game-block .catch-hud-cell { padding: 6px 12px 8px; }
  .game-block .catch-hud-score b { font-size: 30px; }
  /* how-to stays on the card and scrolls inside it if a short screen needs that */
  .game-block .catch-how { padding: 12px; }
  .game-block .catch-how-panel { width: min(540px, 100%); max-height: 100%; padding: 20px 18px 16px; }
}
@media (min-width: 861px) and (max-height: 780px) {
  .games-sec { --ghead: 64px; }
  .game-title { font-size: 26px; }
  .game-sub { font-size: 13px; margin-top: 2px; }
  .game-head-icon { width: 46px; height: 46px; }
  .game-head { grid-template-columns: 46px minmax(0, 1fr); margin-bottom: 10px; }
  .game-block .catch-card { padding: 14px 18px; }
  .game-block .catch-oneline { font-size: 14px; margin-bottom: 8px; line-height: 1.3; }
  .game-block .catch-legend { margin-bottom: 8px; padding: 8px 10px 6px; }
  .game-block .catch-legend-list li { min-height: 25px; grid-template-columns: 24px 1fr auto; }
  .game-block .catch-legend-list img { width: 24px; height: 24px; }
  .game-block .catch-legend-list span { font-size: 12px; }
  .game-block .catch-meters { gap: 4px; margin-bottom: 10px; }
  .game-block .catch-meter-row { font-size: 12px; }
  .game-block .catch-play, .game-block .catch-how-btn { min-height: 44px; font-size: 16px; }
  .game-block .catch-card .fine { margin-top: 6px; font-size: 12px; }
  .game-block .catch-scores { display: none !important; }
  .game-block .catch-how-mark { display: none; }
  .game-block .catch-how-panel { padding: 14px 14px 12px; }
  .game-block .catch-how-panel h3 { font-size: 22px; margin-bottom: 8px; }
  .game-block .how-moves { margin-bottom: 8px; }
  .game-block .how-move { padding: 8px 6px; gap: 4px; }
  .game-block .how-keys { min-height: 30px; }
  .game-block .how-tip { font-size: 12px; margin-bottom: 8px; }
  .game-block .how-cards { gap: 6px; margin-bottom: 8px; }
  .game-block .how-cards li { padding: 5px 4px; gap: 2px; }
  .game-block .how-cards img { width: 30px; height: 30px; }
  .game-block .how-cards b { font-size: 14px; }
  .game-block .catch-how-panel .btn { min-height: 42px; margin-top: 4px; }
  .game-block .how-drag img { height: 34px; width: auto; }
  .game-block .how-drag .how-finger { width: 28px; height: 28px; }
  /* Catch lists 8 items: as compact rows so the whole panel fits short laptops */
  .game-block #catchHowCards li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; justify-items: start; text-align: left; column-gap: 6px; padding: 6px 8px; }
  .game-block #catchHowCards img { width: 26px; height: 26px; }
  .game-block #catchHowCards b { justify-self: end; }
}

/* ---------- Runner touch controls: two matched hold buttons under the field, directions centred above ---------- */
.runner-controls { display: none; }
@media (max-width: 860px), (pointer: coarse) {
  .runner-controls { display: grid; gap: 8px; }
  .runner-touch-hint { margin: 0; text-align: center; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--blue); line-height: 1.3; transition: opacity .4s; }
  .runner-pad { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .runner-hold { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 64px; padding: 0 12px; border: 0; border-radius: 18px; cursor: pointer; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
    font: 900 14px/1 Nunito, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: var(--cream); background: var(--slate);
    box-shadow: inset 0 0 0 1.5px rgba(var(--gc), .7), 0 4px 0 #101317; transition: transform .06s, background .1s; }
  .runner-hold svg { width: 20px; height: 20px; flex: none; }
  .runner-hold.on { background: var(--tan); color: var(--ink); box-shadow: inset 0 0 0 1.5px rgba(var(--gc), 1), 0 1px 0 #101317; transform: translateY(3px); }
}

/* ---------- phones: play fills the portrait screen; how-to is a sheet that always fits ---------- */
@media (max-width: 860px) {
  .games-sec { --hdr: 112px; }
  .game-picker { gap: 10px; margin-bottom: 24px; }
  .game-pick { grid-template-columns: 48px minmax(0, 1fr); gap: 10px; padding: 10px; border-radius: 18px; }
  .game-pick img { width: 48px; height: 48px; }
  .gp-txt b { font-size: 18px; white-space: normal; }
  .gp-txt small { font-size: 11px; }
  .gp-go { display: none; }
  .game-head { height: auto; align-items: start; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; }
  .game-head-icon { width: 44px; height: 44px; }
  .game-title { font-size: 26px; }
  .game-sub { font-size: 13px; -webkit-line-clamp: 4; }
  .game-block .catch-card { padding: 16px; }
  .game-block .catch-idle { grid-template-columns: 1fr; gap: 14px; }
  .game-block .catch-card-art { min-height: 0; height: 200px; }
  main:has(.catch-card.is-playing), main:has(.catch-how:not([hidden])) { z-index: 40; }
  .game-block .catch-card.is-playing .catch-stage { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; gap: 8px;
    padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px calc(env(safe-area-inset-bottom, 0px) + 10px); background: #161C22; }
  .game-block .catch-card.is-playing .catch-playcol, .game-block .catch-card.is-playing .catch-playwrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
  .game-block .catch-card.is-playing .catch-field, .game-block .catch-card.is-playing .runner-field { flex: 1 1 auto; height: auto; min-height: 0; border-radius: 18px; }
  .game-block .catch-card.is-playing .catch-hat-hint { padding: 2px 0 0; }
  .game-block .catch-how { position: fixed; inset: 0; z-index: 60; border-radius: 0; padding: calc(env(safe-area-inset-top, 0px) + 12px) 12px calc(env(safe-area-inset-bottom, 0px) + 12px); }
  .game-block .catch-how-panel { max-height: 100%; }
}

/* ---------- Catch idle card art: night plaza, the Chroop sways under the paper hat and catches the drops ---------- */
.cca > * { position: absolute; pointer-events: none; }
.cca-sky { inset: 0; background: url(/assets/catch/bg-far.webp) 50% 78% / cover no-repeat; animation: ccaSky 26s ease-in-out infinite alternate; }
@keyframes ccaSky { to { background-position: 46% 74%; } }
.cca-mid { left: -4%; right: -4%; bottom: 0; height: 46%; background: url(/assets/catch/bg-mid.webp) 50% 100% / auto 100% repeat-x; }
.cca-hero { left: 0; bottom: 4%; width: 100%; height: 56%; animation: ccaSway 4s ease-in-out infinite; }
.cca-hero img { position: absolute; bottom: 0; left: 30%; height: 100%; width: auto; transform: translateX(-50%); filter: drop-shadow(0 10px 12px rgba(0,0,0,.45)); animation: ccaBounce 2s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes ccaSway { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(34%); } }
@keyframes ccaBounce { 0%, 100% { transform: translateX(-50%) scale(1, 1); } 8% { transform: translateX(-50%) scale(1.06, .94); } 18% { transform: translateX(-50%) scale(.98, 1.02); } }
.cca-drop { width: 13%; max-width: 64px; filter: drop-shadow(0 6px 8px rgba(0,0,0,.4)); opacity: 0; }
.cca-drop.d1 { left: calc(30% - 6.5%); animation: ccaDrop1 4s cubic-bezier(.45, 0, .85, .6) infinite; }
.cca-drop.d2 { left: calc(64% - 6.5%); animation: ccaDrop2 4s cubic-bezier(.45, 0, .85, .6) infinite; filter: drop-shadow(0 0 12px rgba(110, 236, 240, .55)); }
@keyframes ccaDrop1 { 0%, 62% { top: -16%; opacity: 0; transform: rotate(-10deg); } 66% { opacity: 1; } 98% { top: 40%; opacity: 1; transform: rotate(14deg) scale(1); } 100% { top: 41%; opacity: 0; transform: scale(1.4); } }
@keyframes ccaDrop2 { 0%, 12% { top: -16%; opacity: 0; } 16% { opacity: 1; } 48% { top: 40%; opacity: 1; transform: rotate(-8deg) scale(1); } 50%, 100% { top: 41%; opacity: 0; transform: scale(1.4); } }
.cca-fl { width: 11%; max-width: 56px; filter: drop-shadow(0 6px 8px rgba(0,0,0,.35)); animation: ccaFloat 3.6s ease-in-out infinite; }
.cca-fl.f1 { left: 8%; top: 12%; animation-delay: -1.2s; }
.cca-fl.f2 { right: 9%; top: 9%; width: 14%; max-width: 70px; animation-delay: -.4s; }
.cca-fl.f3 { left: 44%; top: 6%; width: 10%; opacity: .85; animation-delay: -2.2s; }
@keyframes ccaFloat { 50% { transform: translateY(-8px) rotate(-7deg); } }

/* Catch end sheet shares the Runner sheet; the Catch title sits like the Runner intro title */
.catch-title { z-index: 6; }
.catch-endstats.runner-endstats { margin: 0; }
.catch-field { background: #121a22; }
.catch-hat { bottom: 0; height: auto; width: auto; filter: none; }

@media (prefers-reduced-motion: reduce) {
  .cca-sky, .cca-hero, .cca-hero img, .cca-drop, .cca-fl { animation: none !important; }
  .cca-drop { opacity: 0; }
}

/* end sheet for Catch reuses the runner sheet */
.runner-sheet .nudge #catchRedeem { grid-column: 1 / -1; }
.runner-sheet .nudge #catchDone { grid-column: auto; }
.catch-sheet.runner-sheet .mark { object-fit: contain; }
@media (min-width: 861px) { .game-block .runner-card-art, .game-block .catch-card-art { min-height: 0; } }
#runner.game-block, #catch.game-block { scroll-margin-top: 0; } /* html already has scroll-padding-top for the sticky header */

/* Phones: compact idle cards so title, summary, art, legend, meters and both buttons fit one screen,
   and both games' cards come out the same height (legends are two 54px rows in each). */
@media (max-width: 860px) {
  .game-block .game-sub { -webkit-line-clamp: 4; line-clamp: 4; font-size: 13px; line-height: 1.35; }
  .game-block .catch-card-idle, .game-block .catch-idle { gap: 0; }
  .game-block .runner-card-art, .game-block .catch-card-art { height: 160px; min-height: 0; aspect-ratio: auto; }
  .game-block .catch-oneline { font-size: 14px; line-height: 1.35; margin: 10px 0 8px; min-height: calc(3 * 1.35em); }
  .game-block .catch-legend { padding: 8px 8px 6px; margin-bottom: 8px; }
  .game-block .catch-legend-title { font-size: 15px; margin-bottom: 4px; }
  .game-block .catch-legend-list { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 54px; gap: 4px; }
  .game-block .runner-legend .catch-legend-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-block .catch-legend-list li { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 0; padding: 0 2px; text-align: center; }
  .game-block .catch-legend-list img { width: 26px; height: 26px; }
  .game-block .catch-legend-list span { font-size: 10.5px; line-height: 1.15; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .game-block .catch-legend-list span[data-short] em { display: none; }
  .game-block .catch-legend-list span[data-short]::after { content: attr(data-short); }
  .game-block .catch-legend-list b { font-size: 12.5px; line-height: 1.1; }
  .game-block .catch-meters { gap: 2px; margin-bottom: 10px; }
  .game-block .catch-meter-row { font-size: 13px; }
  .game-block .catch-idle-actions { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 8px; }
  .game-block .catch-idle-actions .btn { min-height: 50px; margin: 0; width: 100%; }
  .game-block .catch-card .fine { margin-top: 6px; font-size: 12px; line-height: 1.35; min-height: calc(2 * 1.35em); }
}
.catch-legend-list span em { font-style: normal; }

/* In-game music/sound toggle (same switch as the header speaker). */
.music-btn .mi-off { display: none; }
.music-btn.is-off .mi-on { display: none; }
.music-btn.is-off .mi-off { display: block; }
.music-btn.is-off { color: var(--blue); }
.catch-btns { z-index: 7; }
.runner-btn.music-btn svg { width: 21px; height: 21px; }
