/* 폐허의 불빛 — 스타일시트
   색상 팔레트는 light_in_ruins_v3_network.svg에서 인용 */

:root {
  --c-bg: #14161A;
  --c-panel: #1E2128;
  --c-panel-2: #262A33;
  --c-border: #353A45;
  --c-text: #E8E5DD;
  --c-text-dim: #9A9388;
  --c-text-faint: #6A6358;

  --c-blue: #4A6B8C;       /* 재혁 / 주요 액션 */
  --c-precedent: #B04848;  /* 부정 전례 */
  --c-precedent-pos: #4A8B5B; /* 긍정 전례 */
  --c-spiral: #6B8E6E;     /* 상승 나선 */
  --c-beacon: #8B7AB0;     /* 비컨 */
  --c-warn: #D4A14F;       /* 경고/주의 */
  --c-danger: #C25656;     /* 위험 */

  --c-axis-food: #B89548;
  --c-axis-health: #C25656;
  --c-axis-morale: #6E8FB0;
  --c-axis-noise: #8B7AB0;

  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.65;
  letter-spacing: -0.005em;
  min-height: 100vh;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* ─── 타이틀 화면 ─── */
#titleScreen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #1E2128 0%, #0A0B0E 100%);
  z-index: 100;
}
#titleScreen h1 {
  font-size: 3.4rem; font-weight: 300;
  letter-spacing: 0.08em; margin: 0 0 0.5rem;
  color: var(--c-text);
}
#titleScreen .subtitle {
  font-size: 1.1rem; color: var(--c-text-dim);
  letter-spacing: 0.15em; margin-bottom: 3rem;
}
#titleScreen .credits {
  position: absolute; bottom: 2rem;
  font-size: 0.8rem; color: var(--c-text-faint);
  text-align: center; letter-spacing: 0.05em;
}
.title-buttons { display: flex; flex-direction: column; gap: 0.8rem; }
.title-buttons button {
  padding: 0.9rem 3rem;
  border: 1px solid var(--c-border);
  background: var(--c-panel);
  color: var(--c-text);
  letter-spacing: 0.1em;
  transition: all 0.2s;
  min-width: 240px;
}
.title-buttons button:hover {
  background: var(--c-panel-2);
  border-color: var(--c-blue);
}
.title-buttons button:disabled {
  opacity: 0.4; cursor: not-allowed;
}

/* ─── 게임 레이아웃 ─── */
#gameRoot { display: none; min-height: 100vh; }
#gameRoot.active { display: block; }

#topBar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 0.7rem 1.5rem;
  background: var(--c-panel);
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 20;
}
#topBar .day-label {
  font-weight: 600; font-size: 1.05rem;
  color: var(--c-text);
}
#topBar .day-label .season {
  color: var(--c-text-dim); font-weight: 400;
  font-size: 0.85rem; margin-left: 0.4rem;
}
#topBar .axes {
  display: flex; gap: 1.5rem;
  font-size: 0.9rem;
}
#topBar .axes .axis {
  display: flex; align-items: center; gap: 0.4rem;
}
#topBar .axes .axis .label {
  color: var(--c-text-dim); font-size: 0.78rem;
}
#topBar .axes .axis .value {
  font-weight: 600; min-width: 1.8rem; text-align: right;
}
#topBar .axes .axis .qual {
  font-size: 0.72rem; color: var(--c-text-faint);
}
#topBar .actions {
  display: flex; gap: 0.6rem;
}
#topBar .actions button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--c-border);
  border-radius: 3px;
  font-size: 0.82rem;
  color: var(--c-text-dim);
  transition: all 0.15s;
}
#topBar .actions button:hover {
  border-color: var(--c-blue); color: var(--c-text);
}

#layout {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  gap: 1rem;
  padding: 1rem 1.5rem;
  max-width: 1500px;
  margin: 0 auto;
}

#leftPanel, #rightPanel {
  display: flex; flex-direction: column; gap: 0.8rem;
}
.panel {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 0.75rem 0.85rem;
}
.panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--c-text-dim);
  text-transform: uppercase;
  border-bottom: 1px solid var(--c-border);
  padding-bottom: 0.35rem;
}
.panel .row {
  display: flex; justify-content: space-between;
  font-size: 0.85rem;
  padding: 0.15rem 0;
}
.panel .row .lbl { color: var(--c-text-dim); }
.panel .row .val { color: var(--c-text); font-weight: 500; }
.panel .row .val.dim { color: var(--c-text-faint); }

/* 자원 패널 — 그룹 헤더 + 추세 화살표 */
.res-group {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0.5rem 0 0.15rem; font-size: 0.68rem; letter-spacing: 0.08em;
  color: var(--c-spiral); text-transform: uppercase;
}
.res-group:first-child { margin-top: 0; }
.res-group span { font-size: 0.62rem; color: var(--c-text-faint); letter-spacing: 0; text-transform: none; }
.res-tr { font-style: normal; font-size: 0.72rem; margin-left: 0.25rem; }
.res-tr.up { color: var(--c-precedent-pos); }
.res-tr.down { color: var(--c-precedent); }
.panel .row .val.warn { color: var(--c-warn); }
.panel .row .val.danger { color: var(--c-danger); }
.panel .row .val.good { color: var(--c-spiral); }

