/* Shared mobile-first skeleton. Portrait, one thumb, no zoom, no bounce. */
:root {
  --bg: #12141c; --panel: #1c2030; --panel2: #262b3f; --line: #343a55;
  --text: #eef0f7; --dim: #9299b3; --accent: #ffb84d; --good: #5ad19a; --bad: #ff6b6b; --blue: #6aa8ff;
  --tap: 52px; /* minimum touch target */
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* Game pages: <body class="game">. Fixed to the viewport, nothing scrolls or zooms. */
body.game { position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
body.game #app { position: absolute; inset: 0; display: flex; flex-direction: column;
  max-width: 520px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px calc(env(safe-area-inset-bottom, 0px) + 12px); }
/* areas that should take raw touches (canvases) */
.notouch { touch-action: none; }
/* areas inside a game that may scroll (logs, chats) */
.scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }

/* top bar injected by shared.js */
#topbar { position: fixed; top: env(safe-area-inset-top, 0px); left: 0; right: 0; height: 44px; z-index: 50;
  display: flex; align-items: center; gap: 8px; padding: 0 6px; pointer-events: none; }
#topbar a { pointer-events: auto; width: 44px; height: 44px; display: grid; place-items: center;
  color: var(--dim); text-decoration: none; font-size: 26px; border-radius: 12px; }
#topbar a:active { background: var(--panel2); }
#topbar .title { color: var(--dim); font-weight: 600; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; }

button, .btn { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
  border-radius: 14px; min-height: var(--tap); padding: 10px 16px; font-weight: 600; cursor: pointer; }
button:active { transform: scale(.97); filter: brightness(1.2); }
button:disabled { opacity: .4; }
button.primary { background: var(--accent); color: #221a08; border-color: transparent; }
input[type=text], textarea { font: inherit; font-size: 16px; /* 16px stops iOS zoom-on-focus */
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  min-height: var(--tap); padding: 10px 12px; width: 100%; user-select: text; -webkit-user-select: text; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.dim { color: var(--dim); } .good { color: var(--good); } .bad { color: var(--bad); } .accent { color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; } .grow { flex: 1; min-height: 0; min-width: 0; }
.center { text-align: center; }

/* loading state for slow (Claude) calls: Arcade.loading(true, 'Thinking…') */
#loading { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; background: #0009; }
#loading.on { display: grid; }
#loading div { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 22px;
  display: flex; gap: 12px; align-items: center; font-weight: 600; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 80px); transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 95;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; }

/* keep the layout above the on-screen keyboard (shared.js sets --vvh) */
body.game { bottom: auto; height: var(--vvh, 100%); }
#app { gap: 8px; }
.small { font-size: 13px; }
.pad { padding: 8px 4px; }

