@font-face { font-family: 'Golos Text'; font-weight: 400; font-display: swap; src: url(fonts/golos-text-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; font-weight: 400; font-display: swap; src: url(fonts/golos-text-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Golos Text'; font-weight: 600; font-display: swap; src: url(fonts/golos-text-cyrillic-600-normal.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; font-weight: 600; font-display: swap; src: url(fonts/golos-text-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url(fonts/jetbrains-mono-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url(fonts/jetbrains-mono-cyrillic-400-normal.woff2) format('woff2'); unicode-range: U+0400-045F; }
@font-face { font-family: 'JetBrains Mono'; font-weight: 500; font-display: swap; src: url(fonts/jetbrains-mono-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+2212; }

:root {
  --panel: #11141B; --panel2: #161A23; --line: #262B36; --line2: #323848;
  --head: #8A93A3; --text: #C9CFDA; --num: #E6E8EC;
  --amber: #E8A04A; --cold: #7FB8D9; --hot: #E0603A; --water: #2FA3C7; --life: #9CC75A; --warn: #D9534F;
  --gap: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: #0B1220 url(assets/space.jpg) center / cover no-repeat;
  color: var(--text); font-family: 'Golos Text', system-ui, sans-serif; font-size: 14px;
  -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 46%, rgba(11,18,32,0) 45%, rgba(6,10,18,0.75) 100%); }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; color: var(--num); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.ph { margin: 0 0 12px; font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--head); position: relative; padding-bottom: 9px; }
.ph::after { content: ''; position: absolute; left: 0; bottom: 0; width: 36px; height: 2px; background: var(--amber); border-radius: 1px; }
.phone-only { display: none !important; }
button { font: inherit; color: inherit; }
.btn { height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); cursor: pointer; font-size: 13px; transition: border-color .15s, color .15s, background .15s; white-space: nowrap; }
.btn:hover { border-color: #4a5266; color: var(--num); }
.btn.primary { border-color: var(--amber); color: var(--amber); }
.btn.primary:hover { background: rgba(232,160,74,.1); }
.btn.icon { width: 32px; padding: 0; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- top bar ---------- */
#top { position: fixed; top: var(--gap); left: var(--gap); right: var(--gap); height: 52px; display: flex; align-items: center; gap: 18px; padding: 0 14px; z-index: 5; }
.brand { display: flex; align-items: baseline; gap: 12px; padding-left: 10px; border-left: 3px solid var(--amber); min-width: 0; }
.wordmark { font-weight: 600; font-size: 21px; letter-spacing: .07em; color: #EEF0F4; white-space: nowrap; }
.wordmark b { color: var(--amber); font-weight: 600; }
.pname { color: var(--head); font-size: 13px; white-space: nowrap; }
.res { display: flex; gap: 18px; padding-left: 18px; border-left: 1px solid var(--line); margin-left: 4px; }
.r { display: flex; align-items: center; gap: 7px; }
.r img { width: 24px; height: 24px; }
.rl { color: var(--head); font-size: 12px; }
.r .num { font-size: 14px; }
.r.sci .num { color: var(--amber); }
.when { display: flex; gap: 18px; padding-left: 18px; border-left: 1px solid var(--line); margin-left: auto; }
.w { display: flex; flex-direction: column; line-height: 1.15; }
.w .lab { font-size: 10.5px; color: var(--head); letter-spacing: .04em; text-transform: uppercase; }
.w .val { color: var(--life); font-weight: 600; font-size: 13.5px; white-space: nowrap; transition: color .15s; }
.w .num { font-size: 13.5px; white-space: nowrap; }
.acts { display: flex; gap: 8px; }

/* ---------- left: tools ---------- */
#left { position: fixed; left: var(--gap); top: 72px; width: 230px; max-height: calc(100% - 72px - 78px); overflow-y: auto; padding: 14px 12px 12px; z-index: 4; scrollbar-width: thin; scrollbar-color: #2b3140 transparent; }
.grp { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: #6F7888; margin: 10px 2px 6px; text-transform: uppercase; }
.grp:first-child { margin-top: 0; }
.tool { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; margin-bottom: 6px; padding: 5px 8px 5px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; text-align: left; transition: border-color .15s, background .15s; }
.tool::before { content: ''; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 2px; border-radius: 1px; background: rgba(232,160,74,.35); transition: background .15s, top .15s, bottom .15s, width .15s; }
.tool:hover { border-color: #3a4152; }
.tool.on { border-color: rgba(232,160,74,.75); background: #1c1a16; }
.tool.on::before { background: var(--amber); width: 3px; top: -1px; bottom: -1px; }
.tool img { width: 30px; height: 30px; flex: none; }
.tool .tn { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.tool .tl { color: #E3E6EC; font-size: 13.5px; }
.tool .ts { display: none; }
.tool .tc { color: var(--head); font-size: 11px; }
.tool .tc .num { font-size: 11px; color: var(--head); }
.tool.global { cursor: default; }
.tool.global .tv { font-size: 11.5px; color: var(--num); }
.step { display: flex; gap: 4px; flex: none; }
.step button { width: 26px; height: 26px; border-radius: 5px; border: 1px solid var(--line2); background: #10131a; color: var(--num); cursor: pointer; font-family: 'JetBrains Mono', monospace; font-size: 15px; line-height: 1; transition: border-color .15s, color .15s; }
.step button:hover { border-color: var(--amber); color: var(--amber); }
.brush { margin-top: 10px; padding: 8px 4px 2px; border-top: 1px solid var(--line); }
.bl { display: flex; justify-content: space-between; color: var(--head); font-size: 12px; margin-bottom: 6px; }
input[type=range] { width: 100%; accent-color: var(--amber); height: 18px; }

/* ---------- right: parameters ---------- */
#right { position: fixed; right: var(--gap); top: 72px; width: 300px; max-height: calc(100% - 72px - 78px); overflow-y: auto; padding: 14px 14px 12px; z-index: 4; scrollbar-width: thin; scrollbar-color: #2b3140 transparent; }
.prm { display: grid; grid-template-columns: 26px 1fr auto; grid-template-rows: auto auto; column-gap: 10px; row-gap: 5px; align-items: center; margin-bottom: 11px; }
.prm img { width: 24px; height: 24px; grid-row: 1 / 3; }
.prm .pl { color: #E3E6EC; font-size: 13.5px; }
.prm .pv { font-size: 13px; justify-self: end; }
.prm .bar { grid-column: 2 / 4; }
.bar { height: 5px; border-radius: 3px; background: #1d2230; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--cold); transition: width .3s, background-color .3s; }
.bar i.green { background: var(--life); } .bar i.blue { background: var(--water); } .bar i.grey { background: #AEB6C6; }
.bar i.warn { background: var(--warn); } .bar i.cloud { background: #C9D3E0; } .bar i.press { background: #8FB6E0; }
.sparks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 12px; }
.sp { background: #0f1218; border: 1px solid var(--line); border-radius: 6px; padding: 6px 7px 4px; }
.spl { display: flex; justify-content: space-between; font-size: 11px; color: var(--head); margin-bottom: 3px; }
.spl .num { font-size: 11px; }
.sp canvas { width: 100%; height: 40px; display: block; }
.eco { background: #0f1218; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.er { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); height: 26px; }
.er img { width: 18px; height: 18px; opacity: .9; }
.er .num { font-size: 12.5px; }
.status { margin-top: 6px; padding: 6px 0 2px 10px; border-left: 3px solid var(--life); font-size: 12.5px; color: #E3E6EC; line-height: 1.35; transition: border-color .15s; }
.status.warn { border-left-color: var(--warn); }

/* ---------- bottom: time ---------- */
#bottom { position: fixed; left: var(--gap); right: var(--gap); bottom: var(--gap); height: 58px; display: flex; align-items: center; gap: 18px; padding: 0 14px; z-index: 5; }
.seg { display: flex; gap: 6px; }
.seg button { height: 38px; min-width: 52px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--line2); background: var(--panel2); color: #D5DAE3; cursor: pointer; font-family: 'JetBrains Mono', monospace; font-size: 14px; transition: background .15s, color .15s, border-color .15s; }
.seg button:first-child { font-family: 'Golos Text', sans-serif; display: flex; align-items: center; gap: 8px; }
.pz { color: var(--amber); font-size: 12px; letter-spacing: -2px; }
.seg button.on { background: var(--amber); border-color: var(--amber); color: #15120d; }
.seg button.on .pz { color: #15120d; }
.timeline { flex: 1; min-width: 80px; position: relative; height: 40px; }
.track { position: absolute; left: 6px; right: 6px; top: 12px; height: 4px; border-radius: 2px; background: #252b39; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 2px; background: linear-gradient(90deg, #a87035, var(--amber)); }
.thumb { position: absolute; top: -6px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: #2a2218; border: 2px solid var(--amber); left: 0; }
.ticks i { position: absolute; top: 9px; width: 1px; height: 6px; background: #4a5162; }
.ticks i.era { top: -5px; height: 14px; width: 2px; background: var(--life); }
.ticks i.era::after { content: attr(data-n); position: absolute; top: -13px; left: -3px; font-size: 9px; color: var(--life); font-style: normal; font-family: 'JetBrains Mono', monospace; }
.tl-lab { position: absolute; top: 24px; font-size: 12px; transform: translateX(-50%); left: 0; white-space: nowrap; color: var(--text); }
.tl-end { display: flex; align-items: center; gap: 8px; padding-left: 16px; border-left: 1px solid var(--line); }
.tl-end img { width: 20px; height: 20px; opacity: .8; }
.tl-end .num { font-size: 13px; }
.zoom { display: flex; gap: 6px; }

/* ---------- hint, toasts, help ---------- */
#hint { position: fixed; left: 50%; transform: translateX(-50%); top: 72px; z-index: 3; max-width: min(560px, calc(100% - 560px)); text-align: center; font-size: 12.5px; color: #B9C0CC; background: rgba(17,20,27,.92); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; pointer-events: none; line-height: 1.35; }
#hint b { color: var(--amber); font-weight: 600; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 80px; z-index: 6; display: flex; flex-direction: column-reverse; gap: 6px; align-items: center; pointer-events: none; }
.toast { min-width: 240px; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--life); border-radius: 6px; padding: 8px 14px; font-size: 13px; color: #E6E8EC; opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
.toast.in { opacity: 1; transform: none; }
.modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100% - 24px)); max-height: calc(100% - 40px); overflow: auto; padding: 18px 20px; z-index: 20; }
.modal p, .modal li { font-size: 13.5px; line-height: 1.5; color: #D3D8E1; }
.modal ul { padding-left: 18px; margin: 8px 0 14px; }
.modal b { color: #EEF0F4; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; color: #B9C0CC; font-size: 15px; z-index: 30; pointer-events: none; }

/* ---------- rails: narrow screens ---------- */
@media (max-width: 1099px), (max-height: 600px) {
  .rl, .pname { display: none; }
  .res { gap: 12px; padding-left: 12px; }
  .when { gap: 12px; padding-left: 12px; }
  .wordmark { font-size: 17px; }
  #left { width: 82px; padding: 10px 8px; }
  #left .ph, #left .grp { display: none; }
  .tool { flex-direction: column; gap: 2px; padding: 6px 2px 4px; min-height: 0; text-align: center; }
  .tool .tc, .tool .tl { display: none; }
  .tool .ts { display: block; font-size: 10.5px; color: #D5DAE3; line-height: 1.15; }
  .tool .tv { font-size: 10px; }
  .tool .tn { align-items: center; }
  .step button { width: 28px; height: 24px; font-size: 14px; }
  .brush .bl span:first-child { display: none; }
  #right { width: 168px; padding: 10px; }
  #right .ph { font-size: 11px; }
  .prm { grid-template-columns: 22px 1fr auto; margin-bottom: 9px; column-gap: 6px; }
  .prm img { width: 20px; height: 20px; }
  .prm .pl { font-size: 11.5px; }
  .prm .pv { font-size: 11.5px; }
  .sparks { grid-template-columns: 1fr; }
  .er { font-size: 11px; grid-template-columns: 16px 1fr auto; }
  .er span:nth-child(2) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #hint { max-width: calc(100% - 300px); }
}
@media (max-width: 860px) and (min-width: 700px) {
  .when .w:first-child { display: none; }
  .acts .btn:not(.icon) { padding: 0 8px; font-size: 12px; }
}
@media (max-height: 600px) and (min-width: 700px) {
  #top { height: 44px; }
  #left, #right { top: 60px; max-height: calc(100% - 60px - 62px); }
  #bottom { height: 46px; }
  .seg button { height: 32px; }
  #hint { top: 60px; }
  .sparks, .eco .er { display: none; }
}

/* ---------- phone: bottom sheet ---------- */
@media (max-width: 699px) {
  :root { --gap: 6px; }
  .phone-only { display: flex !important; }
  #top { height: 46px; gap: 10px; padding: 0 8px; }
  .brand { padding-left: 8px; border-left-width: 2px; }
  .wordmark { font-size: 12.5px; letter-spacing: .02em; }
  .pname, .when, .acts, .rl { display: none; }
  .res { margin-left: auto; gap: 8px; padding-left: 8px; }
  .r { gap: 3px; }
  .r img { width: 18px; height: 18px; }
  .r .num { font-size: 12px; }
  #b-params { flex: none; }
  #chips { position: fixed; top: 58px; left: 6px; right: 6px; display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 6px; z-index: 4; }
  .chip { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; cursor: pointer; min-width: 0; }
  .chip img { width: 22px; height: 22px; flex: none; }
  .cb { flex: 1; min-width: 0; }
  .ct { display: flex; flex-direction: column; font-size: 10px; color: #AEB6C6; gap: 1px; margin-bottom: 4px; white-space: nowrap; line-height: 1.15; }
  .ct .num { font-size: 12px; color: var(--num); }
  .ct span:first-child { overflow: hidden; text-overflow: ellipsis; }
  .ct .num { font-size: 11px; }
  #left { left: 6px; right: 6px; top: auto; bottom: 64px; width: auto; max-height: none; padding: 8px 8px 6px; overflow: visible; border-radius: 10px 10px 6px 6px; }
  #left .ph, #left .grp { display: none; }
  .groups { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .groups::-webkit-scrollbar { display: none; }
  .tool { flex: none; width: 74px; min-height: 74px; flex-direction: column; justify-content: center; gap: 3px; padding: 6px 3px; margin: 0; text-align: center; }
  .tool img { width: 32px; height: 32px; }
  .tool .tl, .tool .tc { display: none; }
  .tool .ts { display: block; font-size: 11px; color: #E3E6EC; line-height: 1.1; }
  .tool .tn { align-items: center; }
  .tool .tv { font-size: 10px; }
  .tool.global { width: 92px; }
  .step button { width: 30px; height: 24px; }
  .brush { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 6px 4px 0; }
  .bl { margin: 0; gap: 8px; white-space: nowrap; }
  #right { display: none; left: 6px; right: 6px; top: auto; bottom: 64px; width: auto; max-height: 64%; z-index: 9; border-radius: 10px 10px 6px 6px; }
  body.sheet #right { display: block; }
  #right .ph { display: none; }
  .sheet-head { justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--head); }
  .sheet-acts { gap: 8px; margin-top: 12px; flex-wrap: wrap; }
  #bottom { height: 52px; gap: 8px; padding: 0 6px; border-radius: 6px; }
  .seg { flex: 1; }
  .seg button { flex: 1; min-width: 0; padding: 0 6px; height: 38px; font-size: 13px; }
  .timeline, .tl-end { display: none; }
  .zoom .btn { width: 34px; height: 38px; }
  #hint { top: 104px; bottom: auto; width: calc(100% - 12px); max-width: none; font-size: 11.5px; padding: 4px 10px; }
  #toasts { bottom: auto; top: 150px; }
  .toast { min-width: 200px; max-width: calc(100vw - 24px); font-size: 12.5px; }
}
@media (max-width: 379px) {
  .wordmark { font-size: 11px; letter-spacing: 0; }
  .res { gap: 6px; padding-left: 6px; }
  .r img { width: 16px; height: 16px; }
  .r .num { font-size: 11px; }
}

/* ================= menus, tabs, shop, settings, people ================= */
body.in-menu .game-ui, body.in-menu #toasts { display: none !important; }
#menu { position: fixed; inset: 0; z-index: 10; display: none; pointer-events: none; }
body.in-menu #menu { display: block; }
.menu-col { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: max(18px, 4vh) 12px max(14px, 3vh); gap: 20px; pointer-events: none; }
.menu-top { text-align: center; pointer-events: none; width: min(420px, 100%); }
.menu-title { font-weight: 600; font-size: clamp(26px, 7.4vw, 42px); line-height: 1.08; letter-spacing: .08em; color: #EEF0F4; text-shadow: 0 2px 18px rgba(0,0,0,.6); }
.menu-title b { color: var(--amber); font-weight: 600; }
.menu-sub { margin-top: 10px; color: #C4CAD5; font-size: clamp(14px, 1.8vw, 17px); line-height: 1.35; }
.menu-box { position: relative; width: min(420px, 100%); padding: 18px; display: flex; flex-direction: column; gap: 10px; pointer-events: auto; }
.mbtn { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 16px; border-radius: 6px; border: 1px solid var(--line2); background: var(--panel2); color: #E3E6EC; font-size: 17px; cursor: pointer; text-align: left; transition: border-color .15s, background .15s; }
.mbtn img { width: 30px; height: 30px; }
.mbtn span { flex: 1; }
.mbtn em { font-style: normal; font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--head); }
.mbtn:hover:not(:disabled) { border-color: #4a5266; }
.mbtn.primary { border-color: var(--amber); background: #221c13; color: #F4D9B0; box-shadow: 0 0 14px rgba(232,160,74,.18); }
.mbtn:disabled { opacity: .45; cursor: default; }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.lang { display: flex; align-items: center; gap: 8px; color: #C4CAD5; font-size: 15px; }
.langsel { height: 32px; border-radius: 6px; border: 1px solid var(--line2); background: #10131a; color: var(--num); font: inherit; font-size: 15px; padding: 0 8px; }
.menu-dust { display: flex; align-items: center; gap: 6px; color: #E9D2FF; }
.menu-dust img { width: 22px; height: 22px; }
.menu-dust .num { color: #E9D2FF; font-size: 15px; }
@media (min-width: 640px) and (min-aspect-ratio: 1/1) {
  .menu-col { right: auto; width: min(440px, 46vw); left: max(20px, 5vw); padding: 24px 0; align-items: stretch; justify-content: center; gap: 28px; }
  .menu-top, .menu-box { width: 100%; text-align: left; }
  .menu-title { font-size: clamp(28px, min(3.6vw, 7vh), 46px); }
}
@media (min-width: 640px) and (min-aspect-ratio: 1/1) and (max-height: 600px) {
  .menu-col { padding: 12px 0; gap: 14px; }
}
#scrim { position: fixed; inset: 0; background: rgba(5,8,14,.55); z-index: 19; }
.modal.wide { width: min(760px, calc(100% - 24px)); }
.mhead { display: flex; justify-content: space-between; align-items: flex-start; }
.note { color: #AEB6C6 !important; font-size: 12.5px !important; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--head); font-size: 13px; margin: 6px 0 4px; }
.field input { height: 40px; border-radius: 6px; border: 1px solid var(--line2); background: #10131a; color: var(--num); font: inherit; font-size: 15px; padding: 0 12px; }
.plist { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 14px; max-height: 55vh; overflow: auto; }
.prow { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; }
.pinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pinfo b { color: #EEF0F4; font-size: 15px; }
.pinfo span { color: var(--text); font-size: 12.5px; }
.pinfo em { font-style: normal; color: var(--head); font-size: 11.5px; }
.stabs, .rtabs { display: flex; gap: 6px; margin: 6px 0 10px; }
.stabs button, .rtabs button { flex: 1; height: 32px; border-radius: 6px; border: 1px solid var(--line2); background: var(--panel2); color: #D5DAE3; cursor: pointer; font: inherit; font-size: 13px; position: relative; }
.stabs button.on, .rtabs button.on { border-color: var(--amber); color: var(--amber); background: #1c1a16; }
.rtabs button.alert::after { content: ''; position: absolute; top: 5px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.rtabs { margin-top: 0; }
.sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; max-height: 50vh; overflow: auto; margin-bottom: 12px; }
.sitem { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; gap: 4px 10px; padding: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; align-items: center; }
.sitem img { width: 40px; height: 40px; grid-row: 1 / 3; }
.sitem.focus { border-color: var(--amber); }
.sitem.has { opacity: .7; }
.sinfo { display: flex; flex-direction: column; gap: 2px; }
.sinfo b { color: #EEF0F4; font-size: 14px; } .sinfo span { color: #AEB6C6; font-size: 12px; line-height: 1.3; }
.sitem .btn { grid-column: 2; justify-self: start; display: flex; align-items: center; gap: 5px; height: 30px; }
.sitem .btn img, .tool .tc img, .pp-acts .btn img + img, .pp-req .btn img { width: 14px; height: 14px; grid-row: auto; vertical-align: -2px; }
.sitem em { grid-column: 2; font-style: normal; font-size: 11px; color: var(--head); }
.setrows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: #E3E6EC; }
.sctl { display: flex; gap: 6px; }
.sw { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px 0 4px; border-radius: 15px; border: 1px solid var(--line2); background: #10131a; color: #AEB6C6; cursor: pointer; font: inherit; font-size: 13px; }
.sw i { width: 22px; height: 22px; border-radius: 50%; background: #3a4152; transition: background .15s; }
.sw.on { border-color: var(--amber); color: var(--amber); } .sw.on i { background: var(--amber); }
.seg1 { height: 30px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--line2); background: var(--panel2); color: #D5DAE3; cursor: pointer; font: inherit; font-size: 13px; }
.seg1.on { border-color: var(--amber); color: var(--amber); }
.gm { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
#flashfx { position: fixed; inset: 0; pointer-events: none; z-index: 2; }

/* top bar buttons with icons */
.acts .btn { display: flex; align-items: center; gap: 6px; }
.acts .btn img { width: 18px; height: 18px; }
@media (max-width: 1499px) { .rl { display: none; } }
@media (max-width: 1279px) { .acts .bt { display: none; } }
#date-lab.saved { color: var(--life); } #date-lab.bad { color: var(--warn); }
.r.dust .num { color: #E9D2FF; }

/* tool tabs */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 10px; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel2); color: #AEB6C6; cursor: pointer; font: inherit; font-size: 10.5px; line-height: 1.1; }
.tab img { width: 22px; height: 22px; }
.tab.on { border-color: var(--amber); color: var(--amber); background: #1c1a16; }
.brush.hide { display: none !important; }
.tool.locked img:first-child { filter: grayscale(.85) brightness(.75); }
.tool.locked .tl { color: #9AA2B1; }
.tool .tc { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }

/* hint fades out of the way, the tool name stays on its button */
#hint { transition: opacity .6s; }
#hint.dim { opacity: .35; }
#hint.off { display: none !important; }
.toast.warn { border-left-color: var(--warn); }

/* people pane */
.pp-note { font-size: 12.5px; color: #C9CFDA; line-height: 1.45; margin-bottom: 10px; }
.chk { display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; align-items: center; font-size: 12.5px; height: 26px; color: #C9CFDA; }
.chk b { color: var(--warn); } .chk.ok b { color: var(--life); }
.chk .num { font-size: 12px; }
.pp-stage { font-size: 16px; font-weight: 600; color: #EEF0F4; margin-bottom: 6px; }
.pp-prog, .pp-faith { margin: 4px 0 10px; }
.pp-req { display: grid; grid-template-columns: 30px 1fr; gap: 6px 8px; padding: 10px; margin: 10px 0; border: 1px solid var(--amber); border-radius: 6px; background: #1c1a16; }
.pp-req > img { width: 30px; height: 30px; }
.pp-req div { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: #E3E6EC; }
.pp-req b { color: var(--amber); } .pp-req em { font-style: normal; color: var(--head); font-size: 11.5px; }
.pp-req .btn { grid-column: 1 / 3; display: flex; align-items: center; justify-content: center; gap: 5px; }
.pp-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.pp-acts .btn { display: flex; align-items: center; gap: 5px; height: 36px; font-size: 12px; padding: 0 8px; }
.pp-acts .btn img:first-child { width: 20px; height: 20px; }
.towns { display: flex; flex-direction: column; gap: 3px; }
.town { display: flex; justify-content: space-between; font-size: 12.5px; color: #C9CFDA; }
.town span:first-child { display: flex; align-items: center; gap: 6px; } .town img { width: 16px; height: 16px; }

/* rails: narrow desktop and phones held sideways */
@media (max-width: 1099px), (max-height: 600px) {
  .tabs { grid-template-columns: 1fr 1fr; }
  .tab span { display: none; }
  .tool .tl { display: block; font-size: 10px; line-height: 1.15; color: #D5DAE3; }
  .tool .tc { display: none; }
  .tool.global .tc { display: flex; justify-content: center; }
  .tool.global .tv { font-size: 9.5px; }
  #hint { top: auto; bottom: 64px; max-width: min(420px, calc(100% - 300px)); font-size: 11.5px; padding: 4px 10px; }
  #toasts { bottom: auto; top: 62px; }
  .toast { font-size: 12px; padding: 6px 12px; min-width: 0; max-width: min(420px, calc(100vw - 300px)); }
  .rtabs button { font-size: 11px; height: 28px; }
  .pp-acts { grid-template-columns: 1fr; }
}
@media (max-height: 600px) and (min-width: 700px) {
  #hint { bottom: 54px; }
  .menu-title { font-size: 28px; }
  .menu-sub { margin-top: 4px; font-size: 14px; }
  .menu-box { padding: 12px; gap: 7px; }
  .mbtn { height: 42px; font-size: 15.5px; }
}

/* phone held upright */
@media (max-width: 699px) {
  #b-gmenu { flex: none; }
  .r.dust { display: none; }
  .tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 6px; scrollbar-width: none; }
  .tab { flex: 1 0 auto; flex-direction: row; gap: 4px; padding: 4px 8px; font-size: 11px; }
  .tab img { width: 18px; height: 18px; }
  .tab span { display: inline; }
  .tool .tl { display: block; font-size: 11px; line-height: 1.1; color: #E3E6EC; }
  .tool .tc { display: flex; justify-content: center; font-size: 10px; }
  .tool .tc img { width: 12px; height: 12px; }
  .tool.global .step { margin-top: 2px; }
  #hint { top: 104px; bottom: auto; width: calc(100% - 12px); max-width: none; }
  #toasts { top: 150px; }
  .toast { max-width: calc(100vw - 24px); }
  #right { max-height: 70%; overflow-y: auto; }
  .seg .bt { display: none; }
  .menu-box .mbtn { height: 46px; }
}

body.in-menu #chips, body.in-menu #hint { display: none !important; }

/* drags anywhere off the buttons reach the planet, also over the menu panel */
.menu-box { pointer-events: none !important; }
.menu-box button, .menu-box select, .menu-box label { pointer-events: auto; }

/* dialogs never hide the world: lighter backdrop, and on phones a bottom sheet under a visible planet */
#scrim { background: rgba(5,8,14,.28); }
@media (max-width: 699px) {
  .modal, .modal.wide { top: auto; bottom: 8px; left: 50%; transform: translateX(-50%); width: calc(100% - 12px); max-height: 60vh; padding: 12px 14px; border-radius: 12px 12px 8px 8px; }
  .modal .ph { margin-bottom: 8px; }
  .sgrid { grid-template-columns: 1fr 1fr; max-height: 30vh; gap: 6px; }
  .sitem { grid-template-columns: 30px 1fr; padding: 8px; gap: 3px 8px; }
  .sitem img { width: 30px; height: 30px; }
  .sinfo span { display: none; }
  .sinfo b { font-size: 12.5px; }
  .sitem .btn { height: 26px; font-size: 12px; padding: 0 8px; }
  .modal .note { font-size: 11.5px !important; margin: 4px 0; }
  .plist { max-height: 32vh; }
  .setrows .srow { min-height: 34px; font-size: 13px; }
}
@media (max-height: 600px) and (min-width: 700px) {
  .modal, .modal.wide { top: 8px; bottom: 8px; left: auto; right: 8px; transform: none; width: min(460px, 56vw); max-height: none; }
  .sgrid { max-height: calc(100vh - 190px); grid-template-columns: 1fr 1fr; }
}
@media (max-height: 600px) and (min-width: 700px) {
  body.in-menu .modal, body.in-menu .modal.wide { left: 8px; right: auto; }
}
@media (min-width: 640px) and (min-aspect-ratio: 1/1) and (min-height: 601px) {
  body.in-menu .modal, body.in-menu .modal.wide { left: max(20px, 5vw); transform: translateY(-50%); width: min(560px, 46vw); }
}

.menu-go { text-align: center; color: var(--amber); font-size: 15px; padding: 0 0 4px; letter-spacing: .02em; animation: pmpulse 2.2s ease-in-out infinite; }
@keyframes pmpulse { 50% { opacity: .55; } }
.mbtn.big { height: 62px; font-size: 21px; font-weight: 600; }
.mbtn.big img { width: 36px; height: 36px; }
.menu-sec { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mbtn.small { height: 46px; font-size: 16px; gap: 10px; padding: 0 12px; }
.mbtn.small img { width: 26px; height: 26px; }
@media (max-height: 600px) and (min-width: 700px) { .mbtn.big { height: 48px; font-size: 18px; } .mbtn.small { height: 40px; font-size: 15px; } .menu-go { font-size: 14px; } }

#pname { cursor: pointer; }
/* in the game, dialogs dock over the right panel and leave the planet in view */
@media (min-width: 700px) {
  body:not(.in-menu) .modal, body:not(.in-menu) .modal.wide { left: auto; right: var(--gap); top: 72px; bottom: auto; transform: none; width: min(420px, 36vw); max-height: calc(100% - 150px); }
  body:not(.in-menu) .sgrid { grid-template-columns: 1fr; }
}
@media (min-width: 700px) and (max-height: 600px) {
  body:not(.in-menu) .modal, body:not(.in-menu) .modal.wide { top: 6px; bottom: 6px; width: min(330px, 38vw); max-height: none; padding: 10px 12px; }
  body:not(.in-menu) .srow { min-height: 32px; font-size: 12.5px; }
  body:not(.in-menu) .sinfo span { display: none; }
  body:not(.in-menu) .modal .ph { margin-bottom: 6px; }
}

/* ================= left panel as on the concept: one labelled heading, a labelled list ================= */
.tabs { display: block !important; margin: 0 0 10px !important; overflow: visible !important; }
.cat { display: flex; width: 100%; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 2px 2px 9px; background: none; border: 0; cursor: pointer; position: relative; text-align: left; }
.cat::after { content: ''; position: absolute; left: 2px; bottom: 0; width: 36px; height: 2px; background: var(--amber); border-radius: 1px; }
.cat .cn { font-size: 12.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: #E3E6EC; line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat .cv { flex: none; font-size: 10.5px; color: var(--head); border: 1px solid var(--line2); border-radius: 5px; padding: 2px 6px; white-space: nowrap; }
.cat .cv i { font-style: normal; color: var(--amber); display: inline-block; transition: transform .15s; }
.cat.open .cv i { transform: rotate(180deg); }
.cat:hover .cv { border-color: var(--amber); color: var(--amber); }
.tool.cat-row .tc { display: none !important; }
.tool .ts { display: none; }
.rhead { margin-bottom: 10px; }

/* rails (narrow desktop, phone held sideways): labelled rows, not an icon grid */
@media (max-width: 1099px) and (min-width: 700px), (max-height: 600px) and (min-width: 700px) {
  #left { width: 184px !important; padding: 10px 8px 8px !important; }
  .cat .cv { font-size: 0; padding: 2px 5px; }
  .cat .cv i { font-size: 11px; }
  .cat .cn { font-size: 11px; }
  .tool { flex-direction: row !important; gap: 8px !important; padding: 4px 6px 4px 9px !important; min-height: 38px !important; text-align: left !important; margin-bottom: 5px; }
  .tool img { width: 26px !important; height: 26px !important; }
  .tool .tn { align-items: flex-start !important; }
  .tool .tl { display: block !important; font-size: 12px !important; line-height: 1.15 !important; color: #E3E6EC !important; }
  .tool .ts { display: none !important; }
  .tool .tc { display: flex !important; justify-content: flex-start !important; font-size: 10px !important; }
  .tool .tc img { width: 11px !important; height: 11px !important; }
  .tool.global { flex-wrap: wrap; }
  .tool.global .step { margin-left: auto; }
  .tool.global .step button { width: 24px; height: 22px; font-size: 13px; }
  .brush .bl span:first-child { display: inline !important; }
  .brush { margin-top: 6px; padding-top: 6px; }
  #hint { max-width: min(420px, calc(100% - 400px)) !important; }
}
@media (max-height: 600px) and (min-width: 700px) {
  .rhead { display: none; }
  .tool { min-height: 34px !important; margin-bottom: 4px; }
  .tool .tc { display: none !important; }
  .tool.global .tc { display: flex !important; }
}

/* phone held upright: the concept's row of big labelled tiles */
@media (max-width: 699px) {
  .rhead { display: none; }
  .cat { padding: 0 2px 7px; margin-bottom: 2px; }
  .cat .cn { font-size: 11.5px; }
  .tool .tl { display: none !important; }
  .tool .ts { display: block !important; font-size: 11.5px; color: #E3E6EC; line-height: 1.1; }
  #left.picking .groups { flex-wrap: wrap; }
  #left.picking .tool { width: calc(33.33% - 4px); min-height: 58px; }
  .tool.cat-row .ts { font-size: 10.5px !important; }
}

/* dialogs never run off a short screen: the buttons stay in reach */
.modal { display: flex; flex-direction: column; }
.modal[hidden] { display: none !important; }
.modal > .row { flex: none; margin-top: auto; padding-top: 8px; }
.modal .setrows, .modal .sgrid, .modal .plist { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
@media (max-height: 600px) {
  .modal, .modal.wide { max-height: calc(100% - 12px) !important; }
  body:not(.in-menu) .modal { overflow: hidden; }
  .modal .setrows { margin-bottom: 4px; gap: 2px; }
  .modal .srow { min-height: 30px !important; padding: 2px 0; }
  .modal .sw { height: 26px; } .modal .sw i { width: 18px; height: 18px; }
  .modal .langsel { height: 28px; }
  .modal .note { margin: 2px 0 !important; }
}
.modal ul, .modal #pane-x { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
@media (max-width: 699px) {
  #left:not(.picking) .groups .tool { flex: 1 1 0; min-width: 62px; width: auto; }
  #left:not(.picking) .groups .tool.global { min-width: 92px; }
}
.modal .setrows { flex: 0 1 auto; }
