/* Nocturne of Blackwood — dark gothic UI, gold on near-black. */
:root {
  --ink: #0b0906;
  --ink2: #171208;
  --gold: #c9a227;
  --gold-dim: #8a6d1f;
  --paper: #e8dcc0;
  --paper-ink: #2a2118;
  --blood: #7a1622;
  --text: #e6ddc8;
  --muted: #9a8f74;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: Georgia, 'Times New Roman', serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.hidden { display: none !important; }
#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; }

/* ---------- vignette & flashes ---------- */
#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(90, 4, 12, 0.55) 100%);
  opacity: 0; transition: opacity 1.2s ease;
}
#vignette.on { opacity: 1; }
.scare-flash {
  position: absolute; inset: 0; z-index: 25; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 3, 2, 0.88);
  color: var(--paper); text-align: center; padding: 2rem;
  font-size: clamp(1rem, 3.4vw, 1.6rem); font-style: italic; line-height: 1.5;
}
.dmg-flash {
  position: absolute; inset: 0; z-index: 24; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(160, 10, 20, 0.65) 100%);
}

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud-top {
  position: absolute; top: 0.6rem; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 0.1rem;
}
#hud-timer {
  font-size: clamp(1.6rem, 5vw, 2.4rem); letter-spacing: 0.12em; color: var(--paper);
  text-shadow: 0 0 14px rgba(0,0,0,0.9), 0 2px 3px #000;
  font-variant-numeric: tabular-nums;
}
#hud-timer.low { color: #ff5d47; }
#hud-seed { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.2em; }
#hud-left {
  position: absolute; top: 0.7rem; left: 0.9rem;
  display: flex; flex-direction: column; gap: 0.35rem;
  text-shadow: 0 1px 3px #000;
}
.hud-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; }
.hud-label { color: var(--gold); min-width: 3.2rem; letter-spacing: 0.06em; }
#battery-bar {
  width: 7.5rem; height: 0.65rem; border: 1px solid var(--gold-dim);
  background: rgba(0,0,0,0.55); border-radius: 3px; overflow: hidden;
}
#battery-fill { height: 100%; width: 40%; background: linear-gradient(90deg, #d8b93c, #f4e08a); transition: width 0.3s ease; }
#battery-fill.low { background: linear-gradient(90deg, #a33327, #e06a4e); }
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%; background: rgba(232, 220, 192, 0.85);
  box-shadow: 0 0 6px rgba(0,0,0,0.9);
}
#crosshair.active { background: var(--gold); transform: scale(1.7); }
#subtitle {
  position: absolute; left: 50%; bottom: 17%; transform: translateX(-50%);
  max-width: 82%; text-align: center; font-style: italic;
  font-size: clamp(1rem, 3vw, 1.35rem); color: #cfc4a5;
  text-shadow: 0 0 10px #000, 0 2px 4px #000;
}
#toast {
  position: absolute; left: 50%; bottom: 26%; transform: translateX(-50%);
  max-width: 85%; text-align: center; font-size: clamp(0.95rem, 2.6vw, 1.2rem);
  color: var(--paper); background: rgba(10, 7, 3, 0.72); border: 1px solid var(--gold-dim);
  border-radius: 8px; padding: 0.55rem 1rem;
}
#prompt {
  position: absolute; left: 50%; bottom: 10.5%; transform: translateX(-50%);
  font-size: 1rem; color: var(--ink); background: var(--gold);
  border-radius: 999px; padding: 0.45rem 1.1rem; font-weight: bold; letter-spacing: 0.04em;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6); white-space: nowrap;
}

