/* Blupoli Puzzles application shell -----------------------------------------
   Core product surfaces run inside one 100dvh shell. Editorial pages keep
   their document layout; Today, Explore, Progress and Game share this frame. */

:root {
  --puzzles-app-topbar: 64px;
  --puzzles-app-bottom-nav: 72px;
  --puzzles-app-rail: 220px;
  --puzzles-app-gutter: clamp(14px, 2.2vw, 34px);
  --puzzles-app-gap: clamp(12px, 1.6vw, 22px);
}

html:has(body.puzzles-app) {
  height: 100%;
  overflow: hidden;
}

body.puzzles-app {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--puzzles-app-topbar) minmax(0, 1fr);
  background: var(--bg);
}

body.puzzles-app > .skip-link {
  position: fixed;
  z-index: 200;
}

body.puzzles-app > footer,
body.puzzles-app > .blupoli-footer,
body.puzzles-app > .related-games {
  display: none !important;
}

body.puzzles-app header[data-site-header] {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  height: var(--puzzles-app-topbar);
  min-height: 0;
  position: relative;
  inset: auto;
  z-index: 70;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-right));
  border: 0;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-deep) 92%, transparent);
  box-shadow: 0 10px 34px color-mix(in srgb, var(--bg-deep) 34%, transparent);
}

body.puzzles-app header[data-site-header] .brand {
  min-width: 0;
}

body.puzzles-app header[data-site-header] .brand > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.puzzles-app header[data-site-header] .mobile-nav-toggle,
body.puzzles-app header[data-site-header] .mobile-nav {
  display: none !important;
}

body.puzzles-app header[data-site-header] .desktop-nav {
  position: fixed;
  z-index: 80;
  inset: auto 0 0;
  height: calc(var(--puzzles-app-bottom-nav) + env(safe-area-inset-bottom));
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  margin: 0;
  padding: 7px max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-deep) 94%, transparent);
  box-shadow: 0 -12px 38px color-mix(in srgb, var(--bg-deep) 42%, transparent);
  backdrop-filter: blur(22px);
}

body.puzzles-app header[data-site-header] .desktop-nav a {
  min-width: 0;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  font-size: .7rem;
  font-weight: 780;
  line-height: 1.05;
  text-align: center;
  transform: none;
}

body.puzzles-app header[data-site-header] .desktop-nav a::before {
  display: block;
  min-height: 1.15rem;
  color: currentColor;
  font-size: 1.02rem;
  font-weight: 900;
  line-height: 1;
}

body.puzzles-app header[data-site-header] .desktop-nav a:nth-child(1)::before { content: "⌂"; }
body.puzzles-app header[data-site-header] .desktop-nav a:nth-child(2)::before { content: "◷"; }
body.puzzles-app header[data-site-header] .desktop-nav a:nth-child(3)::before { content: "⊞"; }
body.puzzles-app header[data-site-header] .desktop-nav a:nth-child(4)::before { content: "▥"; }

body.puzzles-app header[data-site-header] .desktop-nav a:hover,
body.puzzles-app header[data-site-header] .desktop-nav a:focus-visible,
body.puzzles-app header[data-site-header] .desktop-nav a[aria-current="page"] {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--accent) 18%, var(--line));
}


body.puzzles-app header[data-site-header] .secondary-nav {
  display: flex;
  align-items: center;
  margin-left: auto;
}

body.puzzles-app header[data-site-header] .secondary-nav a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid color-mix(in srgb, var(--blue) 24%, var(--line));
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--blue) 8%, var(--surface-soft));
  color: var(--text);
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
}

body.puzzles-app header[data-site-header] .secondary-nav a::after {
  content: "↗";
  font-size: .75em;
}

body.puzzles-app header[data-site-header] .secondary-nav a:not(:first-child) {
  display: none;
}

body.puzzles-app header[data-site-header] .topbar-actions {
  margin-left: 0;
  gap: 6px;
}

body.puzzles-app header[data-site-header] .theme-toggle {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
}

body.puzzles-app header[data-site-header] .theme-toggle-label {
  display: none;
}

