/*
 * Play mode (task PM1): styles for js/play-mode.js. Not part of the Tailwind
 * build (src/site.css), so it loads only on pages that use Play mode.
 *
 * Layout: in Play mode the host (the deck or game area) is pinned to the
 * viewport, 100dvh, inside the safe-area insets. When the drawer opens, the
 * host's height drops by the drawer's measured height (--pm-drawer-h, set by
 * the script), so the game shrinks and is never covered. The drawer itself
 * sits flush on the bottom edge with only the safe-area inset under the row.
 *
 * ⛶ (.pm-fs) is the one element inside host: absolutely placed by the
 * script just left of the page's timer (fsAnchor), in the page and in the
 * big view alike. The panda (.pm-mascot) is pinned top-right in the big view.
 *
 * Colours and fonts follow css/site.css: brand dark #1e2a4a, brand yellow
 * #f7c65a, the Start button's emerald → cyan, Fredoka One for headings and
 * buttons, Inter for text.
 */

:root {
  --pm-drawer-h: 0px;
  --pm-dark: #1e2a4a;
  --pm-yellow: #f7c65a;
  --pm-sky: #eef6ff;
  --pm-safe-t: env(safe-area-inset-top, 0px);
  --pm-safe-r: env(safe-area-inset-right, 0px);
  --pm-safe-b: env(safe-area-inset-bottom, 0px);
  --pm-safe-l: env(safe-area-inset-left, 0px);
  --pm-z: 2147482000;
}

/* Everything Play mode adds is hidden until it is needed. */
.pm-stage, .pm-tab, .pm-fs, .pm-end-tab, .pm-drawer, .pm-end, .pm-sheet-wrap, .pm-tap { display: none; }

html.pm-on, body.pm-on { overflow: hidden !important; overscroll-behavior: none; }

