/* ═══════════════════════════════════════════════════════════════════
   12 RECIPES RESPONSIVE
   Recipes + responsive media queries
   Sourced from monolithic main.css lines 3928-5453.
   ═══════════════════════════════════════════════════════════════════ */

/* ════════════════════════════════════════════════════════════════
   Inspector modules — Unity-style component cards
   ──────────────────────────────────────────────────────────────── */
.inspector-modules {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.inspector-module {
  --module-accent: var(--accent, #7c75ff);
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
}
.inspector-module::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--module-accent);
  opacity: 0.55;
  transition: opacity .14s;
}
.inspector-module:hover {
  border-color: var(--glass-border-strong);
  box-shadow: var(--glass-shadow-sm);
}
.inspector-module:hover::before { opacity: 0.95; }
.inspector-module.disabled { opacity: 0.55; }
.inspector-module.disabled::before { opacity: 0.2; }
.inspector-module.disabled .inspector-module-body { display: none; }

.inspector-module-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 12px;
  cursor: pointer;
  user-select: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.025) 0%, transparent 100%);
}
.inspector-module-header:hover { background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 100%); }

.inspector-module-chevron {
  font-size: 9px;
  color: var(--text-dim, #888);
  transition: transform .15s;
  width: 10px;
  display: inline-block;
  text-align: center;
}
.inspector-module.collapsed .inspector-module-chevron { transform: rotate(-90deg); }

.inspector-module-icon {
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
}
.inspector-module-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.inspector-module-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--text, #ddd);
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inspector-module-subtitle {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inspector-module-warn {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255,180,80,0.16);
  color: #ffb656;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}
.inspector-module-toggle {
  flex-shrink: 0;
  margin-left: auto;
  display: inline-flex;
}
.inspector-module-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background .12s, color .12s;
}
.inspector-module-menu-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }

.inspector-module-body {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.18);
}
.inspector-module.collapsed .inspector-module-body { display: none; }

/* "+ Aggiungi modulo" button */
.inspector-add-module {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  margin-top: 8px;
  transition: all .14s;
}
.inspector-add-module:hover {
  border-color: var(--accent, #6c63ff);
  color: var(--accent, #6c63ff);
  background: rgba(108,99,255,0.06);
  border-style: solid;
}

/* Module picker popover (Liquid Glass) */
.module-picker-popover {
  position: fixed;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: 6px;
  z-index: 1500;
  min-width: 260px;
  max-width: 340px;
  animation: modulePickerIn 200ms var(--ease-spring);
}
@keyframes modulePickerIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0);    }
}
.module-picker-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 5px;
  transition: background .12s;
}
.module-picker-item:hover { background: rgba(108,99,255,0.14); }
.module-picker-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.module-picker-item.disabled:hover { background: transparent; }
.module-picker-item-icon {
  font-size: 18px;
  line-height: 1.1;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.module-picker-item-text { flex: 1; min-width: 0; }
.module-picker-item-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.module-picker-item-desc {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 1px;
  line-height: 1.4;
}

/* ⋮ context menu (Liquid Glass) */
.inspector-module-menu {
  position: fixed;
  background: var(--glass-bg-strong);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  padding: 4px;
  z-index: 1500;
  min-width: 200px;
  animation: modulePickerIn 0.18s var(--ease-spring);
}
.inspector-module-menu-item {
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12px;
  border-radius: 4px;
  white-space: nowrap;
  color: var(--text);
  transition: background .12s;
}
.inspector-module-menu-item:hover { background: rgba(255,255,255,0.07); }
.inspector-module-menu-item.danger { color: #ff5566; }
.inspector-module-menu-item.danger:hover { background: rgba(255,85,102,0.12); }

/* ════════════════════════════════════════════════════════════════
   Map settings modal — left-rail tabs
   ──────────────────────────────────────────────────────────────── */
.ms-tabs-layout {
  display: flex;
  gap: 14px;
  min-height: 460px;
  max-height: 70vh;
}
.ms-tabs-rail {
  flex-shrink: 0;
  width: 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid var(--border);
  padding-right: 8px;
}
.ms-tabs-rail-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 9px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .12s, color .12s;
}
.ms-tabs-rail-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.ms-tabs-rail-btn.active {
  background: rgba(108,99,255,0.16);
  color: var(--accent, #6c63ff);
  font-weight: 600;
}
.ms-tabs-rail-btn .ms-tab-icon { font-size: 14px; }
.ms-tabs-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.ms-tab-pane { display: none; }
.ms-tab-pane.active { display: block; animation: tabFadeIn .15s ease-out; }
@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Map-settings modal — wider so the left rail + content fit comfortably */
#modal-map-settings .modal-box { width: min(820px, 96vw); }
#modal-map-settings .modal-body { padding: 16px; }

/* ── Mobile orientation gate ───────────────────────────────────── */
#mobile-landscape-gate {
  display: none;
}
.mobile-landscape-card {
  width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--bg2);
  box-shadow: var(--shadow);
  padding: 22px;
  text-align: center;
}
.mobile-landscape-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  font-weight: 800;
}
.mobile-landscape-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 8px;
}
.mobile-landscape-copy {
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 16px;
}
#btn-mobile-landscape {
  min-height: 40px;
  padding: 9px 14px;
  border-radius: var(--radius);
}

