/* ============================================================
   GODMODE — mobile layer (≤767px).
   fit.js adds body.is-mobile and stops scaling the 1920×1080
   stage; every rule here is guarded by that class, so the
   desktop client is untouched at ≥768px.

   Model: "command center in your pocket".
   - persistent layer: compact topbar (year/phase/risks) + bottom nav
   - main layer: one task at a time (the decision card)
   - research layer: world / cabinet / feed / more, one tap away
   ============================================================ */

/* mobile-only DOM zones stay invisible on desktop */
.m-attention, .m-advisors, .m-more, .metric--m { display: none; }

body.is-mobile {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-text-size-adjust: 100%;
}
body.is-mobile .metric--m { display: flex; }

/* the stage becomes a fluid document */
body.is-mobile .stage {
  width: 100%;
  min-height: 100dvh;
  height: auto;
  overflow: visible;
  transform: none;
}

/* heavy decorative layers off: contrast + perf on small screens */
body.is-mobile .scanlines::after,
body.is-mobile .vignette,
body.is-mobile .bg-grid { display: none; }
/* portrait backdrop: the desktop space.jpg is landscape and crops badly on a
   tall phone; space-mobile.jpg is a 9:16 Earth-from-orbit shot that covers the
   whole screen cleanly. Fixed so it stays put while the document scrolls. */
body.is-mobile .stage::before {
  position: fixed; inset: 0;
  background: url(../assets/bg/space-mobile.jpg) center / cover no-repeat;
  opacity: .18;
}

/* every interactive control ≥44px tall. Buttons wrap + shrink instead of
   overflowing: base .btn is nowrap/no-shrink for the fixed desktop stage, but
   on a fluid phone width the longer Russian labels ran past the button edge.
   The html[lang="ru"] rules in godmode.css set .btn font-size, so the mobile
   overrides below carry that same [lang] prefix to win on specificity. */
body.is-mobile .btn {
  min-height: 44px; padding: 10px 14px;
  font-size: 14px; letter-spacing: .05em; line-height: 1.2;
  white-space: normal; flex-shrink: 1;
}
body.is-mobile .btn--sm { min-height: 44px; font-size: 12px; letter-spacing: .04em; padding: 8px 12px; }
body.is-mobile .btn--lg { font-size: 16px; padding: 14px 20px; }
html[lang="ru"] body.is-mobile .btn { font-size: 13px; letter-spacing: .04em; }
html[lang="ru"] body.is-mobile .btn--sm { font-size: 12px; }
html[lang="ru"] body.is-mobile .btn--lg { font-size: 15px; }
body.is-mobile .chip { min-height: 30px; }

/* ================================================== title screen */

body.is-mobile #screen-title { min-height: 100dvh; position: relative; overflow: hidden; }
body.is-mobile #screen-title .center {
  position: relative; inset: auto;
  padding: calc(48px + env(safe-area-inset-top)) 20px 120px;
}
body.is-mobile #screen-title .halo { display: none; }
/* portrait phone: use the 9:16 backdrop at cover so the planet fills the
   screen cleanly (the desktop landscape shot needed contain-letterboxing) */
body.is-mobile #screen-title .bg-planet {
  background-image: url(../assets/bg/space-mobile.jpg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: .7;
}
body.is-mobile #screen-title .ribbon {
  position: static; transform: none;
  width: fit-content; margin: 26px auto 0;
  padding: 10px 18px;
  font-size: 12px; letter-spacing: .18em;
  display: block;
}
body.is-mobile #title-overline { font-size: 11px; letter-spacing: .18em; text-align: center; }
body.is-mobile #screen-title .title-logo { margin-top: 20px; --wm: 44px !important; }
body.is-mobile #screen-title .tagline {
  margin-top: 18px; font-size: 13px; letter-spacing: .3em; text-indent: .3em; text-align: center;
}
body.is-mobile #screen-title .menu { margin-top: 44px; width: 100%; max-width: 340px; gap: 14px; }
body.is-mobile #screen-title .foot {
  position: absolute; bottom: calc(14px + env(safe-area-inset-bottom));
  padding: 0 16px; font-size: 11px;
  flex-wrap: wrap; gap: 6px 14px; justify-content: center;
}
/* the title screen ribbon link needs a tap target too */
body.is-mobile #screen-title .center { display: flex; flex-direction: column; align-items: center; }