/* A soft backdrop over the page, under the host. */
.pm-on .pm-stage {
  display: block;
  position: fixed;
  inset: 0;
  z-index: var(--pm-z);
  background: linear-gradient(180deg, #f3f8ff 0%, #fff8e6 100%);
}

/* The host: the whole viewport (dvh so iPhone's bars don't cut it). Inline
   heights and max sizes on the page's own wrapper are overridden. */
.pm-on .pm-host {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: auto !important;
  width: auto !important;
  max-width: none !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: none !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  padding: calc(var(--pm-safe-t) + 8px) calc(var(--pm-safe-r) + 8px) calc(var(--pm-safe-b) + 8px) calc(var(--pm-safe-l) + 8px) !important;
  z-index: calc(var(--pm-z) + 1) !important;
  transition: height .25s ease;
  outline: none;
}
/* DT2: the tab never covers the game's own buttons (Next, Clear, ▶): the
   host's content ends above it. 48 px tab + 8 px gap. */
.pm-on:not(.pm-end-shown) .pm-host {
  padding-bottom: calc(var(--pm-safe-b) + 56px) !important;
}
.pm-on.pm-drawer-open .pm-host {
  height: calc(100vh - var(--pm-drawer-h)) !important;
  height: calc(100dvh - var(--pm-drawer-h)) !important;
  /* The drawer already keeps the safe area under itself. */
  padding-bottom: 8px !important;
}

/* The big view is the picture, the word and the timer only. */
.pm-on .pm-host .pm-hidden,
.pm-on .pm-host [data-pm-hide] { display: none !important; }

/* ⛶: into the big view (corners out) from the page, and back (corners in).
   A 48 px+ round white button with a shadow, like the timer. */
.pm-fs.pm-fs-on {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  width: 52px;
  height: 52px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .95);
  color: var(--pm-dark);
  box-shadow: 0 4px 14px rgba(30, 42, 74, .22);
  cursor: pointer;
  z-index: 40;
  transition: opacity .3s ease;
  -webkit-tap-highlight-color: transparent;
}
.pm-fs.pm-fs-on:hover { background: #fff; }
.pm-fs:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
.pm-fs svg { display: block; pointer-events: none; }
/* A computer, playing in the page: fades after 3 s without the mouse moving. */
.pm-fs.pm-fs-faded:not(:focus-visible) { opacity: 0; }
.pm-on .pm-host .pm-fs.pm-fs-on { opacity: 1; }

/* The panda: top-right in the big view, about a quarter of the shorter side
   (0.26 upright, 0.22 sideways). Shown even when `hide` names it. */
.pm-on .pm-mascot,
.pm-on .pm-host .pm-mascot.pm-hidden,
.pm-on .pm-host .pm-mascot[data-pm-hide] {
  display: block !important;
  visibility: visible !important;
  position: fixed !important;
  top: calc(var(--pm-safe-t) + 8px) !important;
  right: calc(var(--pm-safe-r) + 8px) !important;
  left: auto !important;
  bottom: auto !important;
  width: calc(min(100vw, 100vh) * .26) !important;
  height: calc(min(100vw, 100vh) * .26) !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  object-fit: contain;
  z-index: calc(var(--pm-z) + 2);
}
@media (orientation: landscape) {
  .pm-on .pm-mascot,
  .pm-on .pm-host .pm-mascot.pm-hidden,
  .pm-on .pm-host .pm-mascot[data-pm-hide] {
    width: calc(min(100vw, 100vh) * .22) !important;
    height: calc(min(100vw, 100vh) * .22) !important;
  }
}
.pm-on.pm-end-shown .pm-mascot,
.pm-on.pm-sheet-shown .pm-mascot { visibility: hidden !important; }

/* A grown-up check (js/parental-gate.js, deck-gate.js's store gate, or any
   element given class pm-above) shows on top of the big view, inside full
   screen. Their roots are fixed overlays with z-index 1300 of their own. */
.pm-on #parental-gate-math,
.pm-on #deck-gate-math,
.pm-above { z-index: calc(var(--pm-z) + 20) !important; }

/* "▲ More games": a small tab on the bottom edge, centred. */
.pm-on .pm-tab {
  display: block;
  position: fixed;
  left: 50%;
  bottom: var(--pm-safe-b);
  transform: translateX(-50%);
  min-width: 48px;
  min-height: 48px;
  padding: 10px 22px calc(10px);
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--pm-yellow);
  color: var(--pm-dark);
  font: 18px/1.2 "Fredoka One", system-ui, sans-serif;
  box-shadow: 0 -4px 14px rgba(30, 42, 74, .15);
  cursor: pointer;
  z-index: calc(var(--pm-z) + 4);
  transition: bottom .25s ease, opacity .2s ease;
}
.pm-on.pm-drawer-open .pm-tab {
  bottom: var(--pm-drawer-h);
  padding: 4px 22px;
  min-height: 32px;
  font-size: 16px;
  border-radius: 14px 14px 0 0;
}
/* DT2 (owner, 2026-11-16): on every device the tab and the exit button show
   for 2 s (body.pm-tab-shown, js/play-mode.js showControls), then hide; a tap
   anywhere (a computer's mouse movement too) shows them again. While hidden
   they take no taps, so a tap there reaches the game. */
body.pm-on:not(.pm-tab-shown):not(.pm-drawer-open) .pm-tab { opacity: 0; pointer-events: none; }
body.pm-on:not(.pm-tab-shown):not(.pm-drawer-open) .pm-host .pm-fs.pm-fs-on:not(:focus-visible) { opacity: 0; pointer-events: none; }
/* 'tab' mode: hidden while a finger is down in the game (dragging, tracing). */
.pm-on.pm-mode-tab.pm-pointer-down .pm-tab { opacity: 0; pointer-events: none; }
.pm-on.pm-end-shown .pm-tab,
.pm-on.pm-sheet-shown .pm-tab { display: none; }

/* The drawer: one row, flush at the bottom. */
.pm-on .pm-drawer {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px var(--pm-safe-r) var(--pm-safe-b) var(--pm-safe-l);
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 24px rgba(30, 42, 74, .16);
  z-index: calc(var(--pm-z) + 3);
  transform: translateY(100%);
  visibility: hidden;
  transition: transform .25s ease, visibility 0s linear .25s;
}
.pm-on .pm-drawer.pm-open {
  transform: none;
  visibility: visible;
  transition: transform .25s ease;
}
.pm-on.pm-sheet-shown .pm-drawer { visibility: hidden; }

