:root {
  --night: #1b1530;     /* небо над городом */
  --night-2: #261d43;   /* поверхность панелей */
  --night-3: #33285a;   /* приподнятое */
  --sodium: #ffb547;    /* уличный фонарь — главный акцент */
  --neon: #ff4fa3;      /* неон — второй акцент, только для «живого» */
  --ink: #f3eefe;
  --mute: #a79cc4;
  --line: #3f3468;
  --ok: #38d39f;
  --bad: #ff5d73;
  --r-s: 10px; --r-m: 16px; --r-l: 26px;
  --display: "Unbounded", system-ui, sans-serif;
  --body: "Golos Text", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--ink); font: 15px/1.45 var(--body); -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--sodium); outline-offset: 2px; }
#app { height: 100%; max-width: 1180px; margin: 0 auto; }
.screen { height: 100%; }
[hidden] { display: none !important; }
.fine { color: var(--mute); font-size: 13px; }
.pad { padding: 0 16px; }

/* ---------- вход ---------- */
#login { display: grid; grid-template-rows: minmax(260px, 55vh) auto; }
.demo { width: 100%; height: 100%; display: block; }
.login-copy { padding: 0 24px 40px; max-width: 520px; margin: 0 auto; text-align: center; }
.login-copy h1 { font: 800 clamp(26px, 6vw, 40px)/1.1 var(--display); letter-spacing: -.01em; margin: 0 0 14px; }
.login-copy p { color: var(--mute); margin: 0 0 22px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 999px; padding: 14px 26px; font-weight: 700; text-decoration: none; transition: transform .1s; }
.btn:active { transform: scale(.97); }
.btn.twitch { background: #9146ff; color: #fff; }
.btn.main { background: var(--sodium); color: #2b1d00; }
.btn.ghost { background: var(--night-3); color: var(--ink); }
.btn[disabled] { opacity: .45; cursor: default; }

/* ---------- шапка ---------- */
#main { display: grid; grid-template-rows: auto auto 1fr auto; grid-template-columns: minmax(0, 1fr); height: 100%; }
#main > *, #v-home > * { min-width: 0; }
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px 10px; padding-top: max(12px, env(safe-area-inset-top)); }
.ava { width: 44px; height: 44px; border-radius: 14px; background: var(--night-3); object-fit: cover; flex: none; }
.who { flex: 1; min-width: 0; }
.who-name { font: 700 16px/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.district { font-size: 12.5px; color: var(--mute); display: flex; justify-content: space-between; gap: 8px; margin-top: 2px; white-space: nowrap; }
.district span { overflow: hidden; text-overflow: ellipsis; }
.dist-next { font-size: 11.5px; color: var(--mute); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog { height: 5px; border-radius: 3px; background: var(--night-3); margin-top: 5px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--sodium); border-radius: 3px; transition: width .6s; }
.coins { display: flex; align-items: baseline; gap: 3px; background: var(--night-2); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; }
.coins b { font: 800 18px/1 var(--display); color: var(--sodium); }
.coins span { color: var(--sodium); font-weight: 700; }
.coins.bump b { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.25); } }

