/* The start / pause menu (index.html #start, ui/menu.js): big items on the left, one page on the right, a key line below.
   Same tokens as the HUD and the loading screen (tokens.css): marshrutka yellow, asphalt plates, the narrow heavy face.
   `#start.menu` outranks the older #start rules of styles.css / theme.css / touch.css. */
#start.menu { display: block; padding: 0; text-align: left; overflow: hidden; cursor: default; color: var(--c-paper); }
#start.menu:not(.cover) { background: linear-gradient(90deg, rgba(6, 8, 11, 0.9) 0%, rgba(6, 8, 11, 0.7) 45%, rgba(6, 8, 11, 0.55) 100%); }
@media (pointer: fine) { #start.menu:not(.cover) { -webkit-backdrop-filter: blur(6px) saturate(0.8); backdrop-filter: blur(6px) saturate(0.8); } }
#start.menu[hidden] { display: none; }

.mn-shell { position: relative; height: 100%; display: grid; grid-template-columns: minmax(280px, 400px) minmax(0, 760px);
  grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: 'brand pages' 'nav pages' 'foot foot';
  column-gap: clamp(28px, 5vw, 96px); row-gap: clamp(16px, 4vh, 44px);
  padding: clamp(20px, 6vh, 64px) clamp(20px, 6vw, 110px) clamp(14px, 3vh, 28px); }

/* the brand: the route board chip and the name in three heavy lines, the loading screen's yellow bar */
.mn-brand { grid-area: brand; }
.mn-chip { display: inline-block; padding: 4px 10px 3px; border-radius: var(--r-plate); background: var(--c-marsh); color: #141005;
  font-size: var(--fs-s); font-weight: var(--fw-heavy); letter-spacing: 0.08em; text-transform: uppercase;
  box-shadow: var(--edge), inset 0 -3px 0 var(--c-marsh-deep); }
.mn-brand h1 { margin: 12px 0 0; padding-left: 14px; border-left: 6px solid var(--c-marsh); font-size: clamp(30px, min(3.4vw, 6vh), 54px);
  font-weight: var(--fw-heavy); line-height: 0.95; letter-spacing: 0.03em; text-transform: uppercase; color: var(--c-paper); }
.mn-brand h1 span { display: block; }

/* the items */
.mn-nav { grid-area: nav; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 0; overflow-y: auto; }
#start.menu .mn-item { position: relative; display: block; width: auto; margin: 0; padding: 3px 18px 3px 22px; border: 0; border-radius: 0;
  background: none; box-shadow: none; color: rgba(243, 239, 228, 0.6); font: var(--fw-heavy) clamp(24px, min(2.5vw, 5vh), 40px)/1.1 var(--font);
  letter-spacing: 0.04em; text-transform: uppercase; text-align: left; cursor: pointer; filter: none; transform: none;
  -webkit-text-stroke: 1.5px var(--c-outline); paint-order: stroke fill; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
  transition: color var(--dur-out) ease-out, transform var(--dur-in) var(--ease-out); }
#start.menu .mn-item::before { content: ''; position: absolute; left: 0; top: 18%; bottom: 18%; width: 7px; background: var(--c-marsh);
  box-shadow: 0 0 0 2px var(--c-outline); transform: scaleY(0); transition: transform var(--dur-in) var(--ease-out); }
#start.menu .mn-item:hover, #start.menu .mn-item:focus-visible, #start.menu .mn-item.on { color: var(--c-marsh); transform: translateX(6px); outline: none; }
#start.menu .mn-item:focus-visible::before, #start.menu .mn-item.on::before { transform: scaleY(1); }
#start.menu #play { color: var(--c-paper); font-size: clamp(28px, min(3vw, 6vh), 48px); margin-bottom: 6px; }
#start.menu #play:hover, #start.menu #play:focus-visible { color: var(--c-marsh); }
#start.menu .mn-item.mn-admin { margin-top: 10px; font-size: clamp(16px, min(1.5vw, 3vh), 22px); color: rgba(243, 239, 228, 0.5); }
#start.menu .mn-item.mn-admin::after { content: ' ⚙'; }
#start.menu .mn-item.mn-admin[hidden] { display: none; }
/* «Готовим графику…» while the shaders compile: a plate with the fill, small type */
#start.menu #play.warming { min-width: 0; width: min(360px, 100%); padding: 10px 14px; border-radius: var(--r-plate); background: rgba(255, 255, 255, 0.1);
  color: var(--c-paper); font-size: var(--fs-m); letter-spacing: 0.02em; text-transform: none; -webkit-text-stroke: 0; text-shadow: none; transform: none; cursor: progress; }