.pm-count {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 24px;
  color: var(--pm-dark);
  font: 700 15px/1 Inter, system-ui, sans-serif;
}
.pm-count[hidden] { display: none; }
.pm-dots { display: flex; gap: 4px; flex-wrap: nowrap; }
.pm-dot { width: 7px; height: 7px; border-radius: 50%; background: #d6deea; }
.pm-dot-done { background: #9fb4d6; }
.pm-dot-on { background: #10b981; transform: scale(1.3); }

.pm-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 12px 0;
  margin: 0;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pm-row::-webkit-scrollbar { display: none; }

.pm-tile {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 92px;
  min-height: 48px;
  padding: 4px 2px 6px;
  border-radius: 14px;
  color: var(--pm-dark);
  text-decoration: none;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
}
.pm-tile:focus-visible { outline: 3px solid #2563eb; outline-offset: -2px; }
.pm-tile-pic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 14px;
  background: var(--pm-sky);
  font-size: 40px;
  line-height: 1;
  overflow: hidden;
}
.pm-tile-pic img { width: 100%; height: 100%; object-fit: contain; }
.pm-tile-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  width: 100%;
  margin-top: 4px;
  text-align: center;
  font: 600 12px/1.25 Inter, system-ui, sans-serif;
  max-height: 2.5em;
  word-break: break-word;
}
.pm-lock {
  position: absolute;
  top: 0;
  right: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(30, 42, 74, .2);
  font-size: 14px;
}

/* The end screen: the message in the middle, the row on the bottom edge.
   With a grown-ups' card (PMR-2): the child's side and the card, side by side
   when wide or sideways, stacked on an upright phone, all without scrolling;
   the row then waits behind its own "▲ More games" tab. */
.pm-on .pm-end.pm-open {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: calc(var(--pm-z) + 2);
  background: linear-gradient(180deg, #f3f8ff 0%, #fff8e6 100%);
}
.pm-end-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: calc(var(--pm-safe-t) + 24px) calc(var(--pm-safe-r) + 16px) 12px calc(var(--pm-safe-l) + 16px);
  text-align: center;
  overflow-y: auto;
}
.pm-end-child {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}
.pm-end-celebrate { display: block; width: clamp(72px, 20vmin, 150px); height: auto; aspect-ratio: 1; object-fit: contain; }
.pm-end-title { margin: 0; color: var(--pm-dark); font: clamp(32px, 7vw, 56px)/1.1 "Fredoka One", system-ui, sans-serif; }
.pm-end-sub { margin: 0; color: #475569; font: 600 17px/1.4 Inter, system-ui, sans-serif; }
.pm-end-sub[hidden], .pm-end-extra[hidden], .pm-end-card[hidden], .pm-end-celebrate[hidden],
.pm-btn[hidden], .pm-btn-again[hidden] { display: none; }
.pm-end-buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: center; }
.pm-end-dock { flex: 0 0 auto; display: flex; flex-direction: column; }
.pm-end-rowwrap {
  flex: 0 0 auto;
  padding: 6px var(--pm-safe-r) var(--pm-safe-b) var(--pm-safe-l);
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 24px rgba(30, 42, 74, .12);
}
.pm-on.pm-sheet-shown .pm-end-rowwrap { visibility: hidden; }

/* With a card: the row behind its tab, over the bottom edge. */
.pm-end-has-card .pm-end-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  pointer-events: none;
}
.pm-end-has-card .pm-end-dock > * { pointer-events: auto; }
.pm-end-has-card .pm-end-rowwrap { display: none; }
.pm-end-has-card.pm-end-row-open .pm-end-rowwrap { display: block; }
.pm-on .pm-end.pm-end-has-card .pm-end-tab {
  display: block;
  align-self: center;
  min-width: 48px;
  min-height: 48px;
  margin-bottom: var(--pm-safe-b);
  padding: 10px 22px;
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--pm-yellow);
  color: var(--pm-dark);
  font: 18px/1.2 "Fredoka One", system-ui, sans-serif;
  box-shadow: 0 -4px 14px rgba(30, 42, 74, .15);
  cursor: pointer;
}
.pm-on .pm-end.pm-end-has-card.pm-end-row-open .pm-end-tab {
  margin-bottom: 0;
  min-height: 32px;
  padding: 4px 22px;
  font-size: 16px;
  border-radius: 14px 14px 0 0;
}
.pm-end-tab:focus-visible { outline: 3px solid #2563eb; outline-offset: -3px; }

/* The grown-ups' card (DeckGate.card): its own content, this frame. */
.pm-end-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 440px;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 22px;
  background: #fff;
  color: var(--pm-dark);
  box-shadow: 0 10px 30px rgba(30, 42, 74, .14);
  font: 15px/1.4 Inter, system-ui, sans-serif;
  text-align: center;
}
.pm-end-card > * { max-width: 100%; }

