:root {
  --bg: #0d1418;
  --panel: #161f26;
  --panel-2: #1e2a33;
  --line: #2b3a45;
  --text: #e8eef2;
  --dim: #8fa3b0;
  --gold: #e8b64c;
  --good: #4cc98a;
  --bad: #e2604f;
  --accent: #3d8bd4;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
}

#topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: linear-gradient(#0d1418ee, #0d141899);
  backdrop-filter: blur(6px);
  z-index: 5;
  font-size: 13px;
}

.res { display: flex; gap: 10px; }
.res span { display: flex; align-items: center; gap: 3px; white-space: nowrap; }
.res b { font-weight: 600; font-variant-numeric: tabular-nums; }
.res i { font-style: normal; opacity: .85; }

.clock { color: var(--dim); font-variant-numeric: tabular-nums; }

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hint {
  position: fixed;
  left: 50%;
  top: 62px;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: #161f26dd;
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--dim);
  z-index: 4;
  transition: opacity .25s;
  pointer-events: none;
  white-space: nowrap;
}
.hint.gone { opacity: 0; }

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  z-index: 6;
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-b);
  transition: transform .22s ease;
  will-change: transform;
}
.sheet.collapsed { transform: translateY(calc(100% - 96px)); }

.grip {
  height: 18px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.grip::before {
  content: "";
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}

#tabs {
  display: flex;
  gap: 4px;
  padding: 0 8px 6px;
  flex: 0 0 auto;
}
#tabs button {
  flex: 1;
  padding: 8px 0;
  font: inherit;
  font-size: 13px;
  color: var(--dim);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 8px;
}
#tabs button.on { color: var(--text); border-bottom-color: var(--accent); background: #ffffff08; }

.body { overflow-y: auto; padding: 4px 12px 16px; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.pane { display: flex; flex-direction: column; gap: 10px; }

h3 { margin: 6px 0 0; font-size: 14px; font-weight: 600; }
h3 small { color: var(--dim); font-weight: 400; font-size: 12px; }
p.empty { color: var(--dim); font-size: 13px; margin: 8px 0; }

.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; background: var(--accent); }

button.btn {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 42px;
  flex: 1;
}
button.btn:active { background: #24323d; }
button.btn[disabled] { opacity: .45; }
button.btn.primary { background: var(--accent); border-color: #56a3e6; }
button.btn.danger { background: #5a2620; border-color: #7a332a; }

.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card .title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card .title b { font-size: 13.5px; }
.card .sub { color: var(--dim); font-size: 12px; }
.card .cost { color: var(--gold); font-size: 12px; }

.log { font-size: 12.5px; color: var(--dim); display: flex; flex-direction: column; gap: 6px; }
.log div { border-left: 2px solid var(--line); padding-left: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28vh + 20px);
  transform: translateX(-50%);
  max-width: 84vw;
  padding: 10px 14px;
  border-radius: 10px;
  background: #24323dfa;
  border: 1px solid var(--line);
  font-size: 13px;
  z-index: 20;
  text-align: center;
}
.toast.bad { border-color: #7a332a; color: #ffb9ae; }

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  color: var(--dim);
  font-size: 14px;
  z-index: 30;
}
.boot.gone { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #ffffff0f;
  font-size: 11.5px;
  color: var(--dim);
}

/* Targeting a march: dim the sheet so the map is tappable. */
body.targeting .sheet { opacity: .55; }
body.targeting #hint { color: var(--text); border-color: var(--accent); }

.row > button.btn { min-width: 0; }
