/* Conacul Uitat — stiluri. Temă: noapte, lemn vechi, roșu sângeriu. */
:root {
  --ink: #e8e0cf;
  --dim: #9a917e;
  --blood: #a3121f;
  --blood-hi: #d41f2e;
  --panel: #141019;
  --panel-edge: #3a2f28;
  --paper: #e4d3a8;
  --paper-ink: #2b1f14;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #07070d; color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}
#app { position: fixed; inset: 0; overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- Butoane ---------- */
.btn {
  display: block; width: 100%; margin: 6px 0;
  padding: 13px 16px; font-size: 17px; font-weight: 700; letter-spacing: .3px;
  color: var(--ink); background: #221b22; border: 2px solid var(--panel-edge);
  border-radius: 10px; cursor: pointer;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--blood); border-color: #5c0a12; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { width: auto; display: inline-block; padding: 8px 14px; font-size: 14px; }

/* ---------- Meniu ---------- */
#menu {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(20,8,10,.55), rgba(4,4,8,.92) 75%);
  padding: 20px;
}
#menu-inner { width: 100%; max-width: 430px; text-align: center; }
#game-kicker { color: var(--dim); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; }
#game-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(52px, 13vw, 84px); line-height: .95; margin: 10px 0 6px;
  color: #f2e8d5; text-shadow: 0 0 26px rgba(163,18,31,.55), 0 3px 0 #3d0308;
  letter-spacing: 1px;
}
#game-sub { color: var(--dim); font-size: 14px; margin-bottom: 18px; }
#menu-buttons { display: flex; flex-direction: column; gap: 2px; }
#menu-foot { margin-top: 14px; color: #6d6558; font-size: 12px; }

/* ---------- Panou generic ---------- */
#panel, #pause {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,4,8,.78); padding: 18px;
}
#panel-box, #pause-box {
  width: 100%; max-width: 430px; background: var(--panel);
  border: 2px solid var(--panel-edge); border-radius: 12px; padding: 18px;
  max-height: 86vh; overflow-y: auto;
}
#panel-title, #pause-title {
  font-family: Georgia, serif; font-size: 26px; margin-bottom: 10px; color: #f2e8d5;
}
#panel-body { font-size: 15px; line-height: 1.55; color: var(--ink); margin-bottom: 12px; }
#panel-body h4 { margin: 12px 0 4px; color: var(--blood-hi); }
#panel-body .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid #2a2230; }
#panel-body input[type="range"] { width: 140px; accent-color: var(--blood-hi); }
.toggle { width: 58px; height: 30px; border-radius: 16px; border: 2px solid var(--panel-edge); background: #33272b; position: relative; cursor: pointer; flex: none; }
.toggle.on { background: var(--blood); }
.toggle::after { content: ""; position: absolute; top: 2px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #e8e0cf; transition: left .15s; }
.toggle.on::after { left: 27px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
#objective-bar {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 12px; right: 64px;
  background: rgba(10,8,12,.72); border: 1px solid var(--panel-edge);
  border-radius: 10px; padding: 8px 12px; font-size: 14px;
}
#chapter-tag {
  display: inline-block; background: var(--blood); color: #fff; font-weight: 800;
  font-size: 12px; padding: 2px 8px; border-radius: 8px; margin-right: 8px;
}
#stats-bar {
  position: absolute; top: calc(58px + env(safe-area-inset-top)); left: 12px;
  display: flex; gap: 8px; font-size: 12px; color: var(--dim);
}
#stats-bar span { background: rgba(10,8,12,.72); border: 1px solid var(--panel-edge); border-radius: 8px; padding: 4px 9px; }
#toast {
  position: absolute; bottom: 34%; left: 50%; transform: translateX(-50%);
  background: rgba(10,8,12,.88); border: 1px solid var(--blood);
  color: #ffe9c9; border-radius: 10px; padding: 10px 18px; font-size: 15px;
  max-width: 86vw; text-align: center;
}
#prompt {
  position: absolute; bottom: calc(118px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: rgba(163,18,31,.9); color: #fff; font-weight: 700;
  border-radius: 10px; padding: 9px 18px; font-size: 15px; white-space: nowrap;
}

