:root {
  --bg: #1a2332;
  --panel: #243044;
  --panel-2: #2c3a52;
  --text: #e8eef7;
  --muted: #9aacbf;
  --accent: #3d9b6e;
  --accent-hover: #48b37f;
  --danger: #c45c5c;
  --border: #3a4a63;
  --road: #1a1a1a;
  --forest: #1e4d2b;
  --zone: #6fbf5a;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 0%, #2a3d55 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, #1e3328 0%, transparent 45%),
    var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(36, 48, 68, 0.9);
  backdrop-filter: blur(6px);
  gap: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn.reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 6px 12px;
}

.btn.reset:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* Оверлей СТАРТ */
.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(10, 16, 28, 0.72);
  backdrop-filter: blur(4px);
}

.start-overlay.hidden {
  display: none;
}

.btn-start {
  border: none;
  cursor: pointer;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #fff;
  background: linear-gradient(180deg, #4ec98a 0%, #2f9a62 100%);
  padding: 22px 72px;
  border-radius: 16px;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.12) inset;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn-start:hover {
  transform: scale(1.04);
  filter: brightness(1.06);
}

.btn-start:active {
  transform: scale(0.98);
}

.start-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: middle;
}

.tick-info {
  color: var(--muted);
  font-size: 0.95rem;
}

.tick-info strong {
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.map-panel,
.lk-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 650;
  margin-bottom: 10px;
}

.panel-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 16px 0 8px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: -1px;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.swatch.forest { background: var(--forest); }
.swatch.zone { background: var(--zone); }
.swatch.road { background: var(--road); }
.swatch.building {
  background: linear-gradient(90deg, #8a8a8a, #e6c84a);
}
.swatch.owned {
  background: #c9a84a;
  box-shadow: inset 0 0 0 2px #3db8ff;
  position: relative;
}

.map {
  display: grid;
  gap: 1px;
  background: #0f1620;
  padding: 1px;
  border-radius: 6px;
  width: fit-content;
  max-width: 100%;
  overflow: auto;
}

.cell {
  width: 18px;
  height: 18px;
  border: none;
  padding: 0;
  cursor: default;
  border-radius: 1px;
}

.cell.building {
  cursor: pointer;
}

.cell.building:hover {
  outline: 2px solid #fff;
  outline-offset: -1px;
  z-index: 1;
  position: relative;
}

/* Наше здание: синяя рамка + точка в центре */
.cell.building.owned {
  outline: 2px solid #3db8ff;
  outline-offset: -1px;
  box-shadow: inset 0 0 0 2px rgba(20, 40, 70, 0.35);
  position: relative;
  z-index: 2;
}

.cell.building.owned::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3db8ff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.cell.forest { background: var(--forest); }
.cell.zone { background: var(--zone); }
.cell.road { background: var(--road); }

.hint {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.balance-card {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 12px;
}

.balance-card .label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.balance-card .value {
  font-size: 1.2rem;
  font-weight: 650;
  margin-bottom: 8px;
}

.balance-card .money {
  color: #7ddea8;
  font-variant-numeric: tabular-nums;
}

.shop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow: auto;
}

.shop-list li {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.9rem;
}

.shop-list .empty {
  color: var(--muted);
  text-align: center;
}

.shop-list .shop-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.shop-list .shop-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  padding: 14px 16px;
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
}

.modal-body .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dashed rgba(154, 172, 191, 0.25);
  padding-bottom: 6px;
}

.modal-body .row span:first-child {
  color: var(--muted);
}

.modal-foot {
  padding: 12px 16px 16px;
  display: flex;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.95rem;
}

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

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  font-weight: 600;
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.btn.ghost {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 8px;
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 8px;
}
