/* App layout: on screens with room for it, each screen fits the window and long panels
   scroll inside themselves instead of the whole page. Smaller screens keep the flowing layout. */
.layout-switch,
.split-handle {
  display: none;
}
@media (min-width: 1100px) and (min-height: 640px) {
  header {
    height: 64px;
  }
  .brand {
    font-size: 22px;
  }
  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }
  .app-shell {
    height: calc(100vh - 64px);
    min-height: 0;
    overflow: hidden;
  }
  main {
    height: 100%;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .travel-screen:not([hidden]),
  #adventureScreen:not([hidden]) {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  /* One-line headings. */
  .travel-heading,
  .page-heading {
    flex-shrink: 0;
    margin: 0 0 12px;
    align-items: center;
    gap: 10px;
  }
  .travel-heading .eyebrow,
  .page-heading .eyebrow {
    display: none;
  }
  .travel-heading h1 {
    font-size: 26px;
    margin: 0;
  }
  .travel-heading h1 br {
    display: none;
  }
  .page-heading h1 {
    font-size: 22px;
    margin: 0;
  }
  .travel-heading p,
  .page-heading p {
    margin: 2px 0 0;
    font-size: 12px;
    line-height: 1.4;
  }
  .travel-heading .outline,
  .page-heading .outline {
    min-height: 34px;
    padding: 7px 12px;
    font-size: 12px;
  }
  .travel-summary {
    flex-shrink: 0;
    margin: 0 0 12px;
  }

  /* Travel: the globe fills the height; the destination panel scrolls. */
  .travel-layout {
    flex: 1;
    min-height: 0;
    align-items: stretch;
  }
  .atlas-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .globe-stage {
    flex: 1;
    height: auto;
    min-height: 240px;
  }
  .destination-panel {
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  /* The panel scrolls, so keep its main action in view. */
  .destination-panel .enter-location {
    position: sticky;
    bottom: 0;
    z-index: 2;
    box-shadow: 0 -14px 14px #fff;
  }
  .journey-note {
    flex-shrink: 0;
    margin-top: 12px;
    padding: 8px 16px;
    font-size: 12px;
  }
  .journey-note p {
    margin: 0;
  }

  /* Adventure: world and workbench share the height; the quest column scrolls. */
  .layout-switch {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border: 1px solid #dce3ef;
    border-radius: 10px;
    background: #fff;
  }
  .layout-switch button {
    padding: 5px 11px;
    font: inherit;
    font-size: 12px;
    color: #607392;
    background: none;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
  }
  .layout-switch button[aria-pressed='true'] {
    color: #4351c9;
    background: #edf0ff;
    font-weight: 600;
  }
  .play-layout {
    flex: 1;
    min-height: 0;
    gap: 16px;
    align-items: stretch;
  }
  .simulation-column {
    min-height: 0;
    gap: 0;
  }
  /* The world gets most of the column by default; the handle below resizes it. */
  .world-panel {
    flex: 0 0 var(--world-share, 60%);
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .world-panel .world {
    aspect-ratio: auto;
    flex: 1;
    min-height: 0;
  }
  /* The quest card in the sidebar already names the next adventure. */
  .world-panel .quest-locator {
    display: none;
  }
  .world-panel .panel-bar,
  .simulation-column .bench-bar {
    min-height: 46px;
  }
  .split-handle {
    display: block;
    flex: 0 0 14px;
    position: relative;
    cursor: row-resize;
    touch-action: none;
  }
  .split-handle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 5px;
    width: 44px;
    height: 4px;
    margin-left: -22px;
    border-radius: 2px;
    background: #c9d2e3;
  }
  .split-handle:hover::after,
  .split-handle:focus-visible::after,
  .split-handle.dragging::after {
    background: #6575dd;
  }
  /* A clear ring around the whole handle, not just the recoloured grip, for keyboard users. */
  .split-handle:focus-visible {
    outline: 2px solid #5260df;
    outline-offset: -2px;
    border-radius: 6px;
  }
  #adventureScreen[data-layout='world'] .split-handle,
  #adventureScreen[data-layout='code'] .split-handle {
    display: none;
  }
  .workbench {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .simulation-column .bench-bar {
    flex-wrap: nowrap;
    padding-bottom: 0;
  }
  .simulation-column .bench-tabs {
    flex-basis: auto;
  }
  .bench-tabs button {
    min-height: 46px;
  }
  #benchContent {
    flex: 1;
    min-height: 0;
    overflow: auto;
    scrollbar-width: thin;
  }
  .simulation-column .editor-layout {
    grid-template-columns: minmax(0, 1fr) 210px;
  }
  .simulation-column .editor-toolbar {
    gap: 6px;
    padding: 8px 12px;
    min-height: 0;
  }
  .editor-toolbar .select-group,
  .editor-toolbar .editor-actions {
    flex-wrap: wrap;
    gap: 4px;
  }
  .editor-toolbar .editor-actions {
    margin-left: auto;
  }
  .editor-toolbar select {
    max-width: 120px;
  }
  .editor-toolbar .text-btn,
  .editor-actions button {
    white-space: nowrap;
  }
  .mission-column {
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    padding-bottom: 4px;
  }
  .app-footer {
    display: none;
  }

  /* Layout modes: give the world or the workbench the whole column. */
  #adventureScreen[data-layout='code'] .world-panel {
    flex: 0 0 auto;
  }
  #adventureScreen[data-layout='code'] .world-panel > :not(.panel-bar) {
    display: none;
  }
  #adventureScreen[data-layout='code'] .editor-wrap {
    height: max(340px, calc(100vh - 360px));
  }
  #adventureScreen[data-layout='world'] .world-panel {
    flex: 1 1 0;
  }
  #adventureScreen[data-layout='world'] .workbench {
    flex: 0 0 auto;
  }
  #adventureScreen[data-layout='world'] #benchContent {
    display: none;
  }
}
@media (min-width: 1100px) and (min-height: 640px) and (max-height: 860px) {
  /* Short windows: keyboard hints give way to the 3D view. */
  .world-panel .world-footer {
    display: none;
  }
}
/* Mirrored homes: flip the minimap so it matches the 3D view. */
.minimap.mirrored {
  transform: scaleX(-1);
}
.sky-settings {
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.sky-date-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.sky-date-label input {
  min-width: 0;
  max-width: 150px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white, #fff);
  color: var(--ink);
  font: inherit;
}
#skyDetails {
  white-space: pre-line;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}
