/* ===== LANDSCAPE-ONLY LAYOUTS (owner 2026-10-15) =====
   Everything here only applies on a phone held sideways (short viewport). The base style.css stays as it was.
   Design canvas 844x390 (also checked at 667x375 and 915x412). Safe area for UI: central ~667x335.
   One section per screen/game. */
@media (orientation: landscape) and (max-height: 900px) {

  #screen-tens > .tens-playing[hidden], #screen-space > .sp-playing[hidden] { display: none; }
  /* --- tens (湊十): the board is 5x7 and tall, so it sits on the right with info on the left --- */
  #screen-tens > .tens-playing { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "ask board fuse" "info board tip"; grid-template-rows: auto auto; align-content: center; align-items: center; justify-items: stretch; gap: 8px 16px; padding: 0 max(16px, env(safe-area-inset-left)) 6px max(16px, env(safe-area-inset-right)); }
  #screen-tens .tens-fuse { grid-area: fuse; width: 100%; }
  #screen-tens .tens-info { grid-area: info; text-align: center; }
  #screen-tens .tens-ask { grid-area: ask; margin: 0; text-align: center; font-size: 16px; }
  #screen-tens .tens-tip { grid-area: tip; margin: 0; padding: 8px 8px 8px 64px; min-height: 0; font-size: 13px; background-size: 44px; background-position: 8px center; }
  #screen-tens .tens-board { grid-area: board; margin: 0; }
  #screen-tens .tens-roof { display: none; }

  /* --- shared: slim HUD, 2-column setup/result panels --- */
  .hud { height: 44px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .pop-panel { padding: 4px max(24px, env(safe-area-inset-left)) 10px; gap: 8px 28px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-content: center; align-items: center; text-align: center; overflow-y: auto; }
  .pop-panel[hidden] { display: none; }
  .pop-panel > .pop-title { grid-column: 1 / -1; margin: 0; font-size: 26px; }
  .pop-panel > .pop-how { grid-column: 1; grid-row: 2 / span 4; margin: 0; text-align: left; }
  .pop-panel > .tens-levels { grid-column: 2; }
  .pop-panel > .pop-best { grid-column: 2; margin: 0; }
  .pop-panel > .big-btn { grid-column: 2; margin: 0 auto; }
  .pop-panel > .pop-medal { grid-column: 1; grid-row: 1 / span 4; justify-self: center; }
  .pop-panel > .chip, .pop-panel > .score, .pop-panel > .stats, .pop-panel > .actions, .pop-panel > .pop-progress, .pop-panel > .pop-best { grid-column: 2; }

  /* --- pop (氣球): target + info on the left, the field uses the full height on the right --- */
  #screen-pop > .pop-playing { flex-direction: row; gap: 14px; padding: 0 max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); }
  #screen-pop .pop-top { flex: 0 0 150px; flex-direction: column; justify-content: flex-start; gap: 10px; padding-top: 6px; }
  #screen-pop .pop-field { flex: 1 1 auto; }

  /* --- space (太空): question on the left, field on the right --- */
  #screen-space > .sp-playing { display: grid; grid-template-columns: clamp(170px, 27vw, 240px) minmax(0, 1fr); grid-template-rows: 1fr auto; grid-template-areas: "q field" "food field"; gap: 6px 14px; padding: 0 max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  #screen-space .sp-q { grid-area: q; margin: 0; align-self: center; font-size: clamp(40px, 6.4vw, 56px); line-height: 1.12; overflow-wrap: anywhere; } /* owner 10-28: the equation on the left must be bigger (shooter.js fitQ shrinks long sentences to the column) */
  #screen-space .sp-food { grid-area: food; align-self: end; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
  #screen-space .sp-field { grid-area: field; min-height: 0; }

  /* --- fish (釣魚): target on the left, pond on the right --- */
  #screen-fish > .fi-playing { flex-direction: row; gap: 14px; padding: 0 max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  #screen-fish .fi-target { flex: 0 0 150px; margin: 0; align-self: center; font-size: 38px; }
  #screen-fish .fi-pond { flex: 1 1 auto; }
  /* the pond is wide but short: smaller fish, rows packed into the water */
  #screen-fish .fi-fish { width: 15%; }
  #screen-fish .fi-fish[data-i="0"] { top: 28% !important; } #screen-fish .fi-fish[data-i="1"] { top: 40% !important; } #screen-fish .fi-fish[data-i="2"] { top: 52% !important; }
  #screen-fish .fi-fish[data-i="3"] { top: 64% !important; } #screen-fish .fi-fish[data-i="4"] { top: 74% !important; }


  /* --- memory (翻牌): the grid is centred and limited by the height --- */
  #screen-memory > .mem-playing { padding: 4px 12px 10px; }
  #screen-memory .mem-grid { width: min(100%, 700px); gap: 8px 10px; }
  #screen-memory .mem-card { aspect-ratio: auto; height: min(150px, calc((100dvh - 110px) / var(--rows, 2))); }
  #screen-memory .mem-card .mem-face { font-size: clamp(18px, 3.4vw, 26px); }

  /* --- mole (地鼠): the equation on the left, the six holes on the right --- */
  #screen-mole > .mo-playing { flex-direction: row; gap: 14px; padding: 0 max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  #screen-mole .mo-q { position: absolute; top: 50px; left: 0; right: 0; width: max-content; margin-inline: auto; /* owner 40: centred WITHOUT a transform, so the q-new pop animation (which sets transform) cannot throw the row sideways */ flex: none; flex-direction: row; align-items: center; margin-block: 0; gap: 10px; z-index: 5; } /* owner 17002: the question is ONE horizontal row: number, sign, number */
  #screen-mole .mo-q .mo-card { min-width: 76px; padding: 4px 10px; font-size: 30px; line-height: 38px; } #screen-mole .mo-q .mo-eq { width: 48px; height: 48px; font-size: 32px; box-sizing: border-box; padding: 0; line-height: .8; } /* owner 17064: the sign sits in the middle of the circle (its ink was 4.75 px low; line-height .8 centres it within 1 px) */
  #screen-mole .mo-field { flex: 1 1 auto; }

  /* --- landing / home: pet on the left, check-in + buttons on the right --- */
  #screen-landing.is-active { display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr); grid-template-rows: auto auto auto auto auto 1fr; gap: 6px 20px; align-content: start; padding: 6px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); overflow-y: auto; }
  #screen-landing .land-top { grid-column: 1 / -1; grid-row: 1; }
  #screen-landing .land-pet { grid-column: 1; grid-row: 2 / span 5; align-self: center; justify-self: center; width: min(100%, 250px, 62vh); margin: 0; }
  #screen-landing .land-days { grid-column: 2; grid-row: 2; max-width: none; margin-top: 0; padding: 6px 8px 8px; }
  #screen-landing .land-days h2 { margin-bottom: 4px; font-size: 14px; }
  #screen-landing .land-days li { padding: 2px 0; }
  #screen-landing .land-feat { grid-column: 2; grid-row: 3; max-width: none; padding: 4px 12px; }
  #screen-landing .land-feat-ico { width: 36px; height: 36px; }
  #screen-landing .land-row { grid-column: 2; grid-row: 4; max-width: none; }
  #screen-landing .land-row .land-btn { min-height: 48px; }
  #screen-landing .land-parent { grid-column: 2; grid-row: 5; max-width: none; padding: 3px 12px; font-size: 13px; }

  /* --- dialogs (who / shop / settings / bonus ...): wider, never taller than the screen --- */
  .modal { padding: 8px max(12px, env(safe-area-inset-left)); }
  .modal-card { width: min(100%, 720px); max-height: calc(100dvh - 16px); padding: 12px 16px 12px; gap: 8px; }
  .who-card { max-width: 720px; width: min(100%, 720px); max-height: calc(100dvh - 16px); }
  .shop-card { gap: 6px; }
  .shop-grid { grid-template-columns: repeat(4, 1fr); max-height: calc(100dvh - 190px); }
  .who-card .big-btn, .modal-card .big-btn { align-self: center; height: 48px; font-size: 20px; }
  .shop-item { padding: 4px 4px 6px; gap: 2px; }
  .shop-ico { height: 38px; } .shop-ico .art { height: 36px; }
  .shop-grid { max-height: calc(100dvh - 170px); }
  /* --- daily login bonus: 7 slots in one row --- */
  .bonus-card-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
  .bonus-slot { aspect-ratio: 1 / 1.05; border-radius: 12px; }
  .bonus-card { gap: 6px; }
  .bonus-run b { font-size: 24px; }
  #bonus .modal-card, #trophy-got .modal-card { width: min(100%, 560px); max-height: calc(100dvh - 16px); padding: 10px 14px 10px; gap: 6px; }
  /* --- result panels: medal on the left, score + stats + buttons on the right, all inside the short screen --- */
  .pop-panel > .pop-medal { font-size: 112px; margin-top: 0; }
  .pop-panel .score { margin: 0; } .pop-panel .score b { font-size: 54px; text-shadow: 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink), 0 5px 0 var(--ink); } .pop-panel .score span { font-size: 20px; }
  .pop-panel .stats { margin: 0; gap: 6px; grid-template-columns: repeat(4, 1fr); } .pop-panel .stats div { padding: 4px 2px; border-radius: 10px; } .pop-panel .stats dt { font-size: 10px; } .pop-panel .stats dd { font-size: 18px; margin: 0; }
  .pop-panel .actions { flex-direction: row; justify-content: center; gap: 10px; margin-top: 0; }
  .pop-panel .actions .big-btn { height: 46px; min-width: 130px; font-size: 18px; } .pop-panel .actions .sub-btn { min-height: 44px; }
  .pop-panel > .chip { font-size: 13px; }

  /* --- games menu: hero on the left, the 8 game cards in a 4 x 2 block, tabs along the bottom --- */
  #screen-title.games-open { padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); overflow-y: auto; }
  #screen-title.games-open > .games-only { margin-top: 6px; }
  #screen-title.games-open .world { width: 100%; max-width: none; grid-template-columns: 230px repeat(4, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px 10px; padding: 0 0 6px; }
  #screen-title.games-open .menu-hero { grid-column: 1; grid-row: 1 / span 2; min-height: 0; padding: 36px 2px 0; }
  #screen-title.games-open .menu-title { font-size: 26px; max-width: 100%; }
  #screen-title.games-open .menu-sub { max-width: 100%; font-size: 13px; }
  #screen-title.games-open .menu-pet { right: 0; top: 30px; width: 84px; height: 84px; } #screen-title.games-open .menu-pet img { width: 66px; height: 66px; }
  #screen-title.games-open .menu-tabs { grid-column: 1 / -1; grid-row: 3; margin-top: 0; padding: 4px; }
  #screen-title.games-open .menu-tab { padding: 8px 2px; min-height: 40px; }
  #screen-title.games-open .menu-foot { display: none; }
  #screen-title.games-open { padding-top: 52px; padding-right: max(64px, calc(12px + env(safe-area-inset-right))); }
  #screen-title.games-open > .games-only { display: none; }
  #screen-title.games-open .world .isle { grid-column: auto; margin-top: 0; min-height: 0; padding: 6px 6px 8px; gap: 3px; border-width: 3px; }
  #screen-title.games-open .isle-shot { height: 56px; width: auto; aspect-ratio: auto; } #screen-title.games-open .isle-shot img { height: 100%; width: auto; max-width: 100%; object-fit: contain; border-radius: 10px; }
  #screen-title.games-open .isle b { font-size: 15px; }
  #screen-title.games-open .isle-shot { padding: 0; } #screen-title.games-open .world { grid-template-rows: auto auto auto; }
  #screen-title.games-open .isle-txt small, #screen-title.games-open .isle-go { display: none; }
  #screen-title.games-open .menu-hero { padding-top: 0; }
  /* tap targets: at least 44 px everywhere */
  .hud .icon-btn, .hud .hud-back { width: 44px; height: 44px; }
  .pet-home .pet-top-back, .pet-home .pet-top-more { width: 44px; height: 44px; }
  .pet-home .dock-btn, .pet-home #care-toggle { min-height: 44px; }
  .mood-chip { min-height: 40px; }

  /* --- practice (the main flow): the working card on the left, the number pad on the right --- */
  #screen-play.is-active { display: grid; grid-template-columns: minmax(0, 1fr) 236px; grid-template-rows: auto auto minmax(0, 1fr); column-gap: 12px; padding: 4px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left)); }
  #screen-play > .hud { grid-column: 1 / -1; grid-row: 1; padding: 0; }
  #screen-play > .hud2 { grid-column: 1; grid-row: 2; align-self: start; padding: 0 4px; height: 36px; }
  #screen-play > .stage { grid-column: 2; grid-row: 2; min-height: 0; height: 78px; margin: 0; }
  #screen-play > .card { grid-column: 1; grid-row: 3; min-height: 0; margin: 0; overflow: auto; }
  #screen-play > .pad { grid-column: 2; grid-row: 3; min-height: 0; align-self: stretch; margin: 0; }
  #screen-play .pad button { min-height: 0; }

  /* --- practice menu (自選程度 / grades / skill tree): two columns --- */
  #screen-title.games-open .modes:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 16px; align-items: center; width: min(100%, 640px); margin: 0 auto; }
  #screen-title.games-open .modes > * { grid-column: 1; margin: 0; }
  #screen-title.games-open .modes > .grades { grid-column: 2; grid-row: 1 / span 4; align-self: center; }
  #screen-title.games-open .modes #drill-back, #screen-title.games-open .modes #progress-toggle { min-height: 44px; }
  .skip-btn { min-height: 44px; min-width: 64px; }
  #screen-title.games-open.drill-open { padding-top: 66px; }

  /* --- settings: two columns so everything is in reach without long scrolling --- */
  #settings .modal-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 18px; align-content: start; width: min(100%, 760px); }
  #settings .modal-card > .chip, #settings .modal-card > .big-btn { grid-column: 1 / -1; justify-self: center; }
  #settings .set-links { grid-column: 1 / -1; display: flex; flex-direction: row; gap: 8px; }
  #settings .set-links > button { flex: 1; min-height: 44px; }
  #settings .set-row { margin: 0; }
  #settings .set-note { margin: 2px 0 0; font-size: 12px; }

  /* --- parent zone: ONE landscape layout (cards in equal-width grids, page scrolls) --- */
  #screen-parent { padding-top: 4px; }
  #par-scroll { display: flex; flex-direction: column; gap: 12px; padding: 4px 14px calc(24px + env(safe-area-inset-bottom)); }

  /* --- trophies / collection: use the width --- */
  #tr-list { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 12px; }
  .co-preview { min-height: 0; max-height: 104px; }
  #co-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* pet room (2026-10-16): the needs panel is one compact row of four bars, with today's wishes under it, and always fits the screen */
@media (orientation: landscape) and (max-height: 900px) {
  .pet-home.needs-open .pet-needs { display: grid; grid-template-columns: repeat(4, 1fr); left: 12px; right: 12px; top: calc(56px + env(safe-area-inset-top)); max-height: calc(100% - 128px); overflow-y: auto; padding: 8px 12px 8px; gap: 6px 14px; border-radius: 20px; }
  .pet-needs .need { gap: 6px; min-width: 0; }
  .pet-needs .need > span { width: 34px; height: 34px; }
  .pet-needs .need .art, .pet-needs .need img { width: 34px; height: 34px; }
  .pet-needs .need i { flex: 1; min-width: 30px; height: 14px; }
  .pet-needs .need-mood { display: none; }
  .pet-needs .wish-list { grid-column: 1 / -1; gap: 3px; padding-top: 5px; }
  .dwish { grid-template-columns: 20px 1fr auto; gap: 6px; font-size: 12.5px; }
  .wish-bubble { max-width: 210px; }
}
