/* ---------------------------------------------------------------
   The Hidden Landscape
   Palette:
     --ink       #10131a  page & veil (deep blue-black, "darkroom")
     --ink-2     #181c26  raised surfaces
     --line      #2a3040  hairlines
     --paper     #e9e6dc  primary text (warm off-white)
     --muted     #8a90a0  secondary text
     --gold      #d9a441  surveyor gold — selection, progress, claims
     --gold-dim  #7a5c22  gold at rest
   Type:
     Space Grotesk  display / UI
     IBM Plex Mono  coordinates, counts, deeds
---------------------------------------------------------------- */

:root {
  --ink: #10131a;
  --ink-2: #181c26;
  --line: #2a3040;
  --paper: #e9e6dc;
  --muted: #8a90a0;
  --gold: #d9a441;
  --gold-dim: #7a5c22;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Top bar ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 20px;
  background: linear-gradient(to bottom, rgba(16, 19, 26, 0.96), rgba(16, 19, 26, 0.82));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
  z-index: 30;
}

.brand h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand .sub {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 2px;
}

.progress-wrap {
  flex: 0 1 380px;
  min-width: 160px;
}

.progress-track {
  height: 6px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.5s ease;
}

.progress-label {
  margin-top: 5px;
  font-size: 0.66rem;
  color: var(--muted);
  text-align: right;
}

/* ---------- Stage / canvas ---------- */

.stage {
  position: fixed;
  inset: 64px 0 0 0;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#view.panning { cursor: grabbing; }
#view.selecting { cursor: crosshair; }

/* ---------- Toolbar ---------- */

.toolbar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
}

.tool {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  font: 500 0.78rem "Space Grotesk", sans-serif;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}

.tool:hover { color: var(--paper); background: rgba(255, 255, 255, 0.04); }

.tool.active {
  color: var(--ink);
  background: var(--gold);
}

.tool.icon-only {
  font-size: 1rem;
  padding: 8px 12px;
  line-height: 1;
}

.tool-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}

.tool:focus-visible,
.btn:focus-visible,
input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- Claim panel ---------- */

.claim-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 230px;
  padding: 16px;
  background: var(--ink-2);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
}

.claim-count { font-size: 0.78rem; }

.claim-price {
  font-size: 1.5rem;
  color: var(--gold);
  margin: 4px 0 14px;
}

.claim-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- Cart ---------- */

.gold { color: var(--gold); }

.cart-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
  font-size: 0.6rem;
  font-weight: 700;
  font-family: "IBM Plex Mono", monospace;
}

.cart-drawer {
  position: fixed;
  top: 64px;
  right: 0;
  bottom: 0;
  width: 300px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--ink-2);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 40;
  overflow: hidden;
}

.cart-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cart-drawer-head .card-close { position: static; }

.cart-items {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.cart-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.78rem;
}

