:root {
  --bg: #0c0e12;
  --bg-elevated: #141820;
  --bg-card: #171b24;
  --bg-choice: #1d222e;
  --bg-choice-hover: #252c3b;
  --border: #2a3140;
  --border-brass: rgba(201, 162, 75, 0.45);
  --text: #e8e6e1;
  --text-muted: #9da4b4;
  --text-dim: #6f7788;
  --brass: #c9a24b;
  --brass-soft: rgba(201, 162, 75, 0.14);
  --suspicion: #d64550;
  --suspicion-glow: rgba(214, 69, 80, 0.35);
  --defiance: #4f94d4;
  --defiance-glow: rgba(79, 148, 212, 0.35);
  --success: #4caf7d;
  --font-serif: "Georgia", "Cambria", "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Consolas", "SFMono-Regular", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, #151a24 0%, var(--bg) 60%);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 1260px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 20px 24px;
}

/* HUD */
.hud {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(12, 14, 18, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
  margin-bottom: 18px;
}

.hud-top-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.brand-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pov-badge {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--brass-soft);
  color: var(--brass);
  border: 1px solid var(--border-brass);
  font-weight: 600;
}

.chapter-pill {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.hud-actions {
  display: flex;
  gap: 6px;
}

.hud-btn {
  background: var(--bg-choice);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.hud-btn:hover:not(:disabled) {
  background: var(--bg-choice-hover);
  border-color: var(--brass);
}

.hud-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.hud-btn-danger:hover:not(:disabled) {
  border-color: var(--suspicion);
  color: #ff9ca3;
}

.hud-stats-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 20px;
  padding-top: 8px;
  border-top: 1px solid rgba(42, 49, 64, 0.55);
}

.meter-block {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: meterReveal 0.45s ease-out;
}

@keyframes meterReveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.meter-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.meter-pips {
  display: flex;
  gap: 4px;
}

.pip {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: #232836;
  border: 1px solid #343d52;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.pip.filled-suspicion {
  background: var(--suspicion);
  border-color: #f06570;
  box-shadow: 0 0 8px var(--suspicion-glow);
}

.pip.filled-defiance {
  background: var(--defiance);
  border-color: #7ab6ee;
  box-shadow: 0 0 8px var(--defiance-glow);
}

.meter-val {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-dim);
  min-width: 24px;
}

.inventory-block {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}

.inventory-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inv-pill {
  font-size: 0.73rem;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 4px;
  background: #1d2432;
  border: 1px solid #344058;
  color: #d6dce8;
}

.inv-pill.stashed {
  border-color: rgba(201, 162, 75, 0.45);
  color: #e4c982;
}

.inv-pill.flag-active {
  border-color: rgba(76, 175, 125, 0.45);
  color: #8ee0b5;
}

.inv-pill.empty {
  color: var(--text-dim);
  border-style: dashed;
}

/* Main Stage (Cinematic Overlap: Text Left overlapping Faded Left Edge of Right 9:16 Art) */
.stage {
  flex: 1;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  align-items: start;
}

.stage.no-art {
  grid-template-columns: minmax(0, 820px);
  justify-content: center;
}

.stage.no-art .art-backdrop {
  display: none;
}

.stage.no-art .scene-card {
  grid-column: 1;
  margin-right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

/* Right-anchored sticky artwork that extends behind the right edge of the text column */
.art-backdrop {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 96px;
  margin-left: -130px;
  z-index: 1;
}

.art-frame {
  position: relative;
  width: 100%;
  max-width: 540px;
  aspect-ratio: 9 / 16;
  max-height: calc(100vh - 118px);
  margin-left: auto;
  border-radius: 14px;
  overflow: hidden;
  background: #0d1017;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  cursor: zoom-in;
}

.art-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.28s ease;
}

.art-frame img.loaded {
  opacity: 1;
}

/* Soft horizontal fade melting the left edge of the artwork into the dark story backdrop */
.art-fade-left {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to right,
    rgba(12, 14, 18, 0.96) 0%,
    rgba(12, 14, 18, 0.68) 18%,
    rgba(12, 14, 18, 0.22) 38%,
    rgba(12, 14, 18, 0) 60%
  );
}

.art-fade-bottom {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    to top,
    rgba(10, 12, 16, 0.85) 0%,
    rgba(10, 12, 16, 0.15) 18%,
    rgba(10, 12, 16, 0) 35%
  );
}