/* ================================================== game console: tabs */

body.is-mobile .console {
  position: relative; inset: auto;
  min-height: 100dvh;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 10px
           calc(132px + env(safe-area-inset-bottom));
}
/* .mid is only a desktop row wrapper — flatten it so its children obey tabs */
body.is-mobile .mid { display: contents; }

/* -- tab visibility --------------------------------------------- */
/* Ход (default): topbar + card + advisor strip */
body.is-mobile #metrics,
body.is-mobile #markets,
body.is-mobile #m-attention,
body.is-mobile #nodes,
body.is-mobile #feed,
body.is-mobile #controls,
body.is-mobile #m-more { display: none; }

/* Мир */
body.is-mobile[data-mtab="world"] #metrics { display: grid; }
body.is-mobile[data-mtab="world"] #markets { display: grid; }
body.is-mobile[data-mtab="world"] #m-attention { display: flex; }
body.is-mobile[data-mtab="world"] #nodes { display: flex; }
body.is-mobile[data-mtab="world"] #card,
body.is-mobile[data-mtab="world"] #m-advisors { display: none; }

/* Ещё */
body.is-mobile[data-mtab="more"] #m-more { display: flex; }
body.is-mobile[data-mtab="more"] #card,
body.is-mobile[data-mtab="more"] #m-advisors { display: none; }

/* ================================================== topbar (persistent layer) */

body.is-mobile .topbar {
  height: auto; flex: none;
  flex-wrap: wrap; align-items: center;
  gap: 6px 8px; padding: 10px 118px 10px 14px;
  --cut: 10px;
  position: sticky; top: 0; z-index: 30;
}
body.is-mobile .topbar [data-logo] { display: none; }
body.is-mobile .topbar .year { font-size: 24px; margin-right: 4px; }
body.is-mobile .topbar .spacer { display: none; }
body.is-mobile .topbar .chip { font-size: 10px; letter-spacing: .08em; padding: 4px 8px; }
/* planet-health ring parks in the top-right corner instead of its own row */
body.is-mobile .ph {
  position: absolute; top: 8px; right: 10px; z-index: 2;
  flex-direction: row-reverse; gap: 6px; align-items: center;
}
body.is-mobile .ph .gauge { width: 44px; height: 44px; }
body.is-mobile .ph .g-val { font-size: 14px; }
body.is-mobile .ph .overline { font-size: 8px; letter-spacing: .1em; max-width: 56px; }
body.is-mobile .ph .data-sm { display: none; }

/* phase line + top risks — mobile-only elements inside the topbar */
.m-phase, .m-risks { display: none; }
body.is-mobile .m-phase {
  display: block; width: 100%; order: 10;
  font-family: var(--f-ui); font-weight: 600; font-size: 12px;
  letter-spacing: .16em; text-transform: uppercase; color: var(--cyan);
}
body.is-mobile .m-phase--wait { color: var(--warn); }
body.is-mobile .m-risks {
  display: flex; width: 100%; order: 11;
  gap: 6px; flex-wrap: wrap;
}
body.is-mobile .m-risks:empty { display: none; }
.m-risk {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; min-height: 28px;
  font-family: var(--f-ui); font-weight: 600; font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  cursor: pointer;
}
.m-risk--warn { color: var(--warn); background: rgba(255,180,84,.1); box-shadow: inset 0 0 0 1px rgba(255,180,84,.4); }
.m-risk--bad  { color: var(--bad);  background: rgba(255,107,97,.12); box-shadow: inset 0 0 0 1px rgba(255,107,97,.45); }
.m-risk .mr-ico { font-size: 12px; }

/* ================================================== world tab */

body.is-mobile .grid-metrics {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
body.is-mobile .metric { min-height: 96px; padding: 12px 14px 10px; --cut: 10px; }
body.is-mobile .metric .m-label { font-size: 10px; letter-spacing: .14em; top: 10px; left: 14px; right: 44px; }
body.is-mobile .metric .m-value { font-size: 24px; }
body.is-mobile .metric .m-delta { font-size: 12px; top: 9px; right: 12px; }

/* state word under the value — not colour-only */
.m-state { display: none; }
body.is-mobile .m-state {
  display: block;
  font-family: var(--f-ui); font-weight: 600; font-size: 10px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--dim);
  margin-top: 2px;
}
body.is-mobile .m-state--warn { color: var(--warn); }
body.is-mobile .m-state--bad { color: var(--bad); }
body.is-mobile .m-state--good { color: var(--good); }

