/* The menu (menu.js, T-095). Dark water, the viewer's own controls: the same colours,
   panels and buttons as the readout and the inspector. Phone first: one column, buttons a
   thumb can hit (44 px), the main choices low on the screen. */

#menu-open {
  position: fixed; z-index: 6; top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left));
  height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: rgba(0, 0, 0, 0.35); color: #cfe3f0;
  font: 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif; cursor: pointer;
}
body.menu-open #menu-open { display: none; }
/* The world's own buttons and readouts would show through the menu: hidden while it is open. */
body.menu-open #hud, body.menu-open #controls, body.menu-open #links, body.menu-open #notice,
body.menu-open #inspector { visibility: hidden; }

#menu {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; touch-action: pan-y;
  background: rgba(4, 14, 24, 0.78); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: #cfe3f0; -webkit-user-select: text; user-select: text;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
}
#menu[hidden] { display: none; }
#menu.sub { background: rgba(4, 14, 24, 0.93); }
#menu * { box-sizing: border-box; }
#menu .m-head, #menu .m-body { max-width: 460px; margin: 0 auto; }
#menu .m-head {
  position: sticky; top: calc(-1 * max(10px, env(safe-area-inset-top))); z-index: 1;
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding-top: 4px;
  background: linear-gradient(rgba(4, 14, 24, 0.96) 70%, rgba(4, 14, 24, 0));
}
#menu .m-brand { font-size: 20px; letter-spacing: 0.04em; color: #e6f2f8; }
#menu h2 { margin: 0; font-size: 17px; font-weight: 600; color: #e6f2f8; flex: 1 1 auto; }
#menu h3 { margin: 18px 0 6px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #7fd1c7; }
#menu .m-close { margin-left: auto; }
#menu button { font: inherit; color: inherit; cursor: pointer; }
#menu .m-back, #menu .m-close {
  min-width: 44px; height: 40px; padding: 0 12px; border: 0; border-radius: 8px; background: rgba(207, 227, 240, 0.1);
}

/* Home: what is on screen, then the choices, low on a tall screen so a thumb reaches them. */
#menu .m-body { display: flex; flex-direction: column; gap: 10px; padding-bottom: 24px; }
@media (min-height: 640px) and (max-width: 560px) {
  #menu .m-body:has(> .m-list) { min-height: calc(100dvh - 90px); justify-content: flex-end; }
}
#menu .m-here {
  display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px;
  background: rgba(207, 227, 240, 0.06); border: 1px solid rgba(207, 227, 240, 0.1);
}
#menu .m-here-what { font-size: 15px; color: #e6f2f8; overflow-wrap: anywhere; }
#menu .m-here-live { font-size: 12px; opacity: 0.7; font-variant-numeric: tabular-nums; }
#menu .m-list { display: flex; flex-direction: column; gap: 6px; }
#menu .m-choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 52px;
  padding: 10px 14px; border: 0; border-radius: 10px; text-align: left; background: rgba(207, 227, 240, 0.1);
}
#menu .m-choice:active, #menu .m-btn:active, #menu .m-chip:active { filter: brightness(1.3); }
#menu .m-choice.primary, #menu .m-btn.primary { background: rgba(127, 209, 199, 0.32); color: #f0fbfa; }
#menu .m-choice-title { font-size: 16px; color: #e6f2f8; }
#menu .m-choice-sub { font-size: 12.5px; opacity: 0.7; font-weight: 400; text-transform: none; letter-spacing: 0; }
#menu .m-foot { margin: 6px 0 0; text-align: center; font-size: 13px; opacity: 0.8; }
#menu a { color: #7fd1c7; }

