  @import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=IBM+Plex+Mono:wght@400;600&display=swap');

  :root {
    --bg: #0b0d10;
    --panel: rgba(10, 12, 15, 0.78);
    --panel-strong: rgba(12, 15, 19, 0.92);
    --text: #e6e2d8;
    --muted: #9aa3a7;
    --accent: #d9b44a;
    --ok: #44d7b6;
    --warn: #ff9f45;
    --danger: #ff6b6b;
  }

  * { box-sizing: border-box; }
  html, body { width: 100%; height: 100%; margin: 0; }
  body {
    background: radial-gradient(1100px 800px at 70% 20%, #151b22 0%, var(--bg) 70%);
    font-family: 'Cinzel', Georgia, serif;
    color: var(--text);
    overflow: hidden;
  }

  canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 1;
  }

  #hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
  }

  .hud-wrap {
    display: grid;
    grid-template-columns: minmax(240px, 320px) 1fr;
    gap: 16px;
    padding: 16px;
    height: 100%;
    align-items: start;
    animation: fadeIn 0.6s ease-out;
  }

  .panel {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  }

  .panel.log {
    max-height: calc(100vh - 32px);
    overflow: auto;
  }

  .panel-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 6px;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
  }

  #title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
  }

  #status {
    font-size: 12px;
    color: var(--muted);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
  }

  .inventory, .meta {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 12px;
    line-height: 1.45;
  }

  .log {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 14px;
    line-height: 1.6;
  }

  .inventory ul, .log ul {
    list-style: none;
    padding: 0;
    margin: 6px 0 0 0;
  }

  .inventory li, .log li {
    padding: 4px 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 6px;
  }

  .log li {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid rgba(217, 180, 74, 0.35);
  }

  .log li.done { color: rgba(230, 226, 216, 0.92); }
  .log li.active {
    border-left-color: rgba(68, 215, 182, 0.7);
    background: rgba(68, 215, 182, 0.08);
    color: var(--text);
  }

  .meta-line {
    display: flex;
    justify-content: space-between;
    gap: 10px;
  }

  #objective {
    font-size: 14px;
    margin: 4px 0 10px 0;
    color: var(--text);
    font-family: 'Cinzel', Georgia, serif;
  }

  #prompt {
    position: absolute;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 12px;
    letter-spacing: 0.04em;
    pointer-events: none;
  }

  #debug {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 11px;
    color: var(--muted);
    white-space: pre;
    pointer-events: none;
  }

  #dialog {
    position: absolute;
    left: 50%;
    bottom: 80px;
    transform: translateX(-50%);
    width: min(680px, 92vw);
    padding: 12px 16px 18px;
    background: rgba(6, 6, 8, 0.94);
    border: 2px solid rgba(230, 226, 216, 0.9);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.5), 0 16px 32px rgba(0, 0, 0, 0.45);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 13px;
    line-height: 1.5;
    letter-spacing: 0.04em;
    color: var(--text);
    display: none;
    pointer-events: none;
  }

  #dialog.active { display: block; }

  #dialog.ready .dialog-continue { opacity: 1; }

  #dialogText { white-space: pre-line; }

  .dialog-continue {
    margin-top: 8px;
    text-align: right;
    font-size: 11px;
    color: var(--muted);
    opacity: 0;
    animation: dialogBlink 1.1s steps(2, start) infinite;
  }

  #reticle {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 10px;
    height: 10px;
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
  }

  .node-label {
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    transform: translateY(-8px);
    white-space: nowrap;
  }

  .legend {
    position: absolute;
    right: 18px;
    bottom: 18px;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 11px;
    color: var(--muted);
    text-align: right;
  }

  .legend span { display: block; margin-bottom: 4px; }

  #mapOverlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(4, 5, 7, 0.66);
    z-index: 4;
    pointer-events: none;
  }

  #mapOverlay.active { display: flex; }

  .mapCard {
    width: min(84vw, 840px);
    height: min(84vh, 840px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 18px;
    background: var(--panel-strong);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  }

  .mapHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
  }

  .mapHeader b {
    color: var(--text);
    font-weight: 600;
  }

  #mapCanvas {
    flex: 1;
    width: 100%;
    height: 100%;
    border-radius: 14px;
    background: rgba(7, 9, 12, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }

  .mapLegend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 11px;
    color: var(--muted);
  }

  #journalOverlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(4, 5, 7, 0.7);
    z-index: 5;
    pointer-events: none;
  }

  #journalOverlay.active { display: flex; }

  .journalCard {
    width: min(88vw, 860px);
    max-height: min(86vh, 920px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 18px;
    background: var(--panel-strong);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 28px 64px rgba(0, 0, 0, 0.6);
  }

  .journalHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
  }

  .journalHeader b {
    color: var(--text);
    font-weight: 600;
  }

  .journalBody {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: auto;
    padding-right: 4px;
  }

  .journalSectionTitle {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
  }

  .journalActive {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(68, 215, 182, 0.08);
    border-left: 3px solid rgba(68, 215, 182, 0.7);
    font-size: 14px;
  }

  #photoOverlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(4, 5, 7, 0.72);
    z-index: 6;
    pointer-events: none;
  }

  #photoOverlay.active { display: flex; }

  .photoFrame {
    width: min(90vw, 860px);
    max-height: min(86vh, 900px);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-radius: 18px;
    background: var(--panel-strong);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 26px 60px rgba(0, 0, 0, 0.6);
  }

  .photoHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
  }

  .photoHeader b {
    color: var(--text);
    font-weight: 600;
  }

  .photoBody {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 7, 9, 0.6);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px;
  }

  #photoImage {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
  }

  .photoCaption {
    font-family: 'IBM Plex Mono', ui-monospace, monospace;
    font-size: 12px;
    color: var(--muted);
    text-align: right;
  }

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

  @keyframes dialogBlink {
    0%, 60% { opacity: 1; }
    100% { opacity: 0; }
  }

  @media (max-width: 900px) {
    .hud-wrap { grid-template-columns: 1fr; }
    #reticle { display: none; }
  }
