/* Дум-версия дайджеста. Палитра — тёмный техбейз: коричневое, ржавое, красное. */

:root {
  --bg:       #0b0a09;
  --bar:      #2a221c;
  --bar-2:    #3b2f26;
  --line:     #6b5443;
  --red:      #c4342b;
  --red-hi:   #ff5b3c;
  --gold:     #f2d06b;
  --cream:    #f4f1e4;
  --muted:    #a08e7c;
  --hud-h:    clamp(56px, 9vh, 84px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--cream);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
}

#game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}

/* ═════════ экран ═════════ */

#screen {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #000;
  cursor: crosshair;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#automap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  background: #060504;
}
#automap.on { display: block; }

/* «прицел» — точка мела */
#screen::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2px 0 0 -2px;
  background: rgba(244, 241, 228, .55);
  box-shadow: 0 0 4px rgba(0, 0, 0, .9);
  pointer-events: none;
}

/* сообщения как в думе — строкой сверху */
#msg {
  position: absolute;
  left: 12px;
  top: 10px;
  max-width: 70%;
  font-size: clamp(11px, 1.5vw, 15px);
  line-height: 1.5;
  letter-spacing: .02em;
  color: var(--cream);
  text-shadow: 1px 1px 0 #000, 2px 2px 0 rgba(0, 0, 0, .6);
  pointer-events: none;
  white-space: pre-line;
}
#msg b { color: var(--gold); font-weight: 600; }

#hint {
  position: absolute;
  left: 14px;
  bottom: 12px;
  font-size: clamp(10px, 1.3vw, 13px);
  color: rgba(244, 241, 228, .62);
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
  transition: opacity .5s;
}
#hint.gone { opacity: 0; }

/* вспышка боли, как палитровый флеш в думе */
/* Слой со смешиванием на весь экран композитится дорого, поэтому по умолчанию
   он спрятан через visibility и включается только на время вспышки. */
#pain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 60%, rgba(196, 32, 20, .18), rgba(160, 20, 12, .62));
  opacity: 0;
  visibility: hidden;
  mix-blend-mode: screen;
}

/* подписи над терминалами и реплики чертей */
#tags { position: absolute; inset: 0; pointer-events: none; }
.tag {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 3px 8px 4px;
  background: rgba(12, 10, 8, .78);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 12px;
  line-height: 1.25;
  letter-spacing: .02em;
  white-space: nowrap;
  text-shadow: 1px 1px 0 #000;
  transition: opacity .18s;
}
.tag i {
  display: block;
  font-style: normal;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.tag.read { opacity: .45; }

/* реплика чертика */
.bub {
  position: absolute;
  transform: translate(-50%, -100%);
  max-width: 240px;
  padding: 5px 9px 6px;
  background: #f4f1e4;
  border: 2px solid #7d1c14;
  border-radius: 3px;
  color: #1a1410;
  font-size: 12px;
  line-height: 1.35;
  text-shadow: none;
  transition: opacity .15s;
}
.bub::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -7px;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top: 6px solid #7d1c14;
}

/* ═════════ статус-бар ═════════ */

#hud {
  flex: 0 0 auto;
  height: var(--hud-h);
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.18) 0 2px, rgba(255,255,255,.02) 2px 4px),
    linear-gradient(180deg, var(--bar-2), var(--bar));
  border-top: 2px solid var(--line);
  box-shadow: inset 0 2px 0 rgba(255, 220, 160, .12);
  user-select: none;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 2px 8px;
  border: 1px solid rgba(107, 84, 67, .55);
  border-radius: 2px;
  background: rgba(0, 0, 0, .22);
}