/* ════════════════════════════════════════════════════════════════
   Mobile responsive layer
   Keeps the desktop editor intact, then stacks panels on narrow screens.
   ──────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root {
    --panel-w: min(100vw, 340px);
    --status-h: 34px;
  }

  html, body {
    min-width: 0;
    width: 100%;
    overscroll-behavior: none;
  }

  body {
    font-size: 13px;
  }

  input, select, textarea {
    font-size: 16px;
  }

  #topbar {
    height: auto;
    min-height: 48px;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px 8px;
    padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
  }

  .topbar-left,
  .topbar-right {
    min-width: 0;
    width: 100%;
  }

  .topbar-left {
    order: 1;
    flex: 1 1 100%;
    gap: 6px;
  }

  .tab-nav {
    order: 2;
    flex: 1 1 100%;
    justify-content: flex-start;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .tab-nav::-webkit-scrollbar,
  .topbar-right::-webkit-scrollbar,
  .map-toolbar::-webkit-scrollbar,
  .preview-toolbar::-webkit-scrollbar,
  .audio-transport::-webkit-scrollbar,
  .modal-footer::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .topbar-right {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  #project-name-display {
    max-width: 36vw;
  }

  .topbar-level-select {
    max-width: 36vw;
    min-height: 34px;
  }

  .topbar-sep {
    display: none;
  }

  .btn-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }

  .btn-git {
    width: auto;
    min-width: 62px;
    padding: 0 8px;
    white-space: nowrap;
  }

  .btn-play {
    min-height: 36px;
    padding: 7px 13px;
    white-space: nowrap;
  }

  .peers-indicator {
    min-height: 36px;
    flex: 0 0 auto;
  }

  #main {
    min-height: 0;
  }

  .tab-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(112px, 24%) minmax(220px, 1fr) minmax(120px, 28%);
    overflow: hidden;
  }

  .panel {
    min-width: 0;
    min-height: 0;
    width: 100%;
    border-right: none;
    border-left: none;
  }

  .panel-left,
  .panel-right,
  .panel-center {
    width: 100%;
    min-width: 0;
  }

  .panel-left {
    border-bottom: 1px solid var(--border);
  }

  .panel-right {
    border-top: 1px solid var(--border);
  }

  .panel-center {
    min-height: 0;
  }

  .panel-header {
    min-height: 40px;
    padding: 7px 10px;
    gap: 8px;
  }

  .lib-controls {
    padding: 7px;
    gap: 6px;
  }

  .inp-search,
  .sel-sm,
  .btn-sm,
  .inp,
  .form-row input[type="text"],
  .form-row input[type="number"],
  .form-row select {
    min-height: 34px;
  }

  .item-list {
    padding: 5px;
  }

  .item-row {
    min-height: 42px;
    padding: 7px 8px;
  }

  .asset-category-header {
    min-height: 36px;
  }

  .asset-category-body {
    padding-left: 4px;
  }

  #tab-assets,
  #tab-audio,
  #tab-vfx {
    display: grid;
    grid-template-rows: minmax(130px, 26%) minmax(220px, 1fr) minmax(130px, 28%);
  }

  #tab-events {
    grid-template-rows: minmax(135px, 30%) minmax(280px, 1fr);
  }

  #tab-map {
    grid-template-rows: minmax(118px, 22%) minmax(300px, 1fr) minmax(150px, 28%);
  }

  #tab-map .panel-left {
    max-height: none;
  }

  #map-center-panel {
    display: flex;
    min-height: 0;
  }

  .map-toolbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 5px;
    padding: 6px 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .map-toolbar > * {
    flex: 0 0 auto;
  }

  .canvas-wrapper {
    min-height: 160px;
    touch-action: none;
  }

  .layer-panel {
    min-height: 96px;
    max-height: 34%;
  }

  .layer-row {
    min-height: 34px;
    padding: 5px 8px;
  }

  .inst-row {
    min-height: 32px;
  }

  .inspector-content,
  .panel-editor {
    padding: 10px;
  }

  .placeholder-msg {
    padding: 10px;
  }

  .asset-preview-layout,
  .audio-preview-layout,
  .vfx-preview-layout,
  .dlg-preview-area {
    padding: 10px;
  }

  .asset-canvas {
    max-height: min(220px, 34vh);
  }

  .preview-toolbar,
  .audio-transport,
  .vfx-preview-toolbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: 100%;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .preview-toolbar > *,
  .audio-transport > *,
  .vfx-preview-toolbar > * {
    flex: 0 0 auto;
  }

  .audio-waveform {
    height: 120px;
  }

  .audio-vol-wrap input {
    width: 92px;
  }

  .vfx-preview-canvas {
    min-height: 220px;
  }

  .dlg-editor-layout {
    flex-direction: column;
  }

  .dlg-step-list {
    width: 100%;
    max-height: 150px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .dlg-step-editor {
    padding: 10px;
  }

  #tab-flags .flags-layout {
    grid-row: 1 / -1;
    min-height: 0;
    overflow: auto;
    padding: 10px;
  }

  .flag-table {
    min-width: 760px;
  }

  #statusbar {
    height: calc(var(--status-h) + env(safe-area-inset-bottom));
    padding: 0 8px env(safe-area-inset-bottom);
    gap: 8px;
  }

  #save-status,
  #history-info {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #save-status {
    max-width: 96px;
  }

  .statusbar-center {
    min-width: 0;
    gap: 4px;
  }

  .statusbar-right {
    gap: 5px;
    font-size: 11px;
  }

  #btn-undo,
  #btn-redo {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
  }

  .cowork-chat {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(var(--status-h) + 12px + env(safe-area-inset-bottom));
  }

  .cowork-chat-toggle {
    width: 48px;
    height: 48px;
  }

  .cowork-chat-panel {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(var(--status-h) + 72px + env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    width: auto;
    height: auto;
    max-height: none;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  }

  .cowork-peer-list {
    grid-column: 1;
    grid-row: 2;
    max-height: 120px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .cowork-peer-item {
    grid-template-columns: 18px minmax(0, 1fr) auto auto;
  }

  .cowork-peer-kick {
    grid-column: auto;
    min-height: 28px;
    padding: 0 8px;
  }

  .cowork-chat-media-slot {
    grid-column: 1;
    grid-row: 3;
  }

  .cowork-chat-text {
    max-width: min(300px, calc(100vw - 96px));
  }

  .cowork-chat-header,
  .cowork-media-toolbar {
    min-height: 42px;
  }

  .cowork-chat-media-slot {
    flex: 0 0 auto;
    max-height: min(44vh, 340px);
    overflow-y: auto;
  }

  .cowork-chat-log {
    grid-column: 1;
    grid-row: 4;
    min-height: 0;
  }

  .cowork-chat-form {
    grid-column: 1;
    grid-row: 5;
  }

  .cowork-media {
    min-height: 0;
  }

  .cowork-media-stage {
    min-height: 0;
  }

  .cowork-media-stage:has(.cowork-media-grid:not(:empty)) {
    grid-template-columns: minmax(0, 1fr);
  }

  .cowork-media-local video {
    max-height: 30vh;
  }

  .cowork-media-grid {
    max-height: 220px;
  }

  .modal {
    align-items: center;
    justify-content: center;
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
  }

  .modal-box,
  .modal-wide,
  .modal-sm,
  #modal-map-settings .modal-box {
    width: 100%;
    max-width: 100%;
    max-height: calc(100vh - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .modal-header {
    padding: 12px 14px;
  }

  .modal-body,
  #modal-map-settings .modal-body {
    padding: 12px;
  }

  .modal-footer {
    justify-content: flex-start;
    overflow-x: auto;
    padding: 12px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer > * {
    flex: 0 0 auto;
    min-height: 36px;
  }

  .modal-footer button {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
  }

  .ms-tabs-layout {
    min-height: 0;
    max-height: none;
    flex-direction: column;
    gap: 10px;
  }

  .ms-tabs-rail {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0 0 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .ms-tabs-rail::-webkit-scrollbar {
    display: none;
  }

  .ms-tabs-rail-btn {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 8px 10px;
    white-space: nowrap;
  }

  .ms-tabs-content {
    padding-right: 0;
    overflow: visible;
  }

  .ms-bg-row {
    flex-direction: column;
  }

  .ms-bg-preview-wrap {
    width: 100%;
    height: 72px;
  }

  .form-grid {
    grid-template-columns: minmax(104px, auto) minmax(0, 1fr);
    gap: 8px;
  }

  .form-row {
    min-width: 0;
  }

  .form-row label {
    width: 92px;
  }

  .range-row .range-value {
    width: 46px;
  }

  .import-item {
    grid-template-columns: 1fr;
  }

  .import-item:not(.import-multirow) canvas {
    width: 100%;
    height: 120px;
  }

  .sheet-preview-wrap {
    max-height: 42vh;
  }

  .row-def-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .row-def-header,
  .row-def-row {
    min-width: 560px;
  }

  .condition-row,
  .effect-row,
  .choice-row,
  .sheet-ctrl-row {
    flex-wrap: wrap;
  }

  .play-header {
    flex-wrap: wrap;
    align-items: center;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
    gap: 8px;
  }

  .play-title {
    min-width: 140px;
  }

  #game-canvas {
    max-width: 100%;
    max-height: 100%;
  }

  .play-controls-hud {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    justify-content: flex-end;
  }

  .play-hud-btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  .debug-panel {
    top: calc(84px + env(safe-area-inset-top));
    left: 8px;
    max-width: calc(100vw - 16px);
  }
}

@media (max-width: 560px) {
  #project-name-display {
    max-width: 30vw;
  }

  .topbar-level-select {
    max-width: 34vw;
  }

  .tab-content {
    grid-template-rows: minmax(108px, 22%) minmax(230px, 1fr) minmax(136px, 30%);
  }

  #tab-map {
    grid-template-rows: minmax(108px, 20%) minmax(300px, 1fr) minmax(150px, 30%);
  }

  .panel-header {
    font-size: 12px;
  }

  .lib-controls {
    flex-wrap: nowrap;
  }

  .inp-search {
    min-width: 120px;
  }

  .sel-sm {
    max-width: 128px;
  }

  .topbar-right {
    gap: 4px;
  }

  .btn-git {
    width: 38px;
    min-width: 38px;
    padding: 0;
    font-size: 0;
  }

  #btn-git-pull::before,
  #btn-git-push::before {
    font-size: 16px;
    line-height: 1;
  }

  #btn-git-pull::before { content: '⬇'; }
  #btn-git-push::before { content: '⬆'; }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .form-row label {
    width: auto;
  }

  .toggle-row,
  .range-row {
    flex-direction: row;
    align-items: center;
  }

  .toggle-row label:first-child,
  .range-row label {
    width: 84px;
    flex-shrink: 0;
  }

  .range-row .num-range {
    width: 100%;
  }

  .range-row input[type="range"] {
    min-width: 96px;
  }

  .statusbar-right {
    display: none;
  }

  .cowork-chat-panel {
    height: min(72vh, 620px);
  }

  .modal-footer {
    flex-wrap: nowrap;
  }

  .modal-footer .btn-secondary,
  .modal-footer .btn-accent,
  .modal-footer .btn-danger,
  .modal-footer .btn-sm {
    white-space: nowrap;
  }

  .dropzone {
    padding: 28px 16px;
  }

  .play-header .checkbox-label {
    order: 3;
  }

  #btn-stop-play {
    min-height: 36px;
    padding: 7px 12px;
  }
}

@media (max-height: 640px) and (max-width: 900px) {
  #topbar {
    max-height: 132px;
    overflow-y: auto;
  }

  .tab-content,
  #tab-assets,
  #tab-audio,
  #tab-vfx,
  #tab-map {
    grid-template-rows: minmax(88px, 24%) minmax(210px, 1fr) minmax(104px, 26%);
  }

  .panel-header,
  .lib-controls {
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .item-row {
    min-height: 36px;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  #mobile-landscape-gate {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background:
      radial-gradient(circle at 50% 16%, rgba(108,99,255,0.24), transparent 34%),
      rgba(13,13,20,0.94);
    backdrop-filter: blur(8px);
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  :root {
    --panel-w: clamp(178px, 24vw, 236px);
    --topbar-h: 44px;
    --status-h: 28px;
  }

  html,
  body {
    height: var(--mobile-vh, 100dvh);
  }

  #mobile-landscape-gate {
    display: none !important;
  }

  #topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    max-height: none;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    overflow: visible;
    padding: max(0px, env(safe-area-inset-top)) 8px 0 max(8px, env(safe-area-inset-left));
  }

  .topbar-left,
  .topbar-right {
    width: auto;
    flex: 0 0 auto;
    order: 0;
  }

  .topbar-left {
    max-width: 28vw;
    gap: 5px;
  }

  .logo {
    font-size: 18px;
  }

  #project-name-display {
    max-width: 84px;
    font-size: 13px;
  }

  .topbar-level-select {
    width: 92px;
    max-width: 92px;
    min-width: 72px;
    min-height: 32px;
  }

  .tab-nav {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    order: 0;
    justify-content: flex-start;
    padding-bottom: 0;
  }

  .tab-btn {
    min-height: 32px;
    padding: 6px 10px;
  }

  .topbar-right {
    max-width: 36vw;
    min-width: 0;
    justify-content: flex-start;
    padding-bottom: 0;
  }

  .btn-icon,
  #btn-undo,
  #btn-redo {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .btn-play {
    min-height: 32px;
    padding: 5px 10px;
  }

  .peers-indicator {
    min-height: 32px;
  }

  .tab-content,
  #tab-assets,
  #tab-audio,
  #tab-vfx,
  #tab-map,
  #tab-events,
  #tab-dialogues {
    display: flex;
    flex-direction: row;
    grid-template-rows: none;
  }

  .item-list,
  .inspector-content,
  .panel-editor,
  .asset-preview-layout,
  .audio-preview-layout,
  .vfx-preview-layout,
  .dlg-preview-area,
  .dlg-step-items,
  .dlg-step-editor {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .panel {
    min-height: 0;
    border-top: none;
    border-bottom: none;
  }

  .panel-left {
    width: var(--panel-w);
    flex: 0 0 var(--panel-w);
    border-right: 1px solid var(--border);
  }

  .panel-right {
    width: var(--panel-w);
    flex: 0 0 var(--panel-w);
    border-left: 1px solid var(--border);
  }

  .panel-center {
    flex: 1 1 auto;
    min-width: 0;
  }

  .panel-header {
    min-height: 34px;
    padding: 5px 8px;
  }

  .lib-controls {
    padding: 6px;
  }

  .inp-search,
  .sel-sm,
  .btn-sm,
  .inp,
  .form-row input[type="text"],
  .form-row input[type="number"],
  .form-row select {
    min-height: 30px;
    font-size: 13px;
  }

  .item-row {
    min-height: 34px;
    padding: 5px 7px;
  }

  .drag-source-list .item-row {
    touch-action: pan-y;
  }

  .asset-category-header {
    min-height: 32px;
  }

  .asset-category-body {
    padding-left: 4px;
  }

  .map-toolbar {
    min-height: 36px;
    padding: 4px 8px;
  }

  .canvas-wrapper {
    min-height: 0;
    touch-action: none;
  }

  .layer-panel {
    min-height: 88px;
    max-height: 32%;
  }

  .inspector-content,
  .panel-editor,
  .asset-preview-layout,
  .audio-preview-layout,
  .vfx-preview-layout,
  .dlg-preview-area {
    padding: 8px;
  }

  .dlg-step-list {
    width: 180px;
    max-height: none;
    border-right: 1px solid var(--border);
    border-bottom: none;
  }

  .dlg-editor-layout {
    flex-direction: row;
  }

  .condition-row,
  .effect-row,
  .choice-row {
    flex-wrap: wrap;
  }

  .condition-row select,
  .effect-row select,
  .condition-row input,
  .effect-row input,
  .choice-row input[type="text"] {
    min-width: 0;
  }

  #tab-flags .flags-layout {
    grid-row: auto;
    width: 100%;
  }

  #statusbar {
    height: calc(var(--status-h) + env(safe-area-inset-bottom));
    padding: 0 8px env(safe-area-inset-bottom);
  }

  .statusbar-right {
    display: flex;
  }

  .cowork-chat {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(var(--status-h) + 12px + env(safe-area-inset-bottom));
  }

  .cowork-chat-panel {
    top: max(8px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(var(--status-h) + 12px + env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    width: auto;
    height: auto;
    max-height: none;
    display: grid;
    grid-template-columns: minmax(150px, 22%) minmax(180px, 30%) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-radius: var(--radius-sm);
  }

  .cowork-chat-header {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .cowork-peer-list {
    grid-column: 1;
    grid-row: 2 / 4;
    max-height: none;
    border-right: 1px solid var(--border);
    border-bottom: none;
  }

  .cowork-peer-item {
    grid-template-columns: 18px minmax(0, 1fr) auto;
  }

  .cowork-peer-kick {
    grid-column: 2 / 4;
  }

  .cowork-chat-media-slot {
    grid-column: 2;
    grid-row: 2 / 4;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    border-bottom: none;
  }

  .cowork-media {
    min-height: 0;
  }

  .cowork-media-toolbar {
    min-height: 36px;
  }

  .cowork-media-actions {
    flex: 0 0 auto;
  }

  .cowork-media-stage {
    min-height: 0;
  }

  .cowork-chat-log {
    grid-column: 3;
    grid-row: 2;
    min-height: 0;
  }

  .cowork-chat-form {
    grid-column: 3;
    grid-row: 3;
  }

  .cowork-media-local video {
    max-height: 26vh;
  }

  .cowork-media-grid {
    max-height: 34vh;
  }

  .modal-box,
  .modal-wide,
  .modal-sm {
    width: min(720px, 96vw);
    max-height: calc(var(--mobile-vh, 100dvh) - 20px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  #modal-map-settings .modal-box {
    width: min(820px, 96vw);
  }

  .ms-tabs-layout {
    min-height: 360px;
    max-height: calc(var(--mobile-vh, 100dvh) - 150px);
    flex-direction: row;
  }

  .ms-tabs-rail {
    width: 150px;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    border-bottom: none;
    padding: 0 8px 0 0;
  }

  .ms-tabs-content {
    overflow-y: auto;
    padding-right: 4px;
  }

  .play-header {
    flex-wrap: nowrap;
    min-height: 42px;
    padding: max(6px, env(safe-area-inset-top)) 10px 6px;
  }

  .play-controls-hud {
    left: auto;
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .play-touch-stick {
    width: clamp(98px, 18vh, 124px);
    height: clamp(98px, 18vh, 124px);
    left: max(14px, env(safe-area-inset-left));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .play-touch-stick-knob {
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
  }

  .play-touch-actions {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    grid-template-columns: repeat(2, clamp(58px, 10vh, 68px));
    gap: 8px;
  }

  .play-touch-btn {
    min-height: clamp(52px, 10vh, 64px);
    border-radius: 16px;
  }

  .play-touch-btn-jump,
  .play-touch-btn-attack {
    min-height: clamp(60px, 12vh, 74px);
  }
}

@media (pointer: coarse) {
  button,
  .item-row,
  .layer-row,
  .inst-row,
  .dlg-step-item,
  .module-picker-item,
  .inspector-module-header {
    -webkit-tap-highlight-color: rgba(108,99,255,0.18);
  }
}