.spiral-stage {
  font-size: 0.85rem;
  padding: 0.3rem 0;
  display: flex; justify-content: space-between;
}
.spiral-stage.active .lbl { color: var(--c-spiral); font-weight: 600; }
.spiral-stage .lbl { color: var(--c-text-faint); }
.spiral-stage .val { color: var(--c-text-dim); }

.precedent-item {
  border-left: 3px solid var(--c-precedent);
  padding: 0.35rem 0.5rem;
  margin: 0.4rem 0;
  background: rgba(176, 72, 72, 0.08);
  font-size: 0.82rem;
}
.precedent-item.pos {
  border-left-color: var(--c-precedent-pos);
  background: rgba(74, 139, 91, 0.08);
}
.precedent-item .name { display: block; color: var(--c-text); font-weight: 500; }
.precedent-item .meta { color: var(--c-text-faint); font-size: 0.75rem; }

/* ─── 시나리오 영역 ─── */
#scenarioPanel {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 1.8rem 2rem 1.5rem;
  min-height: 500px;
  display: flex; flex-direction: column;
}

/* 시나리오 일러스트 */
#sceneImage {
  width: 100%;
  margin: -0.3rem 0 1.2rem;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  background: #0A0B0E;
  aspect-ratio: 16 / 7;
  display: none;
}
#sceneImage.visible { display: block; }
#sceneImage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: fadeInImage 0.7s ease-out;
}
#sceneImage::after {
  /* 부드러운 그라데이션으로 텍스트와 자연스럽게 연결 */
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 40%;
  background: linear-gradient(to bottom, transparent, var(--c-panel));
  pointer-events: none;
}
@keyframes fadeInImage {
  from { opacity: 0; transform: scale(1.03); }
  to { opacity: 1; transform: scale(1); }
}
/* 사운드 토글 — 항상 화면 위에 떠 있는 작은 버튼 */
.sound-toggle {
  position: fixed; right: 14px; bottom: 14px; z-index: 500;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid #ffffff24; background: #1b1d24cc; color: #ffcf86;
  font-size: 1.05rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 12px #0007; backdrop-filter: blur(3px);
  transition: transform .08s, background .15s, border-color .15s;
}
.sound-toggle:hover { background: #262a34ee; border-color: #ffffff40; }
.sound-toggle:active { transform: scale(0.92); }
.sound-toggle.muted { color: #7c7e88; }

/* 하루 전환 — 암전(검은 막) → 타이틀 등장 → 클릭하면 다시 밝아짐 */
#dayBanner {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: flex-start; justify-content: center;
  pointer-events: none; opacity: 0; visibility: hidden;
  padding: 22vh 6vw 0;
  background: #000;   /* 암전 막 */
}
/* 암전 등장: 즉시 검게 깔림(게임 화면이 비치는 깜빡임 방지) → 그대로 유지(클릭 전까지) */
#dayBanner.show {
  pointer-events: auto;                 /* 전환 중 오클릭 흡수 + 클릭 넘기기 */
  cursor: pointer;
  opacity: 1; visibility: visible;      /* 페이드인 없이 바로 암전 */
}
/* 클릭하면 다시 밝아지며 사라짐 */
#dayBanner.show.out { animation: dayOut 0.55s ease forwards; }
@keyframes dayOut {
  from { opacity: 1; visibility: visible; }
  to   { opacity: 0; visibility: visible; }
}
.day-banner-inner {
  display: flex; flex-direction: column; align-items: center; gap: 1.3rem;
}
#dayBannerText {
  font-family: 'Galmuri14', 'Galmuri11', monospace;
  font-size: clamp(1.8rem, 4.6vw, 3.2rem); font-weight: 400;
  color: #ffcf86; text-align: center; line-height: 1.35;
  letter-spacing: 0.01em;
  text-shadow: 0 0 18px rgba(255,207,134,.25), 0 2px 4px #000;
}
/* 매일 핵심 3축 — 암전 화면에 같이 표시 */
#dayBannerStats { display: flex; gap: 1.6rem; justify-content: center; }
.db-stat {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  min-width: 4.5rem; padding: 0.5rem 0.9rem;
  border: 1px solid #ffffff1f; border-radius: 6px; background: #ffffff08;
}
.db-stat-l {
  font-size: 0.78rem; letter-spacing: 0.12em; color: #b9b6a4;
  font-family: 'Galmuri11', monospace;
}
.db-stat-v {
  font-size: clamp(1.3rem, 2.6vw, 1.8rem); font-weight: 700;
  font-family: 'Galmuri14', 'Galmuri11', monospace; line-height: 1;
}
.day-banner-hint {
  font-size: 0.74rem; letter-spacing: 0.1em; color: #6f6d63;
  font-family: 'Galmuri11', monospace;
}
/* 내용(타이틀+스탯): 암전이 깔린 뒤 등장 → 클릭 전까지 유지 */
#dayBanner.show .day-banner-inner { animation: dayContentIn 0.7s ease 0.35s both; }
@keyframes dayContentIn {
  from { opacity: 0; transform: translateY(10px); letter-spacing: 0.12em; }
  to   { opacity: 1; transform: translateY(0); letter-spacing: 0.01em; }
}

