/* V5.3.3: a separate mobile surface; desktop V5.3.2 controls stay intact. */
#mobile-hud,
#config-backdrop {
  display: none;
}
.mobile-sheet {
  padding: 0;
}
@media (max-width: 860px), (pointer: coarse) and (max-height: 600px) {
  :root {
    --edge-left: max(16px, env(safe-area-inset-left));
    --edge-right: max(16px, env(safe-area-inset-right));
    --edge-bottom: max(20px, env(safe-area-inset-bottom));
    --edge-top: max(14px, env(safe-area-inset-top));
  }
  html,
  body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }
  body > header {
    display: none;
  }
  .layout {
    display: block;
    height: var(--viewer-height, 100vh);
    min-height: 0;
  }
  #stage {
    height: 100%;
    min-height: 0;
  }
  .mobile-select,
  .stage-heading,
  .stage-actions,
  .reception-actions,
  .toolbar-wrap,
  .north,
  #panel-toggle {
    display: none !important;
  }
  #hotspots,
  #reception-pin {
    display: none !important;
  }
  body[data-navigation="inspect"][data-hotspots="true"] #hotspots {
    display: block !important;
  }
  .hotspot {
    width: 44px;
    height: 44px;
    font-size: 12px;
    background: #233e32e8;
    border: 2px solid white;
  }
  #mobile-hud {
    display: contents;
  }
  .hud-button {
    min-height: 48px;
    min-width: 48px;
    border: 1px solid #ffffff90;
    border-radius: 24px;
    background: #fcfdf9f0;
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
    padding: 12px 17px;
    box-shadow: 0 3px 18px #10251c18;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  #mobile-exit {
    position: absolute;
    z-index: 12;
    left: var(--edge-left);
    top: var(--edge-top);
  }
  #mobile-menu {
    background: var(--ink);
    color: white;
    border-color: var(--ink);
  }
  #mobile-actions {
    position: absolute;
    z-index: 12;
    bottom: var(--edge-bottom);
    right: var(--edge-right);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
  }
  #mobile-context {
    max-width: 190px;
  }
  #mobile-stick {
    position: absolute;
    z-index: 12;
    left: var(--edge-left);
    bottom: var(--edge-bottom);
    width: 100px;
    height: 100px;
    border: 1px solid #ffffffbc;
    border-radius: 50%;
    background: #fcfdf945;
    box-shadow:
      inset 0 0 0 12px #ffffff20,
      0 3px 20px #10251c12;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }
  #mobile-stick::before,
  #mobile-stick::after {
    content: "";
    position: absolute;
    background: #355b4660;
    pointer-events: none;
  }
  #mobile-stick::before {
    width: 1px;
    height: 72px;
    left: 49px;
    top: 13px;
  }
  #mobile-stick::after {
    width: 72px;
    height: 1px;
    left: 13px;
    top: 49px;
  }
  #stick-knob {
    position: absolute;
    left: 29px;
    top: 29px;
    width: 40px;
    height: 40px;
    background: #43634fe8;
    border: 2px solid #ffffffde;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 3px 8px #14251f2c;
  }
  #mobile-stick:active {
    background: #fcfdf980;
  }
  #mobile-dpad {
    position: absolute;
    z-index: 12;
    left: var(--edge-left);
    bottom: var(--edge-bottom);
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 2px;
  }
  #mobile-dpad button {
    border: 1px solid #ffffffb0;
    border-radius: 12px;
    background: #fcfdf9ed;
    color: var(--ink);
    font-size: 22px;
    touch-action: none;
  }
  #mobile-dpad [data-direction="forward"] {
    grid-area: 1/2;
  }
  #mobile-dpad [data-direction="left"] {
    grid-area: 2/1;
  }
  #mobile-dpad [data-direction="right"] {
    grid-area: 2/3;
  }
  #mobile-dpad [data-direction="back"] {
    grid-area: 3/2;
  }
  #mobile-dpad [data-held="true"] {
    background: var(--green);
    color: white;
  }
  body[data-navigation="inspect"] #mobile-stick,
  body[data-navigation="inspect"] #mobile-dpad {
    display: none;
  }
  #mobile-coach {
    position: absolute;
    z-index: 14;
    left: var(--edge-left);
    right: var(--edge-right);
    bottom: calc(var(--edge-bottom) + 116px);
    width: min(360px, calc(100% - 32px));
    margin-inline: auto;
    background: #fcfdf9f5;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 25px #14251f15;
  }
  #mobile-coach strong {
    display: block;
    font-size: 16px;
    margin: 0 0 6px;
  }
  #mobile-coach p {
    font-size: 14px;
    margin: 0 0 12px;
    color: var(--muted);
  }
  #mobile-coach .btn {
    min-height: 44px;
    font-size: 14px;
    border-radius: 8px;
  }
  #mobile-status {
    position: absolute;
    z-index: 11;
    top: calc(var(--edge-top) + 60px);
    left: var(--edge-left);
    right: var(--edge-right);
    text-align: center;
    pointer-events: none;
  }
  #mobile-status:not(:empty) {
    margin-inline: auto;
    width: fit-content;
    max-width: calc(100% - 32px);
    background: #fcfdf9ee;
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 13px;
  }
  #explore-sheet {
    position: fixed;
    inset: auto 0 0;
    margin: 0 auto;
    width: 100%;
    max-width: 620px;
    max-height: calc(var(--viewer-height, 100vh) * 0.88);
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    overflow: auto;
    padding-bottom: var(--edge-bottom);
  }
  #explore-sheet::backdrop {
    background: #14251f72;
  }
  .sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 10px;
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel);
  }
  .sheet-header h2 {
    font-size: 22px;
    margin: 0;
  }
  .sheet-header .btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    font-size: 22px;
  }
  .sheet-content {
    padding: 8px 20px 20px;
  }
  .sheet-caption {
    font-size: 13px;
    color: var(--muted);
    margin: 4px 0 16px;
  }
  .sheet-product {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    text-align: left;
    border: 1px solid var(--line);
    background: white;
    border-radius: 12px;
    font-size: 14px;
  }
  .sheet-product img {
    width: 76px;
    height: 61px;
    object-fit: cover;
    border-radius: 6px;
  }
  .sheet-product strong {
    display: block;
    font-size: 14px;
    line-height: 1.35;
  }
  .sheet-product small {
    font-size: 12px;
    color: var(--muted);
    display: block;
    margin-top: 4px;
  }
  .sheet-product[aria-pressed="true"] {
    border-color: var(--green);
    background: #edf2e9;
  }
  .sheet-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
  }
  .sheet-buttons .btn {
    min-height: 54px;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
  }
  .sheet-buttons .full {
    grid-column: 1/-1;
  }
  #sheet-tools summary {
    min-height: 48px;
    padding: 14px 0;
    font-size: 14px;
    cursor: pointer;
  }
  #sheet-tools {
    border-top: 1px solid var(--line);
    margin-top: 18px;
  }
  #sheet-tools .row {
    align-items: flex-start;
  }
  #sheet-tools label {
    font-size: 14px;
  }
  #sheet-tools select {
    width: auto;
    min-width: 145px;
    min-height: 44px;
    font-size: 14px;
  }
  #sheet-tools p {
    font-size: 13px;
  }
  #config-backdrop {
    position: fixed;
    inset: 0;
    z-index: 18;
    background: #14251f72;
    border: 0;
    border-radius: 0;
    padding: 0;
  }
  body.mobile-panel-open #config-backdrop {
    display: block;
  }
  aside {
    display: none;
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: 620px;
    margin-inline: auto;
    max-height: calc(var(--viewer-height, 100vh) * 0.88);
    padding: 20px 20px calc(var(--edge-bottom) + 12px);
    border: 1px solid var(--line);
    border-radius: 22px 22px 0 0;
    z-index: 19;
    background: var(--panel);
    overflow: auto;
    overscroll-behavior: contain;
  }
  aside.is-open {
    display: block;
  }
  #close-panel {
    display: block;
    float: right;
    position: sticky;
    top: 0;
    min-height: 44px;
    min-width: 70px;
    font-size: 14px;
    z-index: 2;
  }
  aside > .eyebrow,
  aside > .intro-sub,
  aside > .product-list {
    display: none;
  }
  aside > .intro {
    font-size: 21px;
    line-height: 1.25;
    max-width: calc(100% - 90px);
    margin: 4px 0 22px;
  }
  aside .section {
    margin-top: 20px;
    padding-top: 18px;
  }
  aside .section h2 {
    font-size: 14px;
    letter-spacing: 0.04em;
  }
  aside .small,
  aside .fine-print,
  aside .technical-note,
  aside .source-note {
    font-size: 13px;
  }
  aside .row label,
  aside .checkbox,
  aside .fixed-value,
  aside #summary {
    font-size: 14px;
  }
  aside select,
  aside .btn {
    font-size: 14px;
    min-height: 44px;
  }
  aside .swatch {
    min-height: 64px;
    font-size: 13px;
  }
  aside .checkbox {
    min-height: 44px;
  }
  aside input[type="range"] {
    min-height: 44px;
  }
  .mobile-technical-controls {
    display: grid;
    gap: 14px;
    margin-bottom: 20px;
  }
  .mobile-technical-controls .toolbar,
  .mobile-technical-controls .view-shortcuts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    box-shadow: none;
    padding: 0;
    border: 0;
  }
  .mobile-technical-controls .btn {
    border: 1px solid var(--line);
    background: white;
    min-height: 44px;
    font-size: 14px;
  }
  .mobile-technical-controls > p {
    font-size: 14px;
    color: var(--muted);
    margin: 0;
  }
  #info-card {
    z-index: 16;
    bottom: calc(var(--edge-bottom) + 118px);
    left: var(--edge-left);
    width: calc(100% - var(--edge-left) - var(--edge-right));
    max-height: calc(var(--viewer-height, 100vh) * 0.4);
    overflow: auto;
    border-radius: 14px;
  }
  #info-title {
    font-size: 16px;
    margin-right: 40px;
  }
  #info-text {
    font-size: 14px;
  }
  #close-info {
    width: 44px;
    height: 44px;
  }
  .tour-active #mobile-hud {
    display: none;
  }
  .tour-active #mobile-hud > * {
    display: none !important;
  }
  .tour-card {
    bottom: var(--edge-bottom);
    left: var(--edge-left);
    width: calc(100% - var(--edge-left) - var(--edge-right));
    max-height: calc(var(--viewer-height, 100vh) * 0.45);
    z-index: 25;
    padding: 16px;
    border-radius: 16px;
  }
  .tour-card p {
    font-size: 14px;
  }
  .tour-card h3 {
    font-size: 19px;
  }
  .tour-card .btn {
    min-height: 44px;
    font-size: 13px;
  }
  .tour-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .tour-active aside.is-open {
    top: var(--edge-top);
    bottom: auto;
    max-height: calc((var(--viewer-height, 100vh) * 0.5) - var(--edge-top));
  }
  .tour-active #config-backdrop {
    display: none;
  }
  #reception-dialog {
    padding: 20px;
    width: calc(100% - 24px);
    max-height: calc(var(--viewer-height, 100vh) - var(--edge-top) - var(--edge-bottom));
  }
  #reception-dialog .small,
  #reception-dialog label,
  #reception-dialog .btn,
  .reception-choice span {
    font-size: 14px;
  }
  #reception-dialog .btn {
    min-height: 44px;
  }
  #reception-dialog input,
  #reception-dialog textarea {
    font-size: 16px;
    min-height: 44px;
  }
  .request-fields {
    grid-template-columns: 1fr;
  }
  .resource-actions {
    flex-wrap: wrap;
  }
  .resource-actions > * {
    flex-basis: 40%;
  }
  #loading {
    font-size: 14px;
    z-index: 30;
    border-radius: 12px;
  }
  #stage:fullscreen {
    height: var(--viewer-height, 100vh);
  }
}
@media (max-height: 500px) and (max-width: 1000px) {
  #mobile-stick {
    width: 88px;
    height: 88px;
  }
  #mobile-stick::before {
    left: 43px;
    top: 7px;
  }
  #mobile-stick::after {
    left: 7px;
    top: 43px;
  }
  #stick-knob {
    left: 23px;
    top: 23px;
  }
  #mobile-coach {
    max-width: 330px;
    left: 130px;
    right: 100px;
    top: 14px;
    bottom: auto;
  }
  .tour-card {
    width: 46%;
    left: auto;
    right: var(--edge-right);
    max-height: calc(var(--viewer-height, 100vh) - 32px);
  }
  .tour-active aside.is-open {
    width: 47%;
    left: var(--edge-left);
    right: auto;
    max-height: calc(var(--viewer-height, 100vh) - 32px);
  }
}
