/* ============================================================
   시암시 — 흔들어 뽑는 신점
   국가별 테마는 body[data-bg] 와 CSS 변수로 스킨을 갈아 끼운다.
   ============================================================ */

:root {
  --accent: #e0b44a;
  --paper: #f4ede0;
  --ink: #1a1614;
  --muted: #9b8f86;
  --danger: #a8324a;
  --good: #2f8f7a;
  --bg0: #0e0b14;
  --bg1: #1a1322;
  --card: rgba(26, 19, 34, 0.82);
  --line: rgba(255, 255, 255, 0.08);
  --radius: 18px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  color: var(--paper);
  font-family: "Noto Sans KR", "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg0);
  overscroll-behavior: none;
}

body { position: relative; }

/* 배경 레이어 */
#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  transition: background 0.8s ease;
  pointer-events: none;
}
body[data-bg="kr"] #bg { background: radial-gradient(120% 90% at 50% 0%, #2a1c2e 0%, #140d18 55%, #0b0810 100%); }
body[data-bg="jp"] #bg { background: radial-gradient(120% 90% at 50% 0%, #20141a 0%, #160d13 55%, #0a070c 100%); }
body[data-bg="th"] #bg { background: radial-gradient(120% 90% at 50% 0%, #241a0e 0%, #191108 55%, #0c0805 100%); }
body[data-bg="tw"] #bg { background: radial-gradient(120% 90% at 50% 0%, #240f13 0%, #170b0f 55%, #0a0608 100%); }

#app { position: relative; z-index: 1; }

/* ============ 화면 전환 ============ */
.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 20px calc(20px + env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

/* ============ 상단 바 ============ */
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 10px;
}
.bar-title {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.bar-spacer { width: 40px; }
.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--paper);
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, background 0.2s ease;
}
.icon-btn:active { transform: scale(0.92); background: rgba(255,255,255,0.12); }

