:root {
  --bg:        #05070d;
  --bg-panel:  #0b0f19;
  --bg-raised: #121826;
  --line:      #1e2739;
  --line-soft: #161d2c;
  --ink:       #e8edf7;
  --ink-dim:   #8b97ad;
  --ink-faint: #5a6478;
  --accent:    #ff4d2e;
  --accent-2:  #ffb020;
  --ocean:     #070b14;
  --unclaimed: #222c3f;
  --unclaimed-hi: #313d54;
  --ok:        #2fd98a;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --panel-w:   400px;
}

* { box-sizing: border-box; }

/* Several components below set an explicit display, which would otherwise win
   over the user-agent rule for [hidden]. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-mono);
  overflow: hidden;
}

button, input, select { font-family: inherit; }

/* ------------------------------------------------------------- top bar */

.topbar {
  display: flex; align-items: center; gap: 20px;
  height: 56px; padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 19, .92);
  position: relative; z-index: 40;
}

/* The wordmark is artwork: white lettering with a green .lol, drawn for a dark ground.
   Height is fixed and width follows the 537:81 aspect ratio so it never distorts. */
.brand { display: flex; align-items: center; flex: none; }
.brand img { height: 22px; width: auto; display: block; }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

@media (max-width: 520px) {
  .brand img { height: 18px; }
}

