/* Large screens keep their own sizing; phone and tablet layouts retain theirs. */
@media (min-width: 1100px) and (min-height: 600px) {
  body #app .settings-top { gap: 12px; padding: 10px; }
  body #app .iconbtn { width: 64px; height: 64px; border-radius: 18px; }
  body #app .title-menu-icon { width: 46px; height: 46px; }
  body #app .dock { width: min(1100px, calc(100vw - 48px)); gap: 12px; padding: 12px 16px; }
  body #app .dockbtn { max-width: none; min-height: 76px; gap: 10px; padding: 10px 14px; }
  body #app .dockbtn .di { width: 54px; height: 54px; flex: 0 0 54px; }
  body #app .dockbtn .di .ico { width: 50px; height: 50px; }
  body #app .dockbtn .dl { font-size: 15px; letter-spacing: .5px; }
  body #app.has-dock .main { padding-bottom: 142px; }
  body #app .title-creature { width: clamp(240px, 32vh, 360px) !important; }
  body #app .title-lower-panel { bottom: 136px; }
  body #app .hud-ava { width: 68px; height: 68px; }
  body #app .hud-ava img, body #app .hud-ava svg { width: 56px; height: 56px; }
  body #app .hdr { padding: 10px 24px; gap: 16px; }
  body #app .hud-bars { max-width: 420px; }
  body #app .hbar .track { height: 24px; }
  body #app .hbar .track span { font-size: 12px; }
  body #app .bond-chip { width: 240px; min-height: 82px; }
  body #app .bond-chip small { font-size: 12px; }
  body #app .bond-chip b { font-size: 17px; }
  body #app .bond-chip-emblem { width: 60px; height: 60px; }

  body #app .write-screen { justify-content: flex-start; gap: 18px; padding: 20px 28px 32px; }
  body #app .write-screen > .caption { font-size: 26px; }
  body #app .write-card {
    width: min(1140px, 100%); padding: 20px; gap: 12px;
    grid-template-columns: minmax(360px, .85fr) minmax(480px, 1.35fr);
    align-items: start;
  }
  body #app .write-card > .write-picture { grid-column: 1; grid-row: 1; justify-self: start; width: 150px; height: 130px; }
  body #app .write-picture .wpic { width: 130px; height: 130px; }
  body #app .write-card > .speak { grid-column: 1; grid-row: 1; align-self: center; justify-self: end; width: 64px; height: 58px; }
  body #app .write-card > .write-mode-chip { grid-column: 1; grid-row: 2; position: static; font-size: 15px; }
  body #app .write-mode-chip small { font-size: 12px; }
  body #app .write-mode-chip b { font-size: 14px; }
  body #app .write-card > label, body #app .write-card > .write-answer,
  body #app .write-card > .write-help, body #app .write-card > #write-check,
  body #app .write-card > .write-assist, body #app .write-card > .write-guided { grid-column: 1; }
  body #app .write-card > label { font-size: 16px; text-align: center; }
  body #app .write-card > label { grid-row: 3; }
  body #app .write-card > .write-answer { grid-row: 4; }
  body #app .write-card > .write-help { grid-row: 5; }
  body #app .write-card > #write-check, body #app .write-card > .write-guided { grid-row: 6; }
  body #app .write-card > .write-assist { grid-row: 7; }
  body #app .write-card > .exercise-timer { grid-column: 1; grid-row: 8; }
  body #app .write-answer { font-size: 32px; min-height: 64px; }
  body #app .write-help, body #app .write-guided p { font-size: 15px; }
  body #app .write-card > .writing-board { grid-column: 2; grid-row: 1 / span 12; align-self: stretch; }
  body #app .writing-board-toggle { font-size: 16px; min-height: 56px; }
  body #app .writing-board-paper { height: clamp(300px, 40vh, 460px); }
  body #app .writing-board-model text { stroke: #506f87; stroke-width: 2.5; stroke-dasharray: 5 4; }
  body #app .writing-board-content > p { font-size: 16px; }
  body #app .writing-board-content > small { font-size: 14px; }
  body #app .writing-board-tools button { min-height: 52px; font-size: 15px; }
  body #app .write-letter-choices { gap: 7px; }
  body #app .write-letter-choices button { width: 64px; height: 60px; font-size: 28px; }
  body #app .writing-demo-options { width: min(1140px, 100%); grid-template-columns: 1fr 1fr auto; align-items: end; }
  body #app .writing-demo-options button { grid-column: 3; min-height: 48px; padding: 8px 22px; font-size: 15px; }
  body #app .writing-demo-options label { font-size: 15px; }
}