/* ---------- touch controls ---------- */
.touch-ui { pointer-events: auto; }
#joystick {
  position: absolute; left: 1.1rem; bottom: 1.1rem; width: 7.2rem; height: 7.2rem;
  border-radius: 50%; border: 2px solid rgba(201, 162, 39, 0.5);
  background: rgba(10, 7, 3, 0.35);
}
#stick {
  position: absolute; left: 50%; top: 50%; width: 3.1rem; height: 3.1rem;
  margin: -1.55rem 0 0 -1.55rem; border-radius: 50%;
  background: rgba(201, 162, 39, 0.55); border: 1px solid var(--gold);
}
#touch-buttons {
  position: absolute; right: 1.1rem; bottom: 1.1rem;
  display: flex; flex-direction: column; gap: 0.7rem;
}
.touch-btn {
  pointer-events: auto; min-width: 6.4rem; padding: 0.9rem 1rem;
  font-family: inherit; font-size: 1.05rem; font-weight: bold; letter-spacing: 0.03em;
  color: var(--ink); background: rgba(201, 162, 39, 0.92);
  border: 1px solid #6d5514; border-radius: 12px; cursor: pointer;
}
.touch-btn:active { background: #e8c95a; }
.touch-btn:disabled { opacity: 0.35; }
#btn-pause {
  position: absolute; top: 0.6rem; right: 0.9rem; z-index: 12;
  min-width: 3.2rem; padding: 0.55rem 0.7rem; font-size: 1rem; line-height: 1;
}