body.puzzles-app > main {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
  max-width: none;
  min-width: 0;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding-inline: var(--puzzles-app-gutter);
  padding-bottom: calc(var(--puzzles-app-bottom-nav) + env(safe-area-inset-bottom) + var(--puzzles-app-gutter));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scroll-padding-block: var(--puzzles-app-gutter);
}

body.puzzles-app .home-lobby,
body.puzzles-app .catalogue,
body.puzzles-app .stats-page,
body.puzzles-app .game-layout {
  width: 100%;
  max-width: none;
  margin-inline: 0;
}

body.puzzles-app #today {
  scroll-margin-top: var(--puzzles-app-gutter);
}

/* Today ------------------------------------------------------------------- */

body.puzzles-app .home-lobby {
  padding-top: 0;
}

body.puzzles-app .home-lobby-hero {
  min-height: min(720px, calc(100dvh - var(--puzzles-app-topbar) - var(--puzzles-app-bottom-nav)));
  padding-block: clamp(28px, 5vh, 64px);
}

body.puzzles-app .home-platform-section {
  scroll-margin-top: var(--puzzles-app-gutter);
}

body.puzzles-app .home-recommendations-grid,
body.puzzles-app .home-daily-grid,
body.puzzles-app .home-category-grid {
  width: 100%;
}

/* Explore + Progress ------------------------------------------------------ */

body.puzzles-app .catalogue {
  padding-top: clamp(24px, 4vh, 48px);
}

body.puzzles-app .catalogue-hero,
body.puzzles-app .stats-hero {
  padding-top: 0;
}

body.puzzles-app .catalogue-card-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
}

body.puzzles-app .stats-page {
  padding-top: clamp(24px, 4vh, 48px);
}

body.puzzles-app .stats-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

/* Game ------------------------------------------------------------------- */

body.puzzles-app > main.game-shell {
  --game-context-height: clamp(122px, 18dvh, 168px);
  padding-top: var(--puzzles-app-gutter);
  padding-bottom: calc(var(--puzzles-app-bottom-nav) + env(safe-area-inset-bottom) + var(--puzzles-app-gutter));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--game-context-height) minmax(0, 1fr);
  gap: var(--puzzles-app-gap);
  overflow: hidden;
}

