/* ============================================================
   LIBRARY OF BABEL — 8-bit stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black:   #000000;
  --gold:    #b58b4a;
  --danger:  #9b3a32;
  --text:    #eadfca;
  --muted:   #6a5a44;
  --parch:   #e8d4a8;
  --ink:     #1a1008;
  --font:    'Press Start 2P', monospace;
}

html, body {
  height: 100%;
  background: var(--black);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  image-rendering: pixelated;
}

/* ── Layout ─────────────────────────────────────────────── */
#game-root {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 12px;
}

/* ── HUD ────────────────────────────────────────────────── */
#hud {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 560px;
}

#sanity-label {
  font-size: 7px;
  color: var(--muted);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

#sanity-track {
  flex: 1;
  height: 8px;
  background: #111;
  border: 1px solid #2a1e16;
}

#sanity-fill {
  height: 100%;
  background: var(--gold);
}

#sanity-text {
  font-size: 7px;
  color: var(--muted);
  min-width: 60px;
  text-align: right;
}

/* ── Canvas ─────────────────────────────────────── */
#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}


/* ── Book Panel ────────────────────────────────────── */
#book-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
}

#book-panel.hidden { display: none; }

#book-inner {
  background: url('paper.png') center / cover no-repeat;
  width: min(480px, 88vw);
  aspect-ratio: 4 / 3;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#book-title {
  font-family: var(--font);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: #1a1008;
  margin-bottom: 14px;
  line-height: 1.8;
}

#book-body {
  font-family: var(--font);
  font-size: 8px;
  line-height: 2.6;
  color: #3a2a18;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  overflow-y: auto;
}

#book-body em {
  color: #000;
  font-style: normal;
}

#close-hint {
  font-family: var(--font);
  font-size: 7px;
  color: #5a4a30;
  text-align: right;
  margin-top: 6px;
}

/* ── Screens ─────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--black);
  gap: 32px;
}

.screen.hidden { display: none; }

/* ── Title ───────────────────────────────────────────────── */
#title-main {
  font-size: clamp(18px, 3.5vw, 28px);
  line-height: 1.8;
  text-align: center;
  color: var(--text);
  letter-spacing: 0.04em;
}

#title-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
  font-size: 8px;
  color: var(--muted);
  line-height: 2;
}

#start-btn {
  font-family: var(--font);
  font-size: 10px;
  background: none;
  border: 2px solid var(--gold);
  color: var(--gold);
  padding: 14px 40px;
  cursor: pointer;
  letter-spacing: 0.1em;
}

#start-btn:hover {
  background: var(--gold);
  color: var(--black);
}

/* ── Win / Lose ──────────────────────────────────────────── */
.end-heading {
  font-size: clamp(14px, 2.5vw, 20px);
  line-height: 2;
  text-align: center;
  color: var(--text);
  letter-spacing: 0.04em;
}

.end-btn {
  font-family: var(--font);
  font-size: 9px;
  background: none;
  border: 2px solid var(--muted);
  color: var(--muted);
  padding: 12px 32px;
  cursor: pointer;
  letter-spacing: 0.1em;
}

.end-btn:hover {
  border-color: var(--text);
  color: var(--text);
}