/* resources */
.resbar { display: flex; gap: 10px; padding: 10px 12px; flex: none; }
.res { flex: 1; min-width: 0; }
.rv { font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rr { font-size: 11px; white-space: nowrap; display: flex; justify-content: space-between; gap: 4px; }
.rr .up { color: var(--good); } .rr .bad { font-weight: 800; }
.meter { height: 5px; background: #0008; border-radius: 3px; overflow: hidden; margin: 4px 0 3px; }
.meter.none { background: none; }
.meter i { display: block; height: 100%; width: 0; background: var(--blue); border-radius: 3px; transition: width .2s linear; }
.meter.full i { background: var(--bad); }
.meter.big { height: 10px; margin: 10px 0; } .meter.big i { background: var(--accent); }
.status { text-align: center; flex: none; }

/* banners (away / expedition loot) */
.banner { display: flex; gap: 10px; align-items: center; text-align: left; font-weight: 400; font-size: 14px; line-height: 1.5; flex: none; }
.banner.away { background: #22332a; border-color: var(--good); }
.banner.loot { background: #33301f; border-color: var(--accent); }
.banner .x { color: var(--dim); font-size: 16px; padding: 0 4px; }

/* tabs */
.tabrow { flex: none; }
.tabs { display: flex; gap: 6px; }
.tab { position: relative; min-height: 44px; padding: 4px 14px; font-size: 14px; border-radius: 12px; background: none; color: var(--dim); }
.tab.on { background: var(--panel2); color: var(--text); border-color: var(--accent); }
.tab.qty { color: var(--text); background: var(--panel); min-width: 92px; }
.dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }

/* rows */
.list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.item { position: relative; overflow: hidden; display: flex; gap: 10px; align-items: center; text-align: left; padding: 10px 12px; min-height: 68px; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; font-weight: 400; flex: none; }
.item > * { position: relative; }
.item .fill { position: absolute; inset: 0 auto 0 0; width: 0; background: #ffffff0d; transition: width .2s linear; }
.item:not(.cant):not(.locked) { border-color: var(--good); }
.item:not(.cant) .fill { background: #5ad19a1c; }
.item.cant .t, .item.cant .ic { opacity: .6; }
.item.locked { border-style: dashed; opacity: .7; }
.item.tech:not(.cant) { border-color: var(--accent); }
.ic { font-size: 26px; width: 36px; text-align: center; flex: none; }
.count { color: var(--accent); font-weight: 700; margin-left: 2px; }
.plusn { color: var(--good); font-weight: 700; font-size: 13px; }
.tot { color: var(--text); } .mile { white-space: nowrap; }
.cost { text-align: right; font-weight: 700; font-size: 14px; display: flex; flex-direction: column; gap: 1px; white-space: nowrap; color: var(--good); flex: none; }
.cost .short { color: var(--bad); }
.cost .eta { font-weight: 400; font-size: 11px; }
.hdr { text-transform: uppercase; font-size: 12px; letter-spacing: .08em; margin-top: 6px; }
.relics { display: flex; flex-wrap: wrap; gap: 6px; }
.relics span { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; font-size: 13px; }
.reset { background: none; border: none; font-size: 13px; font-weight: 400; min-height: 44px; flex: none; }

/* dig */
.dig { min-height: 76px; font-size: 22px; flex: none; transition: transform .05s; }
.dig:active { transform: scale(.96); }
.float { position: fixed; z-index: 60; pointer-events: none; font-weight: 800; color: var(--accent); font-size: 20px;
  transform: translate(-50%, 0); animation: floatup .7s ease-out forwards; text-shadow: 0 1px 3px #000; }
@keyframes floatup { to { transform: translate(-50%, -70px); opacity: 0; } }

/* 3D planet */
#app { gap: 8px; }
#scene { flex: none; height: min(250px, 30vh); border-radius: 16px; overflow: hidden; position: relative;
  background: radial-gradient(120% 90% at 30% 20%, #232a4a 0%, #0c0e18 60%, #06070c 100%); border: 1px solid var(--line); }
#scene[hidden] { display: none; }
#scene canvas { display: block; width: 100%; height: 100%; }
#ui { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.dig { min-height: 58px; font-size: 19px; }
.chip { position: fixed; z-index: 60; pointer-events: none; width: 12px; height: 12px; border-radius: 3px; background: #d9a070; box-shadow: 0 0 8px #ffb84d; transform: translate(-50%, -50%); }
[data-res] { display: inline-block; }
.tab { padding: 4px 11px; }

/* one scrolling column: the planet scrolls away, the numbers and tabs stick to the top, Dig sticks to the bottom */
#scroller { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
#ui { flex: 1 0 auto; min-height: auto; }
.head { position: sticky; top: 0; z-index: 5; display: flex; flex-direction: column; gap: 8px; background: var(--bg); padding-bottom: 2px; }
.dig { position: sticky; bottom: 0; z-index: 5; margin-top: auto; box-shadow: 0 -10px 0 var(--bg), 0 4px 0 var(--bg); }
.foot { flex: none; display: flex; flex-direction: column; margin: 28px 0 60px; } /* well clear of the Dig button */

/* planet tab */
.tab { padding: 4px 9px; font-size: 13.5px; }
.tab.qty { min-width: 54px; }
.pinfo { flex: none; padding: 10px 12px; }
.stage.done { color: var(--good); padding: 6px 12px; font-weight: 600; flex: none; }
.item.launch { border-color: var(--accent); }
.item.launch .cost { font-size: 22px; }
.world { display: flex; gap: 10px; align-items: center; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; flex: none; }

/* events */
#evpill { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); min-height: 34px; padding: 4px 14px; font-size: 13px; font-weight: 600; white-space: nowrap;
  border-radius: 20px; background: #12141ccc; border-color: var(--accent); color: var(--text); animation: pillpulse 1.6s ease-in-out infinite; }
#evpill[hidden] { display: none; }
@keyframes pillpulse { 50% { box-shadow: 0 0 14px #ffb84d88; } }
.flare { color: #ffd54a; font-weight: 700; }

/* perks and either/or research */
.item.perk { border-color: var(--accent); background: #2a2618; }
.pair { display: flex; flex-direction: column; gap: 8px; padding: 8px; border: 1px dashed var(--accent); border-radius: 16px; flex: none; }
.pair .hdr { margin: 0 4px; }
.world .small { font-weight: 400; }
.banner.busy { background: #332a1f; border-color: var(--accent); }

/* first-minute hint, save nudge, desktop */
.hint { flex: none; text-align: center; padding: 10px 14px; border: 1px dashed var(--accent); border-radius: 14px; color: var(--text); font-size: 15px; }
.nudge { flex: none; display: flex; flex-direction: column; gap: 10px; border-color: var(--accent); }
.nudge button { min-height: 44px; }
@media (hover: hover) { button { cursor: pointer; } #scene canvas { cursor: grab; } .item:not(.cant):not(.locked):hover { filter: brightness(1.12); } }
#scroller { scrollbar-width: none; } #scroller::-webkit-scrollbar { display: none; } /* a desktop scrollbar would cover the right edge of the rows */

/* loading, and the flight between worlds */
.loading { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 40px 0; color: var(--dim); }
#ui.flying { pointer-events: none; opacity: .4; transition: opacity .4s; }
#ui { transition: opacity .4s; }
#caption { position: absolute; left: 0; right: 0; top: 12px; text-align: center; font-weight: 700; letter-spacing: .04em; text-shadow: 0 1px 6px #000; pointer-events: none; }
#caption[hidden] { display: none; }
#scene.flying #evpill { display: none; }

/* crew: who works where */
.empty { color: var(--dim); font-weight: 400; font-size: 13px; }
.warn { color: #ffd54a; }
.item.job { border-color: var(--line) !important; min-height: 72px; }
.step { display: flex; align-items: center; gap: 6px; flex: none; }
.step button { width: 44px; height: 44px; border-radius: 12px; font-size: 22px; font-weight: 700; padding: 0; }
.step button:disabled { opacity: .3; }
.pips { font-size: 11px; letter-spacing: 2px; color: var(--accent); min-width: 46px; text-align: center; }
.pips i { font-style: normal; color: var(--line); }
.hint.goal { width: 100%; background: none; font: inherit; font-size: 15px; min-height: 44px; }
/* "more below" pill: sits just above the Dig button while rows are hidden under it */
#more { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 64px); transform: translateX(-50%); z-index: 6; min-height: 26px; padding: 2px 12px;
  font-size: 12px; font-weight: 600; white-space: nowrap; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--dim); box-shadow: 0 4px 14px #0008; }
#more.ready { color: #0c2218; background: var(--good); border-color: transparent; } /* green, like the rows you can afford; gold is the Dig button's */
#more[hidden] { display: none; }
/* the world is alive: what to do next, on every tab. Blue, so it is neither the gold Dig button nor a green "can afford" */
.launchbar { width: 100%; min-height: 52px; font-size: 16px; font-weight: 500; color: #fff; border: 0; background: linear-gradient(90deg, #3d6fe0, #7a5cf0); animation: launchglow 1.8s ease-in-out infinite; }
@keyframes launchglow { 0%, 100% { box-shadow: 0 0 0 0 #6aa8ff66; } 50% { box-shadow: 0 0 0 6px #6aa8ff00, 0 0 18px #6aa8ff88; } }
@media (prefers-reduced-motion: reduce) { .launchbar { animation: none; } }
/* questions asked in the game's own style, instead of the browser's confirm box */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 24px; background: #06080fcc; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fadein .16s ease-out; }
.modal.out { opacity: 0; transition: opacity .15s; }
.sheet { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; text-align: center; padding: 22px 18px 16px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 20px 60px #000a; animation: popin .2s cubic-bezier(.2, 1.3, .5, 1); }
.sheet .micon { font-size: 44px; line-height: 1; }
.sheet h2 { margin: 2px 0 0; font-size: 21px; }
.sheet p { margin: 0 0 6px; color: var(--dim); font-size: 15px; line-height: 1.45; }
.sheet p b { color: var(--text); }
.sheet .kindtag { display: inline-block; margin-bottom: 8px; padding: 4px 12px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); font-size: 13px; }
.sheet button { width: 100%; min-height: 50px; font-size: 17px; }
.sheet button[data-no] { background: none; border-color: transparent; color: var(--dim); font-weight: 500; min-height: 44px; }
.sheet.go { border-color: #6aa8ff66; }
.sheet.go button[data-yes] { color: #fff; background: linear-gradient(90deg, #3d6fe0, #7a5cf0); }
.sheet.go .micon { animation: hover 1.6s ease-in-out infinite; }
@keyframes fadein { from { opacity: 0; } }
@keyframes popin { from { transform: scale(.9) translateY(12px); opacity: 0; } }
@keyframes hover { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet.go .micon, .modal { animation: none; } }
/* equipment: two compact tiles side by side above the buildings */
.gearrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; flex: none; }
.item.gear { min-height: 0; padding: 8px 10px; align-items: stretch; }
.item.gear .t { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.gear .small { font-size: 12px; line-height: 1.25; }
.item.gear .cost { flex-direction: row; gap: 8px; align-items: baseline; text-align: left; margin-top: 4px; }
.sheet .over { text-transform: uppercase; font-size: 12px; letter-spacing: .1em; color: var(--good); font-weight: 700; margin-bottom: -6px; }
.sheet.new { border-color: #5ad19a66; padding-bottom: 20px; }
.sheet.new button[data-yes] { background: var(--good); color: #0c2218; }
/* nothing is mining yet: the Dig button breathes until the first drill is built */
.dig.attract { animation: digpulse 1.5s ease-in-out infinite; }
@keyframes digpulse { 0%, 100% { transform: scale(.97); filter: brightness(1); } 50% { transform: scale(1); filter: brightness(1.2); } } /* never larger than full size, so it stays on screen */
@media (prefers-reduced-motion: reduce) { .dig.attract { animation: none; } }
.hint.tip { width: 100%; background: none; font: inherit; font-size: 14px; line-height: 1.35; text-align: left; border-style: solid; border-color: var(--line); }
/* colonists beside the resources */
.res.people { flex: 0 0 auto; min-width: 62px; background: none; border: 0; border-radius: 0; padding: 0 0 0 10px; border-left: 1px solid var(--line); min-height: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.res.people .meter i { background: var(--good); transition: none; }
.res.people .meter.packed i { background: var(--accent); }
.resbar.four { gap: 8px; padding: 10px; } .resbar.four .rv { font-size: 16px; }
/* crew: colonists waiting for a job */
.waiting { flex: none; text-align: center; padding: 8px 12px; border-radius: 12px; font-size: 14px; color: var(--dim); border: 1px dashed var(--line); }
.waiting.some { color: var(--text); border: 1px solid var(--accent); background: #ffb84d14; }
.hint.goal.do { border-style: solid; background: #ffb84d14; }
/* kept worlds (keepsake colonies): resuming one */
button.world.resume { width: 100%; text-align: left; font: inherit; color: inherit; min-height: 56px; border-color: var(--good); cursor: pointer; }
button.world.resume .go { color: var(--good); font-weight: 700; font-size: 14px; }
.world.here { border-color: var(--accent); }
.awaybar { width: 100%; min-height: 44px; font-size: 14px; font-weight: 500; color: var(--text); background: #3d6fe033; border: 1px solid #6aa8ff66; }
/* email sign-in */
.sheet input { width: 100%; min-height: 50px; font-size: 17px; text-align: center; border-radius: 12px; }
.sheet .fine { display: inline-block; margin-top: 8px; font-size: 12.5px; line-height: 1.4; }
.foot div.reset { padding: 8px 4px; }
.sheet input { font: inherit; font-size: 17px; color: var(--text); background: var(--panel2); border: 1px solid var(--line); padding: 10px 12px; user-select: text; -webkit-user-select: text; outline: none; }
.sheet input:focus { border-color: var(--accent); }
.sheet p b { overflow-wrap: anywhere; }
/* a tick-box in a card */
.sheet .tick { display: flex; align-items: center; gap: 10px; min-height: 44px; text-align: left; font-size: 14.5px; color: var(--text); cursor: pointer; }
.sheet .tick input { width: 22px; height: 22px; min-height: 0; flex: none; padding: 0; accent-color: var(--accent); }
/* playing inside another app's browser */
.notice { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; font-size: 13px; line-height: 1.35; color: var(--text); background: #ffb84d1f; border: 1px solid var(--accent); }
.notice button { flex: none; min-height: 36px; padding: 6px 12px; font-size: 13px; } .notice button.x { background: none; border: none; color: var(--dim); padding: 6px 8px; }
