:root {
  --bg: #050505;
  --surface: #1a1a1a;

  --text: #f5f3ee;
  --muted: #b9b0a4;

  --gold-1: #f8d777;
  --gold-2: #d9a548;
  --gold-3: #a6651e;
  --gold-4: #f2c86b;

  --gradient-gold: linear-gradient(
    145deg,
    var(--gold-1) 0%,
    var(--gold-2) 20%,
    var(--gold-3) 52%,
    var(--gold-4) 100%
  );
}


/* =========================
   БАЗА
   ========================= */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;

  display: flex;
  justify-content: center;

  padding: 24px;

  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);

  text-align: center;
}


/* =========================
   ОСНОВНОЙ КОНТЕЙНЕР
   ========================= */

.page {
  width: min(900px, 100%);

  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 20px;
}

.oneline{
  display: flex;
  flex-direction: row;
  gap: 20px;
}


/* =========================
   ТЕКСТ
   ========================= */

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;

  text-align: center;

  background: var(--gradient-gold);
  background-clip: text;
  -webkit-background-clip: text;

  color: transparent;
}

h1 { font-size: 1em; }
h2 { font-size: 0.85em; }
h3 { font-size: 0.6em; }
h4 { font-size: 0.5em; }
h5 { font-size: 0.4em; }
h6 { font-size: 0.3em; }

p {
  margin: 0;

  max-width: 700px;

  color: var(--muted);
  line-height: 1.6;
  text-align: center;
}

.text {
  max-width: 700px;

  color: var(--muted);
  line-height: 1.6;
  text-align: center;
}


/* =========================
   КАРТИНКИ
   ========================= */

img {
  display: block;
  height: auto;
  margin-inline: auto;
}

.image-preview {
  width: min(220px, 60vw);
  max-width: 100%;

  object-fit: contain;
}

.image-full {
  width: min(900px, 100%);

  object-fit: contain;
}


/* =========================
   ФОРМА
   ========================= */

.form {
  width: min(500px, 100%);

  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 14px;
}

.field {
  width: 100%;

  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 8px;
}

label,
.label {
  width: 100%;

  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

input,
textarea,
select,
.input {
  width: 100%;
  min-height: 52px;

  padding: 12px 16px;

  border: none;
  border-radius: 12px;
  outline: none;

  background: rgba(255, 255, 255, 0.03);
  color: var(--text);

  font: inherit;
  text-align: center;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

input:focus,
textarea:focus,
select:focus {
  background: rgba(255, 255, 255, 0.06);
}


/* =========================
   КНОПКИ
   ========================= */

button,
.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  background: none;
  border: none;
  max-height: 10vh;
  padding: 0;
}

button img,
.button img {
  max-height: 10vh;
  width: auto;
  object-fit: contain;
}

button span,
.button span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  color: black;
  font-weight: bold;
  z-index: 1;
}

button:hover,
.button:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}



/* =========================
   СПИСКИ
   ========================= */

ul,
ol,
.list {
  width: min(600px, 100%);

  margin: 0;
  padding: 0;

  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 10px;

  list-style-position: inside;
  color: var(--muted);
}

li {
  width: 100%;
  text-align: center;
}


/* =========================
   ССЫЛКИ
   ========================= */

a {
  color: var(--gold-1);
  text-align: center;
  text-decoration: none;
}

a:hover {
  opacity: 0.8;
}


/* =========================
   УНИВЕРСАЛЬНАЯ ГРУППА
   ========================= */

.group {
  width: 100%;

  display: flex;
  flex-direction: column;
  align-items: center;

  gap: 14px;
}


/* =========================
   МОБИЛЬНЫЕ
   ========================= */

@media (max-width: 560px) {
  body {
    padding: 18px 16px;
  }

  .page {
    gap: 16px;
  }

  .image-preview {
    width: min(200px, 65vw);
  }

  button,
  .button {
    min-height: 52px;
  }
}

.registration-page {
  padding-bottom: 16px;
}

.registration-page .page,
.registration-page .main-box {
  width: min(500px, 100%);
}

