/* 마지막 날들 — 다크 서바이벌 테마 */
:root {
  --bg: #0E0E10;
  --bg-soft: #16161a;
  --panel: #1b1b20;
  --blood: #B3122B;
  --blood-bright: #e21f3c;
  --amber: #E0A800;
  --text: #E8E8E8;
  --muted: #8a8a92;
  --line: #2a2a31;
  --good: #5fae6a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", system-ui, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* 화면 전환 */
.screen { display: none; padding: 28px 20px 60px; min-height: 100vh; }
.screen.active { display: block; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 타이틀 */
.title-wrap { text-align: center; padding-top: 14vh; }
.game-title {
  font-size: 56px; font-weight: 900; letter-spacing: -2px;
  color: var(--text);
  text-shadow: 0 0 28px rgba(179,18,43,.55);
}
.game-sub { color: var(--blood); letter-spacing: 10px; font-size: 13px; margin-top: 6px; font-weight: 700; }
.tagline { color: var(--muted); margin: 26px auto 0; max-width: 420px; font-size: 15px; }
.title-buttons { margin-top: 40px; display: flex; flex-direction: column; gap: 12px; max-width: 280px; margin-left: auto; margin-right: auto; }
.api-warn { margin-top: 26px; color: var(--amber); font-size: 13px; }
.api-warn code { background: #000; padding: 1px 6px; border-radius: 4px; }
.model-tag-wrap { margin-top: 22px; color: var(--muted); font-size: 12px; letter-spacing: .5px; }
.model-tag-wrap #model-tag { color: #b6b6be; }

/* 이어하기 */
.btn-continue { background: var(--bg-soft); border: 1px solid var(--amber); color: var(--amber); display: flex; flex-direction: column; gap: 2px; }
.btn-continue:hover { background: rgba(224,168,0,.12); }
.btn-continue .cont-info { font-size: 12px; color: var(--muted); font-weight: 400; }

/* 버튼 */
.btn {
  font-family: inherit; font-size: 15px; font-weight: 700;
  padding: 13px 18px; border-radius: 10px; border: 1px solid transparent;
  cursor: pointer; transition: .15s; color: var(--text); background: var(--bg-soft);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blood); border-color: var(--blood-bright); }
.btn-primary:hover { background: var(--blood-bright); box-shadow: 0 6px 20px rgba(179,18,43,.35); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-amber { background: var(--amber); color: #1a1500; border-color: var(--amber); }
.btn-amber:hover { filter: brightness(1.08); }
.btn-tiny { padding: 6px 12px; font-size: 13px; background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* 패널 */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 26px 24px; margin-top: 10px;
}
.panel h2 { font-size: 24px; margin-bottom: 4px; }
.muted { color: var(--muted); font-size: 14px; }

/* 입력 필드 */
.field { display: block; margin-top: 18px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; font-size: 16px; font-family: inherit;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
}
.field input:focus { outline: none; border-color: var(--blood); }

/* 설문 */
.survey-q { margin-top: 22px; }
.survey-q .q-text { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.q-options { display: grid; gap: 8px; }
.q-opt {
  text-align: left; padding: 12px 14px; border-radius: 10px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); color: var(--text); font-family: inherit; font-size: 14px;
}
.q-opt:hover { border-color: var(--muted); }
.q-opt.sel { border-color: var(--blood); background: rgba(179,18,43,.12); }

.create-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; }
.create-foot.center { justify-content: center; }
.create-foot .btn { flex: 1; max-width: 220px; }

/* 능력치 그리드 */
.stats-grid { display: grid; gap: 14px; margin-top: 20px; }
.stat-row { display: grid; grid-template-columns: 64px 1fr 40px; align-items: center; gap: 10px; }
.stat-row .stat-name { font-size: 14px; color: var(--muted); }
.stat-track { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.stat-bar { height: 100%; background: linear-gradient(90deg, var(--blood), var(--amber)); border-radius: 6px; transition: width .6s ease; }
.stat-row .stat-val { text-align: right; font-weight: 700; font-size: 14px; }

/* HUD */
.hud { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.hud-left { display: flex; align-items: center; gap: 16px; }
.day-badge { font-size: 13px; color: var(--muted); letter-spacing: 1px; }
.day-badge strong { color: var(--amber); font-size: 18px; }
.clock-badge { font-size: 12px; color: var(--muted); }
.clock-badge strong { color: #cfcfd6; font-size: 14px; margin-left: 3px; }
.hp-wrap { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.hp-bar { width: 90px; height: 9px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.hp-fill { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--blood-bright), var(--blood)); transition: width .5s ease; }
.fat-fill { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #4a7fb5, #6fa8dc); transition: width .5s ease, background .3s; }
.fat-fill.high { background: linear-gradient(90deg, var(--amber), #ff7a3d); }
.hp-wrap strong { color: var(--text); }

/* 휴식 결정 배너 */
.rest-banner { background: linear-gradient(180deg, rgba(74,127,181,.10), var(--bg-soft)); border: 1px solid #35506b; border-radius: 12px; padding: 14px 16px; margin-top: 22px; display: flex; flex-direction: column; gap: 12px; animation: fade .3s ease; }
.rest-msg { font-size: 14px; color: #cdd6e0; line-height: 1.55; }
.rest-msg b { color: var(--amber); font-weight: 700; }
.btn-rest { background: #2f4a66; border: 1px solid #4a7fb5; color: #e6eef6; align-self: flex-start; padding: 11px 18px; }
.btn-rest:hover { background: #3a5a7d; }
.btn-rest.danger { background: #5a1622; border-color: var(--blood); color: #f0c9cf; }
.btn-rest.danger:hover { background: #6e1a2a; }

/* 상태 시트 */
.sheet { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-top: 14px; }
.sheet-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.sheet-row:last-child { border-bottom: none; }
.sheet-row h4 { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip.item { border-color: rgba(224,168,0,.5); }
.chip.injury { border-color: rgba(179,18,43,.6); color: #f0a8b3; }
.chip-use { background: var(--amber); color: #1a1500; border: none; border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 700; cursor: pointer; font-family: inherit; }
.chip-empty { color: var(--muted); font-size: 13px; }

/* 페이지 표시줄 */
.pager { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 8px 12px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; }
.pg-btn { background: transparent; border: 1px solid var(--line); color: var(--text); width: 38px; height: 34px; border-radius: 8px; font-size: 18px; cursor: pointer; font-family: inherit; }
.pg-btn:hover:not(:disabled) { border-color: var(--blood); color: var(--blood-bright); }
.pg-btn:disabled { opacity: .3; cursor: not-allowed; }
.pg-info { font-size: 13px; color: var(--muted); min-width: 56px; text-align: center; letter-spacing: 1px; }
.pg-latest { margin-left: auto; background: transparent; border: 1px solid var(--amber); color: var(--amber); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit; }
.pg-latest:hover:not(:disabled) { background: rgba(224,168,0,.12); }
.pg-latest:disabled { opacity: .4; cursor: not-allowed; }
.page-readonly { margin-top: 10px; padding: 8px 12px; background: rgba(74,127,181,.08); border: 1px dashed #35506b; border-radius: 8px; color: #9fb3c8; font-size: 13px; text-align: center; }

/* 스토리 */
.story { margin-top: 16px; min-height: 230px; }
.story-block.event { padding-left: 12px; border-left: 3px solid var(--blood); }
.story-block.event .ev-clock { font-size: 11px; font-weight: 600; color: var(--amber); letter-spacing: 1px; margin-bottom: 4px; }
.story-block.event .ev-title { font-size: 19px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.story-block.event .ev-desc { font-size: 15.5px; color: #d7d7dd; }
.event-title { font-size: 19px; font-weight: 800; color: var(--text); margin-bottom: 14px; padding-left: 12px; border-left: 3px solid var(--blood); }
.event-title .ev-clock { display: block; font-size: 11px; font-weight: 600; color: var(--amber); letter-spacing: 1px; margin-bottom: 4px; }
.story-block.daybreak { text-align: center; color: var(--amber); font-size: 14px; padding: 10px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); margin: 4px 0; }
.story-block.result .tag { color: var(--amber); }
.story-log { display: flex; flex-direction: column; gap: 16px; }
.story-block { font-size: 15.5px; }
.story-block.result { color: var(--text); }
.story-block.result .tag { color: var(--amber); font-size: 12px; font-weight: 700; display: block; margin-bottom: 4px; letter-spacing: 1px; }
.story-block.event { color: #d7d7dd; }
.story-block.you { color: var(--muted); font-style: italic; font-size: 14px; }
.delta { font-size: 13px; margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; }
.delta span { padding: 2px 8px; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--line); }
.delta .up { color: var(--good); border-color: rgba(95,174,106,.4); }
.delta .down { color: #f0a8b3; border-color: rgba(179,18,43,.4); }

/* 선택지 */
.choices { display: grid; gap: 10px; margin-top: 24px; }
.choice {
  text-align: left; padding: 14px 16px; border-radius: 12px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font-family: inherit; font-size: 15px; transition: .15s;
}
.choice:hover { border-color: var(--blood); background: rgba(179,18,43,.1); transform: translateX(3px); }
.choice .num { color: var(--blood); font-weight: 800; margin-right: 10px; }

/* 자유 입력 */
.free-label { font-size: 12px; color: var(--muted); margin-top: 18px; margin-bottom: 6px; letter-spacing: .3px; }
.free-label strong { color: var(--amber); font-weight: 800; }
.free-label.empty { color: #c98a90; }
.free-label.empty strong { color: var(--blood-bright); }
.free-input { display: flex; gap: 8px; margin-top: 4px; }
.free-input input:disabled { opacity: .45; cursor: not-allowed; }
.free-input input {
  flex: 1; padding: 13px 14px; font-size: 15px; font-family: inherit;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; color: var(--text);
}
.free-input input:focus { outline: none; border-color: var(--amber); }

/* 로딩 */
.thinking { display: flex; align-items: center; gap: 6px; justify-content: center; margin-top: 26px; color: var(--muted); font-size: 14px; }
.thinking em { margin-left: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blood); animation: pulse 1.2s infinite; }
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%,100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

/* 사망 */
.death-panel { text-align: center; }
.death-title { color: var(--blood-bright); font-size: 30px; text-shadow: 0 0 22px rgba(179,18,43,.5); }
.death-reason { color: #d7d7dd; margin: 16px 0; font-size: 16px; }
.death-days { font-size: 18px; margin-bottom: 18px; }
.death-days strong { color: var(--amber); font-size: 28px; }

/* 랭킹 */
.rank-list { list-style: none; margin-top: 18px; counter-reset: rank; }
.rank-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.rank-item .pos { width: 30px; font-weight: 800; color: var(--muted); text-align: center; }
.rank-item.top1 .pos { color: #ffd34d; } .rank-item.top2 .pos { color: #cfd3dc; } .rank-item.top3 .pos { color: #d79a6a; }
.rank-item .who { flex: 1; }
.rank-item .who .nm { font-weight: 700; }
.rank-item .who .cz { font-size: 12px; color: var(--muted); }
.rank-item .dy { font-weight: 800; color: var(--amber); }
.rank-item .dy small { color: var(--muted); font-weight: 400; }

/* 토스트 */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #2a1216; border: 1px solid var(--blood); color: #f0c9cf;
  padding: 12px 18px; border-radius: 10px; font-size: 14px; max-width: 90%; z-index: 50;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
}

@media (max-width: 520px) {
  .game-title { font-size: 44px; }
  .create-foot .btn { max-width: none; }
}
