:root {
  --bg: #0a0b09;
  --panel: rgba(18, 20, 15, 0.9);
  --field: #080907;
  --line: #2b2f24;
  --line-strong: #474d3b;
  --text: #e6e3d5;
  --muted: #9b9d8c;
  --blood: #a3231b;
  --blood-hi: #c8352a;
  --toxic: #9fcc4f;
  --warn: #e3a33c;
  --error: #ff7b6f;
  --radius: 6px;
  --font: "Noto Sans KR", system-ui, -apple-system, "Malgun Gothic", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, #2c1310 0%, transparent 60%),
    radial-gradient(ellipse 80% 50% at 50% 115%, #151b0e 0%, transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

/* 필름 노이즈 + 비네팅 */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 180px 40px rgba(0, 0, 0, 0.85);
}

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 48px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------------------------------------------------------------- 타이틀 */

.brand { text-align: center; }

.brand-title { margin: 0; }

/* 로고는 아래 메뉴(440px)보다 넓게, 화면 가운데에 */
.brand-logo {
  position: relative;
  left: 50%;
  display: block;
  width: min(620px, calc(100vw - 32px));
  height: auto;
  transform: translateX(-50%);
}

.brand-sub {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.menu {
  display: grid;
  gap: 10px;
  margin-top: 44px;
}

.menu-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
}

.menu-divider::before,
.menu-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* 두 버튼을 한 줄에 반씩 */
.menu-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ---------------------------------------------------------------- 버튼 */

.btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: 700 1rem/1.2 var(--font);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover { border-color: var(--muted); background: rgba(255, 255, 255, 0.06); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  border-color: var(--blood-hi);
  background: var(--blood);
  color: #fff;
}

.btn-primary:hover { border-color: #e2493d; background: var(--blood-hi); }

.btn-ghost { background: transparent; border-style: dashed; }

.btn-small { padding: 10px 12px; font-size: 0.9rem; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

[aria-busy="true"] .btn-primary { cursor: progress; }

.btn:focus-visible,
.link-btn:focus-visible,
input:focus-visible {
  outline: 2px solid var(--toxic);
  outline-offset: 2px;
}

.link-btn {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 500 0.9rem var(--font);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-btn:hover { color: var(--text); }

.back { display: block; margin: 20px auto 0; }

/* ---------------------------------------------------------------- 패널/폼 */

.panel {
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--blood);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.panel-warn { border-top-color: var(--warn); }

.panel-kicker {
  margin: 0 0 6px;
  color: var(--toxic);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1.3;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.hint strong { color: var(--text); }

form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 500;
}

.field > span {
  display: flex;
  justify-content: space-between;
}

.counter { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

.field-hint {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

input:not([type="checkbox"]) {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--text);
  font: 400 1rem var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:not([type="checkbox"]):focus {
  outline: none;
  border-color: var(--toxic);
  box-shadow: 0 0 0 3px rgba(159, 204, 79, 0.18);
}

input::placeholder { color: #5a5d50; }

.input-code {
  font-family: var(--font-mono) !important;
  font-size: 1.2rem !important;
  letter-spacing: 0.16em;
  text-align: center;
}

.form-error {
  margin: 0;
  color: var(--error);
  font-size: 0.9rem;
}

.form-error:empty { display: none; }

.notice {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--warn);
  background: rgba(227, 163, 60, 0.08);
  font-size: 0.88rem;
}

.panel-links {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
}

.captcha:empty { display: none; }
.captcha { min-height: 65px; }

.row {
  display: flex;
  gap: 8px;
}

.row > .btn { flex: 1; }

/* ---------------------------------------------------------------- 코드 발급 */

.code-display {
  display: block;
  margin: 18px 0 12px;
  padding: 18px 8px;
  border: 1px dashed var(--warn);
  border-radius: var(--radius);
  background: #070806;
  color: var(--warn);
  font: 700 clamp(1.4rem, 7vw, 1.9rem) var(--font-mono);
  letter-spacing: 0.12em;
  text-align: center;
  white-space: nowrap;
  user-select: all;
}

.warn-list {
  margin: 18px 0;
  padding-left: 1.15em;
  color: var(--muted);
  font-size: 0.88rem;
}

.warn-list li + li { margin-top: 4px; }
.warn-list strong { color: var(--text); }

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  font-size: 0.93rem;
  cursor: pointer;
}

/* 코드 발급 화면: 계속 아래 취소(게스트만) */
#code-cancel { margin-top: 10px; }

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--blood-hi);
}

/* ---------------------------------------------------------------- 생존자 설정 (포트레잇) */

.portrait-field {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.portrait-field legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 0.9rem;
  font-weight: 500;
}

.gender-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* 라디오 버튼을 버튼 모양으로 (키보드 방향키로도 선택 가능) */
.gender-option {
  position: relative;
  cursor: pointer;
}

.gender-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.gender-option > span {
  display: block;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  text-align: center;
  transition: background-color 0.15s, border-color 0.15s;
}

.gender-option:hover > span { border-color: var(--muted); }

.gender-option input:checked + span {
  border-color: var(--blood-hi);
  background: var(--blood);
  color: #fff;
}

.gender-option input:focus-visible + span {
  outline: 2px solid var(--toxic);
  outline-offset: 2px;
}

.portrait-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  /* 배경이 투명한 포트레잇 뒤에 은은한 조명 */
  background: radial-gradient(ellipse 70% 60% at 50% 40%, #232820 0%, #070806 75%);
}

/* 400x480 이미지를 정사각형 칸에: 위(얼굴) 기준으로 채우고 아래를 자른다 */
.portrait-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
}

.gender-option input:disabled { cursor: not-allowed; }
.gender-option input:disabled + span { opacity: 0.4; }
.gender-option:has(input:disabled):hover > span { border-color: var(--line-strong); }

.portrait-soon {
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

/* 좌우 넘김 버튼 */
.portrait-nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(10, 11, 9, 0.72);
  color: var(--text);
  font: 400 1.8rem/1 var(--font);
  cursor: pointer;
  transform: translateY(-50%);
  transition: background-color 0.15s, border-color 0.15s;
}

.portrait-nav:hover { border-color: var(--muted); background: rgba(10, 11, 9, 0.9); }
.portrait-nav:focus-visible { outline: 2px solid var(--toxic); outline-offset: 2px; }
.portrait-prev { left: 10px; }
.portrait-next { right: 10px; }

.portrait-count {
  position: absolute;
  bottom: 10px;
  left: 50%;
  z-index: 1;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(10, 11, 9, 0.72);
  color: var(--text);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
}

.portrait-placeholder {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.05em;
}

/* ---------------------------------------------------------------- 게임 메인 화면 */

/* 가운데 좁은 칸(.shell)을 벗어나 화면 전체를 쓴다 */
.game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* 상단: 포트레잇 · 닉네임 · 레벨 | 물 · 음식 · 연료 */
.game-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-strong);
  background: #0e100c;
}

