/* 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; }