#sceneTitle {
  font-size: 1.3rem;
  font-weight: 500;
  margin: 0 0 1.2rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--c-border);
  letter-spacing: -0.01em;
}
#sceneBody {
  flex: 1;
  font-size: 0.96rem;
  line-height: 1.8;
  margin-bottom: 1.5rem;
}
#sceneBody .narration {
  margin: 0 0 1rem;
  color: var(--c-text);
}
#sceneBody .dialog {
  margin: 0.7rem 0 0.7rem 1.2rem;
  color: var(--c-text);
  border-left: 2px solid var(--c-border);
  padding-left: 1rem;
}
#sceneBody .dialog .speaker {
  display: inline-block; font-weight: 600;
  color: var(--c-blue); margin-right: 0.5rem;
}
#sceneBody .system-note {
  margin: 0.8rem 0; padding: 0.5rem 0.9rem;
  background: rgba(255,255,255,0.03);
  border-left: 3px solid var(--c-warn);
  color: var(--c-text-dim);
  font-size: 0.86rem;
}
#sceneBody .resolution {
  margin: 1.2rem 0 0.5rem;
  padding: 0.8rem 1rem;
  background: rgba(74, 107, 140, 0.08);
  border-left: 3px solid var(--c-blue);
  color: var(--c-text);
}
#sceneBody .key-line {
  margin-top: 1rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--c-border);
  color: var(--c-text-dim);
  font-style: italic;
  font-size: 0.88rem;
}

#choices {
  display: flex; flex-direction: column; gap: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--c-border);
}
.choice-btn {
  text-align: left;
  padding: 0.85rem 1.1rem;
  background: var(--c-panel-2);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  color: var(--c-text);
  transition: all 0.15s;
  display: flex; align-items: flex-start; gap: 0.7rem;
}
.choice-btn:hover {
  border-color: var(--c-blue);
  background: rgba(74, 107, 140, 0.12);
}
.choice-btn .letter {
  font-weight: 700; color: var(--c-blue);
  min-width: 1.2rem;
}
.choice-btn .body { flex: 1; line-height: 1.55; }
.choice-btn.risk-warn .letter { color: var(--c-warn); }
.choice-btn.risk-danger .letter { color: var(--c-danger); }
.choice-btn.risk-danger:hover { border-color: var(--c-danger); }

#nextDayBtn {
  margin-top: 0.5rem;
  padding: 0.85rem 1.5rem;
  background: var(--c-blue);
  border: 1px solid var(--c-blue);
  border-radius: 3px;
  color: white;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-align: center;
  transition: all 0.15s;
}
#nextDayBtn:hover {
  background: #5C7DA0;
}

/* ─── 인물 카드 ─── */
#characterCards {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.5rem;
  padding: 0.8rem 1.5rem 1.5rem;
  max-width: 1500px;
  margin: 0 auto;
}
.char-card {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 3px;
  padding: 0.55rem 0.6rem;
  font-size: 0.75rem;
  position: relative;
  overflow: hidden;
}
.char-card::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--char-color, var(--c-text-faint));
}
.char-card .name {
  font-weight: 600; font-size: 0.85rem;
  display: flex; justify-content: space-between;
  align-items: baseline;
}
.char-card .name .role {
  font-weight: 400; font-size: 0.7rem; color: var(--c-text-faint);
}
.char-card .bar {
  height: 4px; background: var(--c-border);
  border-radius: 2px; overflow: hidden;
  margin: 0.25rem 0;
}
.char-card .bar-fill {
  height: 100%;
  transition: width 0.3s;
}
.char-card .bar.health .bar-fill { background: var(--c-axis-health); }
.char-card .bar.morale .bar-fill { background: var(--c-axis-morale); }
.char-card .bar-label {
  display: flex; justify-content: space-between;
  font-size: 0.68rem; color: var(--c-text-dim);
}
.char-card .status {
  margin-top: 0.3rem; font-size: 0.7rem;
  color: var(--c-text-faint);
}
.char-card .status.injured { color: var(--c-warn); }
.char-card .status.critical, .char-card .status.dying { color: var(--c-danger); font-weight: 600; }
.char-card.dead {
  opacity: 0.4;
  filter: grayscale(0.7);
}
.char-card.dead .name { text-decoration: line-through; }

