/* ==========================================================================
   WordNap · iPad / large-screen layout v2 (2026-11-14) — Figma "iPad 适配" (111:10)
   Top/bottom structure: big picture board on top, pets below.
   Loaded after styles.css. Every layout rule sits inside a min-width media query,
   so phones (< 744px wide, or < 600px tall) render exactly as before.
   v6 (严兵 t119u, 2026-11-14): iPad layout is LANDSCAPE ONLY. An iPad held upright gets the
   phone layout and phone rounds; none of the layout rules below match in portrait.
   Tiers:  tablet base      ≥ 744px wide, ≥ 600px tall, landscape orientation
           tablet large     ≥ 1024px wide, ≥ 600px tall, landscape orientation
           rotation fade    ≥ 744 × 600 either way (only #app.wn-reorient, see js/app.js)
   Sizes are the Figma iPad Pro 13″ values (1032×1376 pt); they shrink with the
   viewport (cqw / cqh of #app) so smaller iPads and Safari's toolbar still fit.
   ========================================================================== */

/* Tablet-only pieces stay out of the phone layout. */
.round-side,
.home-stats,
.home-xp,
.recap-reward { display: none; }
.recap-main { display: contents; }

@media (min-width: 744px) and (min-height: 600px) and (orientation: landscape) {
  :root {
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --tab-pad: clamp(24px, 4.65cqw, 48px);
    --tab-col: 720px;
    --tab-btn: 60px;
  }
  #app { max-width: none; }

  /* No hover-only affordances; every tap target ≥ 44pt. Figma round icon buttons are 60pt. */
  .icon-btn { min-width: 48px; min-height: 48px; }
  .icon-btn img { width: 24px; height: 24px; }
  #screen-round .topbar .icon-btn,
  #screen-profile .topbar .icon-btn,
  #screen-home .home-top .icon-btn:not(.pill) {
    width: var(--tab-btn);
    height: var(--tab-btn);
    min-width: var(--tab-btn);
    min-height: var(--tab-btn);
    border: 1.5px solid var(--border-default);
    background: var(--bg-surface);
  }
  #screen-round .topbar .icon-btn img,
  #screen-profile .topbar .icon-btn img,
  #screen-home .home-top .icon-btn img { width: 28px; height: 28px; }
  #screen-round .hint-count {
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border: 2px solid var(--bg-surface);
    font-size: 13px;
    line-height: 20px;
    top: -7px;
    right: -6px;
  }

  /* —— Overlays / sheets: centred cards, never full-width slabs —— */
  .overlay,
  .overlay.from-bottom {
    justify-content: center;
    padding-left: calc(32px + var(--safe-left));
    padding-right: calc(32px + var(--safe-right));
  }
  .overlay.from-bottom { align-items: flex-end; }
  .sheet { max-width: 480px; }
  .sheet.bottom { max-width: 560px; margin: 0 auto; }
  .sheet h2 { font-size: 22px; }
  .sheet p, .sheet li { font-size: 16px; line-height: 1.5; }
  .sheet .btn { min-height: 52px; font-size: 17px; }

  /* ======================= Home (plan A, Figma 119:95) ======================= */
  #screen-home.active {
    padding: calc(16px + var(--safe-top)) calc(var(--tab-pad) + var(--safe-right)) 0 calc(var(--tab-pad) + var(--safe-left));
  }
  #screen-home .home-top { height: 76px; align-items: center; gap: 14px; }
  #screen-home #btn-profile {
    width: auto;
    min-width: 72px;
    height: var(--tab-btn);
    padding: 0 26px;
    font-size: 18px;
    font-weight: 700;
    border: 1.5px solid var(--border-default);
  }
  #screen-home .brand-block { margin-top: 12px; }
  #screen-home .brand { font-size: clamp(48px, 7.4cqw, 76px); line-height: 1.1; }
  #screen-home .tagline { font-size: 21px; line-height: 28px; margin-top: 2px; }
  #screen-home .pack-chip {
    height: 52px;
    min-height: 52px;
    gap: 12px;
    padding: 0 20px 0 10px;
    margin-top: 18px;
    font-size: 18px;
    font-weight: 500;
    border: 1.5px solid var(--border-default);
  }
  #screen-home .pack-chip .chip-badge { font-size: 14px; padding: 4px 12px; }
  #screen-home .pack-chip .chip-caret { font-size: 24px; font-weight: 700; }

  /* Pet stands in front of a wide peach oval and pokes out above it (700×500 oval, 510×624 pet). */
  #screen-home .hero { margin-top: 0; }
  #screen-home .hero-cushion {
    --hero-w: min(700px, 100%, calc((100cqh - 640px) * 1.07));
    width: var(--hero-w);
    height: auto;
    max-height: none;
    aspect-ratio: 700 / 654;
    border-radius: 0;
    border: 0;
    outline: 0;
    background: none;
    box-shadow: none;
  }
  #screen-home .hero-cushion::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 76.5%;
    border-radius: 50%;
    background: var(--fill-accent-soft);
  }
  #screen-home .hero-cat {
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 72.9%;
    height: 95.4%;
    max-width: none;
    max-height: none;
    aspect-ratio: auto;
  }
  #screen-home #companion-line,
  #screen-home .pet-caption { font-size: 26px; line-height: 36px; font-weight: 500; margin-top: 4px; }
  #screen-home .home-xp {
    display: block;
    position: relative;
    width: 240px;
    height: 8px;
    margin: 10px auto 0;
    border-radius: 999px;
    background: var(--bg-muted);
    overflow: hidden;
    flex-shrink: 0;
  }
  #screen-home .home-xp-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 4px; background: var(--fill-accent); }

  /* Info bar = three stats (Figma), replacing the one-line strip + week dots. */
  #screen-home .info-pill {
    max-width: none;
    height: 104px;
    margin: 32px 0 24px;
    padding: 0 24px;
    border: 1.5px solid var(--border-default);
    border-radius: 24px;
    display: flex;
    align-items: center;
  }
  #screen-home .info-pill .line,
  #screen-home .info-pill .week,
  #screen-home #week { display: none; }
  #screen-home .home-stats { display: flex; align-items: center; gap: 16px; width: 100%; }
  .home-stat { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; white-space: nowrap; }
  .home-stat b { font-family: var(--display); font-weight: 500; font-size: 32px; line-height: 1.2; color: var(--text-primary); }
  .home-stat span { font-size: 15px; line-height: 1.4; color: var(--text-secondary); }
  .home-stat-sep { flex: 0 0 1.5px; height: 44px; background: var(--border-default); }
  #screen-home #btn-demo-home:not([hidden]) { max-width: 440px; min-height: 48px; font-size: 15px; margin-bottom: 12px; }
  #screen-home .home-actions { padding-bottom: calc(40px + var(--safe-bottom)); }
  #screen-home .home-actions .btn,
  #screen-home #btn-start {
    max-width: none;
    height: 72px;
    min-height: 72px;
    border-radius: 26px;
    font-size: 28px;
    font-weight: 500;
  }
  #screen-home .home-quota { font-size: 15px; }

  /* ======================= Round, portrait (Figma 115:17) =======================
     top bar · companion strip · big board · prompt strip · tray (208×236 pets) */
  #screen-round.active {
    --seat-gap: 20px;
    --tray-h: 236px;
    --round-pad: clamp(20px, 3.1cqw, 32px);
    padding: calc(16px + var(--safe-top)) calc(var(--round-pad) + var(--safe-right)) calc(32px + var(--safe-bottom)) calc(var(--round-pad) + var(--safe-left));
    gap: 24px;
    align-items: stretch;
  }
  #screen-round .round-spacer-top,
  #screen-round .round-spacer-bottom { display: none; }
  /* v3 (严兵 14:12): no companion card / strip and no 怎么玩 / prompt during play on iPad. */
  #screen-round .round-side,
  #screen-round .prompt { display: none !important; }
  #screen-round .topbar { order: 0; height: 76px; min-height: 76px; gap: 16px; max-width: none; }
  #screen-round .top-actions { gap: 14px; }
  #screen-round .round-title .name { font-size: 26px; line-height: 1.3; font-weight: 700; }
  #screen-round .round-title .meta { font-size: 15px; line-height: 1.4; margin-top: 2px; }

  /* Companion strip */
  .round-side {
    order: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 76px;
    flex: 0 0 auto;
    padding: 0 24px 0 14px;
    border-radius: 20px;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-default);
    box-sizing: border-box;
  }
  .round-side-art { position: relative; width: 56px; height: 56px; flex: 0 0 56px; }
  .round-side-art .pet-sprite,
  .round-side-art img,
  .round-side-art svg {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
  }
  .round-side-name { margin: 0; font-size: 17px; line-height: 1.35; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
  .round-side-sub { margin: 0; font-size: 14px; line-height: 1.35; color: var(--text-secondary); white-space: nowrap; }
  .round-side { display: grid; grid-template-columns: 56px auto 1fr auto minmax(120px, 240px); grid-template-rows: 1fr auto auto 1fr; grid-template-areas: "art . . prog track" "art name . prog track" "art sub . prog track" "art . . prog track"; column-gap: 14px; row-gap: 0; }
  .round-side-art { grid-area: art; align-self: center; }
  .round-side-name { grid-area: name; align-self: end; }
  .round-side-sub { grid-area: sub; align-self: start; }
  .round-side-progress { grid-area: prog; align-self: center; margin: 0; font-size: 15px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
  .round-side-track { grid-area: track; align-self: center; width: 100%; height: 10px; border-radius: 999px; background: var(--bg-muted); overflow: hidden; }
  .round-side-fill { height: 100%; width: 0; min-width: 16px; border-radius: 5px; background: var(--fill-accent); transition: width .35s ease; }

  /* Board: 296pt picture cards, sized down by width and by height. */
  #screen-round .board-wrap { order: 2; flex: 1 1 auto; width: 100%; max-width: none; min-height: 0; }
  #screen-round .board {
    /* v3: no companion strip / prompt during play → the board takes all the room left (top bar 76, tray, 2 gaps, padding). */
    --seat: min(360px,
      calc((100cqw - 2 * var(--round-pad) - var(--safe-left) - var(--safe-right) - (var(--board-cols, 3) - 1) * var(--seat-gap)) / var(--board-cols, 3)),
      calc((100cqh - 76px - var(--tray-h) - 2 * 24px - 48px - var(--safe-top) - var(--safe-bottom) - (var(--board-rows, 3) - 1) * var(--seat-gap)) / var(--board-rows, 3)));
    width: auto;
    grid-template-columns: repeat(var(--board-cols, 3), var(--seat));
    gap: var(--seat-gap);
    justify-content: center;
  }
  #screen-round .seat {
    border-radius: 32px;
    border: 2px solid var(--border-default);
    background: var(--bg-soft);
    min-height: 0;
  }
  #screen-round .seat .cell-pic { inset: 6.8%; border-radius: 0; }
  #screen-round .seat.selected,
  #screen-round .seat.drop-hover { border: 4px solid var(--fill-accent); background: var(--bg-soft); }
  #screen-round .seat.pulse { border: 4px solid var(--gold); }

  /* 已回窝 (Figma 122:240): faded picture, sleeping pet curled on it, zzz top-right, word tag at the bottom. */
  #screen-round .seat.occupied { border: 2px solid var(--border-default); }
  #screen-round .seat.occupied .cell-pic { inset: 6.8%; opacity: .28; }
  #screen-round .seat.occupied .placed-cat { inset: 6.8% 15.2% 24.3% 13.9%; overflow: visible; }
  #screen-round .seat.occupied .zzz-bits {
    top: 4%;
    right: 7%;
    font-family: var(--display);
    font-style: normal;
    font-weight: 500;
    font-size: clamp(14px, calc(var(--seat) * .075), 22px);
    color: var(--text-secondary);
  }
  #screen-round .seat.occupied .cell-word,
  .board.size-4 .seat.occupied .cell-word,
  .board.size-5 .seat.occupied .cell-word {
    z-index: 5;
    left: 50%;
    right: auto;
    bottom: 8.1%;
    transform: translateX(-50%);
    height: clamp(28px, calc(var(--seat) * .135), 40px);
    padding: 0 clamp(10px, calc(var(--seat) * .06), 18px);
    display: flex;
    align-items: center;
    white-space: nowrap;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-default);
    font-family: var(--font-en);
    font-weight: 700;
    font-size: clamp(14px, calc(var(--seat) * .075), 22px);
    line-height: 1;
    color: var(--text-primary);
    box-sizing: border-box;
  }

  /* Prompt strip */
  #screen-round .prompt {
    order: 3;
    max-width: none;
    height: 56px;
    min-height: 56px;
    padding: 0 24px;
    border-radius: 16px;
    background: var(--bg-soft);
    justify-content: flex-start;
    text-align: left;
    font-size: 17px;
    line-height: 1.4;
    color: var(--text-primary);
  }
  #screen-round .prompt.warn { color: var(--text-accent); background: var(--fill-accent-soft); }

  /* Tray: big pet cards, 208×236, shrink to fit when there are more pets. */
  #screen-round .tray,
  #screen-round .tray:not(.is-overflowing):not(.is-empty) {
    order: 4;
    max-width: none;
    height: var(--tray-h);
    min-height: var(--tray-h);
    gap: 32px;
    padding: 0;
    flex-wrap: nowrap;
    overflow: visible;
    justify-content: center;
    align-items: stretch;
  }
  #screen-round .cat-card {
    flex: 0 1 208px;
    width: 208px;
    min-width: 0;
    max-width: 208px;
    height: var(--tray-h);
    min-height: 0;
    max-height: none;
    padding: 12px 8px;
    gap: 10px;
    justify-content: center;
    overflow: hidden;
    border-radius: 32px;
    border: 2px solid var(--border-default);
    background: var(--bg-surface);
  }
  #screen-round .cat-card.selected { border: 5px solid var(--fill-accent); }
  #screen-round .cat-card .cat-art {
    width: min(156px, 100%);
    height: auto;
    aspect-ratio: 1;
    flex: 0 1 auto;
    max-height: calc(var(--tray-h) - 84px);
  }
  #screen-round .cat-card .word,
  #screen-round .cat-card .word.long {
    padding: 4px 14px;
    border-radius: 999px;
    background: var(--bg-soft);
    font-family: var(--font-en);
    font-weight: 700;
    font-size: 24px;
    line-height: 1.35;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
  }
  #screen-round .cat-card .word.long { font-size: 19px; }
  #screen-round .tray-empty { font-size: 16px; align-self: center; }

  /* ======================= Recap, portrait (Figma 118:64) ======================= */
  #screen-recap.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto auto 1fr auto auto;
    grid-template-areas:
      "kicker kicker"
      "title  title"
      "sub    sub"
      "lang   lang"
      "quilt  quilt"
      "reward reward"
      ".      ."
      "note   note"
      "back   next";
    column-gap: 16px;
    justify-items: stretch;
    padding: calc(28px + var(--safe-top)) calc(var(--tab-pad) + var(--safe-right)) calc(40px + var(--safe-bottom)) calc(var(--tab-pad) + var(--safe-left));
  }
  #screen-recap .recap-main,
  #screen-recap .recap-actions { display: contents; }
  #screen-recap .recap-kicker { grid-area: kicker; font-size: 16px; line-height: 22px; height: auto; max-width: none; }
  #screen-recap .recap-title { grid-area: title; font-size: 44px; line-height: 1.3; margin-top: 4px; max-width: none; }
  #screen-recap .recap-sub { grid-area: sub; font-size: 18px; line-height: 1.4; margin-top: 4px; max-width: none; }
  #screen-recap #btn-recap-repeat { height: 44px; min-height: 44px; min-width: 120px; padding: 0 20px; font-size: 18px; }
  #screen-recap .word-tile.is-matched::after { top: 12px; right: 12px; width: 24px; height: 24px; line-height: 24px; font-size: 14px; }
  #screen-recap .word-tile.is-listening::before { top: 12px; left: 12px; }
  #screen-recap .lang-switch-row { grid-area: lang; margin-top: 16px; height: auto; max-width: none; }
  #screen-recap .lang-switch-row .lang-switch { padding: 4px; }
  #screen-recap .lang-switch-row .lang-opt { min-width: 56px; height: 36px; font-size: 16px; }
  #screen-recap .quilt,
  #screen-recap .quilt.cols-3 {
    grid-area: quilt;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    grid-template-columns: none;
    gap: 24px;
    max-width: none;
    max-height: none;
    margin-top: 36px;
    overflow: visible;
  }
  #screen-recap .word-tile {
    align-self: stretch;
    height: 100%;
    aspect-ratio: auto;
    min-height: 0;
    padding: 16px 16px 24px;
    border-radius: 32px;
    border: 1.5px solid var(--border-default);
    background: var(--bg-surface);
    gap: 0;
    justify-content: flex-start;
  }
  #screen-recap .word-tile .illust {
    width: 100%;
    height: auto;
    aspect-ratio: 256 / 264;
    border-radius: 24px;
    background: var(--bg-soft) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  #screen-recap .word-tile .illust .word-art,
  #screen-recap .word-tile .illust img,
  #screen-recap .word-tile .illust svg { width: 92%; height: 89%; aspect-ratio: auto; object-fit: contain; background: transparent !important; }
  #screen-recap .word-tile .w { margin-top: 20px; font-family: var(--font-en); font-weight: 700; font-size: clamp(26px, 3.7cqw, 38px); line-height: 1.3; }
  #screen-recap .word-tile .ipa { margin-top: 8px; font-family: var(--font); font-weight: 400; font-size: 20px; line-height: 1.3; color: var(--text-secondary); }
  #screen-recap .word-tile .def {
    margin-top: 4px;
    padding-bottom: 10px;
    width: min(216px, 100%);
    border-bottom: 1px solid var(--border-default);
    font-weight: 500;
    font-size: clamp(20px, 2.7cqw, 28px);
    line-height: 1.4;
    color: var(--text-primary);
  }
  #screen-recap .word-tile .ex { margin-top: 10px; font-family: var(--font); font-weight: 400; font-size: clamp(15px, 1.85cqw, 19px); line-height: 1.35; color: var(--text-primary); -webkit-line-clamp: unset; display: block; }
  #screen-recap .word-tile .ex.ex-zh { margin-top: 4px; font-family: var(--font); font-size: 16px; color: var(--text-secondary); }

  /* Reward card (companion + xp) */
  #screen-recap .recap-reward:not([hidden]) {
    grid-area: reward;
    display: flex;
    align-items: center;
    gap: 24px;
    margin-top: 24px;
    padding: 18px 28px;
    border-radius: 24px;
    border: 1.5px solid var(--border-default);
    background: var(--bg-surface);
    text-align: left;
  }
  .recap-reward-art { position: relative; width: 96px; height: 96px; flex: 0 0 96px; }
  .recap-reward-art .pet-sprite,
  .recap-reward-art img,
  .recap-reward-art svg { position: absolute; inset: 0; width: 100% !important; height: 100% !important; object-fit: contain; }
  .recap-reward-text { flex: 1 1 auto; min-width: 0; }
  .recap-reward-head { margin: 0; font-size: 20px; line-height: 1.4; font-weight: 700; color: var(--status-remembered); }
  .recap-reward-bar { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
  .recap-reward-track { position: relative; flex: 0 1 360px; height: 8px; border-radius: 999px; background: var(--bg-muted); overflow: hidden; }
  .recap-reward-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 4px; background: var(--status-remembered); }
  .recap-reward-level { font-size: 15px; color: var(--text-secondary); white-space: nowrap; }
  .recap-reward-more { margin: 8px 0 0; font-size: 15px; line-height: 1.4; color: var(--text-secondary); }
  .recap-reward-more:empty { display: none; }

  #screen-recap .recap-foot { grid-area: note; margin: 0 0 12px; }
  #screen-recap .recap-foot .recap-awards { display: none; }
  #screen-recap #recap-note { font-size: 17px; line-height: 1.4; text-align: center; }
  #screen-recap #btn-back-home,
  #screen-recap #btn-next {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 72px;
    min-height: 72px;
    margin: 0;
    border-radius: 26px;
    font-size: 28px;
    font-weight: 500;
  }
  #screen-recap #btn-back-home { grid-area: back; background: var(--fill-accent-soft); color: var(--fill-accent); border: 0; }
  #screen-recap #btn-next { grid-area: next; }

  /* ======================= Profile (Figma 121:113) ======================= */
  #screen-profile.active {
    padding-left: calc(var(--tab-pad) + var(--safe-left));
    padding-right: calc(var(--tab-pad) + var(--safe-right));
    align-items: center;
    overflow-y: auto;
  }
  #screen-profile .profile-topbar { width: 100%; max-width: 1280px; height: 76px; min-height: 76px; }
  #screen-profile .round-title .name { font-size: 26px; line-height: 1.3; }
  #screen-profile .round-title .meta { font-size: 15px; }
  #screen-profile .profile-body {
    width: 100%;
    max-width: 1280px;
    flex: 0 0 auto;
    height: auto;
    overflow: visible;
    columns: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: calc(32px + var(--safe-bottom));
  }
  #screen-profile .profile-card { display: block; width: auto; margin: 0; break-inside: avoid; padding: 24px 28px; border-radius: 28px; }
  #screen-profile .profile-card h3 { font-size: 22px; line-height: 1.4; }
  #screen-profile .profile-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  #screen-profile .profile-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
  #screen-profile .profile-stats { gap: 16px; }
  #screen-profile .profile-stat { padding: 18px 8px; border-radius: 20px; }
  #screen-profile .profile-stat b { font-size: 30px; line-height: 1.25; }
  #screen-profile .profile-stat span { font-size: 16px; }
  #screen-profile .profile-pet-list { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  #screen-profile .profile-pet {
    min-height: 0;
    padding: 14px 8px 12px;
    border-radius: 24px;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-default);
  }
  #screen-profile .profile-pet.locked { background: var(--bg-muted); border-color: transparent; }
  #screen-profile .profile-pet.companion { outline: 0; border: 3px solid var(--fill-accent); }
  #screen-profile .profile-pet .art,
  #screen-profile .profile-pet .art .pet-sprite,
  #screen-profile .profile-pet .art img,
  #screen-profile .profile-pet .art .pet-sprite img { width: min(104px, 100%); }
  #screen-profile .profile-pet h4 { font-size: 17px; }
  #screen-profile .profile-pet .sub { font-size: 13px; }
  #screen-profile .profile-link,
  #btn-profile-switch-pack { min-height: 44px; padding: 0 6px; display: inline-flex; align-items: center; font-size: 16px; }
  #screen-profile .profile-unit { min-height: 56px; }

  /* —— Pet den (house): wider grid —— */
  #screen-pets.active {
    padding-left: calc(var(--tab-pad) + var(--safe-left));
    padding-right: calc(var(--tab-pad) + var(--safe-right));
    align-items: center;
  }
  #screen-pets .pets-topbar,
  #screen-pets .pets-tabs,
  #screen-pets .pets-body { max-width: 1120px; }
  #screen-pets .pets-tabs { max-width: 520px; }
  #screen-pets .pet-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  #screen-pets .pet-card { min-height: 150px; }
  #screen-pets .pet-card .art { width: 84px; height: 84px; }
  #screen-pets .pets-hero .hero-art { width: min(220px, 100%); height: 240px; }
  #screen-pets .stage-timeline { width: 100%; max-width: 420px; margin-left: auto; margin-right: auto; }
  #screen-pets .nest-slots { max-width: 560px; margin-left: auto; margin-right: auto; }
  #screen-pets .recipe-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }

  /* —— Onboarding —— */
  #screen-onboard.active {
    padding-left: calc(var(--tab-pad) + var(--safe-left));
    padding-right: calc(var(--tab-pad) + var(--safe-right));
    align-items: center;
  }
  #screen-onboard.active > * { width: 100%; max-width: var(--tab-col); }
}

