/* ════════════════════════════════════════════════
   СКАЗКА НА НОЧЬ — ЛАМИ  |  style.css
   ════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Share+Tech+Mono&display=swap');

:root {
  --ember:      #ff6b2b;
  --ember-dim:  #c44a15;
  --coal:       #0d0d0f;
  --ash:        #1a1a22;
  --void:       #050508;
  --pale-fire:  #ffd6a0;
  --frost:      #a8c4d4;
  --silver:     #c8d8e8;
  --gold:       #e8c66a;
  --text:       #e8ddd0;
  --muted:      #7a7080;
  --danger:     #e03030;
  --teal:       #5ad4c4;
  --lavender:   #c890d8;

  /* relation colors */
  --rel-end:    #e8c040;
  --rel-ghelm:  #7ab8d8;
  --rel-tia:    #c890d8;
  --rel-fab:    #5ad4c4;
}

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

body {
  background: var(--void);
  color: var(--text);
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* ════════════════════ SCREENS ════════════════════ */
.screen { display: none; width: 100%; height: 100vh; }
.screen.active { display: flex; }

/* ════════════════════ TITLE ════════════════════ */
#title-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: radial-gradient(ellipse at 50% 80%, #1a0a00 0%, var(--void) 70%);
  overflow: hidden;
}

.ember-particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.particle {
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 6px var(--ember);
  animation: float-up linear infinite;
  bottom: -10px;
}
@keyframes float-up {
  0%   { transform: translateX(0) scale(1); opacity: .9; }
  50%  { transform: translateX(var(--drift, 0px)) scale(.7); opacity: .5; }
  100% { transform: translateX(calc(var(--drift, 0px) * 2)) scale(.2); opacity: 0; bottom: 110%; }
}

.title-logo {
  text-align: center; z-index: 2;
  animation: title-appear 2s ease-out forwards;
  opacity: 0;
}
@keyframes title-appear {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.title-sub {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px; letter-spacing: 6px;
  color: var(--ember); text-transform: uppercase;
  margin-bottom: 16px; opacity: .7;
}
.title-main {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(28px, 5vw, 52px);
  color: var(--pale-fire);
  text-shadow: 0 0 40px rgba(255,107,43,.5), 0 0 80px rgba(255,107,43,.2);
  line-height: 1.2; margin-bottom: 8px;
}
.title-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(36px, 7vw, 72px);
  background: linear-gradient(135deg, var(--gold), var(--ember), var(--pale-fire));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 20px rgba(255,107,43,.4));
}
.title-divider {
  width: 200px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--ember), transparent);
  margin: 24px auto; opacity: .6;
}
.title-desc {
  font-style: italic; font-size: 15px;
  color: var(--muted); letter-spacing: 1px;
  max-width: 400px; text-align: center; line-height: 1.8;
}
.start-btn {
  margin-top: 48px; padding: 14px 56px;
  background: transparent; border: 1px solid var(--ember);
  color: var(--ember); font-family: 'Share Tech Mono', monospace;
  font-size: 13px; letter-spacing: 4px; text-transform: uppercase;
  cursor: pointer; position: relative; overflow: hidden; transition: all .3s;
}
.start-btn::before {
  content: ''; position: absolute; inset: 0;
  background: var(--ember); transform: scaleX(0);
  transform-origin: left; transition: transform .3s; z-index: -1;
}
.start-btn:hover { color: var(--void); }
.start-btn:hover::before { transform: scaleX(1); }

/* ════════════════════ GAME SCREEN ════════════════════ */
#game-screen { flex-direction: column; position: relative; background: var(--coal); }

/* scanlines overlay */
#game-screen::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 60;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 3px,
    rgba(0,0,0,.04) 3px, rgba(0,0,0,.04) 4px
  );
}
/* vignette */
#game-screen::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(0,0,0,.65) 100%);
}

/* ════════════════════ SCENE BACKGROUNDS ════════════════════ */
#scene-bg { position: absolute; inset: 0; transition: opacity .6s; z-index: 0; }