/* the page on the right: an asphalt plate, its title, its own scroll */
.mn-pages { grid-area: pages; min-height: 0; display: flex; align-items: flex-start; }
.mn-page { display: flex; flex-direction: column; width: 100%; max-height: 100%; background: rgba(18, 21, 25, 0.94); border-top: 4px solid var(--c-marsh);
  border-radius: var(--r-panel); box-shadow: var(--edge), var(--drop); animation: mn-in var(--dur-in) var(--ease-out); }
.mn-page[hidden] { display: none; }
@keyframes mn-in { from { opacity: 0; transform: translateX(14px); } }
.mn-page h2 { margin: 0; padding: 16px 24px 10px; font-size: var(--fs-xl); font-weight: var(--fw-heavy); letter-spacing: 0.06em; text-transform: uppercase; color: var(--c-paper); }
.mn-body { min-height: 0; overflow-y: auto; padding: 4px 24px 22px; font-weight: var(--fw-body); font-size: var(--fs-m); line-height: 1.4; overscroll-behavior: contain; }
.mn-empty { margin: 4px 0; color: var(--c-concrete); }
.mn-back { display: none; }
.mn-page h3, .mn-settings h3 { margin: 16px 0 8px; font-size: var(--fs-s); font-weight: var(--fw-heavy); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--c-marsh); }
.mn-page h3:first-child { margin-top: 4px; }

/* the key line */
.mn-foot { grid-area: foot; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 24px; padding-top: 12px;
  border-top: 1px solid var(--panel-line); font-size: var(--fs-s); font-weight: var(--fw-body); color: var(--c-concrete); }
.mn-prompt { color: var(--c-paper); font-size: var(--fs-m); letter-spacing: 0.04em; text-transform: uppercase; font-weight: var(--fw-heavy); }
.mn-prompt-touch, body.touch .mn-prompt-keys, body.touch .mn-keys { display: none; }
body.touch .mn-prompt-touch { display: inline; }
.mn-foot kbd, .mn-page kbd { display: inline-block; min-width: 1.7em; margin: 0 3px; padding: 1px 6px; border-radius: 4px; background: rgba(243, 239, 228, 0.12);
  color: var(--c-paper); font: var(--fw-heavy) 12px/1.5 var(--font); text-align: center; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.35); }
.mn-prompt kbd { background: var(--c-marsh); color: #141005; box-shadow: inset 0 -2px 0 var(--c-marsh-deep); }

/* «Управление» */
#start.menu .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; margin: 0; font-size: var(--fs-m); font-weight: var(--fw-body); color: var(--c-paper); }
#start.menu .controls > div { padding: 7px 0; border-bottom: 1px solid rgba(243, 239, 228, 0.07); }
#start.menu .controls b { min-width: 2em; margin-right: 6px; padding: 1px 7px; border-radius: 4px; background: rgba(255, 198, 26, 0.14); color: var(--c-marsh); }

/* «Настройки»: tabs, rows, switches */
.mn-tabs { position: sticky; top: -4px; z-index: 1; display: flex; flex-wrap: wrap; gap: 2px 4px; margin: 0 -24px 10px; padding: 0 20px;
  background: rgba(18, 21, 25, 0.98); border-bottom: 1px solid var(--panel-line); }
.mn-tab-btn { padding: 10px 10px 9px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--c-concrete); cursor: pointer;
  font: var(--fw-heavy) var(--fs-s)/1.2 var(--font); letter-spacing: 0.06em; text-transform: uppercase; }
.mn-tab-btn:hover { color: var(--c-paper); }
.mn-tab-btn.on { color: var(--c-marsh); border-bottom-color: var(--c-marsh); }
.mn-tab[hidden] { display: none; }
.mn-settings .set-row, .mn-settings .set-line { font-size: var(--fs-m); font-weight: var(--fw-body); margin: 10px 0; }
.mn-settings .set-row { grid-template-columns: 10em minmax(0, 1fr) 4.4em; }
.mn-settings .set-caption { width: 10em; }
.mn-settings .set-col { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 6px 0; }
.mn-settings .set-check { gap: 10px; min-height: 36px; cursor: pointer; }
.mn-settings .muted, .mn-settings .voice-note { color: var(--c-concrete); font-size: var(--fs-s); }
.mn-settings select, .mn-settings input[type=url] { min-height: 32px; padding: 4px 8px; border-radius: var(--r-plate); border: 1px solid var(--panel-line);
  background: rgba(0, 0, 0, 0.35); color: var(--c-paper); font: var(--fw-body) var(--fs-m) var(--font); }
.mn-settings .voice-players { list-style: none; margin: 6px 0; padding: 0; }
.mn-settings .voice-players li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; }
.mn-settings .voice-players button, #quest-pause button { padding: 6px 12px; border: 0; border-radius: var(--r-plate); background: rgba(243, 239, 228, 0.1);
  color: var(--c-paper); font: var(--fw-heavy) var(--fs-s) var(--font); cursor: pointer; }