.game-profile {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* 설정 (톱니바퀴) 버튼: 상단 오른쪽 끝 */
.game-settings-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.game-settings-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  transition: transform 0.3s ease;
}

.game-settings-btn:hover { border-color: var(--muted); background: rgba(255, 255, 255, 0.07); }
.game-settings-btn:hover svg { transform: rotate(60deg); }
.game-settings-btn:focus-visible { outline: 2px solid var(--toxic); outline-offset: 2px; }

/* 설정 창 */
/* 너무 크지 않게, 작은 화면에서는 화면 안에 맞춰서 */
.settings-dialog {
  width: min(340px, calc(100vw - 24px));
  max-height: calc(100dvh - 16px);
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--blood);
  border-radius: var(--radius);
  background: #12140f;
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.settings-dialog::backdrop { background: rgba(0, 0, 0, 0.65); }

/* 제목줄: [뒤로] 가운데 제목 [닫기] */
.settings-head {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.settings-head h2 {
  grid-column: 2;
  margin: 0;
  font-size: 1.05rem;
  text-align: center;
}

#settings-back { grid-column: 1; }
#settings-close { grid-column: 3; }

.settings-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0 0 3px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  font: 400 1.6rem/1 var(--font);
  cursor: pointer;
}

.settings-icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.settings-icon-btn:focus-visible { outline: 2px solid var(--toxic); outline-offset: 0; }