/* Buttons, fields. */
#menu .m-btn, #menu .m-chip {
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 8px; background: rgba(207, 227, 240, 0.12);
}
#menu .m-btn:disabled { opacity: 0.4; cursor: default; }
#menu .m-start { width: 100%; font-size: 16px; min-height: 50px; }
#menu .m-chip { min-height: 36px; padding: 0 12px; border-radius: 18px; font-size: 13px; font-variant-numeric: tabular-nums; }
#menu .m-chip small { opacity: 0.65; }
#menu .m-link-btn { border: 0; background: none; padding: 4px 0; color: #7fd1c7; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }
#menu .m-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#menu .m-row.wrap { margin-top: 8px; }
#menu section { display: flex; flex-direction: column; gap: 8px; }
#menu .m-field { padding: 10px 0; border-bottom: 1px solid rgba(207, 227, 240, 0.08); }
#menu .m-field.changed { border-left: 3px solid #7fd1c7; padding-left: 10px; }
#menu .m-label { display: block; margin-bottom: 6px; font-size: 14px; color: #e6f2f8; }
#menu .m-std { font-size: 12px; opacity: 0.6; margin-left: 4px; }
#menu .m-std .m-link-btn { font-size: 12px; padding: 0; }
#menu .m-note { margin: 4px 0 0; font-size: 12.5px; line-height: 1.45; opacity: 0.72; }
#menu .m-note code, #menu .m-key { font: 11.5px ui-monospace, Menlo, monospace; opacity: 0.75; }
#menu .m-msg { display: block; font-size: 12.5px; margin-top: 4px; }
#menu .m-msg:empty { display: none; }
#menu .m-warn { color: #ffcf9e; font-size: 13px; margin: 0; }
#menu .m-error { color: #ffb4a8; font-size: 13px; margin: 0; }
#menu .small { font-size: 12px; }
#menu .m-wait { opacity: 0.7; font-size: 13px; }
#menu input[type=text], #menu input[type=number], #menu input[type=search], #menu select, #menu .m-url {
  height: 44px; padding: 0 10px; border: 1px solid rgba(207, 227, 240, 0.18); border-radius: 8px;
  background: rgba(0, 0, 0, 0.3); color: #e6f2f8; font: 16px system-ui, -apple-system, sans-serif;  /* 16 px: Safari does not zoom */
}
#menu select { padding-right: 6px; max-width: 100%; }
#menu .m-text, #menu .m-url { width: 100%; }
#menu .m-num { width: 5.5em; font-variant-numeric: tabular-nums; }
#menu .m-num.wide { width: 9em; }
#menu .m-slide { flex: 1 1 140px; accent-color: #7fd1c7; height: 44px; }
#menu .m-part { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; opacity: 0.9; }
#menu .m-part .m-num { width: 5em; }
#menu .m-switch { position: relative; display: inline-block; width: 52px; height: 32px; }
#menu .m-switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
#menu .m-switch span { position: absolute; inset: 0; border-radius: 16px; background: rgba(207, 227, 240, 0.18); transition: background 0.15s; pointer-events: none; }
#menu .m-switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #cfe3f0; transition: transform 0.15s; }
#menu .m-switch input:checked + span { background: rgba(127, 209, 199, 0.6); }
#menu .m-switch input:checked + span::after { transform: translateX(20px); }
#menu .m-switch input:focus-visible + span { outline: 2px solid #7fd1c7; outline-offset: 2px; }
#menu .m-check { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; min-height: 44px; }
#menu .m-check input { width: 20px; height: 20px; accent-color: #7fd1c7; }

/* Founders. */
#menu .m-founders { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#menu .m-founder { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%; }
#menu .m-founder select { flex: 1 1 5em; min-width: 0; }
#menu .m-founder .m-num { width: 4.2em; }
#menu .m-founder code { flex: 1 1 auto; font: 13px ui-monospace, Menlo, monospace; overflow-wrap: anywhere; }
#menu .m-times { opacity: 0.6; }
#menu .m-x { min-width: 40px; height: 40px; border: 0; border-radius: 8px; background: rgba(207, 227, 240, 0.08); }

/* Sections that close. */
#menu .m-group { border-bottom: 1px solid rgba(207, 227, 240, 0.1); }
#menu .m-group > summary { padding: 12px 0; cursor: pointer; font-weight: 600; color: #e6f2f8; min-height: 44px; }
/* Only the one button that acts stays at the bottom of the screen. */
#menu .m-actions { position: sticky; z-index: 1; bottom: calc(-1 * max(16px, env(safe-area-inset-bottom)));
  padding: 10px 0 max(10px, env(safe-area-inset-bottom)); margin-top: 8px; gap: 6px;
  background: #06131f; box-shadow: 0 -10px 12px -6px #06131f; }
#menu .m-actions[hidden] { display: none; }
#menu .m-address { display: block; padding: 8px 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.3); font: 12.5px ui-monospace, Menlo, monospace; overflow-wrap: anywhere; }

/* The link to what was set up. */
#menu .m-link { display: flex; flex-direction: column; gap: 6px; }
#menu .m-url { font-size: 13px; height: 36px; opacity: 0.85; }
#menu .m-copied { font-size: 12.5px; color: #7fd1c7; }

/* Saved worlds. */
#menu .m-runs { display: flex; flex-direction: column; gap: 10px; }
#menu .m-run { padding: 8px; border-radius: 12px; background: rgba(207, 227, 240, 0.06); }
#menu .m-run-open { display: flex; gap: 12px; align-items: center; width: 100%; padding: 0; border: 0; background: none; text-align: left; }
#menu .m-run-open img, #menu .m-thumb-none { flex: 0 0 auto; width: 96px; aspect-ratio: 16 / 10; border-radius: 8px; object-fit: cover; background: #05121f; }
#menu .m-run-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#menu .m-run > .m-link-btn { margin: 6px 0 0 108px; }
#menu .m-states { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px 108px; }
#menu .m-states[hidden] { display: none; }
@media (max-width: 380px) {
  #menu .m-run-open img, #menu .m-thumb-none { width: 76px; }
  #menu .m-run > .m-link-btn, #menu .m-states { margin-left: 88px; }
}