/* Desktop menus share a content width, while each card keeps room for its text.
   These rules also apply on short laptop windows: the menu, not its cards, scrolls. */
@media (min-width: 1024px) {
  body #app { --desktop-content: 1440px; --desktop-catalog: 1760px; }
  body #app :is(.family-main, .progress-main, .album-main, .team-main, .feed-screen, .main:has(> .arc-map)) {
    justify-content: flex-start;
    padding-top: 20px;
    gap: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable both-edges;
  }
  body #app :is(.family-main, .progress-main, .feed-screen, .main:has(> .arc-map)) {
    padding-inline: clamp(24px, 3vw, 48px);
  }
  body #app :is(.family-main, .progress-main, .album-main, .team-main, .feed-screen, .main:has(> .arc-map)) > * {
    flex-shrink: 0;
    min-width: 0;
  }

  /* Family: title, language, selected child and panels stay on the same edges. */
  body #app .family-main { padding-bottom: 130px !important; scroll-padding-bottom: 130px; }
  body #app .family-main > :is(.family-title, .family-language, .family-profile-strip, .family-grid) {
    width: min(100%, var(--desktop-content));
    max-width: none;
    margin-inline: auto;
  }
  body #app .family-title { padding: 16px 22px; min-height: 84px; }
  body #app .family-title-label { gap: 12px; }
  body #app .family-title-label b { font-size: clamp(20px, 1.5vw, 26px); white-space: normal; }
  body #app .family-title-icon { width: 44px; height: 44px; }
  body #app .family-title-actions { grid-template-columns: 130px 210px; gap: 14px; }
  body #app .family-title-actions :is(.family-top-action, #family-done) { height: 56px; min-height: 56px !important; }
  body #app .family-title-actions .family-top-action > b { font-size: 13px; white-space: normal; }
  body #app .family-title-actions :is(.family-action-icon, .family-top-action > span) { width: 32px; height: 32px; flex-basis: 32px; }
  body #app .family-language {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 24px;
    margin-block: 0;
    padding: 16px 22px;
    text-align: left;
  }
  body #app .family-language .locale-selector { justify-content: flex-start; font-size: 16px; gap: 12px; }
  body #app .family-language select { min-width: 160px; min-height: 46px; }
  body #app .family-language small { font-size: 14px; line-height: 1.5; }
  body #app .family-profile-strip { grid-template-columns: 48px minmax(0, 1fr) auto; padding: 13px 20px; gap: 12px; }
  body #app .family-profile-strip b { font-size: 17px; }
  body #app .family-profile-strip small { font-size: 11px; }
  body #app .family-profile-strip strong { font-size: 12px; }
  body #app .family-grid, body #app .family-section-page { gap: 20px; }
  body #app .family-section-page { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  body #app .family-panel { min-width: 0; padding: 22px; border-radius: 20px; }
  body #app .family-panel h2 { font-size: 17px; line-height: 1.4; }
  body #app .family-panel h3 { font-size: 14px; }
  body #app :is(.family-section-heading p, .learning-head p, .family-note, .family-panel > p) { font-size: 14px; line-height: 1.55; }
  body #app .family-panel > label { grid-template-columns: minmax(130px, .8fr) minmax(0, 1.2fr); gap: 14px; margin-block: 12px; font-size: 14px; }
  body #app .family-main .family-panel select { min-width: 0; max-width: 100%; min-height: 48px; font-size: 15px; }
  body #app .family-simple-settings { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 14px; }
  body #app .family-simple-settings > label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 16px;
  }
  body #app .family-simple-settings > label > span:first-child { flex: 1 1 190px; min-width: 0; }
  body #app .family-simple-settings > label > select { flex: 1 1 180px; width: auto; }
  body #app .family-simple-settings > label b { font-size: 15px; line-height: 1.4; }
  body #app .family-simple-settings > label small { font-size: 13px; line-height: 1.5; }
  body #app .parent-control-actions { gap: 12px; }
  body #app .parent-control-actions button { min-height: 48px; font-size: 14px; padding: 10px; white-space: normal; }
  body #app .parent-control-status { font-size: 13px; line-height: 1.5; padding: 12px; }
  body #app .push-settings { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px; }
  body #app .family-bottom-nav { width: min(calc(100% - 64px), var(--desktop-content)); padding: 10px; gap: 12px; }
  body #app .family-bottom-nav button { min-height: 72px; gap: 5px; }
  body #app .family-bottom-nav button b { font-size: 13px; letter-spacing: .6px; white-space: normal; }
  body #app .family-bottom-nav .family-nav-icon { width: 40px; height: 40px; }

  /* Progress previously mixed 760px cards with a full-width reinforcement card. */
  body #app .progress-main > :is(.progress-grid, .review-card, .reinforcement-card, .curriculum-card, .medals, .progress-actions) {
    width: min(100%, var(--desktop-content));
    max-width: none;
  }
  body #app .progress-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
  body #app .progress-grid:has(.mission-card) { grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); }
  body #app .progress-grid > * { min-width: 0; padding: 20px; }
  body #app .stat-card { min-height: 160px; gap: 8px; }
  body #app .stat-card > b { font-size: 32px; }
  body #app :is(.stat-card, .mission-card) small { font-size: 13px; line-height: 1.4; }
  body #app .progress-main > :is(.review-card, .reinforcement-card, .curriculum-card, .medals) { padding: 22px; }
  body #app .progress-main h2 { font-size: 18px; line-height: 1.4; }
  body #app .progress-main :is(.review-explain, .curriculum-explain, .reinforcement-card > p) { max-width: 85ch; font-size: 15px; line-height: 1.6; }
  body #app .progress-main .medals > div { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px; }

  /* World cards wrap before six missions become too cramped on a laptop. */
  body #app .arc-map { width: min(100%, var(--desktop-catalog)); gap: 24px; }
  body #app .arc-section { padding: 20px; }
  body #app .arc-section .wgrid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 18px; }
  body #app .arc-section .wcard { min-height: 250px; padding: 18px; gap: 12px; }
  body #app .arc-section .wcard .wn { font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
  body #app .arc-section .wcard .wb { width: 100px; height: 100px; }

  /* Keep a readable card size, including the last incomplete catalogue row. */
  body #app :is(.album-main > .album, .team-main > .team-evolution-grid) {
    width: min(100%, var(--desktop-catalog));
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    gap: 20px;
  }
  body #app :is(.album-main .acard, .team-main > .team-evolution-grid > .acard) { padding: 20px 16px; min-height: 290px; }
  body #app :is(.album-main .acard, .team-main > .team-evolution-grid > .acard) > :is(.creature3d, .boss-sheet, .weekly-creature-art, .home-companion-sprite, svg) {
    width: clamp(160px, 10vw, 190px) !important;
    height: clamp(160px, 10vw, 190px) !important;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    flex-basis: auto;
  }
  body #app .team-main > .team-tabs { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); max-width: 1500px; }
  body #app .feed-screen > .food-grid { width: min(100%, 1200px); grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
}