/* 설정 목록: 2 x 2 큰 칸 */
.settings-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.settings-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  /* 기본 120px, 화면이 낮으면(눕힌 폰 등) 화면 높이에 맞춰 줄어든다 */
  height: clamp(64px, calc((100dvh - 120px) / 2), 120px);
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: 700 0.9rem var(--font);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.settings-tile svg {
  flex: 0 1 auto;
  width: 44px;
  min-height: 0;
  max-height: 55%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-tile:hover { border-color: var(--muted); background: rgba(255, 255, 255, 0.06); }
.settings-tile:focus-visible { outline: 2px solid var(--toxic); outline-offset: 2px; }

.settings-section { padding: 16px 18px 20px; }

.settings-section .hint { margin: 0; }
.settings-section .info { margin-top: 0; }
.settings-section .row { margin-top: 16px; }

.game-portrait {
  flex: none;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: radial-gradient(ellipse 70% 60% at 50% 40%, #232820 0%, #070806 75%);
}

.game-portrait img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 0%;
}

.game-nickname {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-level {
  color: var(--toxic);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.game-resources {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.resource {
  display: grid;
  justify-items: center;
  min-width: 78px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  line-height: 1.35;
}

.resource-name {
  color: var(--muted);
  font-size: 0.78rem;
}

.resource-value {
  font-size: 0.9rem;
  white-space: nowrap;
}

.resource-value b {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 본문: 왼쪽 세로 탭 | 내용 */
.game-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.game-tabs {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 72px;
  min-height: 0;
  padding: 4px 0 8px 4px;
  border-right: 1px solid var(--line-strong);
}

/* 서류철 탭 모양: 왼쪽만 둥글고, 고른 탭은 내용 쪽과 이어진다.
   탭은 오른쪽 정렬이라 폭이 바뀌면 왼쪽으로 늘어나고 오른쪽으로 줄어든다. */
.game-tab {
  --tab-w: 56px;
  --tab-w-selected: 68px;
  flex: none;
  align-self: flex-end;
  width: var(--tab-w);
  height: 56px;
  margin-right: -1px;
  padding: 0 2px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px 0 0 12px;
  background: #111310;
  color: var(--muted);
  font: 700 0.88rem var(--font);
  white-space: nowrap;
  cursor: pointer;
  transition:
    width 0.25s ease,
    color 0.2s,
    background-color 0.2s,
    box-shadow 0.2s,
    border-color 0.2s;
}

.game-tab:hover { color: var(--text); }

.game-tab[aria-selected="true"] {
  width: var(--tab-w-selected);
  border-right-color: var(--bg);
  background: var(--bg);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--blood-hi);
}

.game-tab:focus-visible {
  outline: 2px solid var(--toxic);
  outline-offset: -4px;
}

/* 나중에 추가될 탭 자리 (좁은 빈 탭). 화면이 낮으면 줄어든다 */
.game-tab-stub {
  flex: 0 1 56px;
  align-self: flex-end;
  width: 14px;
  min-height: 12px;
  margin-right: -1px;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 8px 0 0 8px;
}

.game-content {
  flex: 1;
  min-width: 0;
  padding: 20px;
  overflow-y: auto;
}

.game-panel h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.info {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  font-size: 0.92rem;
}

.info div { display: flex; gap: 12px; }
.info dt { width: 5.5em; color: var(--muted); }
.info dd { margin: 0; }

/* 눕힌 폰 (폭 641px 이상 + 높이 640px 이하): 왼쪽에 두 줄짜리 네모 탭.
   크기는 그대로, 고른 칸은 색만 바뀐다. 아래 빈 칸 두 개는 나중에 추가될 탭 자리 */
@media (min-width: 641px) and (max-height: 640px) {
  .game-tabs {
    display: grid;
    grid-template-columns: repeat(2, 58px);
    grid-auto-rows: minmax(0, 64px);
    align-content: start;
    gap: 6px;
    width: auto;
    padding: 12px 8px;
  }

  .game-tab,
  .game-tab-stub {
    align-self: stretch;
    width: auto;
    height: auto;
    margin: 0;
    border-radius: 10px;
  }

  .game-tab {
    border: 1px solid var(--line-strong);
    font-size: 0.85rem;
    box-shadow: none;
    transition:
      color 0.2s,
      background-color 0.2s,
      border-color 0.2s;
  }

  .game-tab[aria-selected="true"] {
    width: auto;
    border-color: var(--blood-hi);
    background: var(--blood);
    color: #fff;
    box-shadow: none;
  }

  .game-tab-stub { border: 1px solid var(--line); }
  .game-tab-stub:nth-of-type(3) { display: none; }
}

/* 폰: 자원 칸은 두 번째 줄에 세 칸으로, 탭은 화면 아래 가로 탭 바로 */
@media (max-width: 640px) {
  /* 첫 줄: 포트레잇 · 닉네임 · 레벨 · 설정 / 둘째 줄: 물 · 음식 · 연료 */
  .game-profile { order: 1; }
  .game-settings-btn { order: 2; }
  .game-resources { order: 3; width: 100%; }
  .resource { flex: 1; min-width: 0; }

  .game-body { flex-direction: column; }
  .game-content {
    order: 1;
    flex: 1;
    min-height: 0;
    padding: 16px 14px;
  }

  /* 아래쪽 탭 줄: 둥근 칸 여섯 개. 크기는 그대로, 고른 칸은 색만 바뀐다 */
  .game-tabs {
    order: 2;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    width: auto;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line-strong);
    border-right: 0;
    background: #0e100c;
  }

  .game-tab {
    flex: 1;
    align-self: auto;
    width: auto;
    min-width: 0;
    height: 52px;
    margin: 0;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    font-size: 0.85rem;
    box-shadow: none;
    transition:
      color 0.2s,
      background-color 0.2s,
      border-color 0.2s;
  }

  .game-tab[aria-selected="true"] {
    width: auto;
    border-color: var(--blood-hi);
    background: var(--blood);
    color: #fff;
    box-shadow: none;
  }

  .game-tab:focus-visible { outline-offset: -3px; }

  .game-tab-stub { display: none; }
}

/* ---------------------------------------------------------------- 배경 설명 */

/* 가운데 좁은 칸(.shell)을 벗어나 화면 전체를 쓴다 */
.intro {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* 오른쪽 위 홈 버튼: 누르면 로그아웃하고 처음(로그인) 화면으로 */
.intro-home {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.intro-home svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.intro-home:hover { border-color: var(--muted); background: rgba(0, 0, 0, 0.75); }
.intro-home:focus-visible { outline: 2px solid var(--toxic); outline-offset: 2px; }

/* 상단 이미지 자리: 화면 높이의 70% */
.intro-image {
  position: relative;
  flex: none;
  height: 70vh;
  height: 70dvh;
  overflow: hidden;
  background: #050605;
}

.intro-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 이미지 아래쪽을 글 영역 배경색으로 자연스럽게 이어준다 */
.intro-image::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 30%;
  background: linear-gradient(to bottom, transparent, var(--bg));
  pointer-events: none;
}

.intro-image-placeholder {
  position: absolute;
  inset: 16px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-align: center;
}

/* 하단 글 영역 + 오른쪽 아래 다음 버튼
   넓은 화면: [글 | 버튼] 나란히, 좁은 화면: 글 아래에 버튼 */
.intro-bottom {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr);
  align-items: end;
  gap: 8px 28px;
  padding: 12px max(16px, 4vw) 16px;
}

.intro-text {
  align-self: stretch;
  min-height: 0;
  margin: 0;
  overflow-y: auto;
  font-size: clamp(0.95rem, 1.35vw, 1.1rem);
  line-height: 1.65;
  white-space: pre-line;
}

/* 글이 넘치면 아래쪽을 흐리게 해서 더 있다는 걸 알려준다 */
.intro-text.has-more {
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, #000 70%, transparent);
}

.intro-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.intro-hint {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 640px) {
  /* 폰: 글이 한 화면에 들어오도록 이미지를 화면 높이의 50%로 */
  .intro-image {
    height: 50vh;
    height: 50dvh;
  }

  .intro-bottom {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
}

.intro-progress {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.intro-next {
  width: auto;
  min-width: 120px;
  padding: 11px 18px;
}

.intro-enter { animation: intro-fade 0.6s ease both; }

@keyframes intro-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------------------------------------------------------------- 기타 */

.screen-loading { align-items: center; text-align: center; }

.loading-text {
  color: var(--muted);
  letter-spacing: 0.1em;
}

.dots::after {
  content: "";
  animation: dots 1.4s steps(4) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #1a1c16;
  font-size: 0.9rem;
  transform: translateX(-50%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

@media (prefers-reduced-motion: reduce) {
  .dots::after,
  .intro-enter { animation: none; }
  .btn,
  .game-tab,
  .game-settings-btn svg { transition: none; }
}
