/* Pixelify Sans (OFL), положен локально: страница не должна ждать внешние серверы */
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/pixelify-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/pixelify-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/pixelify-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/pixelify-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}


/* Запасные пиксельные шрифты с кириллицей: выбор живёт в примерочной.
   Handjet и Tiny5 под OFL, лежат локально рядом с Pixelify Sans. */

@font-face {
  font-family: 'Handjet';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/handjet-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Handjet';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/handjet-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Handjet';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/handjet-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Handjet';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/handjet-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Tiny5';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/tiny5-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Tiny5';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/tiny5-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Tiny5';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/tiny5-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Tiny5';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/tiny5-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* какой шрифт использовать, решает класс на body */
:root { --font: 'Tiny5', system-ui, sans-serif; }        /* выбран командой */
body.font-handjet { --font: 'Handjet', system-ui, sans-serif; }
body.font-tiny5   { --font: 'Tiny5', system-ui, sans-serif; }
body.font-pixelify { --font: 'Pixelify Sans', system-ui, sans-serif; }
body.font-system  { --font: system-ui, 'Segoe UI', sans-serif; }

/* Пиксельный офис — интерфейс.
   Никаких скруглений и градиентов: рамки ступеньками, тёплая палитра мира. */

:root {
  /* Палитра с присланного борда: тёмная нейтральная основа, тёплые песочные
     тона для текста и рамок, отдельные акценты под состояния. */
  --n900: #1F1F26;   /* фон экрана */
  --n800: #2B2B33;   /* панели */
  --n700: #3A3A46;   /* поля и вложенные блоки */
  --n600: #4B4B57;   /* границы неактивного */
  --n500: #9A9AA6;   /* приглушённый текст: тёмный вариант не читался */
  --n550: #6A6A74;   /* разделители и неактивные рамки */

  --p100: #F0E6D2;   /* основной текст */
  --p200: #E3C9A6;   /* вторичный текст */
  --p300: #C99B66;   /* рамки и обводка */
  --p400: #A67E4D;   /* тёмная рамка, тени */

  --a-blue:   #5C80C4;
  --a-cyan:   #2AA7E3;
  --a-green:  #6FBF8F;
  --a-amber:  #E2B35A;
  --a-red:    #E06C75;

  --bg:      var(--n900);
  --bg2:     var(--n800);
  --panel:   var(--n800);
  --panel2:  var(--n700);
  --line:    var(--p400);
  --text:    var(--p100);
  --dim:     var(--n500);
  --terra:   var(--a-red);
  --ochre:   var(--a-amber);
  --sage:    var(--a-green);
  --blue:    var(--a-blue);
  --red:     var(--a-red);

  --ochre-text: var(--a-amber);
  --terra-text: var(--a-red);
  --sage-text:  var(--a-green);
  --blue-text:  var(--a-cyan);

  --cream: var(--p100);
  --warm: var(--p200);
  --wall: var(--n700);
  --wood: var(--p300);
  --wood-dark: var(--p400);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  overflow: hidden;
  -webkit-font-smoothing: none;
}

button, input { font-family: inherit; font-size: inherit; color: inherit; }

.hidden { display: none !important; }

.screen { display: none; position: absolute; inset: 0; }
.screen.active { display: block; }

/* ---------- панели с пиксельной рамкой ---------- */

.panel, .panel-sm {
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow:
    0 0 0 2px var(--bg2),
    4px 4px 0 0 rgba(0,0,0,.45);
}
.panel { padding: 24px; }
.panel-sm { padding: 10px; }

/* ---------- вход и конструктор ---------- */

.intro-bg {                                 /* живой офис за формой входа */
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  background: #14121a;
}

.auth-wrap {
  position: relative;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: auto;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.07) 0 2px, transparent 2px 4px),
    radial-gradient(circle at 50% 45%, rgba(20,18,26,.12) 0%, rgba(14,12,18,.72) 78%);
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(36, 31, 46, .96);
}