body.is-mobile .grid-markets {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px;
}
body.is-mobile .market {
  height: auto; min-height: 72px; padding: 10px 12px;
  flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 2px;
  --cut: 9px;
}
body.is-mobile .market .m-label { font-size: 9px; letter-spacing: .1em; }
body.is-mobile .market .m-value { font-size: 18px; }
body.is-mobile .market .m-delta { position: static; font-size: 11px; }
body.is-mobile .market .spark { top: 6px; bottom: 26px; }

/* "требует внимания" — risks with a reason line, tap → chart */
body.is-mobile .m-attention {
  flex-direction: column; gap: 8px;
}
.m-attention .ma-head {
  font-family: var(--f-ui); font-weight: 600; font-size: 12px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--dim);
}
.m-attention .ma-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 48px;
  background: rgba(11,19,34,.75);
  box-shadow: inset 0 0 0 1px var(--edge);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  cursor: pointer;
}
.m-attention .ma-row--bad { box-shadow: inset 0 0 0 1px rgba(255,107,97,.45); }
.m-attention .ma-row--warn { box-shadow: inset 0 0 0 1px rgba(255,180,84,.4); }
.m-attention .ma-ico { font-size: 16px; }
.m-attention .ma-row--bad .ma-ico { color: var(--bad); }
.m-attention .ma-row--warn .ma-ico { color: var(--warn); }
.m-attention .ma-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.m-attention .ma-name {
  font-family: var(--f-ui); font-weight: 600; font-size: 14px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text);
}
.m-attention .ma-why { font-family: var(--f-body); font-size: 13px; color: var(--dim); }
.m-attention .ma-go { font-family: var(--f-ui); font-size: 12px; color: var(--cyan); }
.m-attention .ma-ok {
  padding: 10px 14px;
  font-family: var(--f-body); font-size: 14px; color: var(--dim);
}

/* mini-map plate */
body.is-mobile .nodes {
  width: auto; flex: none;
  min-height: 220px; padding: 14px 16px;
}
body.is-mobile .mini-map-legend { flex-wrap: wrap; gap: 8px 14px; }

/* ================================================== decision card (main layer) */

body.is-mobile .card {
  flex: none; min-height: 0;
  padding: 18px 16px 16px; --cut: 12px;
}
body.is-mobile .card-head { gap: 8px; }
body.is-mobile .card-head .overline { font-size: 11px; letter-spacing: .16em; }
body.is-mobile .card-head .chip { font-size: 10px; padding: 3px 8px; }
body.is-mobile .card-title { font-size: 22px; margin-top: 10px; line-height: 1.2; }
body.is-mobile .card-body {
  margin-top: 12px; font-size: 16px; line-height: 1.55;
  max-width: none; overflow: visible;
}
body.is-mobile .card-actions {
  flex-direction: column; gap: 12px; margin-top: 18px; padding-top: 0;
}
body.is-mobile .card-actions .btn {
  min-height: 64px; font-size: 15px; padding: 14px 16px; line-height: 1.35;
}
body.is-mobile .discard, body.is-mobile .discard-note { font-size: 12px; padding: 8px 0; }
body.is-mobile .deltas { font-size: 13px; word-break: break-word; }
body.is-mobile .wire-item { flex-direction: column; gap: 2px; }
body.is-mobile .wire-item .rg { font-size: 12px; }
body.is-mobile .wire-item--click { padding: 8px 8px; margin-left: -8px; }
body.is-mobile .news-flag { gap: 10px; padding: 10px 12px; margin: 4px 0 12px; }
body.is-mobile .news-flag .nf-icon { font-size: 20px; }
body.is-mobile .news-flag .nf-text { font-size: 14px; }
body.is-mobile .report-rows .readout td { font-size: 14px; padding: 8px 0; }

