/* Общие переменные, темы и элементы, одинаковые на всех страницах. */

/* Светлая тема: холодный «утренний» фон, фарфоровые панели, бирюзовый акцент. */
:root,
:root[data-theme="light"] {
  --page-bg: #e6eef6;
  --page-wash:
    radial-gradient(900px 480px at 8% -8%, rgba(18, 140, 132, .16), transparent 58%),
    radial-gradient(720px 420px at 96% 4%, rgba(74, 120, 190, .14), transparent 52%),
    radial-gradient(560px 320px at 50% 110%, rgba(18, 140, 132, .08), transparent 60%),
    linear-gradient(165deg, #f3f7fb 0%, #e6eef6 42%, #e2eaf3 100%);
  --surface: #ffffff;
  --surface-soft: #f1f6fa;
  --field-bg: rgba(255, 255, 255, .78);
  --field-bg-focus: #ffffff;
  --track: #d4dee9;

  --ink: #162033;
  --ink-soft: #5c677a;
  --accent: #0c6f6c;
  --accent-soft: #18948f;
  --line: #c5d2e0;
  --good: #1f8a4f;
  --danger: #c0392b;

  --topbar-bg: #132032;
  --topbar-fg: #f2f6fb;
  --topbar-line: #243449;
  --topbar-muted: #9aabbe;

  --radius: 8px;
  --shadow:
    0 1px 2px rgba(22, 32, 51, .05),
    0 6px 18px rgba(22, 32, 51, .07);
  --topbar-shadow: 0 2px 12px rgba(19, 32, 50, .28);
}

/* Тёмная тема: выбрана вручную */
:root[data-theme="dark"] {
  --page-bg: #14171a;
  --page-wash:
    radial-gradient(700px 380px at 12% -10%, rgba(224, 138, 114, .08), transparent 55%),
    radial-gradient(600px 360px at 100% 0%, rgba(86, 168, 119, .06), transparent 50%);
  --surface: #22262b;
  --surface-soft: #1b1f23;
  --field-bg: rgba(255, 255, 255, .05);
  --field-bg-focus: rgba(255, 255, 255, .11);
  --track: #2e343a;

  --ink: #e6e1d8;
  --ink-soft: #98a0aa;
  --accent: #e08a72;
  --accent-soft: #f0a693;
  --line: #39414a;
  --good: #56a877;
  --danger: #e0645a;

  --topbar-bg: #0f1215;
  --topbar-fg: #e6e1d8;
  --topbar-line: #2e343a;
  --topbar-muted: #8c949e;

  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .45);
  --topbar-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}

/* Системная тема: та же тёмная палитра, но по настройке операционной системы */
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --page-bg: #14171a;
    --page-wash:
      radial-gradient(700px 380px at 12% -10%, rgba(224, 138, 114, .08), transparent 55%),
      radial-gradient(600px 360px at 100% 0%, rgba(86, 168, 119, .06), transparent 50%);
    --surface: #22262b;
    --surface-soft: #1b1f23;
    --field-bg: rgba(255, 255, 255, .05);
    --field-bg-focus: rgba(255, 255, 255, .11);
    --track: #2e343a;

    --ink: #e6e1d8;
    --ink-soft: #98a0aa;
    --accent: #e08a72;
    --accent-soft: #f0a693;
    --line: #39414a;
    --good: #56a877;
    --danger: #e0645a;

    --topbar-bg: #0f1215;
    --topbar-fg: #e6e1d8;
    --topbar-line: #2e343a;
    --topbar-muted: #8c949e;

    --radius: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .45);
    --topbar-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

/* Скрипты прячут блоки атрибутом hidden, а собственный display у них сильнее. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background-color: var(--page-bg);
  background-image: var(--page-wash);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Nunito Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* --- Верхняя панель --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--topbar-bg);
  color: var(--topbar-fg);
  box-shadow: var(--topbar-shadow);
}

.topbar__left, .topbar__right { display: flex; align-items: center; gap: 8px; }

.topbar__logo {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  flex: none;
  opacity: .92;
  transition: opacity .12s, transform .12s;
}
.topbar__logo:hover { opacity: 1; transform: scale(1.06); }
/* На тёмной шапке контур d20 осветляем до цвета текста. */
.topbar__logo img {
  width: 100%;
  height: 100%;
  display: block;
  filter: brightness(0) invert(1);
  opacity: .9;
}

