@font-face {
  font-family: 'Press Start 2P';
  src: url('assets/fonts/PressStart2P-Regular.ttf') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* Scenery stays beside the level on desktop. On small screens browsing opens
   a sheet; choosing a sprite collapses it to placement controls. */
.goo-library[hidden] { display: none !important; }
.goo-library { width: 280px; min-width: 280px; height: 100dvh; overflow-y: auto; padding: 16px; box-sizing: border-box; border-right: 2px solid var(--mx-line); background: var(--mx-panel, #151119); color: var(--mx-paper, #f5f2ea); font-size: 10px; line-height: 1.7; }
.goo-library header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.goo-library h2 { font-size: 12px; margin: 0; text-transform: uppercase; color: var(--mx-paper); }
.goo-library button, .goo-library select, .goo-library input { font: inherit; }
.goo-library button, .goo-library select { color: inherit; border: 1px solid var(--mx-line); background: var(--mx-panel-2); padding: 10px; min-height: 40px; cursor: pointer; }
.goo-library button:hover, .goo-library button:focus-visible { border-color: var(--mx-cyan); }
.goo-library button:focus-visible, .goo-library input:focus-visible, .goo-library select:focus-visible { outline: 2px solid var(--mx-cyan); outline-offset: 3px; }
.goo-library .goo-primary { width: 100%; color: var(--mx-paper); background: var(--mx-panel-2); border-color: var(--mx-purple); }
.goo-library .goo-primary[aria-pressed="true"] { background: var(--mx-purple-deep); }
.goo-library canvas { display: block; width: 100%; image-rendering: pixelated; border-bottom: 1px solid var(--mx-line); }
.goo-library label { display: block; margin-top: 18px; }
.goo-library select { width: 100%; margin-top: 6px; }
.goo-library fieldset { padding: 12px 0 0; margin: 18px 0; border: 0; border-top: 1px solid var(--mx-line); }
.goo-library legend { padding-right: 8px; color: var(--mx-cyan); }
.goo-library fieldset:disabled { opacity: .45; }
.devices-library input[type="number"] { width:100%; box-sizing:border-box; min-height:42px; margin-top:6px; padding:10px; color:inherit; background:var(--mx-panel-2); border:1px solid var(--mx-line); }
.devices-library fieldset > button { display:block; width:100%; margin-top:10px; text-align:left; }
#pipe-orientation { display:flex; align-items:center; gap:12px; margin-top:12px; }
#pipe-orientation > div { flex:1; min-width:0; }
#pipe-orientation label { margin-top:4px; }
#pipe-preview { display:block; flex:none; width:44px; height:44px; border:0; }
#pipe-status { font-size:9px; line-height:1.7; }
#pipe-incoming { margin:8px 0; font-size:9px; line-height:1.7; color:var(--mx-cyan); }
#pipe-location { display:none; }
#grid-canvas[data-pipe-editing] { touch-action:pan-x pan-y; cursor:crosshair; }
@media (max-width:900px) {
  #pipes-library[data-locating="true"] { padding:8px 12px; }
  #pipes-library[data-locating="true"] > :not(#pipe-location) { display:none !important; }
  #pipes-library[data-locating="true"] #pipe-location { display:flex; align-items:center; justify-content:space-between; gap:8px; }
  #pipes-library[data-drawing="true"] { max-height:44dvh; }
  #pipes-library[data-drawing="true"] header { display:none; }
  #pipes-library[data-drawing="true"] #pipe-orientation { margin:0; }
}
.hazard-choices { display: grid; gap: 8px; margin-bottom: 12px; }
.hazard-choices button { text-align: left; display: grid; gap: 4px; }
.hazard-choices button[aria-pressed="true"] { border-color: var(--mx-cyan); background: var(--mx-panel-2); }
.hazard-choices strong { color: var(--mx-paper); font: inherit; }
.hazard-choices span { font-size: 9px; color: var(--mx-muted); }
.goo-library .hazard-choices canvas { width: 96px; height: 32px; border: 0; }
.goo-library [hidden] { display: none !important; }
.goo-height-row { display: flex; align-items: center; gap: 10px; }
.goo-height-row input { min-width: 0; width: 100%; accent-color: var(--mx-cyan); }
.goo-height-row output { white-space: nowrap; font-size: 9px; }
.goo-help { font: 8px/1.8 var(--mx-ui); color: var(--mx-muted); }
.goo-library[data-drawing="true"] fieldset, .goo-library[data-drawing="true"] > label, .goo-library[data-drawing="true"] > select { display: none; }
.goo-library[data-drawing="true"] > .mx-select, .goo-library[data-spikes="true"] .goo-key-help { display: none; }
#goo-status { min-height: 48px; font-family: ui-monospace, monospace; font-size: 12px; }
.goo-presets { display: flex; gap: 6px; margin: 12px 0; }
.goo-presets button { flex: 1; }
#goo-resize, #goo-delete { width: 100%; margin-top: 8px; }
#goo-delete { color: #f7a3a7; }
@media (max-width: 900px) {
  .goo-library { position: fixed; z-index: 84; left: 56px; bottom: 10px; height: auto; max-height: 55dvh; width: min(280px, calc(100vw - 70px)); min-width: 0; border: 2px solid var(--mx-line); padding: 12px; }
  .goo-library canvas, .goo-key-help, .goo-library fieldset > .goo-help { display: none; }
  .goo-library label { margin-top: 8px; }
  #goo-status { min-height: 0; margin: 8px 0; }
  .goo-library fieldset { margin: 12px 0 0; }
  .goo-library[data-drawing="true"] { top: 64px; bottom: auto; max-height: 132px; }
  .goo-library[data-drawing="true"] > .goo-help, .goo-library[data-drawing="true"] > .goo-primary { display: none; }
  .goo-library[data-drawing="true"] .hazard-choices { display: none; }
  .goo-library[data-drawing="true"] header { margin-bottom: 4px; }
  .goo-library header { position: sticky; top: -12px; z-index: 1; background: var(--mx-panel, #151119); padding: 4px 0; }
}
.scenery-library[hidden] { display: none !important; }
.scenery-library {
  width: 304px; min-width: 304px; height: 100dvh; display: flex;
  flex-direction: column; overflow: hidden; border-right: 2px solid var(--mx-line);
  background: var(--mx-panel, #151119); color: var(--mx-paper, #f5f2ea);
  font-size: 9px; line-height: 1.65;
}
.scenery-library button, .scenery-library input, .scenery-library select { font: inherit; color: inherit; }
.scenery-heading { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--mx-line); }
.scenery-heading h2 { font-size: 13px; text-transform: uppercase; }
.scenery-heading button { border: 0; background: transparent; width: 36px; height: 36px; font-size: 22px; cursor: pointer; }
.scenery-browser { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px 16px; overscroll-behavior: contain; }
.scenery-search-label { display: block; color: var(--mx-muted); margin-bottom: 6px; }
.scenery-library input[type="search"] { width: 100%; height: 40px; padding: 8px; border: 1px solid var(--mx-line); border-radius: 0; background: #100d14; font-size: 10px; }
.scenery-pack { margin-top: 12px; border-block: 1px solid var(--mx-line); padding: 10px 0; }
#scenery-ground-details { width: 100%; min-height: 44px; margin-bottom: 8px; padding: 7px; border: 1px solid var(--mx-line); background: #211828; font-size: 8px; cursor: pointer; }
#scenery-ground-details[aria-pressed="true"] { color: var(--mx-cyan); border-color: var(--mx-cyan); background: #112128; }
.scenery-pack-picker { display: grid; gap: 8px; font-size: 8px; }
.scenery-pack-picker select { flex: 1; min-width: 0; min-height: 36px; background: #100d14; border: 1px solid var(--mx-line); padding: 6px; }
#scenery-folders { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 10px; }
#scenery-folders button { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 34px; padding: 6px 4px; text-align: left; background: transparent; border: 1px solid transparent; cursor: pointer; font-size: 8px; }
#scenery-folders button[aria-pressed="true"] { color: var(--mx-cyan); border-color: var(--mx-cyan); background: #112128; }
.scenery-results { min-height: 25px; padding-top: 10px; color: var(--mx-muted); font-size: 8px; }
.scenery-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.scenery-card { display: flex; flex-direction: column; align-items: center; border: 1px solid var(--mx-line); background: #0b1516; padding: 4px 0 8px; min-width: 0; cursor: pointer; }
.scenery-card:hover, .scenery-card[aria-pressed="true"] { border-color: var(--mx-cyan); }
.scenery-card canvas { display: block; width: 128px; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; }
.scenery-card span { font-size: 8px; line-height: 1.7; text-align: center; padding-inline: 5px; }
.scenery-tools { flex-shrink: 0; padding: 10px; border-top: 2px solid var(--mx-line); background: #100d14; }
#scenery-status { min-height: 42px; color: var(--mx-paper); font-size: 8px; }
.scenery-size { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0; font-size: 8px; }
.scenery-size-buttons { display: flex; gap: 5px; }
.scenery-size button, .scenery-size select { min-height: 44px; border: 1px solid var(--mx-line); background: #211828; }
.scenery-size button { min-width: 44px; font-size: 18px; cursor: pointer; }
.scenery-size select { min-width: 72px; padding: 6px; font-size: 12px; }
.scenery-size button:disabled, .scenery-size select:disabled { opacity: .4; cursor: default; }
.scenery-backgrounder { margin-top: 8px; border-block: 1px solid var(--mx-line); font-size: 8px; }
.scenery-backgrounder summary { padding: 12px 2px; cursor: pointer; color: var(--mx-cyan); }
.scenery-depth-controls { display: grid; gap: 5px; padding: 0 2px 10px; }
.scenery-depth-controls select { min-height: 38px; width: 100%; padding: 6px; background: #211828; border: 1px solid var(--mx-line); }
.scenery-depth-controls input[type="range"] { width: 100%; min-height: 32px; accent-color: var(--mx-cyan); }
.scenery-range-label, .scenery-tint-row { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.scenery-tint-row input { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--mx-line); background: #211828; }
.scenery-tint-row button { min-height: 38px; padding: 5px; border: 1px solid var(--mx-line); background: #211828; cursor: pointer; }
.scenery-depth-controls :disabled { opacity: .4; cursor: default; }
.scenery-depth-controls p { color: var(--mx-muted); font-size: 7px; line-height: 1.8; }
.scenery-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 8px 0; font-size: 8px; }
.scenery-options label { display: flex; align-items: center; gap: 5px; min-height: 32px; }
.scenery-options input { accent-color: var(--mx-cyan); width: 16px; height: 16px; }
.scenery-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.scenery-actions button { padding: 8px 4px; min-height: 34px; border: 1px solid var(--mx-line); background: #211828; font-size: 8px; cursor: pointer; }
.scenery-actions button:disabled { opacity: .4; cursor: default; }
.scenery-actions button[aria-pressed="true"] { border-color: var(--mx-cyan); color: var(--mx-cyan); }
.scenery-help { margin-top: 8px; color: var(--mx-muted); font-size: 7px; line-height: 1.9; }
#grid-canvas[data-scenery-active="true"] { touch-action: none; }
@media (min-width: 901px) {
  .scenery-tools { max-height: calc(100dvh - 300px); overflow-y: auto; overscroll-behavior: contain; }
}
@media (max-width: 900px) {
  .app.scenery-library-open .main { padding-bottom: var(--scenery-sheet-height, 0px); }
  .scenery-library { position: fixed; z-index: 85; inset: auto 0 0; width: 100%; min-width: 0; height: min(74dvh, 720px); border: 2px solid var(--mx-line); }
  .scenery-cards { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); }
  .scenery-library[data-collapsed="true"] { height: auto; max-height: 36dvh; overflow-y: auto; }
  .scenery-library[data-collapsed="true"] .scenery-browser,
  .scenery-library[data-collapsed="true"] .scenery-help { display: none; }
  .scenery-library[data-collapsed="true"] .scenery-heading { padding: 2px 8px; }
  .scenery-library[data-collapsed="true"] .scenery-heading h2 { font-size: 9px; }
  .scenery-library[data-collapsed="true"] .scenery-tools { padding: 5px 8px; }
  .scenery-library[data-collapsed="true"] #scenery-status { min-height: 0; }
  .scenery-library[data-collapsed="true"] .scenery-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .scenery-options { margin-block: 3px; }
  .scenery-library input[type="search"] { font-size: 16px; }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--mx-pixel);
  background: #191a1a;
  color: #d4d4d4;
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────── */

.sidebar {
  width: 48px;
  background: #191a1a;
  border-right: 1px solid #2a2b2b;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 0;
  flex-shrink: 0;
}

.sidebar-top,
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sidebar-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: #6b6b6b;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-icon:hover {
  background: #2a2b2b;
  color: #a0a0a0;
}

.sidebar-icon.active {
  color: #4a9a8a;
  background: #2a2b2b;
}

.sidebar-icon.logo {
  color: #4a9a8a;
  margin-bottom: 8px;
}

.sidebar-icon.notification {
  position: relative;
}

.sidebar-icon .dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  background: #4a9a8a;
  border-radius: 50%;
}

.sidebar-icon.avatar img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

/* ── Main Content ────────────────────────────────── */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #2a2b2b;
  gap: 10px;
  flex-shrink: 0;
}

.back-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
}

.back-btn:hover {
  color: #ccc;
}

.title {
  font-size: 14px;
  font-weight: 500;
  color: #d4d4d4;
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  /* wrap to a second row instead of clipping unreachable buttons in the
     ~681–900px band where the toolbar is too wide but the mobile rules don't apply */
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-btn {
  background: none;
  border: 1px solid #333;
  color: #999;
  cursor: pointer;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.header-btn:hover {
  background: #2a2b2b;
  color: #ccc;
}

.header-btn:active {
  transform: scale(0.95);
  background: #333;
}

.header-btn.dots {
  padding: 5px 8px;
  border: 1px solid #333;
}

.header-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.header-btn.share-btn {
  background: #d4d4d4;
  color: #191a1a;
  border-color: #d4d4d4;
  font-weight: 500;
}

.header-btn.share-btn:hover {
  background: #e8e8e8;
}

.header-btn.share-btn:active {
  background: #ccc;
  transform: scale(0.95);
}

/* ── Content Area ────────────────────────────────── */

.content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Tile Palette ───────────────────────────────── */

.tile-palette {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid #2a2b2b;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tile-palette::-webkit-scrollbar {
  display: none;
}

.main ::-webkit-scrollbar {
  display: none;
}

.main * {
  scrollbar-width: none;
}

.palette-tile {
  width: 40px;
  height: 40px;
  border: 2px solid #333;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e2020;
  transition: border-color 0.15s;
  flex-shrink: 0;
  position: relative;
}

.palette-tile:hover {
  border-color: #555;
}

.palette-tile.selected {
  border-color: #4a9a8a;
  background: rgba(74, 154, 138, 0.10);
}

/* Select/Move is a MODE (not a thing you place) — tint it teal so it reads as
   distinct from the tile/enemy/collectable swatches around it. */
.select-tile {
  color: #4a9a8a;
}
.select-tile:hover {
  border-color: #4a9a8a;
}
.select-tile.selected {
  color: #6fe6d2;
  border-color: #4a9a8a;
}

.palette-tile canvas {
  image-rendering: pixelated;
  width: 32px;
  height: 32px;
  border-radius: 0;
}

/* Visible reference numbers for reporting artwork by theme + tile number.
   Reserve space above the preview so labels cannot cover the native art. */
.palette-tile.numbered {
  height: 58px;
  flex-direction: column;
  gap: 4px;
}

.palette-tile-number {
  flex: 0 0 12px;
  font: 8px/12px var(--mx-ui);
  font-variant-numeric: tabular-nums;
  color: var(--mx-paper);
  pointer-events: none;
}

/* Collision is gameplay data, not an invisible implementation detail. Half
   tiles and slopes communicate their shape through their art; only mark
   pass-through tiles, whose missing collision cannot otherwise be seen. */
.palette-tile[data-collider="none"] {
  border-style: dashed;
}

.palette-collider-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  z-index: 1;
  min-width: 16px;
  height: 14px;
  padding: 1px 3px 0;
  display: grid;
  place-items: center;
  border: 1px solid #09070b;
  border-radius: 1px;
  color: var(--mx-paper, #fff7e8);
  background: var(--mx-coral, #ff6666);
  font-family: var(--mx-mono, monospace);
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: normal;
  pointer-events: none;
}

/* Named decorative groups already explain why the tile has no collision. */
.palette-collider-badge.palette-decoration-badge {
  color: #d4e8df;
  background: #29463e;
}

.palette-tile.numbered.palette-decoration-tile {
  width: 48px;
}

.palette-group-label[data-palette-group^="decorations-"] {
  flex-basis: 112px;
}

/* ── Tileset card ──────────────────────────────────
   One compact button with one job: choose the active terrain library. Palette
   category switching is a physically separate control below. */
.tileset-card {
  display: flex;
  align-items: center;
  gap: 0;
  height: 40px;
  width: 140px;
  padding: 0;
  border: 2px solid #333;
  border-radius: 6px;
  background: #1e2020;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.tileset-card:hover { border-color: #555; }
.tileset-card.open { border-color: #4a9a8a; background: rgba(74, 154, 138, 0.10); }
.tileset-card canvas { width: 26px; height: 26px; border-radius: 3px; flex-shrink: 0; }

.tileset-switcher {
  min-width: 0;
  height: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 5px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* shared label (used by the card and the dropdown cards) */
.tileset-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  pointer-events: none;
  min-width: 0;
}
.tileset-badge .set-name {
  font-size: 11px;
  font-weight: 600;
  color: #cfeae3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tileset-badge .set-count {
  font-size: 9px;
  color: #7a8a86;
  white-space: nowrap;
}
/* On the fixed-width card, the badge fills the space and the name truncates with
   an ellipsis when longer than "Pinefields Warm". */
.tileset-card .tileset-badge { flex: 1; align-items: stretch; }

/* The dropdown panel of tileset cards (fixed-positioned on <body>). */
.tileset-dropdown {
  position: fixed;
  z-index: 400;
  min-width: 210px;
  max-height: 62vh;
  overflow-y: auto;
  background: #1a1b1b;
  border: 1px solid #2f3030;
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top left;
  transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.tileset-dropdown.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.tileset-dropdown[hidden] { display: none; }
.tileset-dropdown::-webkit-scrollbar { width: 6px; }
.tileset-dropdown::-webkit-scrollbar-thumb { background: #2f3030; border-radius: 3px; }

/* Uniform tileset card inside the dropdown. */
.ts-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px 6px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  color: inherit;
  font: inherit;
  text-align: left;
}
.ts-card:hover { background: #232525; border-color: #3a3c3c; }
.ts-card canvas {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.ts-card.active { background: rgba(74, 154, 138, 0.14); border-color: #4a9a8a; }
.ts-card.active .set-name { color: #6fe6d2; }
.ts-card-check {
  margin-left: auto;
  padding-left: 8px;
  color: #6fe6d2;
  font-size: 12px;
  font-weight: 700;
}

@media (pointer: coarse) {
  .tileset-card { height: 46px; }
}

.eraser-tile {
  color: #888;
}

.eraser-tile.selected {
  color: #4a9a8a;
}

.spawn-tile {
  color: #e8a84c;
}

.spawn-tile.selected {
  color: #e8a84c;
  border-color: #e8a84c;
}

.goal-tile {
  color: #4caf50;
}

.checkpoint-tile.selected { border-color: #4cdacc; }

.goal-tile.selected {
  color: #4caf50;
  border-color: #4caf50;
}

.palette-separator {
  font-size: 10px;
  color: #555;
  text-transform: uppercase;
  letter-spacing: normal;
  padding: 4px 6px;
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  border-left: 2px solid #333;
  margin-left: 4px;
}

/* ── Grid ───────────────────────────────────────── */

.grid-wrapper {
  flex: 1;
  overflow: auto;          /* long/touch-zoomed levels can move on both axes */
  position: relative;
  background: #141515;
  display: flex;
  /* Anchor a fitting canvas to the bottom, leaving spare space above it.
     Overflow falls back to start so compact touch layouts retain every row.
     flex-start is the fallback for browsers without safe alignment support. */
  align-items: flex-start;
  align-items: safe flex-end;
  justify-content: safe center;  /* center short levels; don't clip the start of long ones */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* no visible scrollbar — navigate with the mouse wheel (desktop) or
     drag-the-background (touch). overflow-x stays so scrollLeft still works. */
}

.grid-wrapper canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  position: relative;
  flex: none;
  touch-action: none;
}

/* Keyboard grid navigation paints its cell marker inside the canvas. The
   canvas itself never needs an additional screen-sized focus frame. */

/* ── Game Mode Overlay ──────────────────────────── */

.game-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.game-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.game-overlay.open[data-playing] { touch-action:none; overscroll-behavior:contain; }
@media (any-pointer: coarse) {
  .game-overlay.open[data-playing] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}
.pipe-hint { position:absolute; z-index:4; top:max(76px,calc(env(safe-area-inset-top) + 70px)); left:50%;
  transform:translateX(-50%); padding:8px 10px; color:#fff; background:#211c30; border:1px solid #867a9d;
  white-space:nowrap; font:9px/1.5 'Press Start 2P',monospace; pointer-events:none; }
#game-overlay:has(#pipe-hint:not([hidden])) #game-hint:not(:has(.level-name)) { visibility:hidden; }

.game-overlay canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  position: absolute;
  flex: none;
}

.game-exit {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #888;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 1;
}

.game-exit:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.game-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(21, 16, 30, 0.94);
  color: #f5f2ff;
  font-size: 13px;
  padding: 8px 20px;
  border: 1px solid #685478;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1;
}

.game-hint.show {
  opacity: 1;
}

/* ── On-screen touch controls (mobile-first) ──
   Hidden by default; .touch-active is added by JS only on touch devices.
   Sits above the canvas (z-index 1/2) but below the pause/completion modals
   (z-index 10) so those still cover the buttons when open. */
.touch-controls {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none; /* container ignores touches; only the buttons catch them */
}

.touch-controls.touch-active {
  display: block;
}

.touch-move {
  position: absolute;
  left: max(18px, env(safe-area-inset-left, 0px));
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 14px;
}

.lobby-directions { display: contents; }
.touch-stick { display: none; }
[data-touch-layout="joystick"] .touch-move.has-touch-stick {
  width: 100px; height: 100px; gap: 0;
}
[data-touch-layout="joystick"] .lobby-directions.has-touch-stick {
  position: relative; display: flex; flex: 0 1 104px; height: 44px; min-width: 88px;
}
[data-touch-layout="joystick"] .has-touch-stick > button {
  position: absolute; inset: 0 auto 0 0; width: 50%; height: 100%; min-width: 0;
  margin: 0; padding: 0; opacity: 0; pointer-events: none;
}
[data-touch-layout="joystick"] .has-touch-stick > button:nth-child(2) { left: 50%; }
[data-touch-layout="joystick"] .has-touch-stick > button:focus-visible { z-index: 2; opacity: 1; }
[data-touch-layout="joystick"] .has-touch-stick > .touch-stick {
  position: absolute; inset: 0; display: block; box-sizing: border-box;
  --knob: 40%; border: 2px solid #d8ceda; border-radius: 100px;
  background: linear-gradient(#9687a4,#9687a4) left 8% center / 5px 2px no-repeat,
    linear-gradient(#9687a4,#9687a4) right 8% center / 5px 2px no-repeat, rgba(24,18,33,.83);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.45); pointer-events: auto;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
[data-touch-layout="joystick"] .lobby-directions > .touch-stick { --knob: 26px; }
.touch-stick::after {
  content: ""; position: absolute; top: 50%; left: 50%; width: var(--knob); aspect-ratio: 1;
  transform: translate(calc(-50% + var(--stick-x,0px)),calc(-50% + var(--stick-y,0px)));
  box-sizing: border-box; border: 2px solid #d8cbe6; border-radius: 50%;
  background: #71627d; box-shadow: inset 0 -3px 0 #58485e; pointer-events: none;
}
.touch-stick[data-held]::after { background: var(--mx-cyan); border-color: #b5fff1; box-shadow: inset 0 -3px 0 #40988f; }

.touch-layout-choice { margin: 0 0 16px; padding: 0; border: 0; color: var(--mx-paper); font: 10px/1.6 var(--mx-ui); }
.touch-layout-choice legend { margin-bottom: 6px; }
.touch-layout-choice label { display: inline-block; position: relative; }
.touch-layout-choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.touch-layout-choice span {
  display: inline-grid; place-items: center; min-width: 94px; min-height: 44px;
  padding: 0 10px; border: 2px solid var(--mx-line); background: var(--mx-panel-2);
}
.touch-layout-choice input:checked + span { color: var(--mx-cyan); border-color: var(--mx-cyan); background: #142a2a; }
.touch-layout-choice input:focus-visible + span { outline: 2px solid var(--mx-paper); outline-offset: 2px; }

.touch-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none; /* suppress browser pan/zoom gestures on the button */
  transition: background 0.1s ease, transform 0.1s ease;
}

.touch-btn.pressed {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.92);
}

.touch-jump {
  position: absolute;
  right: max(18px, env(safe-area-inset-right, 0px));
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  width: 76px;
  height: 76px;
  background: rgba(80, 200, 120, 0.32);
  border-color: rgba(120, 240, 160, 0.5);
}

.touch-jump.pressed {
  background: rgba(80, 200, 120, 0.55);
}

.touch-spin {
  position: absolute;
  right: calc(max(18px, env(safe-area-inset-right, 0px)) + 88px);
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  border-color: var(--mx-cyan);
}


[data-power-drop-binding][hidden] { display: none; }

@media (max-width: 360px) {
  .touch-spin {
    right: max(24px, env(safe-area-inset-right, 0px));
    bottom: calc(max(24px, env(safe-area-inset-bottom, 0px)) + 88px);
  }
}

.game-warning {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(58, 42, 12, 0.92);
  border: 1px solid #6a4a1a;
  color: #e8a84c;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}

.game-warning.show {
  opacity: 1;
}

/* ── Completion Overlay ────────────────────────────── */

.game-overlay button.gamepad-focus {
  box-shadow: inset 0 -3px 0 var(--mx-cyan) !important;
}

.game-controller-status {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 32px); margin: 0; padding: 10px 14px;
  background: #211b2a; color: #f5edf7; font: 10px/1.6 var(--mx-ui);
  border: 2px solid #63e0dc; text-align: center; pointer-events: none;
}
.game-controller-status:empty { display: none; }

.completion-overlay {
  display: flex;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.completion-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.completion-card {
  background: #1a1b1b;
  border: 1px solid #2a2b2b;
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  min-width: 300px;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.completion-overlay.open .completion-card {
  transform: scale(1);
}

.completion-title {
  font-size: 24px;
  font-weight: 700;
  color: #4caf50;
  margin-bottom: 12px;
}

.completion-score {
  font-size: 16px;
  color: #d4d4d4;
  margin-bottom: 24px;
}

.completion-rating {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}

/* Explicit flex/block declarations otherwise outrank the browser's default
   [hidden] rule. Local Playtest has nothing meaningful to vote on, so remove
   the rating surface and its reserved status space completely. */
.completion-rating[hidden],
#rating-status[hidden] { display: none; }

.completion-rate-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid #333;
  background: #1e2020;
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.15s;
}

.completion-rate-btn:hover {
  border-color: #555;
  color: #ccc;
  transform: scale(1.08);
}

.completion-rate-btn.rated {
  border-color: #4a9a8a;
  color: #4a9a8a;
  background: rgba(74, 154, 138, 0.15);
}

.completion-rate-btn:disabled { cursor: wait; opacity: 0.65; transform: none; }
.rating-status {
  min-height: 18px;
  margin-bottom: 16px;
  color: #9aacaa;
  font-size: 12px;
  line-height: 1.4;
}
.rating-status.err { color: #ff8a8a; }
.rating-status.ok { color: #7fd6a0; }

.completion-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.completion-btn {
  padding: 10px 24px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #1e2020;
  color: #d4d4d4;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.completion-btn:hover {
  background: #2a2b2b;
  color: #fff;
}

.completion-btn:active {
  transform: scale(0.95);
}

.completion-btn-exit {
  background: none;
  border-color: #444;
  color: #888;
}

.completion-btn-exit:hover {
  color: #ccc;
  background: #222;
}

/* ── Pause / Options modal (reuses .completion-overlay/.completion-card) ── */
.completion-card.pause-card {
  width: min(460px, calc(100vw - 32px));
  min-width: 0;
  max-height: calc(100dvh - 32px);
  padding: 28px 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.pause-title { color: #4a9a8a; }
.pause-actions { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 16px; min-width: 0; }
.pause-actions .completion-btn { width: 100%; }
#pause-fullscreen[hidden], .pause-fullscreen-status[hidden] { display: none !important; }
.pause-fullscreen-status { margin: 0; color: var(--mx-acid); font: 10px/1.6 var(--mx-pixel); }
.pause-resume { background: #2f7d70; border-color: #10403a; color: #fff; }
.pause-resume:hover { background: #37968a; color: #fff; }
.pause-controls { font-size: 12px; line-height: 1.7; color: #777; text-wrap: balance; }
.pause-skip-panel, .pause-terminal-status { max-width: 100%; }
.pause-controls-panel { text-align: left; color: #d8d3df; font-size: 10px; line-height: 1.9; }
.pause-controls-panel h3 { margin: 20px 0 10px; color: #f8d43c; font-size: 12px; }
.pause-controls-panel h3:first-child { margin-top: 0; }
.pause-controls-panel p { margin: 8px 0 14px; color: #b9b0c4; }
.pause-bindings { margin: 0; }
.pause-bindings > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 12px; padding: 7px 0; border-bottom: 1px solid #302938; }
.pause-bindings dt, .pause-bindings dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.pause-bindings dt { color: #b9b0c4; }
.pause-bindings kbd { font: inherit; color: #f5f2f8; }
.pause-controls-panel .pause-controls-tip { padding-top: 14px; border-top: 1px solid #302938; }
.pause-controls-panel .completion-btn { width: 100%; min-height: 44px; margin-top: 6px; }

/* ── Admin Panel ─────────────────────────────────── */

.admin-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.admin-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.admin-overlay .admin-container {
  transform: scale(0.97) translateY(8px);
  transition: transform 0.2s ease;
}

.admin-overlay.open .admin-container {
  transform: scale(1) translateY(0);
}

.admin-container {
  background: #1a1b1b;
  border: 1px solid #2a2b2b;
  border-radius: 12px;
  width: 96vw;
  max-width: 1200px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #2a2b2b;
  flex-shrink: 0;
}

.admin-header h2 {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
  color: #d4d4d4;
  overflow-wrap: anywhere;
}

.admin-close {
  background: none;
  border: none;
  color: #666;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}

.admin-close:hover {
  color: #ccc;
  background: #2a2b2b;
}

.admin-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Set List ───────────────────────────────────── */

.set-list {
  width: 180px;
  border-right: 1px solid #2a2b2b;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: #181919;
}

.set-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #2a2b2b;
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: normal;
  flex-shrink: 0;
}

.set-list-head button {
  background: none;
  border: 1px solid #333;
  color: #4a9a8a;
  font-size: 11px;
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 4px;
  transition: background 0.15s;
}

.set-list-head button:hover {
  background: #2a2b2b;
}

.set-list-items {
  flex: 1;
  overflow-y: auto;
}

.set-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #888;
  border-bottom: 1px solid #1e1f1f;
  transition: background 0.1s, color 0.1s;
}

.set-item:hover {
  background: #1e2020;
  color: #bbb;
}

.set-item.active {
  background: #1e2222;
  color: #d4d4d4;
  border-left: 2px solid #4a9a8a;
  padding-left: 10px;
}

.set-item canvas {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  flex-shrink: 0;
  background: #141515;
}

.set-item span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-delete {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  color: #664444;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
  border-radius: 3px;
}

.set-item:hover .set-delete,
.set-delete:focus-visible { color: #cc7777; }
.set-item.dragging { opacity: 0.4; }
.set-item.drag-over { border-top: 2px solid #4a9a8a; }

.set-delete:hover {
  color: #cc4444;
  background: rgba(204, 68, 68, 0.1);
}

/* ── Tiles Panel ────────────────────────────────── */

.tiles-panel {
  width: 280px;
  border-right: 1px solid #2a2b2b;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: #181919;
}

.tiles-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid #2a2b2b;
  flex-shrink: 0;
}

.tiles-top.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.tiles-top input {
  flex: 1;
  min-width: 0;
  background: #1e2020;
  border: 1px solid #2a2d2d;
  border-radius: 5px;
  padding: 5px 10px;
  color: #d4d4d4;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}

.tiles-top input:focus {
  border-color: #4a9a8a;
}

.tiles-thumbs {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  padding: 10px;
}

.tile-thumb {
  width: 48px;
  height: 48px;
  border: 2px solid #2a2d2d;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #141515;
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.tile-thumb:hover { border-color: #555; }
.tile-thumb.selected { border-color: #4a9a8a; }
.tile-thumb.dragging { opacity: 0.3; }
.tile-thumb.drop-target { border-color: #4a9a8a; background: rgba(74,154,138,0.1); }

.tile-thumb canvas {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}

.tiles-empty {
  width: 100%;
  padding: 32px 16px;
  text-align: center;
  color: #444;
  font-size: 12px;
}

/* ── Edit Panel ─────────────────────────────────── */

.edit-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.edit-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid #2a2b2b;
  flex-shrink: 0;
}

#edit-label {
  font-size: 12px;
  color: #666;
}

.edit-actions {
  display: flex;
  gap: 4px;
}

@media (max-width: 1100px) {
  .edit-top { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
  .edit-actions { flex: 1 1 100%; flex-wrap: wrap; justify-content: flex-end; }
}

.edit-actions.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.edit-body {
  flex: 1;
  display: flex;
  gap: 20px;
  padding: 16px;
  align-items: flex-start;
  overflow-y: auto;
}

#pixel-canvas {
  image-rendering: pixelated;
  border: 1px solid #2a2d2d;
  cursor: crosshair;
  background: repeating-conic-gradient(#1a1a1a 0% 25%, #151515 0% 50%) 0 0 / 16px 16px;
  width: 256px;
  height: 256px;
  flex-shrink: 0;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.edit-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Tool Buttons ───────────────────────────────── */

.tool-btn {
  background: #1e2020;
  border: 1px solid #2a2d2d;
  color: #888;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.tool-btn:hover {
  background: #262828;
  color: #ccc;
}

.tool-btn:disabled {
  opacity: .42;
  cursor: default;
}

.tool-btn.danger {
  color: #885050;
  border-color: #3a2222;
}

.tool-btn.danger:hover {
  background: #2a1a1a;
  color: #aa6060;
}

#color-pick.active {
  background: #4a9a8a;
  color: #fff;
  border-color: #4a9a8a;
}

/* ── Color Tools ────────────────────────────────── */

.color-palette {
  display: grid;
  grid-template-columns: repeat(4, 24px);
  gap: 3px;
}

.color-swatch {
  appearance: none;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: 3px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.1s, transform 0.1s;
}

.color-swatch:hover { border-color: #666; transform: scale(1.1); }
.color-swatch.selected { border-color: #fff; transform: scale(1.1); }

.color-swatch.transparent-swatch {
  background: repeating-conic-gradient(#333 0% 25%, #222 0% 50%) 50% / 10px 10px;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-current {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  border: 1px solid #2a2d2d;
  flex-shrink: 0;
}

.color-hex {
  width: 76px;
  background: #1e2020;
  border: 1px solid #2a2d2d;
  border-radius: 4px;
  padding: 4px 6px;
  color: #d4d4d4;
  font-size: 11px;
  font-family: var(--mx-pixel);
  outline: none;
  transition: border-color 0.15s;
}

.color-hex:focus { border-color: #4a9a8a; }

/* ── Collider ───────────────────────────────────── */

.collider-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-label {
  font-size: 11px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: normal;
}

.collider-grid {
  display: grid;
  grid-template-columns: repeat(5, 36px);
  gap: 4px;
}

.collider-btn {
  width: 36px;
  height: 36px;
  background: #1e2020;
  border: 2px solid #2a2d2d;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
  padding: 0;
}

.collider-btn:hover { border-color: #555; background: #262828; }
.collider-btn.active { border-color: #4a9a8a; background: rgba(74,154,138,0.1); }
.collider-btn:disabled { opacity: 0.3; cursor: default; }

.collider-btn canvas {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
}

/* ── Scrollbar ───────────────────────────────────── */

.content::-webkit-scrollbar,
.set-list-items::-webkit-scrollbar,
.tiles-thumbs::-webkit-scrollbar,
.edit-body::-webkit-scrollbar {
  width: 5px;
}

.content::-webkit-scrollbar-track,
.set-list-items::-webkit-scrollbar-track,
.tiles-thumbs::-webkit-scrollbar-track,
.edit-body::-webkit-scrollbar-track {
  background: transparent;
}

.content::-webkit-scrollbar-thumb,
.set-list-items::-webkit-scrollbar-thumb,
.tiles-thumbs::-webkit-scrollbar-thumb,
.edit-body::-webkit-scrollbar-thumb {
  background: #2a2b2b;
  border-radius: 3px;
}

.content::-webkit-scrollbar-thumb:hover,
.set-list-items::-webkit-scrollbar-thumb:hover,
.tiles-thumbs::-webkit-scrollbar-thumb:hover,
.edit-body::-webkit-scrollbar-thumb:hover {
  background: #3a3b3b;
}

/* ── Background Selector ───────────────────────── */

.bg-selector-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.bg-selector-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.bg-selector-overlay .bg-selector-container {
  transform: scale(0.97) translateY(8px);
  transition: transform 0.2s ease;
}

.bg-selector-overlay.open .bg-selector-container {
  transform: scale(1) translateY(0);
}

.bg-selector-container {
  background: #1a1b1b;
  border: 1px solid #2a2b2b;
  border-radius: 12px;
  width: 90vw;
  max-width: 860px;
  height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bg-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #2a2b2b;
  flex-shrink: 0;
}

.bg-selector-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #d4d4d4;
}

.bg-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
  align-content: start;
}

.bg-option {
  cursor: pointer;
  border: 2px solid #2a2d2d;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #141515;
  transition: border-color 0.15s;
}

.bg-option:hover {
  border-color: #555;
}

.bg-option.selected {
  border-color: #4a9a8a;
}

.bg-option canvas {
  width: 100%;
  aspect-ratio: 16/9;
  display: block;
  background: #1a1a2e;
}

.bg-option-label {
  padding: 6px 10px;
  font-size: 11px;
  color: #888;
  text-align: center;
  border-top: 1px solid #2a2b2b;
}

.bg-option.selected .bg-option-label {
  color: #4a9a8a;
}

.bg-option-none {
  width: 100%;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #555;
  background: #111;
}

.bg-grid::-webkit-scrollbar {
  width: 5px;
}

.bg-picker-intro { flex-shrink: 0; margin: 0; padding: 12px 16px 0; color: #b8c9cd; font-size: 10px; line-height: 1.7; }
#bg-selector [hidden] { display: none !important; }
#bg-selector-close { min-width: 44px; min-height: 44px; }
.bg-combination { display: flex; align-items: center; gap: 16px; padding: 12px 16px; flex-shrink: 0; }
.bg-combination-art { width: 192px; max-width: 38%; flex-shrink: 0; }
.bg-combination-frame { position: relative; aspect-ratio: 16 / 9; background: #1a1a2e; border: 2px solid var(--mx-line); }
.bg-combination-frame canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
#bg-combination-empty { position: absolute; inset: 0; place-items: center; font-size: 9px; color: #a2b3b8; }
#bg-combination-empty:not([hidden]) { display: grid; }
.bg-combination-copy { min-width: 0; }
.bg-combination-copy h3 { margin: 0 0 10px; font-size: 10px; color: #dce9ec; }
.bg-combination-copy p { margin: 0; font-size: 10px; color: var(--mx-cyan); line-height: 1.8; overflow-wrap: anywhere; }
.bg-text-button { appearance: none; border: 0; border-radius: 0; background: transparent; color: #a9c6ce; font: inherit; font-size: 9px; min-height: 44px; padding: 8px 0; cursor: pointer; text-align: left; }
.bg-text-button:hover { color: var(--mx-cyan); }
.bg-text-button:disabled { opacity: .45; cursor: default; }
.bg-layer-tabs { display: flex; gap: 0; padding: 0 16px; border-bottom: 2px solid var(--mx-line); flex-shrink: 0; }
.bg-layer-tabs button { flex: 1; appearance: none; min-height: 48px; padding: 10px; border: 2px solid var(--mx-line); border-bottom: 0; border-radius: 0; background: #121d27; color: #a9bdc6; font: inherit; font-size: 11px; cursor: pointer; }
.bg-layer-tabs button + button { border-left: 0; }
.bg-layer-tabs button[aria-selected="true"] { color: var(--mx-cyan); background: #183340; box-shadow: inset 0 -3px 0 var(--mx-cyan); }
.bg-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.bg-gallery-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 4px 16px; flex-shrink: 0; min-height: 44px; }
.bg-gallery-heading p { margin: 0; color: #b8c9cd; font-size: 9px; line-height: 1.7; }
.bg-gallery-heading button { flex-shrink: 0; }
.bg-panel .bg-grid { min-height: 0; }
.bg-option:disabled { cursor: default; opacity: .5; }
.bg-option:disabled:hover { border-color: var(--mx-line); }
.bg-option canvas.bg-scene-preview,
.bg-option-none.bg-scene-preview {
  background-color: #1a2c36;
  background-image: linear-gradient(45deg, #233c47 25%, transparent 25%), linear-gradient(-45deg, #233c47 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #233c47 75%), linear-gradient(-45deg, transparent 75%, #233c47 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
@media (max-width: 480px) {
  .bg-combination { gap: 10px; padding: 10px 12px; }
  .bg-combination-copy h3 { margin-bottom: 5px; font-size: 9px; }
  .bg-combination-copy p { font-size: 9px; }
  .bg-layer-tabs { padding: 0 12px; }
  .bg-layer-tabs button { padding: 8px 5px; font-size: 10px; }
  .bg-gallery-heading { padding: 4px 12px; gap: 8px; }
}
@media (max-height: 560px) {
  #bg-selector .bg-selector-container { height: calc(100dvh - 18px); }
  .bg-picker-intro { display: none; }
  .bg-combination { padding-top: 6px; padding-bottom: 6px; }
  .bg-combination-art { width: 96px; }
  .bg-combination-copy { display: flex; align-items: center; gap: 14px; flex: 1; }
  .bg-combination-copy h3 { margin: 0; }
  .bg-combination-copy p { flex: 1; font-size: 9px; }
  .bg-layer-tabs button { min-height: 44px; }
}

.bg-grid::-webkit-scrollbar-track {
  background: transparent;
}

.bg-grid::-webkit-scrollbar-thumb {
  background: #2a2b2b;
  border-radius: 3px;
}

.bg-grid::-webkit-scrollbar-thumb:hover {
  background: #3a3b3b;
}

/* ── Properties Modal ────────────────────────── */

.props-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.props-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.props-overlay .props-container {
  transform: scale(0.97) translateY(8px);
  transition: transform 0.2s ease;
}

.props-overlay.open .props-container {
  transform: scale(1) translateY(0);
}

.props-container {
  background: #1a1b1b;
  border: 1px solid #2a2b2b;
  border-radius: 12px;
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.props-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #2a2b2b;
  flex-shrink: 0;
}

.props-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #d4d4d4;
}

.props-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.props-category {
  margin-bottom: 12px;
}

.props-cat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: normal;
  color: #555;
  margin-bottom: 6px;
  padding: 0 4px;
}

.props-row {
  background: #141515;
  border: 1px solid #222;
  border-radius: 8px;
  margin-bottom: 6px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.props-row.enabled {
  border-color: #2a4a42;
}

.props-row-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #aaa;
  user-select: none;
}

.props-row-header input[type="checkbox"] {
  accent-color: #4a9a8a;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.props-row.enabled .props-row-header span {
  color: #d4d4d4;
}

.props-fields {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.props-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.props-field > label {
  min-width: 80px;
  font-size: 12px;
  line-height: 1.3;
  color: #888;
  overflow-wrap: anywhere;
  white-space: normal;
}

.props-range {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.props-range input[type="range"] {
  flex: 1;
  accent-color: #4a9a8a;
  height: 4px;
}

.props-val {
  font-size: 12px;
  color: #4a9a8a;
  min-width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.props-field select {
  background: #1a1b1b;
  border: 1px solid #333;
  border-radius: 4px;
  color: #ccc;
  padding: 4px 8px;
  font-size: 12px;
  flex: 1;
}

.props-path-btn {
  margin-top: 4px;
  width: 100%;
  text-align: center;
}

/* ── Path Edit Bar ───────────────────────────── */

.path-edit-bar {
  display: flex;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1a1b1b;
  border: 1px solid #2a4a42;
  border-radius: 10px;
  padding: 10px 16px;
  z-index: 90;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.path-edit-bar.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.path-edit-bar > span {
  font-size: 12px;
  color: #888;
}

.path-edit-actions {
  display: flex;
  gap: 8px;
}

.path-done {
  background: #2a5a4a !important;
  color: #fff !important;
}

/* ── Collectables Modal ────────────────────────── */

.col-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.col-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.col-overlay .col-container {
  transform: scale(0.97) translateY(8px);
  transition: transform 0.2s ease;
}

.col-overlay.open .col-container {
  transform: scale(1) translateY(0);
}

.col-container {
  background: #1a1b1b;
  border: 1px solid #2a2b2b;
  border-radius: 12px;
  width: 96vw;
  max-width: 720px;
  height: 80vh;
  max-height: 540px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.col-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid #2a2b2b;
  flex-shrink: 0;
}

.col-header h2 {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
  color: #d4d4d4;
  flex: 1;
  overflow-wrap: anywhere;
}

.shared-library-note {
  display: block;
  margin-top: 5px;
  color: var(--mx-muted, #777078);
  font-family: var(--mx-mono, monospace);
  font-size: 7px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: normal;
  text-transform: uppercase;
}

.col-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.col-list-panel {
  width: 180px;
  border-right: 1px solid #2a2b2b;
  overflow-y: auto;
  flex-shrink: 0;
}

.col-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #222;
  transition: background 0.15s;
}

button.col-item {
  appearance: none;
  width: 100%;
  border-width: 0 0 1px;
  border-style: solid;
  border-color: #222;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.col-item-select {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.col-item:hover {
  background: #222;
}

.col-item.active {
  background: #1a2a25;
  border-left: 3px solid #ffd700;
}

.col-item canvas {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.col-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.col-item-name {
  font-size: 12px;
  color: #ccc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-item-val {
  font-size: 10px;
  color: #666;
}

.col-edit-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  /* flex-start (not center) on the scroll axis: centering tall content in an
     overflow-y:auto flex column clips the top, making it unreachable by scroll */
  align-items: flex-start;
  justify-content: center;
}

.col-empty {
  font-size: 13px;
  color: #555;
  text-align: center;
  padding: 40px;
}

.col-edit-left {
  flex-shrink: 0;
  padding: 16px;
  display: flex;
  align-items: flex-start;
}

.col-pixel-canvas {
  width: 224px;
  height: 224px;
  image-rendering: pixelated;
  cursor: crosshair;
  border: 1px solid #2a2b2b;
  border-radius: 4px;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.col-edit-right {
  flex: 1;
  padding: 16px 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.col-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.col-field > label {
  font-size: 12px;
  color: #888;
  width: 50px;
  flex-shrink: 0;
}

.col-field > input[type="text"],
.col-field > input[type="number"] {
  flex: 1;
  background: #141515;
  border: 1px solid #333;
  border-radius: 4px;
  color: #ccc;
  padding: 5px 8px;
  font-size: 12px;
}

.col-field > input[type="color"] {
  width: 32px;
  height: 28px;
  padding: 0;
  border: 1px solid #333;
  border-radius: 4px;
  background: none;
  cursor: pointer;
}

.col-tools {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.col-tools .tool-btn[aria-pressed="true"] {
  color: var(--mx-ink, #09070b);
  border-color: var(--mx-acid, #f8cf3d);
  background: var(--mx-acid, #f8cf3d);
}

@media (pointer: coarse) {
  .color-palette { grid-template-columns: repeat(4, 44px); gap: 5px; }
  .color-swatch { width: 44px; height: 44px; }
  .collider-grid { grid-template-columns: repeat(5, 44px); gap: 5px; }
  .collider-btn { width: 44px; height: 44px; }
  .admin-container .tool-btn,
  .col-container .tool-btn { min-height: 44px; }
  .col-field > input[type="color"] { width: 44px; height: 44px; }
}

/* ── Palette Collectables ──────────────────────── */

.collectable-tile {
  position: relative;
}

.collectable-tile.selected {
  border-color: #ffd700;
}

/* ── Save Toast ──────────────────────────────────── */

.save-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e2a26;
  border: 1px solid #2a4a42;
  color: #4a9a8a;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 8px;
  z-index: 300;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.save-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.save-toast.error {
  background: #7d2424;
  color: #fff;
  max-width: min(520px, calc(100vw - 32px));
  white-space: normal;
  text-align: center;
}

/* Player-facing online action status. Errors stay until replaced/dismissed by a
   later action; short success/info messages are removed by operator-client.js. */
.app-status {
  position: fixed;
  top: max(18px, env(safe-area-inset-top, 0px));
  right: 18px;
  z-index: 1000;
  width: min(380px, calc(100vw - 36px));
  padding: 11px 14px;
  border: 1px solid #3a4a46;
  border-radius: 9px;
  background: rgba(24, 29, 28, 0.97);
  color: #d8e2df;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.app-status.show { opacity: 1; transform: translateY(0); }
.app-status.success { border-color: #3c765f; color: #8ce0b2; }
.app-status.warning { border-color: #795e2c; color: #ffd083; }
.app-status.error { border-color: #743f45; color: #ff9ba4; }

/* Teaching toast for blocked placements — bottom-centre, amber, non-blocking */
.editor-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 8px);
  max-width: 360px;
  background: #2a2418;
  border: 1px solid #5a4a22;
  color: #f5c85a;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  padding: 10px 18px;
  border-radius: 8px;
  z-index: 320;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
}
.editor-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── Tile Palette Scroll Fade ────────────────────── */

.tile-palette {
  -webkit-mask-image: linear-gradient(to right, black 0%, black calc(100% - 32px), transparent 100%);
  mask-image: linear-gradient(to right, black 0%, black calc(100% - 32px), transparent 100%);
}

.tile-palette.scrolled-start {
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 32px, black calc(100% - 32px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 32px, black calc(100% - 32px), transparent 100%);
}

.tile-palette.scrolled-end {
  -webkit-mask-image: none;
  mask-image: none;
}

.tile-palette.scrolled-start.scrolled-end {
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 32px, black 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 32px, black 100%);
}

/* ── Canvas Cursors ──────────────────────────────── */

.grid-wrapper canvas.cursor-paint {
  cursor: crosshair;
}

.grid-wrapper canvas.cursor-erase {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23ccc' stroke-width='2'%3E%3Cpath d='M20 20H7L3 16l9-9 8 8-4 4z'/%3E%3C/svg%3E") 10 10, crosshair;
}

.grid-wrapper canvas.cursor-spawn {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23e8a84c' stroke-width='2'%3E%3Cpath d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z'/%3E%3Ccircle cx='12' cy='9' r='2.5'/%3E%3C/svg%3E") 10 2, crosshair;
}

.grid-wrapper canvas.cursor-collectable {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23ffd700' stroke-width='2'%3E%3Cpolygon points='12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26'/%3E%3C/svg%3E") 9 9, crosshair;
}

.grid-wrapper canvas.cursor-goal {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%234caf50' stroke-width='2'%3E%3Cpath d='M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z'/%3E%3Cline x1='4' y1='22' x2='4' y2='15'/%3E%3C/svg%3E") 4 2, crosshair;
}

.grid-wrapper canvas.cursor-move {
  cursor: grab;
}
/* while actively dragging an item (mouse button held), show the closed hand */
.grid-wrapper canvas.cursor-move:active {
  cursor: grabbing;
}


/* ── Palette tile labels (enemies / collectables) ── */
.palette-tile.labeled {
  width: auto;
  min-width: 44px;
  height: auto;
  flex-direction: column;
  padding: 4px 6px 3px;
  gap: 2px;
}
.palette-tile.labeled canvas {
  width: 28px;
  height: 28px;
}
.tile-label {
  font-size: 9px;
  color: #9a9a9a;
  max-width: 60px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}
.palette-tile.labeled.selected .tile-label {
  color: #cfeae3;
}

/* ── Enemies modal extras (reuses col-* styles) ── */
.enemies-help {
  font-size: 11px;
  color: #8a8f93;
  padding: 8px 20px;
  border-bottom: 1px solid #2a2b2b;
  flex-shrink: 0;
}
.col-field > select {
  flex: 1;
  background: #141515;
  border: 1px solid #333;
  border-radius: 4px;
  color: #ccc;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}
.col-field-check > input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #4a9a8a;
  cursor: pointer;
}
.enemy-tile.selected {
  border-color: #e84a5a;
}

/* ── Enemies tuning panel ── */
.enemy-preview-wrap {
  flex-shrink: 0;
  padding: 16px;
  display: flex;
  align-items: flex-start;
}
.enemy-preview {
  width: 200px;
  height: 200px;
  background: #141515;
  border: 1px solid #2a2b2b;
  border-radius: 6px;
}
.enemy-tuner-title {
  font-size: 15px;
  font-weight: 600;
  color: #e0e0e0;
}
.enemy-tuner-desc {
  font-size: 11px;
  color: #8a8f93;
  margin-bottom: 6px;
}
#enemies-edit .col-field > label {
  width: 96px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}
.enemy-slider {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.enemy-slider input[type="range"] {
  min-width: 0;
  flex: 1;
  accent-color: #4a9a8a;
  cursor: pointer;
}
.enemy-slider-val {
  font-size: 11px;
  color: #ccc;
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Sidebar: icon-only tool rail (labels hidden, title = tooltip) ── */
.sidebar {
  width: 56px;
  justify-content: flex-start;
  gap: 8px;
}
.sidebar-logo {
  color: #4a9a8a;
  display: flex;
  justify-content: center;
  padding: 4px 0 6px;
}
.sidebar-tools {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.sidebar-icon {
  width: 40px;
  height: 40px;
  flex-direction: row;   /* override the old icon+label column layout */
  gap: 0;
  padding: 0;
}
.sidebar-label { display: none; }   /* icon-only — the button's title attr is the tooltip */
.sidebar-icon.active { color: #4a9a8a; background: #2a2b2b; }

/* ── Header toolbar: icon-only buttons (labels hidden, title = tooltip) ── */
.hb-label { display: none; }
.header-btn { padding: 9px; }
.header-btn svg { width: 16px; height: 16px; display: block; }
.header-btn.icon-only { padding: 9px; }
/* Home button: brand-tinted so it reads as nav, not an edit tool */
.home-btn { color: #4a9a8a; border-color: #2f5d54; }
.home-btn:hover { color: #5fb5a3; background: #223330; }
.header-btn:disabled { opacity: 0.32; cursor: default; }
.header-btn:disabled:hover { background: none; }

/* ── Mobile: drop the title, give fingers room, let the toolbar wrap ── */
.ranking-card.ranking-level .ranking-stats {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.ranking-card.ranking-level .ranking-stat { grid-column: span 2; }
.ranking-card.ranking-level .ranking-stat:nth-last-child(-n + 2) { grid-column: span 3; }

@media (max-width: 680px) {
  .title { display: none; }
  .header { gap: 6px; }
  .header-actions { gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
  .header-btn { padding: 12px; }       /* ~40px tap target */
  .sidebar { width: 52px; }
  .sidebar-icon { width: 42px; height: 42px; }

  /* Palette: bigger tap targets for fingers (≥44px) */
  .palette-tile { width: 46px; height: 46px; }
  .palette-tile canvas { width: 36px; height: 36px; }
  .tile-palette { gap: 8px; padding: 10px 14px; }

  /* Tile Set editor: stack columns vertically */
  .admin-body { flex-direction: column; overflow: auto; }
  .set-list, .tiles-panel { width: 100%; flex-shrink: 1; border-right: none; }

  /* Collectables/Enemies editor: stack columns vertically */
  .col-body { flex-direction: column; overflow: auto; }
  .col-list-panel { width: 100%; flex-shrink: 1; border-right: none; }
  .col-pixel-canvas { max-width: 100%; }
}

/* ── Empty-level hint ── */
.grid-wrapper { position: relative; }
.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.empty-hint.hidden { display: none; }
.empty-hint-card {
  background: rgba(20, 21, 21, 0.84);
  border: 1px solid #2a2b2b;
  border-radius: 12px;
  padding: 18px 22px;
  color: #cfcfcf;
  font-size: 13px;
  max-width: 340px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}
.empty-hint-card strong { color: #fff; }
.empty-hint-card ol {
  margin: 10px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #a8a8a8;
}
.eh-spawn { color: #e8a84c; font-weight: 600; }
.eh-goal { color: #4caf50; font-weight: 600; }
.eh-select { color: #4a9a8a; font-weight: 600; }

/* ── Behaviors discovery callout ── */
.side-callout {
  position: fixed;
  transform: translateY(-50%);
  max-width: 200px;
  background: #1e2a26;
  border: 1px solid #2a4a42;
  color: #cfeae3;
  font-size: 11.5px;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.side-callout.show { opacity: 1; }
.side-callout::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #1e2a26;
}
.side-callout strong { color: #7fd8c4; }

@keyframes propsPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 154, 138, 0); }
  50% { box-shadow: 0 0 0 4px rgba(74, 154, 138, 0.3); }
}
#props-btn.active { color: #4a9a8a; animation: propsPulse 1.6s ease-in-out 3; }

/* ── Completion rewards (operator GOO + loot) ── */
.completion-progress {
  max-width: 360px;
  margin: 0 auto 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
}
.completion-progress:empty { display: none; }
.completion-progress.is-new { border-color: rgba(127,214,160,.5); background: rgba(74,154,138,.13); }
.completion-progress.is-unchanged { border-color: rgba(255,255,255,.16); }
.cp-result { color: #7fd6a0; font-size: 15px; font-weight: 800; }
.is-unchanged .cp-result { color: #d4d4d4; }
.cp-total { margin-top: 3px; color: #f4f0e8; font-size: 12px; font-weight: 700; }
.cp-reason, .cp-next { margin-top: 4px; color: #9aacaa; font-size: 11px; line-height: 1.35; }
.cp-milestone { margin-top: 5px; color: #ffd86b; font-size: 12px; font-weight: 800; }
.completion-next-status { min-height: 17px; margin: 2px auto 8px; color: #9aacaa; font-size: 11px; line-height: 1.35; }
.completion-next-status:empty { min-height: 0; margin: 0; }
.completion-next-status.ok { color: #7fd6a0; }
.completion-next-status.error { color: #ff8a8a; }
.completion-btn-next { border-color: #4a9a8a; color: #7fd6a0; }
.completion-btn:disabled { cursor: not-allowed; opacity: .62; transform: none; }
.completion-rewards {
  margin: 6px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.cr-goo { font-size: 15px; color: #ffd86b; font-weight: 600; }
.cr-goo .cr-bal { color: #9a9a9a; font-size: 12px; font-weight: 400; }
.cr-drop {
  font-size: 14px;
  color: #ff9ad0;
  font-weight: 700;
  animation: crPop 0.4s ease;
}
.cr-loading { font-size: 12px; color: #777; }
.cr-warning { margin-top: 6px; font-size: 11px; line-height: 1.35; color: #ffb86b; }
.cr-error { margin-top: 6px; max-width: 340px; font-size: 12px; line-height: 1.4; color: #ff8a8a; }
@keyframes crPop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }

/* ── Custom hover tooltips (tooltips.js) ── */
.ui-tip {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  max-width: 220px;
  background: #0c0d0d;
  color: #e8e8e8;
  border: 1px solid #383838;
  font-size: 11px;
  line-height: 1.35;
  padding: 5px 8px;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.45);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.ui-tip.below { transform: translateY(3px); }
.ui-tip.visible { opacity: 1; transform: translateY(0); }

/* ── Level Length modal ── */
.length-container { max-width: 440px; width: 92%; }
.length-body { padding: 20px; }
.length-readout {
  font-size: 14px; line-height: 1.4; font-weight: 600; color: #fff; text-align: center; margin-bottom: 14px;
}
#length-slider, #height-slider { width: 100%; accent-color: #ff8a9a; cursor: pointer; }
.length-scale { display: flex; justify-content: space-between; font-size: 11px; color: #888; margin-top: 4px; }
.length-hint { font-size: 12px; color: #9aa0b4; margin: 14px 0 0; line-height: 1.4; }
.length-apply {
  margin-top: 16px; width: 100%; background: #ff8a9a; color: #2a0a14;
  border: none; border-radius: 8px; padding: 10px; font-weight: 700; cursor: pointer;
}
.length-apply:hover { background: #ffa0ad; }

/* ── GOO balance chip (header) ── */
.goo-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #e8c84a;
  background: rgba(232, 200, 74, 0.10);
  border: 1px solid rgba(232, 200, 74, 0.28);
  border-radius: 7px;
  padding: 5px 10px;
  white-space: nowrap;
}
.goo-chip[hidden] { display: none; }

/* ─────────────────────────────────────────────────────────────────────
   Lobby / main menu  (pixel-art styled; art tagged data-art="" is a
   placeholder meant to be swapped for real pixel art later)
   ───────────────────────────────────────────────────────────────────── */
.lobby {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #21242b 0%, #161718 55%, #121313 100%);
  color: #d4d4d4;
  opacity: 1; transition: opacity .25s ease;
}
.lobby.hidden { opacity: 0; pointer-events: none; visibility: hidden; }
/* A project reload goes directly to its destination, including on a cold load
   while the larger deferred Builder scripts are still arriving. */
html[data-reload-view] .lobby {
  opacity: 0; pointer-events: none; visibility: hidden; transition: none;
}
.lobby-sky, .px-cloud, .lobby-ground { display: none; }   /* pixel decoration removed — clean builder style */

/* top-right player HUD */
.lobby-topbar {
  position: absolute; top: 0; right: 0; z-index: 3; padding: 14px 16px;
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
}
.wallet-wrap { position: relative; flex: 0 0 auto; }
.wallet-btn {
  inline-size: 62px; block-size: 62px; min-inline-size: 62px; min-block-size: 62px;
  display: grid; place-items: center; gap: 0; overflow: hidden;
  font-size: 13px; color: #ccc; cursor: pointer;
  padding: 0; background: #1e2020; border: 1px solid #333; border-radius: 3px;
  transition: background .15s, color .15s, border-color .15s;
}
.wallet-btn:hover { background: #2a2b2b; color: #fff; border-color: #555; }
.wallet-btn.connected { padding: 0; }
.wallet-btn:disabled { opacity: .6; cursor: default; }
.wallet-ico {
  width: 100%; height: 100%; display: grid; place-items: center;
}
.wallet-ico svg { width: 29px; height: 29px; }

/* center: logo + menu */
.lobby-center { position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 24px; }
.lobby-logo { text-align: center; }
.lobby-logo-art { display: inline-block; image-rendering: pixelated; animation: lobby-bob 3s ease-in-out infinite; }
.lobby-logo-art svg { image-rendering: pixelated; width: 84px; height: 84px; }
@keyframes lobby-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.lobby-title { font-size: clamp(30px, 7vw, 48px); font-weight: 700; letter-spacing: normal; color: #fff; margin: 14px 0 6px; }
.lobby-tagline { font-size: 13px; color: #7a8a87; letter-spacing: normal; }

.lobby-menu { display: flex; flex-direction: column; gap: 12px; width: min(360px, 88vw); }
.menu-btn {
  display: flex; align-items: center; gap: 14px; width: 100%;
  color: #e8e8e8; text-align: left; cursor: pointer;
  padding: 14px 16px; background: #1e2020; border: 1px solid #333; border-radius: 10px;
  transition: background .15s, border-color .15s, transform .05s;
}
.menu-btn:hover { background: #262828; border-color: #4a9a8a; }
.menu-btn:active { transform: scale(.99); }
.menu-ico { display: flex; width: 40px; height: 40px; align-items: center; justify-content: center; flex: 0 0 auto; border-radius: 9px; background: rgba(255,255,255,.06); color: #cfcfcf; }
.menu-textwrap { display: flex; flex-direction: column; gap: 3px; }
.menu-text { font-size: 16px; font-weight: 600; }
.menu-sub { font-size: 12px; color: #8a8a8a; }
.menu-play .menu-ico { background: rgba(74,154,138,.18); color: #6fd3bf; }
.menu-build .menu-ico { background: rgba(120,90,180,.18); color: #b69ae0; }

.lobby-footer { position: absolute; left: 0; bottom: 0; z-index: 3; padding: 14px 18px; display: flex; gap: 14px; align-items: center; font-size: 12px; color: #5f6663; }
.lobby-goo { background: #1e2020; border: 1px solid #2a2b2b; border-radius: 7px; padding: 5px 10px; color: #9aacaa; }
.lobby-goo[hidden] { display: none; }
.lobby-ver { opacity: .8; }

/* sidebar logo doubles as a home button */
.sidebar-logo { cursor: pointer; }

/* ── Settings modal (reuses .col-overlay / .col-container) ── */
.settings-container { max-width: 460px; height: auto; max-height: 80vh; }
.settings-body { padding: 16px 22px 24px; display: flex; flex-direction: column; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid #1e2222; }
#title-music-volume { flex: 1; min-width: 48px; width: 100px; max-width: 180px; accent-color: #c1e94d; }
#title-music-volume-value { min-width: 4ch; font-size: 10px; text-align: right; }
.settings-row:last-child { border-bottom: none; }
.settings-key { font-size: 13px; color: #e8e8e8; }
.settings-hint { font-size: 12px; color: #8a9a96; text-align: right; }
.toggle { position: relative; width: 50px; height: 26px; background: #333; border: 2px solid #11201d; cursor: pointer; padding: 0; flex: 0 0 auto; }
.toggle .toggle-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #888; transition: left .12s, background .12s; }
.toggle.on { background: #2f7d70; }
.toggle.on .toggle-knob { left: 26px; background: #cdebe4; }

/* ── Login modal (Blockmaker: Email / Pera / Lute) ── */
.login-overlay { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.62); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.login-overlay.open { opacity: 1; pointer-events: auto; }
.login-card { position: relative; width: 92vw; max-width: 360px; background: #1a1b1b; border: 1px solid #2a2b2b; border-radius: 14px; padding: 24px 24px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.5); transform: scale(.97); transition: transform .2s ease; }
.login-overlay.open .login-card { transform: scale(1); }
.login-close { position: absolute; top: 8px; right: 12px; background: none; border: none; color: #888; font-size: 26px; line-height: 1; cursor: pointer; }
.login-close:hover { color: #ccc; }
.login-title { font-size: 20px; color: #e8e8e8; margin-bottom: 14px; text-align: center; }
.login-sub { font-size: 13px; color: #9aacaa; margin-bottom: 14px; text-align: center; line-height: 1.5; }
.login-view { display: flex; flex-direction: column; gap: 10px; }
.login-view[hidden] { display: none; }   /* display:flex above would otherwise defeat [hidden] */
.login-method { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; font-size: 14px; color: #e8e8e8; background: #232525; border: 1px solid #333; border-radius: 10px; cursor: pointer; transition: background .15s, border-color .15s; text-align: left; }
.login-method:hover { background: #2c2f2f; border-color: #4a9a8a; }
.lm-ico { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: 0 0 auto; border-radius: 7px; background: rgba(255, 255, 255, 0.06); color: #e8e8e8; }
.lm-ico svg { display: block; }
.lm-logo { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 7px; object-fit: cover; border: 1px solid rgba(255,255,255,.14); display: block; }
.login-label { display: block; font-size: 13px; color: #b9ccc8; margin: 4px 0 6px; line-height: 1.5; }
.login-input { width: 100%; padding: 12px; font-size: 15px; color: #fff; background: #141515; border: 1px solid #333; border-radius: 9px; margin-bottom: 12px; }
.login-input:focus { outline: none; border-color: #4a9a8a; }
.login-primary { display: block; width: 100%; text-align: center; padding: 12px; font-size: 14px; font-weight: 600; color: #0e1a17; background: #4a9a8a; border: none; border-radius: 9px; cursor: pointer; text-decoration: none; }
.login-primary:hover { background: #5fb5a3; }
.login-primary:disabled, .login-method:disabled, .login-link:disabled, .login-input:disabled {
  cursor: wait;
  opacity: 0.55;
}
.login-link { background: none; border: none; color: #7fbfb0; font-size: 12px; cursor: pointer; margin-top: 6px; }
.login-back { align-self: flex-start; background: none; border: none; color: #888; font-size: 13px; cursor: pointer; padding: 0 0 8px; }
.login-back:hover { color: #ccc; }
.login-status { min-height: 18px; margin-top: 12px; font-size: 12px; color: #9aacaa; text-align: center; line-height: 1.5; }
.login-status:empty { display: none; }   /* no reserved empty space when there's no message */
.login-status.err { color: #ff8a8a; }
.login-status.ok { color: #7fd6a0; }

/* ── Player profile slot ── */
.wallet-avatar { display: block; width: 100%; height: 100%; border-radius: 1px; object-fit: cover; image-rendering: pixelated; }
.wallet-avatar[hidden], .wallet-ico[hidden] { display: none; }
.wallet-btn.connected { padding: 0; }
/* ── Builder header account button (fits the toolbar, not the lobby) ── */
.builder-avatar { width: 18px; height: 18px; border-radius: 5px; object-fit: cover; image-rendering: pixelated; }
.builder-avatar[hidden] { display: none; }   /* don't let other display rules defeat [hidden] */

/* ── Profile modal (reuses .login-overlay / .login-card) ── */
.profile-card { max-width: 340px; text-align: center; }
/* A profile can grow when rewards or username setup are present. Keep the
   first controls reachable in short landscape windows instead of centering a
   taller card above the viewport, and give the nested picture picker the same
   single, touch-friendly scroll boundary. Auto block margins still center a
   card whenever there is enough height. */
#profile-modal,
#pfp-modal {
  align-items: flex-start;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding:
    max(12px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
}
#profile-modal > .profile-card,
#pfp-modal > .pfp-card {
  flex: 0 0 auto;
  margin-block: auto;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - max(12px, env(safe-area-inset-top, 0px)) - max(12px, env(safe-area-inset-bottom, 0px)));
  overflow-y: auto;
  overscroll-behavior: contain;
}
#profile-modal > .profile-card { max-width: 340px; }
#pfp-modal > .pfp-card { max-width: 420px; }
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 4px 0 18px; }
.profile-avatar { width: 72px; height: 72px; border-radius: 16px; object-fit: cover; image-rendering: pixelated; border: 2px solid #2a2b2b; background: #141515; }
.profile-name { font-size: 18px; color: #fff; font-weight: 600; }
.profile-sub { max-width: 100%; min-width: 0; min-height: 14px; overflow-wrap: anywhere; font-size: 12px; color: #8a9a96; }
.profile-rows { display: flex; flex-direction: column; margin-bottom: 16px; text-align: left; }
.profile-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 2px; border-bottom: 1px solid #1e2222; font-size: 13px; align-items: baseline; }
.profile-row:last-child { border-bottom: none; }
.profile-row > span:first-child { color: #8a9a96; flex: 0 0 auto; }
.profile-addr { font-family: var(--mx-pixel); font-size: 11px; color: #9fe6da; word-break: break-all; text-align: right; }
.profile-logout { background: none; border: 1px solid #5a2e2e; color: #ff9b9b; }
.profile-logout:hover { background: rgba(204,68,68,0.12); color: #ffb0b0; }

/* ── Set-username panel (profile modal) ── */
.uname-panel { text-align: left; margin: 2px 0 16px; padding-top: 14px; border-top: 1px solid #1e2222; }
.uname-status.ok { color: #7fd6a0; }

/* Reward allowance, claim approval and history in the profile. */
.rewards-browser { width: min(640px, calc(100vw - 24px)); }
.rewards-notice { padding: 12px; border: 1px solid #507f4a; border-radius: 8px; background: #1d2b22; }
.rewards-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.rewards-total { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid #51465e; border-radius: 8px; }
.rewards-total strong { color: #8ce65b; font-size: 22px; }
.rewards-total:last-child strong { color: #f3c75d; }
.rewards-notice:empty, .rewards-browser .community-status:empty { display: none; }
.rewards-allowance, .rewards-claim { grid-column: 1 / -1; min-width: 0; line-height: 1.65; }
.rewards-claim { padding: 16px; border: 1px solid #8ce65b; background: #16231d; }
.rewards-total strong { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .rewards-total { padding: 12px; }
  .rewards-total strong { font-size: 17px; }
}
.rewards-list .rewards-round { display: block; padding: 14px; }
.rewards-payment { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.rewards-help { color: #c7bfd3; font-size: 12px; line-height: 1.7; }
.rewards-browser button { min-width: 44px; min-height: 44px; }
@media (max-width: 480px), (max-height: 440px) {
  .rewards-browser > .community-actions { position: sticky; bottom: 0; z-index: 1; padding-block: 12px; background: #181424; border-top: 1px solid #51465e; }
}
/* ── Change-picture control (profile modal avatar → button) ── */
.profile-avatar-btn { position: relative; padding: 0; border: none; background: none; cursor: pointer; line-height: 0; border-radius: 16px; }
.profile-avatar-btn .profile-avatar { display: block; }
.profile-avatar-edit { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 0; font-size: 10px; font-weight: 600; color: #cfe; background: rgba(0,0,0,.62); border-radius: 0 0 16px 16px; opacity: 0; transition: opacity .15s ease; }
.profile-avatar-btn:hover .profile-avatar-edit, .profile-avatar-btn:focus-visible .profile-avatar-edit { opacity: 1; }

/* ── Creator-rewards claim section (profile modal) ── */
.profile-claim { text-align: left; margin: 2px 0 16px; padding-top: 14px; border-top: 1px solid #1e2222; }
.profile-claim[hidden] { display: none; }
.profile-claim-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-size: 13px; color: #8a9a96; }
.profile-claim-amt { color: #9fe6da; font-weight: 600; }

/* ── Profile-picture picker modal ── */
.pfp-card { max-width: 420px; text-align: center; }
.pfp-title { font-size: 18px; color: #fff; font-weight: 600; margin: 2px 0 14px; }
.pfp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; max-height: 50vh; overflow: auto; padding: 2px; }
.pfp-empty { grid-column: 1 / -1; padding: 28px 0; font-size: 13px; color: #8a9a96; }
.pfp-tile { position: relative; aspect-ratio: 1; padding: 0; border: 2px solid #2a2b2b; border-radius: 10px; background: #141515; cursor: pointer; overflow: hidden; }
.pfp-tile img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; display: block; }
.pfp-tile.selected { border-color: #4a9a8a; box-shadow: 0 0 0 2px rgba(74,154,138,.4); }
.pfp-tile-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px; font-size: 9px; color: #cfe; background: rgba(0,0,0,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pfp-actions { display: flex; gap: 10px; margin-top: 14px; }
.pfp-actions .login-primary, .pfp-actions .login-secondary { flex: 1; }
.login-secondary { display: block; width: 100%; text-align: center; padding: 12px; font-size: 14px; font-weight: 600; color: #cdd; background: none; border: 1px solid #333; border-radius: 9px; cursor: pointer; }
.login-secondary:hover { border-color: #555; color: #fff; }

/* ======================================================================
   MONSTRS / AFTER DARK
   A dark editorial pixel-poster system shared by the lobby, builder and
   game UI. These overrides intentionally sit at the end of the legacy skin
   so the editor's proven layout and interaction code remain unchanged.
   ====================================================================== */

:root {
  color-scheme: dark;
  --mx-ink: #09080d;
  --mx-ink-2: #0e0b12;
  --mx-panel: #151119;
  --mx-header: #100d14;
  --mx-panel-2: #1d1722;
  --mx-line: #3b3042;
  --mx-paper: #f5f2ea;
  --mx-muted: #b2aaba;
  --mx-purple: #b2549e;
  --mx-purple-deep: #5a2e68;
  --mx-acid: #f8cf3d;
  --mx-cyan: #38c9e7;
  --mx-green: #55d34a;
  --mx-coral: #ff5750;
  --mx-pink: #ed0f7d;
  --mx-pixel: "Press Start 2P", ui-monospace, monospace;
  --mx-display: var(--mx-pixel);
  --mx-ui: var(--mx-pixel);
  --mx-mono: var(--mx-pixel);
  --mx-hard-shadow: none;
}

html { background: var(--mx-ink); }

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--mx-ui);
  font-synthesis: none;
  background: var(--mx-ink);
  color: var(--mx-paper);
  text-rendering: geometricPrecision;
}

button,
input,
select,
textarea { font: inherit; }

::selection { color: var(--mx-ink); background: var(--mx-acid); }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Focus restoration keeps keyboard/screen-reader navigation working without
   drawing an unsolicited outer selector. This applies to mouse, pen and touch. */
:focus { outline: none !important; }

/* A small inner underline is enough to locate controls during deliberate Tab
   navigation. Unrelated keys and automatic focus transfers do not enable it. */
html[data-input-modality="keyboard"] :where(button, [role="button"], input, select, textarea, label[for], summary, a[href]):focus-visible {
  box-shadow: inset 0 -2px 0 var(--mx-cyan) !important;
}

/* ── Builder shell ───────────────────────────────────────────────────── */

.app { min-height: 100vh; min-height: 100dvh; background: var(--mx-ink); }

.sidebar {
  width: 58px;
  padding: 9px 0;
  gap: 10px;
  background:
    linear-gradient(rgba(178, 84, 158, .04), rgba(178, 84, 158, 0) 42%),
    var(--mx-ink-2);
  border-right: 2px solid var(--mx-line);
}

.sidebar-logo {
  appearance: none;
  width: 42px;
  height: 48px;
  margin: 0 auto;
  padding: 3px;
  border: 1px solid var(--mx-line);
  border-radius: 3px;
  background: var(--mx-panel);
  color: var(--mx-paper);
  box-shadow: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease;
}

.sidebar-logo:hover {
  transform: none;
  border-color: var(--mx-acid);
  box-shadow: none;
}

.sidebar-logo img {
  width: 38px;
  height: 38px;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
}

.sidebar-tools { gap: 7px; }

.sidebar-icon {
  width: 42px;
  height: 42px;
  border: 1px solid #29212f;
  border-radius: 3px;
  background: #110e15;
  color: #aaa3b1;
  transition: color .12s ease, background .12s ease, border-color .12s ease, transform .12s ease;
}

.sidebar-icon:hover {
  color: var(--mx-paper);
  background: var(--mx-panel-2);
  border-color: var(--mx-purple);
  transform: translateX(2px);
}

.sidebar-icon.active,
#props-btn.active {
  color: var(--mx-ink);
  background: var(--mx-acid);
  border-color: var(--mx-acid);
  box-shadow: none;
}

.main { background: var(--mx-ink); }

.header {
  position: relative;
  min-height: 58px;
  padding: 9px 14px;
  gap: 9px;
  background: rgba(14, 11, 18, .98);
  border-bottom: 2px solid var(--mx-line);
}

.title {
  display: flex;
  align-items: center;
  min-width: max-content;
  color: var(--mx-paper);
}

/* The generated artwork has a narrow internal dark edge on very wide screens.
   A tiny desktop-only zoom crops it away; mobile keeps its proven cover crop. */
@media (min-width: 1101px) and (min-aspect-ratio: 7/4) {
  .lobby { background-size: 102% auto; }
}

.builder-title {
  font-family: var(--mx-mono);
  font-size: 11px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: normal;
  color: var(--mx-purple);
  white-space: nowrap;
}

.header-actions {
  flex-wrap: nowrap;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  /* Older Safari keeps the safe, reachable fallback. Browsers that support
     overflow alignment right-align when everything fits and fall back to the
     start edge when this rail needs horizontal scrolling. */
  justify-content: flex-start;
  justify-content: safe flex-end;
  padding: 3px;
}

.header-primary-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px;
}

.header-btn,
.header-btn.icon-only {
  min-width: 38px;
  min-height: 38px;
  padding: 9px;
  flex: 0 0 auto;
  border: 1px solid var(--mx-line);
  border-radius: 3px;
  background: var(--mx-panel);
  color: var(--mx-muted);
  transition: transform .12s ease, border-color .12s ease, background .12s ease, color .12s ease;
}

.header-btn:hover {
  color: var(--mx-paper);
  background: var(--mx-panel-2);
  border-color: var(--mx-purple);
  transform: translateY(-2px);
}

.header-btn:active { transform: translateY(1px); }

#grid-toggle-btn[aria-pressed="true"] {
  color: var(--mx-cyan);
  border-color: #326779;
  background: #111c22;
}

.grid-toggle-slash { display: none; }
#grid-toggle-btn[aria-pressed="false"] .grid-toggle-slash { display: block; }

.home-btn {
  color: var(--mx-acid);
  border-color: var(--mx-purple-deep);
  background: #17101a;
}

.home-btn:hover { color: var(--mx-ink); background: var(--mx-acid); border-color: var(--mx-acid); }

#clear-level-btn { color: #ff8e89; border-color: #62332f; }
#publish-level-btn { color: var(--mx-paper); border-color: var(--mx-purple); background: #341b3b; }

.publication-version-status {
  margin: 0;
  padding: 8px 14px;
  border-block: 1px solid #4f3d16;
  background: #211b0d;
  color: var(--mx-acid);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.publication-version-status[data-state="live"] {
  border-color: #285442;
  background: #10231c;
  color: var(--mx-green);
}

.header-btn.share-btn {
  color: var(--mx-ink);
  background: var(--mx-acid);
  border-color: var(--mx-acid);
  box-shadow: none;
}

.header-btn.share-btn:hover {
  color: var(--mx-ink);
  background: #ffe266;
  border-color: #ffe266;
}

#play-btn {
  position: relative;
  overflow: visible;
}

#play-btn[data-playtest-readiness="passed"] {
  color: #08130d;
  border-color: var(--mx-green);
  background: var(--mx-green);
}

#play-btn[data-playtest-readiness="stale"] {
  color: var(--mx-acid);
  border-color: #c58324;
  background: #30210c;
}

#play-btn[data-playtest-readiness="passed"]::after,
#play-btn[data-playtest-readiness="stale"]::after {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border: 1px solid var(--mx-ink);
  border-radius: 50%;
  color: var(--mx-ink);
  font: 900 9px/1 var(--mx-mono);
  pointer-events: none;
}

#play-btn[data-playtest-readiness="passed"]::after {
  content: "\2713";
  background: var(--mx-green);
}

#play-btn[data-playtest-readiness="stale"]::after {
  content: "!";
  background: var(--mx-acid);
}

.goo-chip {
  color: var(--mx-ink);
  background: var(--mx-acid);
  border: 1px solid #000;
  border-radius: 2px;
  font-family: var(--mx-mono);
  font-weight: 800;
}

.tile-palette {
  min-height: 58px;
  padding: 8px 12px;
  gap: 7px;
  background: #100d14;
  border-bottom: 2px solid var(--mx-line);
}

.palette-tile,
.tileset-card,
.ts-card,
.tile-thumb {
  border-color: var(--mx-line);
  border-radius: 3px;
  background: var(--mx-panel);
}

.palette-tile:hover,
.tileset-card:hover,
.ts-card:hover,
.tile-thumb:hover { border-color: var(--mx-purple); }

.palette-tile.selected,
.tileset-card.open,
.ts-card.active,
.tile-thumb.selected {
  color: var(--mx-paper);
  border-color: var(--mx-acid);
  background: #211923;
  box-shadow: none;
}

.select-tile,
.tileset-badge .set-name,
.ts-card.active .set-name { color: var(--mx-cyan); }

.tileset-dropdown {
  background: var(--mx-panel);
  border: 2px solid var(--mx-line);
  border-radius: 4px;
  box-shadow: none;
}

.palette-separator { background: var(--mx-line); }
.tile-label,
.tileset-badge .set-count { color: var(--mx-muted); font-family: var(--mx-mono); }

.grid-wrapper {
  /* The canvas draws the one true, zoom-aware editing grid. Keep its backing
     surface plain so No Background cannot reveal a second fixed CSS lattice. */
  background: #000;
  box-shadow: inset 0 0 0 2px #050407, inset 0 0 60px rgba(0, 0, 0, .7);
}

.grid-wrapper.grid-lines-hidden { background-image: none; }

.empty-hint {
  align-items: flex-start;
  justify-content: flex-start;
  padding: clamp(18px, 3vw, 34px);
}

.empty-hint-card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  max-height: 100%;
  max-width: none;
  padding: 0;
  overflow: hidden;
  pointer-events: auto;
  border: 1px solid #51445a;
  border-radius: 2px;
  background: #0d0a10;
  color: var(--mx-paper);
  box-shadow: none;
  transform: none;
}

.empty-hint-card::before,
.empty-hint-card::after {
  display: none;
}

/* Keep the exit visible even when a phone's toolbar leaves little canvas room.
   Reading or scrolling the guide must not send a paint gesture to the canvas. */
.empty-hint-head, .empty-hint-foot { flex-shrink: 0; }
.empty-hint-card ol {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.empty-hint-head {
  padding: 15px 16px 14px;
}

.empty-hint-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--mx-cyan);
  font-family: var(--mx-mono);
  font-size: 8px;
  font-weight: 900;
  line-height: 1.3;
  text-transform: uppercase;
}

.empty-hint-kicker::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: var(--mx-acid);
}

.empty-hint-head h2 {
  margin: 0;
  font-family: var(--mx-display);
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: normal;
  text-transform: uppercase;
}

.empty-hint-head > p {
  margin: 8px 0 0;
  color: var(--mx-muted);
  font-family: var(--mx-ui);
  font-size: 9px;
  line-height: 1.5;
  text-transform: uppercase;
}

.empty-hint-card ol {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  color: var(--mx-muted);
  list-style: none;
  border-top: 1px solid #302837;
}

.empty-hint-card li {
  min-width: 0;
  flex-shrink: 0;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: start;
  gap: 11px;
  border-bottom: 1px solid #29212f;
}

.eh-step-no {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid #66596d;
  color: var(--mx-acid);
  font-family: var(--mx-mono);
  font-size: 8px;
  line-height: 1;
}

.eh-step-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--mx-ui);
  font-size: 9px;
  line-height: 1.45;
}

.eh-step-copy > b {
  color: var(--mx-paper);
  font-size: 9px;
  line-height: 1.3;
  text-transform: uppercase;
}

.empty-hint-foot {
  margin: 0;
  padding: 10px 14px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #8d8493;
  font-family: var(--mx-mono);
  font-size: 8px;
  line-height: 1.45;
  text-transform: uppercase;
}

.empty-hint-foot > p { min-width: 0; margin: 0; }
.empty-hint-foot > p > span:first-child { color: var(--mx-cyan); }
.empty-hint-dismiss {
  appearance: none;
  pointer-events: auto;
  min-width: 88px;
  min-height: 44px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 2px solid var(--mx-acid);
  border-radius: 3px;
  background: var(--mx-acid);
  color: var(--mx-ink);
  box-shadow: none;
  font: 900 8px/1 var(--mx-ui);
  text-transform: uppercase;
  touch-action: manipulation;
  cursor: pointer;
}
.empty-hint-dismiss:hover { background: #ffe363; border-color: #ffe363; }
.eh-spawn { color: var(--mx-acid); }
.eh-goal { color: #78e36f; }
.eh-select { color: var(--mx-cyan); }

@media (max-width: 600px) {
  .empty-hint { padding: 10px; }
  .empty-hint-card {
    width: 100%;
  }
  .empty-hint-head { padding: 13px 12px 12px; }
  .empty-hint-kicker { margin-bottom: 7px; }
  .empty-hint-head h2 { font-size: 20px; }
  .empty-hint-head > p { margin-top: 6px; font-size: 8px; }
  .empty-hint-card li { padding: 8px 10px; grid-template-columns: 26px minmax(0, 1fr); gap: 9px; }
  .eh-step-no { width: 26px; height: 26px; }
  .eh-step-copy { gap: 2px; font-size: 8px; line-height: 1.4; }
  .eh-step-copy > b { font-size: 8px; }
  .empty-hint-foot { padding: 8px 10px 9px; }
}

@media (max-width: 340px) {
  .empty-hint-kicker,
  .empty-hint-head > p,
  .empty-hint-foot > p { display: none; }
  .empty-hint-head { padding: 9px 10px 8px; }
  .empty-hint-card li {
    min-height: 44px;
    padding: 6px 8px;
  }
  .empty-hint-foot { justify-content: flex-end; padding: 0 8px 6px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .empty-hint { padding: 6px; }
  .empty-hint-card { width: min(620px, 100%); }
  .empty-hint-head { padding: 5px 8px; }
  .empty-hint-kicker { display: none; }
  .empty-hint-head h2 { font-size: 16px; }
  .empty-hint-head > p,
  .empty-hint-foot > p { display: none; }
  .empty-hint-foot { justify-content: flex-end; padding: 0 8px 4px; }
  .empty-hint-card ol {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: max-content; /* short views scroll instead of squeezing instruction text */
  }
  .empty-hint-card li {
    min-height: 44px;
    padding: 6px 8px;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 7px;
  }
  .empty-hint-card li:nth-child(odd) { border-right: 1px solid #29212f; }
  .eh-step-no { width: 22px; height: 22px; }
  .eh-step-copy { gap: 2px; font-size: 8px; line-height: 1.25; }
  .eh-step-copy > b { font-size: 8px; }
}

@media (max-width: 420px) and (orientation: landscape) and (max-height: 560px) {
  .eh-step-copy > span { display: none; }
}

@media (max-height: 280px) {
  .empty-hint { padding: 4px; }
  .empty-hint-head { padding: 5px 8px; }
  .empty-hint-kicker,
  .empty-hint-head > p,
  .empty-hint-foot > p,
  .eh-step-copy > span { display: none; }
  .empty-hint-head h2 { font-size: 12px; line-height: 1.2; }
  .empty-hint-card li {
    min-height: 36px;
    padding: 5px 7px;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
  }
  .eh-step-no { display: none; }
  .eh-step-copy > b { font-size: 8px; line-height: 1.35; }
}

/* ── Lobby / campaign screen ─────────────────────────────────────────── */

.lobby {
  min-height: 100vh;
  min-height: 100svh;
  height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  isolation: isolate;
  background: #101032;
  color: var(--mx-paper);
}

.lobby::before {
  content: "";
  position: absolute;
  inset: auto 0 0 auto;
  width: 100%;
  aspect-ratio: 1672 / 941;
  z-index: 0;
  pointer-events: none;
  background: url("assets/brand/monstrs-home-trio-v1.png") center / 100% 100% no-repeat;
  mask-image: linear-gradient(to bottom, transparent, #000 20%);
}

.lobby-art-scrim {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(9, 8, 13, .12) 0%, rgba(9, 8, 13, .18) 37%, rgba(9, 8, 13, 0) 64%),
    linear-gradient(0deg, rgba(9, 8, 13, .58), transparent 25%);
}

.lobby-topbar {
  top: max(16px, env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  padding: 0;
  max-width: calc(100vw - 32px);
  gap: 10px;
}

.wallet-btn {
  border: 2px solid rgba(245, 242, 234, .78);
  border-radius: 3px;
  background: rgba(9, 8, 13, .9);
  color: var(--mx-acid);
  box-shadow: none;
}

.wallet-btn:hover { color: var(--mx-ink); background: var(--mx-acid); border-color: var(--mx-acid); }
.wallet-btn.connected:hover { border-color: var(--mx-acid); }

.lobby-center {
  z-index: 2;
  flex: 1 0 auto;
  width: min(630px, 46vw);
  max-width: none;
  min-height: min(820px, 100dvh);
  margin: 0 0 0 clamp(32px, 6vw, 108px);
  padding: clamp(68px, 8vh, 92px) 0 132px;
  align-items: stretch;
  justify-content: center;
  gap: clamp(16px, 2.2vh, 22px);
}

.lobby-logo { width: min(100%, 550px); text-align: left; }

.lobby-wordmark {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  object-fit: contain;
  object-position: center center;
  image-rendering: pixelated;
  filter: drop-shadow(7px 8px 0 rgba(0,0,0,.74));
}

.lobby-tagline {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  justify-content: center;
  color: var(--mx-paper);
  font-family: var(--mx-display);
  font-size: 16px;
  line-height: 1;
  letter-spacing: normal;
}

.lobby-tagline i { width: 6px; height: 6px; background: var(--mx-acid); transform: rotate(45deg); }

.lobby-menu {
  width: min(100%, 550px);
  gap: 10px;
}

.menu-btn {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 10px 15px;
  border: 2px solid var(--mx-paper);
  border-radius: 3px;
  background: rgba(20, 16, 24, .94);
  color: var(--mx-paper);
  box-shadow: none;
  overflow: hidden;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}

.menu-btn::after {
  content: "→";
  font-family: var(--mx-mono);
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
  transition: transform .14s ease;
}

.menu-btn:hover,
.menu-btn:focus-visible {
  transform: none;
  box-shadow: none;
}

.menu-btn:hover::after,
.menu-btn:focus-visible::after { transform: translateX(4px); }
.menu-btn:active { transform: none; box-shadow: none; }

.menu-ico {
  width: 44px;
  height: 44px;
  border: 1px solid currentColor;
  border-radius: 2px;
  background: rgba(0, 0, 0, .2);
  color: inherit;
}

.menu-textwrap { gap: 1px; min-width: 0; }

.menu-text {
  font-family: var(--mx-display);
  font-size: 27px;
  font-weight: 900;
  line-height: .95;
  letter-spacing: normal;
}

.menu-sub {
  color: inherit;
  font-family: var(--mx-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: normal;
  opacity: .72;
}

.menu-play {
  color: var(--mx-ink);
  background: var(--mx-acid);
  border-color: var(--mx-acid);
  box-shadow: none;
}

.menu-play .menu-ico,
.menu-build .menu-ico { color: inherit; background: rgba(0, 0, 0, .12); }

.menu-play:hover,
.menu-play:focus-visible { background: #ffe45c; box-shadow: none; }

.menu-load {
  color: var(--mx-cyan);
  background: rgba(25, 17, 31, .96);
  border-color: var(--mx-cyan);
}

.menu-load .menu-ico { color: var(--mx-cyan); background: rgba(56, 201, 231, .1); }
.menu-load[data-state="available"] { color: var(--mx-paper); border-color: var(--mx-acid); }
.menu-load[data-state="available"] .menu-ico { color: var(--mx-ink); border-color: var(--mx-acid); background: var(--mx-acid); }
.menu-load:hover,
.menu-load:focus-visible { color: var(--mx-ink); background: var(--mx-cyan); border-color: var(--mx-paper); }

.menu-btn:disabled { cursor: wait; opacity: .62; }
.menu-btn:disabled::after { transform: none; }

.journey-menu-help {
  width: min(100%, 550px);
  margin: -14px 0 0;
  color: rgba(245, 242, 234, .72);
  font-family: var(--mx-mono);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.55;
  letter-spacing: normal;
  text-align: center;
  text-transform: uppercase;
}

.menu-build {
  color: var(--mx-paper);
  background: rgba(90, 46, 104, .96);
  border-color: #d987c9;
  box-shadow: none;
}

.menu-build:hover,
.menu-build:focus-visible { background: #713574; box-shadow: none; }

.menu-settings:hover,
.menu-settings:focus-visible { color: var(--mx-ink); background: var(--mx-paper); }

.lobby-player-tag {
  position: absolute;
  right: max(24px, env(safe-area-inset-right, 0px));
  bottom: 58px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px 5px 5px;
  border: 1px solid rgba(245, 242, 234, .62);
  background: rgba(9, 8, 13, .85);
  box-shadow: none;
  font-family: var(--mx-mono);
  font-size: 8px;
  line-height: 1.35;
  letter-spacing: normal;
  color: var(--mx-muted);
}

.lobby-player-tag img { width: 50px; height: 50px; image-rendering: pixelated; }
.lobby-player-tag span { display: flex; flex-direction: column; }
.lobby-player-tag b { color: var(--mx-acid); font-size: 9px; }

.lobby-footer {
  left: max(18px, env(safe-area-inset-left, 0px));
  bottom: 37px;
  padding: 0;
  color: var(--mx-paper);
  font-family: var(--mx-mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: normal;
}

.bonus-odds > div:only-child { grid-column: 1 / -1; }
.login-secondary.local-goo-link {
  display: inline-flex;
  width: auto;
  min-height: 44px;
  align-items: center;
  padding: 0 12px;
  border-radius: 3px;
  background: #171021;
  color: #e0f997;
  white-space: nowrap;
}
.lobby-goo {
  box-sizing: border-box;
  height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  border: 2px solid rgba(245, 242, 234, .78);
  border-radius: 3px;
  background: rgba(9, 8, 13, .9);
  color: var(--mx-acid);
  box-shadow: none;
  font-family: var(--mx-mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: normal;
}

.lobby-ver { opacity: .76; }

.lobby-ticker {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  min-height: 28px;
  padding: 7px 20px 6px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 24px;
  overflow: hidden;
  border-top: 2px solid #000;
  background: var(--mx-purple);
  color: var(--mx-ink);
  font-family: var(--mx-display);
  font-size: 13px;
  line-height: 1;
  letter-spacing: normal;
  white-space: nowrap;
}

/* Electronic holder-data notice. Its desktop line-height is deliberately kept
   inside the rail's existing 28px box, so the runner ground does not move. */
.lobby-stats-viewport {
  width: 100%;
  min-width: 0;
  height: 13px;
  overflow: hidden;
  color: var(--mx-ink);
  font-family: var(--mx-mono);
  font-size: 9px;
  font-weight: 900;
  line-height: 13px;
  letter-spacing: normal;
  white-space: nowrap;
}

.lobby-stats-track {
  display: flex;
  width: max-content;
  will-change: transform;
  animation: lobby-stats-scroll 34s linear infinite;
}

.lobby-stats-set {
  flex: 0 0 auto;
  min-width: 100vw;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 26px;
}

.lobby-stats-cell {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  color: rgba(9, 8, 13, .62);
  font: inherit;
}

.lobby-stats-cell::after {
  content: "◆";
  margin-left: 20px;
  color: rgba(9, 8, 13, .38);
  font-size: 6px;
}

@keyframes lobby-stats-scroll {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-50%, 0, 0); }
}

/* ── Title playground ────────────────────────────────────────────────── */

.lobby-runner-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: pixelated;
}

.lobby-runner-instructions {
  position: static;
  flex: 0 1 auto;
  min-width: 0;
  max-width: min(520px, calc(100vw - 250px));
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 8px 12px;
  border: 2px solid rgba(245, 242, 234, .78);
  border-radius: 3px;
  background: rgba(9, 8, 13, .9);
  color: var(--mx-paper);
  font-family: var(--mx-mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: normal;
  white-space: nowrap;
  transition: opacity .2s ease, border-color .2s ease;
  box-shadow: none;
  pointer-events: none;
}

.lobby-runner-instructions.used { opacity: .64; }
.lobby-runner-instructions b { color: var(--mx-acid); }
.lobby-runner-mode {
  padding-right: 10px;
  border-right: 1px solid rgba(245, 242, 234, .3);
  color: var(--mx-pink);
}
.lobby-runner-free { display: none; color: var(--mx-acid); white-space: nowrap; }
.lobby-runner-free-touch { display: none; }

.lobby-runner-jump {
  display: none;
  min-width: 56px;
  min-height: 44px;
  border: 2px solid var(--mx-ink);
  border-radius: 2px;
  background: var(--mx-acid);
  color: var(--mx-ink);
  font-family: var(--mx-display);
  font-size: 16px;
  letter-spacing: normal;
  cursor: pointer;
}

.lobby-ticker {
  border-top-width: 3px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: inset 0 2px 0 rgba(248, 207, 61, .58);
  touch-action: none;
}

.lobby-ticker-copy {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 24px;
}

.lobby-runner-touch-controls { display: none; }

.lobby-runner-touch-controls button {
  min-width: 52px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #000;
  border-radius: 2px;
  background: rgba(9, 8, 13, .92);
  color: var(--mx-paper);
  font-family: var(--mx-display);
  font-size: 20px;
  line-height: 1;
  touch-action: none;
}

.lobby-runner-touch-controls button:last-child {
  background: var(--mx-acid);
  color: var(--mx-ink);
}

.lobby-runner-touch-controls button.pressed {
  background: var(--mx-cyan);
  color: var(--mx-ink);
}

@media (hover: none), (pointer: coarse) {
  .lobby-ticker {
    min-height: calc(50px + env(safe-area-inset-bottom, 0px));
    padding: 3px 10px calc(3px + env(safe-area-inset-bottom, 0px));
    justify-content: center;
  }
  /* Wide touch devices retain the proven control-rail height. The holder notice
     joins the controls only at phone widths in the final mobile rule below. */
  .lobby-stats-viewport { display: none; }
  .lobby-runner-touch-controls {
    width: min(100%, 360px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  .lobby-runner-touch-controls button { flex: 1 1 0; }
  .lobby-runner-keys { display: none; }
  .lobby-runner-jump { display: none; }
  .lobby-runner-free-touch { display: inline; }
}

@media (max-width: 1100px) {
  .lobby-player-tag,
  .lobby-footer { display: none; }
  .lobby-center { padding-bottom: 116px; }
}

@media (max-width: 760px) {
  .lobby-center { padding-bottom: 124px; }
  .lobby-runner-instructions,
  .lobby-goo { display: none; }
  .wallet-btn {
    inline-size: 58px; block-size: 58px; min-inline-size: 58px; min-block-size: 58px;
  }
}

@media (max-width: 480px) and (max-height: 620px) {
  .lobby-center { padding-bottom: 76px; }
}

@media (min-width: 540px) and (max-height: 560px) {
  .lobby-center { padding-bottom: 66px; }
  .lobby-runner-instructions { display: none; }
}

/* ======================================================================
   MONSTRS NETWORK / JOURNEY
   Public charts share the campaign's hard-edged poster language while the
   private progress card remains an independently failing enhancement.
   ====================================================================== */

.menu-rankings {
  color: var(--mx-ink);
  background: var(--mx-cyan);
  border-color: #9cefff;
}

.menu-rankings .menu-ico { color: inherit; background: rgba(0, 0, 0, .12); }
.menu-rankings:hover,
.menu-rankings:focus-visible { color: var(--mx-ink); background: #78e8fb; border-color: var(--mx-paper); }

/* Five campaign doors need a tighter desktop rhythm without sacrificing the
   44px touch target floor. */
.lobby-menu { gap: 7px; }
.menu-btn { min-height: 68px; padding-block: 8px; }
.menu-ico { width: 40px; height: 40px; }
.menu-text { font-size: 25px; }

.rankings-overlay { z-index: 150; padding: 16px; }

.rankings-container {
  width: min(1120px, calc(100vw - 32px));
  max-width: 1120px;
  height: min(900px, calc(100dvh - 32px));
  max-height: 900px;
  border-color: #65516e;
  box-shadow: none;
}

.rankings-header {
  min-height: 70px;
  padding: 12px 18px 12px 22px;
  background:
    linear-gradient(90deg, rgba(56, 201, 231, .12), transparent 45%),
    #100d14;
}

.rankings-header > div:first-child { flex: 1; min-width: 0; }
.rankings-header h2 { margin-top: 3px; font-size: clamp(24px, 3vw, 34px); }
.rankings-eyebrow,
.rankings-kicker {
  display: block;
  color: var(--mx-cyan);
  font-family: var(--mx-mono);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: normal;
}

.rankings-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--mx-purple) var(--mx-ink-2);
}

.rankings-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(330px, .92fr);
  gap: 18px;
  padding: clamp(20px, 3vw, 34px);
  border-bottom: 2px solid var(--mx-line);
  background:
    radial-gradient(circle at 10% 10%, rgba(178, 84, 158, .22), transparent 34%),
    linear-gradient(135deg, #1c1421, #0d0a11 72%);
}

.rankings-hero-copy {
  min-width: 0;
  align-self: center;
  padding: clamp(4px, 1vw, 12px);
}

.rankings-hero-copy h3 {
  max-width: 650px;
  margin: 9px 0 12px;
  color: var(--mx-paper);
  font-family: var(--mx-display);
  font-size: clamp(38px, 5.2vw, 64px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: normal;
  overflow-wrap: anywhere;
  text-transform: uppercase;
  text-wrap: balance;
}

.rankings-hero-copy p {
  max-width: 620px;
  margin: 0;
  color: #c8c0ce;
  font-family: var(--mx-mono);
  font-size: 11px;
  line-height: 1.65;
}

.rankings-progress {
  position: relative;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  min-height: 275px;
  padding: 18px;
  overflow: hidden;
  border: 2px solid var(--mx-acid);
  border-radius: 4px;
  background:
    linear-gradient(145deg, rgba(248, 207, 61, .12), transparent 44%),
    #100d14;
  box-shadow: none;
}

.rankings-progress::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .3;
  background-image:
    linear-gradient(rgba(255, 255, 255, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .055) 1px, transparent 1px);
  background-size: 16px 16px;
}

.rankings-progress > * { position: relative; }
.rankings-progress[aria-busy="true"] { opacity: .74; }
.rankings-progress.sync-error { border-color: var(--mx-coral); }

.rankings-progress-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--mx-muted);
  font-family: var(--mx-mono);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: normal;
  text-transform: uppercase;
}

.rankings-progress-label { color: var(--mx-paper); }
.rankings-progress-rank { color: var(--mx-acid); text-align: right; }

.rankings-tier-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 14px;
}

.rankings-tier-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 2px solid var(--mx-acid);
  color: var(--mx-acid);
  background: #050407;
  font-size: 25px;
  transform: rotate(2deg);
}

.rankings-tier-row > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rankings-tier-kicker { color: var(--mx-cyan); font-family: var(--mx-mono); font-size: 8px; font-weight: 900; letter-spacing: normal; }
.rankings-tier-row strong { font-family: var(--mx-display); font-size: 29px; line-height: 1.15; letter-spacing: normal; overflow-wrap: anywhere; text-transform: uppercase; }

.rankings-progress-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-block: 1px solid var(--mx-line);
}

.rankings-progress-stats > span { padding: 11px 8px 10px 0; }
.rankings-progress-stats > span + span { padding-left: 14px; border-left: 1px solid var(--mx-line); }
.rankings-progress-stats strong { display: block; color: var(--mx-paper); font-family: var(--mx-display); font-size: 26px; line-height: 1; }
.rankings-progress-stats small { display: block; margin-top: 4px; color: var(--mx-muted); font-family: var(--mx-mono); font-size: 8px; letter-spacing: normal; text-transform: uppercase; }

.rankings-progress-meter {
  height: 7px;
  margin-top: 13px;
  overflow: hidden;
  border: 1px solid #51445a;
  background: #060508;
}

.rankings-progress-meter > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--mx-purple), var(--mx-acid));
  transition: width .35s ease;
}

.rankings-progress-note {
  min-height: 30px;
  margin: 8px 0 12px;
  color: var(--mx-muted);
  font-family: var(--mx-mono);
  font-size: 9px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.rankings-journey-btn {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin-top: auto;
  padding: 8px 12px;
  border: 2px solid var(--mx-acid);
  border-radius: 2px;
  color: var(--mx-ink);
  background: var(--mx-acid);
  box-shadow: none;
  font-weight: 950;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.rankings-journey-btn > span { font-family: var(--mx-mono); font-size: 8px; letter-spacing: normal; opacity: .7; }
.rankings-journey-btn > b { font-family: var(--mx-mono); font-size: 18px; }
.rankings-journey-btn:hover { background: #ffe45c; transform: none; }
.rankings-journey-btn:disabled { cursor: wait; opacity: .66; transform: none; }

.rankings-board { padding: clamp(18px, 3vw, 30px); background: #0c0910; }
.rankings-board-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; border-bottom: 2px solid var(--mx-line); }
.rankings-board-tabs { display: flex; gap: 4px; }

.rankings-board-tab {
  min-width: 112px;
  min-height: 48px;
  padding: 9px 16px 7px;
  border: 0;
  border-bottom: 4px solid transparent;
  color: var(--mx-muted);
  background: transparent;
  font-family: var(--mx-display);
  font-size: 23px;
  letter-spacing: normal;
  text-transform: uppercase;
  cursor: pointer;
}

.rankings-board-tab:hover { color: var(--mx-paper); }
.rankings-board-tab.active { color: var(--mx-paper); border-bottom-color: var(--mx-cyan); }
.rankings-generated { padding-bottom: 12px; color: var(--mx-cyan); font-family: var(--mx-mono); font-size: 8px; font-weight: 900; letter-spacing: normal; }

.rankings-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 16px 0; }
.rankings-window-tabs,
.rankings-sort-tabs { display: flex; flex-wrap: wrap; gap: 6px; }

.rankings-filter,
.rankings-sort,
.rankings-retry {
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--mx-line);
  border-radius: 2px;
  color: var(--mx-muted);
  background: var(--mx-panel-2);
  font-family: var(--mx-mono);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: normal;
  text-transform: uppercase;
  cursor: pointer;
}

.rankings-filter { display: inline-flex; align-items: baseline; gap: 6px; }
.rankings-filter small { color: currentColor; font-size: 8px; opacity: .65; }
.rankings-filter:hover,
.rankings-sort:hover,
.rankings-retry:hover { color: var(--mx-paper); border-color: var(--mx-purple); }
.rankings-filter.active,
.rankings-sort.active { color: var(--mx-ink); border-color: var(--mx-acid); background: var(--mx-acid); }
.rankings-sort-tabs[hidden] { display: none; }

.rankings-list { min-height: 280px; }
.rankings-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.ranking-card,
.ranking-row {
  position: relative;
  border: 2px solid var(--mx-line);
  border-radius: 4px;
  color: var(--mx-paper);
  background: #131018;
}

.ranking-card {
  min-width: 0;
  min-height: 310px;
  padding: 17px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: none;
}

.ranking-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--mx-purple);
}

.ranking-card.rank-1 { border-color: #907821; background: linear-gradient(155deg, rgba(248, 207, 61, .13), transparent 38%), #131018; }
.ranking-card.rank-1::before { background: var(--mx-acid); }
.ranking-card.rank-2::before { background: var(--mx-cyan); }
.ranking-card.rank-3::before { background: var(--mx-coral); }

.ranking-position {
  color: var(--mx-acid);
  font-family: var(--mx-display);
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: normal;
}

.ranking-card > .ranking-position { margin-bottom: 13px; }
.ranking-card > .ranking-badges,
.ranking-card > .ranking-badge { position: absolute; top: 14px; right: 12px; max-width: calc(100% - 70px); }
.ranking-entry-heading { min-width: 0; display: flex; flex-direction: column; gap: 5px; }

.ranking-entry-title {
  margin: 0;
  overflow: hidden;
  color: var(--mx-paper);
  font-family: var(--mx-display);
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.ranking-entry-byline { overflow: hidden; color: var(--mx-muted); font-family: var(--mx-mono); font-size: 8px; letter-spacing: normal; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.ranking-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.ranking-badge { display: inline-flex; align-items: center; min-height: 21px; padding: 3px 6px; border: 1px solid currentColor; border-radius: 2px; font-family: var(--mx-mono); font-size: 8px; font-weight: 900; line-height: 1.2; letter-spacing: normal; text-align: center; text-transform: uppercase; }
.ranking-badge.verified { color: #8bf283; background: rgba(85, 211, 74, .1); }
.ranking-badge.unverified { color: #ffaaa6; background: rgba(255, 87, 80, .08); }
.ranking-badge.journey.cleared { color: var(--mx-ink); border-color: var(--mx-cyan); background: var(--mx-cyan); }
.ranking-badge.journey.new { color: var(--mx-ink); border-color: var(--mx-acid); background: var(--mx-acid); }
.ranking-badge.journey.explore { color: var(--mx-muted); }

.ranking-primary-metric { margin: 20px 0 13px; color: var(--mx-cyan); font-family: var(--mx-mono); font-size: 10px; font-weight: 900; letter-spacing: normal; text-transform: uppercase; }
.ranking-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-bottom: 15px; border: 1px solid var(--mx-line); background: var(--mx-line); }
.ranking-stat { min-width: 0; padding: 8px; background: #0b090e; }
.ranking-stat strong { display: block; overflow: hidden; color: var(--mx-paper); font-family: var(--mx-mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.ranking-stat small { display: block; margin-top: 4px; overflow: hidden; color: var(--mx-muted); font-family: var(--mx-mono); font-size: 8px; letter-spacing: normal; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }

.ranking-player-avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  margin: 4px 0 14px;
  border: 2px solid var(--mx-cyan);
  color: var(--mx-ink);
  background: var(--mx-cyan);
  box-shadow: none;
  font-family: var(--mx-display);
  font-size: 25px;
}

.rankings-rows { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.ranking-row { min-height: 76px; padding: 10px 12px; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(210px, .8fr); align-items: center; gap: 13px; }
.ranking-row:hover { border-color: var(--mx-purple); background: #19121d; }
.ranking-row-main { min-width: 0; display: flex; align-items: center; gap: 12px; }
.ranking-row-main .ranking-position { width: 42px; flex: 0 0 auto; font-size: 19px; }
.ranking-row-main .ranking-entry-title { font-size: 19px; }
.ranking-row-main .ranking-badges { margin-left: auto; flex: 0 1 auto; }
.ranking-row-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--mx-line); background: var(--mx-line); }
.ranking-row .ranking-player-avatar { width: 38px; height: 38px; margin: 0; font-size: 19px; }
.ranking-row.ranking-player { grid-template-columns: minmax(0, 1.6fr) minmax(180px, .65fr) auto; }

.rankings-state {
  min-height: 260px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 28px;
  border: 2px dashed var(--mx-line);
  background: #100d14;
}

.rankings-state.error { border-color: #733d40; }
.rankings-state-mark { width: 56px; height: 56px; display: grid; place-items: center; border: 2px solid var(--mx-purple); color: var(--mx-cyan); font-family: var(--mx-display); font-size: 27px; }
.rankings-state.error .rankings-state-mark { color: var(--mx-coral); border-color: var(--mx-coral); }
.rankings-state-copy strong { font-family: var(--mx-display); font-size: 25px; letter-spacing: normal; text-transform: uppercase; }
.rankings-state-copy p { max-width: 560px; margin: 6px 0 0; color: var(--mx-muted); font-family: var(--mx-mono); font-size: 10px; line-height: 1.55; }
.rankings-retry { min-width: 110px; color: var(--mx-ink); border-color: var(--mx-acid); background: var(--mx-acid); }

.rankings-loading { min-height:240px; display:grid; place-items:center; }

.rankings-method { border-top: 2px solid var(--mx-line); background: #100d14; }
.rankings-method summary { min-height: 48px; padding: 15px clamp(18px, 3vw, 30px); color: var(--mx-cyan); font-family: var(--mx-mono); font-size: 9px; font-weight: 900; letter-spacing: normal; text-transform: uppercase; cursor: pointer; }
.rankings-method summary:hover { color: var(--mx-paper); }
.rankings-method-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 0 clamp(18px, 3vw, 30px) 22px; }
.rankings-method-grid p { margin: 0; color: var(--mx-muted); font-family: var(--mx-mono); font-size: 9px; line-height: 1.55; }
.rankings-method-grid strong { display: block; margin-bottom: 3px; color: var(--mx-paper); }

@media (max-width: 900px) {
  .rankings-hero { grid-template-columns: 1fr; }
  .rankings-progress { min-height: 250px; }
  .rankings-podium { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rankings-podium .ranking-card:nth-child(3) { grid-column: 1 / -1; min-height: 250px; }
  .ranking-row { grid-template-columns: minmax(0, 1fr) auto; }
  .ranking-row-metrics { grid-column: 1 / -1; grid-row: 2; }
  .ranking-row.ranking-player { grid-template-columns: minmax(0, 1fr) auto; }
  .rankings-method-grid { grid-template-columns: 1fr; gap: 10px; }
}

@media (max-width: 680px) {
  .rankings-overlay { padding: 6px; }
  .rankings-container { width: calc(100vw - 12px); height: calc(100dvh - 12px); max-height: none; }
  .rankings-header { min-height: 60px; padding: 8px 10px 8px 14px; }
  .rankings-header h2 { font-size: 25px; }
  .rankings-eyebrow { font-size: 8px; }
  .rankings-hero { gap: 14px; padding: 18px 14px; }
  .rankings-hero-copy { padding: 0; }
  .rankings-hero-copy h3 { font-size: clamp(22px, 5.7vw, 28px); line-height: 1.15; margin: 7px 0 9px; }
  .rankings-hero-copy p { font-size: 10px; line-height: 1.5; }
  .rankings-progress { min-width: 0; min-height: 0; padding: 12px; }
  .rankings-tier-row { margin: 10px 0; gap: 9px; }
  .rankings-tier-mark { width: 36px; height: 36px; font-size: 20px; }
  .rankings-tier-row strong { font-size: 20px; }
  .rankings-progress-stats > span { padding-block: 8px; }
  .rankings-progress-stats strong { font-size: 22px; }
  .rankings-progress-note { min-height: 0; margin-block: 7px 10px; }
  .rankings-board { padding: 15px 12px 20px; }
  .rankings-board-head { align-items: center; }
  .rankings-board-tab { min-width: 0; min-height: 43px; padding-inline: 6px; flex: 1; font-size: 16px; }
  .rankings-generated { display: none; }
  .rankings-controls { align-items: stretch; }
  .rankings-window-tabs,
  .rankings-sort-tabs { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .rankings-filter,
  .rankings-sort { min-width: 0; padding-inline: 5px; justify-content: center; text-align: center; }
  .rankings-filter { flex-direction: column; align-items: center; gap: 0; }
  .rankings-podium { grid-template-columns: 1fr; }
  .rankings-podium .ranking-card:nth-child(3) { grid-column: auto; }
  .ranking-card { min-height: 280px; }
  .ranking-row,
  .ranking-row.ranking-player { display: flex; flex-direction: column; align-items: stretch; }
  .ranking-row-main { width: 100%; }
  .ranking-row-main .ranking-badges { display: none; }
  .rankings-state-copy { min-width: 0; }
  .rankings-state-copy strong,
  .rankings-state-copy p { overflow-wrap: anywhere; }
  .rankings-state .rankings-retry { width: 100%; }
  .ranking-row-metrics { width: 100%; }
  .ranking-row .ranking-badge { align-self: flex-start; }
  .rankings-state { grid-template-columns: auto 1fr; gap: 14px; padding: 20px 15px; }
  .rankings-state .rankings-retry { grid-column: 1 / -1; width: 100%; }
}

@media (max-width: 480px) {
  .lobby-center { padding-top: 68px; padding-bottom: 112px; gap: 8px; }
  .lobby-menu { gap: 5px; }
  .menu-btn { min-height: 58px; padding-block: 5px; }
  .menu-ico { width: 34px; height: 34px; }
  .menu-text { font-size: 21px; }
}

@media (max-width: 340px) and (max-height: 520px) {
  .lobby-center { padding: 38px 8px 82px; gap: 3px; }
  .lobby-wordmark { max-height: 68px; }
  .lobby-tagline { font-size: 9px; }
  .lobby-menu { gap: 3px; }
  .menu-btn {
    grid-template-columns: 28px minmax(0, 1fr) 14px;
    min-height: 44px;
    gap: 5px;
    padding: 3px 6px;
  }
  .menu-ico { width: 27px; height: 27px; }
  .menu-ico svg { width: 15px; height: 15px; }
  .menu-text { font-size: 17px; }
  .menu-sub { display: none; }
  .journey-menu-help { display: none; }
  .lobby-ticker { min-height: 46px; }
}

@media (min-width: 540px) and (max-height: 560px) {
  .lobby-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .menu-settings { grid-column: 1 / -1; }
  .journey-menu-help { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rankings-progress-meter > span { transition: none; }
}

@media (min-width: 481px) and (min-height: 561px) and (max-height: 699px) {
  .lobby-center { padding-bottom: 94px; }
  .lobby-runner-keys { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .lobby-runner-instructions { transition: none; }
  .lobby-stats-track {
    width: 100%;
    animation: none;
    transform: none;
    will-change: auto;
  }
  .lobby-stats-set { width: 100%; min-width: 100%; }
  .lobby-stats-set[aria-hidden="true"] { display: none; }
}

/* ── Shared framed surfaces ───────────────────────────────────────────── */

.admin-overlay,
.bg-selector-overlay,
.props-overlay,
.col-overlay,
.login-overlay,
.completion-overlay {
  background: rgba(5, 4, 8, .82);
  backdrop-filter: blur(5px);
}

.admin-container,
.bg-selector-container,
.props-container,
.col-container,
.login-card,
.completion-card {
  border: 2px solid var(--mx-line);
  border-radius: 5px;
  background: var(--mx-panel);
  box-shadow: none;
}

.admin-header,
.bg-selector-header,
.props-header,
.col-header {
  min-height: 58px;
  border-bottom: 2px solid var(--mx-line);
  background: #100d14;
}

.admin-header h2,
.bg-selector-header h2,
.props-header h2,
.col-header h2,
.login-title,
.pfp-title,
.completion-title {
  color: var(--mx-paper);
  font-family: var(--mx-display);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: normal;
  text-transform: uppercase;
}

.admin-close,
.login-close {
  min-width: 40px;
  min-height: 40px;
  padding: 6px;
  border: 1px solid var(--mx-line);
  border-radius: 2px;
  color: var(--mx-paper);
  background: var(--mx-panel-2);
  display: grid;
  place-items: center;
}

.admin-close:hover,
.login-close:hover { color: var(--mx-ink); background: var(--mx-coral); border-color: var(--mx-coral); }

.login-card { max-width: 390px; padding: 30px 26px 22px; }
.login-title { text-align: left; font-size: 30px; margin-bottom: 10px; }
.login-sub { color: var(--mx-muted); text-align: left; }

.login-method,
.login-input,
.col-field > input[type="text"],
.col-field > input[type="number"],
.col-field > select,
.props-field select,
.tiles-top input {
  border: 2px solid var(--mx-line);
  border-radius: 3px;
  background: #0d0b10;
  color: var(--mx-paper);
}

.login-method { min-height: 56px; color: var(--mx-paper); background: var(--mx-panel-2); }
.login-method:hover { border-color: var(--mx-purple); background: #291d2e; }

/* Wallet sign-in and guest play share one compact dialog. */
#login-modal {
  padding: 18px;
  background: rgba(5, 4, 8, .87);
  backdrop-filter: blur(10px);
}
#login-modal .login-card {
  width: min(100%, 360px);
  max-width: 360px;
  max-height: calc(100dvh - 36px);
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #4b424f;
  border-radius: 3px;
  background: #131015;
  background-image: none;
  box-shadow: none;
  transform: translateY(8px);
}
#login-modal .login-card::before,
#login-modal .login-card::after { display: none; }
#login-modal.wallet-active { background: transparent; }
#login-modal.wallet-active .login-card { visibility: hidden; }
#login-modal.open .login-card { transform: translateY(0); }
#login-modal .login-header { position: relative; margin-bottom: 20px; }
#login-modal .login-close {
  top: -9px;
  right: -9px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 2px;
  color: #aaa2b0;
  background: transparent;
  box-shadow: none;
  font-weight: 900;
}
#login-modal .login-close:hover {
  color: var(--mx-paper);
  background: #241f27;
  box-shadow: none;
  transform: none;
}
#login-modal .login-title {
  max-width: calc(100% - 48px);
  margin-bottom: 10px;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: normal;
  text-shadow: none;
}
#login-modal .login-view { gap: 4px; }
#login-modal .login-back {
  min-height: 44px;
  margin: -5px 0 0;
  padding: 8px 0;
  border: 0;
  border-radius: 0;
  color: var(--mx-cyan);
  background: transparent;
  box-shadow: none;
  font-family: var(--mx-ui);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: normal;
  text-transform: uppercase;
}
#login-modal .login-back:hover { color: var(--mx-paper); background: transparent; }
#login-modal .login-label { font-size: 12px; font-weight: 900; }
#login-modal .login-input {
  min-height: 52px;
  border: 1px solid #4b424f;
  border-radius: 3px;
  background: #0b090d;
  box-shadow: none;
  font-weight: 700;
}
#login-modal .login-input:focus-visible {
  border-color: var(--mx-cyan);
}
#login-modal #otp-input { letter-spacing: .28em; }
#login-modal #email-echo { overflow-wrap: anywhere; }
#login-modal .login-primary {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin: 0;
  line-height: 1.4;
  text-decoration: none;
  text-transform: none;
  border-radius: 3px;
  box-shadow: none;
  font-size: 14px;
  font-weight: 900;
}
#login-modal .login-primary[hidden] { display: none; }
#login-modal .login-link { margin: 0; }
#login-modal :is(.login-primary, .login-link, .login-close):focus-visible { outline: 2px solid var(--mx-paper); outline-offset: 2px; }
#login-modal .login-primary:hover { box-shadow: none; transform: none; }
#login-modal .login-status {
  color: #aaa3ae;
  font-weight: 700;
  text-align: left;
}
#login-modal .login-status.err { color: #ff8f88; }

@media (prefers-reduced-motion: reduce) {
  #login-modal,
  #login-modal .login-card { transition: none; }
  #login-modal .login-card,
  #login-modal.open .login-card { transform: none; }
}

.login-input:focus,
.col-field > input:focus,
.col-field > select:focus,
.props-field select:focus,
.tiles-top input:focus { border-color: var(--mx-cyan); outline: none; }

.login-label,
.settings-key { color: var(--mx-paper); font-weight: 700; }
.login-back,
.login-link { min-height: 44px; color: var(--mx-cyan); }

.login-primary,
.length-apply {
  min-height: 44px;
  border: 2px solid var(--mx-acid);
  border-radius: 3px;
  background: var(--mx-acid);
  color: var(--mx-ink);
  box-shadow: none;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: normal;
}

.login-primary:hover,
.length-apply:hover { background: #ffe363; transform: none; }

.login-secondary,
.tool-btn,
.set-list-head button {
  min-height: 36px;
  border: 1px solid var(--mx-line);
  border-radius: 2px;
  background: var(--mx-panel-2);
  color: var(--mx-paper);
}

.tool-btn:hover,
.login-secondary:hover,
.set-list-head button:hover { color: var(--mx-ink); background: var(--mx-paper); border-color: var(--mx-paper); }
.tool-btn.danger { color: #ff9b96; border-color: #6f3834; }
.tool-btn.danger:hover { color: var(--mx-ink); background: var(--mx-coral); border-color: var(--mx-coral); }

.profile-avatar,
.pfp-tile { border-radius: 4px; border-color: var(--mx-line); background: var(--mx-ink); }
.profile-avatar { box-shadow: none; }
.profile-avatar-btn,
.profile-avatar-edit { border-radius: 4px; }
.profile-row,
.settings-row { border-color: var(--mx-line); }
.profile-row > span:first-child,
.settings-hint,
.profile-sub { color: var(--mx-muted); }
.profile-name {
  max-width: 100%;
  font-family: var(--mx-display);
  font-size: 25px;
  line-height: 1.2;
  letter-spacing: normal;
  overflow-wrap: anywhere;
}
.profile-row > span:last-child { min-width: 0; overflow-wrap: anywhere; text-align: right; }

.settings-container,
.length-container { height: auto; max-height: min(88dvh, 620px); overflow: auto; }

.toggle { border-color: var(--mx-line); background: #2d2732; }
.toggle.on { background: var(--mx-purple); }
.toggle.on .toggle-knob { background: var(--mx-acid); }

.set-list,
.tiles-panel { background: #100d14; border-color: var(--mx-line); }
.set-list-head { color: var(--mx-muted); border-color: var(--mx-line); font-family: var(--mx-mono); }
.set-item,
.col-item { color: var(--mx-muted); border-color: #29212f; }
.set-item:hover,
.col-item:hover { color: var(--mx-paper); background: #211823; }
.set-item.active,
.col-item.active { color: var(--mx-paper); background: #281b2d; border-left-color: var(--mx-acid); }
.tiles-top,
.edit-top,
.enemies-help { border-color: var(--mx-line); }
#edit-label,
.col-item-val,
.col-empty,
.tiles-empty,
.props-cat-label { color: var(--mx-muted); }

#pixel-canvas,
.col-pixel-canvas,
.enemy-preview { border: 2px solid var(--mx-line); border-radius: 3px; }

.color-swatch { border-radius: 2px; }
.color-swatch.selected { border-color: var(--mx-acid); box-shadow: none; }

.bg-option,
.props-row {
  border: 2px solid var(--mx-line);
  border-radius: 4px;
  background: #100d14;
}

.bg-option:hover,
.props-row:hover { border-color: var(--mx-purple); }
.bg-option.selected,
.props-row.enabled { border-color: var(--mx-acid); box-shadow: none; }
.bg-option-label,
.props-field > label,
.col-field > label,
.enemy-tuner-desc,
.enemies-help { color: var(--mx-muted); }
.bg-option.selected .bg-option-label,
.props-val { color: var(--mx-acid); }

.path-edit-bar {
  border: 2px solid var(--mx-purple);
  border-radius: 4px;
  background: var(--mx-panel);
  box-shadow: none;
}
.path-edit-bar > span { color: var(--mx-paper); }
.path-done { color: var(--mx-ink) !important; background: var(--mx-acid) !important; }

/* ── Game HUD, completion and feedback ───────────────────────────────── */

.game-exit {
  top: max(16px, env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  width: 46px;
  height: 46px;
  border: 2px solid var(--mx-paper);
  border-radius: 3px;
  background: rgba(9, 8, 13, .86);
  color: var(--mx-paper);
  box-shadow: none;
}
.game-exit:hover { color: var(--mx-ink); background: var(--mx-acid); }

.touch-btn {
  border: 3px solid var(--mx-paper);
  background: rgba(9, 8, 13, .72);
  color: var(--mx-paper);
  box-shadow: none;
}
.touch-jump { color: var(--mx-ink); background: rgba(248, 207, 61, .88); border-color: var(--mx-acid); }

.completion-card { min-width: min(360px, calc(100vw - 32px)); padding: 32px 38px; }
.completion-title { color: var(--mx-green); font-size: 38px; }
.pause-title { color: var(--mx-acid); }
.completion-score { color: var(--mx-paper); font-family: var(--mx-mono); }
.completion-rate-btn {
  border: 2px solid var(--mx-line);
  border-radius: 3px;
  background: var(--mx-panel-2);
  color: var(--mx-paper);
}
.completion-rate-btn:hover { color: var(--mx-ink); border-color: var(--mx-acid); background: var(--mx-acid); }
.completion-rate-btn.rated { color: var(--mx-ink); border-color: var(--mx-green); background: var(--mx-green); }
.completion-btn {
  min-height: 44px;
  border: 1px solid var(--mx-line);
  border-radius: 3px;
  background: var(--mx-panel-2);
  color: var(--mx-paper);
  font-weight: 800;
  text-transform: uppercase;
}
.completion-btn:hover { color: var(--mx-ink); background: var(--mx-paper); }
.completion-btn-next { color: var(--mx-ink); background: var(--mx-green); border-color: var(--mx-green); }
.completion-btn-next:hover { color: var(--mx-ink); background: #a5f29f; }
.completion-btn-primary { color: var(--mx-ink); background: var(--mx-green); border-color: var(--mx-green); }
.completion-btn-primary:hover { color: var(--mx-ink); background: #a5f29f; }
.pause-resume { color: var(--mx-ink); background: var(--mx-acid); border-color: var(--mx-acid); }
.pause-resume:hover { color: var(--mx-ink); background: #ffe363; }

.app-status,
.save-toast,
.editor-toast,
.game-warning,
.side-callout,
.ui-tip {
  border-width: 2px;
  border-radius: 3px;
  background: rgba(14, 11, 18, .97);
  box-shadow: none;
}

.app-status { padding-left: 17px; border-color: var(--mx-cyan); color: var(--mx-paper); }
.app-status::before { content: "//"; margin-right: 8px; color: var(--mx-cyan); font-family: var(--mx-mono); font-weight: 900; }
.app-status.success { border-color: var(--mx-green); color: #a5f29f; }
.app-status.success::before { content: "OK"; color: var(--mx-green); }
.app-status.warning { border-color: var(--mx-acid); color: #ffe78a; }
.app-status.warning::before { content: "!!"; color: var(--mx-acid); }
.app-status.error { border-color: var(--mx-coral); color: #ffaaa6; }
.app-status.error::before { content: "XX"; color: var(--mx-coral); }

.save-toast { color: var(--mx-ink); background: var(--mx-green); border-color: #000; font-weight: 900; }
.save-toast.error { color: var(--mx-paper); background: #7b2528; border-color: var(--mx-coral); }
.editor-toast { color: var(--mx-ink); background: var(--mx-acid); border-color: #000; }
.ui-tip { color: var(--mx-paper); border-color: var(--mx-purple); font-family: var(--mx-mono); }

/* ── Responsive composition and editor repair ────────────────────────── */

@media (max-width: 1100px) {
  .lobby-center { width: min(560px, 51vw); margin-left: 34px; }
  .lobby { background-position: center center; }
  .lobby-art-scrim {
    background:
      linear-gradient(rgba(9,8,13,.16), rgba(9,8,13,.16)),
      linear-gradient(0deg, rgba(9,8,13,.46), transparent 25%);
  }
}

@media (max-width: 900px) {
  .admin-body { overflow: auto; }
  .set-list { width: 150px; }
  .tiles-panel { width: 210px; }
  .edit-panel { min-width: 300px; }
  .edit-body { flex-direction: column; align-items: center; }
  .edit-sidebar { width: min(256px, 100%); }
}

@media (max-width: 760px) {
  .lobby { background-position: center center; }
  .lobby-art-scrim {
    background:
      linear-gradient(rgba(9,8,13,.46), rgba(9,8,13,.46)),
      linear-gradient(0deg, rgba(9,8,13,.32), transparent 24%);
  }
  .lobby-topbar {
    top: max(12px, env(safe-area-inset-top, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
  }
  .lobby-center {
    width: calc(100% - 34px);
    min-height: 100svh;
    margin: 0 auto;
    padding: 86px 0 104px;
    align-items: center;
    gap: 18px;
  }
  .lobby-logo,
  .lobby-menu { width: min(100%, 510px); }
  .lobby-wordmark { width: 100%; }
  .lobby-player-tag { display: none; }
  .lobby-footer { bottom: 36px; }
}

@media (max-width: 680px) {
  .sidebar { width: 52px; }
  .sidebar-logo { width: 40px; height: 44px; }
  .sidebar-logo img { width: 35px; height: 35px; }
  .sidebar-icon { width: 42px; height: 42px; }

  .header { min-height: 54px; padding: 6px; }
  .title { display: none; }
  .header-actions {
    flex: 1;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 3px 5px 5px;
  }
  .header-primary-actions { gap: 4px; padding: 3px 0 5px; }
  .header-btn,
  .header-btn.icon-only { min-width: 42px; min-height: 42px; padding: 11px; }
  .goo-chip { flex: 0 0 auto; padding: 5px 7px; }
  .tile-palette { min-height: 62px; padding: 8px 10px; }

  .admin-container,
  .bg-selector-container,
  .col-container { width: calc(100vw - 18px); height: calc(100dvh - 18px); max-height: none; }
  .col-container.settings-container,
  .col-container.length-container {
    height: auto;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }
  .props-container,
  .login-card,
  .completion-card { max-height: calc(100dvh - 24px); overflow-y: auto; }

  .admin-body { flex-direction: column; overflow-y: auto; }
  .set-list,
  .tiles-panel {
    width: 100%;
    min-height: 122px;
    max-height: 25dvh;
    flex: 0 0 auto;
    border-right: 0;
    border-bottom: 2px solid var(--mx-line);
  }
  .tiles-panel { min-height: 154px; max-height: 29dvh; }
  .edit-panel { min-width: 0; min-height: 470px; flex: 0 0 auto; overflow: visible; }
  .edit-top { align-items: flex-start; gap: 8px; }
  .edit-actions { flex-wrap: wrap; justify-content: flex-end; }
  .edit-body { overflow: visible; flex-direction: column; align-items: center; }
  #pixel-canvas { width: min(256px, calc(100vw - 70px)); height: auto; aspect-ratio: 1; }
  .edit-sidebar { width: min(100%, 300px); }

  .col-body { flex-direction: column; overflow-y: auto; }
  .col-list-panel {
    width: 100%;
    min-height: 90px;
    max-height: 24dvh;
    flex: 0 0 auto;
    border-right: 0;
    border-bottom: 2px solid var(--mx-line);
  }
  .col-edit-panel {
    width: 100%;
    min-height: 430px;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    overflow: visible;
  }
  .col-edit-left,
  .enemy-preview-wrap { justify-content: center; padding: 16px; }
  .col-edit-right { width: 100%; padding: 0 16px 24px; }
  .col-pixel-canvas { width: min(224px, calc(100vw - 64px)); height: auto; aspect-ratio: 1; }
  .enemy-preview { width: min(200px, calc(100vw - 64px)); height: auto; aspect-ratio: 1; }
  .col-field { min-height: 40px; }

  .bg-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .path-edit-bar { width: calc(100vw - 24px); bottom: 12px; flex-direction: column; gap: 8px; }

  .login-close,
  .admin-close { min-width: 44px; min-height: 44px; }
  .tool-btn { min-height: 40px; }
  .completion-card { min-width: 0; width: calc(100vw - 28px); padding: 28px 20px; }
  .completion-title { font-size: 32px; }
  .completion-actions .completion-btn { flex: 1 1 118px; }
  .completion-btn-next { order: -1; flex-basis: 100% !important; }
}

@media (max-width: 480px) {
  #login-modal { padding: 12px; }
  #login-modal .login-card {
    width: 100%;
    max-width: 360px;
    max-height: calc(100dvh - 24px);
    padding: 24px 18px 19px;
    border-radius: 3px;
  }
  #login-modal .login-title { font-size: 26px; }
  #login-modal .login-close { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  .lobby-center { width: calc(100% - 26px); padding-top: 76px; }
  .lobby-wordmark { filter: drop-shadow(4px 5px 0 rgba(0,0,0,.8)); }
  .menu-btn {
    grid-template-columns: 40px minmax(0, 1fr) 18px;
    gap: 9px;
    min-height: 69px;
    padding: 8px 10px;
  }
  .menu-ico { width: 38px; height: 38px; }
  .menu-text { font-size: 23px; }
  .menu-sub { font-size: 8px; }
  .lobby-ticker { justify-content: space-between; }
  .lobby-footer { font-size: 7px; }

  .sidebar { width: 48px; }
  .sidebar-logo { width: 38px; }
  .sidebar-icon { width: 40px; }
  .header { gap: 4px; }
  .header-btn,
  .header-btn.icon-only { min-width: 40px; min-height: 40px; padding: 10px; }
  .goo-chip { display: none; }
  .app-status { top: 10px; right: 10px; width: calc(100vw - 20px); }

  .admin-header,
  .bg-selector-header,
  .props-header,
  .col-header { padding: 10px 12px; }
  .admin-header h2,
  .bg-selector-header h2,
  .props-header h2,
  .col-header h2 { font-size: 19px; }
  .admin-header { flex-wrap: wrap; gap: 8px; }
  .admin-header h2 { flex: 1 1 0; }
  .admin-header #save-defaults-btn { order: 2; width: 100%; }
  .props-field { align-items: stretch; flex-direction: column; }
  .props-field > label,
  .props-field select,
  .props-range { width: 100%; min-width: 0; }
}

@media (max-width: 480px) and (max-height: 620px) {
  .lobby-center { padding: 66px 0 68px; gap: 9px; }
  .lobby-wordmark { max-height: 98px; width: auto; max-width: 100%; }
  .lobby-tagline { font-size: 12px; }
  .lobby-menu { gap: 7px; }
  .menu-btn { min-height: 58px; }
  .menu-ico { width: 34px; height: 34px; }
  .menu-text { font-size: 21px; }
  .lobby-footer { display: none; }
}

/* Short landscape devices get a two-column poster rather than a clipped
   vertical stack. This preserves all five destinations at 568×320. */
@media (min-width: 540px) and (max-height: 560px) {
  .lobby { background-position: center center; }
  .lobby-art-scrim { background: rgba(9, 8, 13, .46); }
  .lobby-center {
    display: grid;
    grid-template-columns: minmax(200px, .82fr) minmax(250px, 1fr);
    align-items: center;
    width: 100%;
    min-height: 100svh;
    margin: 0;
    padding: 52px 16px 36px;
    gap: 16px;
  }
  .lobby-logo,
  .lobby-menu { width: 100%; }
  .lobby-wordmark { max-height: 112px; width: auto; max-width: 100%; }
  .lobby-tagline { font-size: 11px; gap: 7px; }
  .lobby-menu { gap: 6px; }
  .menu-btn {
    grid-template-columns: 34px minmax(0, 1fr) 16px;
    gap: 7px;
    min-height: 56px;
    padding: 6px 8px;
  }
  .menu-ico { width: 32px; height: 32px; }
  .menu-ico svg { width: 18px; height: 18px; }
  .menu-text { font-size: 20px; }
  .menu-sub { font-size: 7px; }
  .lobby-player-tag,
  .lobby-footer { display: none; }
  .lobby-ticker { min-height: 24px; padding: 5px 14px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .lobby *,
  .app-status,
  .save-toast,
  .editor-toast,
  .admin-overlay *,
  .login-overlay *,
  .col-overlay *,
  .props-overlay *,
  .bg-selector-overlay *,
  .completion-overlay * {
    animation: none !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

/* Mid-width portrait / compact browser panes keep the clean negative space
   behind the controls while allowing the campaign character to peek in from
   the right. */
@media (min-width: 481px) and (min-height: 561px) and (max-height: 699px) {
  .lobby {
    background-position: center center;
  }

  .lobby-art-scrim {
    background: rgba(9, 8, 13, .50);
  }

  .lobby-center {
    width: min(448px, calc(100% - 44px));
    min-height: 100svh;
    margin: 0 auto 0 24px;
    padding: 62px 0 54px;
    align-items: stretch;
    justify-content: center;
    gap: 12px;
  }

  .lobby-logo,
  .lobby-menu {
    width: 100%;
    max-width: none;
  }

  .lobby-wordmark {
    width: 100%;
    max-height: 150px;
    margin: 3px 0 1px;
    object-position: left center;
    filter: drop-shadow(5px 6px 0 rgba(0, 0, 0, .82));
  }

  .lobby-tagline {
    width: 100%;
    gap: 8px;
    font-size: 13px;
  }

  .lobby-tagline i {
    width: 5px;
    height: 5px;
  }

  .lobby-menu {
    gap: 0;
    overflow: hidden;
    border: 1px solid rgba(245, 242, 234, .78);
    border-radius: 3px;
    background: rgba(9, 8, 13, .94);
    box-shadow: none;
  }

  .menu-btn {
    grid-template-columns: 40px minmax(0, 1fr) 18px;
    min-height: 62px;
    gap: 9px;
    padding: 7px 11px;
    border: 0;
    border-bottom: 1px solid rgba(245, 242, 234, .18);
    border-left: 4px solid rgba(245, 242, 234, .34);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .menu-btn:last-child {
    border-bottom: 0;
  }


  .menu-btn:hover,
  .menu-btn:focus-visible,
  .menu-play:hover,
  .menu-play:focus-visible,
  .menu-build:hover,
  .menu-build:focus-visible {
    transform: none;
    background: rgba(245, 242, 234, .08);
  }

  .menu-btn:active {
    transform: none;
    background: rgba(245, 242, 234, .12);
  }

  .menu-ico {
    width: 38px;
    height: 38px;
  }

  .menu-ico svg {
    width: 19px;
    height: 19px;
  }

  .menu-text {
    font-size: 23px;
  }

  .menu-sub {
    font-size: 8px;
  }

  .menu-play {
    color: var(--mx-ink);
    background: var(--mx-acid);
    border-left-color: var(--mx-pink);
    box-shadow: none;
  }

  .menu-build {
    color: var(--mx-paper);
    background: rgba(90, 46, 104, .74);
    border-left-color: var(--mx-cyan);
    box-shadow: none;
  }

  .menu-play:hover,
  .menu-play:focus-visible {
    color: var(--mx-ink);
    background: #ffe05a;
    border-left-color: var(--mx-pink);
    box-shadow: none;
  }

  .menu-build:hover,
  .menu-build:focus-visible {
    color: var(--mx-paper);
    background: rgba(113, 53, 116, .92);
    border-left-color: var(--mx-cyan);
    box-shadow: none;
  }

  .menu-settings:hover,
  .menu-settings:focus-visible {
    color: var(--mx-paper);
    background: rgba(245, 242, 234, .09);
    border-left-color: var(--mx-paper);
    box-shadow: none;
  }

  .lobby-footer {
    display: none;
  }

}

/* Phones gain one compact departure-board row above the existing controls.
   Desktop rail dimensions remain the base 28px; narrow non-touch panes get only
   a modest 36px notice, while actual touch phones keep all three controls. */
@media (max-width: 760px) {
  .lobby-ticker {
    min-height: calc(36px + env(safe-area-inset-bottom, 0px));
    padding: 10px 0 calc(9px + env(safe-area-inset-bottom, 0px));
  }
  .lobby-stats-viewport {
    display: block;
    height: 15px;
    font-size: 9px;
    line-height: 15px;
  }
  .lobby-stats-set { padding: 0 12px; gap: 20px; }
  .lobby-stats-cell::after { margin-left: 14px; }
}

@media (max-width: 760px) and (hover: none), (max-width: 760px) and (pointer: coarse) {
  .lobby-ticker {
    height: calc(80px + env(safe-area-inset-bottom, 0px));
    min-height: calc(80px + env(safe-area-inset-bottom, 0px));
    padding: 4px 10px calc(4px + env(safe-area-inset-bottom, 0px));
    flex-direction: column;
    justify-content: center;
    gap: 3px;
  }
  .lobby-stats-viewport { display: block; flex: 0 0 15px; width: calc(100% + 20px); }
  .lobby-runner-touch-controls { inline-size: 100%; max-inline-size: 360px; }
}

@media (prefers-reduced-motion: reduce) {
  .lobby-stats-track { animation: none !important; transform: none !important; }
  .lobby-stats-set[aria-hidden="true"] { display: none; }
}

/* Runner clearance is declared last so earlier composition shorthands cannot
   accidentally consume the title playground on short screens. */
@media (min-width: 761px) and (max-width: 1100px) {
  .lobby-center { padding-bottom: 116px; }
}

@media (max-width: 760px) and (min-height: 621px) {
  .lobby-center {
    padding-top: clamp(88px, 12vh, 104px);
    padding-bottom: 124px;
    justify-content: flex-start;
  }
}

@media (min-width: 481px) and (max-width: 760px) and (min-height: 561px) and (max-height: 699px) {
  .lobby-center {
    padding-top: 62px;
    padding-bottom: 94px;
    justify-content: center;
  }
}

@media (max-width: 480px) and (max-height: 620px) {
  .lobby-center { padding: 40px 0 126px; gap: 5px; }
  .lobby-wordmark { max-height: 84px; }
  .lobby-tagline { font-size: 11px; }
  .lobby-menu { gap: 4px; }
  .menu-btn {
    min-height: 48px;
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .menu-ico { width: 30px; height: 30px; }
  .menu-text { font-size: 19px; }
  .journey-menu-help { display: none; }
  .lobby-runner-instructions { display: none; }
}

@media (max-height: 560px) {
  #login-modal .login-card {
    max-height: calc(100dvh - 20px);
    padding: 14px 16px 13px;
    overflow-y: auto;
  }
  #login-modal .login-header { margin-bottom: 14px; }
  #login-modal .login-title { margin-bottom: 8px; font-size: 25px; }
  #login-modal .login-view { gap: 7px; }
  #login-modal .login-back { min-height: 44px; padding-block: 8px; }
}

@media (max-height: 380px) {
  #login-modal .login-card { padding: 10px 14px; }
  #login-modal .login-title { margin-bottom: 7px; font-size: 22px; }
  #login-modal .login-view { gap: 5px; }
  #login-modal .login-back { min-height: 44px; padding-block: 8px; }
}

@media (min-width: 540px) and (max-height: 560px) {
  .lobby-topbar {
    top: max(10px, env(safe-area-inset-top, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
  }
  .wallet-btn {
    inline-size: 53px; block-size: 53px; min-inline-size: 53px; min-block-size: 53px;
  }
  .wallet-ico svg { width: 26px; height: 26px; }
  .lobby-center {
    padding: 50px 16px 94px;
    gap: 14px;
  }
  .lobby-wordmark { max-height: 92px; }
  .lobby-menu { gap: 3px; }
  .menu-btn {
    min-height: 44px;
    grid-template-columns: 28px minmax(0, 1fr) 14px;
    gap: 5px;
    padding: 3px 6px;
  }
  .menu-ico { width: 28px; height: 28px; }
  .menu-ico svg { width: 16px; height: 16px; }
  .menu-text { font-size: 16px; }
  #menu-load .menu-text { font-size: 14px; letter-spacing: normal; white-space: nowrap; }
  .menu-sub { font-size: 6px; }
  .lobby-runner-instructions { display: none; }

  /* Press Start's fixed glyph grid is wider than the previous UI face. In the compact
     two-column poster, let the words own the full card instead of reducing
     recognisable labels such as LOAD GAME to an unreadable size. */
  #lobby .lobby-tagline { gap: 5px; font-size: 8px; letter-spacing: normal; }
  #lobby .menu-btn {
    grid-template-columns: minmax(0, 1fr);
    text-align: center;
  }
  #lobby .menu-ico,
  #lobby .menu-btn::after { display: none; }
  #lobby .menu-text,
  #lobby #menu-load .menu-text { font-size: 12px; letter-spacing: normal; }
  #lobby .menu-sub {
    display: block;
    font-size: 7px;
    line-height: 1.25;
    letter-spacing: normal;
  }
}

/* The later compact-height lobby skin turns all menu rows transparent. Restore
   the Network identity after that rule so the fourth destination never becomes
   black-on-black at 481–760px portrait sizes. */
@media (min-width: 481px) and (min-height: 561px) and (max-height: 699px) {
  .menu-load,
  .menu-load[data-state="available"] {
    color: var(--mx-paper);
    background: rgba(25, 17, 31, .94);
    border-left-color: var(--mx-cyan);
  }

  .menu-load:hover,
  .menu-load:focus-visible {
    color: var(--mx-ink);
    background: var(--mx-cyan);
    border-left-color: var(--mx-acid);
  }

  .menu-rankings,
  .menu-rankings:hover,
  .menu-rankings:focus-visible {
    color: var(--mx-ink);
    background: var(--mx-cyan);
    border-left-color: var(--mx-acid);
  }
}

/* Final Network touch/readability pass. These rules deliberately live after
   every responsive skin so compact filters and actions never regress below the
   44px interaction target. Five level metrics use a balanced final row instead
   of leaving a sixth decorative cell that looks like missing data. */
@media (max-width: 680px) {
  .rankings-filter,
  .rankings-sort,
  .rankings-retry { min-height: 44px; }

  .ranking-entry-byline { font-size: 9px; line-height: 1.35; }
  .ranking-badge { min-height: 22px; font-size: 8px; }
  .ranking-stat small { font-size: 8px; line-height: 1.3; }
  .rankings-filter,
  .rankings-sort,
  .rankings-retry { font-size: 10px; }

}

/* On phone-landscape/very short windows the completion card scrolls internally.
   Keep the decision row visible as a clear scroll destination instead of hiding
   Replay / Next / Exit below un-signposted content. */
@media (max-width: 680px) and (max-height: 560px) {
  .completion-card { padding-bottom: 0; overscroll-behavior: contain; }
  .completion-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 12px -20px 0;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom, 0px));
    border-top: 2px solid var(--mx-line);
    background: rgba(16, 13, 20, .98);
    box-shadow: none;
  }
  .completion-actions .completion-btn { min-height: 44px; }
}

/* A published result has rating, report and Journey actions in addition to its
   score. In short landscape, the old sticky action footer sat directly over the
   rating row. Give published completion a compact two-column composition so
   result feedback and every decision remain visible without overlap. Local
   Playtest deliberately keeps its simpler Back / Replay single-pane layout. */
@media (min-width: 540px) and (max-height: 560px) {
  #completion-overlay:not(.local-playtest-completion) .completion-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(230px, .9fr);
    align-items: start;
    column-gap: 16px;
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 20px;
  }

  #completion-overlay:not(.local-playtest-completion) .completion-card > :not(.completion-actions) {
    min-width: 0;
    grid-column: 1;
  }

  #completion-overlay:not(.local-playtest-completion) .completion-title {
    margin-bottom: 8px;
    font-size: 25px;
  }

  #completion-overlay:not(.local-playtest-completion) .completion-score {
    margin-bottom: 12px;
  }

  #completion-overlay:not(.local-playtest-completion) .completion-progress {
    padding: 7px 9px;
  }

  #completion-overlay:not(.local-playtest-completion) .completion-rate-btn {
    width: 48px;
    height: 48px;
  }

  #completion-overlay:not(.local-playtest-completion) .completion-actions {
    position: static;
    grid-column: 2;
    grid-row: 1 / 20;
    align-self: stretch;
    justify-content: center;
    flex-direction: column;
    flex-wrap: nowrap;
    margin: 0;
    padding: 0 0 0 16px;
    border-top: 0;
    border-left: 2px solid var(--mx-line);
    background: transparent;
  }

  #completion-overlay:not(.local-playtest-completion) .completion-actions .completion-btn {
    width: 100%;
    min-height: 44px;
    flex: 0 0 auto;
  }

  #completion-overlay:not(.local-playtest-completion) .completion-btn-next {
    flex-basis: auto !important;
  }
}

/* Below 540px there is not enough horizontal room for two readable columns.
   Let the published result scroll as one honest document; an un-stuck footer
   must never cover the rating controls while the user is deciding. */
@media (max-width: 539px) and (max-height: 560px) {
  #completion-overlay:not(.local-playtest-completion) .completion-actions {
    position: static;
  }
}

/* ── Shared action dialog ───────────────────────────────────────────────
   A native top-layer <dialog> with a fully app-owned flat surface. It replaces
   browser alert/confirm/prompt chrome without inheriting any legacy card skin. */
.mx-dialog {
  --dlg-accent: var(--mx-acid);
  --dlg-action: var(--mx-acid);
  --dlg-action-hover: #ffe363;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding:
    max(12px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--mx-paper);
  box-shadow: none;
}

.mx-dialog:not([open]) { display: none; }
.mx-dialog[open] { display: grid; place-items: center; }
.mx-dialog::backdrop {
  background: rgba(5, 4, 8, .88);
  backdrop-filter: blur(7px);
}

.mx-dialog[data-tone="info"] {
  --dlg-accent: var(--mx-cyan);
  --dlg-action: var(--mx-cyan);
  --dlg-action-hover: #78e8fb;
}

.mx-dialog[data-tone="danger"] {
  --dlg-accent: var(--mx-coral);
  --dlg-action: var(--mx-coral);
  --dlg-action-hover: #ff7b75;
}

.mx-dialog__panel {
  width: min(440px, 100%);
  min-width: 0;
  max-height: 100%;
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #4b424f;
  border-radius: 3px;
  background: #131015;
  background-image: none;
  box-shadow: none;
  filter: none;
  transform: none;
  text-align: left;
}

.mx-dialog__header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: start;
}

.mx-dialog__kicker {
  grid-column: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--dlg-accent);
  font: 900 9px/1.3 var(--mx-mono);
  letter-spacing: normal;
  text-transform: uppercase;
}

.mx-dialog__kicker > span {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  background: currentColor;
}

.mx-dialog__title {
  grid-column: 1;
  margin: 0;
  color: var(--mx-paper);
  font: 900 22px/1.18 var(--mx-display);
  letter-spacing: normal;
  overflow-wrap: anywhere;
  text-shadow: none;
  text-transform: uppercase;
}

.mx-dialog__close {
  grid-column: 2;
  grid-row: 1 / 3;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #aaa2b0;
  box-shadow: none;
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
}

.mx-dialog__close:hover {
  color: var(--mx-paper);
  background: #241f27;
}

.mx-dialog__copy {
  margin: 14px 0 0;
  color: #b8b1bc;
  font: 700 11px/1.7 var(--mx-ui);
  letter-spacing: normal;
  overflow-wrap: anywhere;
}

.mx-dialog__field { margin-top: 18px; }
.mx-dialog__field[hidden],
.mx-dialog__error[hidden],
.mx-dialog__btn[hidden] { display: none !important; }

.mx-dialog__label {
  display: block;
  margin: 0 0 8px;
  color: var(--mx-paper);
  font: 900 10px/1.45 var(--mx-ui);
}

.mx-dialog__input {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #4b424f;
  border-radius: 3px;
  background: #0b090d;
  color: var(--mx-paper);
  box-shadow: none;
  font: 700 11px/1.4 var(--mx-ui);
  letter-spacing: normal;
}

.mx-dialog__input:focus-visible {
  border-color: var(--mx-cyan);
}

.mx-dialog__input[aria-invalid="true"] {
  border-color: var(--mx-coral);
}

.mx-dialog__meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--mx-muted);
  font: 700 8px/1.45 var(--mx-mono);
}

.mx-dialog__meta > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.mx-dialog__error {
  margin: 7px 0 0;
  color: #ffaaa6;
  font: 700 9px/1.5 var(--mx-ui);
}

.mx-dialog__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
}

.mx-dialog[data-mode="alert"] .mx-dialog__actions { grid-template-columns: 1fr; }

.mx-dialog__btn {
  min-width: 0;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--mx-line);
  border-radius: 2px;
  background: var(--mx-panel-2);
  color: var(--mx-paper);
  box-shadow: none;
  transform: none;
  font: 900 10px/1.4 var(--mx-ui);
  letter-spacing: normal;
  overflow-wrap: anywhere;
  text-transform: uppercase;
  cursor: pointer;
}

.mx-dialog__btn:hover {
  border-color: var(--mx-paper);
  background: var(--mx-paper);
  color: var(--mx-ink);
}

.mx-dialog__btn--primary {
  border-color: var(--dlg-action);
  background: var(--dlg-action);
  color: var(--mx-ink);
}

.mx-dialog__btn--primary:hover {
  border-color: var(--dlg-action-hover);
  background: var(--dlg-action-hover);
  color: var(--mx-ink);
}


.mx-dialog__btn:disabled,
.mx-dialog__close:disabled,
.mx-dialog__input:disabled {
  opacity: .52;
  cursor: wait;
}

.mx-dialog[aria-busy="true"] .mx-dialog__panel { cursor: wait; }

@media (max-width: 480px) {
  .mx-dialog {
    padding:
      max(10px, env(safe-area-inset-top, 0px))
      max(10px, env(safe-area-inset-right, 0px))
      max(10px, env(safe-area-inset-bottom, 0px))
      max(10px, env(safe-area-inset-left, 0px));
  }
  .mx-dialog__panel { padding: 18px 16px; }
  .mx-dialog__title { font-size: 19px; }
  .mx-dialog__copy { font-size: 10px; line-height: 1.65; }
  .mx-dialog__btn { padding-inline: 8px; font-size: 9px; }
}

@media (min-width: 480px) and (max-height: 420px) {
  .mx-dialog { padding: 8px; }
  .mx-dialog__panel { width: min(620px, 100%); padding: 13px 16px; }
  .mx-dialog__header { grid-template-columns: minmax(0, 1fr) 44px; }
  .mx-dialog__kicker { margin-bottom: 5px; font-size: 7px; }
  .mx-dialog__title { font-size: 17px; line-height: 1.15; }
  .mx-dialog__close { width: 44px; height: 44px; }
  .mx-dialog__copy { margin-top: 7px; font-size: 9px; line-height: 1.5; }
  .mx-dialog__field { margin-top: 9px; }
  .mx-dialog__label { margin-bottom: 5px; font-size: 8px; }
  .mx-dialog__input { min-height: 44px; padding-block: 7px; font-size: 9px; }
  .mx-dialog__meta { margin-top: 4px; font-size: 7px; }
  .mx-dialog__actions {
    grid-template-columns: repeat(2, minmax(0, 150px));
    justify-content: end;
    margin-top: 10px;
  }
  .mx-dialog[data-mode="alert"] .mx-dialog__actions { grid-template-columns: minmax(0, 150px); }
  .mx-dialog__btn { min-height: 44px; font-size: 8px; }
}

@media (max-width: 340px) {
  .mx-dialog { padding: 8px; }
  .mx-dialog__panel { padding: 14px 12px; }
  .mx-dialog__kicker { font-size: 7px; }
  .mx-dialog__title { font-size: 16px; }
  .mx-dialog__copy { font-size: 9px; }
  .mx-dialog__btn { min-height: 44px; font-size: 8px; }
}

@media (max-height: 280px) {
  .mx-dialog__panel { padding: 10px 12px; }
  .mx-dialog__kicker { display: none; }
  .mx-dialog__copy,
  .mx-dialog__field,
  .mx-dialog__actions { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .mx-dialog,
  .mx-dialog::backdrop,
  .mx-dialog * {
    transition: none !important;
    animation: none !important;
  }
}

/* ── Tile selection + Behaviors workflow ───────────────────────────── */

.palette-shell {
  display: flex;
  min-width: 0;
  min-height: 58px;
  flex: 0 0 auto;
  background: #100d14;
  border-bottom: 2px solid var(--mx-line);
}

.palette-quick {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 8px 10px;
  border-right: 2px solid var(--mx-line);
  background: #151019;
}

.palette-quick:empty { display: none; }
.palette-quick .palette-separator { display: none; }

.palette-mode {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 8px 7px;
  border-right: 2px solid var(--mx-line);
  background: #100d14;
}

.palette-mode-toggle {
  appearance: none;
  width: 82px;
  height: 40px;
  min-width: 0;
  padding: 0 8px;
  display: grid;
  place-items: center;
  border: 2px solid var(--mx-purple);
  border-radius: 3px;
  background: #1b1520;
  color: var(--mx-paper);
  box-shadow: none;
  transform: none;
  font: 900 8px/1 var(--mx-ui);
  text-align: center;
  letter-spacing: normal;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
}

.palette-mode-toggle:hover {
  border-color: var(--mx-cyan);
  background: #241a29;
}


.palette-shell > .tile-palette {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  padding: 8px 12px;
  border-bottom: 0;
  background: transparent;
}

.palette-quick .palette-tile {
  appearance: none;
  padding: 0;
  border-color: #55445d;
  background: #1b1520;
  font: inherit;
}

.palette-quick .palette-tile.selected {
  color: var(--mx-ink);
  border-color: var(--mx-cyan);
  background: var(--mx-cyan);
}

#props-btn.picking,
#props-btn[aria-pressed="true"] {
  color: var(--mx-ink);
  border-color: var(--mx-cyan);
  background: var(--mx-cyan);
  animation: none;
}


/* Behaviors is a true flat dialog. Hidden content is additionally made inert
   by JS so it never leaks into the keyboard order. */
.props-overlay .props-container,
.props-overlay.open .props-container {
  width: min(520px, calc(100vw - 28px));
  max-width: none;
  max-height: min(760px, calc(100dvh - 28px));
  border: 1px solid #4b424f;
  border-radius: 3px;
  background: #121015;
  background-image: none;
  box-shadow: none;
  filter: none;
  transform: none;
  transition: none;
}

.props-header {
  min-height: 78px;
  padding: 16px 18px;
  gap: 14px;
  border-bottom: 1px solid var(--mx-line);
  background: #151119;
}

.props-header > div { min-width: 0; }

.props-kicker {
  display: block;
  margin: 0 0 7px;
  color: var(--mx-cyan);
  font: 400 8px/1.4 var(--mx-mono);
  letter-spacing: normal;
  text-transform: uppercase;
}

.props-header h2 {
  margin: 0;
  color: var(--mx-paper);
  font: 400 20px/1.15 var(--mx-display);
  letter-spacing: normal;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.props-context {
  padding: 13px 18px 12px;
  border-bottom: 1px solid var(--mx-line);
  background: #0e0b11;
}

.props-context p { margin: 0; }

#props-intro {
  color: var(--mx-muted);
  font: 400 9px/1.55 var(--mx-ui);
  letter-spacing: normal;
}

.props-selection-summary {
  margin-top: 8px !important;
  color: var(--mx-acid);
  font: 400 9px/1.5 var(--mx-mono);
  letter-spacing: normal;
  overflow-wrap: anywhere;
}

.props-list {
  min-height: 0;
  padding: 14px 16px 8px;
  overscroll-behavior: contain;
}

.props-category { margin-bottom: 14px; }

.props-cat-label {
  margin: 0 0 7px;
  padding: 0;
  color: var(--mx-muted);
  font: 400 8px/1.4 var(--mx-mono);
  letter-spacing: normal;
}

.props-row {
  margin-bottom: 7px;
  border: 1px solid #342d38;
  border-radius: 3px;
  background: #100d14;
  box-shadow: none;
}

.props-row:hover { border-color: #55445d; }
.props-row.enabled { border-color: var(--mx-acid); }
.props-row.mixed { border-color: var(--mx-cyan); }

.props-row-header {
  min-height: 52px;
  padding: 10px 12px;
  align-items: flex-start;
  gap: 11px;
  color: var(--mx-paper);
  font-size: 10px;
  line-height: 1.45;
}

.props-row-header input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  margin: 1px 0 0;
}

.props-row-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
  flex: 1;
}

.props-row-label {
  color: var(--mx-paper);
  font: 400 10px/1.4 var(--mx-ui);
  letter-spacing: normal;
}

.props-row-desc {
  color: var(--mx-muted);
  font: 400 8px/1.55 var(--mx-ui);
  letter-spacing: normal;
  overflow-wrap: anywhere;
}

.props-row.enabled .props-row-header .props-row-desc,
.props-row.mixed .props-row-header .props-row-desc { color: var(--mx-muted); }

.props-mixed {
  align-self: center;
  color: var(--mx-cyan);
  font: 400 7px/1.3 var(--mx-mono);
  letter-spacing: normal;
}

.props-fields {
  padding: 0 12px 12px 43px;
  gap: 10px;
}

.props-field > label {
  color: var(--mx-muted);
  font: 400 8px/1.45 var(--mx-ui);
  letter-spacing: normal;
}

.props-field select,
.props-range input[type="range"] { min-width: 0; }

.props-field select {
  min-height: 40px;
  padding: 7px 9px;
  border: 1px solid #4b424f;
  border-radius: 3px;
  background: #09080b;
  color: var(--mx-paper);
  font: 400 9px/1.4 var(--mx-ui);
  letter-spacing: normal;
}


.props-val {
  color: var(--mx-acid);
  font: 400 8px/1.4 var(--mx-mono);
  letter-spacing: normal;
}

.props-path-btn {
  min-height: 44px;
  border-color: var(--mx-cyan);
  color: var(--mx-cyan);
}

.props-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 16px 13px;
  border-top: 1px solid var(--mx-line);
  background: #151119;
}

.props-footer > span {
  color: var(--mx-green);
  font: 400 8px/1.4 var(--mx-mono);
  letter-spacing: normal;
}

.props-done {
  min-width: 116px;
  min-height: 44px;
  color: var(--mx-ink);
  border-color: var(--mx-acid);
  background: var(--mx-acid);
}

.path-edit-bar {
  max-width: calc(100vw - 24px);
  padding: 12px 14px;
  border: 1px solid #4b424f;
  background: #121015;
}

.path-edit-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.path-edit-copy strong {
  color: var(--mx-acid);
  font: 400 9px/1.35 var(--mx-ui);
  letter-spacing: normal;
  text-transform: uppercase;
}

.path-edit-copy > span {
  color: var(--mx-paper);
  font: 400 8px/1.5 var(--mx-ui);
  letter-spacing: normal;
  overflow-wrap: anywhere;
}

#path-count {
  color: var(--mx-cyan);
  font: 400 8px/1.4 var(--mx-mono);
  letter-spacing: normal;
}

@media (max-width: 680px) {
  .palette-shell { min-height: 62px; }
  .palette-quick { gap: 6px; padding: 8px; }
  .palette-shell > .tile-palette { padding: 8px 10px; }
  .props-overlay .props-container,
  .props-overlay.open .props-container { max-height: calc(100dvh - 18px); }
  .props-header { min-height: 70px; padding: 12px 14px; }
  .props-context { padding: 11px 14px; }
  .props-list { padding: 12px 12px 7px; }
  .props-fields { padding-left: 12px; }
  .props-footer { padding: 9px 12px 11px; }
  .path-edit-bar { align-items: stretch; }
  .path-edit-actions { width: 100%; }
  .path-edit-actions .tool-btn { flex: 1; min-height: 44px; }
}

@media (min-width: 500px) and (max-height: 430px) {
  .props-overlay .props-container,
  .props-overlay.open .props-container {
    width: min(680px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
  }
  .props-header { min-height: 58px; padding: 9px 14px; }
  .props-kicker { display: none; }
  .props-header h2 { font-size: 16px; }
  .props-context { padding: 7px 14px; }
  #props-intro { display: none; }
  .props-selection-summary { margin-top: 0 !important; font-size: 8px; }
  .props-list { padding-block: 8px 4px; }
  .props-footer { padding-block: 7px; }
  .path-edit-bar { bottom: 8px; flex-direction: row; align-items: center; }
}

/* ── Mobile Safari / installed-web-app platform shell ─────────────────
   `viewport-fit=cover` makes the safe-area variables meaningful. Keep the
   artwork edge-to-edge, but inset the builder controls and canvas HUD actions.
   The percentage fallback serves older iPads; dvh follows Safari's collapsing
   browser chrome on current iOS/iPadOS instead of retaining the legacy 100vh. */
:root {
  --mx-safe-top: env(safe-area-inset-top, 0px);
  --mx-safe-right: env(safe-area-inset-right, 0px);
  --mx-safe-bottom: env(safe-area-inset-bottom, 0px);
  --mx-safe-left: env(safe-area-inset-left, 0px);
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.app {
  width: 100%;
  height: 100%;
  min-height: 100%;
  padding: var(--mx-safe-top) var(--mx-safe-right) var(--mx-safe-bottom) var(--mx-safe-left);
}

@supports (height: 100dvh) {
  html,
  body,
  .app {
    height: 100dvh;
    min-height: 100dvh;
  }
}

.game-overlay {
  width: 100vw;
  width: 100dvw;
  height: 100%;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

@supports (height: 100dvh) {
  .game-overlay { height: 100dvh; }
}

#grid-canvas,
#game-canvas,
.lobby-runner-canvas {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

:where(button, a[href], label[for], summary) {
  touch-action: manipulation;
}

.game-hint {
  bottom: max(24px, calc(var(--mx-safe-bottom) + 12px));
  width: max-content;
  max-width: calc(100% - var(--mx-safe-left) - var(--mx-safe-right) - 24px);
  white-space: normal;
  text-align: center;
}

.game-warning {
  top: max(20px, calc(var(--mx-safe-top) + 10px));
  width: max-content;
  /* Reserve the HUD and Pause corners; the notice stays readable without
     covering either control cluster in phone landscape. */
  max-width: min(720px, calc(100% - var(--mx-safe-left) - var(--mx-safe-right) - 180px));
  white-space: normal;
  text-align: center;
}

@media (max-width: 480px) {
  .game-warning {
    top: max(140px, calc(var(--mx-safe-top) + 130px));
    max-width: calc(100% - var(--mx-safe-left) - var(--mx-safe-right) - 24px);
  }
}

.completion-overlay {
  padding:
    max(12px, var(--mx-safe-top))
    max(12px, var(--mx-safe-right))
    max(12px, var(--mx-safe-bottom))
    max(12px, var(--mx-safe-left));
}

.tile-palette,
.grid-wrapper,
.props-list,
.login-card,
.rankings-container,
.admin-container,
.col-container,
.bg-selector-container,
.mx-dialog,
.mx-dialog__panel {
  -webkit-overflow-scrolling: touch;
}

/* iOS zooms the visual viewport when a focused text control renders below
   16px. Preserve user pinch-zoom while keeping forms stable around the virtual
   keyboard by raising only editable controls on devices that have touch. */
@supports (-webkit-touch-callout: none) {
  @media (any-pointer: coarse) {
    input[type="email"],
    input[type="number"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="text"],
    input[type="url"],
    select,
    textarea {
      font-size: 16px !important;
    }
  }
}

/* In phone landscape the title becomes a full-width two-column stage. Its
   normal 16px gutter is smaller than a notched iPhone's side safe area, so keep
   both columns and their controls out from under the sensor housing. */
@media (min-width: 540px) and (max-height: 560px) {
  .lobby-center {
    padding-left: max(16px, var(--mx-safe-left));
    padding-right: max(16px, var(--mx-safe-right));
  }
}

/* ── Responsive component hardening ────────────────────────────────────
   Overlay padding belongs to the viewport, not the card. This keeps every
   custom surface clear of a phone notch in landscape and gives compact cards
   one predictable scroll boundary. */
@media (any-pointer: coarse) {

  .admin-overlay,
  .bg-selector-overlay,
  .props-overlay,
  .col-overlay,
  .login-overlay {
    padding:
      max(9px, var(--mx-safe-top))
      max(9px, var(--mx-safe-right))
      max(9px, var(--mx-safe-bottom))
      max(9px, var(--mx-safe-left));
  }

  .admin-container,
  .bg-selector-container,
  .props-container,
  .col-container,
  .login-card,
  .rankings-container {
    max-width: 100%;
    max-height: 100%;
  }

  .header-btn,
  .header-btn.icon-only,
  .sidebar-logo,
  .sidebar-icon,
  .tool-btn,
  .set-list-head button,
  .login-secondary {
    min-height: 44px;
  }

  .header-btn.icon-only,
  .header-btn,
  .sidebar-logo,
  .sidebar-icon,
  .tool-btn,
  .set-list-head button {
    min-width: 46px;
  }

  .admin-close,
  .login-close,
  .palette-tile,
  .palette-mode-toggle {
    min-width: 44px;
    min-height: 44px;
  }

  .tileset-card { height: 46px; }
  .tileset-switcher { min-height: 44px; }

  .rankings-filter,
  .rankings-sort,
  .rankings-retry,
  .rankings-board-tab,
  .completion-btn { min-height: 46px; }

  input[type="email"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  input[type="text"],
  input[type="url"],
  select,
  textarea {
    min-height: 44px;
  }

  input[type="range"] {
    height: 44px;
    min-height: 44px;
  }

  .color-palette { grid-template-columns: repeat(4, 44px); gap: 4px; }
  .color-swatch { width: 44px; height: 44px; }
  .collider-grid { grid-template-columns: repeat(5, 44px); }
  .collider-btn { width: 44px; height: 44px; }

  .tiles-top { flex-wrap: wrap; }
  .tiles-top > input[type="text"] {
    width: 100%;
    flex: 1 0 100%;
  }
  .tiles-top > .tool-btn { flex: 1 1 auto; }

  .col-field-check { min-height: 44px; }
  .col-field-check > label {
    min-height: 44px;
    display: flex;
    align-items: center;
    cursor: pointer;
  }
  .col-field-check > input[type="checkbox"] { width: 24px; height: 24px; }

  /* Retain the compact 50×26 switch art inside a full-height hit target. */
  .toggle {
    width: 50px;
    height: 44px;
    min-height: 44px;
    border: 0;
    background: transparent;
  }
  .toggle::before {
    content: "";
    position: absolute;
    inset: 9px 0;
    border: 2px solid var(--mx-line);
    background: #2d2732;
  }
  .toggle.on { background: transparent; }
  .toggle.on::before { background: var(--mx-purple); }
  .toggle .toggle-knob { top: 13px; z-index: 1; }

  /* The onboarding message clears the movement and jump controls instead of
     occupying the same bottom strip during its first three seconds. */
  .game-hint {
    bottom: max(118px, calc(var(--mx-safe-bottom) + 106px));
  }
  [data-touch-layout="joystick"] .game-hint {
    bottom: calc(max(24px, var(--mx-safe-bottom)) + 112px);
  }

  #touch-controls[inert],
  #game-menu[inert],
  #game-hint[inert],
  #game-warning[inert] { visibility: hidden; }
}

/* Background choices are intrinsic-height preview cards. Without an explicit
   auto row, a tall phone distributes the grid's finite height across every
   row and crushes 16:9 canvases into thin strips. */
.bg-grid {
  grid-auto-rows: max-content;
  align-items: start;
}

.bg-option {
  appearance: none;
  width: 100%;
  min-width: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: inherit;
}

.completion-title { overflow-wrap: anywhere; }

.completion-card,
.completion-overlay.open .completion-card {
  transform: none;
  transition: none;
}

/* Navigation changes the visible surface in the same frame as its controls.
   Fading a closed screen leaves its pixels over the next destination, while
   fading Home in briefly exposes the Builder underneath. Keep layout boxes for
   canvas sizing, but remove closed surfaces from paint and focus immediately. */
.lobby,
.game-overlay,
.admin-overlay,
.bg-selector-overlay,
.props-overlay,
.col-overlay,
.login-overlay,
.completion-overlay { transition: none; }

.game-overlay:not(.open),
.admin-overlay:not(.open),
.bg-selector-overlay:not(.open),
.props-overlay:not(.open),
.col-overlay:not(.open),
.login-overlay:not(.open),
.completion-overlay:not(.open) { visibility: hidden; }

/* Modal shells stay flat at their final dimensions from the first frame. A
   scale-in briefly shrank already-small touch targets and recreated the raised
   duplicate-card feel the interface deliberately avoids. */
.admin-overlay .admin-container,
.admin-overlay.open .admin-container,
.bg-selector-overlay .bg-selector-container,
.bg-selector-overlay.open .bg-selector-container,
.props-overlay .props-container,
.props-overlay.open .props-container,
.col-overlay .col-container,
.col-overlay.open .col-container,
.login-overlay .login-card,
.login-overlay.open .login-card {
  transform: none;
  transition: none;
}

@media (max-width: 680px) and (any-pointer: coarse) {
  .admin-container,
  .bg-selector-container,
  .col-container,
  .rankings-container {
    width: 100%;
    height: 100%;
  }

  .col-container.settings-container,
  .col-container.length-container { height: auto; }

  .props-overlay .props-container,
  .props-overlay.open .props-container,
  .login-card,
  .completion-card { width: 100%; }
}

@media (max-width: 340px) {
  .pfp-actions { flex-direction: column; }
  .completion-title { font-size: 26px; }
  .rankings-tier-row strong { font-size: 16px; }
  .rankings-journey-btn { font-size: 14px; }
}

@media (max-width: 680px) and (max-height: 560px) {
  .completion-title { font-size: 28px; }
  /* Four clear actions already teach the paused state. Dropping the redundant
     control reminder keeps the simple pause card scroll-free in phone landscape. */
  .pause-controls { display: none; }
}

@media (max-width: 480px) and (orientation: portrait) {
  /* Phone portrait gets a true palette row. Keeping the tool/mode controls on
     their own compact row prevents the tileset selector from consuming the
     entire terrain viewport before Spawn, Goal, or a paintable tile appears. */
  .palette-shell {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    grid-template-rows: auto auto;
    min-height: 120px;
  }
  .palette-quick {
    grid-column: 1;
    grid-row: 1;
    gap: 4px;
    padding-inline: 6px;
    border-bottom: 2px solid var(--mx-line);
  }
  .palette-mode {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-start;
    padding-inline: 5px;
    border-right: 0;
    border-bottom: 2px solid var(--mx-line);
  }
  .palette-mode-toggle { width: 72px; padding-inline: 4px; }
  .palette-shell > .tile-palette {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-height: 58px;
    gap: 5px;
    padding: 6px;
    -webkit-mask-image: linear-gradient(to right, black 0%, black calc(100% - 18px), transparent 100%);
    mask-image: linear-gradient(to right, black 0%, black calc(100% - 18px), transparent 100%);
  }
  .palette-shell > .tile-palette.scrolled-start {
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 18px, black calc(100% - 18px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 18px, black calc(100% - 18px), transparent 100%);
  }
  .palette-shell > .tile-palette.scrolled-end { -webkit-mask-image: none; mask-image: none; }
  .palette-shell > .tile-palette.scrolled-start.scrolled-end {
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 18px, black 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 18px, black 100%);
  }
  .palette-shell > .tile-palette .tileset-card { width: 120px; overflow: hidden; }
  .palette-shell > .tile-palette .tileset-switcher { gap: 3px; padding-inline: 3px; }
}

@media (max-width: 340px) {
  .palette-shell > .tile-palette .tileset-card { width: 100px; }
  .palette-shell > .tile-palette .tileset-badge .set-count { display: none; }
}

/* The broad coarse-pointer modal rule above lets complex editors use the full
   iPad canvas. Settings is intentionally a compact preference card, so keep its
   reading measure bounded on tablets while still filling a narrow phone. */
#settings-modal > .settings-container {
  width: min(460px, 100%);
  max-width: 460px;
}

#length-modal > .length-container {
  width: min(440px, 100%);
  max-width: 440px;
}

/* ── Builder recovery + touch selection controls ───────────────────── */

#builder-recovery-toggle[hidden],
.builder-recovery[hidden],
.builder-recovery-panel[hidden],
.selection-action-bar[hidden],
#selection-place-btn[hidden] {
  display: none !important;
}

/* Version history lives in a dialog, leaving the canvas unobstructed. */
.builder-recovery {
  min-width: 0;
  color: var(--mx-paper);
  font: 400 8px/1.45 var(--mx-ui);
}

#builder-recovery-summary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.builder-recovery-panel {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

#builder-recovery-copy {
  min-width: 0;
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.builder-recovery-actions {
  width: 100%;
  flex-wrap: wrap;
}

.builder-recovery-actions > button { flex: 1; }

.builder-recovery-actions,
.selection-action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.builder-recovery select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 30px 0 9px;
  border: 2px solid #66596d;
  border-radius: 3px;
  background: #211828;
  color: var(--mx-paper);
  font: 400 8px/1.3 var(--mx-ui);
  text-transform: uppercase;
}

.builder-recovery button,
.selection-action-bar button {
  appearance: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 2px solid #66596d;
  border-radius: 3px;
  background: #211828;
  color: var(--mx-paper);
  box-shadow: none;
  font: 900 8px/1 var(--mx-ui);
  text-transform: uppercase;
  touch-action: manipulation;
  cursor: pointer;
}

.builder-recovery button:hover,
.selection-action-bar button:hover,
.builder-recovery button:focus-visible,
.selection-action-bar button:focus-visible {
  border-color: var(--mx-cyan);
}

#restore-draft-btn,
.selection-action-bar button[aria-pressed="true"],
#selection-place-btn {
  border-color: var(--mx-cyan);
  background: var(--mx-cyan);
  color: var(--mx-ink);
}

.selection-action-bar button:disabled,
.builder-recovery button:disabled {
  opacity: .42;
  cursor: default;
}

/* The action strip is purpose-built for touch/Pencil. Desktop keeps the
   keyboard shortcuts and canvas context without spending vertical space. */
.selection-action-bar {
  display: none;
}

#enemy-facing-bar:not([hidden]) {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--mx-panel, #16131d);
}
.enemy-facing-bar .selection-action-status { min-width: 0; flex: 1; }
.enemy-facing-bar button { min-height: 44px; }

.selection-action-status {
  min-width: min(210px, 42vw);
  color: var(--mx-paper);
  font: 400 8px/1.4 var(--mx-ui);
  text-transform: uppercase;
}

.builder-help-btn > span {
  color: var(--mx-cyan);
  font: 900 13px/1 var(--mx-display);
}

.builder-help-btn[aria-expanded="true"] {
  border-color: var(--mx-cyan);
  background: #111c22;
}

@media (any-pointer: coarse), (max-width: 900px) {
  .selection-action-bar:not([hidden]) {
    min-height: 56px;
    flex: 0 0 auto;
    padding: 6px 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 6px;
    overflow: hidden;
    border-bottom: 2px solid var(--mx-purple);
    background: #100d14;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .selection-action-buttons {
    display: flex;
    min-width: 0;
    max-width: 100%;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }
  .selection-action-buttons > button { flex: 0 0 auto; }
  .selection-action-status { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
}

@media (max-width: 600px) {
  .selection-action-status { min-width: 0; }
}

@media (min-width: 800px) and (max-height: 560px) {
  .selection-action-bar:not([hidden]) {
    grid-template-columns: minmax(180px, 1fr) minmax(0, 2fr);
    align-items: center;
  }
}

/* ── Level projects library ──────────────────────────────────────────── */

.project-conflict-slot { display: contents; }

.project-conflict-recovery {
  min-width: 0;
  min-height: 58px;
  flex: 0 0 auto;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 2px solid var(--mx-coral);
  background: #2b1117;
  color: var(--mx-paper);
}

.project-conflict-recovery[hidden] { display: none !important; }

#projects-conflict-slot .project-conflict-recovery {
  margin-bottom: 16px;
  border: 1px solid #92545b;
  border-left: 3px solid var(--mx-coral);
  border-radius: 3px;
}

.project-conflict-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
  font-family: var(--mx-ui);
  text-transform: uppercase;
}

.project-conflict-copy strong { color: #ffaaa6; font-size: 9px; line-height: 1.35; }
.project-conflict-copy span { color: #d8c8cc; font-size: 7px; line-height: 1.5; }

.project-conflict-actions,
.projects-backup-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.project-conflict-actions { flex-wrap: wrap; }

.project-conflict-actions button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #92545b;
  border-radius: 2px;
  background: #1b1014;
  color: var(--mx-paper);
  font: 900 7px/1.25 var(--mx-ui);
  text-transform: uppercase;
  cursor: pointer;
}

#project-conflict-copy {
  color: var(--mx-ink);
  border-color: var(--mx-acid);
  background: var(--mx-acid);
}

.project-conflict-actions button:hover,
.project-conflict-actions button:focus-visible { border-color: var(--mx-cyan); }

.projects-btn {
  color: var(--mx-cyan);
  border-color: #326779;
  background: #111c22;
}

.projects-btn[aria-expanded="true"] {
  color: var(--mx-ink);
  border-color: var(--mx-cyan);
  background: var(--mx-cyan);
}

.project-header-context {
  flex: 0 1 180px;
  min-width: 84px;
  max-width: 180px;
  padding: 2px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  border-left: 2px solid var(--mx-line);
}

#active-project-name,
#project-save-status {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#active-project-name {
  color: var(--mx-paper);
  font: 900 9px/1.2 var(--mx-ui);
  text-transform: uppercase;
}

#project-save-status {
  color: var(--mx-cyan);
  font: 400 7px/1.2 var(--mx-ui);
  text-transform: uppercase;
}

#project-save-status[data-state="saving"] { color: var(--mx-acid); }
#project-save-status[data-state="error"],
#project-save-status[data-state="conflict"] { color: var(--mx-coral); }

#projects-modal {
  padding:
    max(12px, var(--mx-safe-top))
    max(12px, var(--mx-safe-right))
    max(12px, var(--mx-safe-bottom))
    max(12px, var(--mx-safe-left));
}

#projects-modal > .projects-container {
  width: min(1180px, 100%);
  max-width: 1180px;
  height: 100%;
  max-height: 100%;
  min-height: 0;
}

.projects-header {
  min-width: 0;
  min-height: 86px;
  padding: 12px 16px;
  gap: 12px;
}

.projects-heading {
  flex: 1 1 320px;
  min-width: 0;
}

.projects-eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--mx-cyan);
  font: 900 7px/1 var(--mx-ui);
  text-transform: uppercase;
}

.projects-heading h2 { margin: 0; }

#projects-storage-copy {
  margin: 7px 0 0;
  color: var(--mx-muted);
  font: 400 8px/1.45 var(--mx-ui);
  text-transform: uppercase;
}

#projects-storage-status { color: var(--mx-green); }
#projects-storage-status[data-state="warning"] { color: var(--mx-acid); }
#projects-storage-status[data-state="error"],
#projects-storage-status[data-state="conflict"] { color: var(--mx-coral); }

.projects-header-actions,
.projects-empty-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.projects-header-actions { flex: 0 0 auto; }

.projects-header-actions .tool-btn,
.projects-empty-actions .tool-btn {
  min-height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: 900 8px/1 var(--mx-ui);
  text-transform: uppercase;
}

.projects-new-action {
  color: var(--mx-ink) !important;
  border-color: var(--mx-acid) !important;
  background: var(--mx-acid) !important;
}

.projects-new-action:hover { background: #ffe363 !important; }

.projects-close { flex: 0 0 auto; }

.projects-body {
  min-width: 0;
  min-height: 0;
  flex: 1;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
}

.projects-backup,
.projects-library,
.projects-deleted { min-width: 0; }

.projects-backup {
  margin-bottom: 18px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid #44384b;
  background: #130f17;
}

.projects-backup-copy { min-width: 0; }

.projects-backup h3 {
  margin: 0;
  color: var(--mx-paper);
  font: 900 10px/1.3 var(--mx-display);
  text-transform: uppercase;
}

.projects-backup p {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--mx-muted);
  font: 400 7px/1.5 var(--mx-ui);
  text-transform: uppercase;
}

.projects-backup-actions .tool-btn {
  min-height: 44px;
  padding: 0 12px;
  font: 900 7px/1.2 var(--mx-ui);
  text-transform: uppercase;
}

.projects-section-head {
  min-height: 32px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.projects-section-head h3 {
  margin: 0;
  color: var(--mx-paper);
  font: 900 12px/1.2 var(--mx-display);
  text-transform: uppercase;
}

.projects-section-head > span,
.projects-section-head p {
  margin: 4px 0 0;
  color: var(--mx-muted);
  font: 400 7px/1.35 var(--mx-ui);
  text-transform: uppercase;
}

.projects-list,
.projects-deleted-list {
  min-width: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
  gap: 12px;
  list-style: none;
}

.projects-list > li,
.projects-deleted-list > li,
.project-card {
  min-width: 0;
  border: 2px solid var(--mx-line);
  border-radius: 3px;
  background: var(--mx-panel-2);
  overflow: hidden;
}

.project-card[data-active="true"] { border-color: var(--mx-cyan); }

.project-card-open {
  appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 132px;
  padding: 0;
  display: grid;
  grid-template-rows: auto auto;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.project-card-preview {
  width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 8 / 5;
  overflow: hidden;
  border-bottom: 1px solid var(--mx-line);
  background: #100d14;
}

.project-card-preview canvas,
.project-card-preview img {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.project-card-copy {
  min-width: 0;
  padding: 11px;
  display: grid;
  gap: 7px;
}

.project-card-name {
  min-width: 0;
  overflow: hidden;
  color: var(--mx-paper);
  font: 900 10px/1.3 var(--mx-ui);
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.project-card-meta,
.project-card-status {
  color: var(--mx-muted);
  font: 400 7px/1.4 var(--mx-ui);
  text-transform: uppercase;
}

.project-card-status { color: var(--mx-cyan); }

.project-card-actions,
.project-card-manage button {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.project-card-actions {
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
  border: 0;
  border-top: 1px solid var(--mx-line);
  background: #17121c;
  color: var(--mx-paper);
  font: 900 8px/1 var(--mx-ui);
  text-transform: uppercase;
  cursor: pointer;
}

.project-card-actions[aria-expanded="true"] {
  color: var(--mx-cyan);
  background: #211a28;
}

.project-card-manage {
  min-width: 0;
  padding: 7px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  border-top: 1px solid var(--mx-line);
  background: #100d14;
}

.project-card-manage[hidden] { display: none !important; }

.project-card-manage button {
  min-width: 0;
  min-height: 40px;
  padding: 6px;
  overflow: hidden;
  border: 1px solid #4b4052;
  border-radius: 2px;
  background: #1b1520;
  color: var(--mx-paper);
  font: 900 7px/1 var(--mx-ui);
  text-overflow: ellipsis;
  text-transform: uppercase;
  cursor: pointer;
}

.project-card-manage button:hover,
.project-card-manage button:focus-visible {
  border-color: var(--mx-cyan);
  color: var(--mx-cyan);
}

.project-card-manage button.danger { color: var(--mx-coral); }

.project-card-manage .project-delete-action {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding: 10px;
  border-color: #69404a;
  background: #21131b;
}

.project-card-manage button.danger:hover,
.project-card-manage button.danger:focus-visible {
  color: var(--mx-coral);
  border-color: var(--mx-coral);
  background: #321b26;
}

.project-card--deleted .project-card-manage {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.projects-empty {
  min-height: min(420px, 52dvh);
  padding: 36px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  border: 2px dashed #4c4252;
  background: #130f17;
  text-align: center;
}

.projects-empty[hidden],
.projects-deleted[hidden] { display: none !important; }

.projects-empty-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  color: var(--mx-cyan);
  border: 2px solid var(--mx-line);
  background: var(--mx-panel-2);
}

.projects-empty h3 {
  margin: 4px 0 0;
  color: var(--mx-paper);
  font: 900 18px/1 var(--mx-display);
  text-transform: uppercase;
}

.projects-empty p {
  max-width: 430px;
  margin: 0 0 4px;
  color: var(--mx-muted);
  font: 400 8px/1.6 var(--mx-ui);
  text-transform: uppercase;
}

.projects-deleted {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 2px solid var(--mx-line);
}

.projects-legacy-recovery > summary {
  min-height: 44px;
  padding: 12px 8px;
  color: var(--mx-muted);
  font: 400 8px/1.5 var(--mx-ui);
  cursor: pointer;
}

.projects-legacy-recovery > summary:hover,
.projects-legacy-recovery > summary:focus-visible {
  color: var(--mx-cyan);
}

.projects-legacy-recovery > summary > span + span {
  margin-left: 12px;
  white-space: nowrap;
}

.projects-legacy-recovery > p {
  margin: 0 8px 14px;
  max-width: 640px;
  color: var(--mx-muted);
  font: 400 7px/1.7 var(--mx-ui);
}

@media (max-width: 1100px) {
  .project-header-context + .builder-title { display: none; }
}

@media (max-width: 680px) {
  #projects-modal {
    padding:
      max(7px, var(--mx-safe-top))
      max(7px, var(--mx-safe-right))
      max(7px, var(--mx-safe-bottom))
      max(7px, var(--mx-safe-left));
  }

  #projects-modal > .projects-container {
    width: 100%;
    height: 100%;
  }

  .project-header-context {
    flex: 0 1 104px;
    min-width: 64px;
    max-width: 104px;
    padding: 2px 5px;
    display: flex;
    gap: 2px;
  }

  #active-project-name { font-size: 8px; }
  #project-save-status { font-size: 6px; }

  .projects-header {
    min-height: 0;
    padding: 10px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: start;
    gap: 9px;
  }

  .projects-heading { grid-column: 1; grid-row: 1; }
  .projects-close { grid-column: 2; grid-row: 1; }
  .projects-header-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }
  .projects-header-actions .tool-btn { flex: 1; }

  .projects-body { padding: 12px; }
  .projects-backup { align-items: stretch; flex-direction: column; gap: 10px; }
  .projects-backup-actions .tool-btn { flex: 1; }
  .projects-list,
  .projects-deleted-list { grid-template-columns: minmax(0, 1fr); }

  .project-card-open {
    min-height: 100px;
    grid-template-columns: min(42vw, 192px) minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: start;
  }

  .project-card-preview {
    min-height: 0;
    align-self: start;
    border-right: 1px solid var(--mx-line);
    border-bottom: 0;
  }

  .projects-empty { min-height: 0; padding: 30px 14px; }

  .project-card-manage { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .project-conflict-recovery { align-items: stretch; flex-direction: column; gap: 8px; }
  .project-conflict-actions { width: 100%; }
  .project-conflict-actions button { flex: 1; }
}

/* On narrow phones the project context and fixed Publish / Play actions leave
   less than one touch target for the scrolling edit toolbar. Keep identity on
   the first row, then give the edit rail and primary actions a full second row. */
@media (max-width: 420px) {
  .header { flex-wrap: wrap; }

  .header-actions {
    order: 1;
    flex: 1 1 calc(100% - 100px);
    width: auto;
  }

  .header-primary-actions { order: 2; }
}

@media (max-width: 360px) {
  .project-header-context {
    flex-basis: 82px;
    min-width: 54px;
    max-width: 82px;
    padding-inline: 4px;
  }

  #projects-storage-copy { line-height: 1.35; }
  .projects-empty-actions { width: 100%; flex-direction: column; }
  .projects-empty-actions .tool-btn { width: 100%; }
}

/* Short landscape preserves a compact header and two useful project columns
   while the library body owns the only vertical scroll boundary. */
@media (min-width: 481px) and (max-height: 560px) {
  #projects-modal {
    padding:
      max(5px, var(--mx-safe-top))
      max(5px, var(--mx-safe-right))
      max(5px, var(--mx-safe-bottom))
      max(5px, var(--mx-safe-left));
  }

  .projects-header {
    min-height: 52px;
    padding: 5px 8px;
    gap: 8px;
  }

  .projects-eyebrow,
  #projects-storage-copy { display: none; }
  .projects-heading { flex-basis: auto; }
  .projects-heading h2 { font-size: 18px; }
  .projects-header-actions .tool-btn { min-height: 44px; padding-inline: 10px; }
  .projects-body { padding: 8px; }
  .projects-section-head { min-height: 24px; margin-bottom: 7px; }
  .projects-list,
  .projects-deleted-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .projects-empty {
    min-height: 0;
    padding: 14px;
    gap: 8px;
  }
  .projects-empty-mark { display: none; }
  .projects-empty h3 { font-size: 15px; }
  .projects-empty p { line-height: 1.35; }
}

.project-boot-barrier {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  color: var(--mx-paper, #f7f4eb);
  background: rgba(4, 8, 12, 0.94);
  text-align: center;
}

.project-boot-barrier[hidden] { display: none; }

.project-boot-barrier__panel {
  width: min(420px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: clamp(24px, 7vw, 42px);
  border: 1px solid var(--mx-line, rgba(255, 255, 255, 0.24));
  border-radius: 18px;
  background: var(--mx-panel, #111820);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.55);
}

.project-boot-barrier__mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  color: #071015;
  background: var(--accent, #8df5b5);
  font: 900 28px/1 var(--font-display, system-ui, sans-serif);
}

.project-boot-barrier__panel strong {
  font: 800 clamp(19px, 5vw, 25px)/1.15 var(--font-display, system-ui, sans-serif);
}

.project-boot-barrier__panel p {
  max-width: 34em;
  margin: 0;
  color: var(--mx-muted, #aebbc5);
  line-height: 1.5;
}

.project-boot-barrier__panel .tool-btn { min-height: 44px; }

@media (any-pointer: coarse) {
  .projects-header-actions .tool-btn,
  .projects-empty-actions .tool-btn,
  .projects-close,
  .project-card-actions,
  .project-card-open,
  .project-card-manage button { min-height: 44px; }
}

/* Journey feedback is a voluntary, correctable decision. These final cascade
   rules keep the words readable, preserve native [hidden] semantics against
   flex layouts, and give pause-time skip reasons their own status surface. */
.completion-feedback[hidden],
.pause-actions[hidden],
.pause-skip-panel[hidden],
.pause-terminal-status[hidden],
#rating-status[hidden] { display: none !important; }

.completion-feedback { margin: 14px 0 4px; }
.completion-feedback-title,
.completion-feedback-help,
.pause-skip-help {
  margin: 0;
  font-family: var(--mx-pixel);
  line-height: 1.5;
}
.completion-feedback-title { color: var(--mx-paper); font-size: 10px; }
.completion-feedback-help { margin-top: 7px; color: var(--mx-muted); font-size: 8px; }
.completion-rating { gap: 10px; margin: 9px 0 0; }
.completion-rate-btn {
  width: auto;
  min-width: 112px;
  height: 52px;
  padding: 8px 14px;
  gap: 9px;
  border-radius: 3px;
  font: 400 10px/1 var(--mx-pixel);
  text-transform: uppercase;
}
.completion-rate-btn svg { flex: 0 0 auto; width: 22px; height: 22px; }
.completion-rate-btn[aria-pressed="true"] { color: var(--mx-ink); border-color: var(--mx-green); background: var(--mx-green); }
.completion-rate-btn.pending { opacity: .72; }
.rating-status { max-width: 390px; margin-inline: auto; }
.rating-status.info { color: var(--mx-cyan); }
.rating-status.warn { color: var(--mx-acid); }

.completion-btn-skip { color: var(--mx-cyan); border-color: var(--mx-cyan); }
.completion-btn-skip:hover { color: var(--mx-ink); background: var(--mx-cyan); }
.pause-skip-panel {
  display: flex;
  width: min(340px, calc(100vw - 52px));
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 14px;
}
.pause-skip-help { color: var(--mx-muted); font-size: 11px; text-align: left; }
.pause-skip-reasons { display: grid; grid-template-columns: 1fr; gap: 8px; }
.pause-skip-reasons .completion-btn,
.pause-skip-cancel,
.pause-report { width: 100%; min-height: 44px; }
.pause-skip-status {
  min-height: 20px;
  color: var(--mx-muted);
  font: 400 11px/1.5 var(--mx-pixel);
  text-align: left;
}
.pause-skip-status.info { color: var(--mx-cyan); }
.pause-skip-status.ok { color: var(--mx-green); }
.pause-skip-status.warn { color: var(--mx-acid); }
.pause-skip-status.err { color: var(--mx-coral); }
.pause-terminal-status {
  width: min(390px, calc(100vw - 52px));
  margin: 4px 0 16px;
  color: var(--mx-acid);
  font: 400 11px/1.6 var(--mx-pixel);
  text-align: left;
}

@media (max-width: 420px) {
  .completion-rating { width: 100%; }
  .completion-rate-btn { min-width: 0; flex: 1 1 0; padding-inline: 9px; }
  .pause-skip-panel { width: min(100%, calc(100vw - 36px)); }
}

@media (min-width: 540px) and (max-height: 560px) {
  #completion-overlay:not(.local-playtest-completion) .completion-rate-btn {
    width: auto;
    min-width: 104px;
    height: 46px;
  }
  #pause-overlay .pause-card {
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  #pause-overlay .pause-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    min-width: 0;
  }
  #pause-overlay .pause-resume,
  #pause-overlay #pause-exit:last-child { grid-column: 1 / -1; }
  #pause-overlay .pause-skip-panel { width: min(430px, calc(100vw - 50px)); }
  #pause-overlay .pause-skip-reasons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Shared pixel controls. The source selects keep form/state semantics; their
   visible pickers use the same surfaces on desktop, touch and hybrid devices. */
.mx-select { position: relative; min-width: 0; }
.mx-select > select[hidden] { display: none !important; }
.mx-select-trigger, .mx-select-option { -webkit-tap-highlight-color: transparent; }
button.mx-select-trigger {
  appearance: none; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; width: 100%; min-width: 0; min-height: 44px; padding: 10px;
  border: 1px solid var(--mx-line); border-radius: 0; background: #211828;
  color: var(--mx-paper); font: 400 9px/1.7 var(--mx-pixel); text-align: left;
  text-transform: none; letter-spacing: normal; box-shadow: none; cursor: pointer;
  touch-action: manipulation;
}
button.mx-select-trigger:hover:not(:disabled) { background: #2b2033; border-color: #806b8a; }
button.mx-select-trigger[aria-expanded="true"] { border-color: var(--mx-cyan); background: #14272c; }
button.mx-select-trigger:disabled { opacity: .4; cursor: default; }
.mx-select-value { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; flex: 1; min-width: 0; }
.mx-select-label { min-width: 0; overflow-wrap: anywhere; }
.mx-select-meta { align-self: start; color: var(--mx-cyan); white-space: nowrap; font-size: 7px; line-height: 2; }
.mx-select-description { grid-column: 1 / -1; color: var(--mx-muted); font-size: 8px; }
.mx-select-chevron {
  flex: 0 0 10px; width: 10px; height: 6px; background: var(--mx-muted);
  clip-path: polygon(0 0, 100% 0, 100% 33%, 80% 33%, 80% 66%, 60% 66%, 60% 100%, 40% 100%, 40% 66%, 20% 66%, 20% 33%, 0 33%);
}
[aria-expanded="true"] > .mx-select-chevron { transform: rotate(180deg); background: var(--mx-cyan); }
.mx-select-list {
  position: fixed; inset: auto; z-index: 10000; margin: 0; padding: 4px;
  border: 2px solid #66526f; border-radius: 0; background: #151119;
  color: var(--mx-paper); font: 400 9px/1.7 var(--mx-pixel);
  box-shadow: none; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: #66526f #151119;
}
.mx-select-list[hidden] { display: none !important; }
.mx-select-list::backdrop { background: transparent; pointer-events: none; }
.mx-select-option {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 8px; min-height: 44px; align-content: center; padding: 10px 10px 10px 14px;
  border: 1px solid transparent; border-radius: 0; cursor: pointer; touch-action: pan-y;
}
.mx-select-option + .mx-select-option { border-top-color: #302535; }
.mx-select-option[aria-selected="true"] { color: var(--mx-cyan); background: #14272c; }
.mx-select-option[aria-selected="true"]::before {
  content: ''; position: absolute; inset: 10px auto 10px 3px; width: 3px; background: var(--mx-cyan);
}
.mx-select-option[data-active="true"] { background: #302238; border-color: #806b8a; }
.mx-select-option[aria-disabled="true"] { opacity: .4; cursor: default; }
@media (hover: hover) {
  .mx-select-option:hover:not([aria-disabled="true"]) { background: #302238; }
}
.scenery-pack-picker > label { color: var(--mx-muted); text-transform: uppercase; }
.scenery-pack-picker .mx-select-trigger { background: #100d14; }
.scenery-size-buttons .mx-select { width: 80px; }
.scenery-size-buttons .mx-select-trigger { font-size: 12px; justify-content: center; }
.scenery-depth-controls .mx-select { width: 100%; }
.props-field > .mx-select { flex: 1; min-width: 0; }
.builder-recovery-actions > .mx-select { flex: 1 1 100%; min-width: 0; max-width: 100%; }
.scenery-browser, .scenery-tools { scrollbar-width: thin; scrollbar-color: #66526f #100d14; }
.scenery-options label { min-height: 44px; cursor: pointer; }
.scenery-tint-row input[type="color"] { appearance: none; border-radius: 0; }
.scenery-tint-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.scenery-tint-row input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 0; }
.scenery-tint-row input[type="color"]::-moz-color-swatch { border: 0; border-radius: 0; }

/* Keep native slider/checkbox input semantics while giving their visible art
   the same square geometry as the rest of the Builder. */
:is(.scenery-depth-controls, .props-range, .enemy-slider, .length-body) input[type="range"] {
  appearance: none; -webkit-appearance: none; height: 32px; min-height: 32px;
  border: 0; border-radius: 0; background: transparent; cursor: pointer;
}
:is(.scenery-depth-controls, .props-range, .enemy-slider, .length-body) input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border: 1px solid #66526f; border-radius: 0; background: #302535;
}
:is(.scenery-depth-controls, .props-range, .enemy-slider, .length-body) input[type="range"]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 14px; height: 18px; margin-top: -7px;
  border: 2px solid #14272c; border-radius: 0; background: var(--mx-cyan);
}
:is(.scenery-depth-controls, .props-range, .enemy-slider, .length-body) input[type="range"]::-moz-range-track {
  height: 4px; border: 1px solid #66526f; border-radius: 0; background: #302535;
}
:is(.scenery-depth-controls, .props-range, .enemy-slider, .length-body) input[type="range"]::-moz-range-thumb {
  width: 10px; height: 14px; border: 2px solid #14272c; border-radius: 0; background: var(--mx-cyan);
}
:is(.scenery-options, .props-row-header, .col-field-check) input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; display: inline-grid; place-content: center;
  width: 20px; height: 20px; border: 1px solid #806b8a; border-radius: 0;
  background: #100d14; flex-shrink: 0; cursor: pointer;
}
:is(.scenery-options, .props-row-header, .col-field-check) input[type="checkbox"]::before {
  content: ''; width: 12px; height: 12px; background: var(--mx-cyan); visibility: hidden;
  clip-path: polygon(0 33%, 25% 33%, 25% 58%, 42% 58%, 42% 42%, 58% 42%, 58% 25%, 75% 25%, 75% 8%, 100% 8%, 100% 42%, 83% 42%, 83% 58%, 67% 58%, 67% 75%, 50% 75%, 50% 92%, 25% 92%, 25% 75%, 0 75%);
}
:is(.scenery-options, .props-row-header, .col-field-check) input[type="checkbox"]:checked::before { visibility: visible; }
:is(.scenery-options, .props-row-header, .col-field-check) input[type="checkbox"]:indeterminate::before {
  visibility: visible; clip-path: none; height: 3px;
}
@media (any-pointer: coarse) {
  :is(.scenery-depth-controls, .props-range, .enemy-slider, .length-body) input[type="range"] { height: 44px; min-height: 44px; }
}
@media (forced-colors: active) {
  .mx-select-option[aria-selected="true"] { border-color: Highlight; }
  .mx-select-option[data-active="true"] { border-style: dashed; border-color: Highlight; }
  .mx-select-chevron, :is(.scenery-options, .props-row-header, .col-field-check) input[type="checkbox"]::before { background: ButtonText; }
}

/* Settings explain the controls on every input type and keep the choices
   usable in a short landscape viewport or when text is enlarged. */
.settings-container { max-width: 560px; max-height: calc(100dvh - 24px); }
.settings-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.settings-key { font-size: 10px; line-height: 1.7; }
.settings-hint { font-size: 8px; line-height: 1.8; overflow-wrap: anywhere; }
.settings-motion { width: min(270px, 65%); min-width: 0; }
.settings-motion .settings-hint { margin-top: 8px; text-align: left; }
.settings-controls { padding: 16px 0; border-bottom: 1px solid var(--mx-line); }
.settings-controls h3 { font-size: 10px; line-height: 1.7; margin-bottom: 12px; }
.settings-guide { margin-bottom: 12px; border: 1px solid var(--mx-purple); color: var(--mx-paper); background: var(--mx-panel); text-align: left; }
.settings-guide summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 9px 12px; cursor: pointer; list-style: none; font: 12px/1.65 var(--mx-pixel); }
.settings-guide summary::-webkit-details-marker { display: none; }
.settings-guide summary::after { content: ''; width: 8px; height: 8px; flex: none; margin-right: 3px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.settings-guide[open] > summary::after, .settings-guide details[open] > summary::after { transform: rotate(225deg); }
.settings-guide > summary { min-height: 52px; color: var(--mx-paper); background: var(--mx-purple-deep); }
.settings-guide > details { border-top: 1px solid var(--mx-line); }
.settings-guide details > summary { color: var(--mx-cyan); }
.settings-guide p, .settings-guide .guide-bindings { margin: 0; padding: 0 12px 14px; font: 12px/1.9 var(--mx-pixel); overflow-wrap: anywhere; }
.settings-guide .guide-start { padding-top: 14px; }
.settings-guide strong, .guide-bindings dd { color: var(--mx-acid); }
.guide-bindings > div { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.1fr); gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--mx-line); }
.guide-bindings dd { margin: 0; }
.settings-guide a, .settings-body > .settings-hint a { display: inline-block; align-content: center; min-height: 44px; padding: 6px 12px; color: var(--mx-cyan); font: 11px/1.8 var(--mx-pixel); }
.col-field-help { color: var(--mx-muted); font-size: 8px; line-height: 1.7; overflow-wrap: anywhere; }
#collectables-edit .col-field > label { width: 6.5em; }
#collectables-edit .col-field > input { min-width: 0; }
.set-item-select {
  appearance: none; display: flex; align-items: center; gap: 8px; flex: 1;
  min-width: 0; min-height: 44px; padding: 4px; border: 0; border-radius: 0;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
button.tile-thumb { appearance: none; padding: 0; font: inherit; }
.collectable-place-btn { min-height: 44px; width: 100%; margin-top: 12px; border-color: var(--mx-cyan); color: var(--mx-cyan); }
#rankings-progress-retry {
  min-height: 44px; margin-bottom: 8px; border-color: var(--mx-cyan);
  background: #151119; color: var(--mx-cyan);
}
#rankings-progress-retry:hover { background: #14272c; }
.touch-btn { border-radius: 0; background: #151119; transition: background .1s ease; }
.touch-btn.pressed { transform: none; background: #713574; border-color: var(--mx-cyan); }
.touch-jump { background: var(--mx-acid); }
.touch-jump.pressed { background: var(--mx-cyan); border-color: var(--mx-cyan); }

/* The in-game preference can reduce decorative motion without changing the
   user's OS setting. Simulation, input and camera tracking are unaffected. */
html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0s !important;
  scroll-behavior: auto !important;
}
@media (max-width: 480px) {
  #collectables-modal .col-header { gap: 8px; }
  #collectables-title { font-size: clamp(12px, 3.5vw, 16px); overflow-wrap: normal; }
  .settings-body { padding-inline: 16px; }
  .settings-row { gap: 10px; }
  .settings-key { font-size: 9px; }
}

/* Both device and in-game reduction keep every stat reachable in the existing
   rail. Hidden scrollbars preserve its height and the runner's ground line. */
#lobby-holder-stats[data-static="false"] {
  /* Cancel an in-flight touch scroll when automatic motion is restored. */
  overflow: clip;
}
#lobby-holder-stats[data-static="true"] {
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  scroll-behavior: auto;
}
#lobby-holder-stats[data-static="true"]::-webkit-scrollbar { display: none; }
#lobby-holder-stats[data-static="true"] .lobby-stats-track {
  width: max-content;
  min-width: 100%;
  animation: none !important;
  transform: none !important;
  will-change: auto;
}
#lobby-holder-stats[data-static="true"] .lobby-stats-set {
  width: auto;
  min-width: 0;
  flex: 1 0 auto;
}
#lobby-holder-stats[data-static="true"] .lobby-stats-set[aria-hidden="true"] { display: none; }
html[data-input-modality="keyboard"] #lobby-holder-stats[data-static="true"]:focus-visible {
  box-shadow: inset 0 -2px 0 var(--mx-cyan);
}

/* Decorations use one scrollable workspace at a time. Browsing never competes
   with disabled editing controls, and an expanded Backgrounder remains within
   the same reachable editing area on desktop and touch screens. */
.scenery-library [hidden] { display: none !important; }
.scenery-heading { flex: 0 0 auto; padding: 6px 10px; }
.scenery-heading h2 { font-size: 11px; }
.scenery-views { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 7px 10px; flex: 0 0 auto; }
.scenery-views button,
.scenery-footer button,
#scenery-clear-filters {
  min-height: 40px; padding: 7px; border: 1px solid var(--mx-line);
  background: #211828; font-size: 8px; line-height: 1.5; cursor: pointer;
}
.scenery-views button[aria-pressed="true"] { color: var(--mx-cyan); border-color: var(--mx-cyan); background: #112128; }
.scenery-views button:disabled { opacity: .4; cursor: default; }
#scenery-status { flex: 0 0 auto; min-height: 0; margin: 0; padding: 2px 10px 8px; font-size: 7px; line-height: 1.7; }
.scenery-browser { padding-top: 4px; }
#scenery-folders { display: flex; flex-wrap: wrap; gap: 4px; }
#scenery-folders button { flex: 1 0 auto; gap: 8px; min-height: 36px; padding: 6px; }
.scenery-filter-status { display: flex; align-items: center; justify-content: space-between; gap: 5px; padding-block: 7px; }
.scenery-results { min-height: 0; padding: 0; }
#scenery-clear-filters { min-height: 36px; font-size: 7px; }
.scenery-card { justify-content: flex-start; }
.scenery-card canvas { width: 100%; height: 128px; object-fit: contain; }
.scenery-card span { min-height: 30px; display: flex; align-items: center; justify-content: center; }
.scenery-tools { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--mx-line); }
#scenery-edit-empty { color: var(--mx-muted); padding: 8px 0; line-height: 1.9; }
.scenery-footer { flex: 0 0 auto; padding: 7px 10px; border-top: 1px solid var(--mx-line); display: flex; align-items: center; gap: 8px; background: #100d14; }
.scenery-footer button { flex: 0 0 112px; }
.scenery-footer .scenery-help { margin: 0; font-size: 6px; line-height: 1.8; }
@media (max-width: 900px) {
  .scenery-library { height: min(78dvh, 760px); }
  .scenery-library[data-collapsed="true"] { height: 36dvh; max-height: 36dvh; overflow: hidden; }
  .scenery-library[data-collapsed="true"] .scenery-heading { display: none; }
  .scenery-library[data-collapsed="true"] .scenery-views { padding: 4px 8px; }
  .scenery-library[data-collapsed="true"] #scenery-status { padding: 0 8px 4px; font-size: 6px; }
  .scenery-library[data-collapsed="true"] .scenery-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scenery-library[data-collapsed="true"] .scenery-footer { padding: 4px 8px; }
  .scenery-library[data-collapsed="true"] .scenery-footer .scenery-help { display: block; }
  .scenery-views button, .scenery-footer button, #scenery-clear-filters,
  #scenery-folders button, .scenery-actions button { min-height: 44px; }
}

/* A failed thumbnail remains an explicitly labelled, selectable background;
   its separate Retry action never changes the level selection or Undo history. */
.bg-choice { min-width: 0; }
.bg-choice .bg-option { position: relative; }
.bg-preview-status { position: absolute; top: 8px; left: 8px; right: 8px; padding: 7px; background: #100d14; color: var(--mx-paper); font-size: 8px; line-height: 1.8; text-align: center; }
.bg-preview-status[hidden], .bg-preview-retry[hidden] { display: none !important; }
.bg-preview-retry { width: 100%; min-height: 44px; padding: 8px; border: 1px solid var(--mx-cyan); background: #112128; color: var(--mx-cyan); font: inherit; font-size: 8px; cursor: pointer; }

.scenery-categories { margin-top: 8px; border: 1px solid var(--mx-line); }
.scenery-categories summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px; font-size: 8px; cursor: pointer; list-style: none; }
.scenery-categories summary::-webkit-details-marker { display: none; }
.scenery-categories summary::before { content: '▸'; color: var(--mx-cyan); }
.scenery-categories[open] summary::before { content: '▾'; }
#scenery-category-count { margin-left: auto; color: var(--mx-muted); }
.scenery-categories #scenery-folders { margin: 0; padding: 4px; border-top: 1px solid var(--mx-line); }
@media (max-width: 900px) {
  .scenery-library:not([data-collapsed="true"]) { height: min(90dvh, 760px); }
}
@media (max-width: 900px) and (max-height: 650px) {
  .scenery-library:not([data-collapsed="true"]) { height: 100dvh; }
}

.bg-option.selected { border-color: var(--mx-cyan); }
.bg-option.selected .bg-option-label { color: var(--mx-cyan); }
@media (max-width: 900px) {
  .scenery-library[data-collapsed="true"] .scenery-heading { display: contents; }
  .scenery-library[data-collapsed="true"] .scenery-heading h2 { display: none; }
  .scenery-library[data-collapsed="true"] .scenery-heading button { position: absolute; right: 4px; top: 4px; width: 44px; height: 44px; }
  .scenery-library[data-collapsed="true"] .scenery-views { padding-right: 52px; }
}
/* Reviewed open tile variants share the existing theme, with explicit roles
   and a neutral transparency swatch that never enters exported artwork. */
.tile-group-jump {
  flex: 0 0 auto; min-height: 44px; max-width: 132px; padding: 8px;
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  border: 1px solid var(--mx-line, #46394c); border-radius: 2px;
  background: var(--mx-panel, #1b1620); color: var(--mx-cyan, #6fe6d2);
  font: inherit; font-size: 8px; line-height: 1.6; cursor: pointer;
}
.tile-group-jump:focus-visible { outline: none; box-shadow: inset 0 -3px 0 var(--mx-cyan, #6fe6d2); }
.palette-open-label { flex: 0 0 80px; padding: 4px 8px; color: #c2b8c9; font-size: 8px; line-height: 1.8; }
.admin-open-jump { margin-right: calc(100% - 132px); }
.admin-open-label { flex: 0 0 100%; margin: 6px 0 2px; font-size: 8px; line-height: 1.8; color: #c2b8c9; }
.open-detail-tile canvas {
  background-color: #535663;
  background-image: conic-gradient(#6b6f7c 25%, transparent 0 50%, #6b6f7c 0 75%, transparent 0);
  background-size: 16px 16px;
}

/* Taller worlds share the existing compact size dialog. */
.height-readout { margin-top: 24px; }
/* Character selection uses the same square pixel controls as the lobby. */
.menu-characters { color: var(--mx-paper, #f5f2ea); border-color: var(--mx-cyan, #56dfde); }
.menu-characters .menu-ico { transform: translateY(-7px); }
/* The idle frames have transparent headroom above the visible character. */
.menu-characters .menu-ico img { width: 48px; height: 48px; object-fit: contain; image-rendering: pixelated; transform: translateY(-17.5%); }
.characters-container { width: min(640px, calc(100vw - 24px)); height: auto; max-height: calc(100dvh - 24px); overflow-y: auto; background: #17131c; border-radius: 0; box-shadow: none; }
.characters-container .col-header h2 { font-size: 18px; line-height: 1.6; }
.characters-container .admin-close { min-width: 44px; min-height: 44px; }
.characters-body { padding: 20px; }
.characters-body p { font-size: 11px; line-height: 1.8; }
.character-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.character-choice { position: relative; display: grid; grid-template-rows: 1fr auto; gap: 12px; min-width: 0; padding: 18px 8px 14px; border: 2px solid #555363; background: #14151e; color: #f5f2ea; font: inherit; cursor: pointer; }
.character-choice-portrait { display: grid; place-items: end center; min-height: 160px; background: #1d1b28; }
.character-choice img { width: 144px; height: 144px; max-width: 100%; object-fit: contain; image-rendering: pixelated; }
.character-choice-name { font-size: 12px; line-height: 1.6; }
.character-choice-state { position: absolute; top: 8px; right: 8px; display: grid; place-items: center; width: 24px; height: 24px; background: #56dfde; color: #10131c; }
.character-choice-state[hidden] { display: none; }
@media (hover: hover) { .character-choice:hover { border-color: #b9afcb; } }
.character-choice[aria-pressed="true"] { border-color: #56dfde; background: #163135; }
.character-choice[aria-pressed="true"] .character-choice-portrait { background: #194047; }
.character-choice[aria-pressed="true"] .character-choice-name { color: #7eeee8; }
.character-choice:focus-visible, #characters-close:focus-visible { outline: 3px solid #56dfde; outline-offset: 3px; }
.character-status { margin: 16px 0 0; color: #c9c8d4; }
.character-status:empty { display: none; }
@media (max-width: 480px) {
  .characters-body { padding: 12px; }
  .characters-container .col-header h2 { font-size: 15px; }
  .character-choices { gap: 8px; }
  .character-choice { padding: 14px 4px 12px; gap: 10px; }
  .character-choice-portrait { min-height: 112px; }
  .character-choice img { width: 96px; height: 96px; }
  .character-choice-name { font-size: 9px; }
  .character-choice-state { top: 5px; right: 5px; width: 20px; height: 20px; }
}
@media (max-width: 360px) {
  .character-choice-portrait { min-height: 88px; }
  .character-choice img { width: 72px; height: 72px; }
  .character-choice-name { font-size: 8px; }
}
@media (max-height: 560px) and (min-width: 540px) {
  .lobby-menu #menu-settings { grid-column: auto; }
  .character-choice img { width: 96px; height: 96px; }
  .character-choice-portrait { min-height: 104px; }
  .characters-body { padding: 12px 18px; }
  .character-choice { padding: 10px 6px; gap: 8px; }
}

/* The Powers and Interactive blocks galleries share Builder panel chrome. */
#powers-modal .powers-panel, #blocks-modal .blocks-panel {
  width: min(640px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); padding: 0;
  overflow: auto; overscroll-behavior: contain; background: var(--mx-panel);
  color: var(--mx-paper); border: 2px solid var(--mx-line);
}
:is(.powers-panel, .blocks-panel) .col-header { position: sticky; top: 0; z-index: 1; padding: 8px 16px; }
.power-grid { display: grid; padding-inline: 16px; }
.power-card { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 20px; padding: 16px 0; }
.power-card + .power-card { border-top: 1px solid var(--mx-line); }
.power-art { display: grid; place-items: center; aspect-ratio: 1; background: var(--mx-header); border: 1px solid var(--mx-line); }
.power-art canvas, .block-choice canvas { width: 64px; height: 64px; image-rendering: pixelated; }
.power-copy h3, .block-choice strong { font: 12px/1.65 var(--mx-pixel); color: var(--mx-paper); }
.power-copy h3 { margin: 0 0 6px; }
.power-tag { display: block; margin-bottom: 6px; font-size: 8px; line-height: 1.7; color: var(--mx-cyan); }
.power-copy p, .powers-footer, .block-choice span, #blocks-help { color: var(--mx-muted); font: 8px/1.9 var(--mx-ui); }
.power-copy p { margin: 0 0 6px; }
.power-copy .tool-btn { margin-top: 4px; min-height: 44px; white-space: normal; padding: 6px 12px; }
.powers-footer, #blocks-help { margin: 0; border-top: 1px solid var(--mx-line); padding: 12px 16px; }
.palette-power { min-width: 112px; gap: 5px; display: flex; align-items: center; justify-content: center; }
.palette-power canvas { width: 36px; height: 36px; image-rendering: pixelated; }
.palette-power span { font-size: 9px; line-height: 1.5; }
.block-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 16px; }
.block-choice { min-width: 0; display: grid; justify-items: center; align-content: start; gap: 8px; padding: 12px; cursor: pointer;
  background: var(--mx-panel-2); border: 1px solid var(--mx-line); color: var(--mx-paper); }
.block-choice:hover { border-color: var(--mx-purple); }
@media (max-width: 520px) {
  .power-card { grid-template-columns: 64px minmax(0, 1fr); align-items: start; gap: 12px; }
  .power-art canvas { width: 48px; height: 48px; }
  .block-choices { grid-template-columns: 1fr; }
  .block-choice { grid-template-columns: 64px minmax(0, 1fr); align-items: center; justify-items: start; text-align: left; }
  .block-choice canvas { grid-row: span 2; }
}
/* Contextual controls shared by complete ledges in every active family. */
.ledge-controls-button { position:fixed; z-index:45; min-height:44px; padding:0 12px; border:1px solid #75e4d2; background:#14262c; color:#b4fff0; font:inherit; font-size:10px; box-shadow:none; cursor:pointer; }
.ledge-controls-button[hidden] { display:none; }
.ledge-controls-dialog { position:fixed; margin:0; bottom:auto; padding:0; width:370px; max-width:calc(100vw - 16px); max-height:calc(100dvh - 24px); border:1px solid #465967; background:#141b24; color:#e7eef3; box-shadow:none; overflow:hidden; font-family:inherit; }
.ledge-controls-dialog[open] { display:flex; flex-direction:column; }
.ledge-controls-dialog::backdrop { background:#050a1226; }
.ledge-heading { display:flex; flex-shrink:0; justify-content:space-between; align-items:flex-start; gap:8px; padding:18px 16px 12px; border-bottom:1px solid #2e3c47; }
.ledge-eyebrow { margin:0 0 10px; color:#75e4d2; font-size:8px; letter-spacing:normal; }
.ledge-heading h2 { margin:0 0 8px; font-size:15px; line-height:1.5; }
.ledge-heading #ledge-selection-description { color:#a7b5c2; font-size:9px; line-height:1.7; margin:0; }
.ledge-controls-dialog button,.ledge-controls-dialog input { font:inherit; font-size:10px; color:inherit; min-height:44px; border:1px solid #3a4a58; border-radius:0; background:#1d2834; }
.ledge-controls-dialog button { cursor:pointer; padding:8px 10px; }
.ledge-controls-dialog button:hover { background:#293a46; }
.ledge-controls-dialog button:focus-visible,.ledge-controls-dialog input:focus-visible,.ledge-controls-button:focus-visible { outline:none; box-shadow:inset 0 -3px #75e4d2; }
.ledge-controls-dialog .ledge-close { min-width:44px; font-size:22px; margin-top:-6px; border-color:transparent; background:transparent; }
.ledge-scroll { overflow-y:auto; min-height:0; padding:14px 16px 8px; overscroll-behavior:contain; }
.ledge-presets { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; }
.ledge-controls-dialog .ledge-preset { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; min-height:79px; padding:8px 4px; font-size:9px; line-height:1.65; text-align:center; }
.ledge-preset-icon { font:24px/1 monospace; color:#b4c4cf; }
.ledge-controls-dialog [aria-pressed="true"] { border-color:#75e4d2; background:#193830; color:#a8f6d8; }
.ledge-controls-dialog [aria-pressed="true"] .ledge-preset-icon { color:#a8f6d8; }
.ledge-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin-top:16px; }
.ledge-fields:empty { display:none; }
.ledge-field { display:flex; flex-direction:column; gap:8px; font-size:9px; line-height:1.65; min-width:0; }
.ledge-field input { width:100%; box-sizing:border-box; margin-top:auto; padding:8px 10px; background:#0c141e; }
.ledge-direction { grid-column:1/-1; display:flex; gap:8px; }
.ledge-direction button { flex:1; font-size:9px; }
.ledge-explanation,.ledge-custom,.ledge-preview-caption { font-size:9px; line-height:1.9; color:#acbdc9; margin:12px 0; }
.ledge-custom { color:#e9cb87; }
.ledge-preview { border:1px solid #344651; background:#111a20; margin-top:14px; }
.ledge-preview-header { display:flex; align-items:center; gap:8px; padding:0 8px; min-height:44px; font-size:9px; }
.ledge-preview-header>span { margin-right:auto; color:#a9c0cc; }
.ledge-controls-dialog .ledge-preview-header button { background:transparent; border-color:transparent; font-size:9px; padding:6px; }
.ledge-preview canvas { display:block; width:100%; height:auto; image-rendering:pixelated; }
.ledge-preview-caption { margin:0; padding:8px 10px; font-size:8px; }
.ledge-error { color:#ffd195; font-size:9px; line-height:1.8; margin:10px 0 4px; }
.ledge-error:empty { display:none; }
.ledge-footer { display:flex; justify-content:flex-end; gap:10px; padding:12px 16px; border-top:1px solid #2e3c47; background:#141b24; flex-shrink:0; }
.ledge-controls-dialog .ledge-apply { background:#83dfbd; border-color:#83dfbd; color:#10251e; min-width:110px; }
.ledge-controls-dialog button:disabled { opacity:.4; cursor:default; }
@media (max-width:600px) {
  .ledge-controls-dialog { width:calc(100vw - 16px); bottom:max(8px,env(safe-area-inset-bottom)); max-height:calc(100dvh - 16px); }
  .ledge-heading { padding-top:12px; }
}
@media (max-height:550px) and (min-width:601px) {
  .ledge-controls-dialog { width:440px; }
  .ledge-controls-dialog .ledge-preset { min-height:64px; }
}

/* Complete half-platform brushes reuse the native pieces at their true width. */
.palette-tile.palette-ready-ledge {
  width:calc(var(--ledge-width) + 16px); min-width:56px; height:58px;
  padding:4px 6px; display:flex; flex-direction:column; gap:4px;
  border:1px solid #3b4d58; border-radius:0; background:#15202a; color:#dcece6;
  font:inherit; flex-shrink:0;
}
.palette-tile.palette-ready-ledge canvas { width:var(--ledge-width); height:32px; image-rendering:pixelated; }
.palette-ready-size { font-size:8px; line-height:12px; white-space:nowrap; }
.palette-tile.palette-ready-ledge.selected { border-color:#75e4d2; background:#193830; color:#b4fff0; }
.palette-ready-label { flex:0 0 112px; max-width:112px; min-width:112px; max-height:58px; overflow:hidden; color:#9fd8bc; font-size:8px; line-height:1.8; white-space:normal; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:3; }
/* Keep the Mossleaf assembly shelf compact. Full family descriptions remain
   in accessible brush names. Other palettes stay intact. */
#tile-palette:has(> .palette-ready-ledge) > .palette-open-label.palette-group-label {
  flex-basis:160px; max-height:58px; overflow:hidden;
  display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:3;
}

/* Keep the single Toxic Flask choice comfortable on narrow screens. */
@media(max-width:540px){#powers-modal .power-copy .tool-btn{white-space:normal;min-width:0;font-size:10px;line-height:1.6;padding:10px 8px}}

/* One combined Spin / Smash control, also on the title rail. */
.power-grid { display: grid; gap: 12px; }
.touch-fire {
  position: absolute;
  right: max(18px, env(safe-area-inset-right, 0px));
  bottom: calc(max(24px, env(safe-area-inset-bottom, 0px)) + 88px);
  width: 60px; height: 50px;
  color: #b6f269; border-color: #59c135;
  font: 10px 'Press Start 2P', monospace;
}
.touch-fire[hidden] { display: none; }
@media (max-width: 360px) {
  .touch-fire { right: calc(max(24px, env(safe-area-inset-right, 0px)) + 76px); }
}
.touch-spin span { max-inline-size: 66px; font-size: 8px; line-height: 1.3; }
.lobby-runner-keys { white-space: normal; line-height: 1.7; }
.lobby-runner-touch-controls button { padding-inline: 10px; }

/* Leave visible room for the complete spin and smash on portrait phones. */
@media (max-width: 480px) and (min-height: 621px) {
  .lobby-center { padding-top: 80px; gap: 8px; }
  .lobby-wordmark { max-height: 80px; }
  .lobby-tagline { font-size: 12px; }
  .lobby-menu { gap: 5px; }
  .menu-btn { min-height: 50px; padding-block: 4px; }
  .menu-ico { width: 30px; height: 30px; }
  .menu-text { font-size: 22px; }
  .journey-menu-help { margin-top: 0; font-size: 7px; }
}
@media (max-width: 480px) and (min-height: 621px) and (max-height: 749px) {
  .lobby-center { padding-top: 70px; gap: 5px; }
  .lobby-wordmark { max-height: 64px; }
  .menu-btn { min-height: 48px; }
  .journey-menu-help { display: none; }
}
@media (max-width: 480px) and (max-height: 620px) {
  .lobby-center { padding-top: 20px; gap: 4px; }
  .lobby-wordmark { max-height: 56px; }
  .menu-btn { min-height: 44px; padding-block: 2px; }
  .menu-ico { width: 26px; height: 26px; }
}

/* BEGIN GOO_DREAM_BUNDLE */
/* Generated by tools/build_bonus_bundle.mjs; edit bonus/ sources. */
#bonus-hud{position:absolute;top:calc(env(safe-area-inset-top,0px) + 12px);left:calc(env(safe-area-inset-left,0px) + 12px);right:88px;pointer-events:none;color:#d3ee86;font-family:'Press Start 2P',monospace;line-height:1.7;z-index:2}
#bonus-hud[hidden]{display:none}
.bonus-caption,.bonus-readout{width:fit-content;max-width:100%;padding:6px 9px;background:#091b26;border-left:3px solid #91c447}
.bonus-caption{font-size:8px;color:#a2eee1}.bonus-readout{font-size:10px;margin-top:3px}
.bonus-results .completion-score{line-height:2;white-space:pre-line;font-size:clamp(11px,3vw,17px)}
@media(max-width:600px){#bonus-hud{top:calc(env(safe-area-inset-top,0px) + 7px);left:8px;right:70px}.bonus-caption{font-size:7px}.bonus-readout{font-size:8px}}
#bonus-access {
  width:min(476px,calc(100vw - 24px)); max-height:calc(100dvh - 20px); overflow-y:auto;
  padding:16px 20px; box-sizing:border-box; border:2px solid #78b8b2; border-radius:0;
  color:#f4f1ea; background:#171823; box-shadow:none;
}
#bonus-access::backdrop {background:#100d1ad9;}
#bonus-access header {display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:44px;}
#bonus-access h2 {margin:0;font:clamp(12px,3.2vw,16px)/1.65 var(--mx-pixel);}
#bonus-access header button {min-width:44px;min-height:44px;font-size:23px;flex:none;border-radius:0;}
#bonus-access .bonus-portal {display:none;}
#bonus-access .bonus-portal canvas {display:block;width:100%;height:auto;image-rendering:pixelated;}
#bonus-access .bonus-portal>.polaris-loader {display:none;}
#bonus-access[data-reveal="checking"] .bonus-portal {display:grid;place-items:center;min-height:88px;}
#bonus-access[data-reveal="checking"] .bonus-portal>.polaris-loader {display:inline-grid;}
#bonus-access[data-reveal="checking"] canvas {display:none;}
#bonus-access[open]:is([data-reveal="revealing"],[data-reveal="won"],[data-reveal="miss"]) {
  display:grid;grid-template-columns:minmax(0,1fr);
  grid-template-areas:"heading" "gate" "odds" "detail" "actions";
  grid-template-rows:auto auto auto minmax(34px,auto) minmax(44px,auto);gap:8px;
}
#bonus-access header {grid-area:heading;}
#bonus-access:is([data-reveal="revealing"],[data-reveal="won"],[data-reveal="miss"]) .bonus-portal {
  grid-area:gate;display:block;align-self:center;border:2px solid #47666b;background:#102133;
}
#bonus-access[data-reveal="won"] h2 {color:#d4f6ad;}
#bonus-access[data-reveal="miss"] h2 {color:#e1d9eb;}
#bonus-access .bonus-odds {
  grid-area:odds;display:grid;grid-template-columns:1fr 1fr;gap:8px;
  padding:7px 0;border-block:1px solid #41515a;text-align:center;
}
#bonus-access .bonus-odds[hidden], #bonus-access .bonus-verdict:empty, #bonus-access .community-status:empty {display:none;}
#bonus-access .bonus-odds strong {display:block;color:#bee8cc;font:clamp(14px,4.3vw,18px)/1.5 var(--mx-pixel);font-variant-numeric:tabular-nums;}
#bonus-access .bonus-odds span {display:block;margin-top:2px;color:#c4c9d0;}
#bonus-access>p:not([class]) {grid-area:detail;align-self:center;margin:0;}
#bonus-access .community-actions {grid-area:actions;display:flex;flex-wrap:wrap;gap:8px;margin:0;}
#bonus-access .community-actions button {flex:1 1 120px;min-height:44px;border-radius:0;border-width:2px;font:10px/1.7 var(--mx-pixel);}
#bonus-access [data-bonus-action="show-result"] {background:#232b3a;color:#cbdad6;border-color:#50636b;}
#bonus-access [data-bonus-action="enter"],#bonus-access [data-bonus-action="resume"],#bonus-access [data-bonus-action="close"] {background:#91e9be;color:#101e29;border-color:#b9f9d9;}
#bonus-access button:focus-visible {outline:3px solid #d3b7ff;outline-offset:2px;}
@media(min-width:560px) and (max-height:540px) {
  #bonus-access[open]:is([data-reveal="revealing"],[data-reveal="won"],[data-reveal="miss"]) {
    width:min(724px,calc(100vw - 24px));padding:10px 16px;gap:6px 16px;
    grid-template-columns:minmax(0,1.22fr) minmax(0,1fr);
    grid-template-areas:"heading heading" "gate odds" "gate detail" "actions actions";
    grid-template-rows:auto auto minmax(28px,1fr) minmax(44px,auto);
  }
}

/* Keep the same game face through the HUD, vote, draw, results and recovery.
   Existing component font shorthands still control size and line height. */
:is(#lobby,#game-overlay,#community-browser,#journey-browser,#feedback-browser,#bonus-access,#completion-overlay,#pause-overlay,.rewards-browser),
:is(#lobby,#game-overlay,#community-browser,#journey-browser,#feedback-browser,#bonus-access,#completion-overlay,#pause-overlay,.rewards-browser) :where(*) {
  font-family:var(--mx-pixel,'Press Start 2P',monospace) !important;
}
#bonus-access>p:not(.bonus-verdict), #bonus-access .bonus-odds span,
#completion-overlay.community-completion :is(.completion-progress,.completion-rewards) {font-size:clamp(8px,2.2vw,10px);line-height:1.8;}
#bonus-access header button[hidden] {display:none;}
#bonus-access>p:empty {display:none;}
/* END GOO_DREAM_BUNDLE */

/* Creator submissions share the compact, keyboard-safe native dialog layer. */
.creator-release { box-sizing:border-box; margin:auto; width:min(490px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); overflow:auto; padding:20px; border:2px solid #76e4d4; background:#181424; color:#f4f1ea; box-shadow:none; font:12px/1.7 monospace; }
.creator-release::backdrop { background:rgb(5 9 20 / .8); }
.creator-release header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.creator-release h2 { font:12px/1.6 'Press Start 2P',monospace; margin:0; }
.creator-release button { min-height:44px; padding:10px 12px; border:1px solid #667687; color:inherit; background:#263245; font:inherit; cursor:pointer; }
.creator-release header button { min-width:44px; font-size:22px; padding:0; }
.creator-release button:focus-visible { outline:3px solid #e1ed8e; outline-offset:3px; }
.creator-release button:disabled { opacity:.5; cursor:wait; }
.creator-release-steps { padding-left:24px; margin:20px 0; }
.creator-release-steps li { padding:5px 0; }
.creator-release-steps [data-complete="true"] { color:#91e9be; }
.creator-release-detail { overflow-wrap:anywhere; font-weight:bold; }
.creator-release-notice { border-left:3px solid #76e4d4; padding-left:12px; min-height:24px; overflow-wrap:anywhere; }
.creator-release-actions { display:flex; flex-wrap:wrap; gap:8px; }
.creator-release-actions button { flex:1 1 175px; }
.creator-release-actions [data-release-action="submit"] { color:#101e29; background:#91e9be; border-color:#91e9be; font-weight:bold; }
.creator-release-footnote { font-size:11px; color:#b0b8c8; margin:16px 0 0; }
@media(max-width:480px),(max-height:440px) { .creator-release { padding:14px; } .creator-release-steps { margin:10px 0; } }

.community-browser { box-sizing:border-box; margin:auto; width:min(620px,calc(100vw - 24px)); max-height:calc(100dvh - 24px); overflow:auto; padding:20px; border:2px solid #76e4d4; background:#181424; color:#f4f1ea; box-shadow:none; font:14px/1.6 monospace; }
.community-browser::backdrop { background:rgb(5 9 20 / .8); }
.community-browser header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.community-browser h2 { font:12px/1.7 'Press Start 2P',monospace; }
.community-browser button,.community-browser select,.community-browser textarea { box-sizing:border-box; min-height:44px; padding:10px 12px; border:1px solid #667687; color:inherit; background:#263245; font:inherit; }
.community-browser button { cursor:pointer; }
.community-browser header button { min-width:44px; font-size:22px; padding:0; }
.community-browser :is(button,select,textarea):focus-visible { outline:3px solid #e1ed8e; outline-offset:2px; }
.community-browser button:disabled { opacity:.5; cursor:wait; }
.community-status { min-height:24px; margin:14px 0; color:#91e9be; overflow-wrap:anywhere; }
.community-list { list-style:none; padding:0; margin:0 0 16px; }
.community-list li { padding:14px 0; border-bottom:1px solid #3f4358; display:flex; justify-content:space-between; align-items:center; gap:12px; }
.community-list strong { display:block; overflow-wrap:anywhere; }
.community-list span { display:block; color:#b0b8c8; font-size:12px; }
.community-list li>div:first-child { min-width:0; }
.journey-list li { padding:14px 10px; }
.journey-list li[data-journey-state="next"] { border:1px solid #76e4d4; background:#1b302e; }
.journey-list li>button { flex-shrink:0; }
.community-actions { display:flex; gap:8px; flex-wrap:wrap; }
.community-actions [data-community-action^="play-"] { color:#101e29; background:#91e9be; }
.community-browser.community-launch { width:min(440px,calc(100vw - 24px)); border-color:#76e4d4; box-shadow:none; }
.community-launch header { padding-bottom:12px; border-bottom:1px solid #3e465b; }
.community-launch h2 { margin:0; font-size:13px; }
.community-launch .community-list { display:none; }
.community-launch .community-status { margin:20px 0; color:#f4f1ea; text-align:center; }
.community-launch .community-actions { justify-content:center; }
.community-launch .community-actions button { flex:1 1 140px; min-height:48px; border:2px solid #667687; font:10px/1.8 'Press Start 2P',monospace; }
.community-launch [data-community-action="launch-retry"],.community-launch [data-community-action="recover-run"] { color:#101e29; background:#91e9be; border-color:#b9f9d9; }
.polaris-loader.play-loading-mark { display:grid; margin:24px auto; }
.play-loading-mark[hidden] { display:none; }
#play-entry-screen { display:none; }
html[data-play-entry], html[data-play-entry] body { background:#181424; }
html[data-play-entry] body > :not(#community-browser) { visibility:hidden; }
html[data-play-entry] #community-browser, #community-browser[open][data-launch-state="loading"] {
  position:fixed; inset:0; z-index:10000; display:grid; place-items:center; box-sizing:border-box;
  margin:0; width:100%; height:100%; max-width:none; max-height:none; border:0; padding:0;
  background:#181424; box-shadow:none;
}
html[data-play-entry] #community-browser > :not(#play-entry-screen),
#community-browser[data-launch-state="loading"] > :not(#play-entry-screen) { display:none; }
html[data-play-entry] #play-entry-screen, #community-browser[data-launch-state="loading"] #play-entry-screen {
  display:grid; justify-items:center; align-content:center; gap:18px;
  padding:16px; text-align:center; color:#f4f1ea;
}
#play-entry-screen .play-loading-mark { margin:0; }
#play-entry-label { font:11px/1.6 'Press Start 2P',monospace; margin:0; }
#play-entry-screen button { min-width:84px; }
#community-browser:is([data-launch-state="resume"],[data-launch-state="error"])::backdrop { background:#181424; }
#community-browser[data-launch-state="resume"] header button { display:none; }
.game-overlay.community-entry { transition:none; }
.game-hint.level-intro.show { transition:none; }
.game-hint .level-name, .game-hint .level-byline { display:block; overflow-wrap:anywhere; }
.game-hint .level-byline { color:#c8d7dc; font:12px/1.5 monospace; }
.community-report-form { width:100%; }
.community-report-form label { display:block; margin-bottom:14px; }
.community-report-form :is(select,textarea) { display:block; width:100%; margin-top:6px; font-size:16px; }
.community-report-form textarea { resize:vertical; }
@media(max-width:480px),(max-height:440px) { .community-browser { padding:14px; } .community-list li { align-items:stretch; flex-direction:column; } .community-actions button { flex:1 1 auto; } }

/* Wallet-only sign-in keeps both supported providers visible in one action. */
#login-modal .login-wallet-logos { display:flex; align-items:center; gap:6px; flex-shrink:0; }
#login-modal .login-wallet-logos img { width:28px; height:28px; object-fit:contain; }

/* First-party verified-clear ratings; touch targets match completion actions. */
.community-feedback { margin: 22px auto; padding: 0; width: min(100%, 400px); }
.community-feedback[hidden] { display: none; }
.community-feedback p { margin: 12px 0 0; color: #a4c7c0; font: 13px/1.5 monospace; }
.community-feedback p:empty { display: none; }
.community-feedback button, .feedback-browser button { min-height: 44px; }
.feedback-choices { display: flex; justify-content: center; gap: 16px; }
.feedback-choices button[data-feedback-action="good"], .feedback-choices button[data-feedback-action="bad"] {
  flex: 1 1 0; min-width: 0; min-height: 84px; padding: 20px 12px; border: 2px solid #76e4d4;
  border-radius: 0; background: #142d2c; color: #96f9cb; font: 16px/1.5 "Press Start 2P", monospace;
  text-transform: uppercase; box-shadow: none;
}
.feedback-choices button[data-feedback-action="bad"] { border-color: #c890ba; color: #f5b1d2; background: #2d1a31; }
.feedback-choices button[aria-pressed="true"] { outline: 2px solid #fff; outline-offset: 4px; }
.feedback-choices button[aria-pressed="true"]::after { content: " ✓"; }
.feedback-choices button:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.feedback-choices button:hover { filter: brightness(1.18); }
.feedback-browser { max-width: min(440px, calc(100vw - 24px)); }
#completion-overlay.community-completion .completion-card { width: min(680px, calc(100vw - 32px)); }
#completion-overlay.community-completion .completion-progress,
#completion-overlay.community-completion .completion-rewards { border: 0; background: none; padding: 0; margin: 8px auto; color: #aac5bd; font: 13px/1.5 monospace; }
#completion-overlay.community-completion .completion-rewards:empty { display: none; }
#completion-overlay.community-completion .completion-actions { gap: 8px; max-width: 420px; margin: 0 auto; }
#completion-overlay.community-completion :is(#journey-continue, #community-continue) { flex: 1 0 100%; min-height: 52px; margin-bottom: 8px; }
#completion-overlay.community-completion .completion-actions > :is(#completion-restart, #completion-report, #completion-exit) {
  flex: 1 1 0; padding: 12px 8px; font-size: 9px; min-height: 44px; color: #b6b1c3; border-color: transparent; background: transparent;
}
@media (max-width: 539px) {
  .feedback-choices { gap: 12px; }
  .feedback-choices button[data-feedback-action="good"], .feedback-choices button[data-feedback-action="bad"] { min-height: 76px; font-size: 14px; }
  #completion-overlay.community-completion .completion-card { padding: 24px 16px; }
}
@media (min-width: 540px) and (max-height: 560px) {
  #completion-overlay.community-completion .completion-card { width: min(760px, calc(100vw - 24px)); }
  #completion-overlay.community-completion .community-feedback { margin: 14px auto; }
  #completion-overlay.community-completion .completion-actions { margin: 0; width: 100%; }
  #completion-overlay.community-completion :is(#journey-continue, #community-continue) { flex: 0 0 auto; }
  #completion-overlay.community-completion .completion-actions > :is(#completion-restart, #completion-report, #completion-exit) { flex: 0 0 auto; }
}

/* Community charts share the title's acid/mint palette and square pixel frame. */
.community-credit { max-width:100%; overflow-wrap:anywhere; color:#b9ccc9; font:12px/1.6 monospace; margin:6px 0 12px; }
.network-home { display:grid; gap:14px; width:min(100%,550px); }
.network-home-card { background:#13141ff2; border:1px solid #50605b; border-top:3px solid var(--mx-acid,#b9fb4a); padding:14px 16px; min-width:0; }
.network-home-players { border-top-color:#76e4d4; }
.network-home-heading button { display:flex; justify-content:space-between; align-items:center; width:100%; padding:5px 0; border:0; background:none; text-align:left; color:#f7f4e9; font:22px/1.4 var(--mx-display,monospace); min-height:44px; cursor:pointer; }
.network-home-heading button span { color:#b9fb4a; }
.network-rows { list-style:none; padding:0; margin:8px 0 0; }
.network-rows > li { display:flex; align-items:center; gap:12px; padding:12px 0; border-top:1px solid #3b414b; min-width:0; }
.network-level-play { display:flex; align-items:center; gap:12px; min-height:48px; width:100%; min-width:0; text-align:left; padding:10px 8px; }
.network-level-play .network-row-copy { flex:1; }
.network-play-label { flex:0 0 auto; font-size:11px; color:#c5f886; }
.network-rank { flex:0 0 30px; color:#b9fb4a; font:18px/1.4 monospace; }
.network-row-copy { display:flex; flex-direction:column; gap:4px; min-width:0; overflow-wrap:anywhere; font:13px/1.45 monospace; }
.network-row-copy strong { color:#fff6e9; }
.network-row-copy span,.network-row-copy small { color:#b9ccc9; font-size:11px; }
.network-rows .network-empty { color:#b9ccc9; font:12px/1.7 monospace; padding:12px 0; }
/* Chart rows use the same label, hint and selected-control hierarchy as Settings. */
#network-browser { width: min(840px, calc(100vw - 20px)); padding: 0; }
#network-browser .col-header { position: sticky; top: 0; z-index: 1; padding: 8px 16px; }
.network-body { padding: 16px; }
.network-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.network-board { min-width: 0; }
.network-board h3 { margin: 0; color: var(--mx-paper); font-size: 11px; line-height: 1.7; }
.network-note { margin: 4px 0 12px; color: var(--mx-muted); font-size: 8px; line-height: 1.8; }
.network-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; margin-block: 10px; }
.network-board-picker { display: none; }
.network-level-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.network-browser .network-filters button { min-height: 44px; padding: 6px; font-size: 8px; }
.network-browser .network-filters [aria-pressed="true"] {
  background: var(--mx-purple-deep); border-color: var(--mx-purple); box-shadow: inset 0 -3px var(--mx-acid);
}
.network-browser .network-rows { margin: 0; }
.network-browser .network-rows > li { gap: 10px; border-color: var(--mx-line); padding: 10px 0; }
.network-browser .network-rows > li:has(.network-level-play) { padding: 0; }
.network-browser .network-level-play { background: transparent; border: 0; padding: 10px 2px; }
.network-browser .network-rank { flex: 0 0 26px; font: 10px/1.6 var(--mx-pixel); color: var(--mx-acid); }
.network-browser .network-row-copy { gap: 3px; font: 9px/1.7 var(--mx-pixel); }
.network-browser .network-row-copy strong { color: var(--mx-paper); }
.network-browser :is(.network-row-copy span, .network-row-copy small, .network-empty, .network-explainer, .community-status) {
  font: 8px/1.8 var(--mx-pixel); color: var(--mx-muted);
}
.network-browser .network-play-label { font-size: 8px; color: var(--mx-cyan); }
.network-explainer { padding-block: 4px; margin: 12px 0; border-block: 1px solid var(--mx-line); }
.network-explainer summary { cursor: pointer; min-height: 44px; align-content: center; color: var(--mx-paper); }
.network-browser .community-actions button { flex: 1; }
@media(min-width:1101px) and (min-height:650px) {
  .network-home { position:fixed; top:clamp(100px,12vh,150px); right:clamp(28px,5vw,96px); width:min(660px,46vw); grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; max-height:calc(100dvh - 260px); overflow-y:auto; }
  .network-home-card { padding:12px; }
  .network-home-heading button { font-size:clamp(14px,1.45vw,22px); }
}
@media(min-width:1101px) and (min-height:650px) and (max-height:850px) {
  .network-home-card { padding:10px; }
}
@media(max-width:1100px),(max-height:649px) {
  .lobby:has(.network-home) { overflow-y:auto; }
  .network-home { grid-column:1/-1; grid-template-columns:1fr 1fr; gap:8px; width:100%; }
  #menu-rankings { display:none; }
  .network-home-card { padding:6px; }
  .network-home-heading button { font-size:13px; white-space:nowrap; }
}
@media(max-width:650px) {
  .network-board-picker { display: grid; margin: 0 0 18px; }
  .network-columns { grid-template-columns: minmax(0, 1fr); }
  .network-columns[data-chart="levels"] #network-players,
  .network-columns[data-chart="players"] #network-levels { display: none; }
}
@media(min-width:540px) and (max-height:560px) {
  .lobby-center > .lobby-logo { grid-column:1; grid-row:1; }
  .lobby-center > .lobby-menu { grid-column:2; grid-row:1; }
  .network-home-heading button { font-size:clamp(10px,1.6vw,13px); }
}

.creator-release-price { padding:12px; border:1px solid #667687; background:#211d30; margin-block:12px; }
.creator-release-price ul { margin:8px 0; padding-left:20px; }
.creator-release-price small { display:block; overflow-wrap:anywhere; font-size:10px; color:#c9c1d5; }

/* SAMA, HAZO and VUSION share one decorative title illustration. Keep the
   complete trio in view without adding motion or intercepting playground input. */
.lobby-art-scrim {
  background: linear-gradient(90deg, #09080d66, transparent 52%);
}
@media (min-width: 761px) and (max-width: 1100px) and (min-height: 561px) {
  .lobby::before { width: 90%; }
}
@media (max-width: 760px) and (min-height: 561px) {
  .lobby::before {
    width: auto;
    height: clamp(280px, 42dvh, 380px);
    bottom: 64px;
  }
  .lobby-art-scrim { background: none; }
}
@media (max-width: 480px) and (max-height: 620px) {
  .lobby::before {
    width: auto;
    height: 190px;
    bottom: 36px;
  }
}
@media (min-width: 540px) and (max-height: 560px) {
  .lobby::before {
    width: min(53vw, 121dvh);
    height: auto;
    left: -48px;
    right: auto;
    bottom: 24px;
  }
  .lobby-art-scrim { background: none; }
}

/* Phone title screen. The illustrated stage, menu and touch rail share one viewport. */
@media (pointer:coarse) and (max-width:600px) and (orientation:portrait),
       (pointer:coarse) and (max-width:1000px) and (max-height:540px) and (orientation:landscape) {
  #lobby {
    --rail: calc(68px + env(safe-area-inset-bottom, 0px));
    --gutter: clamp(12px, 4vw, 24px);
    width: 100%; width: 100dvw; height: 100dvh; min-height: 0;
    background: linear-gradient(175deg, #201749 8%, #10112a 57%, #19162d 100%);
  }
  #lobby::before {
    top: 0; bottom: auto; left: 0; right: 0; aspect-ratio: auto;
    width: 100%; background-size: cover; background-position: right 82%;
    mask-image: linear-gradient(to bottom, black 86%, transparent 100%);
  }
  #lobby .lobby-art-scrim { background: none; }
  #lobby .lobby-center { box-sizing: border-box; width: 100%; max-width: none; margin: 0; flex: none; }
  #lobby .lobby-topbar { top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); gap: 6px; }
  #lobby .wallet-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
  #lobby .lobby-runner-instructions, #lobby .journey-menu-help { display: none; }
  #lobby .lobby-logo { width: 100%; max-width: none; }
  #lobby .lobby-wordmark { height: auto; margin: 0; max-height: none; filter: drop-shadow(2px 3px 0 #120e28); }
  #lobby .lobby-tagline { width: max-content; gap: 6px; font-size: 8px; line-height: 1.4; }
  #lobby .lobby-tagline i { width: 4px; height: 4px; }
  #lobby .lobby-menu {
    display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px;
    border: 0; box-shadow: none; background: none; width: 100%; max-width: none; overflow: visible;
  }
  #lobby .menu-btn {
    min-width: 0; min-height: 48px; width: 100%; height: auto;
    display: grid; grid-template-columns: 24px minmax(0,1fr); gap: 8px;
    text-align: left; align-items: center; padding: 6px 9px;
    border: 1px solid #72658a; border-radius: 3px; background: #211b37; color: #faf6ff;
    box-shadow: 0 2px 0 #0a0818;
  }
  #lobby .menu-textwrap { min-width: 0; }
  #lobby .menu-text, #lobby #menu-load .menu-text { font-size: clamp(9px, 2.7vw, 12px); line-height: 1.35; white-space: normal; }
  #lobby .menu-sub { display: none; }
  #lobby .menu-btn::after { display: none; }
  #lobby .menu-ico { display: grid; width: 24px; height: 24px; border: none; background: none; }
  #lobby .menu-ico svg { width: 18px; height: 18px; }
  #lobby .menu-characters .menu-ico { display: flex; transform: none; }
  #lobby .menu-characters .menu-ico img { width: 29px; height: 29px; }
  #lobby #menu-play {
    grid-column: 1 / -1; min-height: 52px; padding-inline: 14px;
    grid-template-columns: 28px minmax(0,1fr) auto; gap: 12px;
    background: #f8ce44; color: #201524; border-color: #ffe998;
    box-shadow: 0 3px 0 #906025;
  }
  #lobby #menu-play .menu-text { font-size: 16px; }
  #lobby #menu-play .menu-sub { display: block; font-size: 8px; line-height: 1.4; margin-top: 4px; color: #382615; }
  #lobby #menu-play::after { display: block; }
  #lobby #menu-load { color: #95f4e8; border-color: #4b9395; }
  #lobby #menu-build { background: #42294e; border-color: #926994; }
  #lobby #menu-rankings { display: none; }
  #lobby .network-home { position: static; order: 2; display: grid; grid-column: 1 / -1;
    width: 100%; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
  #lobby .network-home-card { min-width: 0; border: 0; border-top: 1px solid #544769; padding: 0; background: transparent; }
  #lobby .network-home-heading { display: block; margin: 0; }
  #lobby .network-home-heading button span { display: inline; color: #93d7c8; }
  #lobby .lobby-stats-cell { color: #d7c5df; }
  #lobby .lobby-stats-cell::after { color: #927d9e; }
  #lobby .network-home-heading button {
    width: 100%; min-height: 44px; padding: 6px 2px; text-align: left; color: #d5c9e9;
    font-size: 10px; background: transparent; border: 0;
  }
  #lobby .lobby-ticker {
    height: var(--rail); min-height: var(--rail); width: 100%; gap: 2px; padding: 2px 0 max(2px,env(safe-area-inset-bottom));
    display: flex; flex-direction: column; justify-content: center;
    background: #181329; color: #d4bddc; border-top: 1px solid #685374;
  }
  #lobby .lobby-stats-viewport { display: block; flex: 0 0 14px; width: 100%; height: 14px; line-height: 14px; font-size: 8px; }
  #lobby .lobby-runner-touch-controls {
    display: flex; width: 100%; max-width: none; gap: 6px;
    padding: 0 max(12px,env(safe-area-inset-right)) 0 max(12px,env(safe-area-inset-left));
  }
  #lobby .lobby-runner-touch-controls button { flex: 0 1 62px; min-width: 44px; height: 44px; min-height: 44px; }
  #lobby #lobby-runner-touch-spin { margin-left: auto; }
}
@media (pointer:coarse) and (orientation:portrait) and (max-width:600px) {
  #lobby { --hero: clamp(145px, 42dvh, 390px); }
  #lobby::before { height: var(--hero); }
  #lobby .lobby-center {
    display: grid; align-content: start; justify-content: stretch; align-items: start;
    grid-template-columns: minmax(0,1fr); grid-template-rows: var(--hero) auto; gap: 0;
    min-height: 100%; padding: 0 max(var(--gutter),env(safe-area-inset-right)) calc(var(--rail) + 44px) max(var(--gutter),env(safe-area-inset-left));
  }
  #lobby .lobby-logo { grid-row: 1; align-self: start; padding-top: max(16px,env(safe-area-inset-top)); }
  #lobby .lobby-wordmark { width: clamp(150px,45vw,210px); }
  #lobby .lobby-tagline { margin: 2px 0 0 4px; }
  #lobby .lobby-menu { grid-column: 1; grid-row: 2; }
}
@media (pointer:coarse) and (orientation:portrait) and (max-width:600px) and (max-height:620px) {
  #lobby { --hero: clamp(124px,32dvh,190px); }
}
@media (pointer:coarse) and (orientation:landscape) and (max-width:1000px) and (max-height:540px) {
  #lobby { --rail: calc(48px + env(safe-area-inset-bottom, 0px)); }
  #lobby::before {
    width: 48%; height: calc(100% - var(--rail)); background-position: right bottom;
    mask-image: linear-gradient(to right, black 92%, transparent);
  }
  #lobby .lobby-center {
    display: grid; grid-template-columns: minmax(0,.94fr) minmax(0,1.06fr); gap: clamp(8px,2vw,20px);
    align-items: center; min-height: calc(100% - var(--rail)); padding: 8px max(14px,env(safe-area-inset-right)) 8px max(14px,env(safe-area-inset-left));
    margin-bottom: var(--rail);
  }
  #lobby .lobby-topbar { left: max(10px,env(safe-area-inset-left)); right: auto; flex-direction: row-reverse; }
  #lobby .lobby-logo { align-self: start; margin: max(48px,env(safe-area-inset-top)) auto 0; width: max-content; max-width: 100%; }
  #lobby .lobby-wordmark { width: clamp(140px,22vw,208px); max-width: 100%; }
  #lobby .lobby-tagline { margin: 1px auto 0; }
  #lobby .menu-btn { min-height: 44px; }
  #lobby .lobby-menu { gap: 5px; }
  #lobby #menu-play { min-height: 46px; }
  #lobby .lobby-ticker { flex-direction: row; justify-content: space-between; }
  #lobby .lobby-stats-viewport { flex: 1; min-width: 0; }
  #lobby .lobby-runner-touch-controls { flex: 0 1 46%; width: auto; padding-right: max(14px,env(safe-area-inset-right)); }
}

/* Shared Polaris loading mark: stationary silhouette, travelling petal opacity. */
.polaris-loader { --polaris-loader-size:32px; display:inline-grid; place-items:center; flex:0 0 auto; position:relative; inline-size:var(--polaris-loader-size); block-size:var(--polaris-loader-size); vertical-align:middle; color:#f3f1e8; pointer-events:none; user-select:none; }
.polaris-loader[hidden] { display:none; }
.polaris-loader--sm { --polaris-loader-size:20px; }
.polaris-loader--lg { --polaris-loader-size:48px; }
.polaris-loader__mark { display:block; inline-size:var(--polaris-loader-size); block-size:var(--polaris-loader-size); overflow:visible; }
.polaris-loader__petal { opacity:1; }
.polaris-loading-line { display:inline-flex; align-items:center; gap:10px; max-width:100%; }
.request-loading-mark { display:grid; margin:12px auto; }
:not([aria-busy="true"]) > .request-loading-mark { display:none; }
@media(prefers-reduced-motion:no-preference) {
  .polaris-loader__petal { animation:polaris-petal-orbit 1760ms cubic-bezier(.4,0,.2,1) infinite; }
  .polaris-loader__petal--1 { animation-delay:-1320ms; }
  .polaris-loader__petal--2 { animation-delay:-880ms; }
  .polaris-loader__petal--3 { animation-delay:-440ms; }
}
@keyframes polaris-petal-orbit { 0%,25%,100% { opacity:1; } 10%,15% { opacity:0; } }
@media(forced-colors:active) { .polaris-loader { color:CanvasText; } }

/* BEGIN GENERATED PLAYER PROFILE */
/* Wallet profile: compact game styling, readable forms, bounded NFT thumbnails. */
.player-profile {
  --pp-ink: #f5f2ff; --pp-soft: #b6acc5; --pp-line: #4b3d5b; --pp-lime: #d9fa6b; --pp-cyan: #75e1d2;
  width: min(620px, calc(100vw - 28px)); max-height: calc(100dvh - 28px);
  box-sizing: border-box; margin: auto; padding: 0; color: var(--pp-ink);
  background: #15101e; border: 2px solid var(--pp-line); border-radius: 12px;
  box-shadow: 0 18px 90px #000b, 0 0 0 5px #0e0b1477;
  font: 400 10px/1.8 var(--mx-pixel, monospace);
  overflow: auto; overscroll-behavior: contain; scrollbar-color: #756086 #1c1427;
}
.player-profile::backdrop { background: #080610bd; backdrop-filter: blur(7px); }
.player-profile [hidden] { display: none !important; }
.player-profile button, .player-profile input { font: inherit; }
.player-profile button { cursor: pointer; touch-action: manipulation; }
.player-profile button:disabled { cursor: default; opacity: .5; }
.player-profile :is(button,input):focus-visible { outline: 3px solid var(--pp-cyan); outline-offset: 3px; }
.pp-header { position: sticky; top: 0; z-index: 3; background: #15101e; display: flex; gap: 12px; align-items: center; min-height: 70px; padding: 12px 20px; border-bottom: 1px solid #3d2d4d; box-sizing: border-box; }
.pp-header h2 { margin: 0; flex: 1; font: 12px/1.6 var(--mx-pixel, monospace); color: var(--pp-lime); text-transform: uppercase; }
.pp-close { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 1px solid var(--pp-line); border-radius: 6px; background: #21182d; color: var(--pp-ink); font-size: 25px !important; }
.pp-body { padding: 24px; }
.pp-status { margin: 0; padding: 10px 24px; overflow-wrap: anywhere; color: var(--pp-cyan); background: #17312d; border-bottom: 1px solid #38544f; }
.pp-status:empty { display: none; }
.pp-status.error { background: #35202b; border-color: #764453; color: #ffb3c3; }
.pp-hero { position: relative; display: flex; align-items: center; gap: 24px; padding: 24px; margin: -4px -4px 24px; border: 1px solid #57416d; border-radius: 8px; overflow: hidden;
  background: radial-gradient(ellipse at top right, #56336855, transparent 70%), repeating-linear-gradient(0deg, transparent 0 23px, #9776b00c 23px 24px), repeating-linear-gradient(90deg, transparent 0 23px, #9776b00c 23px 24px), #20162e; }
.pp-hero::after { content: ''; position: absolute; width: 9px; height: 9px; background: var(--pp-cyan); right: 14px; top: 14px; box-shadow: -14px 0 #735b89, 0 14px #735b89; pointer-events: none; }
.pp-avatar { position: relative; flex: 0 0 100px; width: 100px; height: 100px; padding: 0; border: 2px solid var(--pp-cyan); border-radius: 7px; background: #173037; overflow: hidden; }
.pp-picture { position: relative; display: block; width: 100%; height: 100%; background: #211b2b; overflow: hidden; }
.pp-picture img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pp-picture.default, .pp-picture.unavailable { background: repeating-conic-gradient(#24223b 0% 25%, #2c2946 0% 50%) 50% / 24px 24px; }
.pp-picture.default::before, .pp-picture.unavailable::before { content: ''; position: absolute; left: 20%; top: 24%; width: 60%; height: 50%; background: var(--pp-cyan);
  clip-path: polygon(0 0,20% 0,20% 18%,80% 18%,80% 0,100% 0,100% 78%,80% 78%,80% 100%,60% 100%,60% 78%,40% 78%,40% 100%,20% 100%,20% 78%,0 78%); }
.pp-picture.default::after, .pp-picture.unavailable::after { content: ''; position: absolute; left: 32%; top: 43%; width: 36%; height: 12%; background: linear-gradient(90deg,#15101e 0 28%,transparent 28% 72%,#15101e 72%); }
.pp-picture.unavailable::before { opacity: .3; }
.pp-avatar-edit { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px; background: #0e1d23df; color: var(--pp-cyan); font-size: 8px; letter-spacing: normal; }
.pp-identity { min-width: 0; }
.pp-eyebrow { display: block; color: var(--pp-soft); font-size: 8px; letter-spacing: normal; }
.pp-identity h3 { margin: 6px 0 10px; font-size: clamp(12px, 3vw, 18px); line-height: 1.6; overflow-wrap: anywhere; letter-spacing: normal; }
.pp-wallet { min-height: 44px; padding: 4px 10px; color: var(--pp-cyan); background: #142c2c; border: 1px solid #3c625f; border-radius: 5px; font-size: 9px !important; }
.pp-wallet::after { content: ' ⧉'; padding-left: 8px; }
.pp-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pp-choice { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 0; min-height: 148px; padding: 18px; text-align: left; background: #21182c; color: var(--pp-ink); border: 1px solid #58436a; border-radius: 7px; }
.pp-choice:hover { background: #2b1f38; border-color: var(--pp-cyan); }
.pp-choice-mark { color: var(--pp-cyan); font-size: 21px; line-height: 1; margin-bottom: 5px; }
.pp-choice strong { font-size: 10px; }
.pp-detail { color: var(--pp-soft); font-size: 9px; overflow-wrap: anywhere; }
.pp-arrow { position: absolute; top: 14px; right: 14px; font-size: 19px; color: var(--pp-soft); }
.pp-home-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid #3d2d4d; margin-top: 24px; padding-top: 12px; }
.pp-text { min-height: 44px; padding: 8px 6px; color: var(--pp-soft); background: none; border: 0; text-decoration: underline; text-underline-offset: 4px; }
.pp-text:hover { color: var(--pp-ink); }
.pp-button { min-height: 46px; padding: 10px 16px; background: #2c203a; color: var(--pp-ink); border: 1px solid #6d5481; border-radius: 6px; font-weight: 700 !important; }
.pp-button:hover:not(:disabled) { background: #39284b; border-color: var(--pp-cyan); }
.pp-button.primary { background: var(--pp-lime); color: #172016; border-color: #e5ff9a; box-shadow: inset 0 -3px #adc944; }
.pp-button.primary:hover:not(:disabled) { background: #e8ff9c; border-color: #f3ffc9; }
.pp-full { width: 100%; margin-top: 16px; }
.pp-muted { color: var(--pp-soft); margin: 12px 0; font-size: 9px; }
.pp-footnote { font-size: 8px; color: var(--pp-soft); margin: 18px 0 0; }
.pp-name-form { display: grid; gap: 12px; }
.pp-name-form label { font-size: 11px; }
.player-profile input { box-sizing: border-box; width: 100%; min-width: 0; min-height: 48px; padding: 10px 13px; background: #0f0b16; color: var(--pp-ink); border: 1px solid #6c537f; border-radius: 6px; }
.player-profile input::placeholder { color: #8f829f; }
.pp-name-form input, .pp-search input { font-size: 16px; }
.pp-owned { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid #4b375c; }
.pp-owned-name { max-width: 100%; overflow-wrap: anywhere; min-height: 46px; padding: 9px 14px; border: 1px solid #685378; border-radius: 6px; color: var(--pp-ink); background: #24192f; }
.pp-owned-name[aria-pressed="true"] { background: #1a3430; border-color: var(--pp-cyan); color: var(--pp-cyan); }
.pp-owned-name[aria-pressed="true"]::after { content: ' ✓'; }
.pp-price { padding: 20px; margin-bottom: 18px; border: 1px solid #68507d; border-radius: 8px; background: #21172d; }
.pp-price h3 { margin: 8px 0 22px; font-size: 18px; overflow-wrap: anywhere; }
.pp-price-lines { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; margin: 0; }
.pp-price-lines dt { color: var(--pp-soft); }
.pp-price-lines dd { margin: 0; text-align: right; }
.pp-price-lines .pp-total { border-top: 1px solid #5b446e; padding-top: 14px; margin-top: 5px; color: var(--pp-lime); font-weight: 800; }
.pp-price ~ .pp-button { width: 100%; margin-bottom: 10px; }
.pp-search { display: flex; gap: 8px; }
.pp-search .pp-button { flex: 0 0 auto; }
.pp-gallery-summary { min-height: 20px; margin: 12px 0; font-size: 11px; color: var(--pp-soft); }
.pp-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.pp-nft { position: relative; display: block; padding: 0; min-width: 0; text-align: left; color: var(--pp-ink); background: #21172c; border: 2px solid #4b385c; border-radius: 7px; overflow: hidden; }
.pp-nft:hover { border-color: #9176a6; }
.pp-nft > .pp-picture { width: 100%; height: auto; aspect-ratio: 1; }
.pp-nft[aria-pressed="true"] { border-color: var(--pp-lime); box-shadow: 0 0 0 2px #d9fa6b33; }
.pp-nft.loading-picture > .pp-picture { opacity: .55; }
.pp-nft-detail { display: block; padding: 8px; }
.pp-nft-detail strong, .pp-nft-detail small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pp-nft-detail strong { font-size: 11px; }
.pp-nft-detail small { font-size: 10px; color: var(--pp-soft); margin-top: 2px; }
.pp-selected { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; text-align: center; background: var(--pp-lime); color: #192516; font-weight: 900; border-radius: 4px; }
.pp-empty { grid-column: 1 / -1; padding: 28px 8px; text-align: center; color: var(--pp-soft); }
.pp-gallery-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0; }
.pp-selection { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; background: #15101e; border-top: 1px solid #59436b; z-index: 1; }
.pp-selection-preview { display: flex; align-items: center; gap: 9px; min-width: 0; }
.pp-selection-preview strong { overflow-wrap: anywhere; line-height: 1.5; font-size: 12px; }
.pp-selection-detail { display: grid; min-width: 0; gap: 3px; }
.pp-selection-detail small { color: var(--pp-soft); font-size: 8px; line-height: 1.6; }
.pp-picture.small { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 5px; }
.pp-selection .pp-button { flex: 0 0 auto; }
@media (max-width: 520px) {
  .player-profile { width: calc(100vw - 18px); max-height: calc(100dvh - 18px); }
  .pp-header { padding: 10px 14px; min-height: 64px; }
  .pp-header h2 { font-size: 10px; }
  .pp-body { padding: 18px; }
  .pp-status { padding: 10px 18px; font-size: 9px; }
  .pp-hero { padding: 18px 14px; gap: 16px; margin: 0 0 18px; }
  .pp-avatar { width: 82px; height: 82px; flex-basis: 82px; }
  .pp-wallet { min-height: 44px; padding: 6px 8px; font-size: 8px !important; }
  .pp-eyebrow { font-size: 8px; }
  .pp-choice { min-height: 138px; padding: 15px 12px; }
  .pp-choice strong { font-size: 9px; }
  .pp-detail { font-size: 8px; }
  .pp-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
  .pp-nft-detail { padding: 6px; }
  .pp-nft-detail strong { font-size: 10px; }
  .pp-selection { gap: 8px; }
  .pp-selection-preview strong { font-size: 9px; }
  .pp-selection .pp-button { padding: 9px 12px; font-size: 9px; }
}
@media (max-height: 500px) and (min-width: 600px) {
  .player-profile { width: min(700px, calc(100vw - 28px)); }
  .pp-header { min-height: 58px; padding-block: 6px; }
  .pp-body { padding: 18px 24px; }
  .pp-hero { padding: 12px 18px; gap: 18px; margin-bottom: 14px; }
  .pp-avatar { width: 70px; height: 70px; flex-basis: 70px; }
  .pp-choice { min-height: 100px; padding: 12px; }
  .pp-choice-mark { display: none; }
  .pp-home-footer { margin-top: 14px; padding-top: 6px; }
  .pp-grid { grid-template-columns: repeat(6, minmax(0,1fr)); }
}

@media (pointer: coarse) and (max-width: 520px), (pointer: coarse) and (max-height: 500px) {
  .pp-hero { --pp-portrait-size: clamp(94px, 27vmin, 108px); gap: 12px; }
  .pp-avatar { flex-basis: var(--pp-portrait-size); width: var(--pp-portrait-size); height: var(--pp-portrait-size); }
  .pp-avatar-edit { left: auto; right: 3px; bottom: 3px; padding: 2px 4px; line-height: 1.4; }
  .pp-identity h3 { margin-block: 5px 2px; }
  /* Keep the copy target thumb-sized while drawing a slimmer address chip. */
  .pp-wallet { position: relative; isolation: isolate; min-height: 44px; padding: 0 8px; border: 0; background: transparent; }
  .pp-wallet::before { content: ''; position: absolute; z-index: -1; inset: 9px 0; border: 1px solid #3c625f; border-radius: 3px; background: #142c2c; }
}

/* END GENERATED PLAYER PROFILE */

/* Settings is the reference for first-party panels and controls. Scope the
   type contract to game-owned UI, including controls created after boot. */
:where(.app, .col-overlay, .props-overlay, .admin-overlay, .bg-selector-overlay, .login-overlay,
       .mx-dialog, .mx-select-popup, .builder-history-dialog, .secret-dialog, .music-library,
       .ledge-controls-dialog, .community-browser, .creator-release, .player-profile, .ai-dialog, .ai-live-bar,
       .app-notice, .game-tooltip),
:where(.app, .col-overlay, .props-overlay, .admin-overlay, .bg-selector-overlay, .login-overlay,
       .mx-dialog, .mx-select-popup, .builder-history-dialog, .secret-dialog, .music-library,
       .ledge-controls-dialog, .community-browser, .creator-release, .player-profile, .ai-dialog, .ai-live-bar,
       .app-notice, .game-tooltip) :where(*) {
  font-family: var(--mx-pixel) !important;
}
:is(dialog.community-browser, dialog.creator-release, dialog.player-profile, dialog.ledge-controls-dialog,
    #music-library .music-panel, #secret-passages-dialog .secret-panel, #login-modal .login-card) {
  border: 2px solid var(--mx-line); border-radius: 0; color: var(--mx-paper); background: var(--mx-panel); box-shadow: none;
}
dialog.community-browser, dialog.creator-release { font-size: 9px; line-height: 1.8; overscroll-behavior: contain; }
:is(dialog.community-browser, dialog.creator-release)::backdrop { background: rgb(5 4 8 / .82); }
:is(dialog.community-browser, dialog.creator-release) > header {
  padding: 0 0 10px; border-bottom: 2px solid var(--mx-line); margin-bottom: 10px;
}
:is(dialog.community-browser, dialog.creator-release) header h2,
:is(#music-library, #secret-passages-dialog, #ai-builder-dialog, dialog.player-profile) header h2 {
  margin: 0; font: 400 clamp(12px, 2.5vw, 16px)/1.5 var(--mx-display); color: var(--mx-paper); text-transform: uppercase;
}
:is(dialog.community-browser, dialog.creator-release) :is(button, select, textarea) {
  border: 1px solid var(--mx-line); border-radius: 0; background: var(--mx-panel-2); color: var(--mx-paper);
}
:is(dialog.community-browser, dialog.creator-release) header button,
:is(.powers-panel, .blocks-panel) .admin-close { min-width: 44px; min-height: 44px; flex-shrink: 0; }
:is(dialog.community-browser, dialog.creator-release) button:hover:enabled,
#powers-modal .tool-btn:hover { border-color: var(--mx-purple); }
dialog.community-browser .community-list span, .community-credit, .creator-release-footnote {
  font: 8px/1.8 var(--mx-pixel); color: var(--mx-muted);
}
dialog.community-browser .journey-list li[data-journey-state="next"] { border-color: var(--mx-purple); background: var(--mx-panel-2); }
dialog.community-browser .community-actions :is([data-community-action^="play-"], [data-community-action="launch-retry"], [data-community-action="recover-run"]),
dialog.creator-release [data-release-action="submit"] { color: var(--mx-ink); background: var(--mx-acid); border-color: var(--mx-acid); }
#network-browser .col-header, :is(.powers-panel, .blocks-panel) .col-header,
#music-library .music-heading, #ai-builder-dialog .ai-header, dialog.player-profile .pp-header,
.app :is(.atmosphere-heading, .scenery-heading), dialog .ledge-heading {
  background: var(--mx-header); border-bottom: 2px solid var(--mx-line); margin: 0;
}
#network-browser .col-header h2, :is(.powers-panel, .blocks-panel) .col-header h2 { font-size: clamp(12px, 4vw, 19px); line-height: 1.5; }
#network-browser .network-filters [aria-pressed="true"] { border-color: var(--mx-purple); background: var(--mx-purple-deep); }
#network-browser .network-level-play { border: 0; background: transparent; }
#network-browser .network-level-play:hover { background: var(--mx-panel-2); }
#network-browser .network-body, #network-browser .network-body * { min-width: 0; }
#network-browser .community-status:empty { display: none; }
#network-browser .network-row-copy { flex: 1; }
#powers-modal .power-copy .tool-btn { border: 1px solid var(--mx-purple); background: var(--mx-panel-2); color: var(--mx-paper); }
#secret-passages-dialog .secret-panel header { padding-bottom: 8px; border-bottom: 2px solid var(--mx-line); }
.app .atmosphere-heading, .app .scenery-heading { margin-bottom: 6px; }
dialog.player-profile { --pp-ink: var(--mx-paper); --pp-soft: var(--mx-muted); --pp-line: var(--mx-line); --pp-lime: var(--mx-acid); --pp-cyan: var(--mx-cyan); }
.player-profile :is(.pp-hero, .pp-choice, .pp-close, .pp-avatar, .pp-card, .pp-action), .characters-body .character-choice { border-radius: 0; }

.app .goo-library header { padding-bottom: 8px; border-bottom: 2px solid var(--mx-line); }
dialog.ledge-controls-dialog :is(button,input) { background: var(--mx-panel-2); border-color: var(--mx-line); color: var(--mx-paper); }
dialog.ledge-controls-dialog :is(.ledge-preset[aria-pressed="true"], button:hover) { border-color: var(--mx-purple); }
.ledge-controls-dialog :is(.ledge-eyebrow,.ledge-preset-icon) { color: var(--mx-cyan); }
#builder-history-dialog .secret-panel { border: 2px solid var(--mx-line); background: var(--mx-panel); box-shadow: none; }
#builder-history-dialog h2 { color: var(--mx-paper); text-transform: uppercase; }
