:root {
  --bg: #14121a;
  --bg-raised: #1e1b26;
  --text: #efe6d6;
  --text-dim: rgba(239, 230, 214, .6);
  --accent: #e8b86b;
  --accent-ink: #1a1408;
  --line: rgba(239, 230, 214, .16);
  --danger: #f08a7a;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --serif: "Nanum Myeongjo", "Noto Serif KR", "AppleMyungjo", "Batang", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100%; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fade-in .6s ease;
}
.screen[hidden] { display: none; }

.panel { width: 100%; max-width: 380px; }
.panel.center { text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: stretch; }

.title { font-size: 22px; font-weight: 300; letter-spacing: .18em; text-align: center; margin: 0 0 10px; }
.lead { color: var(--text-dim); text-align: center; font-size: 15px; line-height: 1.6; margin: 0 0 28px; }
.panel.center .lead { margin-bottom: 8px; }

.form { display: flex; flex-direction: column; gap: 10px; }
.form[hidden] { display: none; }
.form label { font-size: 13px; color: var(--text-dim); }
.form input {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  font-size: 17px; /* 16px 이상이어야 iOS가 확대하지 않음 */
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}
.form input:focus { border-color: var(--accent); }
#code { letter-spacing: .5em; text-align: center; font-size: 22px; }
.sent-to { font-size: 14px; line-height: 1.6; color: var(--text-dim); margin: 0 0 6px; text-align: center; }
.sent-to b { color: var(--text); font-weight: 500; word-break: break-all; }
.row { display: flex; justify-content: space-between; gap: 8px; }

.btn {
  font: inherit;
  font-size: 16px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 48px;
}
.btn:disabled { opacity: .45; cursor: default; }

/* 포커스 흰 테두리는 쓰지 않는다. 대신 마우스를 올리거나(키보드로) 고르면 살짝 밝아진다. */
button:focus, button:focus-visible { outline: none; }
.btn, .icon-btn { transition: filter .18s ease, background-color .18s ease, border-color .18s ease, color .18s ease; }
.btn.primary:not(:disabled):hover, .btn.primary:focus-visible { filter: brightness(1.08) saturate(1.05); }
.btn.ghost:not(:disabled):hover, .btn.ghost:focus-visible { background: color-mix(in srgb, var(--text) 7%, transparent); border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.btn.link:hover, .btn.link:focus-visible { color: var(--text); }
.icon-btn:hover, .icon-btn:focus-visible { color: var(--text); border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; margin-top: 6px; }
.btn.ghost { background: none; color: var(--text); border-color: var(--line); }
.btn.link { background: none; color: var(--text-dim); padding: 10px 4px; font-size: 14px; min-height: 44px; }
.soon { font-size: 11px; padding: 2px 6px; margin-left: 4px; border-radius: 6px; background: var(--line); }

.msg { min-height: 1.4em; margin: 16px 0 0; font-size: 14px; text-align: center; color: var(--text-dim); }
.msg.error { color: var(--danger); }

/* ---------- 도입부 ---------- */
.intro { justify-content: flex-start; position: relative; user-select: none; -webkit-user-select: none; }
.intro.scrolling { height: 100vh; height: 100dvh; overflow: hidden; }
.icon-btn {
  background: none; border: 1px solid var(--line); color: var(--text-dim);
  border-radius: 999px; min-width: 44px; height: 44px; font-size: 18px; cursor: pointer;
}
.icon-btn.text { font-size: 13px; padding: 0 14px; margin-left: auto; }
.icon-btn.off { text-decoration: line-through; opacity: .5; }

.whisper { font-family: var(--serif); font-size: 19px; line-height: 1.8; color: var(--text); margin: 0; text-align: center; }

/* 엔딩 크레딧처럼 아래에서 위로 흘러가는 내레이션.
   화면 위아래 20%는 비우고 가운데 60%만 스크롤 영역으로 쓴다. 영역 가장자리에서 글자가 연하게 들고 난다. */
.narration {
  position: absolute;
  top: 20%; bottom: 20%; left: 0; right: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent 0, #000 18%, #000 82%, transparent 100%);
  mask-image: linear-gradient(transparent 0, #000 18%, #000 82%, transparent 100%);
}
.narration[hidden] { display: none; }
.narration-track {
  position: absolute;
  top: 0; left: 0; right: 0;
  margin: 0 auto;
  max-width: 440px;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 56px;
  text-align: center;
  will-change: transform;
  transform: translate3d(0, 100vh, 0); /* 애니메이션 시작 전 화면 아래에 대기 */
}
.narration-track p {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.9;
  word-break: keep-all;
  white-space: pre-line;
}
.narration.fade-out { opacity: 0; transition: opacity 1.2s ease; }

.birth-card {
  width: 100%;
  max-width: 380px;
  margin: auto 0;
  padding: 24px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-raised);
  display: flex; flex-direction: column; gap: 10px;
  animation: fade-in .8s ease;
}
.birth-card[hidden] { display: none; }
.birth-card h2 { margin: 0 0 6px; font-size: 14px; font-weight: 500; letter-spacing: .2em; color: var(--accent); text-align: center; }
.birth-card dl { margin: 0 0 10px; display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: 15px; }
.birth-card dt { color: var(--text-dim); }
.birth-card dd { margin: 0; }
.birth-card dd small { display: block; color: var(--text-dim); font-size: 13px; margin-top: 2px; line-height: 1.5; }

.birth-draw { margin: -4px 0 6px; font-size: 12px; color: var(--text-dim); text-align: center; letter-spacing: .1em; }
.birth-card dt.rare, .birth-card dd.rare { color: var(--accent); }
.birth-card.has-secret { border-color: var(--accent); box-shadow: 0 0 32px rgba(232, 184, 107, .18); }
.intro-msg { margin-top: 40vh; }
.intro-msg:empty { display: none; }

.who { font-size: 13px; color: var(--text-dim); margin: 12px 0 0; word-break: break-all; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; transition-duration: .01s !important; }
}

