/* ============================================================
   mapped.lol — stylesheet
   Sections:
     1. Design tokens
     2. Base / reset
     3. Map canvas + screen effects
     4. HUD chrome (logo, hint, status, stats)
     5. Search
     6. Layers panel
     7. Tooltip
     8. Claim modal
     9. Buttons (shared)
    10. Select-area button
    11. Draw studio
    12. Toast + loading
    13. Mobile (≤720px)
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  /* palette */
  --accent: #ffd166;        /* gold — brand, prices, highlights */
  --accent-deep: #b98f2f;   /* gold border/shadow */
  --sky: #7dd3fc;           /* light blue — .lol, links, owners */
  --good: #86efac;          /* green — success, prices ok */
  --warn: #fca5a5;          /* red — occupied, override */
  --ink: #e6ecf5;           /* primary text */
  --ink-dim: #b9c7e2;       /* secondary text */
  --ink-faint: #9fb4d8;     /* tertiary text */
  --ink-ghost: #6b7ea8;     /* placeholder / hints */
  --bg: #0a0e1a;            /* page background */
  --well: #0d1322;          /* input backgrounds */
  --raised: #131a2e;        /* button backgrounds */
  --raised-hi: #22304f;     /* active button backgrounds */
  --panel: rgba(10, 14, 26, 0.88);
  --border: #2e3a5c;

  /* depth */
  --shadow-sm: 4px 4px 0 #00000055;
  --shadow-md: 4px 4px 0 #00000066;
  --shadow-lg: 6px 6px 0 #00000088;

  /* z-index scale */
  --z-fx: 5;
  --z-hud: 10;
  --z-search: 15;
  --z-tooltip: 20;
  --z-drawbar: 25;
  --z-modal: 30;
  --z-toast: 40;
  --z-loading: 50;
}

/* ---------- 2. Base / reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: var(--bg); }
body { font-family: 'Press Start 2P', monospace; color: var(--ink); }

/* ---------- 3. Map canvas + screen effects ---------- */
#map { position: fixed; inset: 0; cursor: grab; touch-action: none; image-rendering: pixelated; }
#map.dragging { cursor: grabbing; }
#map.claimable { cursor: crosshair; }
#map.dragging.claimable { cursor: grabbing; }

.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: var(--z-fx);
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0.07) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: var(--z-fx);
  background: radial-gradient(ellipse at center, transparent 62%, rgba(4,6,14,0.55) 100%);
}

/* ---------- 4. HUD chrome ---------- */
.hud { position: fixed; z-index: var(--z-hud); user-select: none; }

#logo { top: 16px; left: 18px; }
#logo h1 { font-size: 20px; color: var(--accent); text-shadow: 3px 3px 0 #00000088; letter-spacing: 1px; }
#logo h1 .lol { color: var(--sky); }
#logo .tag { margin-top: 8px; font-size: 8px; color: var(--ink-faint); text-shadow: 2px 2px 0 #00000088; }
#logo .cursor { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

#hint { top: 16px; right: 18px; font-size: 8px; color: var(--ink-faint); text-align: right; line-height: 2; text-shadow: 2px 2px 0 #000000aa; }

#status { bottom: 14px; left: 18px; font-size: 8px; line-height: 1.9; color: var(--ink-dim); text-shadow: 2px 2px 0 #000000aa; }
#status .band { color: var(--accent); font-size: 10px; }

#stats { bottom: 14px; right: 18px; font-size: 10px; text-align: right; line-height: 2; color: var(--ink-dim); text-shadow: 2px 2px 0 #000000aa; }
#stats b { color: var(--good); }
#recover-link { cursor: pointer; color: var(--sky); text-decoration: underline; }
#recover-link:hover { color: var(--ink); }