.bg-archive {
  background:
    radial-gradient(ellipse at 30% 50%, rgba(100,60,0,.3) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 30%, rgba(0,40,80,.4) 0%, transparent 50%),
    linear-gradient(180deg, #0a0a14 0%, #12100a 100%);
}
.bg-base {
  background:
    radial-gradient(ellipse at 50% 100%, rgba(30,10,0,.5) 0%, transparent 60%),
    linear-gradient(180deg, #080810 0%, #0f0f14 100%);
}
.bg-training {
  background:
    radial-gradient(ellipse at 50% 80%, rgba(150,30,0,.25) 0%, transparent 60%),
    radial-gradient(ellipse at 20% 20%, rgba(0,20,60,.3) 0%, transparent 40%),
    linear-gradient(180deg, #060610 0%, #100808 100%);
}
.bg-field {
  background:
    radial-gradient(ellipse at 50% 60%, rgba(0,80,0,.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(40,60,0,.2) 0%, transparent 40%),
    linear-gradient(180deg, #040810 0%, #080c08 100%);
}
.bg-rift {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(80,0,120,.4) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 60%, rgba(200,50,0,.2) 0%, transparent 40%),
    linear-gradient(180deg, #060208 0%, #0c0408 100%);
}
.bg-sea {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(0,40,80,.5) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(0,20,60,.4) 0%, transparent 40%),
    linear-gradient(180deg, #04080f 0%, #060c10 100%);
}
.bg-tech {
  background:
    radial-gradient(ellipse at 60% 40%, rgba(0,60,80,.3) 0%, transparent 50%),
    linear-gradient(180deg, #050810 0%, #080c0e 100%);
}
.bg-medical {
  background:
    radial-gradient(ellipse at 40% 50%, rgba(20,60,40,.3) 0%, transparent 50%),
    linear-gradient(180deg, #050c08 0%, #080f0a 100%);
}

/* ════════════════════ CHARACTER STAGE ════════════════════ */
#char-stage {
  position: absolute;
  bottom: 200px; left: 0; right: 0;
  height: calc(100vh - 200px);
  display: flex; align-items: flex-end; justify-content: center;
  gap: 40px; z-index: 1; pointer-events: none;
}

.char-sprite {
  position: absolute; bottom: 0;
  display: flex; flex-direction: column; align-items: center;
  transform-origin: bottom center;
  transition: transform .5s ease, opacity .5s ease, filter .5s;
}
.char-sprite.dim    { opacity: .28; filter: brightness(.4) saturate(0); }
.char-sprite.focus  { transform: translateX(-50%) scale(1.05); }
.char-sprite.normal { transform: translateX(-50%) scale(1); }
.char-sprite.enter  { animation: char-enter .55s ease-out; }
@keyframes char-enter {
  from { opacity: 0; transform: translateX(-50%) translateY(24px) scale(.96); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ════════════════════ DIALOGUE BOX ════════════════════ */
#dialogue-box {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 200px;
  background: linear-gradient(180deg, rgba(8,8,14,.88) 0%, rgba(5,5,10,.98) 100%);
  border-top: 1px solid rgba(255,107,43,.2);
  backdrop-filter: blur(8px);
  padding: 20px 32px 16px;
  z-index: 10; display: flex; flex-direction: column;
  cursor: pointer;
}
#speaker-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: 13px; letter-spacing: 2px;
  margin-bottom: 10px; height: 22px;
}
#dialogue-text {
  flex: 1; font-size: 17px; line-height: 1.7;
  color: var(--text); font-weight: 300;
}
.typewriter-cursor {
  display: inline-block; width: 2px; height: 18px;
  background: var(--ember); vertical-align: middle;
  animation: blink .7s step-end infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
#continue-hint {
  text-align: right; font-family: 'Share Tech Mono', monospace;
  font-size: 10px; color: var(--muted); letter-spacing: 2px;
  margin-top: 8px; opacity: 0; transition: opacity .3s;
  animation: pulse 2s ease-in-out infinite;
}
#continue-hint.visible { opacity: 1; }
@keyframes pulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }

/* ════════════════════ HUD ════════════════════ */
#hud {
  position: absolute; top: 0; left: 0; right: 0; height: 50px;
  background: linear-gradient(180deg, rgba(5,5,10,.92) 0%, transparent 100%);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; z-index: 10; pointer-events: none;
}
.hud-rank {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px; color: var(--muted); letter-spacing: 2px;
}
.hud-chapter {
  font-family: 'Cinzel Decorative', serif;
  font-size: 10px; color: rgba(255,107,43,.55);
  letter-spacing: 3px; text-transform: uppercase;
}

/* ════════════════════ RELATIONS BAR ════════════════════ */
#rel-bar {
  position: absolute; top: 56px; right: 20px;
  display: flex; gap: 10px; z-index: 10; align-items: center;
}
.rel-item {
  display: flex; align-items: center; gap: 5px;
  font-family: 'Share Tech Mono', monospace; font-size: 9px;
  opacity: .75; transition: opacity .3s;
}
.rel-item:hover { opacity: 1; }
.rel-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.rel-track {
  width: 44px; height: 3px;
  background: rgba(255,255,255,.08); border-radius: 2px; overflow: hidden;
}
.rel-fill {
  height: 100%; border-radius: 2px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ════════════════════ FLAGS BAR ════════════════════ */
#flags-bar {
  position: absolute; top: 80px; left: 20px;
  display: flex; gap: 6px; z-index: 10; flex-wrap: wrap; max-width: 260px;
}
.flag-tag {
  font-family: 'Share Tech Mono', monospace; font-size: 9px;
  padding: 2px 7px; border-radius: 2px; letter-spacing: 1px;
  border: 1px solid; opacity: .75;
  animation: flag-pop .4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes flag-pop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: .75; } }
.flag-bold        { color: #ff9d6f; border-color: rgba(255,157,111,.35); background: rgba(255,157,111,.07); }
.flag-disciplined { color: #7ab8d8; border-color: rgba(122,184,216,.35); background: rgba(122,184,216,.07); }
.flag-cunning     { color: #e8c066; border-color: rgba(232,192,102,.35); background: rgba(232,192,102,.07); }
.flag-cautious    { color: #c890d8; border-color: rgba(200,144,216,.35); background: rgba(200,144,216,.07); }
.flag-reckless    { color: #e03030; border-color: rgba(224,48,48,.35);   background: rgba(224,48,48,.07); }
.flag-loyal       { color: #5ad4c4; border-color: rgba(90,212,196,.35);  background: rgba(90,212,196,.07); }

/* ════════════════════ INVENTORY ════════════════════ */
#inventory-hud {
  position: absolute; bottom: 210px; left: 16px;
  display: flex; gap: 6px; z-index: 11; flex-wrap: wrap; max-width: 310px;
}
.inv-item {
  background: rgba(8,8,18,.9); border: 1px solid rgba(255,107,43,.18);
  padding: 4px 9px; font-family: 'Share Tech Mono', monospace;
  font-size: 9px; color: var(--muted); letter-spacing: 1px; white-space: nowrap;
}
.inv-item.new {
  animation: inv-pop .5s cubic-bezier(.34,1.56,.64,1);
  border-color: var(--ember); color: var(--pale-fire);
}
@keyframes inv-pop {
  from { transform: scale(0) translateY(8px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

/* ════════════════════ CHOICE PANEL ════════════════════ */
#choice-panel {
  position: absolute; bottom: 200px; left: 0; right: 0;
  display: none; flex-direction: column; align-items: center;
  gap: 8px; padding: 14px 32px; z-index: 20;
}
.choice-header {
  font-family: 'Share Tech Mono', monospace; font-size: 10px;
  color: var(--ember); letter-spacing: 3px; text-transform: uppercase;
  margin-bottom: 2px;
}
.choice-question {
  font-style: italic; font-size: 15px; color: var(--pale-fire);
  text-align: center; max-width: 580px; margin-bottom: 6px; line-height: 1.55;
}
.choice-btn {
  width: 100%; max-width: 580px;
  padding: 12px 20px 10px;
  background: rgba(8,8,18,.93); border: 1px solid rgba(255,107,43,.22);
  color: var(--text); font-family: 'Cormorant Garamond', serif;
  font-size: 16px; cursor: pointer; text-align: left;
  transition: all .22s; position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 3px;
}
.choice-btn-text { display: flex; align-items: baseline; gap: 10px; line-height: 1.5; }
.choice-arrow { color: var(--ember); transition: transform .2s; flex-shrink: 0; }
.choice-consequence {
  font-size: 12px; font-style: italic; color: var(--muted);
  padding-left: 18px; line-height: 1.4;
}
.choice-flags { display: flex; gap: 5px; padding-left: 18px; flex-wrap: wrap; }
.choice-flag-preview {
  font-family: 'Share Tech Mono', monospace; font-size: 9px;
  padding: 1px 6px; border-radius: 2px; opacity: .6;
}

.choice-btn:hover {
  background: rgba(255,107,43,.1); border-color: var(--ember);
  color: var(--pale-fire); transform: translateX(4px);
}
.choice-btn:hover .choice-arrow { transform: translateX(3px); }

/* ════════════════════ CHAT PANEL ════════════════════ */
#chat-panel {
  position: absolute; bottom: 200px; left: 0; right: 0;
  display: none; flex-direction: column; align-items: center;
  padding: 14px 32px; z-index: 20;
}
.chat-box {
  background: rgba(6,6,16,.96); border: 1px solid rgba(100,140,200,.22);
  max-width: 580px; width: 100%; padding: 14px 16px;
  max-height: 195px; overflow-y: auto;
}
.chat-title {
  font-family: 'Share Tech Mono', monospace; font-size: 9px;
  color: var(--frost); letter-spacing: 3px; margin-bottom: 10px; text-align: center;
}
.chat-msg { font-size: 13px; line-height: 1.6; margin-bottom: 5px; color: var(--muted); }
.chat-name { font-weight: 600; margin-right: 6px; }
.chat-msg.end  .chat-name { color: var(--rel-end); }
.chat-msg.tia  .chat-name { color: var(--rel-tia); }
.chat-msg.fab  .chat-name { color: var(--rel-fab); }
.chat-msg.ghelm .chat-name { color: var(--rel-ghelm); }
.chat-msg.lami .chat-name { color: var(--ember); }
.chat-close-btn {
  margin-top: 10px; padding: 7px 26px;
  background: transparent; border: 1px solid rgba(100,140,200,.28);
  color: var(--frost); font-family: 'Share Tech Mono', monospace;
  font-size: 10px; letter-spacing: 2px; cursor: pointer; transition: all .2s;
}
.chat-close-btn:hover { background: rgba(100,140,200,.1); }

/* ════════════════════ ARCHIVE PANEL ════════════════════ */
#archive-panel {
  position: absolute; top: 0; right: -100%; width: 340px; height: 100%;
  background: linear-gradient(135deg, rgba(8,8,18,.98), rgba(12,8,4,.98));
  border-left: 1px solid rgba(100,140,200,.22);
  z-index: 25; transition: right .4s ease;
  padding: 60px 22px 22px; overflow-y: auto;
}
#archive-panel.open { right: 0; }
.archive-title {
  font-family: 'Cinzel Decorative', serif; font-size: 13px;
  color: var(--frost); letter-spacing: 2px;
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 1px solid rgba(100,140,200,.18);
}
.archive-entry {
  margin-bottom: 16px; padding: 11px 13px;
  background: rgba(100,140,200,.04);
  border-left: 2px solid rgba(100,140,200,.22);
}
.archive-entry-title {
  font-family: 'Share Tech Mono', monospace; font-size: 9px;
  color: var(--frost); letter-spacing: 2px; margin-bottom: 6px; opacity: .7;
}
.archive-entry-text { font-size: 13px; line-height: 1.7; color: var(--muted); font-style: italic; }
.archive-empty { font-size: 13px; color: rgba(100,140,200,.3); font-style: italic; text-align: center; padding: 20px 0; }

#archive-btn {
  position: absolute; top: 58px; right: 16px;
  background: rgba(100,140,200,.07); border: 1px solid rgba(100,140,200,.22);
  color: var(--frost); font-family: 'Share Tech Mono', monospace;
  font-size: 10px; letter-spacing: 2px; padding: 5px 11px;
  cursor: pointer; z-index: 15; transition: all .2s;
}
#archive-btn:hover { background: rgba(100,140,200,.16); }
#archive-close {
  position: absolute; top: 14px; right: 14px;
  background: transparent; border: none;
  color: var(--frost); font-size: 20px; cursor: pointer;
  opacity: .45; transition: opacity .2s;
}
#archive-close:hover { opacity: 1; }

/* ════════════════════ ACHIEVEMENT ════════════════════ */
#achievement {
  position: absolute; top: 58px; left: 18px;
  background: linear-gradient(135deg, rgba(14,14,24,.97), rgba(20,12,5,.97));
  border: 1px solid var(--gold);
  padding: 11px 16px; max-width: 260px; z-index: 30;
  opacity: 0; transform: translateX(-115%);
  transition: all .4s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
#achievement.show { opacity: 1; transform: translateX(0); }
.ach-icon { font-size: 18px; margin-bottom: 3px; }
.ach-title {
  font-family: 'Share Tech Mono', monospace; font-size: 9px;
  color: var(--gold); letter-spacing: 3px; text-transform: uppercase; margin-bottom: 4px;
}
.ach-text { font-size: 13px; font-style: italic; color: var(--pale-fire); }

/* ════════════════════ TRANSITION + CHAPTER ════════════════════ */
#transition {
  position: absolute; inset: 0; background: var(--void);
  z-index: 50; pointer-events: none; opacity: 0; transition: opacity .38s;
}
#transition.fade-in { opacity: 1; }

#chapter-title {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; z-index: 40; pointer-events: none;
  opacity: 0; transition: opacity .5s;
}
#chapter-title.show { opacity: 1; }
.chap-num {
  font-family: 'Share Tech Mono', monospace; font-size: 10px;
  color: var(--ember); letter-spacing: 6px; text-transform: uppercase; margin-bottom: 10px;
}
.chap-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(18px, 3vw, 28px); color: var(--pale-fire);
  text-shadow: 0 0 30px rgba(255,107,43,.4);
}

/* ════════════════════ CONSEQUENCE FLASH ════════════════════ */
#consequence-flash {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(14px, 2.5vw, 22px);
  color: var(--pale-fire);
  text-shadow: 0 0 20px rgba(255,107,43,.5);
  text-align: center; max-width: 500px; line-height: 1.6;
  z-index: 45; pointer-events: none;
  opacity: 0; transition: opacity .4s;
}
#consequence-flash.show { opacity: 1; }