.tagline {
  color: var(--ink-faint); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.stats { margin-left: auto; display: flex; gap: 18px; font-size: 12px; color: var(--ink-dim); }
.stats b { color: var(--ink); font-size: 14px; }
.stats .money b { color: var(--accent-2); }

.account { display: flex; gap: 8px; align-items: center; }
.account .who { font-size: 11px; color: var(--ink-dim); max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

.ghost-btn {
  background: transparent; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-size: 11px; letter-spacing: .06em;
  text-transform: uppercase; cursor: pointer; text-decoration: none;
  transition: .15s;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--ink-faint); }

/* ---------------------------------------------------------------- layout */

main { display: flex; height: calc(100% - 56px); }

.map-wrap { position: relative; flex: 1; background: var(--ocean); overflow: hidden; }
#map { width: 100%; height: 100%; display: block; cursor: grab; }
#map.dragging { cursor: grabbing; }

/* Country shapes are fill-only. Borders come from a shared mesh (see drawBorders) so each
   line is drawn exactly once and every border is identical in weight. non-scaling-stroke
   makes stroke-width mean screen pixels rather than map units, so widths hold at any zoom. */
.country { transition: fill .25s, filter .15s; }
.country.unclaimed { fill: var(--unclaimed); }
.country:hover { filter: brightness(1.4); }

.border-line {
  fill: none; stroke-width: 1px; vector-effect: non-scaling-stroke;
  stroke-linejoin: round; stroke-linecap: round; pointer-events: none;
}
.border-inner { stroke: #05070d; }
.border-coast { stroke: #05070d; }

/* Drawn above every country so no neighbour can paint over half of it. */
.highlight {
  fill: none; stroke: #fff; stroke-width: 2px; vector-effect: non-scaling-stroke;
  stroke-linejoin: round; stroke-linecap: round; pointer-events: none;
}

.owner { pointer-events: none; }
.owner-tile { fill: #0b0f19; stroke-width: 1.5px; }
.owner-icon { pointer-events: none; }
.owner-name { font-size: 11px; font-weight: 700; fill: #fff;
              paint-order: stroke; stroke: rgba(0,0,0,.9); stroke-width: 3px;
              text-anchor: middle; letter-spacing: -.2px; }

.map-hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: var(--ink-faint); letter-spacing: .1em;
  text-transform: uppercase; pointer-events: none;
}

.zoom-controls { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 6px; }
.zoom-controls button {
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  background: rgba(18,24,38,.9); border: 1px solid var(--line);
  color: var(--ink-dim); font-size: 16px; line-height: 1;
}
.zoom-controls button:hover { color: var(--ink); border-color: var(--ink-faint); }

.tooltip {
  position: absolute; pointer-events: none; z-index: 30;
  background: rgba(10,14,22,.96); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 11px;
  transform: translate(-50%, calc(-100% - 12px)); white-space: nowrap;
}
.tooltip .t-name { font-weight: 700; margin-bottom: 3px; }
.tooltip .t-price { color: var(--accent-2); }
.tooltip .t-owner { color: var(--ink-dim); }

.search-box { position: absolute; top: 14px; left: 14px; width: 220px; }
.search-box input {
  width: 100%; padding: 9px 12px; border-radius: 8px;
  background: rgba(18,24,38,.9); border: 1px solid var(--line);
  color: var(--ink); font-size: 12px;
}
.search-box input:focus { outline: none; border-color: var(--accent); }
.search-results {
  margin-top: 4px; max-height: 260px; overflow-y: auto;
  background: rgba(10,14,22,.98); border: 1px solid var(--line); border-radius: 8px;
}
.search-results div { padding: 8px 12px; font-size: 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.search-results div:hover { background: var(--bg-raised); }
.search-results .sr-price { color: var(--accent-2); }

/* ----------------------------------------------------------- left panel */

.panel {
  width: 0; flex: 0 0 auto; overflow: hidden;
  background: var(--bg-panel); border-right: 1px solid var(--line);
  transition: width .22s ease;
}
.panel.open { width: var(--panel-w); }
.panel-inner { width: var(--panel-w); height: 100%; overflow-y: auto; padding: 18px; }

.panel-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.panel-head .flag { font-size: 30px; line-height: 1; }
.panel-head h2 { margin: 0; font-size: 21px; letter-spacing: -.5px; }
.panel-head .sub { font-size: 11px; color: var(--ink-faint); margin-top: 3px; }
.panel-close {
  margin-left: auto; background: none; border: none; color: var(--ink-faint);
  font-size: 20px; cursor: pointer; line-height: 1; padding: 0 2px;
}
.panel-close:hover { color: var(--ink); }

.owner-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; margin-bottom: 16px;
}
.owner-card .chip {
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 auto;
  background: var(--bg); border: 1.5px solid var(--line);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.owner-card .chip img { width: 26px; height: 26px; object-fit: contain; }
.owner-card .oc-name { font-weight: 700; font-size: 14px; }
.owner-card .oc-tag { font-size: 11px; color: var(--ink-dim); margin-top: 2px;
                      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.owner-card .oc-meta { font-size: 10px; color: var(--ink-faint); margin-top: 4px; }
.owner-card a.visit {
  margin-left: auto; background: var(--accent); color: #fff; text-decoration: none;
  padding: 8px 12px; border-radius: 8px; font-size: 11px; font-weight: 700;
  letter-spacing: .05em; white-space: nowrap;
}

.free-banner {
  border: 1px dashed var(--line); border-radius: 12px; padding: 12px;
  margin-bottom: 16px; font-size: 12px; color: var(--ink-dim);
}
.free-banner b { color: var(--ok); }

label.field { display: block; margin-bottom: 14px; }
label.field .lbl {
  display: block; font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 6px;
}
label.field input, label.field select {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  background: var(--bg-raised); border: 1px solid var(--line);
  color: var(--ink); font-size: 13px;
}
label.field input:focus { outline: none; border-color: var(--accent); }
label.field input::placeholder { color: var(--ink-faint); }

.bid-row { display: flex; gap: 8px; align-items: stretch; margin-bottom: 6px; }
.bid-row .amount-wrap { flex: 1; position: relative; }
.bid-row .amount-wrap span {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); font-size: 15px;
}
.bid-row input { width: 100%; padding: 12px 12px 12px 26px; font-size: 17px; font-weight: 700;
  border-radius: 10px; background: var(--bg-raised); border: 1px solid var(--line); color: var(--ink); }
.quick { display: flex; gap: 6px; }
.quick button {
  padding: 0 12px; border-radius: 10px; cursor: pointer; font-size: 11px;
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--ink-dim);
}
.quick button:hover { color: var(--ink); border-color: var(--ink-faint); }

.hint { font-size: 11px; color: var(--ink-faint); margin: 0 0 16px; line-height: 1.5; }
.hint b { color: var(--accent-2); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent; padding: 0;
}
.swatches button[aria-pressed="true"] { border-color: #fff; }

.primary-btn {
  width: 100%; margin-top: 18px; padding: 15px; border: none; border-radius: 12px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 800;
  letter-spacing: .04em; cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.1); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }
.secondary-btn {
  width: 100%; margin-top: 8px; padding: 12px; border-radius: 10px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--ink-dim); font-size: 12px;
}
.secondary-btn:hover { color: var(--ink); }

.err {
  background: rgba(255,77,46,.12); border: 1px solid rgba(255,77,46,.4);
  color: #ff9b86; border-radius: 10px; padding: 10px 12px;
  font-size: 12px; margin-bottom: 12px; line-height: 1.45;
}
.note { font-size: 11px; color: var(--ink-faint); margin-top: 12px; line-height: 1.5; text-align: center; }

.section-title {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-faint); margin: 22px 0 10px; padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.history li { list-style: none; display: flex; justify-content: space-between; gap: 10px;
  font-size: 11px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); color: var(--ink-dim); }
.history { padding: 0; margin: 0; }
.history .h-amt { color: var(--ink); }
.history .pending { color: var(--accent-2); }

.sandbox-tag {
  display: inline-block; font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  background: rgba(255,176,32,.15); color: var(--accent-2);
  border: 1px solid rgba(255,176,32,.35); border-radius: 999px; padding: 3px 8px; margin-bottom: 12px;
}

.sandbox-tag.stripe-tag {
  background: rgba(99,91,255,.15); color: #a5a0ff; border-color: rgba(99,91,255,.4);
}

.success-mark { font-size: 40px; text-align: center; margin: 10px 0; }
.success h3 { text-align: center; margin: 0 0 6px; font-size: 18px; }
.success p { text-align: center; font-size: 12px; color: var(--ink-dim); margin: 0 0 4px; line-height: 1.6; }

/* --------------------------------------------------------------- modals */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,4,8,.78);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  width: 380px; max-width: calc(100vw - 32px); max-height: 86vh; overflow-y: auto;
  background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 24px;
}
.modal h2 { margin: 0 0 4px; font-size: 19px; }
.modal .modal-sub { font-size: 12px; color: var(--ink-dim); margin: 0 0 18px; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tabs button {
  flex: 1; padding: 9px; border-radius: 8px; cursor: pointer; font-size: 12px;
  background: var(--bg-raised); border: 1px solid var(--line); color: var(--ink-dim);
}
.tabs button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

.bid-list { list-style: none; padding: 0; margin: 0; }
.bid-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 12px;
}
.bid-list .bl-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.bid-list .bl-meta { color: var(--ink-faint); font-size: 10px; }
.bid-list .bl-amt { margin-left: auto; color: var(--accent-2); font-weight: 700; }
.bid-list .status-pill { flex: 0 0 auto; }
.status-pill { font-size: 9px; text-transform: uppercase; letter-spacing: .08em;
  padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-dim); }
.status-pill.approved { color: var(--ok); border-color: rgba(47,217,138,.4); }
.status-pill.pending_review { color: var(--accent-2); border-color: rgba(255,176,32,.4); }
.status-pill.rejected { color: #ff7a5e; border-color: rgba(255,77,46,.4); }
.status-pill.awaiting_payment { color: var(--ink-faint); }

.empty { text-align: center; color: var(--ink-faint); font-size: 12px; padding: 24px 0; }

@media (max-width: 820px) {
  .tagline, .stats { display: none; }
  .panel.open { width: 100vw; position: absolute; inset: 56px auto 0 0; height: calc(100% - 56px); z-index: 50; }
  :root { --panel-w: 100vw; }
}