/* ---------- 7b. Recovery modal ---------- */
#recover-wrap {
  position: fixed; inset: 0; z-index: var(--z-modal); display: none;
  background: rgba(4, 6, 14, 0.6); align-items: center; justify-content: center;
}
#recover-wrap.open { display: flex; }
#recover-modal {
  width: min(460px, calc(100vw - 32px));
  background: var(--panel); border: 3px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 24px;
}
#recover-modal h2 { font-size: 14px; color: var(--sky); margin-bottom: 14px; }
#recover-modal .rc-note { font-size: 9px; color: var(--ink-faint); line-height: 2; margin-bottom: 16px; }
#recover-modal input[type=email] {
  width: 100%; font-family: inherit; font-size: 11px; padding: 13px;
  background: var(--well); color: var(--ink); border: 2px solid var(--border); outline: none;
  margin-bottom: 16px;
}
#recover-modal input[type=email]:focus { border-color: var(--sky); }

/* ---------- 5. Search ---------- */
#searchwrap {
  top: 14px; left: 50%; transform: translateX(-50%);
  width: min(400px, 56vw); z-index: var(--z-search);
}
#search {
  width: 100%; font-family: inherit; font-size: 9px; padding: 11px 12px;
  background: var(--panel); color: var(--ink); border: 2px solid var(--border);
  outline: none; box-shadow: var(--shadow-sm);
}
#search:focus { border-color: var(--accent); }
#search::placeholder { color: var(--ink-ghost); }
#search-results {
  display: none; margin-top: 4px; background: var(--panel);
  border: 2px solid var(--border); box-shadow: var(--shadow-sm);
  max-height: 300px; overflow-y: auto;
}
#search-results.open { display: block; }
.sr-row { padding: 9px 12px; font-size: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.sr-row:hover, .sr-row.sel { background: var(--raised-hi); }
.sr-row .sr-name { color: var(--ink); }
.sr-row.sel .sr-name { color: var(--accent); }
.sr-row .sr-where { color: var(--ink-ghost); text-align: right; }

/* ---------- 6. Layers panel ---------- */
#layers {
  top: 76px; right: 18px; background: var(--panel); border: 2px solid var(--border);
  padding: 10px 12px; box-shadow: var(--shadow-sm);
}
#layers .lt, #layers .lt2 { font-size: 7px; color: var(--ink-ghost); }
#layers .lt { margin-bottom: 8px; }
#layers .lt2 { margin: 10px 0 4px; }
#layers label {
  display: flex; align-items: center; gap: 8px; font-size: 8px; color: var(--ink-dim);
  padding: 4px 0; cursor: pointer; user-select: none;
}
#layers input[type=checkbox] {
  appearance: none; width: 12px; height: 12px; border: 2px solid var(--border);
  background: var(--well); cursor: pointer; flex-shrink: 0;
}
#layers input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
#map-alpha {
  width: 100%; appearance: none; height: 6px; background: var(--well);
  border: 2px solid var(--border); outline: none; cursor: pointer;
}
#map-alpha::-webkit-slider-thumb {
  appearance: none; width: 14px; height: 14px; background: var(--accent);
  border: 2px solid var(--accent-deep); cursor: pointer;
}

/* ---------- 7. Tooltip ---------- */
#tooltip {
  position: fixed; z-index: var(--z-tooltip); display: none; pointer-events: none;
  background: var(--panel); border: 2px solid var(--border);
  padding: 10px 12px; font-size: 9px; line-height: 1.9; max-width: 300px;
  box-shadow: var(--shadow-md);
}
#tooltip .who { color: var(--sky); }

/* ---------- 8. Claim modal ---------- */
#modal-wrap {
  position: fixed; inset: 0; z-index: var(--z-modal); display: none;
  background: rgba(4, 6, 14, 0.6); align-items: center; justify-content: center;
}
#modal-wrap.open { display: flex; }
#modal {
  width: min(580px, calc(100vw - 32px));
  background: var(--panel); border: 3px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 24px;
}
#modal h2 { font-size: 18px; color: var(--accent); margin-bottom: 14px; }
#modal .where { font-size: 11px; color: var(--ink-faint); margin-bottom: 10px; line-height: 2; }
#modal #modal-price { font-size: 13px; color: var(--good); margin-bottom: 18px; line-height: 2; }
#modal .occupied { font-size: 11px; color: var(--warn); margin-bottom: 16px; line-height: 2; }