/* ===================== Landscape tablet / desktop ===================== */
@media (min-width: 1024px) and (min-height: 600px) and (orientation: landscape) {
  :root { --tab-pad: clamp(32px, 4.1cqw, 56px); }

  /* —— Home (Figma 125:286): brand in the top row, pet centred, stats + CTA side by side —— */
  #screen-home.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) min(400px, 32cqw);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "top   top"
      "chip  chip"
      "hero  hero"
      "info  cta";
    column-gap: 20px;
    padding-top: calc(8px + var(--safe-top));
    padding-bottom: calc(28px + var(--safe-bottom));
  }
  #screen-home .home-top { grid-area: top; height: 96px; max-width: none; }
  #screen-home .brand-block {
    grid-area: top;
    justify-self: center;
    align-self: center;
    width: auto;
    margin: 0;
    pointer-events: none;
    display: contents;
  }
  #screen-home .brand-block .brand,
  #screen-home .brand-block .tagline { grid-area: top; justify-self: center; pointer-events: none; }
  #screen-home .brand-block .brand { align-self: start; margin-top: 4px; font-size: 56px; line-height: 64px; }
  #screen-home .brand-block .tagline { align-self: end; margin: 0 0 4px; font-size: 18px; line-height: 24px; }
  #screen-home .brand-block .pack-chip { grid-area: chip; justify-self: center; margin-top: 14px; height: 48px; min-height: 48px; font-size: 17px; pointer-events: auto; }
  #screen-home .brand-block .pack-chip .chip-caret { font-size: 22px; }
  #screen-home .hero-tap { grid-area: hero; min-height: 0; justify-content: center; }
  #screen-home .hero { flex: 0 1 auto; min-height: 0; }
  #screen-home .hero-cushion {
    --hero-w: min(760px, 100%, calc((100cqh - 96px - 62px - 80px - 120px - var(--safe-top) - var(--safe-bottom)) * 1.288));
    aspect-ratio: 760 / 590;
  }
  #screen-home .hero-cushion::before { height: 76.3%; }
  #screen-home .hero-cat { width: 63.4%; height: 100%; }
  #screen-home #companion-line,
  #screen-home .pet-caption { font-size: 24px; line-height: 32px; margin-top: 6px; }
  #screen-home .home-xp { width: 220px; margin-top: 8px; }
  #screen-home .welcome { display: none; }
  #screen-home .info-pill { grid-area: info; height: 80px; margin: 24px 0 0; padding: 0 24px; align-self: end; }
  .home-stat { flex-direction: row; align-items: baseline; justify-content: center; gap: 10px; }
  .home-stat b { font-size: 30px; }
  .home-stat-sep { height: 36px; }
  #screen-home #btn-demo-home:not([hidden]) { grid-area: chip; justify-self: end; align-self: center; margin: 14px 0 0; }
  #screen-home .home-actions { grid-area: cta; align-self: end; padding: 0; margin-top: 24px; }
  #screen-home .home-quota:not([hidden]) { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; text-align: center; }
  #screen-home .home-actions .btn,
  #screen-home #btn-start { height: 80px; min-height: 80px; }

  /* —— Round (Figma 117:34): board on top, bottom row = companion card · tray · 怎么玩 card —— */
  #screen-round.active {
    --seat-gap: 24px;
    --side-w: clamp(200px, 19.2cqw, 264px);
    /* v3: full 236 tray on a full-height 13″ screen; on shorter screens the tray gives way so the pictures stay big. */
    --tray-h: clamp(176px, calc(100cqh - 796px), 236px);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) var(--tray-h);
    grid-template-areas:
      "top"
      "board"
      "tray";
    column-gap: 24px;
    row-gap: 12px;
    padding: calc(8px + var(--safe-top)) calc(var(--tab-pad) + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(var(--tab-pad) + var(--safe-left));
  }
  #screen-round .topbar { grid-area: top; height: 64px; min-height: 64px; }
  #screen-round .round-title .name { font-size: 24px; }
  #screen-round .board-wrap { grid-area: board; align-self: center; }
  #screen-round .board {
    --seat: min(360px,
      calc((100cqw - 2 * var(--tab-pad) - var(--safe-left) - var(--safe-right) - (var(--board-cols, 3) - 1) * var(--seat-gap)) / var(--board-cols, 3)),
      calc((100cqh - 64px - var(--tray-h) - 2 * 12px - 28px - 4px - var(--safe-top) - var(--safe-bottom) - (var(--board-rows, 3) - 1) * 20px) / var(--board-rows, 3)));
    row-gap: 20px;
  }

  /* Companion card (bottom-left) */
  .round-side {
    grid-area: side;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-radius: 32px;
    overflow: hidden;
  }
  .round-side-art { width: clamp(64px, 9.3cqh, 96px); height: clamp(64px, 9.3cqh, 96px); flex: 0 0 auto; }
  .round-side-name,
  .round-side-sub,
  .round-side-progress { align-self: center; text-align: center; }
  .round-side-name { font-size: 17px; margin-top: 2px; }
  .round-side-sub { font-size: 14px; margin-bottom: 4px; }
  .round-side-progress { font-size: 14px; margin: 0; }
  .round-side-track { display: none; }
  .round-side-progress { display: flex; align-items: center; gap: 10px; }
  .round-side-progress::after {
    content: "";
    width: 110px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(var(--fill-accent), var(--fill-accent)) 0 0 / var(--side-done, 0%) 100% no-repeat, var(--bg-muted);
  }

  /* 怎么玩 card (bottom-right) */
  #screen-round .prompt {
    grid-area: prompt;
    height: auto;
    min-height: 0;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    padding: 0 24px;
    border-radius: 32px;
    font-size: 18px;
    line-height: 1.5;
  }
  #screen-round .prompt::before {
    content: attr(data-kicker);
    font-size: 15px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--fill-accent);
  }

  /* Tray between the two cards */
  #screen-round .tray,
  #screen-round .tray:not(.is-overflowing):not(.is-empty) {
    grid-area: tray;
    height: var(--tray-h);
    min-height: 0;
    gap: clamp(12px, 2cqw, 28px);
    padding: 0;
  }

  /* —— Recap (Figma 124:251): 3 word cards left, reward + actions column right —— */
  #screen-recap.active {
    grid-template-columns: minmax(0, 1fr) min(296px, 24cqw);
    grid-template-rows: auto auto auto 1fr auto auto auto auto 1fr;
    grid-template-areas:
      "kicker kicker"
      "title  title"
      "sub    sub"
      ".      ."
      "quilt  reward"
      "quilt  note"
      "quilt  next"
      "quilt  back"
      ".      .";
    column-gap: 24px;
    padding-top: calc(16px + var(--safe-top));
    padding-bottom: calc(32px + var(--safe-bottom));
  }
  #screen-recap .recap-title { font-size: 40px; }
  #screen-recap .recap-sub { justify-self: end; margin: 8px calc(50% + 6px) 0 0; width: auto; font-size: 17px; align-self: center; }
  #screen-recap .lang-switch-row { grid-area: sub; justify-self: start; margin: 8px 0 0 calc(50% + 6px); width: auto; align-self: center; }
  #screen-recap .quilt,
  #screen-recap .quilt.cols-3 { margin-top: 0; align-self: stretch; }
  #screen-recap .word-tile .def { font-size: clamp(20px, 2cqw, 28px); }
  #screen-recap .recap-reward:not([hidden]) {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 20px 24px;
    border-radius: 28px;
    text-align: center;
  }
  .recap-reward-art { width: clamp(96px, 11.6cqh, 140px); height: clamp(96px, 11.6cqh, 140px); flex-basis: auto; }
  .recap-reward-text { width: 100%; }
  .recap-reward-bar { flex-direction: column; gap: 10px; }
  .recap-reward-track { flex: 0 0 auto; width: 100%; }
  .recap-reward-head { font-size: 19px; }
  #screen-recap .recap-foot { align-self: end; margin: 16px 0 12px; }
  #screen-recap #btn-next { margin-bottom: 16px; }

  /* —— Profile (Figma 126:300): two columns —— */
  #screen-profile .profile-cols { grid-template-columns: minmax(0, 1.36fr) minmax(0, 1fr); }
  #screen-profile .profile-pet-list { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  /* —— Pet den —— */
  #screen-pets .pets-body {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    align-content: start;
  }
  #screen-pets .pets-body > .pets-hero { position: sticky; top: 0; margin: 0; }
  #screen-pets .pets-body > :not(.pets-hero):not(.pet-grid) { grid-column: 1 / -1; }
  #screen-pets .pets-body > .pets-hero ~ .pet-grid { grid-column: 2; }
}

