:root {
  --bg: #090b0d;
  --panel: rgba(9, 12, 15, 0.88);
  --panel-strong: rgba(7, 9, 11, 0.96);
  --text: #f4efe6;
  --muted: #b8ad9d;
  --gold: #c99545;
  --gold-light: #e4bd76;
  --line: rgba(213, 164, 86, 0.32);
  --danger: #bd4f54;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.48);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { overflow-x: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100svh; }
.screen { display: none; min-height: 100svh; position: relative; }
.screen.active { display: flex; }
.hidden { display: none !important; }

.creator-screen {
  align-items: center;
  justify-content: center;
  padding: max(26px, env(safe-area-inset-top)) 18px max(30px, env(safe-area-inset-bottom));
  overflow: hidden;
}
.creator-bg {
  position: fixed;
  inset: 0;
  background: url("assets/images/hotel.webp") center/cover no-repeat;
  transform: scale(1.035);
}
.creator-overlay {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4,6,8,.5), rgba(4,6,8,.82)),
    radial-gradient(circle at 50% 20%, rgba(176,112,35,.13), transparent 42%);
  backdrop-filter: blur(2px);
}
.creator-card {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(9,12,15,.9), rgba(5,7,9,.97));
  box-shadow: var(--shadow);
  border-radius: 24px;
  padding: clamp(24px, 4vw, 42px);
}
.brand-block { text-align: center; margin-bottom: 28px; }
.eyebrow { margin: 0 0 8px; letter-spacing: .28em; font-size: .78rem; color: var(--gold-light); }
h1, h2, .scene-kicker { font-family: Georgia, "Times New Roman", serif; }
h1 { margin: 0; font-size: clamp(2rem, 6vw, 3.7rem); font-weight: 500; line-height: 1.05; }
.tagline { margin: 14px auto 0; max-width: 560px; color: var(--muted); line-height: 1.55; }

