
:root {
  color-scheme: dark;
  --bg: #17151b;
  --panel: #211e27;
  --panel-2: #2b2632;
  --line: #453d4c;
  --text: #f4edf4;
  --muted: #b9aebc;
  --accent: #c5a36b;
  --accent-2: #e3c58e;
  --danger: #c66e72;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Georgia, "Times New Roman", serif; }
body { min-height: 100vh; }
button { font: inherit; }
button:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }
#app { min-height: 100vh; }
.page { width: min(1120px, 100%); margin: 0 auto; padding: 28px 24px 56px; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 34px; }
.brand h1 { margin: 0; letter-spacing: .12em; font-size: clamp(26px, 4vw, 42px); font-weight: 500; }
.brand small { color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .16em; font: 12px Arial, sans-serif; }
h2, h3, p { margin-top: 0; }
h2 { font-size: clamp(25px, 4vw, 38px); font-weight: 500; }
.muted { color: var(--muted); line-height: 1.55; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.story-card { background: linear-gradient(145deg, #302936, #211e27); border: 1px solid var(--line); border-radius: 14px; padding: 24px; min-height: 230px; display: flex; flex-direction: column; }
.story-card h3 { font-size: 25px; font-weight: 500; margin: 12px 0; }
.story-card p { color: var(--muted); line-height: 1.5; }
.story-card .spacer { flex: 1; }
.btn { border: 1px solid var(--accent); color: var(--text); background: transparent; padding: 12px 18px; border-radius: 8px; cursor: pointer; transition: .15s ease; }
.btn:hover { background: rgba(197,163,107,.14); border-color: var(--accent-2); }
.btn.primary { background: var(--accent); color: #211b17; font-weight: 700; }
.btn.primary:hover { background: var(--accent-2); }
.btn.subtle { border-color: var(--line); color: var(--muted); }
.btn.danger { border-color: var(--danger); color: #f0b9bb; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.chapter-list { display: grid; gap: 12px; margin: 28px 0; }
.chapter-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.chapter-row h3 { font-size: 18px; font-weight: 500; margin: 0 0 5px; }
.chapter-row p { margin: 0; color: var(--muted); font: 12px Arial, sans-serif; }
.game-shell { width: min(1200px, 100%); margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: #141117; }
.game-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px; background: #211d26; border-bottom: 1px solid var(--line); z-index: 3; }
.game-top strong { letter-spacing: .1em; font-size: 14px; }
.game-top .toolbar { gap: 6px; }
.game-top .btn { padding: 8px 11px; font: 12px Arial, sans-serif; }
.scene { position: relative; isolation: isolate; flex: 1; min-height: 440px; overflow: hidden; background: #342a29; background-position: center; background-size: cover; }
.scene::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.25)); }
.scene-bg { position: absolute; inset: 0; z-index: -2; background-position: center; background-size: cover; }
.sprite { position: absolute; bottom: 0; height: min(88%, 650px); max-width: 42%; object-fit: contain; object-position: bottom; transform: translateX(-50%); filter: drop-shadow(0 10px 15px rgba(0,0,0,.35)); }
.sprite-placeholder { position: absolute; bottom: 0; transform: translateX(-50%); width: clamp(110px, 19vw, 230px); height: 70%; display: grid; place-items: center; border-radius: 90px 90px 0 0; color: rgba(255,255,255,.9); font-size: 70px; border: 1px solid rgba(255,255,255,.2); background: linear-gradient(180deg, color-mix(in srgb, var(--char-color), transparent 35%), color-mix(in srgb, var(--char-color), #15121a 30%)); }
.dialogue-wrap { padding: 0 18px 18px; background: #17141c; }
.dialogue { position: relative; margin: -22px auto 0; max-width: 940px; padding: 22px 24px 18px; background: rgba(35,30,41,.97); border: 1px solid #65566a; border-radius: 12px; box-shadow: 0 12px 35px rgba(0,0,0,.35); }
.speaker { color: var(--accent-2); font-size: 18px; margin-bottom: 10px; }
.dialogue-text { font-size: clamp(17px, 2.1vw, 21px); line-height: 1.55; min-height: 52px; white-space: pre-wrap; }
.dialogue-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.dialogue-footer small { color: var(--muted); font: 11px Arial, sans-serif; }
.choice-list { display: grid; gap: 9px; margin-top: 16px; }
.choice-btn { width: 100%; text-align: left; background: #302938; border: 1px solid #66576b; color: var(--text); padding: 13px 16px; border-radius: 8px; cursor: pointer; line-height: 1.4; }
.choice-btn:hover:not(:disabled) { border-color: var(--accent-2); background: #3a3041; }
.choice-btn:disabled { opacity: .45; cursor: not-allowed; }
.end-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
#overlay { position: fixed; inset: 0; z-index: 20; display: none; place-items: center; padding: 20px; background: rgba(0,0,0,.72); }
#overlay.open { display: grid; }
.modal { width: min(520px, 100%); padding: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 70px #0009; }
.modal h3 { font-size: 23px; font-weight: 500; }
.slot-list { display: grid; gap: 10px; margin: 18px 0; }
.slot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px; background: var(--panel-2); border-radius: 8px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50; padding: 11px 16px; background: #302a36; border: 1px solid var(--line); border-radius: 8px; transition: .2s; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.error { padding: 22px; border: 1px solid #8f4f55; border-radius: 10px; background: #352328; white-space: pre-wrap; line-height: 1.5; }
.empty { color: var(--muted); padding: 20px 0; }
@media (max-width: 650px) {
  .page { padding: 20px 15px 38px; }
  .brand { margin-bottom: 24px; }
  .game-top { padding: 9px 10px; }
  .game-top .btn { padding: 7px 8px; }
  .scene { min-height: 54vh; }
  .sprite { max-width: 52%; height: 78%; }
  .dialogue-wrap { padding: 0 9px 10px; }
  .dialogue { margin-top: -16px; padding: 17px 15px 14px; }
  .dialogue-text { min-height: 64px; }
  .chapter-row { align-items: flex-start; }
}
/* STORY DETAIL — Ancient Rome */
.story-detail {
  min-height: 100vh;
  background:
    linear-gradient(rgba(20, 13, 9, 0.55), rgba(20, 13, 9, 0.8)),
    url('https://images.unsplash.com/photo-1552832230-c0197dd311b5') center / cover fixed;
  color: #fff;
  padding: 32px;
  border-radius: 16px;
}

.story-detail .muted {
  color: rgba(255, 255, 255, 0.85);
}

.story-detail .chapter-row {
  background: rgba(20, 13, 9, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 16px;
}
.story-backbar {
  justify-content: flex-start;
  margin-bottom: 30px;
}

.story-back-button {
  background: rgba(15, 12, 12, 0.85);
  color: #d6b77a;
  border: 1px solid #80613b;
  padding: 12px 25px;
  letter-spacing: 2px;
  font-family: Georgia, serif;
  transition: 0.2s;
}

.story-back-button:hover {
  background: rgba(75, 48, 35, 0.95);
  border-color: #c6a46a;
}
/* GAME SCREEN — DARK FANTASY LAYOUT */

.game-shell {
  position: relative;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  display: block;
  background: #100e13;
}

.game-top {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(
    to bottom,
    rgba(12, 10, 14, 0.9),
    rgba(12, 10, 14, 0.35)
  );
  border: none;
  padding: 18px 28px;
}

.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.dialogue-wrap {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 24px 24px;
  background: transparent;
}

.dialogue {
  width: min(1000px, 100%);
  max-width: none;
  margin: 0 auto;
  padding: 24px 30px;
  background: rgba(19, 15, 23, 0.91);
  border: 1px solid rgba(173, 139, 91, 0.55);
  border-radius: 14px;
  box-shadow: 0 8px 35px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
}

.dialogue-text {
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.6;
  min-height: auto;
}

@media (max-width: 650px) {
  .game-top {
    padding: 10px;
  }

  .dialogue-wrap {
    padding: 0 10px 12px;
  }

  .dialogue {
    padding: 18px 16px;
  }
}

/* ===== STORYVERSE: DARK FANTASY / ANCIENT ROME ===== */

.game-shell {
  position: fixed;
  inset: 0;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: #120e0d;
  color: #efe6d8;
  font-family: Georgia, serif;
}

.game-top {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: linear-gradient(rgba(12,9,9,.8), transparent);
  border: none;
}

.game-top strong {
  color: #d9bc8c;
  font-family: Georgia, serif;
}

.game-top .btn {
  background: rgba(14,10,10,.65);
  border-color: rgba(176,139,91,.55);
  color: #efe6d8;
}

.scene {
  position: absolute;
  inset: 0;
  min-height: 0;
  overflow: hidden;
  background: #120e0d;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(to top, rgba(0,0,0,.55), transparent 55%),
    radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,.4));
  pointer-events: none;
}

.scene-bg {
  position: absolute;
  inset: 0;
  z-index: -2;
  background-position: center;
  background-size: cover;
}

.sprite {
  position: absolute;
  bottom: 0;
  height: 94%;
  max-width: 48%;
  object-fit: contain;
  object-position: bottom;
  transform: translateX(-50%);
  filter: drop-shadow(0 8px 18px rgba(0,0,0,.5));
  transition: filter .35s ease, transform .35s ease;
}

.sprite-placeholder {
  bottom: 0;
  height: 75%;
}

.dialogue-wrap {
  position: absolute;
  z-index: 8;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 16px 16px;
  background: transparent;
  pointer-events: none;
}

.dialogue {
  position: relative;
  pointer-events: auto;
  width: 100%;
  max-width: 980px;
  max-height: 62vh;
  overflow-y: auto;
  margin: 0 auto;
  padding: 24px 24px 16px;
  background: linear-gradient(
    180deg,
    rgba(26,19,18,.91),
    rgba(11,8,8,.97)
  );
  border: 1px solid rgba(176,139,91,.6);
  border-radius: 12px;
  box-shadow: 0 -6px 30px rgba(0,0,0,.5);
  backdrop-filter: blur(6px);
}

.speaker {
  color: #d9bc8c;
  font-family: Georgia, serif;
  font-size: 21px;
  margin-bottom: 10px;
}

.dialogue-text {
  color: #efe6d8;
  font-family: Georgia, serif;
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.55;
}

.choice-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.choice-btn {
  min-height: 48px;
  padding: 12px 15px;
  color: #efe6d8;
  background: rgba(176,139,91,.12);
  border: 1px solid rgba(176,139,91,.55);
  border-radius: 8px;
  font-family: Georgia, serif;
  font-size: 17px;
}

.choice-btn:hover:not(:disabled) {
  background: rgba(176,139,91,.28);
}

.dialogue-footer {
  margin-top: 14px;
}

.dialogue-footer small {
  color: #a79b8d;
}

.dialogue .btn.primary {
  color: #f3e6d0;
  background: linear-gradient(#8a6a43, #6b4f31);
  border-color: #b08b5b;
}

.end-actions {
  margin-top: 14px;
}

/* Телефон */
@media (max-width: 700px) {
  .game-top {
    padding: 8px 10px;
  }

  .game-top strong {
    font-size: 12px;
  }

  .game-top .toolbar {
    gap: 4px;
  }

  .game-top .btn {
    padding: 7px 8px;
    font-size: 11px;
  }

  .sprite {
    height: 82%;
    max-width: 55%;
  }

  .dialogue-wrap {
    padding: 20px 8px 8px;
  }

  .dialogue {
    max-height: 65vh;
    padding: 21px 14px 12px;
  }

  .speaker {
    font-size: 18px;
  }

  .dialogue-text {
    font-size: 17px;
    line-height: 1.45;
  }

  .choice-btn {
    min-height: 46px;
    font-size: 16px;
  }
}

/* Телефон горизонтально */
@media (max-height: 520px) and (orientation: landscape) {
  .sprite {
    height: 100%;
    max-width: 36%;
  }

  .dialogue {
    max-height: 68vh;
    padding: 15px 16px 10px;
  }

  .dialogue-text {
    font-size: 15px;
  }

  .choice-btn {
    min-height: 38px;
    padding: 8px 12px;
  }
}

/* Эффект говорящего персонажа */
.sprite {
  transition:
    transform 0.35s ease,
    filter 0.35s ease,
    opacity 0.35s ease;
  transform-origin: bottom center;
  transform: translateX(-50%);
  z-index: 1;
}

.sprite.is-speaking {
  transform: translateX(-50%) scale(1.06);
  filter: brightness(1.08);
  opacity: 1;
  z-index: 2;
}

.sprite.is-dimmed {
  filter: brightness(0.55);
  opacity: 0.65;
}

/* Отражение персонажа */
.sprite.flip {
  scale: -1 1;
}
/* ОФОРМЛЕНИЕ ВСПЛЫВАЮЩИХ НАСТРОЕК */
.settings-modal {
  width: min(420px, calc(100% - 32px));
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-modal h3 {
  margin: 0 0 8px;
}

.settings-modal label {
  display: block;
  font-size: 14px;
}

.settings-select {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  border-radius: 8px;
  font: inherit;
}

.settings-toggle {
  display: flex !important;
  align-items: center;
  gap: 10px;
}

.settings-toggle input {
  width: 18px;
  height: 18px;
}
/* РАЗМЕР ТЕКСТА ДИАЛОГОВ */
.dialogue-text {
  font-size: 18px;
}

body.text-small .dialogue-text {
  font-size: 15px;
}

body.text-medium .dialogue-text {
  font-size: 18px;
}

body.text-large .dialogue-text {
  font-size: 22px;
}
/* ОФОРМЛЕНИЕ ГАМБУРГЕР-МЕНЮ */
.game-menu {
  position: absolute;
  top: 60px;
  left: 16px;
  z-index: 1000;
  width: 240px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #211b20;
  border: 1px solid #66515d;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
/* УПРАВЛЕНИЕ ВИДИМОСТЬЮ МЕНЮ */
.game-menu {
  display: none;
}

.game-menu.open {
  display: flex;
}

.game-menu .menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #fff;
}

.game-menu .menu-item,
.game-menu .menu-close {
  padding: 10px 12px;
  color: #fff;
  background: #382c35;
  border: 1px solid #594451;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}

.game-menu .menu-item:hover,
.game-menu .menu-close:hover {
  background: #594451;
}
/* ВНЕШНИЙ ВИД КНОПКИ ГАМБУРГЕР-МЕНЮ */
.burger {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1100;
  width: 44px;
  height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
  background: #211b20;
  border: 1px solid #66515d;
  border-radius: 8px;
  cursor: pointer;
}

/* ТРИ ГОРИЗОНТАЛЬНЫЕ ПОЛОСКИ */
.burger span {
  display: block;
  width: 21px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
}