.type-row { display: flex; gap: 8px; margin-bottom: 16px; }
.type-btn {
  flex: 1; font-family: inherit; font-size: 11px; padding: 14px 4px;
  background: var(--raised); color: var(--ink-dim); border: 2px solid var(--border); cursor: pointer;
}
.type-btn.active { background: var(--raised-hi); color: var(--accent); border-color: var(--accent); }
.type-btn.disabled { opacity: 0.35; pointer-events: none; }

#modal input[type=text] {
  width: 100%; font-family: inherit; font-size: 13px; padding: 15px;
  background: var(--well); color: var(--ink); border: 2px solid var(--border); outline: none;
  margin-bottom: 12px;
}
#modal input[type=text]:focus { border-color: var(--sky); }
#modal input[type=file] {
  width: 100%; font-family: inherit; font-size: 8px; padding: 10px;
  background: var(--well); color: var(--ink-dim); border: 2px solid var(--border);
  margin-bottom: 10px; cursor: pointer;
}
#modal input[type=file]::file-selector-button {
  font-family: inherit; font-size: 8px; padding: 6px 10px; margin-right: 10px;
  background: var(--raised-hi); color: var(--accent); border: 2px solid var(--border); cursor: pointer;
}
.swatches { display: flex; gap: 8px; margin-bottom: 18px; }
.swatch { width: 26px; height: 26px; border: 2px solid #00000055; cursor: pointer; }
.swatch.active { border-color: #ffffff; box-shadow: 0 0 0 2px var(--accent); }

/* ---------- 9. Buttons (shared) ---------- */
.btn-row { display: flex; gap: 10px; }
.btn {
  font-family: inherit; font-size: 11px; padding: 14px 18px; cursor: pointer;
  border: 2px solid var(--border); background: var(--raised); color: var(--ink-dim);
}
.btn.primary { background: var(--accent); color: #1a1408; border-color: var(--accent-deep); flex: 1; }
.btn.primary:active { transform: translate(2px, 2px); }
.btn.danger { background: #7f1d1d; color: #fecaca; border-color: #b91c1c; }

#modal-report {
  margin-top: 14px; font-size: 9px; color: var(--warn); cursor: pointer;
  text-decoration: underline; text-align: center;
}
#terms-link { color: var(--ink-ghost); text-decoration: underline; }


/* ---------- 10. Explore / claim mode toggle ---------- */
#mode-toggle {
  position: fixed; z-index: 12; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; background: var(--panel); border: 2px solid var(--border);
  box-shadow: var(--shadow-md);
}
.mode-btn {
  font-family: inherit; font-size: 10px; padding: 12px 18px; cursor: pointer;
  background: transparent; color: var(--ink-ghost); border: none;
}
.mode-btn.active { background: var(--accent); color: #1a1408; }

/* ---------- 11. Draw studio ---------- */
#drawbar {
  position: fixed; z-index: var(--z-drawbar); left: 50%; bottom: 18px; transform: translateX(-50%);
  display: none; align-items: center; gap: 12px;
  background: var(--panel); border: 3px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 12px 14px;
}
#drawbar.open { display: flex; }
.draw-left { display: flex; flex-direction: column; gap: 8px; }
#draw-palette { display: flex; gap: 4px; flex-wrap: wrap; max-width: 320px; }
.draw-tools { display: flex; gap: 6px; align-items: center; }
.dt-label { font-size: 7px; color: var(--ink-ghost); }
#draw-picker {
  width: 26px; height: 26px; padding: 0; border: 2px solid var(--border);
  background: var(--well); cursor: pointer;
}
.brush-btn {
  font-family: inherit; font-size: 8px; min-width: 26px; height: 26px; cursor: pointer;
  background: var(--raised); color: var(--ink-dim); border: 2px solid var(--border); padding: 0 5px;
}
.brush-btn.active { background: var(--raised-hi); color: var(--accent); border-color: var(--accent); }
.dp-swatch { width: 20px; height: 20px; border: 2px solid #00000066; cursor: pointer; }
.dp-swatch.active { border-color: #ffffff; box-shadow: 0 0 0 2px var(--accent); }
.dp-swatch.eraser { background: repeating-linear-gradient(45deg, #333 0 4px, #555 4px 8px); }
/* cost readout floats above the toolbar, out of the tool row */
#draw-stats {
  position: fixed; z-index: var(--z-drawbar); left: 50%; transform: translateX(-50%);
  bottom: 108px; display: none; text-align: center;
  background: var(--panel); border: 2px solid var(--border);
  box-shadow: var(--shadow-md); padding: 10px 16px;
  font-size: 10px; color: var(--ink-dim); line-height: 1.9; white-space: nowrap;
}
#drawbar.open + #draw-stats { display: block; }
#draw-stats b { color: var(--good); }
@media (max-width: 720px) {
  #draw-stats { bottom: 150px; font-size: 8px; }
}

/* ---------- 11b. Onboarding ---------- */
#onboard-wrap {
  position: fixed; inset: 0; z-index: var(--z-modal); display: none;
  background: rgba(4, 6, 14, 0.7); align-items: center; justify-content: center;
}
#onboard-wrap.open { display: flex; }
#onboard {
  width: min(560px, calc(100vw - 32px)); text-align: center;
  background: var(--panel); border: 3px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 36px 32px;
}
#onboard .ob-emoji { font-size: 60px; margin-bottom: 20px; }
#onboard h2 { font-size: 18px; color: var(--accent); margin-bottom: 18px; }
#onboard p { font-size: 12px; color: var(--ink-dim); line-height: 2.1; margin-bottom: 22px; min-height: 96px; }
#onboard .btn { font-size: 13px; padding: 16px 20px; }
.ob-dots { display: flex; gap: 10px; justify-content: center; margin-bottom: 22px; }
.ob-dots span { width: 12px; height: 12px; background: var(--raised-hi); }
.ob-dots span.on { background: var(--accent); }
@media (max-width: 720px) {
  #onboard { padding: 22px 18px; }
  #onboard .ob-emoji { font-size: 44px; }
  #onboard h2 { font-size: 13px; }
  #onboard p { font-size: 10px; min-height: 80px; }
  #onboard .btn { font-size: 11px; padding: 13px 16px; }
}

/* ---------- 12. Toast + loading ---------- */
#toast {
  position: fixed; z-index: var(--z-toast); left: 50%; top: 70px; transform: translateX(-50%);
  background: var(--panel); border: 2px solid var(--good); color: var(--good);
  font-size: 9px; padding: 10px 16px; display: none; box-shadow: var(--shadow-md);
}
#loading {
  position: fixed; inset: 0; z-index: var(--z-loading); display: flex; align-items: center; justify-content: center;
  background: var(--bg); flex-direction: column; gap: 18px;
}
#loading .globe { font-size: 42px; animation: spin 1.4s steps(8) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading .txt { font-size: 9px; color: var(--ink-faint); }