/* ─── 엔딩 화면 ─── */
#endingOverlay {
  position: fixed; inset: 0;
  background: var(--c-bg);
  z-index: 340;       /* 마을(200) 위 — 마을이 메인 표면일 때도 엔딩이 보이도록 */
  overflow-y: auto;
  padding: 3rem 2rem;
  display: none;
}
#endingOverlay.active { display: block; }
.ending-container {
  max-width: 760px; margin: 0 auto;
}
.ending-title {
  font-size: 2.6rem; font-weight: 300;
  letter-spacing: 0.05em; margin: 0;
  color: var(--c-text);
}
.ending-subtitle {
  font-size: 1rem; color: var(--c-text-dim);
  letter-spacing: 0.1em; margin: 0.3rem 0 2rem;
}
/* 엔딩 히어로 일러스트 (assets/images/endings/{id}.png, 없으면 JS가 숨김) */
.ending-hero {
  margin: 0 0 2rem; border-radius: 6px; overflow: hidden;
  aspect-ratio: 16 / 9; background: #0a0b0e;
  border: 1px solid var(--c-border);
  box-shadow: 0 8px 28px rgba(0,0,0,.5), inset 0 0 60px rgba(0,0,0,.35);
}
.ending-hero img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  image-rendering: pixelated;
}
#endingOverlay.enter .ending-hero { animation: edHero 1.1s ease .55s both; }
@keyframes edHero { from { opacity: 0; transform: scale(1.03); } to { opacity: 1; transform: scale(1); } }
.ending-section {
  margin: 2rem 0; padding-top: 1.5rem;
  border-top: 1px solid var(--c-border);
}
.ending-section h2 {
  font-size: 0.85rem; font-weight: 500;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--c-text-dim); margin: 0 0 1rem;
}
.ending-narration {
  font-size: 1.05rem; line-height: 1.85;
  color: var(--c-text);
}
.ending-narration p { margin: 0 0 1rem; }
.ending-roster {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}
.ending-roster .row {
  display: flex; justify-content: space-between;
  padding: 0.4rem 0.7rem;
  background: var(--c-panel);
  border-radius: 3px;
  font-size: 0.88rem;
}
.ending-roster .row.dead { opacity: 0.5; text-decoration: line-through; }
.ending-ledger { font-size: 0.9rem; }
.ending-ledger .item {
  padding: 0.5rem 0.8rem;
  margin: 0.4rem 0;
  border-left: 3px solid var(--c-precedent);
  background: rgba(176, 72, 72, 0.06);
}
.ending-ledger .item.pos {
  border-left-color: var(--c-precedent-pos);
  background: rgba(74, 139, 91, 0.06);
}
.ending-actions {
  margin-top: 3rem; display: flex; gap: 1rem; justify-content: center;
}
.ending-actions button {
  padding: 0.8rem 2rem;
  border: 1px solid var(--c-border);
  background: var(--c-panel);
  color: var(--c-text);
  letter-spacing: 0.1em;
  transition: all 0.2s;
}
.ending-actions button:hover {
  background: var(--c-panel-2); border-color: var(--c-blue);
}

/* ─── 컷씬 모달 ─── */
#cutsceneOverlay {
  position: fixed; inset: 0;
  background: rgba(10, 11, 14, 0.92);
  backdrop-filter: blur(6px);
  z-index: 320;       /* 마을(200) 위 — 컷씬이 마을 위에서 재생 */
  display: none;
  align-items: center; justify-content: center;
  flex-direction: column;
  padding: 2rem;
  cursor: pointer;
}
#cutsceneOverlay.active { display: flex; }
.cutscene-stage {
  max-width: 900px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cutscene-image {
  width: 100%;
  max-height: 60vh;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  background: #14161A;
  aspect-ratio: 16 / 9;
  margin-bottom: 1.5rem;
}
.cutscene-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: cutsceneIn 0.6s ease-out;
}
/* 일러스트가 아직 없는 장면 — 빈 프레임 폴백 (업로드 전 슬롯 표시) */
.cutscene-placeholder {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: .55rem;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(224,178,74,.05), transparent 65%),
    repeating-linear-gradient(45deg, #16181d 0 14px, #14161a 14px 28px);
}
.cutscene-placeholder.show { display: flex; }
.cs-ph-frame {
  position: absolute; inset: 12px;
  border: 1px dashed rgba(246,241,226,.22);
  border-radius: 3px;
  pointer-events: none;
}
.cs-ph-cap { color: rgba(246,241,226,.5); font-size: .95rem; letter-spacing: .12em; }
.cs-ph-file { color: rgba(246,241,226,.28); font-size: .72rem; font-family: monospace; }
@keyframes cutsceneIn {
  from { opacity: 0; transform: scale(1.05); }
  to { opacity: 1; transform: scale(1); }
}
.cutscene-text {
  font-size: 1.18rem;
  line-height: 1.8;
  color: #f6f1e2;
  text-align: center;
  max-width: 680px;
  min-height: 4em;
  word-break: keep-all;        /* 단어 중간 잘림 방지 (한국어 어절 단위 줄바꿈) */
  overflow-wrap: break-word;
  padding: 0.7rem 1.4rem;
  border-radius: 6px;
  background: rgba(12, 11, 9, 0.55);
  box-shadow: 0 4px 18px rgba(0,0,0,.35);
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  animation: textFadeIn 0.8s 0.3s both;
}
@keyframes textFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.cutscene-progress {
  margin-top: 1.5rem;
  display: flex; gap: 0.5rem;
}
.cutscene-progress .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--c-text-faint);
  transition: background 0.3s;
}
.cutscene-progress .dot.active { background: var(--c-text); }
.cutscene-hint {
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--c-text-faint);
  letter-spacing: 0.15em;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.85; }
}

