:root {
  --grass: #a8c97f;
  --grass-dark: #94b86c;
  --road: #6b6f76;
  --road-line: #e8e2c8;
  --ink: #1f2430;
  --muted: #6b7280;
  --panel: #fffdf7;
  --line: #e7e2d4;
  --accent: #f2a541;
  --accent-ink: #3a2500;
  --good: #2f9e62;
  --bad: #d64545;
  --sheet-w: 380px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--grass-dark);
  color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* --- Карта --- */
.map {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.map.dragging { cursor: grabbing; }
.world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.world svg { display: block; }

.bld { cursor: pointer; }
.bld .roof { transition: filter .15s; }
.bld:hover .roof { filter: brightness(1.08); }
.bld.selected .roof { stroke: var(--accent); stroke-width: 6; }
.bld.kind-decor { cursor: help; }

.bld-label {
  font: 600 22px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  fill: var(--ink);
  paint-order: stroke;
  stroke: rgba(255, 255, 255, .85);
  stroke-width: 5px;
  pointer-events: none;
}
.bld-icon { font-size: 40px; pointer-events: none; }
.badge-text { font: 700 16px/1 -apple-system, BlinkMacSystemFont, sans-serif; fill: #fff; pointer-events: none; }
.street-name {
  font: 700 22px/1 -apple-system, BlinkMacSystemFont, sans-serif;
  fill: rgba(255, 255, 255, .7);
  letter-spacing: 2px;
  pointer-events: none;
}

/* --- Герой, маршрут, автобусы --- */
.hero { pointer-events: none; }
.hero-ring { fill: #fff; stroke: var(--accent); stroke-width: 4; }
.hero-icon { font-size: 30px; }
.route { stroke: var(--accent); stroke-width: 6; stroke-dasharray: 2 12; stroke-linecap: round; opacity: .9; pointer-events: none; }
.bus { pointer-events: none; }
.bus-num { font: 800 13px/1 -apple-system, BlinkMacSystemFont, sans-serif; fill: #5a4300; }

/* --- HUD --- */
.hud {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.hud-row { display: flex; gap: 8px; align-items: stretch; }
.hud-item, .hud-btn, .hud-pill {
  pointer-events: auto;
  background: rgba(255, 253, 247, .94);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.hud-item { display: flex; flex-direction: column; min-width: 0; }
.hud-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.hud-value { font-weight: 700; font-size: 16px; white-space: nowrap; }
.hud-value.neg { color: var(--bad); }
.hud-debt { color: var(--bad); }
.hud-btn { margin-left: auto; font-size: 20px; padding: 0 14px; }
.hud-pill { padding: 4px 10px; font-weight: 700; font-size: 13px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.energy-track { display: inline-block; width: 70px; height: 7px; border-radius: 4px; background: #e9e4d6; overflow: hidden; }
.energy-bar { display: block; height: 100%; width: 0; border-radius: 4px; }

/* --- Строка статуса: что делает герой + время --- */
.status {
  position: fixed;
  left: 10px;
  right: 66px;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(31, 36, 48, .86);
  color: #fff;
  padding: 8px 10px 8px 14px;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
  max-width: 640px;
}
.status-text { flex: 1 1 180px; font-size: 14px; font-weight: 600; cursor: pointer; min-width: 0; }
.status-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.st-btn {
  border: none;
  border-radius: 9px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}
.st-btn.on { background: var(--accent); color: var(--accent-ink); }

.map-controls {
  position: fixed;
  right: 10px;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-controls button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, .94);
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}

/* --- Шторка / панель --- */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 10;
}
.backdrop.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 78vh;
  max-height: 78dvh;
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .2);
  transform: translateY(105%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  z-index: 11;
  user-select: text;
  -webkit-user-select: text;
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #f0ece0;
}
.sheet-body {
  overflow-y: auto;
  padding: 8px 18px max(18px, env(safe-area-inset-bottom));
}

@media (min-width: 820px) {
  .sheet {
    left: auto;
    top: 76px;
    right: 12px;
    bottom: 12px;
    width: var(--sheet-w);
    max-height: none;
    border-radius: 16px;
    transform: translateX(calc(100% + 24px));
  }
  .sheet.open { transform: translateX(0); }
  .sheet-grip { display: none; }
  .backdrop { display: none; }
}

.s-head { display: flex; gap: 12px; align-items: center; padding-right: 36px; margin-top: 6px; }
.s-icon { font-size: 34px; line-height: 1; }
.s-title { font-size: 18px; font-weight: 700; margin: 0; }
.s-addr { color: var(--muted); font-size: 13px; }
.s-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #efeadb;
  margin-top: 4px;
}
.s-tag.mine { background: #d9f0e3; color: #1d6b43; }
.s-tag.here { background: #fde7c4; color: #7a4a00; }
.s-text { margin: 12px 0; color: #3b4150; font-style: italic; }
.s-facts { margin: 0 0 12px; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.s-facts li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.s-facts span:first-child { color: var(--muted); }
.s-facts span:last-child { font-weight: 600; text-align: right; }
.s-section { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 16px 0 8px; }

.actions { display: flex; flex-direction: column; gap: 8px; }
.act {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.act.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.act.danger { color: var(--bad); }
.act:disabled { opacity: .45; cursor: not-allowed; }
.act .act-main { flex: 1; }
.act .act-sub { display: block; font-size: 12px; font-weight: 400; opacity: .8; }
.act .act-price { font-weight: 700; white-space: nowrap; }
.note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* --- Тост --- */
.toast {
  position: fixed;
  left: 50%;
  top: 80px;
  transform: translate(-50%, -20px);
  max-width: min(92vw, 440px);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Старт --- */
.intro {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(31, 36, 48, .55);
  padding: 16px;
  z-index: 30;
}
.intro.hidden { display: none; }
.intro-card {
  background: var(--panel);
  border-radius: 18px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
.intro-card h1 { margin: 0 0 8px; font-size: 24px; }
.intro-sub { color: #3b4150; font-style: italic; }
.intro-choice { display: flex; gap: 10px; flex-wrap: wrap; }
.intro-choice button, .intro-next {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 600;
  font-size: 16px;
}
.intro-next { width: 100%; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); margin-top: 8px; }

@media (max-width: 480px) {
  .hud { gap: 6px; }
  .hud-item { padding: 5px 9px; }
  .hud-value { font-size: 14px; }
  .hud-label { font-size: 10px; }
}
