/* Rockhound: Mother Lode — mining-town builder, portrait-first.
   Full-height layout: money header, canvas map, build bar pinned low. */

:root {
  --paper: #f3ead8;
  --card: #fdf8ee;
  --edge: #d9c9a8;
  --ink: #2a2118;
  --muted: #7d6f5c;
  --accent: #7a5230;
  --gold: #b8862f;
  --green: #3e7a3e;
  --buy: #7a5230;
  --buy-ink: #fff8ec;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #2a1c10;
  color: var(--ink);
  display: flex; flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Money header ────────────────────────────────────────────────── */
.ml-top {
  flex: none; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: calc(.5rem + env(safe-area-inset-top)) .9rem .5rem;
  background: #2a1c10;
  color: #f5ead2;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}
.ml-back {
  color: #cbb58e; text-decoration: none; font-size: 1.4rem; line-height: 1;
  padding: .3rem .5rem; border-radius: 8px;
}
.ml-back:active { background: rgba(255,255,255,.12); }
.ml-money { flex: 1; text-align: center; }
.ml-cash { font-size: 1.45rem; font-weight: 700; letter-spacing: .02em; }
.ml-cash b { font-variant-numeric: tabular-nums; }
.ml-rate { font-size: .78rem; color: #cbb58e; font-variant-numeric: tabular-nums; }
.ml-brand {
  display: flex; align-items: center; gap: .35rem;
  font-size: .66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #cbb58e; text-align: left; line-height: 1.15;
}

/* ── Map stage ───────────────────────────────────────────────────── */
.ml-stage { position: relative; flex: 1; min-height: 0; }
#map { display: block; width: 100%; height: 100%; touch-action: none; }

.ml-hint {
  position: absolute; top: .6rem; left: 50%; transform: translateX(-50%);
  max-width: 92%; text-align: center;
  background: rgba(42,28,16,.85); color: #f5ead2;
  font-size: .8rem; padding: .45rem .8rem; border-radius: 999px;
  pointer-events: none; z-index: 5;
}

/* ── Bottom sheet (selected tile) ────────────────────────────────── */
.ml-sheet {
  position: absolute; left: .6rem; right: .6rem; bottom: 5.6rem; z-index: 10;
  background: var(--card); border: 1px solid var(--edge); border-radius: 14px;
  padding: .7rem .8rem; box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.ml-sheet-head { display: flex; align-items: flex-start; gap: .6rem; }
.ml-sheet-icon { font-size: 1.7rem; line-height: 1; }
.ml-sheet-title { flex: 1; min-width: 0; }
.ml-sheet-title h3 { font-size: .98rem; color: var(--accent); }
.ml-sheet-title p { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.ml-x {
  background: none; border: none; color: var(--muted); font-size: 1rem;
  padding: .2rem .4rem; cursor: pointer;
}
.ml-sheet-actions { margin-top: .55rem; display: flex; gap: .6rem; }
.ml-maxed { font-size: .82rem; color: var(--gold); font-weight: 700; align-self: center; }

/* ── Build bar ───────────────────────────────────────────────────── */
.ml-buildbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
  background: linear-gradient(rgba(42,28,16,0), rgba(42,28,16,.92) 30%);
  padding: .9rem .5rem calc(.55rem + env(safe-area-inset-bottom));
}
.ml-chips {
  display: flex; gap: .45rem; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; padding: 0 .2rem;
}
.ml-chips::-webkit-scrollbar { display: none; }
.ml-chip {
  flex: none; display: flex; flex-direction: column; align-items: center;
  gap: .05rem; min-width: 4.6rem; min-height: 58px;
  background: var(--card); border: 2px solid var(--edge); border-radius: 12px;
  padding: .35rem .5rem; cursor: pointer;
  font-family: inherit; color: var(--ink);
}
.ml-chip.sel { border-color: var(--gold); background: #fbf0d2; box-shadow: 0 0 0 2px rgba(232,199,106,.5); }
.ml-chip:disabled { opacity: .55; }
.ml-chip.hire { border-color: #c94f2e; background: #fdeee6; }
.ml-chip-icon { font-size: 1.25rem; line-height: 1.1; height: 30px; display: flex; align-items: center; }
.ml-chip-icon canvas, .ml-chip-icon svg { display: block; }
.ml-chip-name { font-size: .62rem; font-weight: 700; white-space: nowrap; }
.ml-chip small { font-size: .66rem; color: var(--green); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Buy buttons (sheet) ─────────────────────────────────────────── */
.ml-buy {
  flex: 1; min-height: 48px;
  border: none; border-radius: 12px; cursor: pointer;
  background: var(--buy); color: var(--buy-ink);
  font-weight: 700; font-size: .9rem; line-height: 1.2;
  padding: .45rem .7rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 2px 0 #4e3218, 0 3px 8px rgba(0,0,0,.18);
}
.ml-buy small { font-weight: 600; font-size: .74rem; opacity: .85; font-variant-numeric: tabular-nums; }
.ml-buy:active:not(:disabled) { transform: translateY(1px); }
.ml-buy:disabled { background: #b7a688; box-shadow: none; cursor: default; }

/* Floating +$ numbers */
.ml-float {
  position: fixed; z-index: 50; pointer-events: none;
  font-weight: 800; font-size: 1.05rem; color: #8ee08e;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
  animation: floatUp .85s ease-out forwards;
}
@keyframes floatUp {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-58px); }
}

/* ── Footer ──────────────────────────────────────────────────────── */
.ml-foot {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  font-size: .72rem; color: #cbb58e; background: #2a1c10;
  padding: .35rem .9rem calc(.35rem + env(safe-area-inset-bottom));
}
.ml-reset {
  background: none; border: 1px solid rgba(255,255,255,.35); color: #cbb58e;
  border-radius: 8px; padding: .3rem .55rem; font-size: .7rem; cursor: pointer;
}

/* ── Away modal ──────────────────────────────────────────────────── */
.ml-modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(30,20,10,.55);
  display: flex; align-items: center; justify-content: center; padding: 1.2rem;
}
.ml-modal[hidden] { display: none; }
.ml-modal-card {
  background: var(--card); border-radius: 16px; padding: 1.4rem 1.2rem;
  max-width: 340px; width: 100%; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.ml-modal-card h3 { color: var(--accent); margin-bottom: .5rem; }
.ml-modal-card p { font-size: .9rem; color: var(--muted); }
.ml-away-cash {
  font-size: 1.9rem; font-weight: 800; color: var(--green);
  margin: .6rem 0 .9rem; font-variant-numeric: tabular-nums;
}
.btn {
  background: var(--buy); color: var(--buy-ink); border: none; cursor: pointer;
  font-weight: 700; font-size: 1rem; border-radius: 12px;
  padding: .7rem 1.4rem; min-height: 48px;
  box-shadow: 0 2px 0 #4e3218;
}
.btn:active { transform: translateY(1px); }