/* ---------- Touch ---------- */
#touch-ui { position: absolute; inset: 0; z-index: 21; pointer-events: none; }
#joystick {
  position: absolute; left: 22px; bottom: calc(26px + env(safe-area-inset-bottom));
  width: 128px; height: 128px; border-radius: 50%;
  border: 2px solid rgba(232,224,207,.35); background: rgba(10,8,12,.4);
  pointer-events: auto;
}
#stick {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border-radius: 50%;
  background: rgba(232,224,207,.75); transform: translate(-50%,-50%);
}
#touch-buttons {
  position: absolute; right: 16px; bottom: calc(22px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: auto;
}
.tbtn {
  border: 2px solid var(--panel-edge); background: rgba(20,16,25,.8); color: var(--ink);
  border-radius: 50%; width: 66px; height: 66px; font-size: 12px; font-weight: 800;
}
.tbtn.big { width: 92px; height: 92px; background: var(--blood); border-color: #5c0a12; color: #fff; font-size: 13px; }
.tbtn.active { outline: 3px solid var(--blood-hi); }
#look-hint {
  position: absolute; top: 38%; left: 50%; transform: translateX(-50%); z-index: 22;
  background: rgba(10,8,12,.8); padding: 8px 16px; border-radius: 10px; font-size: 14px; color: var(--dim);
  pointer-events: none;
}

/* ---------- Dialog ---------- */
#dialog {
  position: absolute; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 30; background: rgba(12,9,14,.94); border: 2px solid var(--panel-edge);
  border-radius: 12px; padding: 14px 16px 12px; min-height: 128px; cursor: pointer;
}
#dialog-name { font-weight: 800; color: var(--blood-hi); font-size: 15px; margin-bottom: 6px; letter-spacing: .5px; }
#dialog-text { font-size: 17px; line-height: 1.5; min-height: 52px; }
#dialog-next { text-align: right; color: var(--dim); font-size: 13px; margin-top: 6px; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { #dialog-next { animation: none; } }

/* ---------- Cititor ---------- */
#reader { position: absolute; inset: 0; z-index: 32; display: flex; align-items: center; justify-content: center; background: rgba(4,4,8,.7); padding: 20px; }
#reader-paper {
  width: 100%; max-width: 430px; max-height: 80vh; overflow-y: auto;
  background: var(--paper); color: var(--paper-ink); border-radius: 6px; padding: 22px 20px;
  font-family: Georgia, serif; box-shadow: 0 10px 60px rgba(0,0,0,.8);
  transform: rotate(-.6deg);
}
#reader-title { font-size: 20px; font-weight: 700; margin-bottom: 10px; border-bottom: 2px solid #8a6d3b; padding-bottom: 8px; }
#reader-body { font-size: 16px; line-height: 1.65; white-space: pre-wrap; }
#reader-close { margin-top: 14px; background: #2b1f14; border-color: #2b1f14; color: #e4d3a8; }

/* ---------- Seif ---------- */
#safe { position: absolute; inset: 0; z-index: 32; display: flex; align-items: center; justify-content: center; background: rgba(4,4,8,.7); }
#safe-box { width: min(92vw, 340px); background: #1c1a20; border: 3px solid #4a4a55; border-radius: 14px; padding: 18px; text-align: center; }
#safe-title { font-size: 15px; color: var(--dim); margin-bottom: 10px; }
#safe-display { font-size: 34px; letter-spacing: 8px; font-weight: 800; margin-bottom: 14px; font-variant-numeric: tabular-nums; }
#safe-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
#safe-keys button { padding: 13px 0; font-size: 20px; font-weight: 800; background: #2c2a33; color: var(--ink); border: 1px solid #4a4a55; border-radius: 8px; }
#safe-keys button:active { background: var(--blood); }

/* ---------- Card capitol ---------- */
#chapter-card {
  position: absolute; inset: 0; z-index: 35; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: #050508; text-align: center; padding: 24px;
}
#chapter-kicker { color: var(--blood-hi); letter-spacing: 4px; text-transform: uppercase; font-size: 14px; }
#chapter-title { font-family: Georgia, serif; font-size: clamp(40px, 10vw, 64px); margin: 8px 0; }
#chapter-sub { color: var(--dim); font-size: 15px; max-width: 420px; line-height: 1.5; }