/* ════════════════════ END OVERLAY ════════════════════ */
#end-overlay {
  position: absolute; inset: 0; background: rgba(5,5,8,.93);
  z-index: 70; display: none; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: 18px;
}
#end-overlay.show { display: flex; }
.end-title {
  font-family: 'Cinzel Decorative', serif; font-size: 28px;
  color: var(--ember); text-shadow: 0 0 40px rgba(255,107,43,.5);
}
.end-sub {
  font-style: italic; font-size: 15px; color: var(--muted);
  max-width: 400px; line-height: 1.9;
}
.end-stats {
  display: flex; gap: 32px; margin-top: 6px;
}
.end-stat-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: 'Share Tech Mono', monospace; font-size: 10px; color: var(--muted);
}
.end-stat-val { font-size: 22px; color: var(--gold); font-family: 'Cormorant Garamond', serif; }
.end-btn {
  padding: 12px 40px; background: transparent;
  border: 1px solid var(--ember); color: var(--ember);
  font-family: 'Share Tech Mono', monospace; font-size: 11px;
  letter-spacing: 3px; cursor: pointer; transition: all .3s;
  margin-top: 8px;
}
.end-btn:hover { background: var(--ember); color: var(--void); }

/* ════════════════════ SPEAKER COLORS ════════════════════ */
.n-lami   { color: #ff9d6f; }
.n-ghelm  { color: #7ab8d8; }
.n-tia    { color: #c890d8; }
.n-end    { color: #e8c040; }
.n-fab    { color: #5ad4c4; }
.n-nar    { color: var(--muted); font-style: italic; }
.n-sys    { color: var(--gold); font-family: 'Share Tech Mono', monospace; font-size: 11px; }

/* ════════════════════ SCROLLBARS ════════════════════ */
#archive-panel::-webkit-scrollbar,
.chat-box::-webkit-scrollbar { width: 3px; }
#archive-panel::-webkit-scrollbar-thumb,
.chat-box::-webkit-scrollbar-thumb { background: rgba(100,140,200,.22); }

/* ════════════════════ MOBILE ════════════════════ */
@media (max-width: 600px) {
  #dialogue-box { height: 220px; padding: 14px 18px 10px; }
  #dialogue-text { font-size: 15px; }
  #choice-panel { padding: 10px 14px; }
  .choice-btn { font-size: 14px; padding: 10px 14px 8px; }
  #inventory-hud, #flags-bar { display: none; }
  #rel-bar { top: auto; bottom: 214px; right: 12px; }
}
