/* KING OF IMMO — interface */
:root {
  --ink: #1d2a3a;
  --ink-2: #55606e;
  --paper: #f5f1e8;
  --card: #ffffff;
  --line: #e2dccf;
  --gold: #d99a1e;
  --gold-dark: #a8740c;
  --blue: #3a6fd8;
  --red: #c0392b;
  --green: #1f8a5b;
  --radius: 10px;
  --shadow: 0 4px 18px rgba(29, 42, 58, .14);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
[hidden] { display: none !important; }
button, input { font: inherit; }
.muted { color: var(--ink-2); }
.crown { color: var(--gold); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }

button {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
button:hover { border-color: var(--ink-2); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
button.primary:hover { background: #2c3e55; }
button.buy { background: var(--gold); border-color: var(--gold-dark); color: #2a1d00; font-weight: 600; width: 100%; padding: 11px; }
button.buy:hover { background: #e7aa2c; }
button.ghost { background: transparent; }
input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ------------------------------------------------------------ screens */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(420px, 100%); padding: 28px; }
.auth-card h1 { margin: 0 0 6px; font-size: 26px; }
.auth-card form { display: grid; gap: 10px; margin-top: 18px; }
.auth-card label { font-weight: 600; font-size: 14px; }
.hint { font-size: 13px; color: var(--ink-2); margin: 0; }
.error { color: var(--red); font-size: 14px; }
.dev { background: #fff6dd; border: 1px dashed var(--gold); padding: 8px 10px; border-radius: 8px; font-size: 14px; }

/* ------------------------------------------------------------ HUD */
body { display: flex; flex-direction: column; }
#hud {
  position: relative; z-index: 5; min-height: 56px; flex: none;
  display: flex; align-items: center; gap: 18px; padding: 0 14px;
  background: var(--ink); color: #fff;
}
#hud .muted { color: #b8c2cf; }
.brand { font-weight: 700; white-space: nowrap; }
.brand #city { font-weight: 400; margin-left: 6px; }
.stats { display: flex; gap: 18px; margin-left: auto; }
.stat { display: grid; line-height: 1.15; }
.stat .label { font-size: 11px; color: #b8c2cf; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
#hud button { color: #fff; border-color: #44566d; padding: 6px 10px; }

/* ------------------------------------------------------------ map */
#game { position: relative; flex: 1; min-height: 0; }
#map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; background: radial-gradient(ellipse at center, #3c566b 0%, #1d2b38 75%); }
#map.dragging { cursor: grabbing; }
#legend { position: absolute; left: 12px; bottom: 12px; padding: 10px 12px; font-size: 13px; display: grid; gap: 4px; }
#filters { position: absolute; left: 12px; top: 12px; padding: 8px 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
#filters label { font-weight: 600; }
#filters select { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.zoom { position: absolute; right: 12px; bottom: 12px; display: grid; gap: 6px; }
.zoom button { width: 40px; height: 40px; padding: 0; font-size: 20px; box-shadow: var(--shadow); }

/* ------------------------------------------------------------ property panel */
#panel {
  position: absolute; top: 12px; right: 12px; bottom: 12px; width: 380px;
  overflow-y: auto; padding: 18px 18px 22px;
}
#panel .close { position: absolute; top: 10px; right: 10px; border: 0; font-size: 22px; padding: 2px 8px; background: transparent; }
#panel h2 { margin: 0 34px 2px 0; font-size: 20px; }
#panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); margin: 18px 0 8px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.tag { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: #efe9dc; }
.tag.mine { background: #fbe7b8; color: #6b4a00; }
.tag.warn { background: #fde2dd; color: #8a2a1d; }
.tag.ok { background: #d9f0e4; color: #0f5a39; }
dl.facts { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--ink-2); }
dl.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
dl.facts dd.big { font-size: 18px; font-weight: 700; }
.statebar { height: 8px; background: #eee6d6; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.statebar span { display: block; height: 100%; background: var(--green); }
.units { display: grid; gap: 8px; }
.unit { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.unit .top { display: flex; justify-content: space-between; font-weight: 600; }
.offer { background: #fbf7ee; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: 16px; }
.offer .refusal { color: var(--red); font-size: 14px; margin: 10px 0 0; }
.picklist { display: grid; gap: 8px; }
.picklist button { text-align: left; display: flex; justify-content: space-between; gap: 8px; }

.nav { display: flex; gap: 6px; }
#hud .nav button { background: #2c3e55; border-color: #44566d; }
#hud .nav button:hover { background: #38506d; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.hint { margin: 6px 0 0; }
button.small { font-size: 13px; padding: 5px 10px; margin-top: 6px; }
button.danger { background: #fff; border-color: #e0b1aa; color: var(--red); font-weight: 600; width: 100%; }
button.danger:hover { background: #fdecea; }
button.armed { outline: 2px solid var(--ink); outline-offset: 1px; }
.offer.bonus .buy { margin-bottom: 4px; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.feed li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: grid; gap: 2px; }
.feed li.link { cursor: pointer; }
.feed li.link:hover { border-color: var(--ink-2); background: #fbf7ee; }
.feed .when { font-size: 12px; color: var(--ink-2); }
.feed.alerts li { border-left: 4px solid var(--gold); }
.feed.alerts li.vacant { border-left-color: var(--red); }
.action-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 10px; display: grid; gap: 8px; }
.action-card .top, .build-opt .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.action-card .refusal, .offer .refusal { margin: 0; }
.build-opt { border-top: 1px dashed var(--line); padding-top: 8px; display: grid; gap: 6px; }
dl.facts.small { font-size: 13px; }
.status { background: #fff6dd; border-radius: 8px; padding: 8px 10px; font-size: 14px; margin: 8px 0 0; }
.rent-form { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.rent-form label { display: flex; gap: 6px; align-items: center; flex: 1; }
.rent-form input { width: 100px; padding: 5px 8px; }
.loan { margin-top: 12px; display: grid; gap: 4px; font-size: 14px; }
.loan input[type=range] { padding: 0; border: 0; }
.prop-list { display: grid; gap: 8px; margin-top: 14px; }
.prop-row { display: grid; gap: 4px; text-align: left; width: 100%; }
.prop-row .figs { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.prop-row .tag { margin-left: 6px; }

#toast {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 6;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 90vw;
}
#toast.error { background: var(--red); }

#clock { white-space: nowrap; }
@media (max-width: 1100px) {
  #clock, .brand #city { display: none; }
  .stats { gap: 12px; }
}

/* ------------------------------------------------------------ mobile */
@media (max-width: 760px) {
  #hud { flex-wrap: wrap; gap: 6px 12px; padding: 8px 10px; }
  #clock, #hud .brand #city { display: none; }
  .stats { order: 3; width: 100%; margin: 0; justify-content: space-between; gap: 8px; }
  .stat .label { font-size: 10px; }
  .stat .value { font-size: 14px; }
  #logout { margin-left: auto; }
  .nav { order: 4; width: 100%; }
  .nav button { flex: 1; }
  #legend { display: none; }
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 62%; border-radius: 16px 16px 0 0; }
  .zoom { bottom: auto; top: 12px; }
}

/* ------------------------------------------------------------ objectives, city events, badges */
.row-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.feed.objectives li { gap: 4px; }
.objective .top { display: flex; justify-content: space-between; gap: 8px; }
.objective.done { background: #f1f8f3; }
.objective.done .statebar span { background: var(--gold); }
.feed.city li { border-left: 4px solid var(--blue); }
.feed.city li.announced { border-left-color: var(--gold); background: #fffaf0; }
.feed.city li.done { opacity: .75; }
.badges { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; font-size: 14px; }
.badges li { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; opacity: .6; }
.badges li.got { opacity: 1; background: #fffaf0; border-color: #ecd9a8; }
.badges .medal { font-size: 22px; line-height: 1; color: var(--gold); }
.badges .when { font-size: 12px; color: var(--ink-2); }

/* ---------------------------------------------------------------- leaderboards and profiles */
button.tag { border: 1px solid transparent; cursor: pointer; margin: 0; }
button.tag.link:hover { border-color: var(--ink-2); }
.tag.small { font-size: 11px; padding: 1px 6px; }
.scope { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 6px 0 10px; }
.scope select { flex: 1; font: inherit; padding: 5px 6px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; padding: 7px 6px; font-size: 14px; }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.ranks { display: grid; gap: 4px; }
.rank-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; text-align: left; width: 100%; padding: 7px 10px; }
.rank-row.me { background: #fffaf0; border-color: #ecd9a8; }
.rank-row .pos-n { font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.rank-row .who { line-height: 1.25; overflow-wrap: anywhere; }
.rank-row .who .muted { font-size: 12px; }
.rank-row .val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.crown { margin: 6px 0; padding: 7px 10px; border-radius: 8px; background: #fff4d6; border: 1px solid #ecd9a8; font-size: 14px; }
p.crown[data-player] { cursor: pointer; }
.badges.compact { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-top: 6px; font-size: 13px; }
.badges.compact li { padding: 5px 8px; align-items: center; }
#legend .link { cursor: pointer; }
#legend .link:hover { text-decoration: underline; }