/* quick links after a consequence: jump to what just changed */
.m-quick { display: none; }
body.is-mobile .m-quick {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px;
}
.m-quick .mq {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 8px 14px;
  font-family: var(--f-ui); font-weight: 600; font-size: 12px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--cyan);
  background: rgba(94,200,247,.07);
  box-shadow: inset 0 0 0 1px rgba(94,200,247,.3);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  cursor: pointer; border: 0;
}

/* ================================================== advisor strip (turn screen) */

.m-advisors { display: none; }
body.is-mobile .m-advisors { display: flex; flex-direction: column; gap: 8px; }
body.is-mobile[data-mtab="world"] .m-advisors,
body.is-mobile[data-mtab="more"] .m-advisors { display: none; }
.m-advisors .mad-head {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--f-ui); font-weight: 600; font-size: 12px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--dim);
}
.m-advisors .mad-head .hot { color: var(--good); letter-spacing: .08em; }
.m-advisors .mad-row {
  display: flex; gap: 10px; overflow-x: auto;
  padding: 2px 2px 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.m-advisors .mad-row::-webkit-scrollbar { display: none; }
.mad {
  position: relative; flex: 0 0 auto;
  width: 76px; min-height: 104px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px 6px;
  background: rgba(11,19,34,.75);
  box-shadow: inset 0 0 0 1px var(--edge);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  cursor: pointer; border: 0; color: inherit; font: inherit;
}
.mad--hot { box-shadow: inset 0 0 0 1px rgba(99,230,165,.6), 0 0 12px rgba(99,230,165,.25); }
.mad .mad-img {
  width: 48px; height: 60px;
  clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
  background: #0A1424; box-shadow: inset 0 0 0 1px var(--edge-bright);
}
.mad .mad-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mad--trusted .mad-img { box-shadow: inset 0 0 0 2px #E8C15A, 0 0 10px rgba(232,193,90,.5); }
.mad .mad-name {
  font-family: var(--f-ui); font-weight: 600; font-size: 10px;
  letter-spacing: .04em; color: var(--text);
  max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mad .mad-mood {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 6px currentColor;
}
.mad .mad-hand {
  position: absolute; top: 2px; right: 4px; font-size: 15px;
  filter: drop-shadow(0 0 6px rgba(99,230,165,.8));
}
.mad .mad-conf {
  position: absolute; top: 2px; left: 4px; font-size: 11px; color: var(--bad);
}

/* ================================================== "ещё" tab */

body.is-mobile .m-more { flex-direction: column; gap: 10px; }
.m-more .mm-head {
  font-family: var(--f-ui); font-weight: 600; font-size: 12px;
  letter-spacing: .2em; text-transform: uppercase; color: var(--dim);
  margin-top: 8px;
}
.m-more .mm-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 12px 16px;
  background: rgba(11,19,34,.75);
  box-shadow: inset 0 0 0 1px var(--edge);
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  font-family: var(--f-ui); font-weight: 600; font-size: 15px;
  letter-spacing: .06em; color: var(--text);
  cursor: pointer; border: 0; text-transform: none;
}
.m-more .mm-row .mi { width: 22px; text-align: center; color: var(--cyan); }
.m-more .mm-row .sub { margin-left: auto; font-family: var(--f-data); font-size: 12px; color: var(--dim); text-align: right; }
.m-more .mm-note { font-family: var(--f-data); font-size: 11px; color: var(--steel-d); text-align: center; margin-top: 6px; }

/* ================================================== bottom nav + return chip */

.m-nav { display: none; }
body.is-mobile .m-nav {
  display: flex;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: rgba(5, 9, 17, .96);
  border-top: 1px solid var(--edge-bright);
  box-shadow: 0 -6px 24px rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
}
body.is-mobile.on-title .m-nav { display: none; }
.m-nav .m-tab {
  flex: 1; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; cursor: pointer;
  font-family: var(--f-ui); font-weight: 600; font-size: 11px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--dim);
  position: relative;
}
.m-nav .m-tab .ico { font-size: 18px; line-height: 1; }
.m-nav .m-tab.on { color: var(--cyan); text-shadow: 0 0 10px rgba(94,200,247,.55); }
.m-nav .m-tab.on::after {
  content: ""; position: absolute; top: 0; left: 26%; right: 26%;
  height: 2px; background: var(--cyan); box-shadow: 0 0 8px rgba(94,200,247,.8);
}
.m-nav .m-tab .badge {
  position: absolute; top: 4px; right: calc(50% - 22px);
  min-width: 16px; height: 16px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 10px; font-weight: 700;
  background: var(--good); color: #05240F;
}
.m-nav .m-tab .badge--dot {
  min-width: 8px; width: 8px; height: 8px; padding: 0; border-radius: 50%;
  background: var(--cyan);
}

.m-return { display: none; }
body.is-mobile .m-return:not([hidden]) {
  display: inline-flex; align-items: center; gap: 8px;
  position: fixed; z-index: 56;
  left: 50%; transform: translateX(-50%);
  bottom: calc(72px + env(safe-area-inset-bottom));
  min-height: 44px; padding: 10px 20px;
  font-family: var(--f-ui); font-weight: 700; font-size: 13px;
  letter-spacing: .12em; text-transform: uppercase;
  color: #EAF7FF; cursor: pointer; border: 0;
  background: linear-gradient(180deg, #1E5D8F 0%, #14436E 45%, #0E3054 100%);
  box-shadow: inset 0 1px 0 rgba(94,200,247,.5), 0 4px 18px rgba(0,0,0,.5), 0 0 16px rgba(94,200,247,.35);
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
}

/* ================================================== overlays (research layer) */

body.is-mobile .overlay {
  position: fixed; inset: 0; z-index: 40;
  background: #04070d; /* fully opaque: the turn screen must not bleed through */
  padding: calc(10px + env(safe-area-inset-top)) 12px
           calc(128px + env(safe-area-inset-bottom));
  gap: 10px;
  overflow-y: auto;
}
body.is-mobile .ov-head { flex-wrap: wrap; gap: 8px 12px; position: relative; }
body.is-mobile .ov-title { font-size: 20px; }
body.is-mobile .ov-sub { font-size: 12px; width: 100%; order: 5; }
body.is-mobile .ov-head .chip { font-size: 10px; }

body.is-mobile .modal-wrap {
  position: fixed; inset: 0; z-index: 60;
  padding: calc(12px + env(safe-area-inset-top)) 12px
           calc(12px + env(safe-area-inset-bottom));
}
body.is-mobile .modal { width: 100%; padding: 24px 16px; }
/* leave room for the absolute close ✕ so the title never runs under it */
body.is-mobile .modal .m-title { font-size: 18px; letter-spacing: .05em; padding-right: 44px; line-height: 1.2; }
body.is-mobile .modal .m-note { font-size: 12px; }
/* stack the modal action buttons full-width — side-by-side, the longer
   Russian labels ("Продолжить последнюю игру ▸") had no room to shrink into */
body.is-mobile .modal .m-actions { flex-direction: column; }
body.is-mobile .modal .m-actions .btn { flex: 1 1 auto; width: 100%; }

body.is-mobile #toast {
  position: fixed; bottom: calc(78px + env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 480px;
  font-size: 14px; text-align: center;
}

/* ================================================== war room / desk / candidates */

body.is-mobile .wr-grid {
  display: flex; flex-direction: column; gap: 12px;
  flex: none; overflow: visible;
}
body.is-mobile .domain { padding: 14px 16px; }
body.is-mobile .domain .d-title { font-size: 16px; }
body.is-mobile .domain .readout { flex: none; }
body.is-mobile .domain .readout td { font-size: 13px; padding: 4px 0; }
body.is-mobile .domain .btn { min-height: 48px; }

body.is-mobile .desk-body { flex-direction: column; gap: 12px; flex: none; }
body.is-mobile .profile {
  width: auto; flex: none;
  padding: 14px 16px;
  display: grid; grid-template-columns: 72px 1fr; gap: 4px 14px;
  align-items: start; overflow: visible;
}
body.is-mobile .profile .avatar {
  width: 72px; height: 94px; margin-bottom: 0; grid-row: 1 / 5;
}
body.is-mobile .p-name { font-size: 18px; }
body.is-mobile .p-role { font-size: 12px; margin-top: 2px; }
body.is-mobile .p-since { margin-top: 2px; font-size: 11px; }
/* long bio + domain numbers fold away behind a tap on mobile */
body.is-mobile .profile .p-fold { grid-column: 1 / -1; }
body.is-mobile .profile .p-fold summary {
  list-style: none; cursor: pointer; min-height: 40px;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-ui); font-weight: 600; font-size: 12px;
  letter-spacing: .14em; text-transform: uppercase; color: var(--cyan);
}
body.is-mobile .profile .p-fold summary::-webkit-details-marker { display: none; }
body.is-mobile .profile .p-bio { margin-top: 6px; }
body.is-mobile .profile .p-fold .overline { margin: 12px 0 8px; display: block; }

body.is-mobile .consult { padding: 14px 14px; flex: none; }
body.is-mobile .chat {
  flex: none; max-height: 46dvh; padding-right: 6px;
  overscroll-behavior: contain;
}
body.is-mobile .msg { max-width: 94%; padding: 10px 14px; }
body.is-mobile .msg .body { font-size: 15px; line-height: 1.5; }
body.is-mobile .ask-row { flex-wrap: wrap; gap: 10px; }
body.is-mobile .ask-input { flex: 1 1 100%; }
body.is-mobile .ask-input input { height: 48px; font-size: 16px; padding: 0 14px; }
body.is-mobile .ask-row .btn { flex: 1; }

/* suggested prompts above the ask box */
.m-prompts { display: none; }
body.is-mobile .m-prompts { display: flex; gap: 8px; overflow-x: auto; margin-top: 12px;
  padding-bottom: 4px; scrollbar-width: none; }
body.is-mobile .m-prompts::-webkit-scrollbar { display: none; }
.m-prompts .mp {
  flex: 0 0 auto; min-height: 40px; padding: 8px 14px;
  font-family: var(--f-body); font-size: 13px; color: var(--text);
  background: rgba(94,200,247,.07);
  box-shadow: inset 0 0 0 1px rgba(94,200,247,.28);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  cursor: pointer; border: 0;
}

body.is-mobile .cands { gap: 12px; flex: none; overflow: visible; }
body.is-mobile .cand { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; }
body.is-mobile .cand .c-portrait { align-self: center; }
body.is-mobile .cand .btn { width: 100%; }

/* ================================================== map */

body.is-mobile .map-overlay { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
body.is-mobile .map-body { flex-direction: column; gap: 8px; min-height: 0; flex: 1; }
body.is-mobile .map-wrap { padding: 0; flex: 1; min-height: 40dvh; }
body.is-mobile #map-slot { touch-action: none; }
body.is-mobile #world-svg { touch-action: none; }
body.is-mobile .map-tabs {
  margin-left: 0; width: 100%; order: 6;
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; padding-bottom: 4px;
}
body.is-mobile .map-tabs::-webkit-scrollbar { display: none; }
body.is-mobile .map-tabs .prov-tab { flex: 0 0 auto; min-width: 0; min-height: 40px; font-size: 13px; }
body.is-mobile .map-legend { font-size: 11px; }
body.is-mobile .map-layers-legend { gap: 8px 14px; font-size: 10px; }

/* map reset zoom button (mobile-only, injected by app.js) */
.map-reset { display: none; }
body.is-mobile .map-reset {
  display: inline-flex; align-items: center; justify-content: center;
  position: absolute; right: 10px; top: 10px; z-index: 5;
  width: 44px; height: 44px; border: 0; cursor: pointer;
  font-size: 18px; color: var(--cyan);
  background: rgba(8,14,26,.85);
  box-shadow: inset 0 0 0 1px var(--edge-bright);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

/* country card: bottom sheet over the map, geography stays visible above it */
body.is-mobile .map-info-slot {
  width: auto; flex: none;
  position: fixed; left: 0; right: 0; z-index: 45;
  bottom: calc(64px + env(safe-area-inset-bottom));
  max-height: 46dvh; overflow-y: auto;
  padding: 0 10px;
}
body.is-mobile .map-info-slot:not(.has-sel) { display: none; }
body.is-mobile .map-info {
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  background: rgba(7, 11, 19, .97);
  box-shadow: inset 0 0 0 1px var(--edge-bright), 0 -8px 30px rgba(0,0,0,.6);
}
body.is-mobile .map-info .mi-name { font-size: 19px; margin-bottom: 10px; }
body.is-mobile .map-info .readout td { font-size: 13px; padding: 6px 0; }
body.is-mobile .map-info .mi-close { min-height: 40px; min-width: 44px; }
body.is-mobile .stab-actions .btn { flex: 1 1 30%; }

/* ================================================== newswire / article */

body.is-mobile .news-list { padding-right: 0; flex: none; overflow: visible; }
body.is-mobile .news-year .ny-head { font-size: 17px; }
body.is-mobile .news-grid { grid-template-columns: 1fr; gap: 10px; }
body.is-mobile .news-item .n-art { width: 96px; flex: 0 0 96px; }
body.is-mobile .news-item .n-body { padding: 10px 12px; gap: 5px; }
body.is-mobile .news-item .n-tag { font-size: 10px; letter-spacing: .12em; }
body.is-mobile .news-item .n-headline { font-size: 14px; line-height: 1.4; }
body.is-mobile .news-item--click .n-more { opacity: .9; font-size: 11px; margin-top: 2px; }

body.is-mobile .article-modal { width: 100%; }
body.is-mobile .article-modal .art-hero { height: 140px; }
body.is-mobile .article-modal .art-title { font-size: 20px; }
body.is-mobile .article-modal .art-p { font-size: 16px; line-height: 1.6; }

/* ================================================== chart overlay */

body.is-mobile .chart-panel { padding: 10px; flex: 1; min-height: 46dvh; }
body.is-mobile .chart-box svg { touch-action: none; }
body.is-mobile .ch-tick { font-size: 26px; }
body.is-mobile .chart-tip { padding: 6px 10px; }
body.is-mobile .chart-tip .t-val { font-size: 15px; }
body.is-mobile .ov-head .data-md { font-size: 17px; }
body.is-mobile .ov-head .data-sm { font-size: 11px; }

/* ================================================== history / leaderboard / solutions */

body.is-mobile .hist-list { padding-right: 4px; }
body.is-mobile .hist-item .h-head { font-size: 15px; }
body.is-mobile .hist-item .h-choice { font-size: 14px; }
body.is-mobile .lb-list { padding-right: 4px; }
body.is-mobile .lb-name { font-size: 15px; }
body.is-mobile .lb-score { font-size: 18px; }
body.is-mobile .overlay > .cham:not(.chart-panel) { padding: 16px 14px !important; flex: none !important; }

body.is-mobile .sol-panel {
  width: 100%; max-height: none; margin: auto 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
body.is-mobile .sol-row { flex-wrap: wrap; gap: 10px; padding: 12px 0; }
body.is-mobile .sol-row .s-name { flex: 1 1 100%; font-size: 15px; }
body.is-mobile .sol-row .btn { width: 100%; }

/* ================================================== finale */

/* dvh (not the fixed inset:0 = 100vh) so the mobile browser's collapsing
   toolbar can't hide the bottom; -webkit-overflow-scrolling for momentum.
   Extra bottom padding guarantees the action buttons clear the browser UI. */
body.is-mobile .fin {
  position: fixed; left: 0; right: 0; top: 0;
  height: 100dvh;
  /* flex-start, NOT stretch: stretch forces the panel to the viewport height
     and its flex column then clips the advisors + action buttons past the
     fold. flex-start lets the panel grow to its content so .fin can scroll
     the whole thing. */
  align-items: flex-start;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
body.is-mobile .fin-panel {
  width: 100%; max-width: none; max-height: none;
  margin: 0; padding: calc(20px + env(safe-area-inset-top)) 16px
                      calc(56px + env(safe-area-inset-bottom));
  overflow: visible;
}
/* the finish buttons are the whole point of this screen — keep them big and
   never let the row clip a label */
body.is-mobile .fin-actions { padding-top: 4px; }
body.is-mobile .fin-actions .btn { min-height: 48px; }
body.is-mobile .fin-body { grid-template-columns: 1fr; gap: 18px; }
body.is-mobile .fin-title { font-size: 22px; }
body.is-mobile .score-num { font-size: 30px; }
body.is-mobile .reveal-grid { grid-template-columns: 1fr; }
body.is-mobile .fin-actions .btn { flex: 1 1 100%; }
body.is-mobile .fin-nick { flex-wrap: wrap; }
body.is-mobile .fin-nick input { min-height: 48px; flex: 1 1 100%; }

/* ================================================== intro + tutorial */

body.is-mobile #intro-root { position: fixed; inset: 0; }
/* mobile briefing uses a still portrait image instead of the landscape video
   (which cropped hard and is heavy on a phone). Hide the video, paint the
   9:16 backdrop on .intro-bg; the typed briefing runs straight over it. */
body.is-mobile .intro-video { display: none; }
body.is-mobile .intro-bg {
  background: url(../assets/bg/space-mobile.jpg) center / cover no-repeat, #02040A;
}
body.is-mobile .intro-stage { padding: calc(24px + env(safe-area-inset-top)) 20px 90px; justify-content: flex-start; overflow-y: auto; }
body.is-mobile .intro-tag { font-size: 12px; letter-spacing: .18em; margin: 12px 0 16px; }
body.is-mobile .intro-text { font-size: 15px; line-height: 1.65; min-height: 0; }
body.is-mobile .intro-actions { margin-top: 24px; }

/* mobile tour: bottom sheet + glow outline on live elements (no spotlight —
   the desktop dim/hole scheme fights body scroll on phones) */
body.is-mobile #tutorial-root { position: fixed; inset: 0; }
body.is-mobile #tutorial-root.tut-mobile { pointer-events: none; }
body.is-mobile #tutorial-root.tut-mobile .tut-sheet { pointer-events: auto; }
body.is-mobile .tut-sheet {
  position: fixed; left: 10px; right: 10px;
  bottom: calc(78px + env(safe-area-inset-bottom)); /* clear of the nav bar */
  z-index: 70;
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px 12px; max-height: 40dvh;
}
/* per-step sheet positions (see M_TUT_STEPS layout contract) */
body.is-mobile .tut-sheet--top {
  bottom: auto;
  top: calc(8px + env(safe-area-inset-top));
}
body.is-mobile .tut-sheet--center {
  bottom: auto;
  top: 50%;
  transform: translateY(-50%);
  max-height: 58dvh; /* the briefing step carries the longest copy */
}

/* full-screen dim between the app and the sheet: the sheet must clearly
   dominate the background on every step */
body.is-mobile .tut-dim-m {
  position: fixed; inset: 0; z-index: 66;
  background: rgba(3, 5, 10, .64);
  pointer-events: auto; /* freeze the app behind the tour */
}
/* spotlight variant: the element under the hole keeps full brightness while
   the same wash covers everything else (used only where the spec asks) */
body.is-mobile .tut-dim-m--hole {
  inset: auto;
  background: transparent;
  box-shadow: 0 0 0 4000px rgba(3, 5, 10, .64);
  border-radius: 3px;
  outline: 2px solid rgba(94, 200, 247, .95);
  outline-offset: 2px;
  animation: tut-glow 1.6s ease-in-out infinite;
  pointer-events: none; /* the chip itself stays tappable */
}
body.is-mobile .tut-sheet .t-step { font-family: var(--f-data); font-size: 12px; color: var(--dim); }
body.is-mobile .tut-sheet .t-title {
  font-family: var(--f-ui); font-weight: 700; font-size: 18px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--cyan);
  text-shadow: 0 0 16px rgba(94,200,247,.4);
}
body.is-mobile .tut-sheet .ts-text { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
body.is-mobile .tut-sheet .t-text { font-family: var(--f-body); font-size: 14px; line-height: 1.5; color: var(--text); }
body.is-mobile .tut-sheet .t-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
body.is-mobile .tut-sheet .t-actions .btn { min-height: 44px; }
body.is-mobile .tut-sheet .t-skip {
  margin-left: auto; min-height: 44px;
  font-family: var(--f-ui); font-size: 13px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--steel-d);
  background: none; border: 0; cursor: pointer;
}

@keyframes tut-glow {
  0%, 100% { outline-color: rgba(94, 200, 247, .95); }
  50% { outline-color: rgba(94, 200, 247, .3); }
}
@media (prefers-reduced-motion: reduce) { .tut-dim-m--hole { animation: none; } }

/* ================================================== reduced motion */

@media (prefers-reduced-motion: reduce) {
  .pulse, .feed-track, .mad-hand,
  .intro-caret, .intro-tag::before { animation: none !important; }
  body.is-mobile * { transition-duration: .01ms !important; }
}