/* checkboxes as switches */
#start.menu input[type=checkbox], #admin-panel input[type=checkbox] { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 40px; height: 22px; margin: 0;
  border-radius: 11px; background: rgba(243, 239, 228, 0.16); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4); cursor: pointer; transition: background var(--dur-out); }
#start.menu input[type=checkbox]::after, #admin-panel input[type=checkbox]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--c-paper); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); transition: transform var(--dur-in) var(--ease-out); }
#start.menu input[type=checkbox]:checked, #admin-panel input[type=checkbox]:checked { background: var(--c-marsh); }
#start.menu input[type=checkbox]:checked::after, #admin-panel input[type=checkbox]:checked::after { transform: translateX(18px); background: #141005; }
#start.menu input[type=range], #admin-panel input[type=range] { accent-color: var(--c-marsh); }
/* the ‹ Ясно › weather picker */
.mn-step { display: inline-flex; align-items: center; gap: 4px; }
.mn-step-btn { width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--r-plate); background: rgba(243, 239, 228, 0.1); color: var(--c-marsh);
  font: var(--fw-heavy) 22px/1 var(--font); cursor: pointer; }
.mn-step-btn:hover { background: rgba(255, 198, 26, 0.2); }
.mn-step-value { min-width: 11em; text-align: center; font-weight: var(--fw-heavy); font-size: var(--fs-l); text-transform: uppercase; letter-spacing: 0.03em; }

/* «Задания» */
#quest-pause .qp-stats { display: flex; gap: 12px; }
#quest-pause .qp-stat { flex: 1; padding: 10px 14px; border-radius: var(--r-plate); background: rgba(243, 239, 228, 0.06); }
#quest-pause .qp-stat b { display: block; font-size: var(--fs-2xl); line-height: 1.1; color: var(--c-paper); font-variant-numeric: tabular-nums; }
#quest-pause .qp-stat:last-child b { color: var(--c-money); }
#quest-pause .qp-stat span { color: var(--c-concrete); font-size: var(--fs-s); text-transform: uppercase; letter-spacing: 0.06em; }
#quest-pause .qp-line { font-size: var(--fs-l); }
#quest-pause .qp-where { margin: 6px 0 16px; color: var(--c-concrete); font-size: var(--fs-s); }

/* «Авторы» */
#start .credits ul { list-style: none; margin: 0; padding: 0; color: var(--c-concrete); font-size: var(--fs-s); line-height: 1.45; }
#start .credits li { padding: 5px 0; border-bottom: 1px solid rgba(243, 239, 228, 0.07); }
#start .credits b { display: inline-block; min-width: 7em; color: var(--c-paper); }
#start .credits a { color: var(--c-paper); }
#start #credits li { font-size: var(--fs-l); }

/* «Онлайн»: the lobby (ui/lobby.js) without its own card */
#start #coop { position: static; width: auto; max-height: none; overflow: visible; padding: 0; border: 0; border-radius: 0; background: none;
  -webkit-backdrop-filter: none; backdrop-filter: none; font: var(--fw-body) var(--fs-m) var(--font); }
#start #coop h2 { margin: 12px 0 4px; font-size: var(--fs-l); text-transform: uppercase; letter-spacing: 0.04em; }
#start #coop label { font-size: var(--fs-s); }
#start #coop input[type=text], #start #coop select { min-height: 38px; border-radius: var(--r-plate); border-color: var(--panel-line); font-size: var(--fs-m); }
#start #coop button { border-radius: var(--r-plate); min-height: 38px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: var(--fw-heavy); }
#start #coop button.primary { background: var(--c-marsh); color: #141005; box-shadow: inset 0 -3px 0 var(--c-marsh-deep); }

/* the voice step on the first Play (ui/voiceChoice.js) */
.mn-modal { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(4, 5, 7, 0.72); }
.mn-modal[hidden] { display: none; }
#start #voice-choice { width: min(460px, 100%); margin: 0; padding: 20px 22px 18px; border: 0; border-top: 4px solid var(--c-marsh); border-radius: var(--r-panel);
  background: var(--c-asphalt); box-shadow: var(--edge), var(--drop); animation: mn-in var(--dur-in) var(--ease-out); }
#start #voice-choice .vc-step { color: var(--c-marsh); font-size: var(--fs-s); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
#start #voice-choice .vc-title { margin: 2px 0 8px; font-size: var(--fs-xl); text-transform: uppercase; letter-spacing: 0.03em; }
#start #voice-choice .vc-note, #start #voice-choice .vc-hint { font-size: var(--fs-s); font-weight: var(--fw-body); color: var(--c-concrete); opacity: 1; }
#start #voice-choice .vc-row { margin: 16px 0 10px; }
#start #voice-choice .vc-opt { min-height: 48px; border: 0; border-radius: var(--r-plate); background: rgba(243, 239, 228, 0.1); font-size: var(--fs-l);
  text-transform: uppercase; letter-spacing: 0.03em; }