.creator-form { display: grid; gap: 22px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend, .field > span { display: block; margin-bottom: 10px; color: #e8dfd1; font-size: .94rem; }
.field input[type="text"], .field select {
  width: 100%;
  padding: 14px 15px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.045);
  color: var(--text);
  outline: none;
}
.field input[type="text"]:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,149,69,.12); }
.field select { padding: 13px 42px 13px 14px; appearance: auto; }
.field select option { background: #0b0e11; color: var(--text); }
.choice-grid { display: grid; gap: 10px; }
.choice-grid.three { grid-template-columns: repeat(3, 1fr); }
.choice-grid.two { grid-template-columns: repeat(2, 1fr); }
.select-card { position: relative; min-width: 0; }
.select-card input { position: absolute; opacity: 0; pointer-events: none; }
.select-card > span, .select-card > small { display: block; }
.select-card {
  min-height: 82px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 13px;
  background: rgba(255,255,255,.035);
  transition: .18s ease;
}
.select-card span { font-weight: 650; }
.select-card small { margin-top: 5px; color: var(--muted); font-size: .75rem; }
.select-card.compact { min-height: 56px; display: grid; align-items: center; }
.select-card:hover { border-color: rgba(218,176,106,.55); transform: translateY(-1px); }
.select-card:has(input:checked) {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(201,149,69,.2), rgba(201,149,69,.055));
  box-shadow: inset 0 0 0 1px rgba(255,215,145,.08);
}
.toggle-row { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; background: rgba(255,255,255,.03); }
.toggle-row input { width: 20px; height: 20px; accent-color: var(--gold); }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row small { color: var(--muted); margin-top: 3px; }
.primary-button, .secondary-button, .next-button, .voice-button, .back-button {
  min-height: 48px;
  border-radius: 13px;
  border: 1px solid transparent;
  padding: 12px 18px;
  color: var(--text);
}
.primary-button, .next-button {
  background: linear-gradient(135deg, #9b672a, #c48a39);
  border-color: rgba(255,222,163,.25);
  box-shadow: 0 10px 25px rgba(137,86,31,.22);
  font-weight: 750;
}
.secondary-button, .voice-button { background: rgba(255,255,255,.055); border-color: rgba(255,255,255,.13); }
.back-button { background: transparent; border-color: rgba(255,255,255,.1); color: rgba(238,229,215,.68); padding-inline: 11px; font-size: .82rem; }
.back-button:hover { color: var(--gold-light); border-color: rgba(201,149,69,.35); background: rgba(255,255,255,.025); }
.primary-button:hover, .next-button:hover { filter: brightness(1.08); }

.story-screen { min-height: 100svh; align-items: flex-end; overflow: hidden; background: #030506; }
.scene-image {
  position: fixed;
  inset: 0;
  background-position: center;
  background-size: cover;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity .55s ease, transform 7s ease;
}
.scene-image.loaded { opacity: 1; transform: scale(1); }
.scene-shade {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0,0,0,.2) 0%, rgba(0,0,0,.08) 34%, rgba(2,4,6,.82) 75%, rgba(2,4,6,.97) 100%),
    linear-gradient(90deg, rgba(0,0,0,.24), transparent 48%, rgba(0,0,0,.14));
}
.story-header {
  position: fixed;
  z-index: 5;
  left: 0; right: 0; top: 0;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 15px 12px;
  background: linear-gradient(180deg, rgba(4,6,8,.9), transparent);
}
.icon-button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); background: rgba(9,12,15,.58); color: var(--text); font-size: 1.15rem; }
.progress-wrap { display: grid; gap: 7px; text-align: center; }
#chapter-label { font-size: .77rem; letter-spacing: .12em; text-transform: uppercase; color: #ead9bd; }
.progress-track { height: 3px; border-radius: 999px; background: rgba(255,255,255,.18); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #9a682e, #e4bc73); transition: width .3s ease; }
.stats-panel {
  position: fixed;
  z-index: 5;
  top: max(76px, calc(env(safe-area-inset-top) + 70px));
  right: 14px;
  display: flex;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 999px;
  background: rgba(7,9,11,.64);
  backdrop-filter: blur(10px);
  font-size: .78rem;
  color: var(--gold-light);
}
.stats-panel b { color: var(--text); }

.content-panel {
  position: relative;
  z-index: 3;
  width: min(760px, calc(100% - 20px));
  margin: 0 auto max(10px, env(safe-area-inset-bottom));
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid rgba(214,167,92,.28);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(10,13,16,.78), rgba(5,7,9,.96));
  box-shadow: 0 25px 70px rgba(0,0,0,.42);
  backdrop-filter: blur(13px);
  max-height: min(68svh, 760px);
  overflow: auto;
  scrollbar-width: thin;
}
.scene-kicker { color: var(--gold-light); font-size: 1.1rem; letter-spacing: .04em; margin-bottom: 9px; }
.scene-content { line-height: 1.65; font-size: clamp(1rem, 2.3vw, 1.13rem); }
.scene-content p { margin: 0 0 12px; }
.scene-content p:last-child { margin-bottom: 0; }
.dialogue { color: #fff7e9; border-left: 2px solid var(--gold); padding-left: 13px; font-style: italic; }
.dialogue.leon::before { content: "Leon"; display: block; font-style: normal; font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-light); margin-bottom: 2px; }
.dialogue.unknown::before { content: "Nieznany numer"; display: block; font-style: normal; font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: #b8c5cc; margin-bottom: 2px; }
.dialogue.woman::before { content: "Kobieta w czerwieni"; display: block; font-style: normal; font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-light); margin-bottom: 2px; }

.chat-window { display: grid; gap: 9px; padding: 4px 0; }
.chat-message { max-width: 82%; padding: 10px 12px; border-radius: 14px; line-height: 1.45; font-size: .96rem; box-shadow: 0 8px 22px rgba(0,0,0,.14); }
.chat-message.incoming { justify-self: start; background: rgba(255,255,255,.09); border-bottom-left-radius: 4px; }
.chat-message.outgoing { justify-self: end; background: rgba(157,105,40,.78); border-bottom-right-radius: 4px; }
.chat-time { display: block; font-size: .66rem; color: rgba(255,255,255,.58); text-align: right; margin-top: 4px; }

