* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b2026; color: #eef2f5; font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
/* no text selection / magnifier on long-press or double-tap (web-portal mobile requirement); the seed field stays editable */
body { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
input { -webkit-user-select: text; user-select: text; }
#view { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; outline: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }
.ico { display: inline-block; width: 28px; height: 28px; background-size: contain; background-repeat: no-repeat; background-position: center; flex: none; }
.grow { flex: 1; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#top { position: absolute; left: 0; right: 0; top: 0; display: flex; gap: 6px; padding: calc(env(safe-area-inset-top) + 6px) 8px 0; align-items: flex-start; pointer-events: none; }
#top > * { pointer-events: auto; }
#top .grow { pointer-events: none; }
.pill { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 10px; border-radius: 12px; background: rgba(20, 24, 30, .82); border: 1px solid rgba(255, 255, 255, .12); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.pill.sq { min-width: 44px; justify-content: center; padding: 4px 8px; position: relative; }
.pill .lbl { font-size: 12px; font-weight: 600; }
#btnResearch { max-width: 46vw; text-align: left; }
#btnResearch .txt { display: flex; flex-direction: column; min-width: 0; }
#btnResearch b { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#resBar { display: block; height: 5px; width: 100px; max-width: 100%; border-radius: 3px; background: #39414b; margin-top: 3px; overflow: hidden; }
#resBar u { display: block; height: 100%; width: 0; background: #e0453a; }
#btnResearch.pick { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px #ffd23a; } }
#qBadge { position: absolute; top: -4px; right: -4px; background: #ffd23a; color: #222; font-style: normal; font-size: 11px; font-weight: 700; border-radius: 9px; padding: 0 5px; min-width: 18px; text-align: center; }
#threat { font-size: 12px; font-weight: 600; }
#threat .dot { width: 10px; height: 10px; border-radius: 50%; background: #5ad65a; flex: none; }
#threat.warn .dot { background: #e8c23a; }
#threat.alert { background: rgba(120, 20, 20, .9); }
#threat.alert .dot { background: #ff4a3a; animation: pulse 0.8s infinite; }

#invStrip { position: absolute; left: 8px; top: calc(env(safe-area-inset-top) + 56px); display: flex; flex-wrap: wrap; gap: 4px; max-width: calc(100vw - 16px); pointer-events: none; }
#invStrip > span { display: flex; align-items: center; gap: 2px; padding: 1px 6px 1px 2px; border-radius: 8px; background: rgba(20, 24, 30, .7); font-size: 12px; font-weight: 600; }
#invStrip .ico { width: 20px; height: 20px; }

#tut { position: absolute; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 84px); width: min(440px, calc(100vw - 16px)); background: rgba(24, 30, 38, .95); border: 2px solid #ffd23a; border-radius: 14px; padding: 10px 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .45); }
#tutStep { font-size: 11px; font-weight: 700; color: #ffd23a; letter-spacing: .05em; text-transform: uppercase; }
#tutText { margin: 4px 0 8px; font-size: 14px; }
#tut .row { display: flex; gap: 8px; align-items: center; }
#tut button { min-height: 38px; padding: 6px 12px; border-radius: 10px; background: #ffd23a; color: #222; font-weight: 700; }
#tut button.ghost { background: transparent; color: #c9d1d9; text-decoration: underline; font-weight: 500; padding: 6px 4px; }

#toasts { z-index: 6; position: absolute; right: 8px; top: calc(env(safe-area-inset-top) + 84px); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; max-width: min(320px, 70vw); pointer-events: none; }
#toasts div { pointer-events: auto; background: rgba(20, 24, 30, .92); border-left: 4px solid #6bc6e8; border-radius: 8px; padding: 7px 10px; font-size: 13px; box-shadow: 0 2px 8px rgba(0, 0, 0, .4); animation: tin .2s ease-out; }
#toasts div.bad { border-left-color: #ff4a3a; }
#toasts div.good { border-left-color: #5ad65a; }
#toasts div.go { cursor: pointer; text-decoration: underline dotted; }
#toasts div:not(.go) { pointer-events: none; } /* plain messages never swallow a tap on the world under them */
@keyframes tin { from { transform: translateX(30px); opacity: 0; } }
#tut:not([hidden]) ~ #toasts { top: calc(env(safe-area-inset-top) + 210px); }
/* v1.11 job tracker (top left; game.js layoutTrack() sets its top under the item strip / tutorial and hides rows that would reach the joystick) */
#track { position: absolute; left: 8px; top: calc(env(safe-area-inset-top) + 84px); display: flex; flex-direction: column; gap: 4px; width: min(250px, calc(100vw - 16px)); pointer-events: none; z-index: 3; }
#track .trow { pointer-events: auto; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; align-items: center; column-gap: 6px; min-height: 36px; padding: 3px 8px 4px 4px; border-radius: 10px; background: rgba(20, 24, 30, .84); border: 1px solid rgba(255, 255, 255, .12); text-align: left; font-size: 12px; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
#track .trow .tf { width: 26px; height: 26px; grid-row: 1 / 3; border-radius: 50%; background-color: #2c343f; }
#track .trow .tg { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#track .trow b { font-size: 12px; color: #ffd23a; }
#track .trow i { grid-column: 2 / 4; display: block; height: 3px; border-radius: 2px; background: #39414b; overflow: hidden; margin-top: 2px; }
#track .trow i u { display: block; height: 100%; background: #5ad65a; }
#track .trow.done { border-color: #5ad65a; } #track .trow.done b { color: #5ad65a; }
#track .trow.offer { border: 2px solid #ffd23a; animation: pulse 1.4s infinite; } #track .trow.offer .tg { white-space: normal; }
#track.compact { width: auto; align-items: flex-start; } /* v1.11: narrow screens where the rows would cover the middle: portrait + progress only */
#track.compact .trow { grid-template-columns: auto auto; padding-right: 8px; }
#track.compact .trow .tg { display: none; }
#track.compact .trow i { grid-column: 2 / 3; }
#track[data-more]:not([data-more=""])::after { content: attr(data-more); align-self: flex-start; font-size: 11px; color: #c9d1d9; background: rgba(20, 24, 30, .7); border-radius: 6px; padding: 0 6px; }
/* v1.11 talk card (in the panel) */
.npc { display: flex; gap: 10px; align-items: flex-start; margin: 2px 0 6px; }
.npc .face { width: 56px; height: 56px; border-radius: 50%; background-color: #2c343f; border: 2px solid rgba(255, 255, 255, .15); }
.npc .who b { font-size: 16px; } .npc .who small { color: #9aa7b4; margin-left: 4px; }
.npc .say { margin: 4px 0 0; font-size: 14px; color: #e8eef3; font-style: italic; }
.job { background: #232a33; border-radius: 10px; padding: 4px 10px 10px; } .job.done { outline: 2px solid #5ad65a; }
.ings.rew > span { padding: 2px 6px 2px 2px; font-size: 12px; } .ings.rew .perk { background: #3a3320; color: #ffd27a; padding: 3px 8px; }

#hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 86px); background: rgba(20, 24, 30, .86); border-radius: 10px; padding: 6px 12px; font-size: 13px; white-space: nowrap; max-width: calc(100vw - 16px); overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

/* terraform: raise / lower / flatten, above the build hint */
#terra { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 122px); display: flex; gap: 6px; }
#terra button { min-height: 44px; min-width: 78px; padding: 6px 10px; border-radius: 12px; background: rgba(28, 33, 40, .92); border: 2px solid rgba(255, 255, 255, .12); color: #e8eef3; font-weight: 700; font-size: 14px; }
#terra button.on { border-color: #ffd23a; background: rgba(70, 60, 20, .95); }
#bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); background: linear-gradient(transparent, rgba(10, 12, 16, .55)); }
#tools { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
#tools::-webkit-scrollbar { display: none; }
#fixed { display: flex; gap: 6px; flex: none; }
.tool { position: relative; flex: none; width: 60px; height: 66px; border-radius: 12px; background: rgba(28, 33, 40, .92); border: 2px solid rgba(255, 255, 255, .1); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px; }
.tool .ico { width: 34px; height: 34px; }
.tool .lbl { font-size: 10px; font-weight: 600; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tool .n { position: absolute; top: 2px; right: 4px; font-size: 11px; font-weight: 700; color: #ffd23a; text-shadow: 0 1px 2px #000; }
.tool.zero { opacity: .45; }
.tool.on { border-color: #ffd23a; background: rgba(70, 60, 20, .95); }
.tool.pulse { animation: pulse 1s infinite; }
#btnRemove.on { border-color: #ff6a5a; background: rgba(90, 25, 20, .95); }

#panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 72vh; display: flex; flex-direction: column; background: rgba(22, 27, 34, .97); border-top: 2px solid rgba(255, 255, 255, .14); border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, .5); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
#panel .head { display: flex; align-items: center; padding: 10px 12px 6px; font-weight: 700; font-size: 16px; gap: 8px; }
#panel .head span { flex: 1; }
#panel .x { width: 44px; height: 40px; border-radius: 10px; background: #2c343f; font-size: 24px; line-height: 1; }
#pBody { overflow-y: auto; padding: 0 12px 14px; -webkit-overflow-scrolling: touch; }
@media (min-width: 900px) and (pointer: fine) {
  #panel { left: auto; right: 10px; bottom: 90px; top: 64px; width: 400px; max-height: none; border-radius: 16px; border: 2px solid rgba(255, 255, 255, .14); }
}
.sect { margin: 10px 0 4px; font-size: 11px; font-weight: 700; color: #9aa7b4; letter-spacing: .06em; text-transform: uppercase; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.card2 { background: #232a33; border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.card2 .t { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; }
.card2 .t small { margin-left: auto; color: #9aa7b4; font-weight: 500; }
.ings { display: flex; flex-wrap: wrap; gap: 3px; font-size: 11px; }
.ings > span { display: inline-flex; align-items: center; gap: 1px; background: #2e3742; border-radius: 6px; padding: 0 4px 0 1px; }
.ings > span.miss { background: #5a2626; }
.ings .ico { width: 18px; height: 18px; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.btns button, button.act { min-height: 40px; padding: 6px 12px; border-radius: 10px; background: #34404d; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.btns button .ico { width: 22px; height: 22px; }
.btns button.pri, button.act.pri { background: #d9a92e; color: #1d1d1d; }
.btns button.bad { background: #6a2c2c; }
button:disabled { opacity: .4; cursor: default; }
.kv { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid #2a323c; }
.kv .ico { width: 24px; height: 24px; }
.kv b { margin-left: auto; }
.prog { height: 7px; border-radius: 4px; background: #39414b; overflow: hidden; margin: 6px 0; }
.prog u { display: block; height: 100%; width: 0; background: #5ad65a; }
.tech { background: #232a33; border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; }
.tech.done { opacity: .55; }
.tech.cur { outline: 2px solid #ffd23a; }
.tech .t { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.tech .t small { margin-left: auto; font-weight: 500; color: #9aa7b4; }
.tech p { margin: 3px 0; font-size: 12px; color: #c4ccd4; }
.muted { color: #9aa7b4; font-size: 12px; }
.inv { display: flex; flex-wrap: wrap; gap: 4px; }
.inv > span { display: inline-flex; align-items: center; gap: 2px; background: #2a323c; border-radius: 8px; padding: 2px 8px 2px 2px; font-size: 12px; font-weight: 600; }
.inv .ico { width: 22px; height: 22px; }
.recipes { display: flex; flex-wrap: wrap; gap: 4px; }
.recipes button { width: 52px; height: 52px; border-radius: 10px; background: #2c343f; border: 2px solid transparent; display: flex; align-items: center; justify-content: center; }
.recipes button.on { border-color: #ffd23a; }
.recipes button .ico { width: 34px; height: 34px; }
.seg { display: inline-flex; border-radius: 10px; overflow: hidden; }
.seg button { min-height: 40px; padding: 6px 14px; background: #2c343f; font-weight: 600; }
.seg button.on { background: #d9a92e; color: #1d1d1d; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 30%, rgba(40, 60, 80, .75), rgba(10, 12, 16, .92)); padding: 16px; z-index: 20; }
.screen .card { width: min(420px, 100%); text-align: center; background: rgba(20, 24, 30, .85); border: 1px solid rgba(255, 255, 255, .12); border-radius: 18px; padding: 22px 20px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); max-height: 100%; overflow-y: auto; }
.screen h1 { margin: 4px 0 2px; font-size: 44px; line-height: .95; letter-spacing: .02em; font-weight: 900; color: #ffd23a; text-shadow: 0 3px 0 #7a4a10; }
.screen h1 span { display: block; font-size: 18px; color: #e8eef3; letter-spacing: .5em; text-shadow: none; margin: 4px 0; }
.screen h1.won { color: #9fe3ff; text-shadow: 0 3px 0 #1f5a7a; }
.tag { margin: 6px 0 16px; color: #c9d1d9; }
.big { display: block; width: 100%; min-height: 50px; margin: 8px 0; border-radius: 12px; background: #d9a92e; color: #1d1d1d; font-size: 18px; font-weight: 800; }
.big.alt { background: #34404d; color: #eef2f5; }
.opts { margin: 6px 0; text-align: left; font-size: 14px; }
.opts summary { list-style: none; cursor: pointer; text-align: center; color: #9aa7b4; font-size: 13px; padding: 8px; border-radius: 8px; }
.opts summary::-webkit-details-marker { display: none; }
.opts summary::after { content: ' \25BE'; }
.opts[open] summary::after { content: ' \25B4'; }
.opts summary:hover { color: #eef2f5; }
.opts label { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.opts input[type=text], .opts input:not([type]) { flex: 1; min-height: 38px; border-radius: 8px; border: 1px solid #3a4450; background: #12161b; color: #eef2f5; padding: 4px 10px; font: inherit; }
.opts input[type=checkbox] { width: 22px; height: 22px; }
.small { font-size: 12px; color: #9aa7b4; margin: 8px 0 0; }
.credit { color: #c9b98a; }
.tip { display: inline-block; margin-top: 10px; color: #ffd27a; font-size: 14px; }
#winStats { text-align: left; margin: 14px 0; }
#winStats .kv { font-size: 14px; }
/* offline catch-up: the Welcome back card (same card as the title and win screens) */
.screen h1.back { font-size: 40px; color: #b6f08a; text-shadow: 0 3px 0 #2f6a1f; }
#back .tag { margin: 8px 0 10px; }
#backBar { display: block; height: 8px; border-radius: 4px; background: #39414b; margin: 12px 0; overflow: hidden; }
#backBar[hidden] { display: none; }
#backBar u { display: block; height: 100%; width: 0; background: #5ad65a; }
#backStats { text-align: left; margin: 8px 0 10px; }
#backStats .kv { font-size: 14px; }
/* Phones up to 440 px wide: the top bar overflowed and pushed Menu off-screen (4 px at 390, 65 px at 320). */
@media (max-width: 440px) { #top { gap: 3px; padding-left: 6px; padding-right: 6px; } #btnResearch { max-width: 34vw; } #btnCraft .lbl, #threatTxt { display: none; } #threat { min-width: 44px; justify-content: center; } }
/* The late game shows 15 tools + Rotate + Pick up. They fit without sideways scrolling, so a mouse reaches every tool, from 800 px
   wide up (CG portal iframes 821x462 / 907x510 / 1077x606 / 1080x607, 800x450): 60 px buttons need 1132 px, 54 px need 1000,
   49 px need 900, 44 px need 789. Label widths: "Assembler" is 47.2 px at 10 px, 42.5 px at 9 px, 38.9 px at 9 px with -.4 px spacing. */
@media (max-width: 1140px) { #tools, #fixed { gap: 4px; } .tool { width: 54px; padding: 2px 0; } }
@media (max-width: 1000px) { #tools, #fixed { gap: 3px; } .tool { width: 49px; } .tool .lbl { font-size: 9px; } }
@media (max-width: 900px) { #bar { gap: 3px; padding-left: 4px; padding-right: 4px; } #tools, #fixed { gap: 2px; } .tool { width: 44px; padding: 2px 0; } .tool .lbl { letter-spacing: -.4px; } }
/* v1.5 engineer: joystick (touch only, bottom left, above the toolbar), side buttons (bottom right), health */
#joy { display: none; position: absolute; left: 12px; bottom: calc(env(safe-area-inset-bottom) + 92px); width: 118px; height: 118px; border-radius: 50%; background: rgba(20, 24, 30, .38); border: 2px solid rgba(255, 255, 255, .28); touch-action: none; z-index: 2; }
#joy.on { background: rgba(20, 24, 30, .55); border-color: rgba(255, 210, 58, .7); }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(232, 238, 243, .78); box-shadow: 0 2px 6px rgba(0, 0, 0, .4); pointer-events: none; }
@media (pointer: coarse) { #joy { display: block; } }
#side { position: absolute; right: 8px; bottom: calc(env(safe-area-inset-bottom) + 92px); display: grid; grid-template-columns: repeat(2, auto); gap: 6px; z-index: 2; pointer-events: none; } /* the gaps and the empty cell pass taps through to the world */
#side .tool { width: 52px; height: 52px; pointer-events: auto; }
#side .tool .ico { width: 26px; height: 26px; }
#side .tool { padding: 2px 0; }
#side .tool .lbl { font-size: 10px; } /* ("1st person" / "3rd person" fit the 52 px button at 10 px with no side padding) */
#side .tool .n { font-size: 9px; top: 1px; right: 2px; }
#side .tool.full .n { color: #ff6a5a; }
#side .tool[hidden] { display: none; }
#hp { position: absolute; left: 12px; bottom: calc(env(safe-area-inset-bottom) + 92px); display: flex; flex-direction: column; gap: 2px; padding: 3px 8px; border-radius: 8px; background: rgba(20, 24, 30, .72); font-size: 11px; font-weight: 700; pointer-events: none; }
@media (pointer: coarse) { #hp { bottom: calc(env(safe-area-inset-bottom) + 216px); } }
#hp i { display: block; width: 92px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .15); overflow: hidden; }
#hp u { display: block; height: 100%; background: #5ad65a; }
#hp.low u { background: #ff4a3a; } #hp.low { color: #ffb0a6; }
@media (pointer: coarse) { #hint { bottom: calc(env(safe-area-inset-bottom) + 216px); left: calc(50% + 40px); max-width: calc(100vw - 150px); } #terra { left: 12px; transform: none; bottom: calc(env(safe-area-inset-bottom) + 246px); flex-direction: column; } #terra button { min-width: 74px; } }
.slots { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.slot { position: relative; aspect-ratio: 1; border-radius: 6px; background: #2c343f; border: 1px solid rgba(255, 255, 255, .08); display: flex; align-items: center; justify-content: center; }
.slot.empty { background: #232a33; }
.slot .ico { width: 70%; height: 70%; }
.slot b { position: absolute; right: 2px; bottom: 0; font-size: 10px; text-shadow: 0 1px 2px #000; }
#pBody p.far { background: rgba(255, 74, 58, .14); border-left: 3px solid #ff4a3a; padding: 4px 8px; border-radius: 4px; font-size: 13px; }
.inv.store button { display: flex; align-items: center; gap: 2px; padding: 2px 6px 2px 2px; min-height: 34px; border-radius: 8px; background: #2c343f; font-weight: 600; font-size: 12px; }
/* v1.6 first person: a small centre crosshair (desktop); brighter while the mouse is locked */
#xhair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; pointer-events: none; z-index: 1; opacity: .55; }
#xhair::before, #xhair::after { content: ''; position: absolute; background: #fff; box-shadow: 0 0 2px rgba(0, 0, 0, .9); }
#xhair::before { left: 10px; top: 2px; width: 2px; height: 18px; }
#xhair::after { top: 10px; left: 2px; height: 2px; width: 18px; }
#xhair.lock { opacity: .95; }
#xhair[hidden] { display: none; }