/* ─── 토스트 / 시스템 알림 ─── */
#toastContainer {
  position: fixed; top: 70px; right: 20px;
  z-index: 360;       /* 항상 최상단 — 마을/컷씬/엔딩 위 */
  display: flex; flex-direction: column; gap: 0.5rem;
  pointer-events: none;
}
.toast {
  background: var(--c-panel-2);
  border-left: 3px solid var(--c-blue);
  padding: 0.6rem 1rem;
  border-radius: 3px;
  font-size: 0.85rem;
  max-width: 320px;
  animation: toast-in 0.25s ease-out, toast-out 0.4s 4s forwards;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.toast.precedent-neg { border-left-color: var(--c-precedent); }
.toast.precedent-pos { border-left-color: var(--c-precedent-pos); }
.toast.smallwin { border-left-color: var(--c-warn); }
.toast.spiral { border-left-color: var(--c-spiral); }
.toast.raid { border-left-color: var(--c-danger); }
.toast.beacon { border-left-color: var(--c-beacon); }

/* 비컨 포트레이트 (주간 비컨 패널) */
.beacon-port {
  display: flex; justify-content: center; margin: 0 0 0.6rem;
}
.beacon-port img {
  width: 84px; height: 84px; object-fit: cover; object-position: top center;
  border: 2px solid var(--c-beacon); border-radius: 4px;
  background: #15131c; image-rendering: pixelated;
  box-shadow: 0 0 10px rgba(139,122,176,.5), inset 0 1px 0 #ffffff14;
  animation: beaconPortPulse 2s ease-in-out infinite;
}
@keyframes beaconPortPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(139,122,176,.4), inset 0 1px 0 #ffffff14; }
  50%      { box-shadow: 0 0 16px rgba(139,122,176,.75), inset 0 1px 0 #ffffff14; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(20px); }
}

/* ─── 반응형 (좁은 화면 폴백) ─── */
@media (max-width: 1100px) {
  #layout {
    grid-template-columns: 1fr;
  }
  #leftPanel, #rightPanel {
    flex-direction: row; flex-wrap: wrap;
  }
  .panel { flex: 1 1 200px; }
  #characterCards {
    grid-template-columns: repeat(5, 1fr);
  }
}
@media (max-width: 700px) {
  #characterCards {
    grid-template-columns: repeat(2, 1fr);
  }
  #topBar .axes { font-size: 0.78rem; gap: 0.8rem; }
}

/* ═══════════════════════════════════════════════════════
   픽셀 테마 통일 — 타이틀 · 엔딩을 마을(메탈슬러그) 룩에 맞춤
   (Galmuri 픽셀 폰트 + 앰버 + 금속 패널 + 스텐실 + 하드섀도우)
   ═══════════════════════════════════════════════════════ */