.topbar select {
  background: var(--topbar-line);
  color: var(--topbar-fg);
  border: 1px solid var(--topbar-line);
  border-radius: var(--radius);
  padding: 5px 8px;
  max-width: 220px;
}

.topbar__user { font-size: 12px; color: var(--topbar-muted); }
/* Стол, за которым играет персонаж, но ведёт его кто-то другой. */
.topbar__game {
  font-size: 12px;
  color: var(--topbar-muted);
  border: 1px solid var(--topbar-line);
  border-radius: var(--radius);
  padding: 3px 8px;
}

/* --- Меню под именем в шапке --- */
.usermenu { position: relative; }
.usermenu__button {
  font: inherit;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid var(--topbar-line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--topbar-fg);
  cursor: pointer;
  max-width: 200px;
}
.usermenu__button:hover, .usermenu__button[aria-expanded="true"] { background: var(--topbar-line); }
.usermenu__button > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.usermenu__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 210px;
  max-width: min(280px, calc(100vw - 16px));
  padding: 4px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.usermenu__list[hidden] { display: none; }
.usermenu__list form { margin: 0; }
.usermenu__item {
  font: inherit;
  font-size: 13px;
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.usermenu__item:hover { background: var(--field-bg-focus); }

.save-status { font-size: 12px; color: var(--topbar-muted); min-width: 96px; text-align: right; }
.save-status--saving { color: #e8c46a; }
.save-status--saved { color: #8ec98e; }
.save-status--error { color: #ef8b80; }

/* --- Кнопки --- */
.btn {
  font: inherit;
  font-size: 13px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: var(--field-bg-focus); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:disabled:hover { background: var(--surface); }
.btn--small { font-size: 12px; padding: 3px 8px; }
.btn--ghost { background: transparent; color: var(--topbar-fg); border-color: var(--topbar-line); }
.btn--danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--good { background: var(--good); color: #fff; border-color: var(--good); }
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-soft); border-color: var(--accent-soft); color: #fff; }

/* --- Поля ввода --- */
input[type="text"], input[type="number"], input[type="password"],
select, textarea, output {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 3px 2px;
  width: 100%;
  border-radius: 0;
}
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field-bg);
  padding: 6px;
  resize: vertical;
  font-size: 13px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-soft);
  background: var(--field-bg-focus);
}
select { cursor: pointer; }
select option { background: var(--surface); color: var(--ink); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="checkbox"] { accent-color: var(--accent); }

label.checkbox { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
label.checkbox input { width: auto; }

/* --- Панели --- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.panel__title {
  font-family: Georgia, "Times New Roman", serif;
  font-variant: small-caps;
  letter-spacing: .06em;
  font-size: 15px;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.hint { font-size: 11px; color: var(--ink-soft); font-variant: normal; letter-spacing: 0; }

/* --- Переключатель темы --- */
.theme-switch { display: flex; border: 1px solid var(--topbar-line); border-radius: var(--radius); overflow: hidden; }
.theme-switch button {
  font: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 5px 8px;
  border: none;
  background: transparent;
  color: var(--topbar-muted);
  cursor: pointer;
}
.theme-switch button[aria-pressed="true"] { background: var(--topbar-line); color: var(--topbar-fg); }

/* --- Страницы входа и регистрации --- */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth__card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.auth__title {
  font-family: Georgia, serif;
  font-variant: small-caps;
  letter-spacing: .06em;
  color: var(--accent);
  margin: 0 0 4px;
  font-size: 22px;
}
.auth__subtitle { color: var(--ink-soft); font-size: 13px; margin: 0 0 18px; }
.auth__field { margin-bottom: 14px; }
.auth__field label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.auth__error {
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 14px;
}
.auth__actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; }
.auth__actions .btn { flex: 1; text-align: center; }
.auth__alt { font-size: 12px; color: var(--ink-soft); text-align: center; margin-top: 16px; }

/* --- Общий контейнер страниц --- */
.page { max-width: 1100px; margin: 0 auto; padding: 18px 14px 60px; }
/* Кабинет и панель занимают всю ширину окна: карточкам и спискам так просторнее. */
.page--fluid { max-width: none; padding-inline: clamp(14px, 3vw, 48px); }
.page--wide { max-width: 1500px; }
.page__header { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page__header-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page__title { font-family: Georgia, serif; font-size: 26px; margin: 0; }
.page__subtitle { color: var(--ink-soft); font-size: 13px; margin: 2px 0 0; }
.page__title--small { font-size: 21px; }

/* Разделы кабинета: рамка держит содержимое, когда окно во всю ширину. */
.block {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  padding: 14px 16px 16px;
  margin-bottom: 14px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.block .page__header { margin-bottom: 12px; }
.block .page__header:last-child { margin-bottom: 0; }
.block .empty { padding: 0; }
/* Игры и вход стоят рядом, пока хватает ширины. */
.blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 14px;
}
.blocks .block { margin-bottom: 0; }
.empty { color: var(--ink-soft); font-size: 13px; padding: 10px 0; }

/* --- Карточки персонажей: вертикальные, портрет сверху --- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
/* На телефоне auto-fill оставил бы одну карточку во всю ширину экрана. */
@media (max-width: 460px) { .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card__portrait {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  background: var(--surface-soft);
  overflow: hidden;
}
.card__portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__portrait--small {
  width: 84px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card__initial {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
  font-size: 46px;
  color: var(--line);
  text-transform: uppercase;
}
.card__portrait--small .card__initial { font-size: 30px; }

.card__badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  max-width: calc(100% - 12px);
  font-size: 10px;
  line-height: 1.4;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card__badge[data-kind="pending"] { background: #b8860b; }

.card__body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 3px; }
.card__name {
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  color: inherit;
  text-decoration: none;
  line-height: 1.2;
}
.card__name:hover { color: var(--accent); }
.card__meta { font-size: 11px; color: var(--ink-soft); }

.card__edit {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, .5);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.card__edit:hover { background: var(--accent); }

/* --- Меню редактирования --- */
.sheet-dialog {
  width: min(440px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.sheet-dialog--narrow { width: min(340px, calc(100vw - 24px)); }
.sheet-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.sheet-dialog__close { position: absolute; top: 10px; right: 10px; margin: 0; }
.sheet-dialog__title {
  font-family: Georgia, serif;
  font-size: 20px;
  margin: 0 30px 14px 0;
}
.sheet-dialog__section { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.sheet-dialog__section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.sheet-dialog__section h3 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
  margin: 0 0 8px;
}
/* Второй шаг внутри раздела отделяем воздухом, а не линией. */
.sheet-dialog__section h3 ~ h3 { margin-top: 18px; }
.sheet-dialog__image { display: flex; gap: 12px; align-items: flex-start; }
.sheet-dialog__image-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sheet-dialog__image-actions .hint { width: 100%; margin: 0; }
.sheet-dialog__row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.sheet-dialog__row--center { justify-content: center; margin-top: 10px; }
.sheet-dialog__game { margin: 0 0 8px; font-size: 13px; }

/* --- Столы персонажа в окне «карандаш» --- */
.seats { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.seat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.seat__name { flex: 1; min-width: 0; font-size: 13px; }

/* --- Ответы мастеров по заявкам --- */
.notices { display: flex; flex-direction: column; gap: 8px; }
.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  background: var(--surface);
}
.notice__text { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 3px; }
.notice__title { margin: 0; font-size: 13px; font-weight: 600; }
.notice__reason { margin: 0; font-size: 13px; }
.notice__reason--empty { color: var(--ink-soft); font-style: italic; }

/* --- Список игр --- */
.games { display: flex; flex-direction: column; gap: 8px; }
.game-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.game-row__name { font-weight: 600; }
.game-row__id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--field-bg);
  border-radius: 4px;
  padding: 2px 6px;
}
.game-row__badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #b8860b;
  color: #fff;
}
.game-row__actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }

/* --- Панель администратора --- */
.users { display: flex; flex-direction: column; gap: 8px; }
.user-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: border-color .12s, background .12s;
}
.user-card--target { border-color: var(--accent); background: var(--field-bg-focus); }
.user-card__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-card__stuff { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.user-card__stuff:empty { margin-top: 0; }

.chips { display: contents; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field-bg);
  cursor: grab;
  user-select: none;
}
.chip--dragged { opacity: .4; }
.chip__kind {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-soft);
}
.user-row__name { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.user-row__meta { font-size: 12px; color: var(--ink-soft); }
.user-row__tag {
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--ink-soft);
}
.user-row__tag[hidden] { display: none; }
.user-card__head .game-row__actions { margin-left: auto; }

.new-password {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
  letter-spacing: .05em;
  background: var(--field-bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 8px 0;
  user-select: all;
  overflow-wrap: anywhere;
}

/* --- Второй фактор --- */
.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 22px;
  letter-spacing: .18em;
  text-align: center;
}
.code-input--small { font-size: 17px; max-width: 140px; }

.qr {
  /* Не шире окна: на узком экране код должен уменьшаться целиком, а не обрезаться. */
  width: min(220px, 100%);
  padding: 12px;
  margin: 12px auto;
  background: #fff;
  border-radius: var(--radius);
  color: #000; /* segno рисует модули через currentColor */
  box-sizing: border-box;
}
.qr svg { display: block; width: 100%; height: auto; }
.qr__secret { text-align: center; margin: 6px 0 0; }
.qr__secret code { display: inline-block; line-height: 1.6; letter-spacing: .08em; }
.hint--center { text-align: center; margin-bottom: 0; }

.recovery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 12px;
  margin: 8px 0;
  padding-left: 22px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

/* --- Приглашение в игру --- */
.page--narrow { max-width: 560px; }
.notice {
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
}
.notice--good { border-color: var(--good); }

.picker { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.picker__item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
}
.picker__item:hover { border-color: var(--accent-soft); }
.picker__item--disabled { opacity: .55; cursor: default; }
.picker__item input { width: auto; flex: none; }
.picker__portrait {
  position: relative;
  width: 42px;
  height: 56px;
  flex: none;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-soft);
}
.picker__portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.picker__initial {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: Georgia, serif;
  font-size: 22px;
  color: var(--line);
  text-transform: uppercase;
}
.picker__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.picker__name { font-weight: 600; }
.picker__meta { font-size: 11px; color: var(--ink-soft); }

.field-block { display: block; margin-bottom: 12px; }
.field-block span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.field-block input[type="text"],
.field-block input[type="password"] {
  display: block;
  width: 100%;
  min-width: 0;
}
.delete-dialog__username {
  display: block;
  margin: 0 0 8px;
  padding: 6px 8px;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  user-select: all;
}

/* --- Страница ошибки --- */
.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.error-page__code { font-family: Georgia, serif; font-size: 64px; color: var(--accent); line-height: 1; }
.error-page__text { color: var(--ink-soft); margin: 8px 0 20px; }

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    padding: 8px 10px;
    row-gap: 6px;
  }
  .topbar__left,
  .topbar__right {
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
  }
  .topbar__right { margin-left: auto; }
  .topbar__game {
    max-width: min(180px, 100%);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .save-status { min-width: 0; text-align: left; }
  /* Кнопка после переноса может оказаться слева — меню тянем на всю шапку. */
  .usermenu { position: static; }
  .usermenu__list {
    left: 8px;
    right: 8px;
    width: auto;
    min-width: 0;
    max-width: none;
  }
  .page { padding: 14px 10px 50px; }
  .page__title { font-size: 21px; }
}