/* ===== v4: iPad rounds use 5 words on a 5 × 2 board (js/app.js beginRound → TABLET_WORDS / TABLET_PICTURES) ===== */
@media (min-width: 744px) and (min-height: 600px) and (orientation: landscape) {
  #screen-round.active { --seat-gap: clamp(12px, 1.9cqw, 20px); }
  #screen-round .seat,
  #screen-round .seat.occupied { border-radius: clamp(18px, calc(var(--seat) * .12), 32px); }
  /* 5 pet cards side by side: cards shrink evenly, gaps and type follow the width. */
  #screen-round .tray,
  #screen-round .tray:not(.is-overflowing):not(.is-empty) { gap: clamp(12px, 2.2cqw, 32px); }
  #screen-round .cat-card { border-radius: clamp(20px, 2.6cqw, 32px); padding: 12px 6px; }
  #screen-round .cat-card .word,
  #screen-round .cat-card .word.long { padding: 4px clamp(8px, 1.2cqw, 14px); font-size: clamp(15px, 2.1cqw, 24px); }
  #screen-round .cat-card .word.long { font-size: clamp(13px, 1.7cqw, 19px); }

  /* Recap with 5 word cards */
  #screen-recap .quilt[data-count="5"] { gap: clamp(10px, 1.6cqw, 20px); }
  #screen-recap .quilt[data-count="5"] .word-tile { padding: 10px 10px 16px; border-radius: clamp(18px, 2.4cqw, 28px); }
  #screen-recap .quilt[data-count="5"] .word-tile .illust { border-radius: clamp(14px, 1.8cqw, 22px); }
  #screen-recap .quilt[data-count="5"] .word-tile .w { margin-top: 12px; font-size: clamp(18px, 2.5cqw, 30px); overflow-wrap: anywhere; }
  #screen-recap .quilt[data-count="5"] .word-tile .ipa { font-size: clamp(13px, 1.5cqw, 18px); }
  #screen-recap .quilt[data-count="5"] .word-tile .def { font-size: clamp(15px, 1.9cqw, 22px); }
  #screen-recap .quilt[data-count="5"] .word-tile .ex { font-size: clamp(12px, 1.4cqw, 16px); overflow-wrap: anywhere; }
  #screen-recap .quilt[data-count="5"] .word-tile .ex.ex-zh { font-size: clamp(12px, 1.3cqw, 15px); }
}
@media (min-width: 1024px) and (min-height: 600px) and (orientation: landscape) {
  #screen-round .tray,
  #screen-round .tray:not(.is-overflowing):not(.is-empty) { gap: clamp(12px, 2cqw, 28px); }
  #screen-recap .quilt[data-count="5"] .word-tile .def { font-size: clamp(15px, 1.5cqw, 22px); }
  #screen-recap .quilt[data-count="5"] .word-tile .w { font-size: clamp(18px, 2cqw, 30px); }
}

