@media (max-width: 820px) {
  /* Hero elements move from the frame to the fixed UI layer. */
  .frame .wm, .frame .script, .frame .badge { display: none; }
  .m-only { display: block; }

  /* Solid stage sampled from the top of the hero photo; case colours fade in at the start of the dive. */
  .stage { background: #0b3b2a; }
  .stage::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #1b4a34 0%, #1b4a34 55%, #2f6a50 80%, #7fb79d 100%);
    opacity: 0;
    transition: opacity 1.6s;
  }
  .stage.m-case::before { opacity: 1; }

  .nav { left: 12px; right: 12px; top: 12px; }
  .nav > div { gap: 8px; }
  .tag { height: 30px; padding: 0 12px; font-size: 13px; }
  .logo { display: none; }
  .hint { bottom: 18px; font-size: 11px; gap: 10px; }
  .hint i { width: 1.5px; height: 20px; }

  .m-wm {
    position: absolute;
    left: 3vw;
    top: 64px;
    width: 94vw;
    height: calc(94vw * 240 / 1440);
    overflow: visible;
  }
  .m-script {
    position: absolute;
    right: 6vw;
    top: calc(64px + 14vw);
    font-family: 'Caveat Brush', cursive;
    font-size: 15vw;
    line-height: 1;
    white-space: nowrap;
    transform: rotate(-7deg);
    text-shadow: 0 2px 10px rgba(0, 0, 0, .2);
  }
  /* "finance & operations" is five characters longer and ran off the left edge at 15vw. */
  :lang(en) .m-script { font-size: 11.5vw; }
  .m-badge {
    position: absolute;
    right: 2vw;
    top: calc(64px + 9vw);
    z-index: -1;
    width: 27vw;
    height: calc(27vw * 1030 / 582);
  }
  /* The badge keeps its 582x1030 internals; --mbs (set by scene.js) scales it into the box. */
  .m-badge .badge {
    left: 0;
    top: 0;
    scale: var(--mbs, .2);
    translate: calc(-288px + 13.5vw) 0;
  }

  /* Desk mode: ticket and icon grid at the top, laptop at the bottom. */
  .ticket {
    left: 50%;
    right: auto;
    top: 62px;
    width: min(86vw, 360px);
    margin-left: calc(min(86vw, 360px) / -2);
    padding: 22px 26px 16px 36px;
    border-radius: 3px;
  }
  .ticket h2 { font-size: 30px; }
  .ticket .rows { margin-top: 8px; }
  .ticket .rows div { padding: 4px 0 3px; font-size: 11px; }
  .ticket .hole { width: 15px; height: 15px; }
  .ticket .tl, .ticket .bl { left: 10px; }
  .ticket .tr, .ticket .br { right: 10px; }
  .ticket .tl, .ticket .tr { top: 10px; }
  .ticket .bl, .ticket .br { bottom: 10px; }
  .desc { display: none; }

  .m-grid {
    position: absolute;
    left: 50%;
    top: calc(62px + var(--th, 120px) + 18px);
    width: min(86vw, 360px);
    margin-left: calc(min(86vw, 360px) / -2);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    opacity: 0;
    font-family: var(--font-sys);
  }
  body.is-desk .m-grid { pointer-events: auto; }
  body:not(.is-desk) .m-grid { visibility: hidden; } /* not focusable while invisible on the hero */
  .m-grid .ico { width: auto; min-height: 76px; padding: 8px 4px; font-size: 12px; line-height: 16px; }
  .m-grid .ico .fi { --s: 40px; }
  .m-grid .ico:hover, .m-grid .ico:not(.quiet):focus-visible { background: rgba(255, 255, 255, .16); color: #fff; }
  .m-grid .ico.big .fi { --s: 104px; } /* the CV keeps its four cells: two of the three columns, two rows */

  /* The laptop screen keeps only wallpaper and the menu bar. */
  .desk-icons, .desk-globe, .dfold, .desk-tips, .ask, .cw, .dock-layer { display: none; }

  /* Windows become full-screen sheets: no free placement, resizing or minimising. */
  .win { left: 0; top: 0; width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .grip { display: none; }
  /* Phones get a sheet, not a Mac window: no traffic lights, a 44pt close button on the trailing side. */
  .win-bar { padding: 4px 8px; }
  .lights { display: none; }
  .m-close { display: grid; }
  .win-btn { width: 44px; height: 44px; border-radius: 12px; }
  .win-btn .i { width: 24px; height: 24px; }
  .win-body { flex: 1; padding: 16px 20px 32px; border-radius: 0; }
  .stat { flex-direction: column; gap: 8px; }
  .cv-row { flex-direction: column; gap: 0; }
  .cv-row span { text-align: left; }
}

/* Short landscape phones: there is no room for ticket + grid + laptop, so the ticket goes,
   the grid gets a backing (its white labels would otherwise sit on the cream laptop screen),
   and the hero's handwriting and badge shrink so they stay clear of the man's face. */
@media (max-width: 820px) and (max-height: 520px) {
  .ticket { display: none; }
  .m-grid {
    top: 56px;
    padding: 8px;
    border-radius: 12px;
    background: rgba(11, 47, 32, .78);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
  .m-script { right: 20vw; top: calc(64px + 9vw); font-size: 8vw; }
  .m-badge { width: 13vw; height: calc(13vw * 1030 / 582); }
  .m-badge .badge { translate: calc(-288px + 6.5vw) 0; }
}