.cart-item-remove {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.cart-item-remove:hover { color: var(--paper); }

.cart-drawer-foot {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.order-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.85rem;
}

.order-row.total { font-size: 1rem; }
.order-row.total .gold { font-size: 1.15rem; }

@media (max-width: 600px) {
  .cart-drawer { width: 100vw; max-width: 100vw; top: 0; }
}

.btn {
  padding: 9px 14px;
  font: 500 0.8rem "Space Grotesk", sans-serif;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn.primary {
  background: var(--gold);
  color: var(--ink);
}

.btn.primary:hover { filter: brightness(1.08); }

.btn.primary:disabled {
  opacity: 0.5;
  cursor: default;
  filter: none;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.btn.ghost:hover { color: var(--paper); }

/* ---------- Legend ---------- */

.legend {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 14px;
  padding: 8px 12px;
  font-size: 0.62rem;
  color: var(--muted);
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
}

.legend span { display: inline-flex; align-items: center; gap: 6px; }

.legend .sw {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid var(--line);
}

.sw-free { background: #181c26; }
.sw-held { background: #3a2e12; border-color: var(--gold-dim); }
.sw-taken { background: #2c2618; }
.sw-mine {
  background: linear-gradient(135deg, #2c3e6b 50%, #c96f4a 50%);
  border-color: var(--gold);
}

/* ---------- Tooltip ---------- */

.tooltip {
  position: absolute;
  pointer-events: none;
  padding: 6px 9px;
  font-size: 0.68rem;
  line-height: 1.5;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 5px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  z-index: 25;
}

.tooltip .t-owner { color: var(--gold); }
.tooltip .t-free { color: var(--muted); }

/* ---------- Owner card ---------- */

.owner-card {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 250px;
  padding: 16px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
}

.eyebrow {
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  color: var(--gold);
  margin-bottom: 6px;
}

.owner-card h3 {
  font-size: 1.05rem;
  margin: 6px 0 4px;
  overflow-wrap: anywhere;
}

.owner-card a {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--gold);
  overflow-wrap: anywhere;
  margin-bottom: 6px;
}

.owner-card .muted { font-size: 0.64rem; }

#ownerCoords { font-size: 0.66rem; color: var(--muted); }

.owner-prize {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--gold-dim);
  background: rgba(217, 164, 65, 0.08);
  font-size: 0.7rem;
}

.owner-prize .op-title { color: var(--gold); font-weight: 600; margin-bottom: 2px; }
.owner-prize .op-detail { color: var(--muted); font-size: 0.66rem; }
.owner-prize .op-redeem { margin-top: 6px; color: var(--paper); font-size: 0.68rem; }

.card-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.card-close:hover { color: var(--paper); }

.prize-modal { max-width: 380px; }
.prize-image {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin: 10px 0;
  border: 1px solid var(--line);
}
.prize-redeem {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--ink);
  border: 1px solid var(--line);
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 12, 0.72);
  z-index: 40;
}

.modal {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal h2 {
  font-size: 1.3rem;
  margin-bottom: 8px;
}

.modal > .muted {
  font-size: 0.8rem;
  margin-bottom: 18px;
}

.modal label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  margin: 12px 0 5px;
}

.modal input {
  width: 100%;
  padding: 10px 12px;
  font: 400 0.85rem "IBM Plex Mono", monospace;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.modal input::placeholder { color: #565c6b; }

.modal .claim-actions { margin-top: 20px; }

.modal .fine {
  margin-top: 14px;
  font-size: 0.62rem;
  text-align: center;
}

.error {
  color: #e07059;
  font-size: 0.7rem;
  margin-top: 10px;
}

/* ---------- Reveal banner ---------- */

.reveal-banner {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  padding: 18px 34px;
  background: var(--ink-2);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: 0 0 60px rgba(217, 164, 65, 0.25), var(--shadow);
  z-index: 35;
  animation: reveal-pop 0.7s ease both;
}

.reveal-banner h2 { font-size: 1.2rem; color: var(--gold); }
.reveal-banner p { font-size: 0.7rem; color: var(--muted); margin-top: 4px; }

@keyframes reveal-pop {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  font-size: 0.72rem;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 7px;
  box-shadow: var(--shadow);
  z-index: 50;
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .topbar { height: 76px; flex-wrap: wrap; padding: 8px 14px; }
  .stage { inset: 76px 0 0 0; }
  .progress-wrap { flex: 1 1 100%; }
  .progress-label { text-align: left; margin-top: 3px; }
  .brand .sub { display: none; }
  .toolbar { top: 10px; }
  .tool span { display: none; }
  .tool { padding: 11px 14px; }         /* bigger tap targets */
  .legend { display: none; }
  .claim-panel { right: 10px; bottom: 10px; width: 200px; }
  .owner-card { left: 10px; bottom: 10px; width: 220px; }
  .btn { padding: 11px 16px; }
}

/* ---------- Rotate hint (narrow + tall = phone in portrait) ---------- */

.rotate-hint {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  font-size: 0.68rem;
  color: var(--muted);
  background: var(--ink-2);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 22;
}

.rotate-hint button {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.rotate-hint button:hover { color: var(--paper); }

@media (max-width: 640px) and (orientation: portrait) {
  .rotate-hint { display: flex; top: auto; bottom: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Account & auth ---------- */

.account {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-chip {
  font-size: 0.7rem;
  color: var(--gold);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink-2);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal { position: relative; }

.auth-modal { max-width: 380px; }

.auth-modal .card-close {
  position: absolute;
  top: 10px;
  right: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn.wide { width: 100%; justify-content: center; }

.btn.google {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  background: #fff;
  color: #1a1c22;
  border: 1px solid var(--line);
  font-weight: 500;
}

.btn.google:hover { filter: brightness(0.94); }

.auth-links {
  margin-top: 14px;
  text-align: center;
}

.auth-links a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted var(--line-2, #4a4f63);
}

.auth-links a:hover { color: var(--gold); }

.claim-as {
  font-size: 0.8rem;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  margin: 6px 0 2px;
}

.claim-as strong { color: var(--gold); font-weight: 500; }

#rsDone { color: var(--gold); margin-top: 6px; }

@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; }
  .account .btn { padding: 6px 10px; font-size: 0.72rem; }
}

/* ---------- Admin ---------- */

.admin-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--ink-2);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 25;
}

.admin-tag {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: var(--gold);
  padding: 0 4px;
}

.btn.danger {
  color: #e06c5b;
  border-color: #5a2c24;
  margin-top: 10px;
}

.btn.danger:hover { background: rgba(224, 108, 91, 0.1); }