/* ── 타이틀 화면 ── */
#titleScreen h1 {
  font-family: 'Galmuri14', 'Galmuri11', monospace;
  font-weight: 400; letter-spacing: 0.04em;
  color: #ffcf86; text-shadow: 2px 2px 0 #000, 0 0 24px rgba(255,207,134,.18);
}
#titleScreen .subtitle {
  font-family: 'Galmuri11', monospace;
  color: #8e8f5e; text-shadow: 1px 1px 0 #000;
}
#titleScreen .credits {
  font-family: 'Galmuri11', monospace; color: #6a6a48; line-height: 1.7;
}
.title-buttons button {
  font-family: 'Galmuri11', monospace; letter-spacing: 0.04em;
  border-radius: 2px; border: 2px solid #14130d; color: #e8e5d0;
  background: linear-gradient(180deg, #3c3f31, #24261b);
  box-shadow: inset 0 1px 0 #5e624799, inset 0 -2px 0 #0009;
  text-shadow: 1px 1px 0 #000; transition: background .12s, color .12s, transform .06s;
}
.title-buttons button:hover {
  background: linear-gradient(180deg, #7a6526, #4a3c14);
  border-color: #14130d; color: #ffcf86;
}
.title-buttons button:active { transform: translateY(1px); box-shadow: inset 0 2px 5px #000a; }
.title-buttons button:disabled { opacity: 0.35; }
.title-buttons button:disabled:hover { background: linear-gradient(180deg, #3c3f31, #24261b); color: #e8e5d0; }
/* 첫 버튼(새 게임) = 앰버 강조 */
.title-buttons button:first-child {
  background: linear-gradient(180deg, #7a6526, #4a3c14); color: #ffcf86;
}
.title-buttons button:first-child:hover { background: linear-gradient(180deg, #8a7330, #564618); color: #fff; }

/* ── 엔딩 화면 ── */
#endingOverlay {
  background:
    radial-gradient(ellipse at 50% 0%, #1a1d24 0%, #0a0b0e 70%);
}
.ending-title {
  font-family: 'Galmuri14', 'Galmuri11', monospace; font-weight: 400;
  color: #ffcf86; text-shadow: 2px 2px 0 #000, 0 0 20px rgba(255,207,134,.15);
}
.ending-subtitle {
  font-family: 'Galmuri11', monospace; color: #8e8f5e; text-shadow: 1px 1px 0 #000;
}
.ending-section h2 {
  font-family: 'Galmuri11', monospace; color: #d8c882;
  letter-spacing: 1px; text-transform: none; text-shadow: 1px 1px 0 #000;
}
.ending-section h2::before { content: '▌'; color: var(--c-warn); margin-right: 5px; }
.ending-section { border-top: 2px solid #14130d; }
/* 본문 내레이션은 가독성 위해 Noto 유지, 톤만 살짝 따뜻하게 */
.ending-narration { color: #d8d4c2; }
/* 생존자 명단 = 군용 태그 */
.ending-roster .row {
  border-radius: 1px; border: 1px solid #14130d; border-left: 4px solid #4a4d38;
  background: linear-gradient(180deg, #2a2c20, #181a12);
  box-shadow: inset 0 1px 0 #4a4d3855;
  font-family: 'Galmuri11', monospace; text-shadow: 1px 1px 0 #000;
}
.ending-roster .row.dead {
  border-left-color: #5a2020; opacity: 0.55; text-decoration: none; color: #a07070;
}
/* 전례 원장 = 금속 + 색 좌측바 유지 */
.ending-ledger .item {
  border-radius: 1px; border: 1px solid #14130d; border-left: 3px solid var(--c-precedent);
  background: linear-gradient(180deg, #261b1b, #181210);
}
.ending-ledger .item.pos {
  border-left-color: var(--c-precedent-pos);
  background: linear-gradient(180deg, #1b2620, #101810);
}
.ending-ledger .item strong { font-family: 'Galmuri11', monospace; color: #ffcf86; }
/* 30일 타임라인 헤더 픽셀 */
#endingTimeline th { font-family: 'Galmuri11', monospace; color: #8e8f5e !important; }
/* 액션 버튼 = 금속 */
.ending-actions button {
  font-family: 'Galmuri11', monospace; letter-spacing: 0.04em;
  border-radius: 2px; border: 2px solid #14130d; color: #e8e5d0;
  background: linear-gradient(180deg, #3c3f31, #24261b);
  box-shadow: inset 0 1px 0 #5e624799, inset 0 -2px 0 #0009;
  text-shadow: 1px 1px 0 #000;
}
.ending-actions button:hover {
  background: linear-gradient(180deg, #7a6526, #4a3c14); border-color: #14130d; color: #ffcf86;
}
.ending-actions button:active { transform: translateY(1px); box-shadow: inset 0 2px 5px #000a; }

/* ═══════════════════════════════════════════════════════
   엔딩 연출 — 시네마틱 페이드인 + 엔딩별 무드 색 + 타이틀 극적 등장
   ═══════════════════════════════════════════════════════ */
#endingOverlay { opacity: 0; transition: opacity .7s ease; }
#endingOverlay.enter { opacity: 1; }

/* 엔딩별 무드: 어둠(소멸/붕괴) · 따뜻함(빛의마을/안전지대) · 씁쓸(잊혀진/흔들리는/생존) */
#endingOverlay.mood-dark { background: radial-gradient(ellipse at 50% -5%, #1c1418 0%, #07080a 68%); --mood: #c08080; --moodglow: rgba(190,95,95,.28); }
#endingOverlay.mood-warm { background: radial-gradient(ellipse at 50% -5%, #261e12 0%, #0a0907 68%); --mood: #ffcf86; --moodglow: rgba(255,200,120,.34); }
#endingOverlay.mood-grey { background: radial-gradient(ellipse at 50% -5%, #161a20 0%, #08090b 68%); --mood: #a6b2bd; --moodglow: rgba(160,175,190,.22); }

/* 타이틀 — 무드 색 + 극적 등장(레터스페이싱 수렴 + 글로우 점등) */
#endingOverlay .ending-title { color: var(--mood, #ffcf86); }
#endingOverlay.enter .ending-title    { animation: edTitle 1.5s cubic-bezier(.2,.7,.2,1) both; }
#endingOverlay.enter .ending-subtitle { animation: edSub 1s ease .75s both; }
#endingOverlay.enter .ending-section,
#endingOverlay.enter .ending-actions  { animation: edFade .9s ease .95s both; }
@keyframes edTitle {
  0%   { opacity: 0; transform: translateY(16px) scale(.95); letter-spacing: .3em; text-shadow: none; }
  55%  { opacity: 1; }
  100% { opacity: 1; transform: none; letter-spacing: .04em; text-shadow: 2px 2px 0 #000, 0 0 28px var(--moodglow); }
}
@keyframes edSub  { from { opacity: 0; } to { opacity: 1; } }
@keyframes edFade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* 생존자 명단/전례 좌측바도 무드 색으로 미세 통일 */
#endingOverlay .ending-section h2::before { color: var(--mood); }

/* 컷씬 시네마틱 마감 — 비네트 + 프레임 */
.cutscene-image { border: 1px solid #2a2620; box-shadow: 0 18px 54px #000c, inset 0 0 70px #0007; }
.cutscene-image::after { content: ''; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 95px 20px rgba(0,0,0,.55); border-radius: 4px; }
.cutscene-hint { font-family: 'Galmuri11', monospace; letter-spacing: 1px; }

/* ── 컷씬 톤: plain(자동, 담백) vs reward(스몰윈, "잘 골랐다" 금색 보상) ── */
.cutscene-badge { display: none; }
#cutsceneOverlay.tone-reward {
  background: radial-gradient(ellipse at 50% 28%, #2a200f 0%, rgba(8,7,4,.95) 68%);
}
#cutsceneOverlay.tone-reward .cutscene-badge {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  margin-bottom: 1rem; padding: 7px 22px; border-radius: 16px;
  font-family: 'Galmuri11', monospace;
  color: #2a1e08; background: linear-gradient(180deg, #ffd97a, #e0a64a);
  border: 1px solid #ffe9b0; box-shadow: 0 2px 14px rgba(224,166,74,.55);
  animation: cutBadgePop 0.5s cubic-bezier(.2,1.5,.4,1) both;
}
#cutsceneOverlay.tone-reward .cb-kicker { font-size: 0.62rem; letter-spacing: 0.14em; opacity: 0.82; }
#cutsceneOverlay.tone-reward .cb-name { font-size: 1rem; font-weight: 700; letter-spacing: 0.01em; text-shadow: 0 1px 0 #ffe9b099; }
@keyframes cutBadgePop { 0% { opacity: 0; transform: scale(.6) translateY(10px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
#cutsceneOverlay.tone-reward .cutscene-image {
  /* 스몰윈 카드는 1:1 → 정사각 박스로 띄워 안 잘리게 */
  aspect-ratio: 1 / 1;
  width: min(54vh, 88vw);
  max-height: 54vh;
  border: 2px solid #e0b85a;
  box-shadow: 0 18px 54px #000c, inset 0 0 70px #0007, 0 0 38px rgba(224,176,74,.32);
  animation: cutGoldGlow 2.4s ease-in-out infinite;
}
@keyframes cutGoldGlow {
  0%, 100% { box-shadow: 0 18px 54px #000c, inset 0 0 70px #0007, 0 0 26px rgba(224,176,74,.26); }
  50%      { box-shadow: 0 18px 54px #000c, inset 0 0 70px #0007, 0 0 54px rgba(224,176,74,.5); }
}
#cutsceneOverlay.tone-reward .cutscene-text { color: #f3e6c8; }
#cutsceneOverlay.tone-reward .cutscene-image::after { box-shadow: inset 0 0 95px 20px rgba(40,28,8,.5); }

/* 공용 뱃지 2단(킥커+이름) */
#cutsceneOverlay .cb-kicker { font-size: 0.62rem; letter-spacing: 0.14em; opacity: 0.82; }
#cutsceneOverlay .cb-name { font-size: 1rem; font-weight: 700; letter-spacing: 0.01em; }

/* ── 나쁜/무거운 선택(bad) — 붉은 경고 프레임 ── */
#cutsceneOverlay.tone-bad {
  background: radial-gradient(ellipse at 50% 28%, #2a1010 0%, rgba(8,5,4,.95) 68%);
}
#cutsceneOverlay.tone-bad .cutscene-badge {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  margin-bottom: 1rem; padding: 7px 22px; border-radius: 16px;
  font-family: 'Galmuri11', monospace;
  color: #2a0c0c; background: linear-gradient(180deg, #f0a0a0, #c25656);
  border: 1px solid #ffc8c8; box-shadow: 0 2px 14px rgba(200,70,70,.5);
  animation: cutBadgePop 0.5s cubic-bezier(.2,1.5,.4,1) both;
}
#cutsceneOverlay.tone-bad .cutscene-image {
  border: 2px solid #c25656;
  box-shadow: 0 18px 54px #000c, inset 0 0 70px #0007, 0 0 38px rgba(200,70,70,.3);
  animation: cutRedGlow 2.2s ease-in-out infinite;
}
@keyframes cutRedGlow {
  0%, 100% { box-shadow: 0 18px 54px #000c, inset 0 0 70px #0007, 0 0 24px rgba(200,70,70,.24); }
  50%      { box-shadow: 0 18px 54px #000c, inset 0 0 70px #0007, 0 0 52px rgba(200,70,70,.46); }
}
#cutsceneOverlay.tone-bad .cutscene-text { color: #f0d8d8; }
#cutsceneOverlay.tone-bad .cutscene-image::after { box-shadow: inset 0 0 95px 20px rgba(40,8,8,.5); }

/* ── NEW 카드 획득 강조(컷씬 뱃지) ── */
#cutsceneOverlay .cb-kicker.cb-new { animation: cutNewBlink 0.6s ease-in-out 4; }
@keyframes cutNewBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ══════ 작은 승리 수집 갤러리 ══════ */
#collectionOverlay {
  position: fixed; inset: 0; z-index: 350; display: none;
  background: rgba(8, 9, 12, .94);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 2rem;
}
#collectionOverlay.active { display: flex; }
.collection-panel {
  width: 100%; max-width: 940px; max-height: 86vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #1a1d24, #111319);
  border: 1px solid var(--c-border); border-radius: 12px; padding: 1.2rem 1.4rem;
  box-shadow: 0 24px 70px #000b;
}
.collection-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.collection-head h2 {
  margin: 0; color: #ffcf86; font-size: 1.2rem; letter-spacing: 0.02em;
  font-family: 'Galmuri14', 'Galmuri11', monospace;
}
.collection-count {
  color: var(--c-text-dim); font-family: 'Galmuri11', monospace; font-size: 0.95rem;
  padding: 2px 10px; border: 1px solid var(--c-border); border-radius: 14px;
}
.collection-close {
  margin-left: auto; background: none; border: 1px solid var(--c-border);
  color: var(--c-text-dim); width: 34px; height: 30px; border-radius: 6px; cursor: pointer;
}
.collection-close:hover { color: var(--c-danger); border-color: var(--c-danger); }
.collection-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 12px; overflow-y: auto; padding: 2px;
}
.coll-card {
  background: linear-gradient(180deg, #20232b, #161922);
  border: 1px solid #2a2d36; border-radius: 8px; padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.coll-card.locked { opacity: 0.5; }
.coll-art {
  aspect-ratio: 1 / 1; border-radius: 5px; overflow: hidden; background: #0d0f14;
  display: flex; align-items: center; justify-content: center; color: #3a3f4a; font-size: 2.6rem;
  border: 1px solid #20232b;
}
.coll-art img { width: 100%; height: 100%; object-fit: cover; }
.coll-name { font-size: 0.9rem; font-weight: 700; color: #ffcf86; }
.coll-card.locked .coll-name { color: #5a5f6a; }
.coll-desc {
  font-size: 0.72rem; line-height: 1.5; color: var(--c-text-dim);
  font-family: 'Noto Sans KR', sans-serif;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.collection-foot {
  margin-top: 1rem; padding-top: 0.8rem; border-top: 1px solid var(--c-border);
  font-size: 0.74rem; color: var(--c-text-faint); font-family: 'Noto Sans KR', sans-serif;
}

/* ══════ 엔딩 카드 수집 갤러리 (작은 승리 카드 스타일 재사용 + 결말 전용) ══════ */
#endingCollectionOverlay {
  position: fixed; inset: 0; z-index: 350; display: none;
  background: rgba(8, 9, 12, .94);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  align-items: center; justify-content: center; padding: 2rem;
}
#endingCollectionOverlay.active { display: flex; }
.ec-card { position: relative; }
.ec-card .coll-art { aspect-ratio: 4 / 3; }
.ec-card.survival { border-color: #3a4a3a; }
.ec-card.gameover { border-color: #4a2e2e; }
.ec-type {
  position: absolute; top: 13px; right: 13px;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 1px 7px; border-radius: 10px; font-family: 'Galmuri11', monospace;
}
.ec-type.survival { color: #b8e0b0; background: rgba(58,74,58,.85); border: 1px solid #4a6a4a; }
.ec-type.gameover { color: #e8a8a8; background: rgba(74,46,46,.85); border: 1px solid #6a3a3a; }
.ec-card.locked .ec-type { opacity: .4; }
.ec-sub {
  font-size: 0.64rem; letter-spacing: 0.06em; color: #8a8f9a;
  font-family: 'Galmuri11', monospace; margin-top: -2px;
}

/* 엔딩 화면 — '엔딩 카드 수집됨' 배지 */
.ending-collect-badge {
  display: inline-block; margin-left: 0.5rem;
  font-size: 0.7rem; font-family: 'Galmuri11', monospace; letter-spacing: 0.04em;
  padding: 2px 9px; border-radius: 11px; vertical-align: middle;
  color: var(--c-text-dim); border: 1px solid var(--c-border); background: rgba(255,255,255,.03);
}
.ending-collect-badge.is-new {
  color: #1a140a; background: linear-gradient(180deg, #ffd98a, #e7b257);
  border-color: #ffcf86; font-weight: 700;
  animation: endingBadgePop .5s cubic-bezier(.2,1.5,.4,1) both;
}
@keyframes endingBadgePop { 0% { opacity: 0; transform: scale(.6); } 100% { opacity: 1; transform: scale(1); } }

/* 선택 결과 변화량 칩 — 컷씬에 크게 표시 (초록=상승, 빨강=하락) */
.cutscene-result { display: none; flex-wrap: wrap; gap: 0.55rem; justify-content: center; margin: 0.1rem 0 1.3rem; }
.cs-rchip {
  display: inline-flex; align-items: baseline; gap: 0.35rem;
  padding: 0.4rem 0.95rem; border-radius: 9px; border: 1px solid;
  font-size: 1.0rem; font-family: 'Galmuri11', monospace; letter-spacing: 0.02em;
  animation: csChipPop .45s cubic-bezier(.2,1.5,.4,1) both;
}
.cs-rchip b { font-size: 1.35rem; font-weight: 700; }
.cs-rchip.up   { color: #cbeabf; border-color: #4a7a3e; background: rgba(74,122,62,.2); }
.cs-rchip.up b { color: #8fe070; }
.cs-rchip.down { color: #ecbcbc; border-color: #7a3e3e; background: rgba(122,62,62,.2); }
.cs-rchip.down b { color: #ff9090; }
@keyframes csChipPop { 0% { opacity: 0; transform: scale(.7) translateY(10px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }

/* 나쁜 사건 컷씬 — 진입 시 화면 흔들림 (시스템1 즉각 피드백) */
.cutscene-stage.shake { animation: cutsceneShake .5s cubic-bezier(.36,.07,.19,.97) 1; }
@keyframes cutsceneShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-9px, 2px); }
  30% { transform: translate(8px, -3px); }
  45% { transform: translate(-6px, 2px); }
  60% { transform: translate(5px, -1px); }
  75% { transform: translate(-3px, 1px); }
  90% { transform: translate(2px, 0); }
}

/* 마을 연대기 — 엔딩 '30일의 기록' 상단의 사건 연표 */
.ending-chronicle {
  margin-bottom: 1.1rem;
  border-left: 2px solid var(--c-border);
  padding-left: 0.9rem;
  display: flex; flex-direction: column; gap: 0.32rem;
}
.chron-row { font-size: 0.86rem; color: var(--c-text-dim); display: flex; gap: 0.6rem; word-break: keep-all; }
.chron-row b { color: var(--c-text-faint); min-width: 2.6rem; font-weight: 600; }
.chron-row.death b, .chron-row.death span { color: var(--c-danger); }
.chron-row.neg span { color: #c08585; }
.chron-row.pos span { color: var(--c-spiral); }
.chron-row.raid span { color: var(--c-warn); }
.chron-row.beacon span { color: var(--c-beacon); }