.sky-settings small {
  display: block;
  margin-top: 8px;
  font-size: 10px;
}
.world.sky-view .map-layer,
.world.sky-view .dpad,
.world.sky-view .minimap,
.world.sky-view .quest-locator,
.world.sky-view #roofToggle,
.world.sky-view #followCamera {
  display: none;
}

/* Large displays can show the scene and the code at useful heights together. */
@media (min-width: 1600px) and (min-height: 640px) {
  main {
    max-width: none;
  }
  .play-layout {
    grid-template-columns: minmax(0, 1fr) 260px;
  }
  #adventureScreen[data-layout='split'] .simulation-column {
    flex-direction: row;
  }
  #adventureScreen[data-layout='split'] .world-panel {
    flex: 0 0 clamp(320px, var(--world-share, 60%), calc(100% - 494px));
    min-width: 0;
  }
  #adventureScreen[data-layout='split'] .workbench {
    min-width: 480px;
  }
  #adventureScreen[data-layout='split'] .split-handle {
    cursor: col-resize;
  }
  #adventureScreen[data-layout='split'] .split-handle::after {
    top: 50%;
    left: 5px;
    margin: -22px 0 0;
    width: 4px;
    height: 44px;
  }
  #adventureScreen[data-layout='split'] .world-panel .panel-bar {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 6px;
  }
  #adventureScreen[data-layout='split'] .world-status {
    width: 100%;
    justify-content: space-between;
  }
  #adventureScreen[data-layout='split'] .editor-layout,
  #adventureScreen[data-layout='split'] .editor-layout.with-coach {
    grid-template-columns: minmax(0, 1fr);
  }
  #adventureScreen[data-layout='split'] .coach {
    height: auto;
    min-height: 0;
    max-height: 220px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  #adventureScreen[data-layout='split'] .editor-wrap {
    height: max(320px, calc(100vh - 510px));
  }
}

/* Keep the camera controls distinct from the room labels and movement pad. */
.camera-bar {
  max-width: calc(100% - 32px);
  box-sizing: border-box;
  flex-wrap: wrap;
  justify-content: center;
  border-radius: 12px;
  backdrop-filter: blur(12px);
}
.world-tabs {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.world-tabs button {
  flex-shrink: 0;
  white-space: nowrap;
}
.camera-bar button {
  min-height: 28px;
  padding: 5px 8px;
}
.map-tools {
  border-radius: 12px;
  overflow: hidden;
}
.world.is-3d .area-marker {
  /* Above resident name tags (z-index 8) so room buttons always receive clicks. */
  z-index: 10;
  border-radius: 9px;
  box-shadow: 0 3px 10px #17243b14;
}
.bench-tabs {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.bench-tabs button {
  flex-shrink: 0;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .camera-bar .three-d-badge {
    display: none;
  }
  .camera-bar {
    width: calc(100% - 32px);
  }
}