#start #voice-choice .vc-opt:first-child { background: var(--c-marsh); color: #141005; box-shadow: inset 0 -3px 0 var(--c-marsh-deep); }

/* a short desktop window: tighter */
@media (max-height: 700px) and (min-width: 640px) {
  .mn-shell { row-gap: 12px; padding-top: 18px; }
  .mn-brand h1 span { display: inline; }
  .mn-brand h1 { font-size: clamp(22px, 2.6vw, 34px); }
}

/* a phone held sideways (844×390): brand on one line, a narrow column, the page fills the rest */
@media (max-height: 500px) and (min-width: 640px) {
  .mn-shell { grid-template-columns: minmax(180px, 230px) minmax(0, 1fr); column-gap: 16px; row-gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .mn-chip { font-size: var(--fs-xs); padding: 2px 7px 1px; }
  .mn-brand h1 { margin-top: 6px; font-size: 17px; line-height: 1.05; border-left-width: 4px; padding-left: 8px; }
  #start.menu .mn-item { font-size: 20px; min-height: 40px; padding: 4px 10px 4px 16px; }
  #start.menu #play { font-size: 24px; margin-bottom: 2px; }
  #start.menu .mn-item.mn-admin { font-size: 15px; margin-top: 0; }
  .mn-page h2 { padding: 10px 16px 6px; font-size: var(--fs-l); }
  .mn-body { padding: 2px 16px 14px; font-size: var(--fs-s); }
  .mn-tabs { margin: 0 -16px 6px; padding: 0 12px; }
  .mn-foot { padding-top: 6px; }
  .mn-foot .mn-prompt { font-size: var(--fs-s); }
  #start.menu .controls { grid-template-columns: 1fr; }
  .mn-nav { gap: 0; }
}
body.touch #start.menu .mn-item { min-height: 44px; }
body.touch #start.menu .set-row input[type=range] { height: 40px; }
body.touch .mn-step-btn, body.touch .mn-tab-btn { min-height: 44px; min-width: 44px; }

/* a phone upright: the list fills the screen; a page covers it with «‹ Назад» */
@media (max-width: 639px) {
  .mn-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: 'brand' 'nav' 'foot'; row-gap: 20px;
    padding: max(28px, env(safe-area-inset-top)) 22px max(16px, env(safe-area-inset-bottom)); }
  .mn-brand h1 { font-size: 34px; }
  .mn-nav { justify-content: center; gap: 6px; }
  #start.menu .mn-item { font-size: 30px; min-height: 48px; }
  #start.menu #play { font-size: 38px; margin-bottom: 10px; }
  .mn-pages { position: absolute; inset: 0; z-index: 3; display: none; padding: max(12px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom)); background: rgba(6, 8, 11, 0.96); }
  #start.mn-open .mn-pages { display: flex; }
  .mn-page { height: 100%; }
  .mn-back { display: block; align-self: flex-start; min-height: 44px; margin: 6px 0 0 8px; padding: 0 12px; border: 0; background: none; color: var(--c-marsh);
    font: var(--fw-heavy) var(--fs-m) var(--font); text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer; }
  .mn-page h2 { padding-top: 0; }
  .mn-body { padding: 2px 16px 18px; }
  .mn-tabs { margin: 0 -16px 8px; padding: 0 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .mn-tab-btn { flex: none; }
  #start.menu .controls { grid-template-columns: 1fr; }
  .mn-settings .set-row { grid-template-columns: minmax(0, 1fr) 4em; }
  .mn-settings .set-row label { grid-column: 1 / -1; }
  .mn-step-value { min-width: 8em; }
}
@media (prefers-reduced-motion: reduce) { .mn-page, #start #voice-choice { animation: none; } }

/* the cover behind the first menu: the same picture as the loading screen (menu.jpg has a dark band baked in) */
#start.menu.cover { --key-art: url("../../assets/ui/loading/a.webp"); }
:root[data-art="2"] #start.menu.cover { --key-art: url("../../assets/ui/loading/b.webp"); }
:root[data-art="3"] #start.menu.cover { --key-art: url("../../assets/ui/loading/c.webp"); }
body:has(#admin-panel:not([hidden])) #start .mn-pages { visibility: hidden; } /* the creator panel takes the right side */
body.touch #start.menu:not(.cover) { background: rgba(6, 8, 11, 0.9); } /* no blur on a phone: a darker veil instead */