/* ---------- Jumpscare ---------- */
#jumpscare { position: absolute; inset: 0; z-index: 60; background: #000; display: flex; align-items: center; justify-content: center; flex-direction: column; }
#jumpscare-face { font-family: Georgia, serif; font-size: min(46vw, 220px); line-height: 1; }
#jumpscare-text { color: var(--blood-hi); font-size: 30px; font-weight: 900; letter-spacing: 3px; margin-top: 10px; }
#jumpscare.shake { animation: shk .1s infinite; }
@keyframes shk {
  0% { transform: translate(0,0) rotate(0); } 25% { transform: translate(-14px,8px) rotate(-2deg); }
  50% { transform: translate(12px,-10px) rotate(2deg); } 75% { transform: translate(-8px,-6px) rotate(-1deg); }
  100% { transform: translate(10px,10px) rotate(1deg); }
}
#flash { position: absolute; inset: 0; z-index: 59; background: #fff; opacity: .9; pointer-events: none; }

/* ---------- Final ---------- */
#ending { position: absolute; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center; background: rgba(4,4,8,.9); padding: 20px; }
#ending-box { width: 100%; max-width: 450px; background: var(--panel); border: 2px solid var(--blood); border-radius: 12px; padding: 22px; text-align: center; max-height: 88vh; overflow-y: auto; }
#ending-kicker { color: var(--blood-hi); letter-spacing: 4px; text-transform: uppercase; font-size: 13px; }
#ending-title { font-family: Georgia, serif; font-size: 34px; margin: 6px 0 10px; }
#ending-body { font-size: 15px; line-height: 1.6; text-align: left; white-space: pre-wrap; }
#ending-stats { margin: 12px 0; color: var(--dim); font-size: 14px; }

/* ---------- Pauză / boot / loader ---------- */
#btn-pause {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; z-index: 25;
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--panel-edge);
  background: rgba(10,8,12,.72); color: var(--ink); font-weight: 900; font-size: 15px;
}
#boot-error, #loader { position: absolute; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: #050508; padding: 24px; }
#boot-box, #loader-box { max-width: 400px; text-align: center; }
.boot-title { font-family: Georgia, serif; font-size: 24px; margin-bottom: 10px; }
#boot-msg { color: var(--dim); font-size: 14px; margin-bottom: 14px; line-height: 1.5; }
.loader-bar { height: 10px; background: #221b22; border-radius: 6px; overflow: hidden; margin-top: 12px; }
#loader-fill { height: 100%; width: 10%; background: var(--blood); border-radius: 6px; transition: width .3s; }

#btn-journal {
  position: absolute; top: calc(62px + env(safe-area-inset-top)); right: 12px; z-index: 25;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--panel-edge);
  background: rgba(10,8,12,.72); color: var(--ink); font-weight: 800; font-size: 13px;
}
#journal { position: absolute; inset: 0; z-index: 31; display: flex; align-items: center; justify-content: center; background: rgba(4,4,8,.7); padding: 20px; }
#journal-box { width: 100%; max-width: 430px; max-height: 82vh; overflow-y: auto; background: var(--panel); border: 2px solid var(--panel-edge); border-radius: 12px; padding: 18px; }
#journal-title { font-family: Georgia, serif; font-size: 24px; color: #f2e8d5; }
#journal-sub { color: var(--dim); font-size: 13px; margin: 4px 0 10px; }
#journal-pages, #journal-notes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.jbtn { text-align: left; background: #221b22; border: 2px solid var(--panel-edge); color: var(--ink); border-radius: 10px; padding: 10px 12px; font-size: 15px; font-weight: 700; }
.jbtn.locked { opacity: .45; font-weight: 400; }
.jsec { color: var(--blood-hi); font-weight: 800; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; margin: 6px 0 2px; }

@media (min-width: 700px) {
  #dialog { left: 50%; transform: translateX(-50%); width: 640px; }
  #prompt { bottom: 60px; }
}
