/* 사주 동물 카드 웹 — 8차(2026-11-03 사장님 "조잡" · "어르신 느낌" · "뫼비우스의 띠처럼 되풀이" → 한 장 카드 중심).
   카드 그림과 같은 결(한지 크림 종이 · 고운바탕 굵은 제목 · 가는 이중선). 보는 것은 카드 한 장이고 나머지는 작고 조용하게.
   한글은 어절 중간에서 끊지 않는다(사장님 절대 규칙). docs/36 §1-9 · §5-12 */

:root {
  color-scheme: only light;
  --paper: #F4EDE2;      /* 카드 위아래 띠와 같은 종이 색 — 카드가 화면에 스며들게 */
  --paper-hi: #FBF7EF;   /* 한 겹 위 종이(입력 카드 · 칸) */
  --paper-lo: #EBE1D1;   /* 한 겹 아래 종이 */
  --ink: #4A3426;        /* 카드 본문 먹색 */
  --soft: #7A5A44;       /* 카드 안내 글씨 · 이중선 */
  --field: #9C8169;      /* 입력칸 테두리(흰 바탕 대비 3.6:1) */
  --line: #E2D4C1;       /* 순위 줄 테두리 */
  --focus: #2C5A8A;
  /* 동물 다섯 색 — tools/animal_card/compose_all.py 의 TITLE 과 같은 값 */
  --red: #9E2B22;
  --blue: #2C5A8A;
  --gold: #8E6410;
  --white: #5C6670;
  --black: #23232B;
  --accent: var(--red);
  --kind: var(--soft);
  /* 타고난 궁합(카드끼리 · 평생 그대로) = 한지 금빛 */
  --born-bg: #F6EEDC;
  --born-line: #D5BA7E;
  --born-ink: #775311;
  /* 오늘의 궁합(두 사람 · 날마다 바뀜) = 청록 — 궁합 순위 점수 · 펼친 풀이 */
  --today-bg: #E2F0ED;
  --today-ink: #1B6A60;
  /* 한 사람의 오늘 운세 = 노을빛 + 해 그림 — 카드의 점수 · 오늘 운세 순위(궁합과 섞이지 않게, 7차) */
  --luck-line: #EDBB7A;
  --luck-ink: #9C4A0A;
  --sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239C4A0A' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4.2' fill='%23F2B45C'/%3E%3Cpath d='M12 2.5v2.2M12 19.3v2.2M2.5 12h2.2M19.3 12h2.2M5.3 5.3l1.6 1.6M17.1 17.1l1.6 1.6M5.3 18.7l1.6-1.6M17.1 6.9l1.6-1.6'/%3E%3C/svg%3E");
  /* 카카오톡 공유 단추 — 카카오 디자인 가이드(바탕 #FEE500 · 말풍선 #000 · 글씨 #000 85%) */
  --kakao: #FEE500;
  --kakao-ink: rgba(0, 0, 0, .85);
  --gutter: 16px;
  --shadow: 0 1px 2px rgba(74, 52, 38, .10), 0 16px 34px -16px rgba(74, 52, 38, .5);
  --serif: "Gowun Batang", "Nanum Myeongjo", "AppleMyungjo", serif;
  --sans: Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

.c-red { --accent: var(--red); }
.c-blue { --accent: var(--blue); }
.c-gold { --accent: var(--gold); }
.c-white { --accent: var(--white); }
.c-black { --accent: var(--black); }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
p, li { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; margin: 0; font-weight: 700; }
p { margin: 0; }
img { max-width: 100%; }
button, select, input { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter); }

/* 카드의 가는 이중선(굵은 선 + 가는 선) */
.rule { height: 9px; border-top: 3px solid var(--soft); border-bottom: 1px solid var(--soft); }
.rule-rev { border-top-width: 1px; border-bottom-width: 3px; }

/* ── 화면 갈래 — 머리의 한 줄 스크립트가 그리기 전에 붙이고 card.js 가 같은 셈으로 다시 정한다 ── */
.mode-main #animal, .mode-animal #stage, .mode-animal #ilju-all { display: none; }