.art-caption {
  position: absolute;
  right: 0;
  left: 0;
  bottom: 0;
  padding: 20px 16px 12px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: rgba(232, 230, 225, 0.78);
  pointer-events: none;
}

.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(5, 7, 10, 0.96);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  cursor: zoom-out;
}

.lightbox-backdrop img {
  max-height: 94vh;
  max-width: 96vw;
  border-radius: 10px;
  border: 1px solid var(--border-brass);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.8);
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 85;
  background: rgba(20, 24, 32, 0.88);
  color: var(--text);
  border: 1px solid var(--border-brass);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.lightbox-close:hover {
  background: rgba(34, 40, 54, 0.95);
}

.scene-card {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  z-index: 2;
  background: linear-gradient(
    to right,
    rgba(20, 24, 32, 0.94) 0%,
    rgba(20, 24, 32, 0.88) 78%,
    rgba(20, 24, 32, 0.72) 100%
  );
  backdrop-filter: blur(6px);
  border: 1px solid rgba(42, 49, 64, 0.85);
  border-radius: 12px;
  padding: 26px 28px 28px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.22s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.scene-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
}

.scene-restraint {
  color: var(--brass);
  padding: 1px 8px;
  border-radius: 4px;
  background: rgba(201, 162, 75, 0.08);
  border: 1px solid rgba(201, 162, 75, 0.25);
}

.scene-restraint.danger {
  color: #ff9ba3;
  background: rgba(214, 69, 80, 0.12);
  border-color: rgba(214, 69, 80, 0.35);
}

.scene-title {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 600;
  margin: 0 0 18px;
  color: #f4f1ea;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.ending-banner {
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 1px solid var(--border-brass);
  background: linear-gradient(135deg, rgba(201, 162, 75, 0.14), rgba(23, 27, 36, 0.9));
}

.ending-banner.ending-victory {
  border-color: rgba(76, 175, 125, 0.55);
  background: linear-gradient(135deg, rgba(76, 175, 125, 0.16), rgba(23, 27, 36, 0.9));
}

.ending-banner.ending-fatal {
  border-color: rgba(214, 69, 80, 0.6);
  background: linear-gradient(135deg, rgba(214, 69, 80, 0.18), rgba(23, 27, 36, 0.9));
}

.ending-tag {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--brass);
  font-weight: 700;
  margin-bottom: 4px;
}

.ending-banner.ending-victory .ending-tag { color: #7ee2b0; }
.ending-banner.ending-fatal .ending-tag { color: #ff8a93; }

.ending-subtitle {
  font-size: 0.92rem;
  color: var(--text);
}

.scene-prose {
  font-family: var(--font-serif);
  font-size: 1.07rem;
  line-height: 1.76;
  color: #e4e1d9;
}

.scene-prose p {
  margin: 0 0 15px;
}

.scene-prose p:last-child {
  margin-bottom: 0;
}

.scene-prose blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--brass);
  background: rgba(201, 162, 75, 0.06);
  border-radius: 0 6px 6px 0;
  font-family: var(--font-sans);
  font-size: 0.94rem;
  line-height: 1.55;
  color: #dcd9d0;
}

.state-toast {
  margin-top: 18px;
  padding: 9px 13px;
  border-radius: 6px;
  background: rgba(79, 148, 212, 0.1);
  border: 1px solid rgba(79, 148, 212, 0.3);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #b7d7f7;
}

/* Choices */
.choices-section {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.choices-header {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brass);
  margin-bottom: 12px;
}

.choices-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-btn {
  width: 100%;
  text-align: left;
  background: var(--bg-choice);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 13px 16px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.choice-btn:hover {
  background: var(--bg-choice-hover);
  border-color: var(--brass);
  transform: translateX(2px);
}

.choice-num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--brass);
  background: var(--brass-soft);
  border: 1px solid var(--border-brass);
  border-radius: 4px;
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  flex-shrink: 0;
}

.choice-content {
  flex: 1;
}

.choice-label {
  font-size: 0.97rem;
  line-height: 1.45;
  color: #f0eee8;
}

.choice-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.choice-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.choice-tag.tag-req {
  color: #8ee0b5;
  border-color: rgba(76, 175, 125, 0.35);
  background: rgba(76, 175, 125, 0.08);
}

.choice-tag.tag-risk {
  color: #ff9ba3;
  border-color: rgba(214, 69, 80, 0.35);
  background: rgba(214, 69, 80, 0.08);
}

.ending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ending-actions .choice-btn {
  width: auto;
  flex: 1;
  min-width: 180px;
  justify-content: center;
  text-align: center;
}