.registration-page .main-box {
  min-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.registration-page .logo-wrap .image-preview {
  width: min(150px, 42vw);
}

.registration-intro {
  margin-bottom: 14px;
}

.registration-form {
  flex: 1;
}

.wizard-step {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wizard-step[hidden] {
  display: none;
}

.registration-summary {
  width: 100%;
  margin: 0;
}

.registration-summary div {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
  padding: 11px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.registration-summary dt {
  color: var(--muted);
}

.registration-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.wizard-actions {
  width: 100%;
  margin-top: auto;
  padding-top: 18px;
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: linear-gradient(transparent, var(--bg) 22%);
}

.wizard-back {
  min-height: auto;
  padding: 6px 18px;
  color: var(--gold-1);
  cursor: pointer;
}

.wizard-back[hidden] {
  display: none;
}

.wizard-next {
  cursor: pointer;
}

/* Портал и профиль */
.portal-page .page {
  padding-top: 84px;
  padding-bottom: 82px;
}

.portal-bar {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 10;
  transform: translateX(-50%);
  width: min(900px, calc(100% - 32px));
  --portal-height: 58px;
  height: calc(var(--portal-height) + 2px);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.portal-logo-link,
.portal-main-button {
  display: block;
  flex-shrink: 0;
  height: var(--portal-height);
}

.portal-logo {
  width: auto;
  height: var(--portal-height);
  max-height: none;
  margin: 0;
  object-fit: contain;
}

.portal-user-actions {
  height: var(--portal-height);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.portal-pseudonym {
  overflow: hidden;
  background: var(--gradient-gold);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  font-family: 'Pero', 'Alice', serif;
  height: var(--portal-height);
  line-height: var(--portal-height);
  font-size: calc(var(--portal-height) * 0.5);
  min-width: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.portal-main-button img {
  width: auto;
  height: var(--portal-height);
  max-height: none;
  margin: 0;
  object-fit: contain;
}

.bottom-menu {
  position: fixed;
  bottom: 14px;
  left: 50%;
  z-index: 10;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 32px));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.bottom-menu button {
  min-width: 0;
  cursor: pointer;
  font-size: clamp(0.75rem, 3.2vw, 0.875rem);
}

.bottom-menu button img {
  max-width: 100%;
}

.bottom-menu button:focus-visible {
  outline: 2px solid var(--gold-1);
  outline-offset: 3px;
}
.quest-list,
.quest-content {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 18px;
}

.quest-list > h1,
.quest-content > h1 { margin-bottom: 4px; }

.quest-filters { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.quest-filter { padding: 10px 16px; border: 1px solid #65502e; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.quest-filter.is-active { background: var(--gold-1); color: #211709; }
.quest-filter-status { min-height: 1.3em; font-size: 0.85rem; }
.quest-list-item.is-hidden { display: none; }

.quest-list-item {
  width: 100%;
  min-height: 104px;
  padding: 10px 14px 10px 8px;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  border: 1px solid rgba(248, 215, 119, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.035);
  text-align: left;
}

.quest-list-item { color: inherit; text-decoration: none; }
.quest-list-item:hover { border-color: var(--gold-2); }
.quest-list-item:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 3px; }
.quest-thumbnail { width: 84px; height: 84px; margin: 0; border-radius: 12px; object-fit: cover; }
.quest-thumbnail-empty { display: grid; place-items: center; background: #171717; color: var(--gold-2); font-size: 2rem; }
.quest-list-copy { min-width: 0; text-align: left; }
.quest-list-copy h2 { overflow: hidden; text-align: left; white-space: nowrap; text-overflow: ellipsis; }
.quest-list-copy p { margin-top: 7px; overflow: hidden; color: var(--muted); font-size: 0.84rem; line-height: 1.35; text-align: left; white-space: nowrap; text-overflow: ellipsis; }
.quest-empty { align-self: center; }

.quest-main-image { width: min(580px, 100%); max-height: 55vh; border-radius: 18px; object-fit: contain; }
.quest-description { max-width: 680px; align-self: center; white-space: normal; }
.quest-media { display: flex; flex-direction: column; gap: 16px; }
.quest-media audio, .quest-media video { width: 100%; max-width: 680px; align-self: center; border-radius: 14px; }
.quest-media video { max-height: 58vh; background: #000; }
.media-placeholder { width: 100%; padding: 12px; border: 1px dashed rgba(248, 215, 119, 0.2); border-radius: 12px; font-size: 0.85rem; }
.quest-result-actions { display: flex; justify-content: center; gap: 20px; margin-top: 8px; }
.quest-result-actions[hidden] { display: none; }
.quest-result-actions button { cursor: pointer; }
#quest-completion { width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 40px); padding: 20px; border: 1px solid var(--gold-2); border-radius: 20px; background: #17140e; color: var(--text); }
#quest-completion::backdrop { background: rgba(0, 0, 0, 0.78); }
#quest-completion .quest-skills { padding: 0; border: 0; }
.completion-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; margin-top: 18px; }
.completion-actions button { padding: 12px 18px; border: 1px solid var(--gold-2); border-radius: 999px; background: transparent; color: var(--gold-1); font: inherit; cursor: pointer; }
.completion-actions #completion-confirm { background: var(--gold-1); color: #211709; }
.completion-actions button:disabled { opacity: 0.5; cursor: wait; }
#completion-status { margin-top: 14px; }
.quest-start { display: grid; justify-items: center; gap: 14px; }
.quest-start button { padding: 12px 24px; border: 1px solid var(--gold-1); border-radius: 999px; background: var(--gold-1); color: #211709; font: inherit; cursor: pointer; }
.quest-start button:disabled { opacity: 0.55; cursor: default; }
.quest-list-heading { display: flex; align-items: center; gap: 10px; min-width: 0; }
.quest-list-heading h2 { min-width: 0; }
.quest-level { flex-shrink: 0; color: var(--gold-1); font-family: Arial, sans-serif; font-size: 1rem; letter-spacing: 2px; white-space: nowrap; }
.quest-metadata { color: var(--muted); text-align: center; margin-top: -8px; }
.quest-skills .quest-reward { cursor: default; }
.selected-skill { display: inline-flex; align-items: center; gap: 0; padding-right: 8px; border: 1px solid var(--gold-1); border-radius: 999px; background: var(--gold-1); color: #211709; }
.quest-skills .selected-skill .skill-button { border: 0; background: transparent; padding-right: 10px; }
.selected-skill .skill-quantity { width: auto; min-width: 46px; min-height: 32px; margin: 0; padding: 4px 6px; border: 0; border-left: 1px solid rgba(33, 23, 9, 0.25); border-radius: 0; background: transparent; color: #211709; font: inherit; font-size: 0.9rem; font-weight: bold; box-shadow: none; cursor: pointer; }
.skill-quantity option { background: var(--gold-1); color: #211709; }
.skill-quantity:focus-visible { outline: 2px solid var(--gold-1); outline-offset: 2px; }
.skill-amount { display: inline-block; min-width: 24px; margin-left: 6px; padding: 2px 6px; border-radius: 50%; background: rgba(0, 0, 0, 0.12); text-align: center; font-weight: bold; }

.quest-skills { padding: 20px; border: 1px solid rgba(248, 215, 119, 0.25); border-radius: 16px; text-align: left; }
.quest-skills h2, .quest-skills h3 { text-align: left; margin-bottom: 12px; }
.quest-skills > p { margin-bottom: 18px; font-size: 0.9rem; line-height: 1.5; }
.quest-skills h3 { margin-top: 20px; font-size: 0.5rem; }
#skills-count { margin-left: 8px; color: var(--gold-1); }
.skill-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
#selected-skills { min-height: 44px; margin-bottom: 22px; color: var(--muted); }
.skill-tabs { display: flex; gap: 4px; overflow-x: auto; padding-top: 4px; }
.quest-skills .skill-tabs button { flex: 0 0 auto; padding: 12px 14px; border: 1px solid #65502e; border-bottom: 0; border-radius: 12px 12px 0 0; background: #17140e; color: var(--muted); font: inherit; font-size: 0.8rem; cursor: pointer; }
.quest-skills .skill-tabs button[aria-selected='true'] { background: #302616; color: var(--gold-1); box-shadow: inset 0 3px var(--gold-2); }
.skill-panel { padding: 18px; border: 1px solid #65502e; border-radius: 0 0 12px 12px; background: #17140e; }
.skill-panel[hidden] { display: none; }
.quest-skills .skill-button { padding: 10px 14px; border: 1px solid #76603b; border-radius: 999px; background: #211d16; color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer; }
.quest-skills .skill-button.is-selected { background: var(--gold-1); color: #211709; border-color: var(--gold-1); }
.quest-skills .skill-button[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; }
.quest-skills button:focus-visible { outline: 2px solid var(--gold-1); outline-offset: 2px; }
.quest-skills #skills-status { margin: 14px 0 0; min-height: 2.8em; }
@media (max-width: 560px) {
  .quest-skills { padding: 14px; min-width: 0; }
  .skill-panel { padding: 12px; }
}

@font-face {
  font-family: 'Pero';
  src: url('/static/fonts/Pero.ttf') format('truetype');
  font-display: swap;
}

.profile-page .page {
  width: min(500px, 100%);
}

.profile-logo-link .image-preview {
  width: min(150px, 42vw);
}

.profile-form {
  gap: 18px;
}

.magic-mirror { width: 100%; padding: 20px; border: 1px solid #65502e; border-radius: 20px; background: #14110c; }
#mirror-dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 40px); padding: 16px; border: 1px solid #65502e; border-radius: 20px; background: #14110c; color: var(--text); overflow-y: auto; }
#mirror-dialog::backdrop { background: rgba(0, 0, 0, 0.78); }
#mirror-dialog .magic-mirror { border: 0; padding: 16px 0 0; }
.mirror-close { padding: 12px 20px; border: 1px solid var(--gold-2); border-radius: 999px; background: #211d16; color: var(--gold-1); font: inherit; cursor: pointer; }
.mirror-close { display: block; margin-left: auto; }
.mirror-description { margin: 12px 0; font-size: 0.85rem; line-height: 1.5; }
#mirror-status { font-size: 0.85rem; }
.mirror-scale { display: flex; justify-content: space-between; margin: 10px calc(var(--mirror-value-width, 4ch) + 6px) 0; color: var(--muted); font-size: 0.75rem; }
.mirror-area { margin-top: 14px; }
.mirror-area h3 { text-align: center; font-size: 0.45rem; margin-bottom: 8px; }
.mirror-row { margin-bottom: 7px; }
.mirror-name { text-align: center; font-size: 0.8rem; line-height: 1.2; margin-bottom: 2px; }
.mirror-track { display: grid; grid-template-columns: var(--mirror-value-width, 4ch) minmax(0, 1fr) var(--mirror-value-width, 4ch); align-items: center; gap: 6px; font-size: 0.75rem; }
.mirror-value { color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; }
.mirror-plot { height: 14px; position: relative; background: rgba(255,255,255,0.035); border-radius: 3px; }
.mirror-plot::after { content: ''; position: absolute; left: 50%; top: -5px; bottom: -5px; width: 1px; background: var(--muted); }
.mirror-bar { position: absolute; height: 100%; }
.mirror-negative { right: 50%; background: #b77f8e; border-radius: 3px 0 0 3px; }
.mirror-positive { left: 50%; background: var(--gradient-gold); border-radius: 0 3px 3px 0; }

.avatar-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.avatar-preview {
  width: 150px;
  height: 150px;
  border: 2px solid rgba(248, 215, 119, 0.38);
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
}

.avatar-upload {
  width: auto;
  padding: 10px 18px;
  border: 1px solid rgba(248, 215, 119, 0.3);
  border-radius: 999px;
  color: var(--gold-1);
  cursor: pointer;
}

.avatar-field input[type='file'] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.profile-status {
  min-height: 1.6em;
  color: var(--gold-1);
}

.profile-save {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  max-height: none;
  padding: 0;
  align-self: center;
  text-decoration: none;
  cursor: pointer;
}
.profile-save img { width: 64px; height: 64px; max-width: 100%; max-height: none; margin: 0; object-fit: contain; }
.profile-save span { position: static; transform: none; color: var(--gold-1); font-size: 0.75rem; line-height: 1.3; }

@media (max-width: 560px) {
  .portal-page .page {
    padding-top: 74px;
  }

  .portal-bar {
    top: 10px;
    width: calc(100% - 20px);
  }





  .quest-list-item { grid-template-columns: 68px minmax(0, 1fr); gap: 10px; padding-right: 10px; }
  .quest-thumbnail { width: 68px; height: 68px; }
  .bottom-menu { bottom: 10px; width: calc(100% - 20px); }
}

/* Only the middle row scrolls; navigation keeps its own space. */
body.has-navigation {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 22px;
  padding: 16px 0 14px;
}
body.has-navigation .portal-bar,
body.has-navigation .bottom-menu {
  position: static;
  transform: none;
}
body.has-navigation .portal-bar {
  grid-row: 1;
}
body.has-navigation .bottom-menu {
  grid-row: 3;
}
.page-scroll {
  grid-row: 2;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 0 24px;
}
body.has-navigation .page {
  margin-inline: auto;
  padding-top: 0;
  padding-bottom: 0;
}
@media (max-width: 560px) {
  .portal-bar { --portal-height: 50px; gap: 10px; }
  .portal-user-actions { gap: 8px; }
  body.has-navigation { padding-top: 10px; padding-bottom: 10px; gap: 20px; }
  .page-scroll { padding-inline: 16px; }
}

.wiki-page .page { width: min(760px, 100%); gap: 24px; }
.wiki-page h2 { margin-top: 8px; }
.wiki-link {
  color: white;
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  text-underline-offset: 4px;
}
.wiki-link:hover { color: var(--gold-4); }
.wiki-link:focus-visible { outline: 2px solid var(--gold-1); outline-offset: 4px; }