/* Native scrolling keeps wheel, keyboard and touch behaviour. No extra script. */
@media (any-hover: hover) and (any-pointer: fine) {
  body * { scrollbar-color: #48dff2 #07182e; scrollbar-width: auto; }
  body *::-webkit-scrollbar { width: 12px; height: 12px; }
  body *::-webkit-scrollbar-track { background: #07182e; border-radius: 12px; box-shadow: inset 0 0 0 1px #183e57; }
  body *::-webkit-scrollbar-thumb {
    min-height: 44px;
    border: 3px solid #07182e;
    border-radius: 12px;
    background: linear-gradient(180deg, #85f5ef, #22bad8);
    background-clip: padding-box;
  }
  body *::-webkit-scrollbar-thumb:hover { background: #ffe184; background-clip: padding-box; }
  body *::-webkit-scrollbar-thumb:active { background: #ffb23e; background-clip: padding-box; }
  body *::-webkit-scrollbar-corner { background: #07182e; }
  @supports selector(::-webkit-scrollbar) {
    body * { scrollbar-color: auto; }
  }
}
@media (forced-colors: active) {
  body * { scrollbar-color: auto; }
  body *::-webkit-scrollbar-thumb { background: ButtonText; border-color: Canvas; }
  body *::-webkit-scrollbar-track, body *::-webkit-scrollbar-corner { background: Canvas; box-shadow: none; }
}
