/* The mobile game is one handset, with utilities kept out of its hit areas. */
.mobile-header-control { display: none; }
@media (max-width: 700px) {
  html[data-theme] { overflow-x: clip; }
  html[data-theme] body { overflow-x: clip; }
  html[data-theme] .page-shell {
    width: 100%; max-width: none; min-height: 100svh; padding: 0;
  }
  html[data-theme] .site-header {
    position: relative; flex: 0 0 auto;
    height: calc(88px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0;
    border: 0; align-items: center;
  }
  html[data-theme] .brand {
    top: calc(44px + env(safe-area-inset-top)); left: 50%;
    width: clamp(100px, 30vw, 136px); height: auto;
    transform: translate(-50%, -50%); padding: 0;
  }
  html[data-theme] .header-actions {
    position: static; display: grid; grid-template-columns: 44px 44px minmax(0,1fr) 44px 44px;
    align-items: center; width: 100%; padding: 0; gap: 4px;
  }
  html[data-theme] #mobile-music-mute { grid-column: 2; grid-row: 1; }
  html[data-theme] #mobile-share-game { grid-column: 4; grid-row: 1; }
  html[data-theme] #mobile-menu-open { grid-column: 5; grid-row: 1; }
  html[data-theme] .header-actions #theme-toggle,
  html[data-theme] .header-actions .mobile-glass-button {
    display: inline-flex; width: 44px; height: 44px; min-width: 44px;
    padding: 0; gap: 0; border: 0; border-radius: 50%;
    color: var(--ui-ink); background: var(--ui-raised);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 2px 8px rgba(0,0,0,.1);
    transition: scale 180ms cubic-bezier(.2,0,0,1);
  }
  html[data-theme="day"] .header-actions #theme-toggle,
  html[data-theme="day"] .header-actions .mobile-glass-button {
    box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 2px 8px rgba(0,0,0,.06);
  }
  html[data-theme] #theme-label, .mobile-mute-label { display: none; }
  .mobile-header-control svg, .mobile-music-mute svg { width: 20px; height: 20px; }
  html[data-theme] .mobile-glass-button:active, html[data-theme] #theme-toggle:active { scale: .96; }
  html[data-theme] .mobile-glass-button:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 3px; }
  html[data-theme] .mobile-music-mute { position: relative; }
  html[data-theme] .mobile-music-mute .speaker-on,
  html[data-theme] .mobile-music-mute .speaker-off {
    position: absolute; display: block; opacity: 1; scale: 1; filter: blur(0);
    transition: opacity 180ms ease, scale 180ms cubic-bezier(.2,0,0,1), filter 180ms ease;
  }
  html[data-theme] .mobile-music-mute .speaker-off,
  html[data-theme] .mobile-music-mute[aria-pressed="true"] .speaker-on { opacity: 0; scale: .25; filter: blur(4px); }
  html[data-theme] .mobile-music-mute[aria-pressed="true"] .speaker-off { opacity: 1; scale: 1; filter: blur(0); }
  html[data-theme] .experience { flex: 0 0 auto; padding: 0 0 env(safe-area-inset-bottom); gap: 0; }
  html[data-theme] .phone-area,
  html[data-theme] body[data-challenge="true"] .phone-area {
    /* Artwork includes transparent margins: size its visible handset, not its canvas. */
    width: max(320px, min(150vw, calc((100svh - 88px - env(safe-area-inset-top) - env(safe-area-inset-bottom) - var(--challenge-banner-height, 0px)) * .666667)));
    max-width: none; margin: 0; opacity: 1; scale: 1; transition: none;
  }
  html[data-theme] .challenge-banner { min-height: 68px; }
  html[data-theme] .challenge-banner .challenge-action { height: 44px; }
  .challenge-banner #challenge-landing-copy { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  html[data-theme] .phone { transform: none; translate: none; transition: none; }
  html[data-theme] body[data-phase="running"] .phone { translate: none; }
  html[data-theme] .mobile-opening {
    position: fixed; inset: 0; z-index: 20; width: 100%; height: 100%;
    background: #000; pointer-events: auto; display: none; opacity: 1;
    transition: opacity 200ms ease;
  }
  html.mobile-intro-active .mobile-opening { display: grid; }
  html[data-theme] .mobile-opening.is-leaving { display: grid; opacity: 0; pointer-events: none; }
  html[data-theme] .mobile-opening img {
    width: min(62vw, 260px); transform: none; animation: none; transition: none; opacity: 1;
  }
  html[data-theme] .mobile-menu-dialog { background: var(--ui-surface); }
  html[data-theme] .mobile-menu-dialog .mobile-sheet-top { background: var(--ui-surface); }
  html[data-theme] .mobile-menu-dialog .mobile-sheet-top button:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 3px; }
  html[data-theme] .mobile-menu-dialog h2 { font: 550 20px/1.2 var(--ui-font); letter-spacing: -.02em; margin: 0; }
  .mobile-menu-body { padding: 18px 24px max(24px, env(safe-area-inset-bottom)); }
  .mobile-volume-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
  #mobile-volume-value { color: var(--ui-muted); font-variant-numeric: tabular-nums; }
  #mobile-volume {
    appearance: none; -webkit-appearance: none; width: 100%; height: 48px; margin: 6px 0 0;
    border: 0; padding: 0; background: transparent; cursor: pointer; touch-action: pan-y;
  }
  #mobile-volume::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--ui-ink) var(--range-fill,10%), var(--ui-line) var(--range-fill,10%)); }
  #mobile-volume::-moz-range-track { height: 6px; border-radius: 999px; background: var(--ui-line); }
  #mobile-volume::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--ui-ink); }
  #mobile-volume::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--ui-ink); margin-top: -10px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
  #mobile-volume::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--ui-ink); }
  #mobile-volume:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 2px; border-radius: 8px; }
  .mobile-volume-note { color: var(--ui-muted); font-size: 12px; line-height: 1.5; margin: 0 0 22px; }
  html[data-theme] .mobile-menu-row {
    display: flex; align-items: center; gap: 14px; width: 100%; min-height: 64px;
    padding: 12px 0; border: 0; background: transparent; color: var(--ui-ink);
    text-align: left; font: 500 14px/1.4 var(--ui-font); cursor: pointer;
    box-shadow: inset 0 1px 0 var(--ui-line); touch-action: manipulation;
  }
  .mobile-menu-row svg { width: 22px; height: 22px; flex: 0 0 auto; }
  .mobile-menu-row > span:nth-child(2) { flex: 1; }
  .mobile-menu-row small { display: block; color: var(--ui-muted); font-size: 12px; font-weight: 400; margin-top: 3px; }
  html[data-theme] .mobile-menu-row:focus-visible { outline: 2px solid var(--ui-ink); outline-offset: 3px; border-radius: 8px; }
  html[data-theme] .mobile-menu-row:active { opacity: .7; }
  html[data-theme] .mobile-sheet[open] {
    animation: none; opacity: 1; transform: translateY(var(--sheet-drag, 0px));
    transition: opacity 180ms ease, transform 220ms cubic-bezier(.2,0,0,1);
  }
  @starting-style {
    html[data-theme] .mobile-sheet[open] { opacity: 0; transform: translateY(24px); }
  }
  html[data-theme] .mobile-sheet.is-dragging { transition: none; }
  html[data-theme] .mobile-sheet.is-closing { opacity: 0; transform: translateY(24px); }
  /* Short landscape screens can scroll vertically without shrinking game keys below usable size. */
  @media (orientation: landscape) {
    html[data-theme] .site-header { height: calc(72px + env(safe-area-inset-top)); }
    html[data-theme] .brand { top: calc(36px + env(safe-area-inset-top)); }
  }
}
@media (max-width: 700px) and (prefers-reduced-motion: reduce) {
  html[data-theme] .mobile-opening { display: none !important; }
  html[data-theme] .header-actions button,
  html[data-theme] .mobile-music-mute svg { transition: none; }
}