/* Stacked (an upright phone): compact, with room at the bottom for the tab. */
.pm-end-has-card .pm-end-body {
  justify-content: safe center;
  gap: 10px;
  padding-top: calc(var(--pm-safe-t) + 12px);
  padding-bottom: calc(var(--pm-safe-b) + 58px);
}
.pm-end-has-card .pm-end-child { gap: 6px; }
.pm-end-has-card .pm-end-celebrate { width: clamp(56px, 11vh, 96px); }
.pm-end-has-card .pm-end-title { font-size: clamp(26px, 6.5vw, 40px); }
.pm-end-has-card .pm-end-sub { font-size: 15px; }
.pm-end-has-card .pm-end-buttons { gap: 8px; }
.pm-end-has-card .pm-btn { min-height: 48px; padding: 8px 20px; font-size: 19px; }
.pm-end-has-card .pm-end-card .fk-offer-plan { min-height: 4.4rem; padding: .85rem .4rem .5rem; }
.pm-end-has-card .pm-end-card .fk-offer-plans { margin-bottom: .5rem; gap: .5rem; }
.pm-end-has-card .pm-end-card .fk-offer-fine { margin-bottom: .5rem; }
.pm-end-has-card .pm-end-card .fk-offer-or { margin: .6rem 0 .5rem; }
.pm-end-has-card .pm-end-card h2,
.pm-end-has-card .pm-end-card h3 { margin: 0 0 .5rem; font-size: 1rem; line-height: 1.3; }

/* Two columns: child | card (wide screens, and anything held sideways). */
@media (min-width: 700px), (orientation: landscape) {
  .pm-end-has-card .pm-end-body {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(16px, 4vw, 48px);
    padding-left: calc(var(--pm-safe-l) + 20px);
    padding-right: calc(var(--pm-safe-r) + 20px);
  }
  .pm-end-has-card .pm-end-child { flex: 1 1 0; max-width: 420px; }
  .pm-end-has-card .pm-end-card { flex: 1 1 0; }
}
/* Short (a phone held sideways): a smaller panda and title, compact plans,
   and the "or get the app" line dropped. */
@media (max-height: 520px) {
  .pm-end-body { padding-top: calc(var(--pm-safe-t) + 12px); }
  .pm-end-has-card .pm-end-body { padding-top: calc(var(--pm-safe-t) + 8px); padding-bottom: calc(var(--pm-safe-b) + 54px); }
  .pm-end-has-card .pm-end-celebrate { width: clamp(44px, 14vh, 72px); }
  .pm-end-has-card .pm-end-title { font-size: clamp(22px, 7vh, 32px); }
  .pm-end-has-card .pm-end-sub { font-size: 14px; }
  .pm-end-has-card .pm-end-card { padding: 10px 14px; font-size: 14px; }
  .pm-end-has-card .pm-end-card .fk-offer-plan { min-height: 3.4rem; padding: .7rem .4rem .35rem; gap: 0; }
  .pm-end-has-card .pm-end-card .fk-offer-plan-name { font-size: 1rem; }
  .pm-end-has-card .pm-end-card .fk-offer-plan-price strong { font-size: 1.1rem; }
  .pm-end-has-card .pm-end-card .fk-offer-primary { min-height: 2.75rem; padding: .55rem 1rem; }
  .pm-end-has-card .pm-end-card .fk-offer-or { display: none; }
  .pm-end-has-card .pm-end-card .fk-offer-fine { margin-bottom: .4rem; font-size: .8rem; }
  .pm-end-has-card .pm-end-card h2,
  .pm-end-has-card .pm-end-card h3 { margin-bottom: .4rem; font-size: .9rem; }
}