.hud-num {
  font-family: 'Oswald', 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: clamp(18px, 3.4vh, 30px);
  line-height: 1;
  color: var(--red-hi);
  text-shadow: 0 2px 0 #4a0f08, 0 0 12px rgba(255, 91, 60, .35);
  font-variant-numeric: tabular-nums;
}
.hud-key {
  font-size: 8px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-ammo, .hud-found, .hud-hp { min-width: clamp(54px, 7vw, 88px); }

/* мало здоровья — цифра пульсирует */
.hud-num.low { animation: lowhp .7s steps(2) infinite; }
@keyframes lowhp { 50% { color: #ffd0c4; text-shadow: 0 2px 0 #4a0f08, 0 0 18px rgba(255, 91, 60, .8); } }

.hud-score { gap: 4px; }
.hud-score .sc {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 8px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.hud-score .sc b {
  min-width: 1.6em;
  text-align: right;
  font-family: 'Oswald', monospace;
  font-size: clamp(11px, 1.8vh, 16px);
  color: var(--gold);
}

.slots { display: flex; gap: 4px; }
.slot {
  width: clamp(14px, 2vw, 20px);
  height: clamp(16px, 2.4vh, 22px);
  display: grid;
  place-items: center;
  border: 1px solid rgba(107, 84, 67, .7);
  border-radius: 2px;
  background: rgba(0, 0, 0, .35);
  font-family: 'Oswald', monospace;
  font-weight: 700;
  font-size: clamp(10px, 1.4vh, 13px);
  color: #5c4b3d;
}
.slot.on {
  color: #12100e;
  background: var(--gold);
  border-color: #fff0b8;
  box-shadow: 0 0 10px rgba(242, 208, 107, .5);
}

.hud-face {
  padding: 3px;
  background: #16120f;
  border-color: var(--line);
}
#face {
  display: block;
  width: clamp(30px, 4.6vh, 44px);
  height: auto;
  image-rendering: pixelated;
}

.hud-keys {
  margin-left: auto;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  font-size: clamp(8px, 1.1vh, 10px);
  color: var(--muted);
  line-height: 1.4;
  text-align: left;
}
.hud-keys b { color: var(--cream); font-weight: 600; }

.k-btns { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.mini-btn {
  padding: 2px 7px 3px;
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--muted);
  font-family: inherit;
  font-size: clamp(8px, 1.1vh, 10px);
  letter-spacing: .06em;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.mini-btn:hover { color: #12100e; background: var(--gold); border-color: #fff0b8; }
.mini-btn.off { color: #5c4b3d; text-decoration: line-through; }

/* ═════════ вырезка из дайджеста ═════════ */

#cut {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: #0b0a09;
}
#cut[hidden] { display: none; }

.cut-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 8px 12px;
  background: linear-gradient(180deg, var(--bar-2), var(--bar));
  border-bottom: 2px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, .12);
}

.cut-label {
  flex: 0 0 auto;
  padding: 3px 8px 4px;
  border: 1px solid var(--gold);
  border-radius: 2px;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
}
.cut-title {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: clamp(14px, 2.4vw, 20px);
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--red-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cut-hint {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.cut-x {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--cream);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.cut-x:hover { background: var(--red-hi); color: #12100e; }

#cut-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #0b0a09;
}

/* рамка ещё грузится — не пустой экран, а честное «тянем» */
#cut.loading::after {
  content: 'тянем вырезку из дайджеста…';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  animation: cutwait 1s steps(2) infinite;
}
@keyframes cutwait { 50% { color: var(--cream); } }

@media (max-width: 700px) {
  .cut-hint { display: none; }
  .cut-title { white-space: normal; font-size: 14px; }
}

/* ═════════ панель сюжета ═════════ */

#panel {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 3vh 3vw;
  background: rgba(6, 4, 3, .74);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#panel[hidden] { display: none; }

/* Резерв показывает то же, что дайджест: светлая бумага, тёмный текст,
   текст слева и медиа справа. Читаемость важнее думовского антуража. */
.panel-box {
  --ink: #23201C;
  --ink-dim: rgba(35, 32, 28, .72);
  --ink-line: rgba(35, 32, 28, .16);
  width: min(1000px, 100%);
  max-height: 94%;
  overflow-y: auto;
  padding: clamp(20px, 3vw, 34px);
  background: #F6F4EF;
  border: 2px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  animation: pop .16s steps(3);
}

.panel-cols { display: grid; grid-template-columns: 1fr; gap: clamp(18px, 3vw, 34px); }
.panel-box.has-media .panel-cols { grid-template-columns: 1.05fr .95fr; align-items: start; }
@media (max-width: 820px) {
  .panel-box.has-media .panel-cols { grid-template-columns: 1fr; }
}

.panel-media { display: flex; flex-direction: column; gap: 12px; }
.pm { margin: 0; background: #fff; padding: 8px 8px 4px; border-radius: 4px; box-shadow: 0 12px 26px -18px rgba(35,32,28,.5); }
.pm video, .pm img { display: block; width: 100%; max-height: 380px; object-fit: contain; border-radius: 2px; background: #EBE7DE; }
.pm figcaption { padding: 7px 2px 3px; font-size: 11.5px; line-height: 1.4; color: rgba(35,32,28,.6); text-align: center; }
.pm-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  min-height: 190px; padding: 22px 18px; text-align: center;
  border: 2px dashed var(--ink-line); border-radius: 6px; background: rgba(35,32,28,.03);
}
.pm-slot span { font-size: 26px; }
.pm-slot b { font-size: 13.5px; font-weight: 500; color: var(--ink-dim); max-width: 300px; }
.pm-slot i { font-style: normal; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: rgba(35,32,28,.45); }
@keyframes pop { from { transform: scale(.94); opacity: .3; } }

.panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.panel-label {
  padding: 3px 9px 4px;
  border: 1px solid rgba(156, 107, 14, .4);
  border-radius: 2px;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #9C6B0E;
}
.panel-x {
  width: 30px; height: 30px;
  flex: 0 0 auto;
  background: rgba(35,32,28,.06);
  border: 1px solid rgba(35,32,28,.25);
  border-radius: 2px;
  color: rgba(35,32,28,.6);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.panel-x:hover { color: #23201C; border-color: #23201C; }

#panel h2 {
  margin: 0 0 10px;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: clamp(24px, 4.2vw, 40px);
  line-height: 1.02;
  letter-spacing: .01em;
  text-transform: uppercase;
  color: #23201C;
}

.panel-lead {
  margin: 0 0 16px;
  font-size: clamp(15px, 1.8vw, 17.5px);
  line-height: 1.6;
  color: var(--ink-dim);
}

.panel-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.panel-stats .st {
  flex: 1 1 180px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--ink-line);
  border-left: 3px solid #9C6B0E;
  border-radius: 2px;
}
.panel-stats .st b {
  display: block;
  font-family: 'Oswald', sans-serif;
  font-size: clamp(22px, 3.4vw, 32px);
  line-height: 1;
  color: #9C6B0E;
}
.panel-stats .st span {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(35,32,28,.6);
}

#p-body h3 {
  margin: 16px 0 4px;
  font-size: 12px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #9C6B0E;
}
#p-body p { margin: 0; font-size: 15px; line-height: 1.65; color: var(--ink-dim); }

#p-body ul { margin: 6px 0 0; padding: 0; list-style: none; }
#p-body li .st { color: #12100e; }
#p-body li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 4px 12px;
  padding: 9px 0;
  border-top: 1px solid var(--ink-line);
  font-size: 14.5px;
  line-height: 1.5;
}
#p-body li .st {
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #12100e;
  background: var(--muted);
  border-radius: 2px;
  padding: 3px 6px;
  align-self: start;
  justify-self: start;
}
#p-body li .st.done { background: #7fe3a1; }
#p-body li .st.work { background: var(--gold); }
#p-body li .st.wait { background: #b18bff; }
#p-body li b { display: block; font-weight: 600; color: var(--ink); }
#p-body li i { font-style: normal; color: var(--ink-dim); font-size: 13.5px; }

.panel-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.panel-links a {
  padding: 8px 12px;
  background: #fff;
  border: 1px solid rgba(156, 107, 14, .4);
  border-radius: 2px;
  color: #9C6B0E;
  font-size: 13px;
  text-decoration: none;
}
.panel-links a:hover { color: #12100e; background: #F2D06B; border-color: #9C6B0E; }

.panel-foot {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--ink-line);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(35,32,28,.45);
}

/* ═════════ титул и финал ═════════ */

#ask, #title, #finale, #dead {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 4vh 4vw;
  overflow-y: auto;
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(196, 52, 43, .3), transparent 65%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.25) 0 3px, rgba(255,255,255,.014) 3px 6px),
    linear-gradient(180deg, #241a14, #0b0a09 70%);
}
#ask {
  background:
    radial-gradient(85% 65% at 50% 0%, rgba(242, 208, 107, .16), transparent 68%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.25) 0 3px, rgba(255,255,255,.014) 3px 6px),
    linear-gradient(180deg, #241a14, #0b0a09 70%);
}
.ask-list { margin-top: 26px; }
.ask-list button { padding: 16px 18px; font-size: clamp(15px, 2.2vw, 19px); }