/* Footer */
.app-footer {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid rgba(42, 49, 64, 0.5);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.8);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-dialog {
  width: 100%;
  max-width: 720px;
  max-height: 85vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: #f4f1ea;
}

.modal-subtitle {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1.3rem;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--brass);
}

.modal-body {
  padding: 16px 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.map-chapter h3 {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brass);
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 8px;
}

.map-node {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.8rem;
}

.map-node.visited {
  border-color: rgba(79, 148, 212, 0.45);
  background: rgba(79, 148, 212, 0.08);
  color: #e2ecf8;
}

.map-node.current {
  border-color: var(--brass);
  background: var(--brass-soft);
  color: #fff3d1;
  font-weight: 600;
}

.map-node.unvisited {
  color: var(--text-dim);
  border-style: dashed;
}

.map-node-id {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.67rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 0 10px 20px;
  }
  .stage {
    display: block;
  }
  .art-backdrop {
    position: sticky;
    top: 68px;
    margin-left: 0;
    z-index: 1;
  }
  .art-frame {
    max-width: 100%;
    max-height: 76vh;
    border-radius: 12px;
  }
  .art-fade-left {
    background: none;
  }
  .art-fade-bottom {
    background: linear-gradient(
      to top,
      rgba(12, 14, 18, 0.98) 0%,
      rgba(12, 14, 18, 0.65) 26%,
      rgba(12, 14, 18, 0) 58%
    );
  }
  .art-caption {
    display: none;
  }
  .scene-card {
    margin-top: -155px;
    position: relative;
    z-index: 3;
    background: rgba(16, 20, 28, 0.88);
    backdrop-filter: blur(10px);
  }
  .stage.no-art .scene-card {
    margin-top: 0;
  }
}

@media (max-width: 600px) {
  .scene-card {
    padding: 18px 16px 22px;
  }
  .scene-title {
    font-size: 1.38rem;
  }
  .scene-prose {
    font-size: 1rem;
  }
}

/* =========================================================================
   TEMPORARY ADMIN REVIEW MODE
   ========================================================================= */
.hud-btn-admin {
  border-color: rgba(201, 162, 75, 0.55);
  color: #f0d28c;
  background: rgba(201, 162, 75, 0.12);
}

.hud-btn-admin:hover {
  background: rgba(201, 162, 75, 0.22);
  border-color: var(--brass);
}

.admin-panel {
  margin-top: 22px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(16, 18, 24, 0.88);
  border: 1px dashed rgba(201, 162, 75, 0.45);
}

.admin-panel.hidden {
  display: none;
}

.admin-panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.admin-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.admin-badge {
  background: rgba(201, 162, 75, 0.22);
  color: #f3d796;
  border: 1px solid rgba(201, 162, 75, 0.5);
  border-radius: 4px;
  padding: 1px 6px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.admin-screen-id {
  color: #e6e2d8;
}

.admin-img-name {
  color: var(--text-muted);
}

.admin-jump-select {
  background: #14171f;
  color: #e6e2d8;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  max-width: 240px;
}

.admin-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.admin-tag-btn {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.12s ease;
}

.admin-tag-btn:hover {
  border-color: var(--brass);
  color: #f0eee8;
}

.admin-tag-btn.active {
  background: rgba(201, 162, 75, 0.22);
  border-color: var(--brass);
  color: #f5db9c;
}

.admin-textarea {
  width: 100%;
  box-sizing: border-box;
  background: #0d1016;
  color: #f0eee8;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.45;
  resize: vertical;
  margin-bottom: 10px;
}

.admin-textarea:focus {
  outline: none;
  border-color: var(--brass);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.admin-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #8ee0b5;
}

.admin-current-notes {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-note-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
  line-height: 1.4;
}

.admin-note-body {
  flex: 1;
}

.admin-note-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #f0d28c;
  margin-bottom: 3px;
}

.admin-note-del {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}

.admin-note-del:hover {
  color: #ff8e96;
  background: rgba(214, 69, 80, 0.16);
}

.admin-modal-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.admin-all-notes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-note-jump {
  background: rgba(201, 162, 75, 0.14);
  border: 1px solid rgba(201, 162, 75, 0.4);
  color: #f0d28c;
  border-radius: 4px;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
  margin-right: 6px;
}

.admin-note-jump:hover {
  background: rgba(201, 162, 75, 0.28);
}

.map-node.admin-clickable {
  cursor: pointer;
}

.map-node.admin-clickable:hover {
  border-color: var(--brass);
}