.choices { display: grid; gap: 10px; margin-top: 18px; }
.choice-button {
  width: 100%;
  text-align: left;
  color: var(--text);
  border: 1px solid rgba(213,164,86,.36);
  background: linear-gradient(135deg, rgba(201,149,69,.12), rgba(255,255,255,.035));
  padding: 13px 14px;
  border-radius: 13px;
  line-height: 1.35;
  transition: .16s ease;
}
.choice-button:hover { border-color: var(--gold); transform: translateY(-1px); background: rgba(201,149,69,.18); }
.choice-button small { display: block; margin-top: 4px; color: var(--muted); }
.story-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 18px; }
.story-actions .back-button { margin-right: auto; }
.voice-button.speaking { border-color: var(--gold); color: var(--gold-light); }
.next-button { min-width: 132px; }

.ending-card { text-align: center; padding: 8px 0; }
.ending-card h2 { font-size: clamp(1.8rem, 6vw, 3rem); margin: 4px 0 12px; font-weight: 500; }
.ending-card .ending-quote { font-family: Georgia, serif; color: var(--gold-light); font-size: 1.15rem; line-height: 1.55; }
.ending-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 18px 0; }
.ending-summary div { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.11); border-radius: 12px; padding: 12px 8px; }
.ending-summary b { display:block; font-size:1.3rem; color: var(--gold-light); }
.ending-buttons { display: grid; gap: 10px; margin-top: 18px; }

.settings-dialog {
  width: min(480px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  color: var(--text);
  background: #0b0e11;
  box-shadow: var(--shadow);
}
.settings-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }
.settings-dialog form { padding: 22px; display: grid; gap: 18px; }
.settings-dialog header { display:flex; justify-content:space-between; align-items:center; }
.settings-dialog h2 { margin: 0; }
.dialog-toggle { padding: 12px; }
#speech-rate { width: 100%; accent-color: var(--gold); }
.dialog-note { color: var(--muted); line-height: 1.5; font-size: .88rem; margin:0; }
.confirm-dialog p { color: var(--muted); }
.dialog-buttons { display:grid; grid-template-columns:1fr 1fr; gap:10px; }

@media (max-width: 620px) {
  .creator-card { padding: 24px 17px; border-radius: 18px; }
  .choice-grid.three { grid-template-columns: 1fr; }
  .select-card { min-height: auto; }
  .content-panel { width: calc(100% - 12px); border-radius: 18px; padding: 19px 17px; max-height: 64svh; }
  .story-actions { position: sticky; bottom: -19px; margin-inline: -17px; padding: 13px 17px 1px; background: linear-gradient(180deg, transparent, rgba(5,7,9,.98) 32%); }
  .scene-image { background-position: center top; }
}