/* ============ 랜딩 ============ */
.landing-inner {
  margin: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.brand { margin: 4vh 0 20px; }
.brand-symbol { font-size: 52px; filter: drop-shadow(0 6px 18px rgba(224,180,74,0.35)); }
.brand h1 {
  margin: 10px 0 4px;
  font-size: 34px;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-family: "Noto Serif KR", serif;
}
.tagline { margin: 0; color: var(--muted); font-size: 14px; }

.lang-bar { display: flex; gap: 8px; margin-bottom: 28px; }
.lang-btn {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.lang-btn.active { color: var(--paper); border-color: var(--accent); background: rgba(224,180,74,0.12); }

.region-title { font-size: 13px; color: var(--muted); font-weight: 500; margin: 0 0 14px; }

.region-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.region-card {
  position: relative;
  padding: 22px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}
.region-card:active { transform: scale(0.97); }
.region-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.region-card .rc-symbol { font-size: 30px; display: block; margin-bottom: 12px; }
.region-card .rc-name { font-weight: 700; font-size: 17px; }
.region-card .rc-orig { font-size: 13px; color: var(--accent); margin: 2px 0 8px; }
.region-card .rc-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }

.collection-link { margin-top: 16px; }

.disclaimer { margin-top: 26px; font-size: 11px; color: #6d655f; line-height: 1.5; max-width: 420px; }

/* ============ 흔들기 화면 ============ */
.quota { text-align: center; font-size: 12px; color: var(--muted); margin: 4px 0 6px; min-height: 16px; }

.hex-progress {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 6px 0 10px;
}
.hex-progress .hp-line {
  width: 30px;
  height: 7px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  position: relative;
  transition: background 0.3s ease;
}
.hex-progress .hp-line.filled::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: var(--accent);
}
.hex-progress .hp-line.broken::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 0;
  bottom: 0;
  border-radius: 3px;
  background: var(--accent);
}
.hex-progress .hp-line .hp-val {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--muted);
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.tube-scene {
  position: relative;
  width: 200px;
  height: 300px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sticks {
  position: absolute;
  bottom: 150px;
  width: 150px;
  height: 130px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
}
.stick {
  width: 7px;
  border-radius: 3px;
  background: linear-gradient(180deg, #e6c98a 0%, #c49a5a 70%, #a87f43 100%);
  transform-origin: bottom center;
}

.tube {
  position: absolute;
  bottom: 0;
  width: 150px;
  height: 170px;
  transform-origin: bottom center;
  will-change: transform;
  filter: drop-shadow(0 14px 30px rgba(0,0,0,0.5));
}
.tube-body {
  position: absolute;
  inset: 18px 0 0 0;
  border-radius: 0 0 16px 16px;
  background: linear-gradient(100deg, #7a4a28 0%, #a96b35 35%, #6f4120 70%, #5a351b 100%);
  box-shadow: inset 0 0 24px rgba(0,0,0,0.45);
}
.tube-body::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0 0 16px 16px;
  background: repeating-linear-gradient(90deg, rgba(0,0,0,0.16) 0 4px, transparent 4px 9px);
}
.tube-rim {
  position: absolute;
  top: 0;
  left: -6px;
  right: -6px;
  height: 26px;
  border-radius: 14px;
  background: linear-gradient(180deg, #c9934a, #8a5424);
  box-shadow: inset 0 2px 6px rgba(255,255,255,0.25), inset 0 -4px 8px rgba(0,0,0,0.4);
}
body[data-bg="kr"] .tube-rim,
body[data-bg="kr"] .tube-body { filter: hue-rotate(0deg); }
body[data-bg="jp"] .tube-rim { background: linear-gradient(180deg, #b33a2e, #7a1f18); }
body[data-bg="th"] .tube-rim { background: linear-gradient(180deg, #d9a71a, #8a6a10); }
body[data-bg="tw"] .tube-rim { background: linear-gradient(180deg, #b8323c, #7a1f26); }

.hint {
  margin-top: 18px;
  min-height: 22px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  transition: color 0.2s ease;
}
.hint.hot { color: var(--accent); }

/* 게이지 */
.gauge-wrap { margin: 8px 0 14px; }
.gauge {
  height: 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), #fff1c4);
  transition: width 0.08s linear;
  box-shadow: 0 0 16px rgba(224,180,74,0.5);
}
.gauge-label { text-align: center; font-size: 12px; color: var(--muted); margin-top: 7px; min-height: 16px; }

.alt-inputs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.chip {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--paper);
  font-size: 13px;
  cursor: pointer;
}
.chip:active { transform: scale(0.96); }
.chip.active { border-color: var(--accent); }

/* ============ 낙하 연출 ============ */
#drop-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
.drop-stick {
  position: absolute;
  width: 9px;
  height: 120px;
  border-radius: 4px;
  background: linear-gradient(180deg, #ecd3a0 0%, #c49a5a 60%, #a87f43 100%);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  transition: transform 1.15s cubic-bezier(0.2, 0.7, 0.3, 1), top 1.15s cubic-bezier(0.2, 0.7, 0.3, 1), left 1.15s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.drop-stick .ds-num {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
  font-size: 16px;
  font-weight: 700;
  color: #5a351b;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.drop-stick.landed { transform: rotate(90deg) translateY(40px); }
.drop-stick.landed .ds-num { opacity: 1; }

/* ============ 확인(대만) ============ */
.confirm-body { margin: auto; width: 100%; text-align: center; }
.confirm-desc { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 8px 0 28px; }
.jiao-wrap { display: flex; gap: 30px; justify-content: center; margin-bottom: 24px; }
.jiao-block {
  width: 84px;
  height: 120px;
  border-radius: 40px 40px 14px 14px;
  display: grid;
  place-items: center;
  font-size: 30px;
  color: #5a351b;
  transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2), background 0.2s ease;
}
.jiao-block.flat {
  background: linear-gradient(180deg, #f0d9a8, #c79a52);
  transform: rotate(0deg) translateY(6px);
}
.jiao-block.round {
  background: linear-gradient(180deg, #b8733a, #7a421f);
  color: #f0d9a8;
  transform: rotate(180deg);
}
.jiao-result { min-height: 28px; font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.jiao-progress { font-size: 13px; color: var(--muted); margin-bottom: 22px; min-height: 18px; }

/* ============ 결과 ============ */
.result-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.result-head { text-align: center; margin: 10px 0 20px; }
.result-number { font-size: 14px; color: var(--muted); letter-spacing: 0.08em; }
.result-grade {
  font-family: "Noto Serif KR", serif;
  font-size: 46px;
  font-weight: 700;
  margin: 8px 0;
  color: var(--accent);
  text-shadow: 0 4px 30px rgba(224,180,74,0.4);
}
.result-grade.grade-bad { color: var(--danger); }
.result-grade.grade-great { color: #f6c95a; }
.result-poem {
  font-family: "Noto Serif KR", serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--paper);
  margin: 14px 0 6px;
}
.result-overview { color: var(--muted); font-size: 14px; line-height: 1.7; }

.result-flag { text-align: center; font-size: 12px; margin-top: 8px; }
.result-flag.unconfirmed { color: var(--danger); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
}
.card h3 { margin: 0 0 12px; font-size: 13px; color: var(--accent); letter-spacing: 0.04em; }

.section-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.section-item { padding: 12px; border-radius: 12px; background: rgba(255,255,255,0.04); }
.section-item .si-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.section-item .si-name { font-size: 12px; color: var(--muted); }
.section-item .si-score { font-size: 14px; font-weight: 700; color: var(--accent); }
.section-item .si-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; margin-bottom: 8px; }
.section-item .si-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.section-item .si-txt { font-size: 12px; color: var(--paper); line-height: 1.5; }

.actions-list { list-style: none; margin: 0; padding: 0; }
.actions-list li { padding: 8px 0 8px 26px; position: relative; font-size: 14px; line-height: 1.5; }
.actions-list li::before { content: "☑"; position: absolute; left: 2px; color: var(--accent); }

.lucky-row { display: flex; gap: 14px; flex-wrap: wrap; }
.lucky-chip { font-size: 13px; padding: 7px 12px; border-radius: 999px; background: rgba(255,255,255,0.05); border: 1px solid var(--line); }
.lucky-chip b { color: var(--accent); }

.warning-text { font-size: 13px; color: #e0a5a5; line-height: 1.6; }
.avoid-text { margin-top: 10px; font-size: 13px; color: var(--muted); line-height: 1.6; }

/* 키워드 + 확언 */
.keyword-card { text-align: center; }
.keyword {
  font-family: "Noto Serif KR", serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.affirmation { font-size: 14px; color: var(--paper); font-style: italic; line-height: 1.6; }

/* 괘사 */
.gua-ci-han {
  font-family: "Noto Serif KR", "Noto Serif CJK KR", serif;
  font-size: 16px;
  color: var(--paper);
  line-height: 1.9;
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}
.gua-ci-ko { font-size: 13px; color: var(--muted); line-height: 1.7; }
.qian-title { font-size: 13px; color: var(--accent); margin-bottom: 10px; letter-spacing: 0.02em; }
.qian-gloss { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: rgba(224,180,74,0.1); color: var(--paper); font-size: 14px; line-height: 1.6; }

/* 전통 점단 */
.traditional-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.trad-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.trad-name { font-size: 11px; color: var(--accent); }
.trad-text { font-size: 13px; color: var(--paper); line-height: 1.5; }

/* 오늘의 루틴 */
.routine-list { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.routine-list li {
  counter-increment: step;
  position: relative;
  padding: 10px 0 10px 44px;
  font-size: 14px;
  line-height: 1.5;
}
.routine-list li span {
  position: absolute;
  left: 0;
  top: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(224,180,74,0.16);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

/* 결과 액션 */
.result-actions { display: flex; gap: 10px; padding-top: 14px; }
.btn {
  flex: 1;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--paper);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(120deg, var(--accent), #c9923a);
  color: #241503;
  border: none;
}
.btn:disabled { opacity: 0.5; cursor: default; }

.post-actions { display: flex; gap: 10px; padding-top: 12px; }
.btn.ritual { border-color: var(--accent); color: var(--accent); }

.coll-owned { font-size: 12px; color: var(--muted); margin-top: 7px; line-height: 1.6; }
.reset-link { margin: 24px auto 0; display: block; color: var(--muted); }

/* ============ 보관함 ============ */
.coll-stats { text-align: center; font-size: 13px; color: var(--muted); margin: 6px 0 14px; }
.coll-list { list-style: none; margin: 0; padding: 0; }
.coll-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  cursor: pointer;
}
.coll-item .ci-grade { font-family: "Noto Serif KR", serif; font-weight: 700; font-size: 18px; min-width: 46px; color: var(--accent); }
.coll-item .ci-grade.bad { color: var(--danger); }
.coll-item .ci-main { flex: 1; }
.coll-item .ci-title { font-size: 14px; }
.coll-item .ci-date { font-size: 11px; color: var(--muted); margin-top: 3px; }
.coll-empty { text-align: center; color: var(--muted); font-size: 14px; margin-top: 60px; }

/* ============ 토스트 ============ */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: #21172e;
  color: #fff4df;
  border: 1px solid #b99acb;
  border-radius: 18px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
  box-shadow: 0 8px 28px #0006;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  max-width: 88vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 쌀점 (던지기) ============ */
.rice-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.rice-bowl {
  position: relative;
  width: 230px;
  height: 150px;
  border-radius: 0 0 115px 115px;
  background: linear-gradient(180deg, #d8c9a0, #b9a678);
  box-shadow: inset 0 10px 24px rgba(0,0,0,0.25), 0 14px 30px rgba(0,0,0,0.4);
  overflow: hidden;
}
.rice-grains { position: absolute; inset: 10px 16px; }
.grain {
  position: absolute;
  width: 9px;
  height: 5px;
  border-radius: 50%;
  background: #f7efd8;
  box-shadow: inset -1px -1px 1px rgba(0,0,0,0.15);
}
.rice-bowl.tossing .grain { animation: grain-toss 0.8s ease-out forwards; }
@keyframes grain-toss {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(0, -130px) scale(0.7); opacity: 0; }
}
.rice-bowl-label {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  color: #5a4d2e;
  font-weight: 600;
}
.rice-hint { font-size: 14px; color: var(--muted); }
.rice-count { font-size: 22px; font-weight: 700; color: var(--accent); min-height: 30px; opacity: 0; transform: translateY(8px); transition: opacity 0.3s ease, transform 0.3s ease; }
.rice-count.show { opacity: 1; transform: translateY(0); }
.rice-toss-btn { width: 100%; max-width: 280px; }

/* ============ MUDAN — 캐릭터 & 채팅 (와이어프레임) ============ */
.brand-mudan { font-family: "Noto Serif KR", serif; font-weight: 700; letter-spacing: 0.14em; color: var(--accent); }

.char-body { flex: 1; display: flex; flex-direction: column; }
.char-heading { font-size: 26px; line-height: 1.35; margin: 10px 0 6px; font-family: "Noto Serif KR", serif; }
.char-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

.char-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.char-card {
  position: relative;
  padding: 20px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  text-align: left;
  transition: transform 0.15s ease, border-color 0.2s ease;
  overflow: hidden;
}
.char-card:active { transform: scale(0.97); }
.char-card:hover { border-color: var(--cc, var(--accent)); }
.char-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--cc, var(--accent));
}
.char-avatar {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: rgba(255,255,255,0.05);
  display: grid; place-items: center;
  font-size: 28px;
  margin-bottom: 12px;
  border: 1px dashed var(--line); /* 와이어프레임 플레이스홀더 */
}
.char-name { font-weight: 700; font-size: 17px; }
.char-ko { color: var(--muted); font-size: 13px; font-weight: 400; }
.char-subtitle { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.char-fortune { font-size: 11px; color: var(--cc, var(--accent)); margin-top: 8px; letter-spacing: 0.02em; }
.char-specialty {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--cc, var(--accent));
}

/* 캐릭터 캐러셀 */
.char-carousel-wrap { position: relative; display: flex; align-items: center; }
.char-carousel {
  flex: 1;
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 2px 10px;
}
.char-carousel::-webkit-scrollbar { display: none; }
.char-carousel .char-card { flex: 0 0 76%; scroll-snap-align: center; }
.carousel-arrow {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--paper);
  font-size: 18px;
  cursor: pointer;
  display: grid; place-items: center;
  z-index: 2;
}
.carousel-arrow:active { transform: scale(0.9); }
.carousel-dots { display: flex; gap: 8px; justify-content: center; margin-top: 2px; }
.carousel-dots .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  cursor: pointer;
  padding: 0;
}
.carousel-dots .dot.active { background: var(--accent); }

/* 채팅 */
#screen-chat { padding-left: 0; padding-right: 0; }
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.ai { justify-content: flex-start; }
.bubble {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.msg.ai .bubble { background: rgba(255,255,255,0.08); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.user .bubble { background: linear-gradient(120deg, var(--accent), #c9923a); color: #241503; border-bottom-right-radius: 5px; }
.bubble.typing { color: var(--muted); animation: blink 1.2s infinite; }
@keyframes blink { 0%,100%{opacity:.3} 50%{opacity:1} }
.bubble-note { background: rgba(224,180,74,0.12); color: var(--accent); text-align: center; width: 100%; max-width: 100%; }

.quick-actions {
  display: flex;
  justify-content: center;
  padding: 8px 16px 4px;
}
.quick-actions .chip { font-size: 13px; }

.chat-inputbar {
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(10, 8, 16, 0.5);
}
#chat-input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  color: var(--paper);
  font-size: 14px;
  outline: none;
}
#chat-input:focus { border-color: var(--accent); }
.send { background: var(--accent); color: #241503; border: none; font-weight: 700; }

/* AI 해석 */
.ai-card { border-color: var(--accent); }
.ai-interpret { min-height: 40px; color: var(--muted); font-size: 14px; }
.ai-text { color: var(--paper); line-height: 1.7; font-size: 14.5px; }

/* 상담 기록 */
.history-list { padding: 14px 20px; overflow-y: auto; flex: 1; }
.history-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  margin-bottom: 10px;
}
.hi-avatar {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px dashed var(--line);
  display: grid; place-items: center;
  font-size: 20px;
  flex: 0 0 auto;
}
.hi-main { flex: 1; min-width: 0; }
.hi-head { display: flex; justify-content: space-between; align-items: baseline; }
.hi-name { font-weight: 700; font-size: 14px; }
.hi-date { font-size: 11px; color: var(--muted); }
.hi-concern { font-size: 13px; color: var(--paper); margin-top: 4px; line-height: 1.5; }
.hi-fortune { font-size: 12px; color: var(--accent); margin-top: 6px; }
.history-empty { text-align: center; color: var(--muted); margin-top: 60px; font-size: 14px; }

.avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.avatar-letter {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #241503;
  font-weight: 700;
  font-size: 13px;
}

/* 캐릭터 패널 (채팅 상단) */
.char-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,8,16,0.4);
}
.char-portrait {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px dashed var(--line);
  display: grid; place-items: center;
  font-size: 26px;
}
.char-meta-name { font-weight: 700; font-size: 15px; }
.char-meta-status { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* 진입 메뉴 */
.start-menu {
  margin: 12px 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.start-question { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.start-options { display: flex; flex-direction: column; gap: 8px; }
.start-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  color: var(--paper);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}
.start-opt:active { transform: scale(0.98); }
.start-opt.primary { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.start-opt.disabled { opacity: 0.45; cursor: default; }
.start-opt.back { justify-content: center; color: var(--muted); border-style: dashed; }
.so-icon { flex: 0 0 auto; font-size: 18px; }
.so-sub { margin-left: auto; font-size: 11px; color: var(--muted); }

/* 고민 확인 카드 */
.concern-card {
  margin: 12px 20px;
  padding: 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: rgba(224,180,74,0.08);
}
.concern-label { font-size: 12px; color: var(--muted); }
.concern-summary {
  font-family: "Noto Serif KR", serif;
  font-size: 17px;
  font-weight: 700;
  margin: 8px 0 14px;
  line-height: 1.5;
  color: var(--paper);
}
.concern-actions { display: flex; gap: 8px; }
.concern-actions .btn { padding: 11px; font-size: 14px; }

/* 말풍선 모드 */
#screen-chat.bubble-mode .bubble { position: relative; }
#screen-chat.bubble-mode .msg.ai .bubble { border-radius: 4px 18px 18px 18px; }
#screen-chat.bubble-mode .msg.ai .bubble::before {
  content: ""; position: absolute; left: -7px; top: 14px;
  width: 0; height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-right: 8px solid rgba(255,255,255,0.10);
}
#screen-chat.bubble-mode .msg.user .bubble { border-radius: 18px 4px 18px 18px; }
#screen-chat.bubble-mode .msg.user .bubble::after {
  content: ""; position: absolute; right: -7px; top: 14px;
  width: 0; height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 8px solid #c9923a;
}

/* ============ 접근성 ============ */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.05s !important; animation-duration: 0.05s !important; }
}
/* Language choice is available before and after sign-in. */
.language-select{max-width:105px;min-width:76px;padding:7px 4px;border:1px solid #d7b780;border-radius:10px;background:#302039;color:#fff0d5;font:600 12px system-ui,sans-serif;cursor:pointer}
.language-select:focus-visible{outline:2px solid #ffd46a;outline-offset:2px}