.pm-btn {
  min-height: 56px;
  min-width: 48px;
  padding: 12px 28px;
  border: 0;
  border-radius: 18px;
  font: 22px/1.1 "Fredoka One", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(30, 42, 74, .15);
  transition: transform .15s ease;
}
.pm-btn:active { transform: scale(.96); }
.pm-btn-next, .pm-btn-keep, .pm-tap-btn { background: linear-gradient(90deg, #34d399, #22d3ee); color: #fff; }
.pm-btn-again { background: #fff; color: var(--pm-dark); }
/* The paid end's subtle "↺ Play again": underlined text, not a button look. */
.pm-again-link {
  min-height: 48px;
  min-width: 48px;
  padding: 8px 14px;
  border: 0;
  background: none;
  box-shadow: none;
  color: #334155;
  font: 600 17px/1.2 Inter, system-ui, sans-serif;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.pm-again-link:focus-visible, .pm-btn:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

/* The bottom sheet (the offer, a 🔒 tile). Works in and out of Play mode. */
.pm-sheet-wrap.pm-open {
  display: block;
  position: fixed;
  inset: 0;
  z-index: calc(var(--pm-z) + 6);
}
.pm-sheet-backdrop { position: absolute; inset: 0; background: rgba(30, 42, 74, .35); }
.pm-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 18px calc(var(--pm-safe-r) + 16px) calc(var(--pm-safe-b) + 16px) calc(var(--pm-safe-l) + 16px);
  background: #fff;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 30px rgba(30, 42, 74, .25);
  color: var(--pm-dark);
  font: 16px/1.4 Inter, system-ui, sans-serif;
}
@media (min-width: 640px) {
  .pm-sheet { left: 50%; right: auto; width: 560px; transform: translateX(-50%); }
}
.pm-sheet-close {
  position: absolute;
  z-index: 1; /* above a hosted sheet's own overlay (deck-gate's offer), so ✕ can be tapped */
  top: 8px;
  right: calc(var(--pm-safe-r) + 8px);
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--pm-dark);
  font: 700 20px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
}

/* "▶ Tap to play": a page opened from the row waits for a fresh tap. */
.pm-tap.pm-open {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: calc(var(--pm-z) + 7);
  background: rgba(243, 248, 255, .94);
}
.pm-tap-btn { font-size: 30px; padding: 20px 40px; min-height: 72px; }

@media (prefers-reduced-motion: reduce) {
  .pm-on .pm-host, .pm-on .pm-tab, .pm-on .pm-drawer, .pm-on .pm-drawer.pm-open, .pm-btn, .pm-fs { transition: none !important; }
  .pm-btn:active { transform: none; }
}

/* PMR-8: the Option C row. "1 free play" under the name (never on the
   picture), the ⭐ Unlock tile, and small dividers between the groups. */
.pm-tile-once { display: block; margin: 2px auto 0; width: max-content; max-width: 100%; padding: 1px 7px; border-radius: 999px;
  background: #fff1d6; color: #8a4b00; font: 700 11px/1.4 Inter, system-ui, sans-serif; white-space: nowrap; }
.pm-unlock .pm-tile-pic { background: linear-gradient(150deg, #2849d6, #7b5cf0); color: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; padding: 6px; box-sizing: border-box; text-align: center; }
.pm-unlock-star { font-size: 26px; line-height: 1; }
.pm-unlock-text { font: 700 12px/1.15 Inter, system-ui, sans-serif; }
.pm-unlock .pm-tile-name { color: #2849d6; }
.pm-row-div { flex: 0 0 auto; align-self: center; writing-mode: vertical-rl; transform: rotate(180deg); padding: 0 2px;
  font: 700 10px/1 Inter, system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: #6b7280; }
