:root {
  --bg: #120f0c;
  --bg2: #1b1713;
  --card: #231e18;
  --card2: #2c261f;
  --line: #3a3229;
  --text: #efe6d8;
  --muted: #a3978a;
  --sun: #ffb238;
  --sun2: #ff7a2f;
  --good: #5fd17a;
  --bad: #ff5d5d;
  --blue: #4fa3ff;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { background: radial-gradient(ellipse at top, #2a1c0e 0%, var(--bg) 55%) fixed; min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); min-height: 1.4em; margin-top: 8px; }
.good { color: var(--good); } .bad { color: var(--bad); } .sun { color: var(--sun); }
h2 { margin: 18px 0 10px; font-size: 19px; } h3 { margin: 14px 0 8px; font-size: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

.logo { font-weight: 800; letter-spacing: .5px; color: var(--sun); white-space: nowrap; }
.logo.big { font-size: 30px; text-align: center; margin-bottom: 6px; }

.btn { background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; font: inherit; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--sun); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--sun), var(--sun2)); color: #1a1006; border: 0; font-weight: 700; }
.btn.danger { border-color: #6d2a2a; color: #ff9b9b; }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 3px 8px; font-size: 12px; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
input, select { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; font: inherit; }

.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.auth-card .row .btn { flex: 1; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: rgba(18,15,12,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.res { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; }
.res b { font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 4px; padding: 8px 16px; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--bg2); }
.tab { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 9px; cursor: pointer; font: inherit; white-space: nowrap; position: relative; }
.tab.on { background: var(--card2); color: var(--sun); }
.tab .dot { position: absolute; top: 4px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--sun2); }
main { max-width: 1200px; margin: 0 auto; padding: 8px 16px 60px; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.sel { border-color: var(--sun); box-shadow: 0 0 0 1px var(--sun) inset; }
.card.dim { opacity: .55; }
.card.pick { cursor: pointer; }
.card h4 { margin: 0; font-size: 15px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }

.hero-top { display: flex; gap: 10px; align-items: center; }
.avatar { width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center; font-size: 24px; background: var(--bg2); border: 2px solid var(--line); flex: none; position: relative; }
.avatar .el { position: absolute; right: -6px; bottom: -6px; font-size: 14px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; font-size: 12px; margin: 8px 0; text-align: center; }
.stats div { background: var(--bg2); border-radius: 6px; padding: 3px 0; }
.stats b { display: block; font-size: 13px; }
.bar { height: 7px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin: 4px 0; }
.bar > i { display: block; height: 100%; background: var(--good); border-radius: 99px; transition: width .4s; }
.bar.xp > i { background: var(--blue); }
.bar.boss { height: 16px; } .bar.boss > i { background: linear-gradient(90deg, var(--sun2), var(--sun)); }
.bar.prog > i { background: var(--sun); }
.slots { display: flex; flex-direction: column; gap: 3px; font-size: 12px; margin: 6px 0; }
.slots .it { display: flex; justify-content: space-between; gap: 6px; background: var(--bg2); padding: 3px 7px; border-radius: 6px; }
.status { font-size: 12px; }

.item { display: flex; flex-direction: column; gap: 6px; }
.kv { display: flex; justify-content: space-between; gap: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; background: var(--bg2); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit; }
.seg button.on { background: var(--card2); color: var(--sun); }

.floor-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.floor-btn { flex: none; width: 46px; height: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); color: var(--text); cursor: pointer; font: inherit; font-weight: 700; }
.floor-btn.on { border-color: var(--sun); color: var(--sun); }
.floor-btn.new { box-shadow: 0 0 10px rgba(255,178,56,.5); }

.log { font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; background: var(--bg2); border-radius: 8px; padding: 8px 10px; max-height: 320px; overflow: auto; white-space: pre-wrap; }
details summary { cursor: pointer; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; }
.close { position: absolute; top: 8px; right: 12px; background: none; border: 0; color: var(--muted); font-size: 26px; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(120px); background: var(--card2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; transition: transform .25s; z-index: 30; max-width: calc(100% - 32px); }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--bad); color: #ffb3b3; }

.ev { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ev time { color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 92px; }

/* пассивки и характер */
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.chip { font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); cursor: help; white-space: nowrap; }
.chip.pos { border-color: #2f6b3d; color: #8fe0a2; }
.chip.neg { border-color: #7a2f2f; color: #ff9b9b; }
.chip.char { border-color: #6b5a2f; color: var(--sun); }
.star { color: #ff4f6d; }
.card.unique { border-color: #ff4f6d55; box-shadow: 0 0 18px #ff4f6d22; }
.legend { margin-top: 10px; }

/* город: карта 6×4, Разлом 2×2 в центре */
.city-wrap { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 14px; align-items: start; margin-top: 12px; }
.city { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-flow: dense; gap: 6px; padding: 10px; border-radius: 16px;
  background: radial-gradient(circle at center, #3a2408 0%, var(--bg2) 70%); border: 1px solid var(--line); }
.tile { aspect-ratio: 1; background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font: inherit;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px; text-align: center; min-width: 0; }
.tile b { font-size: 11px; line-height: 1.15; overflow-wrap: normal; hyphens: auto; }
.tile .small { font-size: 10px; }
.tile:hover, .tile.on { border-color: var(--sun); }
.tile.ready { box-shadow: 0 0 0 1px #5fd17a66 inset; }
.tile.empty { border-style: dashed; background: transparent; opacity: .7; }
.tile.empty .tile-icon { filter: grayscale(1); opacity: .6; }
.tile.deco { cursor: default; background: transparent; border-color: transparent; font-size: 20px; opacity: .35; }
.tile-icon { font-size: 22px; }
.tile.rift { grid-column: 3 / span 2; grid-row: 2 / span 2; aspect-ratio: auto; background: radial-gradient(circle, #ff7a2f55 0%, #1a0f05 75%); border-color: var(--sun2); }
.tile.rift b { font-size: 14px; }
.tile.rift .small { font-size: 12px; }
.tile.rift .tile-icon { font-size: 44px; animation: spin 14s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tile.rift .tile-icon { animation: none; } }
.secret { border-color: var(--sun); background: linear-gradient(135deg, #3a2408, var(--card)); }
.secret-off { padding: 10px 16px; }
.invasion { border-color: var(--bad); background: linear-gradient(135deg, #3a0f0f, var(--card)); }
.panel.inner { background: var(--bg2); padding: 10px 12px; margin: 10px 0; }
.meters { display: grid; grid-template-columns: auto 1fr; gap: 2px 6px; align-items: center; margin: 6px 0 2px; }
.meters .bar { margin: 0; }
.bar.stam > i { background: #4fd1c5; }
.bar.mood > i { background: var(--sun); }
input[type=number] { padding: 5px 8px; }
select { padding: 5px 8px; }

@media (max-width: 860px) {
  .city-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .city { grid-template-columns: repeat(4, 1fr); }
  .tile.rift { grid-column: 2 / span 2; grid-row: 2 / span 2; }
}
@media (max-width: 600px) {

  .top { gap: 8px; }
  .top .res { order: 3; flex-basis: 100%; }
  .top .who { margin-left: auto; }
  .stats { grid-template-columns: repeat(5, 1fr); font-size: 11px; }
  .grid { grid-template-columns: 1fr; }
}
.kv .tag { flex: none; align-self: flex-start; white-space: nowrap; }

/* арт */
.art { display: block; width: 100%; height: 100%; }
.avatar { overflow: visible; padding: 0; border-color: var(--line); background: none; }
.avatar > svg { border-radius: 8px; }
.avatar.big { width: 96px; height: 96px; }
.hero-frame { border: 2px solid transparent; background: linear-gradient(var(--bg2), var(--bg2)) padding-box,
  linear-gradient(120deg, #ff4f6d, #ffb238, #ffd23f, #4fd36b, #4fa3ff, #b77bff, #ff4f6d) border-box; }
.item-icon { width: 34px; height: 34px; flex: none; }
.slots .it .art.icon { width: 18px; height: 18px; flex: none; }
.rainbow { background: linear-gradient(90deg, #ff4f6d, #ffb238, #ffd23f, #4fd36b, #4fa3ff, #b77bff, #ff4f6d);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent !important;
  animation: rainbow 4s linear infinite; }
@keyframes rainbow { to { background-position: 200% 0; } }
@media (prefers-reduced-motion: reduce) { .rainbow { animation: none; } }

/* живой город */
.city { position: relative; }
.city-life { position: absolute; inset: 0; pointer-events: none; }
.walker { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; overflow: visible;
  transition: left 3s ease-in-out, top 3s ease-in-out, opacity 1.5s, transform 1.5s; filter: drop-shadow(0 2px 3px #000a); pointer-events: auto; }
.walker > svg { border-radius: 50%; border: 1.5px solid #fff8; }
.walker .badge { position: absolute; right: -7px; top: -8px; font-size: 11px; }
.walker.away { opacity: .35; transform: scale(.7); }
.walker.lost { filter: grayscale(1) drop-shadow(0 0 4px #f44); }
@media (prefers-reduced-motion: reduce) { .walker { transition: none; } }
.plaza { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ============================================================ пиксельный стиль */
:root { --bg: #14101a; --bg2: #1d1724; --card: #261e2e; --card2: #31283b; --line: #4a3d58; --text: #f1e9dc; --muted: #a596b0; --radius: 0; }
html, body { font-family: "VT323", "Courier New", monospace; font-size: 20px; line-height: 1.2; }
.small { font-size: 17px; }
.stats, .chip, .tag, .slots { font-size: 16px; }
h1, h2, h3, h4, .logo, .btn, .tab, .tile b, .seg button, th, .num b, .kv > b, .tag, .chip { font-family: "Tiny5", "VT323", monospace; font-weight: 400; }
h2 { font-size: 22px; } h3 { font-size: 18px; } h4 { font-size: 16px; }
.btn, .tab, .seg button { font-size: 15px; }
.tile b { font-size: 12px; } .tile .small { font-size: 14px; }
.chip, .tag { font-size: 12px; }
body { background: var(--bg); background-image:
  linear-gradient(45deg, #17121e 25%, transparent 25%, transparent 75%, #17121e 75%),
  linear-gradient(45deg, #17121e 25%, transparent 25%, transparent 75%, #17121e 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; }
*, *::before, *::after { border-radius: 0 !important; }
svg.px { image-rendering: pixelated; display: block; width: 100%; height: 100%; }
img.aic { display: inline-block; width: 100%; height: 100%; object-fit: contain; image-rendering: auto; vertical-align: middle; }
.ico { display: inline-block; width: 16px; height: 16px; vertical-align: -2px; margin-right: 4px; }
.ico.big { width: 28px; height: 28px; vertical-align: -5px; }
.logo { font-weight: 700; text-shadow: 2px 2px 0 #000; }

/* рамки: двойная пиксельная обводка + жёсткая тень */
.card, .panel, .auth-card, .modal-card { border: 2px solid #0b080f; box-shadow: inset 0 0 0 2px var(--line), 4px 4px 0 #0008; }
.card.sel { box-shadow: inset 0 0 0 2px var(--sun), 4px 4px 0 #0008; }
.card.unique { box-shadow: inset 0 0 0 2px #ff4f6d88, 4px 4px 0 #0008; }
.panel.inner { box-shadow: inset 0 0 0 2px #0006; }
.top { background: #1a1422; border-bottom: 4px solid #0b080f; box-shadow: 0 2px 0 var(--line); }
.tabs { background: #1d1724; border-bottom: 4px solid #0b080f; }
.tab { font-family: inherit; }
.tab.on { background: var(--card2); color: var(--sun); box-shadow: inset 0 -3px 0 var(--sun); }

/* кнопки: объёмные пиксельные */
.btn { font-family: inherit; border: 2px solid #0b080f; background: var(--card2);
  box-shadow: inset -2px -2px 0 #0006, inset 2px 2px 0 #ffffff1a; padding: 7px 12px; }
.btn:hover:not(:disabled) { border-color: #0b080f; filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: inset 2px 2px 0 #0006; }
.btn.primary { background: #ffb238; color: #1a1006; box-shadow: inset -2px -2px 0 #c46a10, inset 2px 2px 0 #ffe0a0; }
.btn.danger { color: #ff9b9b; }
input, select { font-family: inherit; border: 2px solid #0b080f; box-shadow: inset 2px 2px 0 #0008; background: #120e17; }

/* полоски: сегменты */
.bar { height: 10px; border: 2px solid #0b080f; background: #0e0b12; margin: 3px 0; }
.bar > i { background-image: repeating-linear-gradient(90deg, transparent 0 5px, #0007 5px 7px); }
.bar.boss { height: 18px; }

/* чипы и теги */
.chip, .tag { border: 2px solid #0b080f; box-shadow: inset 0 0 0 1px #ffffff14; }

/* портреты и иконки */
.avatar { width: 52px; height: 52px; border: 2px solid #0b080f; box-shadow: 2px 2px 0 #0008; }
.avatar > svg { border-radius: 0; }
.hero-frame { border: 2px solid #0b080f; box-shadow: 0 0 0 2px #ff4f6d, 0 0 0 4px #ffd23f, 0 0 0 6px #4fa3ff; }
.item-icon { width: 36px; height: 36px; }
.slots .it .px.icon { width: 20px; height: 20px; flex: none; }

/* город: трава, домики-спрайты */
.city { background-color: #3f7a32; background-image:
  linear-gradient(90deg, #00000014 1px, transparent 1px), linear-gradient(#00000014 1px, transparent 1px),
  radial-gradient(#5c9a3f 1px, transparent 1.5px);
  background-size: 16px 16px, 16px 16px, 8px 8px; border: 4px solid #0b080f; box-shadow: inset 0 0 0 2px #2c5521, 4px 4px 0 #0008; }
.tile { background: #0000; border: 2px solid transparent; color: #fff; text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000; }
.tile:hover, .tile.on { border-color: #ffd23f; background: #0000002a; }
.tile.ready { box-shadow: inset 0 0 0 2px #4fd36b; }
.tile.empty { border-style: dashed; border-color: #ffffff30; opacity: 1; }
.tile.empty .tile-icon { filter: none; opacity: .7; }
.tile-icon { width: 46px; height: 46px; font-size: 0; }
.tile.rift { background: #1a0f05aa; border-color: #ff7a2f; }
.tile.rift .tile-icon { width: 92px; height: 92px; animation: riftspin 6s steps(12) infinite; }
@keyframes riftspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tile.rift .tile-icon { animation: none; } }
.walker { width: 22px; height: 22px; margin: -18px 0 0 -11px; border-radius: 0; filter: drop-shadow(2px 2px 0 #0009); }
.walker > svg { border: none; border-radius: 0; animation: bob .6s steps(2) infinite; }
@keyframes bob { 50% { transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .walker > svg { animation: none; } }
.walker .badge { right: -8px; top: -10px; }
.log { font-family: "VT323", monospace; font-size: 17px; }
@media (max-width: 600px) {
  .tile-icon { width: 34px; height: 34px; }
  .tile.rift .tile-icon { width: 64px; height: 64px; }
}

/* ============================================================ верхнее меню (HUD) */
.hud { position: sticky; top: 0; z-index: 6; background: #1a1422; border-bottom: 4px solid #0b080f; box-shadow: 0 2px 0 var(--line); }
.hud-top { display: flex; align-items: center; gap: 14px; padding: 8px 16px; flex-wrap: wrap; }
.hud-city { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hud-city .px, .hud-res .px, .tool .px { width: 16px; height: 16px; display: inline-block; }
.hc-name { display: inline-flex; gap: 6px; align-items: center; font-family: "Tiny5", monospace; font-size: 15px; }
.hc-lvl, .hc-rep { display: inline-flex; gap: 4px; align-items: center; padding: 1px 8px; background: #0e0b12; border: 2px solid #0b080f;
  box-shadow: inset 0 0 0 1px var(--line); font-size: 17px; }
.hud-res { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; justify-content: flex-end; }
.hr { display: inline-flex; gap: 5px; align-items: center; padding: 2px 8px; background: #0e0b12; border: 2px solid #0b080f;
  box-shadow: inset 0 0 0 1px var(--line); font-size: 18px; }
.hr b { font-family: "Tiny5", monospace; font-weight: 400; font-size: 13px; }
.hbar { display: inline-block; width: 28px; height: 6px; background: #261e2e; border: 1px solid #000; }
.hbar i { display: block; height: 100%; background: #4fd36b; }
.hbar.full i { background: #ffb238; }
.hud-tools { display: flex; gap: 6px; padding: 6px 16px 8px; overflow-x: auto; scrollbar-width: thin; }
.tool { position: relative; flex: none; display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; cursor: pointer;
  background: var(--card2); color: var(--text); border: 2px solid #0b080f; box-shadow: inset -2px -2px 0 #0006, inset 2px 2px 0 #ffffff1a;
  font-family: "Tiny5", monospace; font-size: 12px; }
.tool:hover { filter: brightness(1.2); }
.tool:active { transform: translate(1px, 1px); }
.tool .tl { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.tool small { font-family: "VT323", monospace; font-size: 15px; color: var(--muted); display: inline-flex; gap: 2px; align-items: center; }
.tool small .px { width: 10px; height: 10px; }
.tool.hot { background: #5a3a12; box-shadow: inset -2px -2px 0 #0006, inset 2px 2px 0 #ffd23f55, 0 0 0 2px #ffb238; animation: blink 1.2s steps(2) infinite; }
.tool.bad { background: #4a1a1e; box-shadow: inset -2px -2px 0 #0006, 0 0 0 2px #e0474c; }
@keyframes blink { 50% { box-shadow: inset -2px -2px 0 #0006, 0 0 0 2px #ffd23f; } }
@media (prefers-reduced-motion: reduce) { .tool.hot { animation: none; } }
.tbadge { position: absolute; top: -8px; right: -6px; min-width: 18px; padding: 0 4px; background: #e0474c; color: #fff;
  border: 2px solid #0b080f; font-size: 11px; text-align: center; }
.tab { display: inline-flex; align-items: center; gap: 6px; }
.tab .ico { width: 16px; height: 16px; margin: 0; }
.pi { display: inline-block; width: 1em; height: 1em; vertical-align: -0.12em; margin: 0 1px; }
.pi > svg { width: 100%; height: 100%; }
.tile-icon .pi { width: 100%; height: 100%; }
@media (max-width: 600px) {
  .hud-top { gap: 8px; padding: 6px 10px; }
  .hud-res { justify-content: flex-start; }
  .hud-tools { padding: 4px 10px 6px; }
  .logo { font-size: 14px; }
}
.walker .badge { width: 10px; height: 10px; } .walker .badge .pi { width: 10px; height: 10px; }
#r-name { display: none; }
@media (max-width: 600px) {
  .hud { position: static; }
  .hr { font-size: 16px; padding: 1px 6px; }
  .hc-lvl, .hc-rep { font-size: 15px; }
}

/* ============================================================ сцена города */
.citymap { position: relative; border: 4px solid #0b080f; box-shadow: 4px 4px 0 #0008; background: #3e7531; line-height: 0; }
.cityscene { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.cityscene .spot { cursor: pointer; }
.cityscene .spot .hit { fill: transparent; stroke: transparent; stroke-width: 2; }
.cityscene .spot:hover .hit { fill: #ffffff18; stroke: #ffd23f; }
.cityscene .spot.sel .hit { fill: #ffd23f22; stroke: #ffd23f; }
.cityscene .spot.plot { opacity: .8; }
.cityscene .lbl { font-family: "Tiny5", monospace; font-size: 10px; fill: #fff; paint-order: stroke; stroke: #0b080f; stroke-width: 3px; stroke-linejoin: round; }
.cityscene .lbl.big { font-size: 10px; fill: #ffd23f; }
.cityscene .lvl { font-family: "Tiny5", monospace; font-size: 10px; fill: #ffd23f; }
.cityscene .riftspin { transform-box: fill-box; transform-origin: center; animation: riftspin 6s steps(12) infinite; }
@media (prefers-reduced-motion: reduce) { .cityscene .riftspin { animation: none; } }
.city-wrap { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .city-wrap { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .cityscene .lbl:not(.big) { display: none; } }
.citymap .walker { width: var(--ws, 18px); height: var(--ws, 18px); margin: calc(var(--ws, 18px) * -0.85) 0 0 calc(var(--ws, 18px) * -0.5); }

/* ============================================================ изометрический город */
.isomap { position: relative; height: 620px; border: 4px solid #0b080f; box-shadow: 4px 4px 0 #0008; background: #3e7531; touch-action: none; }
.isocanvas { display: block; width: 100%; height: 100%; cursor: grab; image-rendering: pixelated; }
.isozoom { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; }
.isozoom .btn { min-width: 30px; font-size: 16px; }
@media (max-width: 600px) { .isomap { height: 440px; } }

/* нарисованные спрайты */
.ai-icon { display: inline-block; width: 100%; height: 100%; }
.ai-icon img { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.slots .it .ai-icon { width: 20px; height: 20px; flex: none; }
img.px.portrait { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

/* ============================================================ город на весь экран (кроме верхнего меню) */
body.city-mode { overflow: hidden; }
body.city-mode main { max-width: none; padding: 0; margin: 0; }
.city-full { position: relative; height: calc(100vh - var(--top, 160px)); height: calc(100dvh - var(--top, 160px)); }
.city-full .isomap { height: 100%; border: 0; box-shadow: none; }
.city-over { position: absolute; left: 12px; right: 140px; top: 8px; pointer-events: none; }
.city-over .panel { pointer-events: auto; margin: 0; max-width: 720px; }
.city-status { position: absolute; left: 10px; bottom: 8px; padding: 2px 10px; background: #0e0b12cc; border: 2px solid #0b080f; pointer-events: none; }
/* меню здания / логова — окно по центру */
.modal-card.wide { max-width: 960px; }
@media (max-width: 600px) { .modal { padding: 6px; } .modal-card { padding: 14px 10px; max-height: 94vh; } }
/* тумблер налога в верхнем меню */
.tool.toggle { background: #23402a; box-shadow: inset -2px -2px 0 #0006, 0 0 0 2px #4fd36b; }
.tool.toggle.on { background: #4a3a12; box-shadow: inset -2px -2px 0 #0006, 0 0 0 2px #ffb238; }
/* логово босса и бестиарий */
.boss-head { display: flex; gap: 16px; align-items: center; }
.boss-art { height: 150px; image-rendering: pixelated; flex: none; filter: drop-shadow(0 0 10px #ff4a2f88); }
.boss-art.dead { filter: grayscale(1) opacity(.5); }
@media (max-width: 600px) { .boss-head { flex-direction: column; } .boss-art { height: 110px; } }
.boss-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.boss-mini { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; background: var(--card); border: 2px solid #0b080f; text-align: center; font-size: 16px; }
.boss-mini.on { box-shadow: 0 0 0 2px #ffb238; }
.boss-mini img { height: 64px; image-rendering: pixelated; }
.foes { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-end; margin: 4px 0; }
img.creature { image-rendering: pixelated; vertical-align: middle; margin-right: 4px; }
.city-over .close-x { float: right; background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 0 0 8px; }
@media (max-width: 600px) { .city-over { right: 120px; } .city-over .panel { font-size: 15px; padding: 6px 8px; } }

/* ============================================================ окна вкладок поверх карты */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; top: var(--top, 160px); z-index: 10; display: flex; justify-content: center;
  align-items: flex-start; padding: 14px; background: rgba(10, 8, 14, .45); }
.sheet-card { position: relative; width: 100%; max-width: 1180px; max-height: 100%; overflow: auto; background: var(--bg);
  border: 2px solid #0b080f; box-shadow: inset 0 0 0 2px var(--line), 6px 6px 0 #000a; padding: 0 16px 16px; }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 10px 0; background: var(--bg); border-bottom: 2px solid var(--line); margin-bottom: 10px; }
.sheet-head h2 { margin: 0; flex: 1; display: flex; gap: 8px; align-items: center; }
.sheet-head .pi { width: 20px; height: 20px; display: inline-block; }
.sheet-head .close { position: static; }
@media (max-width: 600px) { .sheet { padding: 4px; } .sheet-card { padding: 0 8px 10px; } }
/* лента событий на карте */
.city-status { max-width: min(560px, calc(100% - 20px)); pointer-events: none; line-height: 1.15; }
.city-status .tick { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
/* список героев */
.hlist { display: flex; flex-direction: column; gap: 4px; }
.hrow { display: grid; grid-template-columns: 40px minmax(0, 1fr) 150px 64px; gap: 10px; align-items: center; padding: 4px 8px; cursor: pointer;
  background: var(--card); border: 2px solid #0b080f; box-shadow: inset 0 0 0 1px var(--line); }
.hrow:hover { filter: brightness(1.15); }
.hrow.sel { box-shadow: inset 0 0 0 2px #ffb238; }
.hrow.dim { opacity: .45; cursor: default; }
.hrow.unique { box-shadow: inset 0 0 0 1px #ffd23f88; }
.hr-main { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; min-width: 0; }
.hr-bars { display: flex; flex-direction: column; gap: 3px; }
.mb { display: block; height: 5px; background: #1a1420; border: 1px solid #000; }
.mb i { display: block; height: 100%; }
.hr-pow { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.avatar.sm { width: 36px; height: 36px; }
@media (max-width: 600px) { .hrow { grid-template-columns: 36px minmax(0, 1fr) 60px; } .hr-pow { display: none; } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
table.kvt { width: 100%; margin-top: 4px; } table.kvt td { padding: 1px 4px; border-bottom: 1px solid #ffffff10; }

/* характеристики героя: настроение, характер, пассивки */
.trait { display: flex; flex-direction: column; gap: 1px; padding: 5px 8px; margin-top: 5px; background: #0e0b12; border-left: 3px solid var(--line); }
.trait.pos { border-left-color: #4fd36b; } .trait.neg { border-left-color: #e0474c; } .trait.char { border-left-color: #b77bff; }
.trait.pos > b { color: #7dff8f; } .trait.neg > b { color: #ff7a6a; } .trait.char > b { color: #e0a8ff; }
.mood-big { font-family: "Tiny5", monospace; font-size: 26px; margin: 4px 0; }
/* крупные значки ресурсов в верхнем меню */
.hud-res .px, .hud-res .pi { width: 26px !important; height: 26px !important; }
.hud-city .px { width: 22px !important; height: 22px !important; }
.tool .px { width: 22px !important; height: 22px !important; }
.tool small .px { width: 14px !important; height: 14px !important; }
.hr { padding: 3px 10px; gap: 7px; }
.hr b { font-size: 16px; }
@media (max-width: 600px) { .hud-res .px { width: 20px !important; height: 20px !important; } .hr b { font-size: 14px; } }

/* картинка здания в его меню, под ней — описание */
.bld-art { margin: 10px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bld-art > img { width: min(300px, 70vw); height: auto; image-rendering: pixelated; border: 3px solid #0b080f; box-shadow: 4px 4px 0 #0008; }
.bld-art figcaption { text-align: center; color: var(--muted); max-width: 640px; }
.tab-art { float: right; width: 120px; height: auto; margin: 0 0 8px 12px; image-rendering: pixelated; border: 3px solid #0b080f; box-shadow: 3px 3px 0 #0008; }
@media (max-width: 600px) { .tab-art { width: 80px; } }

/* картинки лавок на витринах (вкладка «Торговля») */
.shop-panel { overflow: hidden; }
.shop-art { float: left; width: 96px; height: auto; margin: 0 12px 6px 0; image-rendering: pixelated; border: 2px solid #0b080f; }
@media (max-width: 600px) { .shop-art { width: 64px; } }

/* режимы цен в лавке: дешёвые — зелёная рамка, обычные — белая, дорогие — красная; выбранный — ярче и толще */
.seg .pm { border: 2px solid transparent; margin: 0 2px; }
.seg .pm-cheap { border-color: #4fd36b66; color: #7dff8f; }
.seg .pm-normal { border-color: #ffffff55; color: #f4f0e6; }
.seg .pm-expensive { border-color: #e0474c66; color: #ff7a6a; }
.seg .pm.on { border-width: 3px; }
.seg .pm-cheap.on { border-color: #4fd36b; background: #1f3a24; color: #a8ffb5; }
.seg .pm-normal.on { border-color: #ffffff; background: #3a3440; color: #fff; }
.seg .pm-expensive.on { border-color: #e0474c; background: #4a1a1e; color: #ffb0a8; }

/* витрина в меню лавки */
.irow { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 5px 6px; margin-top: 4px;
  background: #0e0b12; border: 1px solid #ffffff12; }
.irow .item-icon { width: 24px; height: 24px; display: inline-block; }
.ir-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.swap-box { margin: 2px 0 8px 20px; padding: 6px; border-left: 3px solid #ffb238; background: #1a1420; }
.swap-list { max-height: 260px; overflow: auto; }
@media (max-width: 600px) { .irow { grid-template-columns: 24px minmax(0, 1fr); } .ir-side { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; } }

/* ============================================================ левая панель героев на карте */
.side { position: absolute; left: 8px; top: 8px; bottom: 8px; width: 290px; overflow-y: auto; z-index: 3; display: none;
  background: #140f1acc; border: 2px solid #0b080f; box-shadow: inset 0 0 0 1px var(--line), 4px 4px 0 #0008; padding: 6px; scrollbar-width: thin; }
.city-full.side-on .side { display: block; }
.side-toggle { position: absolute; left: 8px; top: 8px; z-index: 4; font-family: "Tiny5", monospace; font-size: 12px; padding: 4px 8px; cursor: pointer;
  background: var(--card2); color: var(--text); border: 2px solid #0b080f; }
.city-full.side-on .side-toggle { left: 306px; }
.side-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.sh { padding: 5px 6px; margin-bottom: 4px; background: #0e0b12d0; border: 1px solid #ffffff14; cursor: pointer; }
.sh:hover { border-color: #ffb23888; }
.sh.unique { border-color: #ffd23f66; }
.sh-top { display: flex; gap: 6px; align-items: center; }
.avatar.xs { width: 28px; height: 28px; }
.sh-name { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.sh-name b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-bars { display: grid; grid-template-columns: 22px 1fr 34px; gap: 2px 4px; align-items: center; margin: 4px 0 2px; font-size: 13px; }
.sh-bars .sl { color: var(--muted); font-family: "Tiny5", monospace; font-size: 10px; }
.sh-bars .sv { text-align: right; font-family: "Tiny5", monospace; font-size: 10px; }
.sb { display: block; height: 6px; background: #1a1420; border: 1px solid #000; }
.sb i { display: block; height: 100%; }
.sh-act { line-height: 1.15; }
.sw-wish { font-size: 14px; line-height: 1.15; margin-top: 2px; color: var(--muted); }
.sw-wish.ok { color: #a8ffb5; }
.city-full.side-on .city-over { left: 306px; }
.city-full.side-on .city-status { left: 306px; }
@media (max-width: 700px) {
  .side { width: auto; right: 8px; bottom: 60px; }
  .city-full.side-on .side-toggle { left: auto; right: 8px; top: auto; bottom: 64px; }
  .city-full.side-on .city-over, .city-full.side-on .city-status { left: 10px; }
}
/* свёрнутый баннер нашествия */
.inv-pill { pointer-events: auto; margin-left: 30px; font: inherit; font-size: 16px; color: #ffd0c8; cursor: pointer; padding: 4px 10px;
  background: linear-gradient(135deg, #3a0f0f, var(--card)); border: 2px solid var(--bad); box-shadow: 3px 3px 0 #000a; }
.inv-pill:hover { filter: brightness(1.2); }
/* кто копит на вещь с витрины */
.savers { margin: -2px 0 6px 44px; color: var(--sun); }
.grid .savers { margin: 4px 0 0; }
/* выбор здания на пустом участке */
.plot-list { display: flex; flex-direction: column; gap: 6px; }
.plot-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 6px; background: var(--card); border: 2px solid #0b080f; }
.plot-row img { width: 56px; image-rendering: pixelated; }
.plot-ic { font-size: 28px; text-align: center; }
@media (max-width: 600px) { .plot-row { grid-template-columns: 40px 1fr; } .plot-row img { width: 40px; } .plot-row .btn { grid-column: 1 / -1; } }
/* цена в кнопках постройки и улучшения: тёмная плашка, крупные цифры; чего не хватает — красным */
.cost-btn { display: inline-flex; align-items: center; gap: 10px; }
.cost { display: inline-flex; align-items: center; gap: 14px; padding: 3px 10px; background: #1a1006; border: 1px solid #0b080f;
  border-radius: 3px; box-shadow: inset 1px 1px 0 #ffffff14; }
.cost-i { display: inline-flex; align-items: center; gap: 6px; line-height: 1; }
.cost-i img, .cost-i svg, .cost-i .pi { width: 22px !important; height: 22px !important; vertical-align: middle; margin: 0; }
.cost-i b { font-family: "VT323", monospace; font-size: 24px; font-weight: 400; color: #ffd23f; font-variant-numeric: tabular-nums; }
.cost-i + .cost-i b { color: #ffa25a; }
.cost-i.lack b { color: #ff6a5a; text-decoration: underline dotted; text-underline-offset: 3px; }
.btn.cost-btn:disabled { opacity: .85; filter: saturate(.75); }
/* объявления */
.news.pinned { border-color: var(--sun); }
.news.fresh { box-shadow: inset 3px 0 0 var(--sun); }
.news-body { margin-top: 6px; line-height: 1.35; }
/* админка */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.tiles .atile { display: flex; flex-direction: column; gap: 2px; padding: 10px; background: var(--card); border: 2px solid #0b080f; }
.tiles .atile b { font-size: 22px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
textarea, select { font: inherit; background: var(--card2); color: var(--text); border: 2px solid #0b080f; padding: 6px; }
.big-btn { font-size: 18px; padding: 12px 18px; width: 100%; justify-content: center; display: inline-flex; gap: 8px; align-items: center; }
#w-name, #legacy input { width: 100%; box-sizing: border-box; margin: 4px 0; }
/* ===== экран входа ===== */
.auth-card { max-width: 440px; gap: 14px; padding: 26px 26px 18px; }
.auth-logo { justify-content: center; font-size: 30px; }
.auth-tag { text-align: center; color: var(--muted); margin: 0; line-height: 1.35; }
.auth-step { display: flex; flex-direction: column; gap: 10px; }
.auth-note { margin: 0; text-align: center; }
.big-btn { font-size: 19px; padding: 12px 18px; width: 100%; justify-content: center; display: inline-flex; gap: 10px; align-items: center; }
.btn-ico, .btn-ico .aic, .btn-ico img { width: 28px !important; height: 28px !important; }
.w-list { display: flex; flex-direction: column; gap: 6px; }
.w-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px; background: var(--card2); color: var(--text);
  border: 2px solid #0b080f; box-shadow: inset 0 0 0 1px var(--line); font: inherit; font-size: 18px; cursor: pointer; text-decoration: none; text-align: left; }
.w-item:hover { filter: brightness(1.2); box-shadow: inset 0 0 0 1px var(--sun); }
.w-item b { flex: 1; font-weight: 400; }
.w-ico, .w-ico img, .w-ico .aic { width: 30px; height: 30px; flex: none; border-radius: 6px; image-rendering: auto; }
.wiki-btn { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px 16px; margin-top: 4px; text-decoration: none;
  color: var(--sun); background: linear-gradient(180deg, #2c2238, #1c1526); border: 2px solid var(--sun); box-shadow: 3px 3px 0 #000a; }
.wiki-btn:hover { filter: brightness(1.2); }
.wiki-btn span { display: flex; flex-direction: column; line-height: 1.1; }
.wiki-btn b { font-family: "Tiny5", monospace; font-weight: 400; font-size: 20px; }
.wiki-btn small { color: var(--muted); font-size: 15px; }
.wiki-btn .btn-ico, .wiki-btn .btn-ico img { width: 34px !important; height: 34px !important; }
#legacy { text-align: center; }
#legacy[open] { text-align: left; }
.w-item b { font-family: "VT323", monospace; font-size: 21px; }