.logo {
  margin: 0 0 6px;
  font-size: 46px; line-height: .88; font-weight: 700;
  letter-spacing: 4px;
  text-shadow: 4px 4px 0 #000, 0 0 22px rgba(232, 178, 104, .25);
}
.logo span { color: var(--ochre); }
.sub { margin: 0 0 20px; color: var(--dim); font-size: 14px; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 8px; cursor: pointer;
  background: var(--panel2); border: 2px solid var(--line); color: var(--dim);
}
.tab.active { color: var(--text); border-color: var(--ochre); background: #332b3a; }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; color: var(--dim); font-size: 14px; }
.form input {
  padding: 9px 10px;
  background: var(--bg2);
  border: 2px solid var(--line);
  color: var(--text);
  font-size: 16px;
}
.form input:focus { outline: none; border-color: var(--ochre); }

.btn {
  padding: 9px 14px; cursor: pointer;
  background: var(--panel2);
  border: 2px solid var(--line);
  color: var(--text);
  box-shadow: 3px 3px 0 0 rgba(0,0,0,.4);
}
.btn:hover { background: #342d3d; border-color: #574d66; }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 0 rgba(0,0,0,.4); }
.btn.primary { background: var(--terra); border-color: #d8794f; color: #fff2e6; }
.btn.primary:hover { background: #d06f45; }
.btn.tiny { padding: 6px 9px; font-size: 14px; }

.form label small { color: #7d7488; font-size: 12px; margin-top: -2px; }

.error { margin: 14px 0 0; font-size: 15px; }
.error:not(:empty) {                       /* ошибку должно быть видно сразу */
  color: #ffd9d0;
  background: #5a2422;
  border: 2px solid var(--red);
  padding: 9px 11px;
}

.ttl { margin: 0 0 18px; font-size: 26px; text-shadow: 2px 2px 0 #000; }

.creator { width: min(760px, 100%); }
.modal-card.wide { width: min(760px, 94vw); }
.creator-body { display: grid; grid-template-columns: 210px 1fr; gap: 22px; align-items: start; }

.creator-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.creator-tab {
  flex: 1; padding: 7px 6px; cursor: pointer; font-size: 14px;
  background: var(--panel2); border: 2px solid var(--line); color: var(--dim);
}
.creator-tab.active { color: var(--text); border-color: var(--ochre); background: #332b3a; }
.creator-rows { display: flex; flex-direction: column; gap: 12px; min-height: 232px; }

.preview-stage {
  display: grid; place-items: center;
  padding: 14px;
  background:
    repeating-conic-gradient(#252030 0% 25%, #2c2637 0% 50%) 0 0 / 16px 16px;
  border: 2px solid var(--line);
}
#char-preview, #char-preview2 { image-rendering: pixelated; }
.preview-controls { display: flex; gap: 6px; margin-top: 8px; }
.preview-controls .btn:nth-child(2) { flex: 1; }
.preview-name { margin-top: 10px; text-align: center; }
.preview-name strong { display: block; font-size: 18px; }
.preview-name span { color: var(--dim); font-size: 13px; }

.options { display: flex; flex-direction: column; gap: 10px; }
.opt { display: grid; grid-template-columns: 104px 1fr; align-items: center; gap: 10px; }
.opt > span { color: var(--dim); font-size: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.swatch {
  width: 28px; height: 28px; cursor: pointer;
  border: 2px solid var(--line);
}
.swatch.on { border-color: var(--ochre); box-shadow: 0 0 0 2px var(--bg2); }
.choice {
  padding: 5px 9px; cursor: pointer; font-size: 14px;
  background: var(--panel2); border: 2px solid var(--line); color: var(--dim);
}
.choice.on { color: var(--text); border-color: var(--ochre); background: #332b3a; }
.choice.locked {                            /* вещь из магазина, ещё не куплена */
  opacity: .5; cursor: not-allowed;
  border-style: dashed;
}

.creator-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- офис ---------- */

#world { display: block; width: 100%; height: 100%; image-rendering: pixelated; background: #0d0b12; }
#overlay {                                  /* подписи и реплики: экранный масштаб, без пикселизации */
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.act-btn {                                  /* появляется, когда рядом есть с чем повзаимодействовать */
  position: absolute; left: 50%; bottom: 200px; transform: translateX(-50%);
  padding: 10px 18px; cursor: pointer; font-size: 15px;
  background: var(--terra); color: #fff2e6;
  border: 2px solid #d8794f;
  box-shadow: 3px 3px 0 rgba(0,0,0,.45);
  animation: act-in .12s ease-out;
}
.act-btn:hover { background: #d06f45; }
.act-btn:active { transform: translateX(-50%) translateY(2px); }
@keyframes act-in { from { opacity: 0; transform: translateX(-50%) translateY(6px); } }

.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }

.hud-top-left { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.zone-badge { font-size: 13px; letter-spacing: .4px; padding: 6px 9px; }
.zone-badge span { color: var(--ochre-text); }
.hint { font-size: 12px; color: var(--dim); max-width: 230px; padding: 6px 9px; }
.hint:empty { display: none; }

.hud-top-right {
  position: absolute; top: 12px; right: 12px;
  width: 168px; max-height: 60vh;
}
.online-box { padding: 6px 8px; }
.online-title {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 0; padding: 0; font: inherit;
  font-size: 12px; color: var(--dim);
}
.online-title span { color: var(--ochre-text); }
.online-title::after { content: ' ▾'; color: var(--dim); }
.online-box.folded .online-title::after { content: ' ▸'; }
.online-box.folded .online-list { display: none; }
.online-list { margin-top: 6px !important; max-height: 40vh; overflow-y: auto; }
.online-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.online-list li { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.online-list canvas { image-rendering: pixelated; }
.online-list .who { flex: 1; min-width: 0; }
.online-list .who b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-list .who small { color: var(--dim); font-size: 10px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; flex: none; }
.dot.free  { background: var(--sage); }
.dot.busy  { background: var(--red); }
.dot.call  { background: var(--ochre); }
.dot.lunch { background: var(--terra); }
.dot.afk   { background: #6d6478; }

/* Низ экрана — одна панель: чат, полоса опыта и кнопки стоят в общей раме и
   на одной линии. Раньше полоса висела сама по себе посреди экрана, а кнопки
   жались к правому краю, и всё выглядело собранным из разных игр. */
.hud-bottom {
  position: absolute; left: 12px; bottom: 12px; right: 12px;
  display: flex; gap: 8px; align-items: center;
  padding: 6px; background: #2b2118; border: 3px solid #3d2b1f;
  box-shadow: inset 0 2px 0 #5a4130;
}
.chat-side { position: relative; display: flex; align-items: center; }
/* Окно чата всплывает над панелью, а не раздвигает её изнутри. */
.chat-side .chat { position: absolute; left: 0; bottom: 100%; margin-bottom: 8px; z-index: 12; }

.chat { width: min(320px, 40vw); padding: 6px; }
.chat-log {
  height: 74px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
  font-size: 13px; line-height: 1.3;
  margin-bottom: 6px;
}
.chat:focus-within .chat-log { height: 190px; }        /* пишем — видим историю */
.chat-log .msg b { color: var(--ochre-text); font-weight: 500; }
.chat-log .msg.me b { color: var(--sage-text); }
.chat-log .sys { color: var(--dim); font-size: 13px; font-style: italic; }
#chat-input { width: 100%; padding: 6px 8px; font-size: 13px; background: var(--bg2); border: 2px solid var(--line); }
#chat-input:focus { outline: none; border-color: var(--ochre); }

.toolbar {
  margin-left: auto; display: flex; align-items: center; gap: 3px;
  padding: 4px 6px; background: rgba(43,43,51,.94); border: 2px solid var(--line);
}
.ic {
  position: relative; min-width: 38px; height: 36px; padding: 0 3px;
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 2px solid transparent; color: var(--text);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.ic canvas { display: block; image-rendering: pixelated; }
.ic .badge, .ic .points {
  position: absolute; right: 1px; bottom: 0;
  padding: 0 2px; background: rgba(43,43,51,.94);
}
.ic #status-dot, .ic .dot { position: absolute; right: 3px; bottom: 3px; }
.dot-new {
  position: absolute; top: 2px; right: 2px; width: 7px; height: 7px;
  background: var(--terra); border: 1px solid var(--warm);
}
.ic:hover { border-color: var(--line); background: var(--panel2); }
.ic.on { border-color: var(--ochre); background: #332b3a; }
.ic .badge, .ic .points { font-size: 11px; color: var(--ochre-text); }
.ic-sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.build { font-size: 10px; color: #6d6478; margin-left: 4px; }

/* всплывающие статусы и эмоции: в обычном виде их не видно */
.pop {
  position: absolute; right: 12px; bottom: 96px; z-index: 12;
  padding: 6px; background: var(--panel); border: 2px solid var(--line);
}
.statuses, .emotes { display: flex; gap: 4px; flex-wrap: wrap; max-width: 240px; }
.st, .em {
  padding: 4px 7px; cursor: pointer; font-size: 13px;
  background: var(--panel2); border: 2px solid var(--line); color: var(--dim);
}
.st.on { color: var(--text); border-color: var(--ochre); background: #332b3a; }
.em { font-size: 16px; padding: 3px 6px; }
.em:hover, .st:hover { border-color: var(--ochre); }

/* ---------- модалки ---------- */

.modal {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(10,8,14,.72);
}
.modal-card { width: min(720px, 94vw); }
.modal-card.narrow { width: min(420px, 94vw); }
.modal-card header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-card h3 { margin: 0; font-size: 20px; }
.x { background: none; border: none; font-size: 26px; cursor: pointer; color: var(--dim); line-height: 1; }
.x:hover { color: var(--text); }

#board-canvas {
  width: 100%; display: block; cursor: crosshair;
  background: #f2ece0;
  border: 2px solid var(--line);
  image-rendering: pixelated;
  touch-action: none;
}
.board-tools { display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.colors { display: flex; gap: 5px; }
.size { font-size: 13px; color: var(--dim); display: flex; align-items: center; gap: 8px; }

.ttt-status { text-align: center; color: var(--dim); margin-bottom: 12px; font-size: 14px; min-height: 20px; }
.ttt-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ttt-cell {
  aspect-ratio: 1; cursor: pointer;
  background: var(--panel2); border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 44px; line-height: 1;
}
.ttt-cell:hover { border-color: var(--ochre); }
.ttt-cell.x { color: var(--terra); }
.ttt-cell.o { color: var(--blue); }
.ttt-actions { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }

.toast {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  padding: 9px 16px; z-index: 30;
  background: var(--panel); border: 2px solid var(--ochre);
  box-shadow: 3px 3px 0 rgba(0,0,0,.5);
  font-size: 14px;
}

/* полосы прокрутки в тон */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--line); border: 2px solid var(--bg2); }

@media (max-width: 760px) {
  .creator-body { grid-template-columns: 1fr; }
  .hud-top-right { display: none; }
  .hud-bottom { flex-wrap: wrap; }
  .chat { width: auto; }
  .chat-log { height: 108px; }
  .toolbar { margin-left: 0; }
}

.boot-note {                                /* видно, пока грузится скрипт */
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 8px 14px; font-size: 14px; color: var(--dim);
  background: var(--panel); border: 2px solid var(--line);
}
.boot-note.bad { color: #ffd9d0; border-color: var(--red); background: #5a2422; }

/* ---------- магазин ---------- */

.points { color: var(--ochre); }

.wallet { margin-left: auto; margin-right: 14px; font-size: 14px; color: var(--dim); }
.wallet b { color: var(--ochre); }

.shop-list {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  max-height: 58vh; overflow-y: auto;
}
.shop-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  background: var(--panel2); border: 2px solid var(--line);
}
.shop-item.owned { border-color: #4d6a4a; }
.shop-item.on { border-color: var(--ochre); background: #332b3a; }
.shop-item canvas { image-rendering: pixelated; flex: none; }
.shop-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.shop-info b { font-weight: 500; }
.shop-info small { color: var(--dim); font-size: 11px; line-height: 1.2; }
.shop-item .btn:disabled { opacity: .45; cursor: not-allowed; }

.shop-help { margin-top: 14px; font-size: 13px; color: var(--dim); }
.shop-help summary { cursor: pointer; }
.shop-help ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.6; }

.gain {                                     /* всплывающее «+N баллов» */
  position: absolute; right: 18px; bottom: 210px;
  padding: 6px 12px; z-index: 25;
  background: var(--panel); border: 2px solid var(--ochre); color: var(--ochre);
  font-size: 14px;
  animation: gain-up 2.4s ease-out forwards;
}
@keyframes gain-up {
  0% { opacity: 0; transform: translateY(8px); }
  12% { opacity: 1; transform: translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

.blocked {                                  /* офис открыт в другой вкладке */
  position: absolute; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(12, 10, 16, .88);
  text-align: center; padding: 24px;
}
.blocked b { font-size: 22px; }
.blocked span { color: var(--dim); font-size: 14px; }

.stale {                                    /* страница устарела: скрипт из кэша браузера */
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 35;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; font-size: 13px;
  background: var(--panel); border: 2px solid var(--ochre);
  box-shadow: 3px 3px 0 rgba(0,0,0,.45);
}

.build { align-self: center; font-size: 11px; color: #6f6578; }

/* ---------- кабинеты ---------- */

.room-panel {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  max-width: min(520px, 92vw);
}
.room-panel > b { font-size: 15px; }
.room-actions { display: flex; gap: 6px; }
.room-hint { font-size: 12px; color: var(--dim); text-align: center; }
.room-palette {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  max-height: 30vh; overflow-y: auto;
}
.decor-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px; cursor: pointer; width: 78px;
  background: var(--panel2); border: 2px solid var(--line); color: var(--dim);
  font-size: 10px; line-height: 1.1;
}
.decor-btn canvas { image-rendering: pixelated; }
.decor-btn.on { border-color: var(--ochre); color: var(--text); background: #332b3a; }

.staff-list {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  max-height: 60vh; overflow-y: auto;
}
.staff-card {
  display: flex; align-items: center; gap: 10px; padding: 8px;
  background: var(--panel2); border: 2px solid var(--line);
}
.staff-card.me { border-color: var(--ochre); }
.staff-card canvas { image-rendering: pixelated; flex: none; }
.staff-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.staff-info b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.staff-info small { color: var(--dim); font-size: 11px; }
.staff-loading { color: var(--dim); font-size: 13px; padding: 8px; }

/* ---------- задания и достижения ---------- */

.badge {
  display: inline-block; min-width: 16px; padding: 0 4px; margin-left: 4px;
  background: var(--terra); color: #fff2e6; font-size: 12px; text-align: center;
}
.badge.empty { background: #4d6a4a; }

.quests-list { display: flex; flex-direction: column; gap: 6px; }
.quest {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--panel2); border: 2px solid var(--line);
}
.quest.done { border-color: #4d6a4a; opacity: .75; }
.quest > b { color: var(--ochre); width: 14px; }
.quest.done > b { color: #7fa872; }
.quest-text { flex: 1; display: flex; flex-direction: column; }
.quest-text small { color: var(--dim); font-size: 11px; }
.quest-prize { color: var(--ochre); font-size: 13px; }

.quests-bonus {
  margin-top: 10px; padding: 8px 12px; font-size: 13px; color: var(--dim);
  border: 2px dashed var(--line);
}
.quests-bonus.done { border-style: solid; border-color: #4d6a4a; color: #a8c49e; }

.quests-title { margin: 18px 0 8px; font-size: 16px; }
.ach-list {
  display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  max-height: 34vh; overflow-y: auto;
}
.ach {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px;
  background: var(--panel2); border: 2px solid var(--line); opacity: .5;
}
.ach.got { opacity: 1; border-color: var(--ochre); }
.ach-icon { font-size: 20px; }
.ach b { display: block; font-weight: 500; font-size: 13px; }
.ach small { color: var(--dim); font-size: 11px; }

.reward {
  position: absolute; right: 18px; top: 90px; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--panel); border: 2px solid var(--ochre);
  box-shadow: 4px 4px 0 rgba(0,0,0,.5);
  animation: reward-in .25s ease-out;
}
.reward-icon { font-size: 26px; }
.reward small { display: block; color: var(--dim); font-size: 11px; }
.reward b { font-size: 15px; }
.reward-points { color: var(--ochre); font-size: 14px; }
@keyframes reward-in { from { opacity: 0; transform: translateX(20px); } }

/* ---------- разговор с гостем ---------- */

.npc-line {
  padding: 12px 14px; margin-bottom: 10px; font-size: 15px; line-height: 1.4;
  background: #f2ece0; color: #2a2533;
  border: 2px solid var(--line);
}
.npc-answer { min-height: 20px; margin-bottom: 12px; font-size: 14px; color: var(--ochre-text); }
.npc-replies { display: flex; flex-direction: column; gap: 6px; }
.npc-replies .btn { text-align: left; }
.npc-gifts { display: flex; flex-direction: column; gap: 8px; }
.npc-gifts-list { display: flex; flex-wrap: wrap; gap: 6px; }
.npc-actions { margin-top: 12px; display: flex; justify-content: flex-end; }

/* ---------- миникарта ---------- */

.hud-top-right { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.online-box { min-width: 176px; }

.minimap-box { position: relative; padding: 4px; cursor: pointer; pointer-events: auto; }
.minimap-box canvas {
  display: block; width: 152px; height: 152px;
  image-rendering: pixelated; background: var(--cream);
}
.minimap-place { color: var(--wood-dark);
  position: absolute; left: 4px; right: 4px; bottom: 4px;
  padding: 2px 4px; font-size: 10px; text-align: center;
  background: rgba(43,43,51,.92);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.modal-card.wide { max-width: 960px; width: 94vw; }
.map-stage { background: #1a1722; border: 2px solid var(--line); }
.map-stage canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; cursor: crosshair; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.map-legend .btn i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; vertical-align: middle; }
.map-actions { margin-top: 10px; display: flex; justify-content: flex-end; }

@media (max-width: 720px) {
  .minimap-box canvas { width: 116px; height: 116px; }
  .online-box { min-width: 116px; }
}

/* ---------- читальный клуб ---------- */

.read-form { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.read-form input[type="text"], .read-form input:not([type]) { flex: 1 1 180px; }
.read-form input { padding: 7px 9px; border: 2px solid var(--line); background: #f2ece0; color: #2a2533; font: inherit; }
#reading-chapter { width: 92px; flex: 0 0 auto; }

.read-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.read-cols h4 { margin: 0 0 6px; font-size: 13px; color: var(--ochre-text); }
.read-cols section { min-width: 0; }
.read-shelf, .read-club, .read-matches { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.read-matches { max-height: 120px; margin-bottom: 4px; }

.read-row { display: flex; align-items: center; gap: 6px; padding: 5px 7px; background: rgba(255,255,255,.04); border: 2px solid transparent; }
.read-row.on { border-color: var(--ochre); }
.read-pick { flex: 1; text-align: left; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; }
.read-del { background: none; border: 0; color: var(--dim); cursor: pointer; font-size: 16px; line-height: 1; }
.read-del:hover { color: #e0616a; }
.read-link { color: var(--blue); font-size: 12px; text-decoration: none; }
.read-link:hover { text-decoration: underline; }
.read-empty { padding: 8px; font-size: 13px; color: var(--dim); }

.read-card { padding: 8px; background: rgba(255,255,255,.04); display: flex; flex-direction: column; gap: 6px; }
.read-card-head { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.read-readers { display: flex; flex-wrap: wrap; gap: 4px; }
.read-chip { padding: 2px 6px; font-size: 12px; background: rgba(0,0,0,.25); color: #cfc4d8; }
.read-chip.now { background: var(--ochre); color: #24202c; }
.read-match { font-size: 13px; padding: 4px 6px; }
.read-match span { color: var(--dim); }

@media (max-width: 720px) {
  .read-cols { grid-template-columns: 1fr; }
}

/* ---------- экран: развороты, хоткеи, чистый вид ---------- */

kbd {
  display: inline-block; margin-left: 4px; padding: 0 4px;
  font: 600 10px/16px var(--font);
  color: var(--text); background: rgba(0,0,0,.35); border: 1px solid rgba(201,155,102,.35);
}

.modal-card header .expand {
  background: none; border: 0; color: var(--dim); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 2px 6px;
}
.modal-card header .expand:hover { color: var(--ochre); }

.modal-card.full {
  max-width: none; width: 96vw; height: 92vh;
  display: flex; flex-direction: column;
}
.modal-card.full > *:not(header) { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal-card.full .read-cols { grid-template-columns: 1fr 1fr; }
.modal-card.full .read-shelf, .modal-card.full .read-club { max-height: none; }
.modal-card.full .map-stage canvas { max-height: 76vh; width: auto; margin: 0 auto; }

body.hud-off .hud-bottom, body.hud-off .hud-top-right,
body.hud-off .hud-top-left .hint { display: none; }

#hud-restore {
  display: none; position: fixed; right: 12px; bottom: 12px; z-index: 30;
  padding: 6px 10px; font: 500 12px var(--font);
  background: rgba(43,43,51,.96); color: var(--ochre);
  border: 2px solid var(--line); cursor: pointer;
}
body.hud-off #hud-restore { display: block; }
body.is-fullscreen .hud { padding: 10px; }

.reading-line { color: #9cc4dc; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }


/* ---------- компоненты с борда ---------- */

/* Карточка: тёмная панель, тёплая рамка, при наведении рамка светлеет */
.panel, .panel-sm, .modal-card {
  background: var(--n800);
  border: 2px solid var(--p400);
  box-shadow: 0 2px 0 rgba(0,0,0,.45);
}
.panel-sm:hover, .modal-card:hover { border-color: var(--p300); }

/* Кнопки: три состояния, как на борде */
.btn, .ic, .opt button, .tabs button {
  background: var(--n700);
  border: 2px solid var(--p400);
  color: var(--p100);
}
.btn:hover, .ic:hover, .opt button:hover, .tabs button:hover {
  background: #45454F; border-color: var(--p300);
}
.btn:active, .ic:active { background: #23232B; border-color: var(--p400); }
.btn.primary { background: var(--p400); border-color: var(--p300); color: #1F1F26; }
.btn.primary:hover { background: var(--p300); }
.btn:disabled, .ic:disabled { background: var(--n800); border-color: var(--n600); color: var(--n500); }
.btn.tiny.on, .ic.on, .tabs button.on { border-color: var(--a-amber); background: #45454F; }

/* Поля ввода: тёмное поле, охристая рамка в фокусе */
input, textarea, select {
  background: var(--n900); border: 2px solid var(--n600); color: var(--p100);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--a-amber); }

/* Слот инвентаря: пустой, наведённый, закрытый */
.slot {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--n900); border: 2px solid var(--n600);
}
.slot:hover { border-color: var(--a-amber); background: var(--n700); }
.slot.locked { border-style: dashed; color: var(--n550); }


/* ---------- полоса иконок: одинаковые ячейки, как в хотбаре с борда ---------- */

.toolbar {
  gap: 4px; padding: 0; flex-wrap: wrap;            /* на узком экране переносим, а не режем */
  background: none; border: 0; box-shadow: none;    /* рама теперь общая, у всей панели */
}
/* Кнопка панели: светлая плашка в тёмной раме. На тёмном фоне иконки
   пропадали — половина набора сама тёмная, контур сливался с кнопкой. */
.toolbar .ic {
  width: 72px; height: 72px; min-width: 72px; padding: 0;
  display: grid; place-items: center;
  border: 3px solid #3d2b1f;
  box-shadow: inset 0 3px 0 #f5ecd6, inset 0 -3px 0 #c4ae86;
  background: #e6d7b8;
}
.toolbar .ic:hover { background: #f2e6c9; }
.toolbar .ic.on { background: #f2d191; box-shadow: inset 0 3px 0 #f7e4b4, inset 0 -3px 0 #c99640; }
.toolbar .ic canvas, .toolbar .ic img.ui-icon {
  width: 64px; height: 64px; image-rendering: pixelated;   /* ровно 2× от сетки 32 */
}
.toolbar .ic .badge, .toolbar .ic .points {
  position: absolute; right: -2px; bottom: -3px;
  padding: 0 3px; font-size: 10px; line-height: 12px;
  background: var(--n900); border: 1px solid var(--p400); color: var(--a-amber);
}
.toolbar .ic .dot { position: absolute; right: 2px; top: 2px; width: 6px; height: 6px; }
.ic-sep { width: 2px; height: 22px; background: var(--n600); margin: 0 2px; }
.chat-side .ic {
  width: 72px; height: 72px; min-width: 72px;
  border: 3px solid #3d2b1f;
  box-shadow: inset 0 3px 0 #f5ecd6, inset 0 -3px 0 #c4ae86;
  background: #e6d7b8;
}
.chat-side .ic canvas, .chat-side .ic img.ui-icon { width: 64px; height: 64px; image-rendering: pixelated; }
.chat-side .ic:hover { background: #f2e6c9; }

.sound-mix { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.sound-mix .st { text-align: left; }

/* ---------- панель администратора ---------- */

.admin-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.admin-row { display: flex; align-items: center; gap: 8px; padding: 7px 9px; background: var(--n900); border: 2px solid var(--n600); }
.admin-who { flex: 1; min-width: 0; }
.admin-who small { display: block; color: var(--n500); font-size: 11px; }
.admin-who .tag { font-size: 10px; color: var(--a-amber); border: 1px solid var(--p400); padding: 0 4px; }
.admin-who .online { color: var(--a-green); }
.btn.danger { border-color: var(--a-red); color: var(--a-red); }
.btn.danger:hover { background: #3A2A2E; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- рюкзак и профиль ---------- */

.bag-list { display: flex; flex-direction: column; gap: 6px; max-height: 58vh; overflow-y: auto; }
.bag-item { display: flex; align-items: center; gap: 10px; padding: 7px 9px;
            background: var(--n900); border: 2px solid var(--n600); }
.bag-item img { width: 32px; height: 32px; image-rendering: pixelated; }
.bag-item b { min-width: 150px; }
.bag-item small { flex: 1; color: var(--n500); font-size: 11px; }

.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.profile-level { width: 54px; height: 54px; display: grid; place-items: center;
                 font-size: 22px; color: var(--a-amber);
                 background: var(--n900); border: 2px solid var(--p400); }
.xp-bar { margin-top: 6px; height: 10px; background: var(--n900); border: 2px solid var(--n600); }
.xp-bar span { display: block; height: 100%; background: var(--a-amber); }
#profile-body h4 { margin: 14px 0 6px; font-size: 13px; color: var(--a-amber); font-weight: 500; }
.profile-sources { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.profile-sources .src { padding: 5px 7px; background: var(--n900); font-size: 12px; }
.profile-sources .src b { color: var(--a-green); margin-right: 4px; }
.profile-sources small { display: block; color: var(--n500); font-size: 10px; }
.profile-rewards { display: flex; flex-direction: column; gap: 3px; }
.profile-rewards .rw { padding: 5px 7px; background: var(--n900); font-size: 12px; color: var(--n500); }
.profile-rewards .rw.done { color: var(--p100); border-left: 3px solid var(--a-green); }
.profile-rewards .rw b { display: inline-block; min-width: 22px; color: var(--a-amber); }

/* Подсказка теперь рисуется у самого предмета, кнопка нужна лишь без клавиатуры */
.act-btn { display: none; }
@media (max-width: 720px) {
  .act-btn { display: block; }
}

/* полоса близости с гостем: видно, сколько до следующего уровня */
.npc-bond { margin: 0 0 10px; }
.npc-bond-bar {
  height: 8px; border: 2px solid var(--ink); border-radius: 2px;
  background: rgba(0, 0, 0, .25); overflow: hidden;
}
.npc-bond-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, #e0a077, #e2b35a);
  transition: width .25s ease;
}
.npc-bond small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

/* полоса опыта под экраном — по образцу золотого RPG-интерфейса */
/* Полоса опыта живёт в той же раме, что панель кнопок: раньше она была вдвое
   ниже кнопок и читалась как деталь из другой игры. */
.xp-strip {
  flex: 1; min-width: 120px;
  display: flex; align-items: center; gap: 6px;
  pointer-events: none;
}
/* Значок уровня: деревянная табличка в палитре офиса. Золотая рамка из чужого
   образца сюда не подходит — офис тёплый и деревянный. */
.xp-strip b {
  display: grid; place-items: center; min-width: 60px; height: 60px; padding: 0 8px;
  color: #f0e6d2; font-size: 24px; line-height: 1;
  background: #a5703f;
  border: 3px solid #3d2b1f;
  box-shadow: inset 0 3px 0 #c28d55, inset 0 -3px 0 #7d4f30;
}
.xp-bar {
  position: relative; flex: 1; height: 60px;
  display: flex; align-items: center;
  background: #1f1810; border: 3px solid #3d2b1f;
  box-shadow: inset 0 3px 0 #5a4130;
}
.xp-bar i {
  display: block; height: 26px; width: 0; margin-left: 8px;
  background: #6a9b57;
  box-shadow: inset 0 3px 0 #8bbb74, inset 0 -3px 0 #4f7c44;
  transition: width .3s steps(12, end);
}
.xp-strip small {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  color: #f0e6d2; font-size: 13px; letter-spacing: .5px;
  text-shadow: 1px 1px 0 #2b2118;
}
.xp-strip.level-up { animation: xp-pop .5s steps(4, end); }
@keyframes xp-pop { 0% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.07); } 100% { transform: translateX(-50%) scale(1); } }

/* достижения в профиле */
.profile-achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-bottom: 10px; }
.ach { border: 2px solid var(--ink); border-radius: 3px; padding: 6px 8px; background: rgba(0,0,0,.2); opacity: .55; }
.ach.done { opacity: 1; background: rgba(127, 174, 94, .18); }
.ach b { display: block; font-size: 12px; }
.ach small { display: block; color: var(--muted); font-size: 11px; }
.ach i { display: block; margin-top: 3px; font-size: 11px; color: #A9C98A; font-style: normal; }

/* действия в профиле: редактор персонажа переехал сюда из панели */
.profile-actions { margin: 8px 0 4px; }

/* ---------- личные даты ---------- */
.dates-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.dates-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.dates-form input {
  padding: 7px 8px; font: inherit; font-size: 14px;
  background: var(--bg2); border: 2px solid var(--line); color: var(--text);
}
.dates-form input:focus { outline: none; border-color: var(--ochre); }
.dates-actions { display: flex; gap: 8px; align-items: center; }