#dead {
  background:
    radial-gradient(90% 70% at 50% 0%, rgba(196, 52, 43, .55), transparent 70%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.3) 0 3px, rgba(255,255,255,.014) 3px 6px),
    linear-gradient(180deg, #3a1310, #0b0a09 72%);
}
#ask[hidden], #title[hidden], #finale[hidden], #dead[hidden] { display: none; }

.title-inner { width: min(720px, 100%); text-align: center; }

.title-eyebrow {
  font-size: 10px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--muted);
}

#ask h1, #title h1, #finale h1, #dead h1 {
  margin: 10px 0 4px;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: clamp(38px, 9vw, 84px);
  line-height: .94;
  letter-spacing: .01em;
  text-transform: uppercase;
  color: #e8ded0;
  text-shadow: 0 3px 0 #000, 0 6px 18px rgba(0, 0, 0, .8);
}
#ask h1 span, #title h1 span, #finale h1 span, #dead h1 span {
  color: var(--red-hi);
  text-shadow: 0 3px 0 #55110a, 0 0 30px rgba(255, 91, 60, .45);
}

.title-sub {
  font-size: clamp(11px, 1.7vw, 14px);
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
}

.title-lead {
  max-width: 46ch;
  margin: 18px auto 0;
  font-size: clamp(13px, 1.7vw, 15px);
  line-height: 1.65;
  color: #cbbfae;
}