/* ---------- screens & menu ---------- */
.screen {
  position: absolute; inset: 0; z-index: 20; overflow-y: auto;
  display: flex;
  background: radial-gradient(ellipse at 50% 30%, #241a0c 0%, var(--ink) 68%);
  padding: 1.2rem;
}
.menu-inner { max-width: 620px; width: 100%; text-align: center; padding: 1rem 0; margin: auto; }
.menu-kicker { color: var(--gold); letter-spacing: 0.3em; text-transform: uppercase; font-size: 0.8rem; margin-bottom: 0.7rem; }
.game-title {
  font-size: clamp(2rem, 7vw, 3.4rem); font-weight: normal; color: var(--paper);
  letter-spacing: 0.04em; line-height: 1.12; margin-bottom: 0.9rem;
  text-shadow: 0 0 26px rgba(201, 162, 39, 0.25);
}
.game-title.small { font-size: clamp(1.5rem, 5vw, 2.2rem); }
.menu-tagline { color: var(--muted); font-size: clamp(0.95rem, 2.6vw, 1.08rem); line-height: 1.55; margin-bottom: 1.4rem; }
#last-note-preview {
  text-align: left; font-style: italic; color: #cfc4a5; line-height: 1.55;
  border: 1px solid var(--gold-dim); border-left: 4px solid var(--gold);
  background: rgba(23, 18, 8, 0.85); border-radius: 6px;
  padding: 0.8rem 1rem; margin: 0 auto 1.3rem; max-width: 520px; white-space: pre-line;
}
.menu-buttons { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; margin-bottom: 0.8rem; }
.menu-sub-buttons { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.2rem; }
.btn {
  font-family: inherit; font-size: 1.05rem; padding: 0.75rem 1.5rem; border-radius: 8px;
  cursor: pointer; letter-spacing: 0.03em; border: 1px solid var(--gold-dim);
}
.btn-primary { background: linear-gradient(180deg, #d8b93c, #a37f1d); color: #171106; font-weight: bold; }
.btn-primary:active { background: #e8c95a; }
.btn-ghost { background: rgba(23, 18, 8, 0.8); color: var(--paper); }
.btn-ghost:active { background: #2c2210; }
.seed-row { display: flex; align-items: center; justify-content: center; gap: 0.6rem; flex-wrap: wrap; color: var(--muted); margin-bottom: 1.1rem; }
.seed-row label { color: var(--gold); letter-spacing: 0.15em; text-transform: uppercase; font-size: 0.8rem; }
#seed-input {
  font-family: inherit; font-size: 1rem; width: 8.5rem; text-align: center;
  background: var(--ink2); color: var(--paper); border: 1px solid var(--gold-dim);
  border-radius: 6px; padding: 0.45rem 0.3rem; letter-spacing: 0.08em;
}
.seed-hint { font-size: 0.82rem; width: 100%; }
.menu-footer { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
#privacy-link { text-decoration: underline; cursor: pointer; }
.footer-sep { margin: 0 0.4rem; }
#ad-slot { min-height: 0; margin-top: 0.8rem; }

/* ---------- modals ---------- */
.modal {
  position: absolute; inset: 0; z-index: 30; display: flex;
  align-items: center; justify-content: center; padding: 1rem;
  background: rgba(4, 3, 1, 0.78);
}
.modal-card {
  background: var(--ink2); border: 1px solid var(--gold-dim); border-radius: 12px;
  max-width: 560px; width: 100%; max-height: 88%; overflow-y: auto;
  padding: 1.4rem 1.5rem; text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,0.7);
}
.modal-card.parchment {
  background: linear-gradient(175deg, #efe3c2, #dcc493 80%);
  color: var(--paper-ink); border-color: #9a7f3f;
}
.modal-title { font-weight: normal; font-size: 1.45rem; color: var(--gold); margin-bottom: 1rem; letter-spacing: 0.03em; }
.parchment .modal-title { color: #6d5514; }
#reader-body { text-align: left; line-height: 1.65; font-size: 1.02rem; white-space: pre-line; margin-bottom: 1.2rem; }
.setting-row {
  display: flex; gap: 0.8rem; align-items: flex-start; text-align: left;
  padding: 0.7rem 0.2rem; cursor: pointer; line-height: 1.4;
}
.setting-row input { width: 1.3rem; height: 1.3rem; margin-top: 0.15rem; accent-color: var(--gold); }
.setting-help { color: var(--muted); font-size: 0.88rem; }
.archive-slot {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  border: 1px solid #3a2f16; border-radius: 8px; padding: 0.8rem 1rem; margin-bottom: 0.7rem;
  text-align: left;
}
.archive-open { border-color: var(--gold-dim); }
.archive-name { font-size: 1rem; }
.archive-state { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.archive-open .archive-state { color: var(--gold); }
.pause-text { color: var(--muted); margin-bottom: 1.2rem; font-style: italic; }
.modal-card .btn { margin: 0.25rem; }

/* ---------- keypad ---------- */
#keypad-display {
  font-size: 2rem; letter-spacing: 0.5em; text-indent: 0.5em; color: var(--paper);
  border: 1px solid var(--gold-dim); border-radius: 8px; padding: 0.5rem 0;
  margin-bottom: 1rem; font-variant-numeric: tabular-nums; min-height: 3.6rem;
}
#keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.55rem; margin-bottom: 1rem; }
#keypad-grid button {
  font-family: inherit; font-size: 1.3rem; padding: 0.7rem 0; border-radius: 8px;
  background: #241b0d; color: var(--paper); border: 1px solid var(--gold-dim); cursor: pointer;
}
#keypad-grid button:active { background: #3a2c12; }

/* ---------- end screen ---------- */
#poster-img {
  width: min(430px, 88vw); border: 1px solid var(--gold-dim); border-radius: 6px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.65); margin-bottom: 1.2rem; background: #e8dcc0;
}
#copy-feedback { color: var(--gold); margin-top: 0.4rem; }
#end-screen { z-index: 35; }

/* ---------- rotate overlay ---------- */
#rotate-overlay {
  position: absolute; inset: 0; z-index: 50; background: var(--ink);
  display: flex; align-items: center; justify-content: center; text-align: center;
}
#rotate-text { color: var(--paper); font-size: 1.2rem; padding: 2rem; font-style: italic; }

@media (max-height: 500px) {
  .menu-inner { padding: 0.4rem 0; }
  .menu-tagline { margin-bottom: 0.8rem; }
  #hud-left { transform: scale(0.88); transform-origin: top left; }
}