body.puzzles-app .game-shell-heading {
  grid-column: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.puzzles-app .game-shell-heading > .eyebrow {
  margin-bottom: 8px;
}

body.puzzles-app .game-hero-panel {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: clamp(12px, 2vw, 20px);
  border-radius: var(--radius-md);
}

body.puzzles-app .game-symbol {
  width: 54px;
  border-radius: 16px;
}

body.puzzles-app .game-hero-copy h1 {
  margin-bottom: 4px;
  font-size: clamp(1.75rem, 4vw, 3rem);
}

body.puzzles-app .game-hero-copy > p {
  font-size: .92rem;
  line-height: 1.45;
}

body.puzzles-app .game-quick-facts {
  margin-top: 9px;
}

body.puzzles-app .game-play-card {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  container-type: inline-size;
}

body.puzzles-app .game-play-header { grid-row: 1; }
body.puzzles-app .game-controlbar { grid-row: 2; }
body.puzzles-app .engine-warning { grid-row: 3; }
body.puzzles-app .game-stage,
body.puzzles-app .game-root { grid-row: 4; }
body.puzzles-app .game-board-actions { grid-row: 5; }


/* Fit-to-stage contract ----------------------------------------------------
   Expanded game screens reserve their chrome first. Engines then fit their
   playable surface into the exact remaining rectangle; normal gameplay never
   relies on clipping or an internal scrollbar. */
body.puzzles-app .game-fit-slot {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  container-type: size;
}

body.puzzles-app .game-fit-square {
  width: min(100cqw, 100cqh, var(--game-board-max, 640px));
  height: min(100cqw, 100cqh, var(--game-board-max, 640px));
  max-width: 100%;
  max-height: 100%;
}

body.puzzles-app .game-stage .custom-board {
  max-width: 100%;
  max-height: 100%;
}

body.puzzles-app .game-status-wrap { grid-row: 6; }

body.puzzles-app .game-play-header {
  padding: 10px 13px;
}

body.puzzles-app .game-controlbar {
  min-width: 0;
  align-items: center;
  padding: 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

body.puzzles-app .game-options,
body.puzzles-app .game-actions,
body.puzzles-app .game-control-group {
  flex-wrap: nowrap;
}

body.puzzles-app .game-options,
body.puzzles-app .game-actions {
  flex: 0 0 auto;
}

body.puzzles-app .game-stage,
body.puzzles-app .game-root {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: clamp(8px, 1.5vw, 18px);
  overflow: hidden;
  container-type: size;
  display: grid;
  place-items: center;
}

body.puzzles-app .game-stage > *,
body.puzzles-app .game-root > * {
  max-width: 100%;
  max-height: 100%;
}

body.puzzles-app .game-status-wrap {
  min-width: 0;
}

body.puzzles-app .game-guide-card {
  position: fixed;
  z-index: 110;
  inset: auto 8px calc(var(--puzzles-app-bottom-nav) + env(safe-area-inset-bottom) + 8px);
  width: auto;
  max-height: min(76dvh, 720px);
  margin: 0;
  padding: 22px;
  overflow: auto;
  transform: translateY(calc(100% + var(--puzzles-app-bottom-nav) + 32px));
  opacity: 0;
  pointer-events: none;
  transition: transform .22s ease, opacity .18s ease;
  box-shadow: var(--shadow);
}

body.puzzles-app.game-guide-open .game-guide-card {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

body.puzzles-app .game-guide-close {
  position: sticky;
  top: 0;
  z-index: 2;
  float: right;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin: -6px -6px 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
}

body.puzzles-app .game-guide-scrim {
  position: fixed;
  z-index: 100;
  inset: 0;
  border: 0;
  background: color-mix(in srgb, var(--bg-deep) 68%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

body.puzzles-app.game-guide-open .game-guide-scrim {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 520px) {
  body.puzzles-app header[data-site-header] .brand > span:last-child {
    display: none;
  }

  body.puzzles-app header[data-site-header] .site-language-switcher select {
    max-width: 112px;
  }

  body.puzzles-app .home-lobby-hero {
    min-height: auto;
  }

  body.puzzles-app .game-hero-copy > p,
  body.puzzles-app .game-quick-facts,
  body.puzzles-app .game-hero-panel > .pill {
    display: none;
  }

  body.puzzles-app .game-symbol {
    width: 46px;
  }

  body.puzzles-app .game-hero-panel {
    grid-template-columns: auto minmax(0, 1fr);
  }

  body.puzzles-app .game-shell-heading > .eyebrow {
    font-size: .68rem;
  }

  body.puzzles-app .game-play-header {
    gap: 8px;
  }

  body.puzzles-app .play-session #engine-label {
    display: none;
  }
}

/* Landscape tablets and desktop use a persistent navigation rail. */
@media (min-width: 900px) and (orientation: landscape) {
  :root {
    --puzzles-app-bottom-nav: 0px;
  }

  body.puzzles-app {
    grid-template-columns: var(--puzzles-app-rail) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  body.puzzles-app header[data-site-header] {
    grid-column: 1;
    grid-row: 1;
    width: var(--puzzles-app-rail);
    height: 100dvh;
    min-height: 100dvh;
    padding: 18px 12px max(18px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 12px 0 38px color-mix(in srgb, var(--bg-deep) 28%, transparent);
  }

  body.puzzles-app header[data-site-header] .brand {
    min-height: 48px;
    padding-inline: 8px;
  }

  body.puzzles-app header[data-site-header] .desktop-nav {
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 24px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  body.puzzles-app header[data-site-header] .desktop-nav a {
    min-height: 48px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 11px;
    padding: 9px 11px;
    font-size: .84rem;
    text-align: left;
  }

  body.puzzles-app header[data-site-header] .desktop-nav a::before {
    width: 22px;
    min-height: 0;
    flex: 0 0 22px;
    text-align: center;
  }

  body.puzzles-app header[data-site-header] .secondary-nav {
    width: 100%;
    display: grid;
    gap: 4px;
    margin: auto 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--line);
  }

  body.puzzles-app header[data-site-header] .secondary-nav::before {
    content: "BLUPOLI";
    padding: 0 10px 4px;
    color: var(--muted);
    font-size: .62rem;
    font-weight: 850;
    letter-spacing: .12em;
  }

  body.puzzles-app header[data-site-header] .secondary-nav a,
  body.puzzles-app header[data-site-header] .secondary-nav a:not(:first-child) {
    min-height: 38px;
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-subtle);
    font-size: .78rem;
  }

  body.puzzles-app header[data-site-header] .secondary-nav a:hover,
  body.puzzles-app header[data-site-header] .secondary-nav a:focus-visible {
    color: var(--text);
    background: var(--surface-soft);
  }

  body.puzzles-app header[data-site-header] .topbar-actions {
    width: 100%;
    margin: 12px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  body.puzzles-app header[data-site-header] .site-language-switcher {
    margin-left: 0;
    flex: 1 1 100%;
  }

  body.puzzles-app header[data-site-header] .site-language-switcher select {
    width: 100%;
  }

  body.puzzles-app > main {
    grid-column: 2;
    grid-row: 1;
    padding-bottom: var(--puzzles-app-gutter);
  }

  body.puzzles-app > main.game-shell {
    padding-top: 12px;
    padding-bottom: 12px;
    gap: 10px 14px;
    grid-template-columns: minmax(0, 1fr) minmax(270px, 320px);
    grid-template-rows: 76px minmax(0, 1fr);
  }

  body.puzzles-app .game-shell-heading {
    height: 76px;
    min-height: 76px;
    overflow: hidden;
  }

  body.puzzles-app .game-shell-heading > .eyebrow {
    display: none;
  }

  body.puzzles-app .game-hero-panel {
    height: 100%;
    min-height: 0;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 16px;
  }

  body.puzzles-app .game-symbol {
    width: 44px;
    border-radius: 12px;
    font-size: .78rem;
  }

  body.puzzles-app .game-hero-meta {
    margin-bottom: 2px;
    gap: 5px;
  }

  body.puzzles-app .game-badge {
    padding: 3px 7px;
    font-size: .6rem;
  }

  body.puzzles-app .game-hero-copy h1 {
    margin: 0;
    font-size: clamp(1.45rem, 2.3vw, 2rem);
    line-height: 1;
  }

  body.puzzles-app .game-hero-copy > p,
  body.puzzles-app .game-quick-facts {
    display: none;
  }

  body.puzzles-app .game-play-header {
    min-height: 42px;
    padding: 4px 8px;
  }

  body.puzzles-app .play-session {
    gap: 0;
  }

  body.puzzles-app .session-kicker {
    display: none;
  }

  body.puzzles-app .play-session strong {
    font-size: .8rem;
  }

  body.puzzles-app .play-session #engine-label {
    font-size: .6rem;
  }

  body.puzzles-app .game-help-trigger {
    min-height: 36px;
    padding-inline: 10px;
    font-size: .72rem;
  }

  body.puzzles-app .game-controlbar {
    min-height: 44px;
    padding: 4px 7px;
    gap: 6px;
  }

  body.puzzles-app .game-control-label,
  body.puzzles-app .game-control-group-label {
    font-size: .58rem;
  }

  body.puzzles-app .game-select,
  body.puzzles-app .game-action,
  body.puzzles-app .game-segmented-option {
    min-height: 36px;
    font-size: .72rem;
  }

  body.puzzles-app .game-status-wrap {
    min-height: 34px;
  }

  body.puzzles-app .game-status-wrap .game-status {
    padding-block: 6px;
    font-size: .72rem;
  }

  body.puzzles-app .status-hint {
    font-size: .58rem;
    padding-right: 10px;
  }

  body.puzzles-app .game-shell-heading {
    grid-column: 1 / -1;
  }


  body.puzzles-app .game-board-actions {
    width: 100%;
    max-width: none;
    min-height: 48px;
    margin: 0;
    padding: 4px 7px;
    border-inline: 0;
    border-radius: 0;
    box-shadow: none;
    overflow-x: hidden;
  }

  body.puzzles-app .game-board-actions > .game-board-tools {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    overscroll-behavior-x: contain;
  }

  body.puzzles-app .game-board-actions .game-board-tool {
    flex: 1 1 0;
    min-width: 52px;
    min-height: 42px;
    padding: 3px 5px;
  }

  body.puzzles-app .game-board-actions .game-board-tool-icon {
    font-size: 1.15rem;
  }

  body.puzzles-app .game-board-actions .game-board-tool-label {
    font-size: .68rem;
    line-height: 1.05;
    white-space: nowrap;
  }

  body.puzzles-app .game-status-wrap {
    min-height: 40px;
  }


  body.puzzles-app .game-stage,
  body.puzzles-app .game-root {
    overflow: hidden;
  }

  body.puzzles-app .sudoku-shell,
  body.puzzles-app .fifteen-shell,
  body.puzzles-app .polypivot-shell,
  body.puzzles-app .ball-sort-shell {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
  }

  body.puzzles-app .sudoku-shell {
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: clamp(6px, 1cqh, 12px);
  }

  body.puzzles-app .sudoku-board-slot {
    min-height: 0;
  }

  body.puzzles-app .sudoku-board {
    --game-board-max: 640px;
    aspect-ratio: 1;
  }

  body.puzzles-app .sudoku-hud,
  body.puzzles-app .sudoku-input-dock {
    flex: 0 0 auto;
  }

  body.puzzles-app .sudoku-input-dock {
    gap: 6px;
    padding: 8px;
  }

  body.puzzles-app .sudoku-number {
    min-height: 42px;
  }

  body.puzzles-app .sudoku-input-dock .game-board-tool {
    min-height: 46px;
    padding-block: 5px;
  }

  body.puzzles-app .sudoku-session-actions .game-action {
    min-height: 38px;
  }

  body.puzzles-app .fifteen-shell {
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: clamp(6px, 1cqh, 12px);
  }

  body.puzzles-app .fifteen-frame {
    --game-board-max: 580px;
    width: min(100cqw, 100cqh, var(--game-board-max));
    height: min(100cqw, 100cqh, var(--game-board-max));
    max-width: 100%;
    max-height: 100%;
    box-sizing: border-box;
    display: grid;
  }

  body.puzzles-app .fifteen-board {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
  }

  body.puzzles-app .polypivot-shell {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: clamp(5px, .8cqh, 10px);
  }

  body.puzzles-app .polypivot-stage {
    min-width: 0;
    min-height: 0;
    height: 100%;
    display: grid;
    place-items: center;
    container-type: size;
  }

  body.puzzles-app .polypivot-board {
    width: min(100cqw, calc(100cqh * var(--polypivot-board-ratio, 1)));
    height: auto;
    max-width: 100cqw;
    max-height: 100cqh;
    aspect-ratio: var(--polypivot-board-ratio, 1);
  }

  body.puzzles-app .game-guide-card {
    position: static;
    inset: auto;
    width: auto;
    height: 100%;
    max-height: 100%;
    padding: 20px;
    overflow: auto;
    transform: none;
    opacity: 1;
    pointer-events: auto;
    box-shadow: var(--shadow-soft);
  }

  body.puzzles-app .game-guide-close,
  body.puzzles-app .game-guide-scrim {
    display: none !important;
  }
}

@media (min-width: 900px) and (max-width: 1120px) and (orientation: landscape) {
  :root {
    --puzzles-app-rail: 176px;
  }

  body.puzzles-app header[data-site-header] .brand > span:last-child {
    font-size: .88rem;
  }

  body.puzzles-app header[data-site-header] .desktop-nav a {
    font-size: .77rem;
    gap: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.puzzles-app .game-guide-card,
  body.puzzles-app .game-guide-scrim {
    transition: none;
  }
}


/* App-native density ------------------------------------------------------- */

body.puzzles-app .home-lobby-intro h1 {
  max-width: 680px;
  font-size: clamp(2.25rem, 5vw, 4.6rem);
  line-height: .96;
}

body.puzzles-app .home-lobby-intro > p {
  max-width: 620px;
  font-size: clamp(.96rem, 1.35vw, 1.08rem);
  line-height: 1.55;
}

body.puzzles-app .home-lobby-hero {
  grid-template-columns: minmax(0, .82fr) minmax(430px, 1.18fr);
  gap: clamp(22px, 4vw, 56px);
}

body.puzzles-app .home-focus-card {
  min-height: 280px;
  border-radius: var(--radius-md);
}

body.puzzles-app .home-focus-card--daily {
  transform: none;
}

body.puzzles-app .home-platform-section {
  padding: clamp(28px, 4vh, 46px) 0;
}

body.puzzles-app .home-platform-head {
  margin-bottom: clamp(16px, 2.4vh, 24px);
}

body.puzzles-app .home-platform-head h2 {
  font-size: clamp(1.65rem, 3vw, 2.8rem);
}

body.puzzles-app .catalogue-hero {
  padding-bottom: 22px;
}

body.puzzles-app .catalogue-hero h1 {
  max-width: 760px;
  font-size: clamp(2.25rem, 4.6vw, 4.35rem);
}

body.puzzles-app .catalogue-controls {
  position: sticky;
  top: 0;
  z-index: 12;
  margin-bottom: 22px;
  padding-block: 7px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
}

body.puzzles-app .catalogue-category-panel {
  margin-bottom: 28px;
  padding: clamp(16px, 2vw, 22px);
  border-radius: var(--radius-md);
}

body.puzzles-app .catalogue-category-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

body.puzzles-app .catalog-game-card {
  min-height: 220px;
}

body.puzzles-app .stats-hero {
  gap: 20px;
  padding-bottom: 22px;
}

body.puzzles-app .stats-hero h1 {
  font-size: clamp(2.25rem, 4.6vw, 4.2rem);
}

body.puzzles-app .stats-hero p {
  max-width: 720px;
  font-size: clamp(.95rem, 1.4vw, 1.08rem);
  line-height: 1.55;
}

body.puzzles-app .stats-kpi {
  min-height: 118px;
  padding: 16px;
}

body.puzzles-app .stats-card {
  padding: clamp(16px, 2vw, 24px);
}

body.puzzles-app .stats-card-head {
  margin-bottom: 16px;
}

body.puzzles-app .stats-chart,
body.puzzles-app .stats-line-chart {
  min-height: 230px;
}

/* The shell owns control density on game screens, overriding legacy
   small-screen stacking that used to make the page grow vertically. */
body.puzzles-app .game-controlbar {
  flex-direction: row;
}

body.puzzles-app .game-options,
body.puzzles-app .game-actions {
  width: auto;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
}

body.puzzles-app .game-control-group {
  display: flex;
}

body.puzzles-app .game-stage .pzpr-board {
  width: min(100%, 640px);
  height: min(100cqh, 100cqw, 640px);
  min-height: 0;
  aspect-ratio: 1;
}

@media (max-width: 899px), (orientation: portrait) {
  body.puzzles-app .home-lobby-hero {
    grid-template-columns: 1fr;
    min-height: auto;
    gap: 20px;
  }

  body.puzzles-app .home-lobby-focus {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.puzzles-app .home-focus-card {
    min-height: 230px;
  }

  body.puzzles-app .catalogue-hero,
  body.puzzles-app .stats-hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  body.puzzles-app .catalogue-count {
    width: max-content;
  }

  body.puzzles-app .stats-hero-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  body.puzzles-app .home-lobby {
    padding-inline: 0;
  }

  body.puzzles-app .home-lobby-intro h1 {
    font-size: clamp(2rem, 11vw, 3.2rem);
  }

  body.puzzles-app .home-lobby-focus {
    grid-template-columns: 1fr;
  }

  body.puzzles-app .home-focus-card {
    min-height: 205px;
    padding: 18px;
  }

  body.puzzles-app .home-platform-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  body.puzzles-app .home-daily-grid,
  body.puzzles-app .home-recommendations-grid,
  body.puzzles-app .home-favorites-grid {
    grid-template-columns: 1fr;
  }

  body.puzzles-app .catalogue-controls {
    grid-template-columns: 1fr;
  }

  body.puzzles-app .catalogue-mode-switch button {
    min-width: 0;
  }

  body.puzzles-app .catalogue-category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.puzzles-app .catalogue-hero h1,
  body.puzzles-app .stats-hero h1 {
    font-size: clamp(2rem, 10vw, 3rem);
  }

  body.puzzles-app .stats-dashboard-grid,
  body.puzzles-app .stats-dashboard-grid--primary {
    grid-template-columns: 1fr;
  }

  body.puzzles-app .stats-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}



@container (max-width: 620px) {
  body.puzzles-app .game-board-actions .game-board-tool {
    min-width: 48px;
    padding-inline: 4px;
  }

  body.puzzles-app .game-board-actions .game-board-tool-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  body.puzzles-app .game-board-actions .game-board-tool-icon {
    font-size: 1.28rem;
  }
}

/* Mobile game screens ------------------------------------------------------
   The app owns 100dvh, but a game must never be clipped to a synthetic
   fixed-height stage on small screens. Mobile behaves like a native app:
   compact chrome, a vertically scrollable screen, full-width board and
   touch-sized controls. */
@media (max-width: 899px), (orientation: portrait) {
  :root {
    --puzzles-app-topbar: 56px;
    --puzzles-app-bottom-nav: 64px;
    --puzzles-app-gutter: clamp(8px, 2vw, 16px);
    --puzzles-app-gap: 8px;
  }

  body.puzzles-app > main.game-shell {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    min-height: 0;
    padding: 8px 10px calc(var(--puzzles-app-bottom-nav) + env(safe-area-inset-bottom) + 10px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: auto;
    scroll-padding-block: 8px calc(var(--puzzles-app-bottom-nav) + 12px);
    -webkit-overflow-scrolling: touch;
  }

  body.puzzles-app .game-shell-heading {
    flex: 0 0 auto;
    display: block;
    min-height: 0;
    overflow: visible;
  }

  body.puzzles-app .game-shell-heading > .eyebrow {
    margin: 0 2px 4px;
    font-size: .72rem;
    line-height: 1.2;
  }

  body.puzzles-app .game-hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 0;
    padding: 4px 2px 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  body.puzzles-app .game-symbol,
  body.puzzles-app .game-hero-copy > p,
  body.puzzles-app .game-quick-facts,
  body.puzzles-app .game-hero-panel > .pill {
    display: none;
  }

  body.puzzles-app .game-hero-meta {
    margin-bottom: 3px;
    gap: 5px;
  }

  body.puzzles-app .game-badge {
    padding: 3px 7px;
    font-size: .62rem;
  }

  body.puzzles-app .game-hero-copy h1 {
    margin: 0;
    font-size: clamp(1.45rem, 7vw, 2rem);
    line-height: 1;
    letter-spacing: -.035em;
  }

  body.puzzles-app .game-play-card {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
    border-radius: 16px;
  }

  body.puzzles-app .game-play-header {
    min-height: 44px;
    padding: 5px 8px;
    gap: 8px;
  }

  body.puzzles-app .play-session {
    gap: 0;
  }

  body.puzzles-app .session-kicker,
  body.puzzles-app .play-session #engine-label {
    display: none;
  }

  body.puzzles-app .play-session strong {
    font-size: .82rem;
    line-height: 1.15;
  }

  body.puzzles-app .game-help-trigger {
    min-height: 40px;
    padding: 0 10px;
    font-size: .78rem;
  }

  body.puzzles-app .game-controlbar {
    flex: 0 0 auto;
    min-height: 0;
    padding: 5px 7px;
    gap: 6px;
    align-items: center;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  body.puzzles-app .game-controlbar::-webkit-scrollbar {
    display: none;
  }

  body.puzzles-app .game-options,
  body.puzzles-app .game-actions,
  body.puzzles-app .game-control-group {
    width: auto;
    flex: 0 0 auto;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 5px;
  }

  body.puzzles-app .game-control {
    display: block;
    min-width: 0;
  }

  body.puzzles-app .game-control-label,
  body.puzzles-app .game-control-group-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  body.puzzles-app .game-select,
  body.puzzles-app .game-action,
  body.puzzles-app .game-segmented-option {
    min-height: 42px;
    width: auto;
    padding-inline: 10px;
    border-radius: 10px;
    font-size: .84rem;
    white-space: nowrap;
  }

  body.puzzles-app .game-fit-slot {
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    container-type: inline-size;
  }

  body.puzzles-app .game-fit-square {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: none;
    aspect-ratio: 1;
  }

  body.puzzles-app .game-stage,
  body.puzzles-app .game-root {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 8px 5px;
    overflow: visible;
    container-type: inline-size;
    display: block;
  }

  body.puzzles-app .game-stage > *,
  body.puzzles-app .game-root > * {
    width: 100%;
    max-width: 100%;
    max-height: none;
    margin-inline: auto;
  }

  body.puzzles-app .game-stage .pzpr-board {
    width: min(100%, 640px);
    height: auto;
    max-height: none;
    aspect-ratio: 1;
    margin-inline: auto;
  }

  /* Engines that previously filled a fixed stage must become content-sized
     on portrait screens. Their board geometry remains responsive to width. */
  body.puzzles-app .ball-sort-shell {
    height: auto;
    min-height: 0;
    container-type: inline-size;
  }

  body.puzzles-app .ball-sort-board {
    height: auto;
    min-height: 0;
    grid-template-rows: repeat(var(--ball-sort-portrait-rows, 1), auto);
    align-items: center;
  }

  body.puzzles-app .ball-sort-tube {
    block-size: clamp(9.25rem, 45cqw, 11.5rem);
  }

  body.puzzles-app .fifteen-shell,
  body.puzzles-app .sudoku-shell {
    height: auto;
    min-height: 0;
  }

  body.puzzles-app .game-board-actions {
    flex: 0 0 auto;
    width: 100%;
    margin: 0;
    padding: 6px 7px;
    gap: 5px;
    border-radius: 0;
    box-shadow: none;
  }

  body.puzzles-app .game-board-tools {
    grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
    gap: 5px;
  }

  body.puzzles-app .game-board-tool,
  body.puzzles-app .game-board-actions > .game-action,
  body.puzzles-app .game-board-actions > .tool-button,
  body.puzzles-app .game-board-actions > .game-board-tool {
    min-height: 48px;
    padding: 5px 4px;
    border-radius: 10px;
  }

  body.puzzles-app .game-board-tool-icon {
    font-size: 1.15rem;
  }

  body.puzzles-app .game-board-tool-label {
    font-size: .66rem;
    line-height: 1.05;
  }

  body.puzzles-app .game-status-wrap {
    flex: 0 0 auto;
    min-height: 40px;
  }

  body.puzzles-app .game-status-wrap .game-status {
    min-height: 0;
    padding-block: 8px;
    font-size: .78rem;
    line-height: 1.3;
  }

  body.puzzles-app .status-hint {
    display: none;
  }
}

@media (max-width: 430px) {
  body.puzzles-app .game-board-tools {
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  }

  body.puzzles-app .game-board-tool {
    min-height: 46px;
  }

  body.puzzles-app .game-board-tool-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  body.puzzles-app .game-board-tool-icon {
    font-size: 1.22rem;
  }
}


@media (min-width: 900px) and (orientation: landscape) and (max-height: 820px) {
  body.puzzles-app .game-guide-card {
    padding: 14px;
  }

  body.puzzles-app .game-guide-card h2 {
    margin-bottom: 10px;
    font-size: 1.12rem;
  }

  body.puzzles-app .game-guide-card ol li {
    padding-left: 31px;
    font-size: .76rem;
    line-height: 1.42;
  }

  body.puzzles-app .game-guide-card ol li + li {
    margin-top: 9px;
  }

  body.puzzles-app .game-tips {
    margin-top: 12px;
    padding: 10px;
  }
}

@media (max-width: 520px) {
  body.puzzles-app header[data-site-header] .secondary-nav a {
    min-width: 38px;
    padding-inline: 9px;
    font-size: 0;
  }

  body.puzzles-app header[data-site-header] .secondary-nav a::before {
    content: "B";
    font-size: .8rem;
  }

  body.puzzles-app header[data-site-header] .secondary-nav a::after {
    font-size: .65rem;
  }
}