/* ---- 첫 화면(포스터) ---- */
.gate { position: relative; overflow: hidden; justify-content: center; align-items: center; cursor: default; }
.gate-bg {
  position: absolute; inset: 0; z-index: 0;
  background: #14121a url(/dev/candidates/image/poster/poster-wide.jpg) center / cover no-repeat;
  animation: gate-drift 40s ease-in-out infinite alternate;
}
.gate-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(20,18,26,0) 55%, rgba(20,18,26,.5) 78%, rgba(20,18,26,.85)); }
@media (max-aspect-ratio: 4/5) { .gate-bg { background-image: url(/dev/candidates/image/poster/poster-tall.jpg); } }
@keyframes gate-drift { from { transform: scale(1.02); } to { transform: scale(1.1) translate(-1%, -1%); } }
.gate-type, .gate-stage { position: absolute; z-index: 1; left: 50%; bottom: max(11vh, calc(env(safe-area-inset-bottom) + 40px)); transform: translateX(-50%); }
.gate-stage { display: flex; justify-content: center; }
.gate-type {
  margin: 0; width: min(90vw, 640px); text-align: center; white-space: pre-line;
  font-family: var(--serif); font-size: clamp(20px, 4.6vw, 30px); line-height: 1.7; letter-spacing: .04em;
  color: #fff6e6; text-shadow: 0 2px 18px rgba(0,0,0,.7);
  transition: opacity .9s ease;
}
.gate-type.fade-out { opacity: 0; }
.gate-enter {
  min-width: 220px; padding: 16px 32px; font-size: 17px; letter-spacing: .08em;
  opacity: 0; transform: translateY(8px); transition: opacity 1.1s ease, transform 1.1s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
}
.gate-enter.fade-in { opacity: 1; transform: none; }
/* 고양이 집사 까망: 버튼 윗변을 바닥 삼아 왼쪽 화면 밖에서 걸어 들어와 앉는다 */
.gate-cat { position: absolute; bottom: calc(100% - 4px); left: 50%; width: 0; height: 0; pointer-events: none; }
.gate-cat[hidden] { display: none; }
.gate-cat img { position: absolute; bottom: 0; height: var(--cat-h, 92px); width: auto; transform: translateX(-50%); filter: drop-shadow(0 6px 10px rgba(0,0,0,.45)); }
/* 까망이 말풍선: 앉은 머리 위에 뜬다 */
.cat-bubble {
  position: absolute; bottom: calc(var(--cat-sit-h, 108px) + 10px); left: 0;
  transform: translate(-50%, 6px); opacity: 0;
  width: max-content; max-width: min(260px, 80vw);
  margin: 0; padding: 9px 14px; border-radius: 16px;
  background: #fffaf2; color: #2a2230; font-size: 14px; line-height: 1.4; text-align: center;
  word-break: keep-all; box-shadow: 0 6px 18px rgba(0,0,0,.35);
  transition: opacity .35s ease, transform .35s ease;
}
.cat-bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  border: 8px solid transparent; border-bottom: 0; border-top-color: #fffaf2;
}
/* 대사 앞 고양이 발자국: 큰 발·작은 발, 분홍 젤리 */
.cat-bubble::before {
  content: ''; display: inline-block; width: 30px; height: 20px; margin-right: 6px; vertical-align: -4px;
  background: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 46 30"%3E%3Cg transform="translate(12 17) rotate(-14)"%3E%3Cg%3E%3Cellipse rx="10" ry="9.5" fill="%23e4e2e6" stroke="%238f8b96" stroke-width="1.1"/%3E%3Cellipse cy="3.4" rx="4.8" ry="3.7" fill="%23f3a3b5"/%3E%3Cellipse cx="-5.7" cy="-2.4" rx="1.9" ry="2.5" fill="%23f3a3b5"/%3E%3Cellipse cx="-2.1" cy="-5.6" rx="1.9" ry="2.5" fill="%23f3a3b5"/%3E%3Cellipse cx="2.1" cy="-5.6" rx="1.9" ry="2.5" fill="%23f3a3b5"/%3E%3Cellipse cx="5.7" cy="-2.4" rx="1.9" ry="2.5" fill="%23f3a3b5"/%3E%3C/g%3E%3C/g%3E%3Cg transform="translate(35 10) rotate(10) scale(.68)"%3E%3Cg%3E%3Cellipse rx="10" ry="9.5" fill="%23e4e2e6" stroke="%238f8b96" stroke-width="1.1"/%3E%3Cellipse cy="3.4" rx="4.8" ry="3.7" fill="%23f3a3b5"/%3E%3Cellipse cx="-5.7" cy="-2.4" rx="1.9" ry="2.5" fill="%23f3a3b5"/%3E%3Cellipse cx="-2.1" cy="-5.6" rx="1.9" ry="2.5" fill="%23f3a3b5"/%3E%3Cellipse cx="2.1" cy="-5.6" rx="1.9" ry="2.5" fill="%23f3a3b5"/%3E%3Cellipse cx="5.7" cy="-2.4" rx="1.9" ry="2.5" fill="%23f3a3b5"/%3E%3C/g%3E%3C/g%3E%3C/svg%3E') no-repeat center / contain;
}
.cat-bubble.show { opacity: 1; transform: translate(-50%, 0); }
.cat-bubble[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .cat-bubble { transition: none; } }
.gate-cat.sitting img { height: var(--cat-sit-h, 108px); transform: translateX(-30%); } /* 꼬리 쪽 여백을 빼고 몸통을 가운데로 */
.gate-enter[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .gate-bg { animation: none; }
  .gate-type, .gate-enter { transition: none; }
}