/* ── 머리 ─────────────────────────────── */
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { font: 700 24px/1 var(--serif); color: var(--ink); text-decoration: none; padding: 10px 0; }
.top-tag { font: 600 16px/1.3 var(--sans); color: var(--soft); }
/* 머리 오른쪽 [인생지도 앱 받기] — 어느 화면에서든 늘 보이는 작은 보조 단추(테두리 · 먹색 글씨, 누르기 48px) */
.top-app {
  display: inline-flex; align-items: center; min-height: 48px; padding: 6px 14px; border-radius: 10px;
  border: 2px solid var(--ink); background: var(--paper-hi); color: var(--ink);
  font: 700 16px/1.2 var(--sans); text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.top-app:hover { background: #fff; }

/* ── 큰 화면 — 한 줄(가운데). 카드 · 공유 · 순위 · 다시 보기가 모두 카드 폭(--cw) ───────────── */
.stage {
  /* 폰에서는 카드 아래 공유 단추까지 첫 화면에 보이게 카드 폭을 화면 높이에 맞춰 줄인다(300px 아래로는 줄이지 않는다) */
  --cw: min(100%, 400px);
  display: flex; flex-direction: column; align-items: center;
  padding-top: 12px; padding-bottom: 40px;
}
.stage > * { width: var(--cw); }
@media (max-width: 759.98px) {
  .stage { --cw: min(100%, 400px, max(300px, calc((100vh - 250px) * .5625))); }
  @supports (height: 100svh) {
    .stage { --cw: min(100%, 400px, max(300px, calc((100svh - 250px) * .5625))); }
  }
}
.today-date { margin: 0 0 10px; text-align: center; font: 600 15px/1.5 var(--sans); color: var(--soft); letter-spacing: .02em; }
.today-date:empty { display: none; }
/* 방이 없어졌을 때 · 같은 날 다른 생일 — 카드 위 한 줄 */
.notice {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--paper-lo);
  font: 600 15.5px/1.55 var(--sans); color: var(--ink); text-align: center; text-wrap: balance;
}

/* 카드 자리 — 입력 카드 · 불러오는 중 · 내 카드 가운데 하나만 */
.card-wait { display: none; }
.has-me .stage:not([data-state]) .incard { display: none; }
.has-me .stage:not([data-state]) .card-wait { display: flex; }
.stage[data-state="loading"] .incard { display: none; }
.stage[data-state="loading"] .card-wait { display: flex; }
.stage[data-state="card"] .incard { display: none; }
.stage:not([data-state="card"]) .mycard,
.stage:not([data-state="card"]) .share2,
.stage:not([data-state="card"]) .again { display: none; }

/* ── 입력 카드 — 카드와 같은 틀(종이 · 가는 이중 테두리), 칸은 낮고 단정하게 ───────────── */
.incard {
  position: relative; padding: 22px 18px 18px; border-radius: 8px; background: var(--paper-hi);
  border: 1.5px solid var(--soft);
  box-shadow: inset 0 0 0 4px var(--paper-hi), inset 0 0 0 5px rgba(122, 90, 68, .55), 0 18px 36px -26px rgba(74, 52, 38, .6);
}
.incard-title { font: 700 clamp(22px, 6.2vw, 26px)/1.3 var(--serif); color: var(--ink); text-align: center; }
.incard-title:focus { outline: none; }
/* 제목 아래 짧은 이중선 — 카드 그림의 별명 아래 선과 같은 결 */
.incard-title::after {
  content: ""; display: block; width: 56px; height: 7px; margin: 10px auto 0;
  border-top: 2px solid var(--soft); border-bottom: 1px solid var(--soft);
}
.f { position: relative; min-width: 0; margin: 14px 0 0; padding: 0; border: 0; }
.f-label { display: block; margin: 0 0 6px; padding: 0; font: 700 15px/1.4 var(--sans); color: var(--ink); }
.f-opt { margin-left: 6px; font-weight: 500; font-size: 13.5px; color: var(--soft); }
.f-in {
  display: block; width: 100%; height: 48px; margin: 0; padding: 0 14px; border: 1.5px solid var(--field); border-radius: 12px;
  background: #fff; font: 600 17px/1.2 var(--sans); color: var(--ink);
}
.f-in::placeholder { color: #A8927C; font-weight: 500; }
.f-in[aria-invalid="true"] { border-color: #B23A2C; }
.name-hint { margin-top: 6px; font: 600 14.5px/1.5 var(--sans); color: #8A2A1E; text-wrap: balance; }

/* 양력 · 음력 — 바탕 위 흰 손잡이(고른 쪽은 먹색 테두리 · 굵은 글씨) */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border-radius: 14px; background: var(--paper-lo); }
.seg-opt { position: relative; display: block; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opt span {
  display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 11px;
  border: 1.5px solid transparent; font: 600 17px/1.2 var(--sans); color: var(--soft);
  transition: background-color .15s, color .15s;
}
.seg-opt input:checked + span {
  background: #fff; border-color: var(--ink); color: var(--ink); font-weight: 700; box-shadow: 0 3px 8px -5px rgba(74, 52, 38, .6);
}
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
/* 윤달 — 음력일 때만, '생년월일' 줄 오른쪽(누르는 자리 44px) */
.leap {
  position: absolute; top: -12px; right: 0; display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 0 2px 0 10px; cursor: pointer; font: 600 15px/1.2 var(--sans); color: var(--ink);
}
.leap input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); flex: none; }

.ymd { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 6px; }
.hm { display: grid; grid-template-columns: 1.6fr 1fr; gap: 6px; }
.hm.no-min { grid-template-columns: 1fr; }
.select {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 48px; margin: 0;
  padding: 0 24px 0 11px; border: 1.5px solid var(--field); border-radius: 12px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1.2 1.2 6 6l4.8-4.8' fill='none' stroke='%237A5A44' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 9px center / 11px 7px;
  font: 600 16.5px/1.2 var(--sans); color: var(--ink); cursor: pointer;
  text-overflow: ellipsis; white-space: nowrap;
}
.select:invalid, .select.is-empty { color: var(--soft); font-weight: 500; }
.select option { color: var(--ink); }
.form-error {
  margin: 14px 0 0; padding: 10px 12px; border-radius: 10px;
  background: #F6E3DE; color: #8A2A1E; font: 600 15.5px/1.5 var(--sans); text-wrap: balance;
}
.incard-go { margin-top: 18px; }
.incard-note { margin-top: 10px; font-size: 13.5px; line-height: 1.55; color: var(--soft); text-align: center; text-wrap: balance; }
@media (max-width: 379.98px) {
  .incard { padding: 20px 14px 16px; }
  .select { padding: 0 22px 0 9px; background-position: right 8px center; font-size: 16px; }
}

/* 이 휴대폰이 기억한 내 카드를 불러오는 동안 — 카드와 같은 크기의 빈 카드 */
.card-wait {
  flex-direction: column; align-items: center; justify-content: center; gap: 12px; aspect-ratio: 9 / 16;
  padding: 20px; border-radius: 6px; background: var(--paper-hi); border: 1.5px solid var(--line);
  font: 600 16px/1.5 var(--sans); color: var(--soft); text-align: center;
}

/* ── 버튼 — 채움 하나(주 · 먹색) · 테두리(보조) ───────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 54px;
  padding: 10px 18px; border-radius: 12px; border: 2px solid var(--ink);
  font: 700 19px/1.3 var(--sans); text-align: center; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: background-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--paper-hi); }
.btn-primary:hover { background: #3A281C; }
.btn-line { background: transparent; color: var(--ink); }
.btn-line:hover { background: var(--paper-lo); }
.btn[disabled] { cursor: progress; opacity: .85; }
.spin {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  border: 3px solid rgba(251, 247, 239, .35); border-top-color: var(--paper-hi);
  animation: spin .8s linear infinite;
}
.spin-ink { border-color: rgba(74, 52, 38, .22); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 카드 — 앞면(그림 + 오늘 운세) · 뒷면(이름 · 별명 · 일주 · 성격과 약점 · 앱 단추). 보드게임 카드처럼 3D 로 뒤집힌다 ── */
.mycard, .solo { container-type: inline-size; } /* 뒷면 글씨 · 점수 칸은 카드 폭(cqi)에 맞춘다 */
.mycard:focus { outline: none; } /* 카드가 나오면 읽어 주기 초점만 옮긴다 */
.tc { position: relative; perspective: 1500px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.tc-in { position: relative; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, .85, .25, 1); }
.tc.is-flipped .tc-in { transform: rotateY(180deg); }
.tc-face { border-radius: 6px; -webkit-backface-visibility: hidden; backface-visibility: hidden; box-shadow: var(--shadow); }
.tc-front { position: relative; background: var(--paper-hi); }
.tc-img { display: block; width: 100%; height: auto; aspect-ratio: 9 / 16; border-radius: 6px; }
.tc-back { position: absolute; inset: 0; transform: rotateY(180deg); background: var(--paper); overflow: hidden; }
/* 보이지 않는 쪽은 눌리지 않게(뒤집힌 동안 앞면 · 앞면일 때 뒷면의 앱 단추) */
.tc.is-flipped .tc-front, .tc:not(.is-flipped) .tc-back { pointer-events: none; }
/* 뒷면 테두리 — 카드 그림의 바깥 이중선과 같은 자리 · 같은 결 */
.tc-back::before {
  content: ""; position: absolute; inset: 2.8%; border: 2px solid var(--soft); pointer-events: none;
  box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 5px var(--soft);
}
.cb {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; overflow-y: auto;
  padding: 11cqi 10cqi 9cqi; text-align: center;
}
.cb-name { font: 700 clamp(24px, 9.6cqi, 38px)/1.2 var(--serif); color: var(--accent); }
.cb-nick { margin-top: 2.4cqi; font: 700 clamp(15px, 4.9cqi, 20px)/1.45 var(--serif); color: var(--ink); text-wrap: balance; }
.cb-ilju { margin-top: 1.6cqi; font: 600 clamp(13px, 3.8cqi, 15px)/1.4 var(--sans); color: var(--soft); }
.cb-ilju b { color: var(--ink); }
/* 성격 세 문장 + 약점 한 문장을 한 글로(8차) — 위에 짧은 이중선. 이름 줄과 앱 단추 사이 가운데에 */
.cb-desc {
  width: 100%; margin: auto 0; padding: 4cqi 0 14px; text-align: left; color: var(--ink);
  font: 500 clamp(15px, 5.1cqi, 19px)/1.78 var(--sans);
}
.cb-desc::before {
  content: ""; display: block; width: 48px; height: 6px; margin: 0 auto 4.4cqi;
  border-top: 2px solid var(--soft); border-bottom: 1px solid var(--soft);
}
.cb-app {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 46px; margin-top: 0;
  padding: 8px 12px; border-radius: 10px; background: var(--ink); color: var(--paper-hi); text-decoration: none;
  font: 700 clamp(14.5px, 4.4cqi, 17px)/1.35 var(--sans); text-align: center; -webkit-tap-highlight-color: transparent;
}
.cb-app:hover { background: #3A281C; }
/* 앞면의 오늘 운세 — 그림 오른쪽 위(60장 모두 하늘 · 바탕 자리) 작은 점수 칸. 노을빛 + 해(한 사람의 운이다 — 궁합 아님) */
.tc-badge {
  position: absolute; top: 21.4%; right: 6%; display: flex; flex-direction: column; align-items: center;
  padding: 1.7cqi 3.2cqi 1.9cqi; border-radius: 3cqi; background: rgba(251, 247, 239, .95);
  border: 1.5px solid var(--luck-line); box-shadow: 0 10px 20px -14px rgba(74, 52, 38, .8);
  color: var(--luck-ink); text-align: center; line-height: 1.2; pointer-events: none;
}
.tc-badge-k { display: flex; align-items: center; gap: .3em; font: 700 clamp(11px, 3.3cqi, 13.5px)/1.3 var(--sans); white-space: nowrap; }
.tc-badge-k::before { content: ""; width: 1.15em; height: 1.15em; flex: none; background: var(--sun) center / contain no-repeat; }
.tc-badge-n { margin-top: .5cqi; font: 700 clamp(13px, 4cqi, 16px)/1 var(--serif); white-space: nowrap; }
.tc-badge-n b { font-size: 2.05em; line-height: 1; margin-right: 1px; letter-spacing: -.01em; }
/* '뒷면' — 카드 아래 작은 글자 하나(누르면 뒤집힘, 뒤집히면 '앞면') */
.flip-word {
  display: block; min-width: 64px; min-height: 44px; margin: 4px auto 0; padding: 8px 14px; border: 0; background: none;
  cursor: pointer; font: 600 15.5px/1.4 var(--sans); color: var(--soft);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; -webkit-tap-highlight-color: transparent;
}
.flip-word:hover { color: var(--ink); }

/* ── 공유 한 쌍 — 크고 노란 [찰떡궁합 친구 찾기](카카오 공유 카드 하나) · 작은 [다른 앱](폰 기본 공유 창) ── */
.share2 { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 8px; }
.share2 .btn { min-height: 64px; padding: 10px 12px; gap: 8px; font-size: 20px; line-height: 1.25; }
.share2 .btn svg { flex: none; }
.btn-kakao { background: var(--kakao); border-color: var(--kakao); color: var(--kakao-ink); box-shadow: 0 1px 0 rgba(74, 52, 38, .18); }
.btn-kakao:hover { background: #F2DA00; border-color: #F2DA00; }
.btn-kakao .share-label { text-wrap: balance; }
.btn-apps { background: var(--paper-hi); color: var(--ink); }
.btn-apps:hover { background: #fff; }
.share2 .btn-apps { flex-direction: column; gap: 2px; width: auto; min-width: 84px; padding: 6px 10px; font-size: 16px; line-height: 1.2; }
.share2 .btn-apps svg { width: 22px; height: 22px; }
@media (max-width: 379.98px) {
  .share2 { gap: 6px; }
  .share2 .btn { padding: 8px 8px; gap: 6px; font-size: 19px; }
  .share2 .btn-apps { min-width: 72px; padding: 6px 6px; font-size: 16px; }
}

/* ── 방 순위 — 1:1 은 둘 다 펼쳐 작은 이름표만, 단톡방은 접힌 막대 둘(누르면 아래로 펼침). 목록은 다섯 줄 높이까지 ── */
.board { margin-top: 28px; }
.board-wait { display: flex; align-items: center; justify-content: center; gap: 10px; font: 600 16px/1.5 var(--sans); color: var(--soft); }
.load-error { display: grid; gap: 10px; }
.load-error p {
  padding: 10px 14px; border-radius: 10px; background: #F6E3DE; color: #8A2A1E;
  font: 600 16px/1.55 var(--sans); text-align: center; text-wrap: balance;
}
.rk + .rk { margin-top: 18px; }
.board[data-mode="group"] .rk + .rk { margin-top: 10px; }
.board[data-mode="direct"] .rk-bar, .board[data-mode="group"] .rk-label { display: none; }
.rk-label { margin: 0 0 8px 2px; font: 700 15px/1.4 var(--sans); color: var(--soft); letter-spacing: .02em; }
.rk-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 54px;
  margin: 0; padding: 10px 18px 10px 16px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--paper-hi);
  font: 700 18px/1.3 var(--serif); color: var(--ink); text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.rk-bar:hover { background: #fff; }
.rk-bar[aria-expanded="true"] { border-color: var(--field); background: #fff; }
.rk-chev {
  flex: none; width: 10px; height: 10px; border-right: 2.5px solid var(--soft); border-bottom: 2.5px solid var(--soft);
  transform: translateY(-3px) rotate(45deg); transition: transform .2s;
}
.rk-bar[aria-expanded="true"] .rk-chev { transform: translateY(2px) rotate(-135deg); }
.rk-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; overflow-y: auto; }
.board[data-mode="group"] .rk-list { margin-top: 8px; }
/* 다섯 줄이 넘으면 칸 안에서 스크롤 — 아래가 더 있다는 것을 끝을 흐리게 해서 보인다 */
.rk-list.is-scroll:not(.at-end) {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}

/* 순위 한 줄 — 메달 · 동물 동그라미(궁합은 둘 겹쳐서 · 오늘 운세는 하나) · 이름 · 점수. 내 줄은 테두리 색만 다르다 */
.row { border-radius: 14px; background: var(--paper-hi); border: 1.5px solid var(--line); }
.row.is-me { border-color: var(--accent); }
.row-main {
  display: grid; grid-template-columns: 34px 40px minmax(0, 1fr) auto; align-items: center; gap: 9px;
  width: 100%; min-height: 58px; margin: 0; padding: 8px 12px 8px 10px; border: 0; border-radius: 12px;
  background: none; color: inherit; font: inherit; text-align: left;
}
button.row-main { grid-template-columns: 34px 40px minmax(0, 1fr) auto 12px; padding-right: 10px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
@media (hover: hover) { button.row-main:hover { background: #fff; } }
.pair-row .row-main { grid-template-columns: 34px 54px minmax(0, 1fr) auto; }
.pair-row button.row-main { grid-template-columns: 34px 54px minmax(0, 1fr) auto 12px; }
.row-go { display: grid; place-items: center; width: 12px; height: 14px; }
.row-go::before {
  content: ""; width: 8px; height: 8px; border-right: 2.5px solid var(--soft); border-bottom: 2.5px solid var(--soft);
  transform: translateY(-2px) rotate(45deg); transition: transform .2s;
}
.row.is-open .row-go::before { transform: translateY(2px) rotate(-135deg); }
.row.to-app .row-go::before { transform: translateX(-2px) rotate(-45deg); }
/* 펼친 짧은 풀이 — 그날 제목 + 한 줄(오늘의 궁합 색 바탕) */
.row-more { margin: 0 8px 8px; padding: 9px 12px 11px; border-radius: 10px; background: var(--today-bg); }
.rm-title { font: 700 17px/1.5 var(--serif); color: var(--today-ink); }
.rm-line { margin-top: 2px; font-size: 16px; line-height: 1.65; color: var(--ink); }
.medal {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font: 700 17px/1 var(--serif); color: var(--soft); background: var(--paper-lo);
}
/* 1~3등은 메달 느낌(금 · 은 · 동) */
.row.m1 .medal { background: radial-gradient(circle at 35% 30%, #FFE9A6, #E9B93C 62%, #B88A1E); color: #5A3E08; box-shadow: 0 0 0 2px #C99A2E; }
.row.m2 .medal { background: radial-gradient(circle at 35% 30%, #FFFFFF, #CBD2DA 62%, #98A2AE); color: #3E4650; box-shadow: 0 0 0 2px #A9B2BC; }
.row.m3 .medal { background: radial-gradient(circle at 35% 30%, #FFD8B8, #D99566 62%, #A8643A); color: #4E2A12; box-shadow: 0 0 0 2px #B97A4E; }
.row-face {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: 50% 72%;
  background: var(--paper); border: 2px solid var(--paper-hi); box-shadow: 0 0 0 1.5px #D3C2AB;
}
.face-empty { display: block; }
.duo { display: flex; }
.duo .row-face { width: 35px; height: 35px; }
.duo .row-face + .row-face { margin-left: -16px; }
.who { min-width: 0; font: 700 17px/1.35 var(--sans); color: var(--ink); }
.row-score { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; white-space: nowrap; }
.rs-num { font: 700 22px/1 var(--serif); color: var(--today-ink); } /* 궁합 점수 — 오늘의 궁합 청록 */
.luck-row .rs-num { color: var(--luck-ink); } /* 한 사람의 오늘 운세 — 노을빛 */
.rs-num small { margin-left: 2px; font-size: 14px; }
.row-date { font: 600 13.5px/1.2 var(--sans); color: var(--soft); }
@media (max-width: 379.98px) {
  .row-main { grid-template-columns: 30px 36px minmax(0, 1fr) auto; gap: 8px; padding: 7px 10px 7px 8px; }
  button.row-main { grid-template-columns: 30px 36px minmax(0, 1fr) auto 12px; padding-right: 8px; }
  .pair-row .row-main { grid-template-columns: 30px 48px minmax(0, 1fr) auto; }
  .pair-row button.row-main { grid-template-columns: 30px 48px minmax(0, 1fr) auto 12px; }
  .medal { width: 30px; height: 30px; font-size: 15px; }
  .row-face { width: 36px; height: 36px; }
  .duo .row-face { width: 31px; height: 31px; }
  .duo .row-face + .row-face { margin-left: -14px; }
  .who { font-size: 16px; }
  .rs-num { font-size: 20px; }
}

/* ── 다른 생일로 다시 보기 — 누르면 지금 카드 · 방 순위 기록을 지우고 입력 카드로 ── */
.again { margin-top: 26px; text-align: center; }
.again-btn {
  min-height: 44px; padding: 8px 14px; border: 0; background: none; cursor: pointer;
  font: 600 16.5px/1.4 var(--sans); color: var(--ink); text-decoration: underline; text-underline-offset: 5px;
  -webkit-tap-highlight-color: transparent;
}
.again-note { font-size: 13.5px; line-height: 1.55; color: var(--soft); text-wrap: balance; }

/* ── 동물 화면 — /card/<열쇠>(r 없이). ← · (기억이 있으면) 궁합 칸만 · (없으면) 그 동물 카드 + 내 카드 보기 ── */
.animal { padding-top: 8px; padding-bottom: 44px; }
.back-btn {
  display: inline-grid; place-items: center; width: 48px; height: 48px; margin-left: -10px; border-radius: 50%;
  color: var(--ink); -webkit-tap-highlight-color: transparent;
}
.back-btn:hover { background: var(--paper-lo); }
.animal-wait { display: none; align-items: center; justify-content: center; gap: 10px; margin: 40px 0; font: 600 16px/1.5 var(--sans); color: var(--soft); }
.has-me .animal:not([data-state]) .animal-wait { display: flex; }
.has-me .animal:not([data-state]) .solo { display: none; }
.animal[data-state="compat"] .solo { display: none; }
.solo { width: min(100%, 400px); margin: 4px auto 0; }
@media (max-width: 759.98px) {
  /* 큰 화면의 카드와 같은 셈 — 카드 아래 [내 카드 보기]까지 첫 화면에 */
  .solo { width: min(100%, 400px, max(300px, calc((100vh - 230px) * .5625))); }
  @supports (height: 100svh) {
    .solo { width: min(100%, 400px, max(300px, calc((100svh - 230px) * .5625))); }
  }
}
.solo-go { margin-top: 12px; }

/* 이 카드 × 내 카드 — 7차 궁합 칸 그대로(사장님 "이 부분은 좋다"). 누르면 60가지 그림 칸의 그 자리로 돌아간다 */
.panel {
  background: var(--paper-hi);
  border: 2px solid var(--soft);
  box-shadow: inset 0 0 0 5px var(--paper-hi), inset 0 0 0 6px var(--soft);
  border-radius: 3px;
}
.k-best { --kind: var(--red); }
.k-good { --kind: var(--gold); }
.k-same { --kind: var(--soft); }
.k-plain { --kind: var(--white); }
.k-clash { --kind: var(--blue); }
.compat { max-width: 960px; margin: 4px auto 0; padding: 26px 20px 26px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pair-head { text-align: center; }
.pair-faces { display: flex; align-items: flex-start; justify-content: center; gap: 12px; }
.face { margin: 0; text-align: center; }
.face img {
  display: block; width: 96px; height: 96px; border-radius: 50%; object-fit: cover; object-position: 50% 72%;
  border: 3px solid var(--paper-hi); box-shadow: 0 0 0 2px var(--kind); background: var(--paper);
}
.face figcaption { margin-top: 8px; font: 600 16px/1.3 var(--sans); color: var(--soft); }
.pair-x { padding-top: 30px; font: 700 30px/1 var(--serif); color: var(--soft); }
.pair-names { margin-top: 14px; font: 700 clamp(22px, 6.2vw, 30px)/1.35 var(--serif); color: var(--ink); text-wrap: balance; }
.scores { display: flex; justify-content: center; margin-top: 16px; }
.score-box {
  flex: 1 1 0; min-width: 0; max-width: 260px; padding: 14px 8px; border-radius: 14px; border: 2px solid;
  display: flex; flex-direction: column; align-items: center;
}
.sb-born { background: var(--born-bg); border-color: var(--born-line); }
.sb-name { font: 700 19px/1.35 var(--serif); color: var(--ink); }
.sb-tag { margin-top: 2px; font: 700 15px/1.4 var(--sans); color: var(--born-ink); }
.sb-num { margin-top: 6px; font: 700 clamp(46px, 13vw, 60px)/1.05 var(--serif); letter-spacing: -.01em; white-space: nowrap; color: var(--born-ink); }
.sb-num small { margin-left: 3px; font-size: .45em; }
.pair-kind {
  display: inline-block; margin-top: 8px; padding: 3px 12px; border: 2px solid var(--kind); border-radius: 999px;
  background: #fff; font: 700 15px/1.4 var(--sans); color: var(--kind);
}
.pair-body { margin-top: 22px; padding-top: 20px; border-top: 1px solid #D9CBB8; }
.pair-title { font: 700 23px/1.45 var(--serif); color: var(--ink); }
.pair-lines p { margin-top: 10px; font-size: 18px; line-height: 1.75; }

/* ── 60가지 동물 · 일주 한눈에 ───────────────────────── */
.ilju-all { padding-bottom: 36px; }
.ilju-all h2 { margin-top: 30px; font: 700 clamp(24px, 6.6vw, 32px)/1.35 var(--serif); color: var(--ink); }
.ilju-all h2 + p { margin-top: 10px; }
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 10px; margin: 20px 0 0; padding: 0; list-style: none; }
.gallery li { margin: 0; text-align: center; scroll-margin: 24px; }
.gallery img {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 74%;
  border-radius: 8px; background: var(--paper-hi); box-shadow: 0 8px 18px -12px rgba(74, 52, 38, .6);
}
.gallery span { display: block; margin-top: 6px; font: 700 17px/1.35 var(--serif); color: var(--accent); }
.gallery small { display: block; margin-top: 2px; font: 600 14px/1.35 var(--sans); color: var(--soft); }
.gallery a { display: block; color: inherit; text-decoration: none; }
.gallery a:hover img { box-shadow: 0 0 0 2px var(--accent); }

/* ── 바닥 ─────────────────────────────── */
.foot { padding-bottom: 40px; color: var(--soft); font-size: 16px; }
.foot p { margin-top: 16px; }
.foot a { color: var(--ink); text-underline-offset: 4px; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 10;
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  padding: 14px 20px; border-radius: 12px; background: var(--ink); color: var(--paper-hi);
  font: 600 17px/1.5 var(--sans); text-align: center; text-wrap: balance; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
}

/* ── 넓은 화면 ─────────────────────────── */
@media (min-width: 760px) {
  :root { --gutter: 32px; }
  .gallery { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 20px 16px; }
  .compat { padding: 32px 36px 30px; }
}

@media (min-width: 960px) {
  .stage { --cw: 400px; padding-top: 26px; }
  /* 두 칸 — 왼쪽 카드(입력 카드), 오른쪽 공유 한 쌍 · 방 순위 · 다시 보기(폰에서 카드 아래 오는 것들 그대로의 차례).
     입력 카드에 방 순위가 없으면 한 칸 가운데. 맨 아래 남는 줄이 카드 높이를 받아 오른쪽 사이가 벌어지지 않게 */
  .stage[data-state="card"], .stage[data-state="loading"], .has-me .stage:not([data-state]), .stage.has-board {
    display: grid; grid-template-columns: 400px minmax(0, 460px); justify-content: center; column-gap: 56px; align-items: start;
    grid-template-rows: auto auto auto auto auto 1fr;
    grid-template-areas: "date ." "notice ." "slot share" "slot board" "slot again" "slot .";
  }
  .stage > .today-date { grid-area: date; }
  .stage > .notice { grid-area: notice; }
  .stage > .slot { grid-area: slot; }
  .stage > .share2 { grid-area: share; }
  .stage > .board { grid-area: board; }
  .stage > .again { grid-area: again; }
  .stage[data-state="card"] > :is(.share2, .board, .again), .stage.has-board > :is(.share2, .board, .again) { width: 100%; }
  .stage[data-state="card"] > .share2 { margin-top: 0; }
  .stage[data-state="input"] > .board { margin-top: 0; }
  .stage[data-state="card"] > .again { text-align: left; }
  .stage[data-state="card"] .again-btn { padding-left: 0; }

  .compat { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); column-gap: 44px; align-items: center; }
  .compat[hidden] { display: none; }
  .pair-body { margin-top: 0; padding-top: 0; padding-left: 40px; border-top: 0; border-left: 1px solid #D9CBB8; }
  .pair-title { font-size: 27px; }
  .pair-lines p { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