.skill-head {
  margin: 26px 0 10px;
  font-size: 10px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--muted);
}

.skills { margin: 0; padding: 0; list-style: none; }
.skills li { margin: 0 0 5px; }
.skills button {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, .3);
  border: 1px solid rgba(107, 84, 67, .5);
  border-radius: 2px;
  color: #d8ccbb;
  font-family: inherit;
  font-size: clamp(13px, 1.8vw, 16px);
  text-align: left;
  cursor: pointer;
  transition: none;
}
.skills button:hover, .skills button.sel {
  color: #12100e;
  background: var(--red-hi);
  border-color: var(--gold);
}
.skills button em {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--muted);
}
.skills button:hover em, .skills button.sel em { color: rgba(18, 16, 14, .75); }
.skills button::before {
  content: '›';
  color: var(--gold);
  font-weight: 700;
}
.skills button:hover::before, .skills button.sel::before { color: #12100e; }

.title-foot {
  margin-top: 24px;
  font-size: 11px;
  line-height: 1.9;
  letter-spacing: .06em;
  color: #7c6c5d;
}
.title-foot a { color: var(--gold); text-decoration: none; }
.title-foot a:hover { text-decoration: underline; }

.tally { margin: 22px 0 0; padding: 0; list-style: none; text-align: left; }
.tally li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(107, 84, 67, .4);
  font-size: clamp(13px, 1.8vw, 16px);
  color: #cbbfae;
}
.tally li b {
  font-family: 'Oswald', sans-serif;
  font-size: clamp(18px, 2.6vw, 24px);
  color: var(--gold);
}

.again {
  margin-top: 6px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, .3);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--cream);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.again:hover { background: var(--red-hi); color: #12100e; }

/* ═════════ тач ═════════ */

/* только над экраном: под статус-бар кнопки лезть не должны */
#touch { position: absolute; inset: 0 0 var(--hud-h) 0; z-index: 20; pointer-events: none; }
#touch[hidden] { display: none; }

.pad {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(3, 46px);
  gap: 4px;
}
.pad button, .fire {
  pointer-events: auto;
  background: rgba(20, 16, 13, .6);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--cream);
  font-family: inherit;
  font-size: 15px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.pad [data-t="f"] { grid-area: 1 / 2; }
.pad [data-t="l"] { grid-area: 2 / 1; }
.pad [data-t="b"] { grid-area: 2 / 2; }
.pad [data-t="r"] { grid-area: 2 / 3; }

.fire {
  position: absolute;
  right: 14px;
  bottom: 20px;
  width: 84px;
  height: 56px;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold);
}

/* на тачах подсказка внизу упирается в крестовину — уводим её наверх */
@media (pointer: coarse) {
  #hint { top: 34px; bottom: auto; }
}

/* узко: прячем подсказку по клавишам, ужимаем бар */
@media (max-width: 760px) {
  .hud-keys { display: none; }
  #hud { gap: 3px; }
  .hud-cell { padding: 3px 6px; }
  .hud-slots { display: none; }
  #panel h2 { font-size: 26px; }
  #p-body li { grid-template-columns: 1fr; }
  #p-body li .st { margin-bottom: 2px; }
}

@media (max-width: 420px) {
  .hud-face { display: none; }
}