/* ---- 고양이 집사 확인 창 ---- */
.cat-dialog {
  width: min(92vw, 400px); padding: 28px 22px 20px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--bg-raised); color: var(--text); text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.cat-dialog::backdrop { background: rgba(10,8,14,.6); backdrop-filter: blur(3px); }
.cat-dialog[open] { animation: cat-pop .35s cubic-bezier(.2,1.4,.4,1); }
@keyframes cat-pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
.cat-face { width: 120px; height: 120px; object-fit: cover; border-radius: 50%; background: #2a2633; border: 3px solid var(--accent); display: block; margin: -4px auto 14px; }
.cat-say { margin: 0 0 20px; font-size: 15px; line-height: 1.7; color: var(--text); word-break: keep-all; }
.cat-say b { color: var(--accent); font-weight: 600; }
.cat-actions { display: flex; gap: 10px; }
.cat-actions .btn { flex: 1; margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .cat-dialog[open] { animation: none; } }

/* 가족 환영 배경 자리(TODO: 그림). 출생 카드 뒤에 크게 깔린다. */
.birth-welcome {
  position: absolute; inset: 0; z-index: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 4px; padding-top: max(28px, env(safe-area-inset-top));
  background:
    radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 65%),
    repeating-linear-gradient(135deg, transparent 0 22px, color-mix(in srgb, var(--line) 45%, transparent) 22px 23px);
  color: var(--text-dim); text-align: center; pointer-events: none;
  animation: fade-in 1.2s ease;
}
.birth-welcome[hidden] { display: none; }
/* 도입부가 흐르는 동안: 어렴풋하게. 문장이 끝나면 dim이 빠지며 2.4초에 걸쳐 밝아진다. */
.birth-welcome { transition: opacity 2.4s ease, filter 2.4s ease; }
.birth-welcome.dim { opacity: .16; filter: blur(3px) saturate(.5); animation: none; }
.intro .narration { z-index: 1; }
.birth-welcome p { margin: 0; font-size: 14px; }
.birth-welcome b { color: var(--accent); font-weight: 600; }
.birth-welcome small { font-size: 11px; letter-spacing: .15em; opacity: .7; }
.intro .birth-card { position: relative; z-index: 1; }