.live { margin: 0 16px 8px; padding: 9px 12px 9px 14px; border-radius: var(--r-m); background: linear-gradient(90deg, rgba(255,79,163,.18), rgba(255,79,163,.05)); border: 1px solid rgba(255,79,163,.4); display: flex; align-items: center; gap: 10px; font-size: 14px; }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--neon); box-shadow: 0 0 10px var(--neon); flex: none; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.live .grow { flex: 1; }
.live button { border: 0; background: var(--neon); color: #fff; border-radius: 999px; padding: 6px 14px; font-weight: 700; }

/* ---------- вкладки ---------- */
.view { overflow-y: auto; min-height: 0; }
#v-home { display: grid; grid-template-rows: 1fr auto; grid-template-columns: minmax(0, 1fr); overflow: hidden; }
.stage { position: relative; min-height: 0; background: radial-gradient(ellipse at 50% 70%, #3b2c63 0%, var(--night) 70%); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage.small { height: 46vh; min-height: 280px; border-radius: var(--r-l); margin: 0 16px; overflow: hidden; }
.saved { position: absolute; top: 10px; right: 14px; font-size: 12.5px; color: var(--mute); transition: opacity .4s; opacity: 0; }
.saved.on { opacity: 1; }

.selbar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 4px; align-items: center; background: rgba(38,29,67,.94); border: 1px solid var(--line); border-radius: 999px; padding: 5px; backdrop-filter: blur(6px); max-width: calc(100% - 20px); }
.selbar .nm { padding: 0 10px 0 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selbar button { border: 0; background: var(--night-3); border-radius: 999px; padding: 7px 12px; white-space: nowrap; }
.selbar button.danger { background: transparent; color: var(--bad); }
.palette { position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%); display: flex; gap: 6px; background: rgba(38,29,67,.96); border: 1px solid var(--line); border-radius: var(--r-m); padding: 8px; flex-wrap: wrap; justify-content: center; max-width: 290px; }
.palette button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,.2); }
.palette button.on { border-color: #fff; }

.tray { background: var(--night-2); border-top: 1px solid var(--line); border-radius: var(--r-l) var(--r-l) 0 0; padding: 10px 0 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 13px; color: var(--mute); font-size: 13.5px; }
.chips button.on { background: var(--ink); color: var(--night); border-color: var(--ink); font-weight: 600; }
.chips.sticky { position: sticky; top: 0; background: var(--night); padding-top: 4px; z-index: 2; }
.tray-items { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 4px; min-height: 104px; scrollbar-width: thin; }
.slot { flex: none; width: 86px; border: 0; background: var(--night-3); border-radius: var(--r-m); padding: 6px 4px 7px; display: grid; justify-items: center; gap: 2px; position: relative; }
.slot canvas { width: 62px; height: 62px; }
.slot small { font-size: 11.5px; line-height: 1.15; text-align: center; color: var(--ink); max-width: 80px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.slot .n { position: absolute; top: 5px; right: 7px; font: 700 11px/1 var(--display); color: var(--sodium); }
.slot.used { opacity: .4; }
.slot.on { outline: 2px solid var(--sodium); }
.tray-empty { color: var(--mute); padding: 18px 4px; font-size: 14px; }

/* ---------- магазин ---------- */
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 4px 16px 20px; }
.card { background: var(--night-2); border-radius: var(--r-m); padding: 12px; display: grid; gap: 6px; align-content: start; position: relative; }
.card canvas { width: 96px; height: 96px; justify-self: center; }
.card h4 { margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.25; }
.card .desc { font-size: 12.5px; color: var(--mute); }
.card .price { font: 700 15px var(--display); color: var(--sodium); }
.card .lock { font-size: 12.5px; color: var(--mute); }
.card .have { position: absolute; top: 10px; right: 12px; font-size: 12px; color: var(--ok); font-weight: 600; }
.card button { border: 0; border-radius: var(--r-s); padding: 8px; background: var(--sodium); color: #2b1d00; font-weight: 700; }
.card button[disabled] { background: var(--night-3); color: var(--mute); cursor: default; }
.card.locked canvas { filter: grayscale(.8) brightness(.7); }
.shop-note { grid-column: 1 / -1; color: var(--mute); font-size: 13.5px; margin: 2px 0 4px; }

/* ---------- гости ---------- */
.guests-tools { display: flex; gap: 8px; padding: 4px 16px 10px; }
.guests-tools input, .guests-tools select { background: var(--night-2); border: 1px solid var(--line); border-radius: var(--r-s); padding: 9px 12px; min-width: 0; }
.guests-tools input { flex: 1; }
.star { margin: 4px 16px 12px; padding: 14px 16px; border-radius: var(--r-l); background: linear-gradient(120deg, #3a2a68, #2a1f4c); border: 1px solid #574a8c; display: flex; gap: 12px; align-items: center; cursor: pointer; }
.star .t { font: 700 15px/1.25 var(--display); }
.star .s { font-size: 13px; color: var(--mute); }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; }
.row:hover { background: rgba(255,255,255,.03); }
.row img, .row .ph { width: 42px; height: 42px; border-radius: 13px; background: var(--night-3); object-fit: cover; flex: none; }
.row .nm { font-weight: 600; }
.row .sub { font-size: 13px; color: var(--mute); }
.row .grow { flex: 1; min-width: 0; }
.row .likes { font-weight: 700; color: var(--neon); white-space: nowrap; }
.back { border: 0; background: none; color: var(--mute); padding: 6px 16px 10px; }
.visit-head { display: flex; align-items: center; gap: 12px; padding: 0 16px 12px; }
.visit-head img { width: 48px; height: 48px; border-radius: 14px; background: var(--night-3); object-fit: cover; }
.visit-head .grow { flex: 1; min-width: 0; }
.visit-head h2 { font: 700 18px/1.2 var(--display); margin: 0; }
.like { border: 1px solid rgba(255,79,163,.5); background: transparent; color: var(--neon); border-radius: 999px; padding: 8px 14px; font-weight: 700; }
.like.on { background: var(--neon); color: #fff; }
.gb { padding: 16px 16px 24px; max-width: 640px; }
.gb h3 { font: 700 15px var(--display); margin: 0 0 10px; }
.gb form { display: flex; gap: 8px; margin-bottom: 14px; }
.gb input { flex: 1; min-width: 0; background: var(--night-2); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; }
.gb form button { border: 0; background: var(--sodium); color: #2b1d00; font-weight: 700; border-radius: var(--r-s); padding: 0 14px; }
.note { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.note img { width: 30px; height: 30px; border-radius: 9px; background: var(--night-3); flex: none; }
.note .t { font-size: 14.5px; }
.note .m { font-size: 12px; color: var(--mute); }
.note .del { margin-left: auto; border: 0; background: none; color: var(--mute); font-size: 18px; line-height: 1; padding: 0 4px; align-self: start; }

/* ---------- профиль ---------- */
.me { padding: 4px 16px 28px; display: grid; gap: 22px; max-width: 760px; }
.me h3 { font: 700 15px var(--display); margin: 0 0 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-radius: var(--r-m); overflow: hidden; }
.stats div { background: var(--night-2); padding: 12px; }
.stats b { display: block; font: 700 19px/1.1 var(--display); }
.stats span { font-size: 12.5px; color: var(--mute); }
.code { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; background: var(--night-2); border-radius: var(--r-m); padding: 14px 16px; }
.code b { font: 800 24px var(--display); letter-spacing: .06em; color: var(--sodium); }
.code p { margin: 0; font-size: 13.5px; color: var(--mute); flex-basis: 100%; order: 3; }
.code button { border: 0; background: var(--night-3); border-radius: 999px; padding: 8px 14px; }
.ladder { display: grid; gap: 6px; }
.step { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-s); background: var(--night-2); }
.step .e { font-size: 22px; }
.step .grow { flex: 1; }
.step .x { font-size: 12.5px; color: var(--mute); }
.step.done { opacity: .55; }
.step.cur { outline: 2px solid var(--sodium); opacity: 1; }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.ach { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--r-s); background: var(--night-2); align-items: center; }
.ach .i { font-size: 22px; filter: grayscale(1) opacity(.4); }
.ach.got .i { filter: none; }
.ach .t { font-weight: 600; font-size: 14px; }
.ach .d { font-size: 12.5px; color: var(--mute); }
.ach .rw { margin-left: auto; font: 700 12px var(--display); color: var(--sodium); white-space: nowrap; }
.how { color: var(--mute); font-size: 14px; margin: 0; padding-left: 18px; }
.how li { margin: 3px 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--night-2); border-radius: var(--r-m); padding: 12px 16px; }
.toggle input { width: 44px; height: 24px; accent-color: var(--sodium); }

/* ---------- город ---------- */
.city-wrap { position: relative; margin: 4px 16px 10px; border-radius: var(--r-l); overflow: hidden; aspect-ratio: 16/9; max-height: 72vh; background: #000; }
/* город рисуется в том же размере, что на стриме (1920×1080), и уменьшается целиком — как картинка */
.city-wrap iframe { position: absolute; top: 0; left: 0; width: 1920px; height: 1080px; border: 0; transform-origin: 0 0; pointer-events: none; }
.city-wrap:fullscreen { border-radius: 0; aspect-ratio: auto; }
.city-full { position: absolute; right: 10px; bottom: 10px; border: 0; border-radius: 999px; padding: 7px 14px; background: rgba(27,21,48,.85); color: var(--ink); font-size: 13px; }

/* ---------- нижнее меню ---------- */
.dock { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--night); border-top: 1px solid var(--line); padding: 6px 4px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.dock button { border: 0; background: none; color: var(--mute); display: grid; justify-items: center; gap: 1px; font-size: 11.5px; padding: 4px 0; border-radius: var(--r-s); }
.dock button span { font-size: 21px; line-height: 1.2; filter: grayscale(.6); }
.dock button.on { color: var(--ink); }
.dock button.on span { filter: none; }

.toast { position: fixed; left: 50%; top: max(14px, env(safe-area-inset-top)); transform: translate(-50%, -20px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--night); padding: 10px 16px; border-radius: 999px; font-weight: 600; transition: transform .25s, opacity .25s; z-index: 50; max-width: calc(100% - 32px); text-align: center; font-size: 14px; }
.toast.on { transform: translate(-50%, 0); opacity: 1; }
.toast.bad { background: var(--bad); color: #fff; }

/* широкий экран: инвентарь справа от комнаты */
@media (min-width: 900px) {
  #v-home { grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: 1fr; gap: 0; }
  .tray { border-radius: var(--r-l) 0 0 0; border-top: 0; border-left: 1px solid var(--line); display: grid; grid-template-rows: auto 1fr; padding-top: 14px; }
  .chips { flex-wrap: wrap; overflow: visible; }
  .tray-items { flex-wrap: wrap; overflow-y: auto; align-content: start; }
  .dock { max-width: 560px; margin: 0 auto 10px; border: 1px solid var(--line); border-radius: 999px; width: 100%; }
  .stage.small { height: 52vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
