/* Lacquer & Lead — main stylesheet */

:root {
  --bg-0: #05050b;
  --bg-1: #0a0a14;
  --bg-2: #14141f;
  --ink-0: #f5f1e8;
  --ink-1: #c9c2b3;
  --ink-2: #8a8473;
  --accent-cyan: #6df0e6;
  --accent-magenta: #ff4f9e;
  --accent-amber: #d4a373;
  --accent-blood: #b21b1b;
  --accent-cold: #4a5e7a;
  --danger: #d63d3d;
  --good: #6df0e6;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
  --serif: 'Cormorant Garamond', 'Georgia', 'Times New Roman', serif;
  --mono: 'JetBrains Mono', 'Menlo', monospace;
  --vh: 100vh;
  --vh-actual: 100vh;
}

@supports (height: 100dvh) {
  :root { --vh-actual: 100dvh; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-0);
  color: var(--ink-0);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  overflow: hidden;
  height: var(--vh-actual);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  /* CRT-ish grain overlay */
  content: '';
  position: fixed; inset: 0;
  background-image: radial-gradient(circle at center, transparent 50%, rgba(0,0,0,0.45) 100%);
  pointer-events: none;
  z-index: 1000;
  mix-blend-mode: multiply;
}

.app {
  position: relative;
  width: 100vw;
  height: var(--vh-actual);
  overflow: hidden;
}

/* === STAGE === */

.stage {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.stage__bg {
  position: absolute;
  inset: 0;
  background-color: var(--bg-1);
  background-size: cover;
  background-position: center;
  filter: contrast(1.05) saturate(0.85) brightness(0.85);
  transition: opacity 600ms ease, filter 600ms ease;
}

.stage__bg.is-loading {
  filter: blur(20px) brightness(0.5);
}

.stage__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 35%, rgba(0,0,0,0.7) 100%);
  pointer-events: none;
}

.stage__characters {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4%;
  padding-bottom: 22vh;
}

.character {
  position: relative;
  height: 70vh;
  max-height: 70vh;
  filter: drop-shadow(0 14px 24px rgba(0,0,0,0.7));
  transform: translateY(20px);
  opacity: 0;
  transition: opacity 500ms ease, transform 500ms ease;
}

.character.is-shown {
  opacity: 1;
  transform: translateY(0);
}

.character img {
  height: 100%;
  width: auto;
  display: block;
  object-fit: contain;
  mask-image: linear-gradient(to bottom, black 75%, transparent 100%);
}

.character[data-position="left"]  { align-self: flex-end; }
.character[data-position="right"] { align-self: flex-end; }
.character[data-position="center"]{ z-index: 2; }

.stage__title {
  position: absolute;
  top: 12vh;
  left: 0; right: 0;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 800ms ease;
}
.stage__title.is-shown { opacity: 1; }
.stage__title h1 {
  font-family: var(--serif);
  font-size: clamp(38px, 7vw, 92px);
  font-weight: 400;
  letter-spacing: 0.04em;
  margin: 0;
  color: var(--ink-0);
  text-shadow: 0 4px 24px rgba(0,0,0,0.6), 0 0 40px rgba(109, 240, 230, 0.15);
}
.stage__title .subtitle {
  margin: 4px 0 0;
  font-size: 18px;
  letter-spacing: 0.3em;
  color: var(--accent-cyan);
  text-transform: uppercase;
}

/* === HUD === */

.hud {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 30;
  width: 260px;
  background: rgba(10, 10, 20, 0.78);
  border: 1px solid rgba(109, 240, 230, 0.15);
  border-radius: 8px;
  padding: 12px 14px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.hud.is-hidden { display: none; }

.hud__chapter {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 10px;
}
.hud__label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.hud__chapter-num {
  font-family: var(--serif);
  font-size: 18px;
  font-style: italic;
  color: var(--accent-cyan);
}

.hud__bars { display: flex; flex-direction: column; gap: 8px; }

.bar {
  display: grid;
  grid-template-columns: 80px 1fr 32px;
  gap: 8px;
  align-items: center;
  font-family: var(--mono);
  font-size: 11px;
}

.bar__label {
  color: var(--ink-2);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.bar__track {
  position: relative;
  height: 5px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}

.bar__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--accent-cyan);
  transition: width 400ms ease, background 300ms ease;
}

.bar__fill.is-warn  { background: var(--accent-amber); }
.bar__fill.is-danger{ background: var(--danger); }
.bar__fill.is-good  { background: var(--good); }

.bar__value {
  text-align: right;
  color: var(--ink-1);
  font-weight: 600;
}