/* ---------- 13. Mobile ---------- */
@media (max-width: 720px) {
  #logo { top: 10px; left: 12px; }
  #logo h1 { font-size: 13px; }
  #logo .tag { display: none; }
  #hint { display: none; }
  #searchwrap { top: 42px; width: calc(100vw - 24px); }
  #search { font-size: 8px; padding: 9px 10px; }
  #layers { top: 86px; right: 10px; padding: 7px 9px; }
  #layers label { font-size: 7px; padding: 3px 0; gap: 6px; }
  #layers input[type=checkbox] { width: 10px; height: 10px; }
  #layers .lt, #layers .lt2 { font-size: 6px; }
  #status { bottom: 10px; left: 12px; font-size: 7px; }
  #stats { bottom: 10px; right: 12px; font-size: 7px; }
  #btn-area { bottom: 10px; font-size: 8px; padding: 9px 12px; }
  #drawbar {
    flex-wrap: wrap; justify-content: center; gap: 8px;
    max-width: calc(100vw - 16px); bottom: 10px; padding: 9px 10px;
  }
  #draw-palette { max-width: 100%; }
  #draw-stats { font-size: 7px; }
  #modal { padding: 16px; }
  #modal h2 { font-size: 12px; }
  .type-btn { font-size: 8px; padding: 9px 2px; }
  .btn { font-size: 10px; padding: 12px 14px; }
}