/* Rotation fade (js/app.js fadeReorient). The only rule that can match an iPad in portrait: it animates
   #app.wn-reorient (set for ~0.3s right after a rotation); the portrait layout itself is plain phone CSS. */
@media (min-width: 744px) and (min-height: 600px) {
  @keyframes wn-reorient { from { opacity: 0; } to { opacity: 1; } }
  #app.wn-reorient { animation: wn-reorient .3s ease-out both; }
}
@media (min-width: 744px) and (min-height: 600px) and (prefers-reduced-motion: reduce) {
  #app.wn-reorient { animation: none; }
}

/* ===== Quick study on iPad landscape / desktop (portrait uses the phone rules; column-width still fills the width) ===== */
@media (min-width: 744px) and (min-height: 600px) and (orientation: landscape) {
  #screen-onboard .pack-card-wrap { max-width: var(--tab-col); }
  #screen-onboard .pack-card-wrap .pack-study { right: 20px; top: 21px; height: 36px; min-height: 36px; padding: 0 16px; font-size: 14px; }
  #screen-onboard .pack-card.has-study .card-top { padding-right: 120px; min-height: 36px; }
  #screen-study.active {
    padding: calc(24px + var(--safe-top)) calc(var(--tab-pad, 32px) + var(--safe-right)) 0 calc(var(--tab-pad, 32px) + var(--safe-left));
    gap: 10px;
  }
  #screen-study #study-title { font-size: 22px; line-height: 28px; }
  #screen-study #study-meta { font-size: 14px; line-height: 18px; }
  #screen-study .study-hint { font-size: 14px; line-height: 18px; }
  .study-mode-opt { height: 36px; min-width: 64px; font-size: 15px; }
  .study-cols { gap: 14px; }
  #screen-study.study-compact .study-cols { gap: 10px; }
  .study-card { margin-bottom: 14px; }
  #screen-study.study-compact .study-card { margin-bottom: 12px; }
  .study-card .w { font-size: 20px; line-height: 26px; }
  #screen-study.study-compact .study-card .w { font-size: 17px; line-height: 22px; }
  .study-card .def { font-size: 15px; line-height: 20px; }
  .study-card .ex { font-size: 13px; line-height: 18px; }
  .study-unit { font-size: 15px; margin: 14px 2px 10px; }
}
