/* «Последняя осень» — интерфейс: пергамент, чернила, тёплый свет. */

:root {
  --ink: #211a13;
  --parchment: #e9dcbd;
  --parchment-dim: #cbbb96;
  --panel: rgba(28, 22, 17, 0.94);
  --panel-edge: #6b573a;
  --gold: #d9a441;
  --rust: #b4643a;
  --green: #8f9c56;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  --font-title: Georgia, 'Times New Roman', 'PT Serif', serif;
  --font-ui: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Скрытые панели не должны перехватывать клики: класс с display задан ниже. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #12100e;
  color: var(--parchment);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

button { font-family: inherit; font-size: inherit; cursor: pointer; }

.key {
  display: inline-block;
  min-width: 1.7em;
  padding: 1px 6px;
  margin: 0 2px;
  border: 1px solid #7d6742;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(50, 40, 28, 0.85);
  color: #f0e2c2;
  font-size: 0.82em;
  font-weight: 600;
  text-align: center;
}

/* ─────────────── HUD ─────────────── */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.hud__left {
  position: absolute;
  top: 16px;
  left: 16px;
  max-width: min(420px, 46vw);
  padding: 10px 16px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 4px 10px 10px 4px;
  background: linear-gradient(100deg, rgba(24, 19, 14, 0.92), rgba(24, 19, 14, 0.66));
  backdrop-filter: blur(2px);
}

.hud__label {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #b09a6d;
}

.hud__objective {
  margin-top: 2px;
  font-family: var(--font-title);
  font-size: 19px;
  line-height: 1.35;
  color: #f2e6c8;
}

.hud__objective.pulse { animation: pulse 1.4s ease-out; }

@keyframes pulse {
  0% { color: var(--gold); text-shadow: 0 0 14px rgba(217, 164, 65, 0.7); }
  100% { color: #f2e6c8; text-shadow: none; }
}

.hud__place {
  margin-top: 6px;
  font-size: 13px;
  color: #a2916d;
  font-style: italic;
}

.hud__right {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(24, 19, 14, 0.7);
  font-size: 12.5px;
  color: #b6a582;
  text-align: right;
  max-width: 40vw;
}

.hud__prompt {
  position: absolute;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  padding: 9px 20px;
  border: 1px solid #7d6742;
  border-radius: 999px;
  background: rgba(24, 19, 14, 0.9);
  color: #f2e2bb;
  font-size: 16px;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* ─────────────── уведомления ─────────────── */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 9px 15px;
  border-left: 3px solid var(--gold);
  border-radius: 4px 8px 8px 4px;
  background: rgba(26, 21, 16, 0.95);
  color: #f0e3c4;
  font-size: 15px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  max-width: min(360px, 70vw);
}

.toast.is-in { opacity: 1; transform: none; }
.toast--good { border-left-color: var(--gold); }
.toast--quest { border-left-color: var(--green); }
.toast--bad { border-left-color: var(--rust); }
.toast--info { border-left-color: #7d6742; }

/* ─────────────── диалог ─────────────── */

.dialogue {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 0 16px 18px;
  animation: rise 0.22s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.dialogue__box {
  position: relative;
  width: min(880px, 100%);
  padding: 18px 24px 14px;
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(30, 24, 18, 0.97), rgba(20, 16, 12, 0.98));
  box-shadow: var(--shadow);
}

.dialogue__close {
  position: absolute;
  top: 8px;
  right: 10px;
}

.dialogue__name {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.dialogue__text {
  margin: 0;
  min-height: 3.1em;
  font-size: 19.5px;
  line-height: 1.55;
  color: #f1e5c9;
}

.dialogue__text.is-narration {
  font-style: italic;
  color: #cfc0a0;
}

.dialogue__text.fade-in { animation: fade 0.24s ease-out; }

@keyframes fade {
  from { opacity: 0.2; }
  to { opacity: 1; }
}

.dialogue__choices {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}

.dlg-choice {
  display: flex;
  align-items: baseline;
  gap: 11px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #5b4a32;
  border-radius: 8px;
  background: rgba(48, 38, 27, 0.6);
  color: #f0e3c4;
  font-size: 17px;
  text-align: left;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

.dlg-choice:hover,
.dlg-choice:focus-visible {
  background: rgba(76, 60, 40, 0.9);
  border-color: var(--gold);
  transform: translateX(3px);
  outline: none;
}

.dlg-choice__num {
  flex: 0 0 auto;
  width: 1.5em;
  color: var(--gold);
  font-weight: 700;
  font-size: 14px;
}

.dialogue__hint {
  margin-top: 10px;
  font-size: 12.5px;
  color: #93815f;
  text-align: right;
}

/* ─────────────── панели ─────────────── */

.panel {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 8, 6, 0.72);
  backdrop-filter: blur(3px);
}

.panel__box {
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: min(86vh, 760px);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  background: linear-gradient(180deg, #241d16, #191410);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel--narrow .panel__box { width: min(440px, 100%); }

.panel__head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid #3d3123;
  background: rgba(46, 36, 26, 0.6);
}

.panel__title {
  margin: 0;
  font-family: var(--font-title);
  font-size: 22px;
  color: #f2e6c8;
  flex: 1 1 auto;
}

.panel__body {
  padding: 18px;
  overflow-y: auto;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #5b4a32;
  border-radius: 8px;
  background: rgba(48, 38, 27, 0.7);
  color: #e0cfa8;
  font-size: 15px;
  line-height: 1;
}

.icon-btn:hover { border-color: var(--gold); color: #fff; }

.journal__tabs { display: flex; gap: 8px; }

.journal__tab {
  padding: 7px 16px;
  border: 1px solid #5b4a32;
  border-radius: 999px;
  background: transparent;
  color: #c4b28c;
  font-size: 15px;
}

.journal__tab.is-active {
  background: var(--gold);
  border-color: var(--gold);
  color: #2a2114;
  font-weight: 600;
}

.journal__group {
  margin: 18px 0 8px;
  font-family: var(--font-title);
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #a89263;
}

.journal__group:first-child { margin-top: 0; }
.journal__empty { color: #9c8b69; font-style: italic; }
.journal__count { margin: 0 0 12px; color: #c4b28c; }

.quest, .clue {
  margin-bottom: 12px;
  padding: 13px 16px;
  border: 1px solid #3d3123;
  border-left: 3px solid #6b573a;
  border-radius: 4px 10px 10px 4px;
  background: rgba(44, 35, 26, 0.55);
}

.quest--active { border-left-color: var(--gold); }
.quest--done { border-left-color: var(--green); opacity: 0.78; }

.quest__head { display: flex; align-items: baseline; gap: 12px; }
.quest__title { margin: 0; font-family: var(--font-title); font-size: 19px; color: #f2e6c8; flex: 1 1 auto; }
.quest__status { font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: #a89263; }
.quest__summary { margin: 6px 0 0; font-size: 15px; color: #c2b18d; }
.quest__step { margin: 8px 0 0; font-size: 16px; color: #f0e3c4; }
.quest--done .quest__step { text-decoration: line-through; text-decoration-color: rgba(240, 227, 196, 0.4); }

.clue__title { margin: 0; font-family: var(--font-title); font-size: 18px; color: #f2e6c8; }
.clue__short { margin: 4px 0 0; font-size: 14.5px; color: #a89263; font-style: italic; }
.clue__text { margin: 9px 0 0; font-size: 16px; color: #ded0ad; white-space: pre-line; }
.clue--item { border-left-color: #7d6742; }

.pause__stats { margin: 0 0 16px; font-size: 14.5px; color: #a89263; }

.menu { display: flex; flex-direction: column; gap: 9px; }

.btn {
  padding: 12px 18px;
  border: 1px solid #5b4a32;
  border-radius: 9px;
  background: rgba(52, 41, 29, 0.75);
  color: #f0e3c4;
  font-size: 16.5px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover:not(:disabled), .btn:focus-visible:not(:disabled) {
  background: rgba(78, 61, 41, 0.95);
  border-color: var(--gold);
  outline: none;
}

.btn:active:not(:disabled) { transform: translateY(1px); }

.btn--primary {
  background: linear-gradient(180deg, #d9a441, #b5822c);
  border-color: #e0b45c;
  color: #2a2114;
  font-weight: 700;
}

.btn--primary:hover { background: linear-gradient(180deg, #e8b652, #c08f31); }
.btn--danger { border-color: #7a4436; color: #e8b9a0; }
.btn--big { padding: 14px 28px; font-size: 18px; }

.btn:disabled, .btn.is-disabled { opacity: 0.4; cursor: not-allowed; }

.options { margin-top: 18px; padding-top: 14px; border-top: 1px solid #3d3123; }
.option { display: flex; align-items: center; gap: 12px; font-size: 15px; color: #c4b28c; margin-bottom: 10px; }
.option input[type='range'] { flex: 1 1 auto; accent-color: var(--gold); }
.option--check { gap: 9px; }
.option--check input { accent-color: var(--gold); width: 17px; height: 17px; }

/* ─────────────── стартовый экран ─────────────── */

.title {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(20, 15, 10, 0.55), rgba(8, 6, 5, 0.94) 70%),
    linear-gradient(180deg, rgba(10, 8, 6, 0.5), rgba(8, 6, 5, 0.9));
  overflow-y: auto;
}

.title__inner {
  width: min(660px, 100%);
  text-align: center;
  animation: rise 0.5s ease-out;
}

.title__over {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: #9a8154;
}

.title__name {
  margin: 6px 0 14px;
  font-family: var(--font-title);
  font-size: clamp(40px, 8vw, 74px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
  color: #f0dfb4;
  text-shadow: 0 4px 30px rgba(217, 164, 65, 0.28), 0 2px 2px rgba(0, 0, 0, 0.6);
}

.title__lead {
  margin: 0 auto 26px;
  max-width: 30em;
  font-size: 17.5px;
  line-height: 1.6;
  color: #cbbb96;
}

.title__menu { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.title__save { margin: 14px 0 0; font-size: 14px; color: #9a8154; }

.title__help {
  margin: 26px auto 0;
  max-width: 30em;
  padding: 16px 20px;
  border: 1px solid #3d3123;
  border-radius: 12px;
  background: rgba(24, 19, 14, 0.7);
  font-size: 14.5px;
  color: #bfae89;
  text-align: left;
  display: grid;
  gap: 7px;
}

.title__foot { margin: 18px 0 0; font-size: 13px; color: #7d6b4c; }

/* ─────────────── финал ─────────────── */

.ending {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, rgba(40, 30, 20, 0.7), rgba(6, 5, 4, 0.97) 70%);
  overflow: hidden;
  animation: fade 0.6s ease-out;
}

.ending[data-tone='best'] { background: radial-gradient(ellipse at 50% 30%, rgba(66, 54, 26, 0.75), rgba(8, 6, 4, 0.97) 70%); }
.ending[data-tone='dark'] { background: radial-gradient(ellipse at 50% 30%, rgba(24, 22, 30, 0.8), rgba(4, 4, 5, 0.98) 70%); }
.ending[data-tone='bitter'] { background: radial-gradient(ellipse at 50% 30%, rgba(48, 32, 26, 0.75), rgba(7, 5, 4, 0.97) 70%); }

.ending__box {
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  padding: 26px 32px 20px;
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  background: rgba(20, 16, 12, 0.92);
  box-shadow: var(--shadow);
  margin: auto;
}

/* Текст прокручивается внутри рамки, кнопки всегда остаются на виду. */
.ending__body {
  overflow-y: auto;
  padding-right: 8px;
}

.ending__rank {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--gold);
}

.ending__title {
  margin: 6px 0 16px;
  font-family: var(--font-title);
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 400;
  line-height: 1.12;
  color: #f0dfb4;
}

.ending__para {
  margin: 0 0 11px;
  font-size: 16.5px;
  line-height: 1.6;
  color: #ded0ad;
}

.ending__closing {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid #3d3123;
  font-family: var(--font-title);
  font-size: 19px;
  font-style: italic;
  color: #f0dfb4;
}

.ending__subtitle {
  margin: 20px 0 9px;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #a89263;
}

.ending__list { margin: 0; padding-left: 20px; }
.ending__list li { margin-bottom: 7px; font-size: 15.5px; line-height: 1.55; color: #c8b894; }

.ending__stats {
  margin: 22px 0 0;
  font-size: 14px;
  color: #94825f;
}

.ending__menu {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  flex: 0 0 auto;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #3d3123;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #12100e;
  color: var(--parchment);
  font-size: 20px;
  z-index: 100;
}

/* ─────────────── небольшие экраны ─────────────── */

@media (max-width: 1150px) {
  .hud__right { font-size: 11.5px; padding: 6px 10px; max-width: 46vw; }
}

@media (max-width: 900px) {
  body { font-size: 16px; }
  .hud__right { display: none; }
  .hud__left { max-width: 60vw; padding: 8px 12px 10px; }
  .hud__objective { font-size: 16.5px; }
  .dialogue__text { font-size: 17.5px; }
  .dlg-choice { font-size: 16px; padding: 9px 12px; }
  .ending__box { padding: 22px 20px; }
}

@media (max-height: 620px) {
  .dialogue__box { padding: 12px 18px 10px; }
  .dialogue__text { min-height: 2.4em; font-size: 17px; }
  .title__help { display: none; }
  .title__lead { margin-bottom: 16px; }
}