.hud__details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.hud__details summary {
  cursor: pointer;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.hud__relations {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hud__relations li {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
}
.hud__relations .name { color: var(--ink-1); }
.hud__relations .val  { color: var(--ink-2); }
.hud__relations .val.is-high { color: var(--good); }
.hud__relations .val.is-low  { color: var(--danger); }

.hud__hints {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* === TEXTBOX === */

.textbox {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  z-index: 20;
  padding: 24px 32px 28px;
  min-height: 22vh;
  background: linear-gradient(180deg, transparent 0%, rgba(5,5,11,0.86) 30%, rgba(5,5,11,0.96) 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
}

.textbox.is-active { cursor: pointer; }
.textbox.is-waiting .textbox__hint { opacity: 1; }

.textbox__speaker {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  min-height: 22px;
}

.textbox__body {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.5;
  color: var(--ink-0);
  max-width: 920px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

.textbox__body.is-narration {
  font-style: italic;
  color: var(--ink-1);
}

.textbox__hint {
  position: absolute;
  bottom: 8px;
  right: 28px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.15em;
  opacity: 0;
  transition: opacity 300ms ease;
}

/* === CHOICES === */

.choices {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(5, 5, 11, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.choices[hidden] { display: none; }

.choices__inner {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choices__prompt {
  font-family: var(--serif);
  font-size: 26px;
  font-style: italic;
  color: var(--ink-1);
  margin: 0 0 12px;
  text-align: center;
}

.choice {
  background: rgba(20, 20, 31, 0.92);
  border: 1px solid rgba(109, 240, 230, 0.18);
  border-left: 3px solid var(--accent-cyan);
  color: var(--ink-0);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.4;
  padding: 16px 20px;
  text-align: left;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease, transform 120ms ease;
}

.choice:hover, .choice:focus {
  background: rgba(30, 30, 50, 0.95);
  border-color: var(--accent-cyan);
  outline: none;
  transform: translateX(4px);
}

.choice.is-irreversible {
  border-left-color: var(--danger);
  color: var(--ink-1);
}
.choice.is-irreversible::after {
  content: ' · необратимо';
  font-size: 12px;
  color: var(--danger);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: var(--mono);
}

.choice__hint {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  letter-spacing: 0.05em;
}
.choice__hint .up   { color: var(--good); }
.choice__hint .down { color: var(--danger); }

/* === MENU === */

.menu {
  position: absolute;
  inset: 0;
  z-index: 50;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 79, 158, 0.08), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(109, 240, 230, 0.08), transparent 50%),
    linear-gradient(180deg, #05050b 0%, #14141f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.menu.is-hidden { display: none; }

.menu__inner {
  text-align: center;
  max-width: 560px;
  padding: 32px;
}

.menu__title {
  font-family: var(--serif);
  font-size: clamp(48px, 8vw, 96px);
  font-weight: 400;
  letter-spacing: 0.04em;
  margin: 0 0 4px;
  text-shadow: 0 0 60px rgba(109, 240, 230, 0.3);
}

.menu__subtitle {
  margin: 0 0 28px;
  font-size: 16px;
  letter-spacing: 0.3em;
  color: var(--accent-cyan);
  text-transform: uppercase;
}

.menu__tagline {
  margin: 0 0 36px;
  font-style: italic;
  color: var(--ink-2);
}

.menu__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-bottom: 32px;
}

.btn {
  font-family: var(--serif);
  font-size: 19px;
  padding: 14px 28px;
  min-width: 240px;
  background: rgba(20, 20, 31, 0.8);
  color: var(--ink-0);
  border: 1px solid rgba(109, 240, 230, 0.3);
  border-radius: 4px;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease;
}
.btn:hover:not(:disabled), .btn:focus:not(:disabled) {
  background: rgba(30, 30, 50, 0.95);
  border-color: var(--accent-cyan);
  outline: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn--primary {
  background: var(--accent-cyan);
  color: var(--bg-0);
  font-weight: 600;
  border-color: var(--accent-cyan);
}
.btn--primary:hover:not(:disabled) {
  background: #9bf7ec;
  border-color: #9bf7ec;
}
.btn--ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.15);
}

.menu__warnings {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.6;
  letter-spacing: 0.05em;
}
.menu__warnings p { margin: 4px 0; }

.menu__status {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
}

/* === MODAL / SLOTS === */

.modal {
  background: var(--bg-1);
  color: var(--ink-0);
  border: 1px solid rgba(109, 240, 230, 0.3);
  border-radius: 8px;
  padding: 0;
  max-width: 560px;
  width: 90vw;
}
.modal::backdrop { background: rgba(5, 5, 11, 0.8); backdrop-filter: blur(4px); }
.modal__inner { padding: 24px; }
.modal__inner h2 { margin: 0 0 16px; font-family: var(--serif); font-weight: 400; }

.slots {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}
.slots li {
  display: grid;
  grid-template-columns: 60px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: rgba(20, 20, 31, 0.6);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 4px;
}
.slots .slot__num {
  font-family: var(--mono);
  color: var(--accent-cyan);
}
.slots .slot__info {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-1);
}
.slots .slot__actions { display: flex; gap: 4px; }
.slots button {
  background: transparent;
  border: 1px solid rgba(109, 240, 230, 0.3);
  color: var(--ink-1);
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 3px;
  cursor: pointer;
}
.slots button:hover { background: rgba(109, 240, 230, 0.1); }
.slots button.danger { border-color: var(--danger); color: var(--danger); }

.menu dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin: 0;
}
.menu dialog button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--ink-1);
  font-family: var(--serif);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
}

/* === TOAST === */

.toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  z-index: 100;
  background: rgba(10, 10, 20, 0.96);
  border: 1px solid var(--accent-cyan);
  border-radius: 6px;
  padding: 16px 24px;
  font-family: var(--serif);
  font-size: 18px;
  color: var(--ink-0);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease, transform 250ms ease;
}
.toast.is-shown {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* === ACCESSIBILITY === */

@media (prefers-reduced-motion: reduce) {
  .stage__bg, .character, .stage__title, .toast {
    transition-duration: 0ms !important;
  }
}

@media (max-width: 720px) {
  .hud { width: 200px; font-size: 11px; }
  .textbox__body { font-size: 18px; }
  .choices__prompt { font-size: 20px; }
  .choice { font-size: 16px; padding: 12px 14px; }
  .stage__characters { padding-bottom: 24vh; gap: 2%; }
  .character { height: 60vh; }
}