@media (min-width: 900px) {
  .content-panel { margin-bottom: 24px; }
  .scene-image { background-position: center 30%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.feedback-form {
  display: grid;
  gap: 13px;
  margin-top: 22px;
  padding: 17px;
  border: 1px solid rgba(213,164,86,.27);
  border-radius: 15px;
  background: rgba(255,255,255,.035);
  text-align: left;
}
.feedback-form h3 { margin: 0; color: var(--gold-light); font-family: Georgia, serif; font-size: 1.22rem; }
.feedback-note { margin: 0 !important; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.rating-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rating-row label { cursor: pointer; }
.rating-row input { position: absolute; opacity: 0; pointer-events: none; }
.rating-row span {
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: rgba(255,255,255,.045);
  color: var(--text);
  font-weight: 750;
  transition: .15s ease;
}
.rating-row input:checked + span,
.rating-row label:hover span { border-color: var(--gold); background: rgba(201,149,69,.22); color: var(--gold-light); }
.feedback-field { display: grid; gap: 7px; color: #ead9bd; font-size: .9rem; }
.feedback-field select,
.feedback-field textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 11px;
  background: rgba(4,7,9,.76);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
}
.feedback-field textarea { resize: vertical; min-height: 82px; }
.send-status { margin: 0 !important; min-height: 1.3em; color: var(--muted); font-size: .85rem; line-height: 1.45; text-align: center; }
.send-status.success { color: #9fe0b1; }
.send-status.error { color: #ffb0a5; }
.ending-buttons .primary-button:disabled { opacity: .72; cursor: wait; }

/* ===== Moja Legenda 0.3 ===== */
button, input, select, textarea { font: inherit; }

.format-explainer {
  margin: 0 0 26px;
  padding: 17px;
  border: 1px solid rgba(213,164,86,.25);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(201,149,69,.11), rgba(255,255,255,.025));
}
.format-explainer h2 { margin: 0 0 8px; font-size: 1.25rem; font-weight: 500; color: var(--gold-light); }
.format-explainer p { margin: 0; color: #d4cabc; line-height: 1.55; font-size: .94rem; }
.format-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.format-steps span { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 9px; border-radius: 11px; background: rgba(0,0,0,.2); color: #ece2d3; font-size: .76rem; line-height: 1.3; }
.format-steps b { flex: 0 0 24px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: rgba(201,149,69,.24); color: var(--gold-light); }
.voice-preview-toggle { opacity: .92; }

.scene-shade {
  background:
    linear-gradient(180deg, rgba(0,0,0,.18) 0%, rgba(0,0,0,.04) 45%, rgba(2,4,6,.34) 68%, rgba(2,4,6,.88) 100%),
    linear-gradient(90deg, rgba(0,0,0,.18), transparent 48%, rgba(0,0,0,.1));
}

.content-panel {
  width: min(700px, calc(100% - 18px));
  padding: 16px 18px 15px;
  max-height: min(49svh, 570px);
  background: linear-gradient(180deg, rgba(10,13,16,.66), rgba(5,7,9,.91));
  backdrop-filter: blur(10px);
  transition: width .2s ease, max-height .2s ease, padding .2s ease, background .2s ease;
  overflow: auto;
}
.content-panel.is-choice { max-height: min(65svh, 720px); }
.content-panel.is-chat { max-height: min(58svh, 650px); }
.content-panel.is-ending { max-height: min(84svh, 900px); }
.content-panel.is-prologue {
  max-width: 620px;
  background: linear-gradient(180deg, rgba(8,10,12,.56), rgba(5,7,9,.88));
}
.panel-body { display: block; }
.panel-toggle {
  position: sticky;
  top: -8px;
  z-index: 4;
  float: right;
  margin: -6px -7px 5px 12px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: rgba(4,7,9,.72);
  color: #d7c9b4;
  font-size: .72rem;
  backdrop-filter: blur(8px);
}
.content-panel.collapsed {
  width: auto;
  max-width: calc(100% - 28px);
  max-height: 52px;
  padding: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(5,7,9,.58);
}
.content-panel.collapsed .panel-body { display: none; }
.content-panel.collapsed .panel-toggle { position: static; float: none; margin: 0; }
.scene-content { line-height: 1.54; font-size: clamp(.96rem, 2.15vw, 1.08rem); }
.scene-content p { margin: 0 0 9px; }
.scene-kicker { margin-bottom: 7px; font-size: 1.02rem; }
.story-actions { margin-top: 13px; }
.choices { margin-top: 13px; gap: 8px; }
.choice-button { padding: 11px 13px; }

.settings-dialog select {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 11px;
  background: #101419;
  color: var(--text);
}

@media (max-width: 620px) {
  .creator-screen { align-items: flex-start; overflow: auto; }
  .creator-card { margin: 6px 0; }
  .format-steps { grid-template-columns: 1fr; }
  .content-panel {
    width: calc(100% - 10px);
    max-height: 42svh;
    padding: 14px 15px 13px;
    border-radius: 16px;
    margin-bottom: max(5px, env(safe-area-inset-bottom));
  }
  .content-panel.is-prologue { max-height: 40svh; }
  .content-panel.is-choice { max-height: 63svh; }
  .content-panel.is-chat { max-height: 56svh; }
  .content-panel.is-ending { max-height: 88svh; }
  .story-actions {
    bottom: -14px;
    margin-inline: -15px;
    padding: 10px 15px 0;
  }
  .scene-image { background-position: center 30%; }
  .stats-panel { top: max(72px, calc(env(safe-area-inset-top) + 66px)); }
  .scene-content { font-size: .98rem; line-height: 1.5; }
  .scene-content p { margin-bottom: 8px; }
  .panel-toggle { top: -6px; }
}

/* 0.3.2: krótkie sceny bez przewijania ramki narracyjnej */
.content-panel.is-narrative,
.content-panel.is-prologue {
  max-height: none;
  overflow: hidden;
}

@media (max-width: 620px) {
  .content-panel.is-narrative,
  .content-panel.is-prologue {
    max-height: none;
    overflow: hidden;
  }
}

/* Legend Engine 1.0 — karty podsumowania po odcinku */
.social-summary {
  margin-top: 1.4rem;
  padding: 1rem;
  border: 1px solid rgba(218, 183, 105, 0.28);
  border-radius: 16px;
  background: rgba(10, 12, 15, 0.58);
}

.social-summary h3 {
  margin: 0 0 0.4rem;
  color: var(--gold-light);
  font-family: Georgia, serif;
}

.social-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-top: 0.8rem;
}

@media (max-width: 560px) {
  .social-card-actions {
    grid-template-columns: 1fr;
  }
}


/* Nawigacja po zakończeniu odcinka */
.episode-navigation {
  margin-top: 18px;
  padding-top: 17px;
  border-top: 1px solid rgba(213,164,86,.24);
}
.episode-navigation h3 {
  margin: 0 0 6px;
  color: var(--gold-light);
  font-family: Georgia, serif;
  font-weight: 500;
}
.episode-navigation-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.episode-navigation-actions > button { width: 100%; }
.episode-navigation-actions > button:disabled {
  opacity: .55;
  cursor: not-allowed;
  filter: grayscale(.25);
}
@media (max-width: 620px) {
  .episode-navigation-actions { grid-template-columns: 1fr; }
}


/* Aurora V6 local test overrides */
.stats-panel:empty, .stats-panel.hidden { display:none !important; }
.creator-card { max-width: 760px; }
.creator-card .format-explainer { margin-bottom: 1.2rem; }
.scene-content p { line-height: 1.58; }
.choice-button strong { font-size: 1.02rem; }
.choice-button small { line-height: 1.35; }


/* Aurora — finał jako osobny moment historii */
.final-share {
  margin-top: 1.8rem;
  padding: 1.15rem;
  border: 1px solid rgba(218, 183, 105, 0.34);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(13,15,19,.76), rgba(8,10,13,.62));
  text-align: left;
}
.final-memory {
  margin: 0 0 .35rem;
  color: #d8c9a7;
  font-size: .92rem;
  letter-spacing: .02em;
}
.final-share h3 {
  margin: 0 0 .75rem;
  color: var(--gold-light);
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 500;
}
.final-route-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 0;
  border-top: 1px solid rgba(255,255,255,.07);
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.final-route-line span { color: #938a7b; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; }
.final-route-line strong { color: #f1ddb0; font-family: Georgia, serif; font-weight: 500; text-align: right; }
.social-card-actions--final { grid-template-columns: 1.2fr 1fr 1fr; }
.final-next-button { width: 100%; margin-top: 1.15rem; }
.aftercare-panel {
  margin-top: 1.6rem;
  padding-top: .3rem;
  border-top: 1px solid rgba(218,183,105,.20);
  animation: aftercare-in .35s ease both;
}
@keyframes aftercare-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.ending-hook { margin-top: 1rem; }
@media (max-width: 720px) {
  .social-card-actions--final { grid-template-columns: 1fr; }
  .final-route-line { align-items: flex-start; flex-direction: column; gap: .35rem; }
  .final-route-line strong { text-align: left; }
}
