/* ── Reset & Variables ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #0a0a0f;
  --bg2:     #0f0f18;
  --surface: #14141f;
  --border:  rgba(255,107,53,.15);
  --accent:  #ff6b35;
  --text:    #e8e8f0;
  --muted:   #6b6b85;
  --font:    'Segoe UI', system-ui, sans-serif;
  --mono:    'Courier New', monospace;
  --radius:  8px;
}

html, body { height: 100%; overflow: hidden; }
body { background: var(--bg); color: var(--text); font-family: var(--font); display: flex; flex-direction: column; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input  { font: inherit; }

/* ── Top bar ──────────────────────────────────────────── */
.topbar {
  height: 56px; flex-shrink: 0;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.5rem;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  z-index: 10;
}
.topbar-logo {
  font-family: var(--mono); font-weight: 900; font-size: 1.1rem;
  color: var(--accent); letter-spacing: .12em; text-decoration: none;
  flex-shrink: 0;
}
.topbar-pop {
  display: flex; align-items: center; gap: .4rem;
  background: rgba(255,107,53,.08); border: 1px solid var(--border);
  border-radius: 100px; padding: .25rem .8rem;
}
.pop-val { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.pop-label { font-size: .75rem; color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.topbar-city { font-size: .85rem; color: var(--muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-avatar { border-radius: 50%; border: 1px solid var(--border); }

.btn-sm { padding: .3rem .75rem; font-size: .8rem; border-radius: var(--radius); border: 1px solid var(--border); color: var(--muted); transition: color .2s, border-color .2s; }
.btn-sm:hover { color: var(--text); border-color: rgba(255,107,53,.4); }

/* ── Layout ───────────────────────────────────────────── */
.game-layout { display: flex; flex: 1; overflow: hidden; }

/* ── City panel ──────────────────────────────────────── */
.city-panel {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; padding: 1.25rem;
  gap: 1rem;
}
.city-header { flex-shrink: 0; }
.city-name-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.city-name-big { font-size: 1.4rem; font-weight: 800; }
.rename-btn { font-size: 1rem; opacity: .5; transition: opacity .2s; padding: .2rem; }
.rename-btn:hover { opacity: 1; }
.city-meta { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--muted); }
.cm-sep { opacity: .3; }
.ref-code-val { font-family: var(--mono); color: var(--accent); letter-spacing: .1em; }
.copy-btn { font-size: .8rem; opacity: .6; margin-left: .25rem; transition: opacity .2s; }
.copy-btn:hover { opacity: 1; }

#cityCanvas {
  flex: 1; width: 100%; border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #060610;
  min-height: 0;
}

.claim-panel { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.btn-claim {
  padding: .8rem 2.5rem; font-size: 1rem; font-weight: 700;
  background: var(--accent); color: #000;
  border-radius: var(--radius);
  box-shadow: 0 0 20px rgba(255,107,53,.4);
  transition: transform .15s, box-shadow .15s, filter .15s, opacity .2s;
}
.btn-claim:hover { transform: translateY(-2px); box-shadow: 0 0 32px rgba(255,107,53,.7); }
.btn-claim:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.claim-timer { font-family: var(--mono); font-size: .85rem; color: var(--muted); }
.claim-hint { font-size: .75rem; color: var(--muted); opacity: .6; }

/* ── Side panel ───────────────────────────────────────── */
.side-panel {
  width: 300px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  overflow-y: auto; display: flex; flex-direction: column;
  scrollbar-width: thin; scrollbar-color: rgba(255,107,53,.3) transparent;
}
.panel-section { padding: 1rem; border-bottom: 1px solid var(--border); }
.panel-title {
  font-family: var(--mono); font-size: .65rem; letter-spacing: .2em;
  color: var(--accent); margin-bottom: .75rem;
}

/* Upgrades list */
.upgrade-list { display: flex; flex-direction: column; gap: .5rem; }
.upgrade-item {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .75rem;
  display: flex; flex-direction: column; gap: .25rem;
  transition: border-color .2s;
}
.upgrade-item:hover { border-color: rgba(255,107,53,.35); }
.ui-header { display: flex; justify-content: space-between; align-items: center; }
.ui-name { font-weight: 700; font-size: .9rem; display: flex; align-items: center; gap: .4rem; }
.ui-level { font-family: var(--mono); font-size: .7rem; color: var(--muted); }
.ui-desc { font-size: .78rem; color: var(--muted); }
.ui-footer { display: flex; justify-content: space-between; align-items: center; margin-top: .25rem; }
.ui-cost { font-family: var(--mono); font-size: .8rem; color: var(--accent); }
.btn-upgrade {
  padding: .3rem .9rem; font-size: .78rem; font-weight: 700;
  background: var(--accent); color: #000;
  border-radius: var(--radius);
  transition: filter .15s, opacity .2s;
}
.btn-upgrade:hover { filter: brightness(1.1); }
.btn-upgrade:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.btn-upgrade.maxed { background: rgba(255,255,255,.08); color: var(--muted); }

/* Leaderboard */
.lb-list { display: flex; flex-direction: column; gap: .25rem; }
.lb-entry {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .5rem; border-radius: var(--radius);
  transition: background .2s;
  font-size: .83rem;
}
.lb-entry.me { background: rgba(255,107,53,.06); border: 1px solid rgba(255,107,53,.15); }
.lb-entry:hover { background: rgba(255,255,255,.03); }
.lb-r { font-family: var(--mono); width: 1.8rem; font-size: .75rem; color: var(--muted); flex-shrink: 0; }
.lb-info { flex: 1; min-width: 0; }
.lb-n  { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-c  { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-p  { font-family: var(--mono); font-size: .8rem; color: var(--accent); flex-shrink: 0; }

/* ── Modal ────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal.open { opacity: 1; pointer-events: all; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); }
.modal-box {
  position: relative; z-index: 1;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 2rem; width: 100%; max-width: 400px;
  transform: translateY(20px); transition: transform .3s;
}
.modal.open .modal-box { transform: none; }
.modal-close {
  position: absolute; top: .75rem; right: .75rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: rgba(255,255,255,.05); color: var(--muted); font-size: .9rem;
  transition: background .2s;
}
.modal-close:hover { background: rgba(255,107,53,.15); }
.modal-title { font-size: 1.2rem; font-weight: 800; }
.ref-input {
  width: 100%; padding: .65rem 1rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: .95rem; transition: border-color .2s;
}
.ref-input:focus { outline: none; border-color: var(--accent); }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .65rem 1.4rem; border-radius: var(--radius);
  background: var(--accent); color: #000; font-weight: 700;
  transition: filter .15s;
}
.btn-primary:hover { filter: brightness(1.1); }

/* ── Toast ────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .65rem 1.4rem;
  font-size: .9rem; font-weight: 600; color: var(--text);
  transition: transform .3s, opacity .3s;
  opacity: 0; z-index: 999; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 700px) {
  .side-panel { display: none; }
  .city-panel { padding: .75rem; }
}
