@font-face {
  font-family: 'Daerong';
  src: url('/fonts/온글잎 대롱체.ttf') format('truetype');
  font-display: swap;
}

:root {
  --ink: #3a2c2a;
  --outline: #2f2f33;
  --bubble-bg: #dedede;
  --btn-red: #a85656;
  --btn-red-hover: #b86464;
  --btn-gray: #8a8a8a;
  --snow: #cfd6ef;
  --white: #ffffff;
  --shadow: rgba(40, 40, 80, 0.28);
  --font: 'Daerong', 'Apple SD Gothic Neo', 'Hiragino Sans', 'Noto Sans JP', 'Malgun Gothic', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #2a2c66;
  font-family: var(--font);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; opacity: 0.45; }
[hidden] { display: none !important; }

.app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  container-type: size;
  background: var(--snow);
}

/* ---------- 배경 ---------- */
.scene {
  position: absolute;
  inset: 0;
  background-color: var(--snow);
  background-image: url('/bg/크리스마스때먹으면안되는음식은울면곱뺴기.png');
  background-repeat: no-repeat;
  background-position: center top;
  /* 세로: 높이 기준으로 확대 → 트리가 화면 중앙 위쪽, 아래는 눈밭.
     숫자를 줄이면 마을이 더 넓게 보인다 (바꾸면 .host 와 .slot-* 위치도 같이 맞추기) */
  background-size: auto 140%;
}

@media (orientation: landscape) {
  .scene {
    /* 가로: 가로폭 기준으로 채우고 위쪽 마을 부분을 보여준다 */
    background-size: cover;
    background-position: center top;
  }
}

/* ---------- 마을 ---------- */
.village { position: absolute; inset: 0; }

.village-header {
  position: absolute;
  top: max(11cqh, 66px);
  left: 5cqw;
  z-index: 5;
  color: var(--white);
  text-shadow: 0 2px 6px rgba(20, 20, 60, 0.45);
  pointer-events: none;
}

.village-title {
  margin: 0;
  font-size: clamp(24px, 7.2cqw, 34px);
  font-weight: normal;
  line-height: 1.15;
}

.village-count {
  margin: 2px 0 0;
  font-size: clamp(14px, 4cqw, 19px);
}

.village-dday {
  display: inline-block;
  margin: 6px 0 0;
  padding: 3px 11px;
  border-radius: 999px;
  background: rgba(20, 30, 80, 0.55);
  font-size: clamp(12px, 3.4cqw, 16px);
}
.village-dday:empty { display: none; }

@media (orientation: landscape) {
  .village-header { top: max(5cqh, 68px); left: 3cqw; }
  .village-title { font-size: clamp(24px, 3.2cqw, 46px); }
  .village-count { font-size: clamp(14px, 1.6cqw, 24px); }
  .village-dday { font-size: clamp(12px, 1.3cqw, 19px); }
}

/* 마을에 내리는 눈: 배경 바로 위, 글씨·캐릭터보다 아래.
   흰 눈밭 위에서도 보이게 눈송이 둘레에 옅은 남색 그림자를 준다 */
.village-snow {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.village-snow::before,
.village-snow::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  will-change: transform;
  filter: drop-shadow(0 0 1px rgba(40, 50, 120, 0.5));
}
.village-snow::before {
  top: -220px;
  opacity: 0.9;
  background-image:
    radial-gradient(2px 2px at 25px 30px, #fff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 130px 70px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 190px 130px, #fff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 70px 160px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 165px 205px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 100px 110px, #fff 50%, transparent 51%);
  background-size: 220px 220px;
  animation: village-snow-small 5s linear infinite;
}
.village-snow::after {
  top: -360px;
  opacity: 0.85;
  background-image:
    radial-gradient(3px 3px at 50px 70px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 260px 190px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 170px 320px, #fff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 320px 40px, #fff 50%, transparent 51%);
  background-size: 360px 360px;
  animation: village-snow-big 6s linear infinite;
}
/* 무늬 한 칸만큼 내려가면 처음과 똑같아서 끊김 없이 반복된다 */
@keyframes village-snow-small { to { transform: translateY(220px); } }
@keyframes village-snow-big { to { transform: translateY(360px); } }

.pages-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  /* 화면 전체를 덮지만 클릭은 뒤의 대표 캐릭터까지 통과시키고, 주민만 받는다 */
  pointer-events: none;
}
.resident { pointer-events: auto; }

/* ---------- 마을 대표 캐릭터 ---------- */
.host {
  --hh: min(12.5cqh, 31cqw);
  position: absolute;
  left: 50%;
  top: 49%; /* 그루터기 사이 (세로 배경 140% 기준) */
  z-index: 0;
  transform: translate(-50%, -100%);
}
@media (orientation: landscape) {
  .host { --hh: min(17cqh, 14cqw); top: 72%; }
}

.host-char {
  position: relative;
  display: block;
  height: var(--hh);
  margin: 0 auto;
  touch-action: manipulation;
}
.host-char::before {
  /* 그림자 */
  content: '';
  position: absolute;
  left: 50%;
  bottom: -3%;
  width: 70%;
  height: 10%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--shadow);
  filter: blur(1px);
}
.host-char img {
  position: relative;
  display: block;
  height: 100%;
  width: auto;
  transform-origin: 50% 100%;
  animation: host-idle 6s ease-in-out infinite;
  user-select: none;
  -webkit-user-drag: none;
}
.host-char:hover img { animation: hop 1s ease-in-out; }
.host.is-poked .host-char img { animation: poke 1s ease-in-out; }

/* 대표 캐릭터는 몸집이 커서 주민보다 느리고 작게 숨쉰다 */
@keyframes host-idle {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.01, 0.99); }
}

.host-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  width: max-content;
  max-width: min(72cqw, 320px);
  padding: 8px 14px;
  border: 3px solid var(--outline);
  border-radius: 18px;
  background: #fff;
  color: #2a2a2e;
  font-size: clamp(15px, 2.1cqh, 19px);
  line-height: 1.35;
  text-align: center;
  word-break: keep-all;
  overflow-wrap: anywhere;
  transform: translateX(-50%);
  box-shadow: var(--ring, 0 0 transparent), 0 6px 16px rgba(20, 20, 60, 0.22);
  animation: bubble-pop 0.35s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
.host-bubble::before,
.host-bubble::after {
  /* 꼬리 */
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-style: solid;
  border-color: transparent;
}
.host-bubble::before { bottom: -14px; border-width: 12px 9px 0; border-top-color: var(--outline); }
.host-bubble::after { bottom: -8px; border-width: 8px 6px 0; border-top-color: #fff; }

.host-text { margin: 0; white-space: pre-wrap; }
.host.is-owner .host-text { cursor: pointer; }
.host-bubble.is-placeholder { border-style: dashed; color: #77777d; }

/* ---------- 말풍선 테마 (마을 꾸미기에서 고름) ----------
   .bubble-theme-* 는 실제 말풍선과 고르기 칸의 미리보기에 같이 쓴다.
   --edge: 꼬리 색 (테두리와 같은 색) */
.bubble-theme-candy,
.bubble-theme-mint {
  border: 4px solid transparent;
  background:
    linear-gradient(#fff, #fff) padding-box,
    repeating-linear-gradient(45deg, var(--stripe) 0 6px, #fff 6px 12px) border-box;
  --ring: 0 0 0 1.5px var(--stripe);
}
.bubble-theme-candy { --stripe: #d8343c; --edge: #d8343c; }
.bubble-theme-mint { --stripe: #2f9e5b; --edge: #2f9e5b; }
.bubble-theme-lights {
  --edge: #b8862b;
  border: 5px solid transparent;
  background:
    linear-gradient(#fff, #fff) padding-box,
    radial-gradient(circle, #fff3b0 0 1.6px, transparent 2.2px) 0 0 / 10px 10px border-box,
    linear-gradient(#b8862b, #b8862b) border-box;
  animation: bubble-twinkle 2.4s ease-in-out infinite;
}
.host-bubble.bubble-theme-lights {
  animation: bubble-pop 0.35s cubic-bezier(0.3, 1.4, 0.5, 1) both, bubble-twinkle 2.4s ease-in-out 0.35s infinite;
}
@keyframes bubble-twinkle {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(255, 210, 90, 0.4)); }
  50% { filter: drop-shadow(0 0 7px rgba(255, 210, 90, 0.95)); }
}
.bubble-theme-ginger {
  --edge: #a0612b;
  border: 6px solid #a0612b;
  outline: 2px dashed #fff;
  outline-offset: -4px;
}
.host-bubble[class*='bubble-theme-']::before { border-top-color: var(--edge); }
.host-bubble.is-placeholder[class*='bubble-theme-'] { border-style: solid; }
@media (prefers-reduced-motion: reduce) {
  .bubble-theme-lights, .host-bubble.bubble-theme-lights { animation: none; filter: drop-shadow(0 0 5px rgba(255, 210, 90, 0.7)); }
}

/* 마을 꾸미기: 말풍선 테마 고르기 */
.bubble-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.bubble-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 1;
  padding: 4px 2px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  line-height: 1.2;
  word-break: keep-all;
  color: #4a4a50;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.bubble-option:hover { background: rgba(255, 255, 255, 0.9); }
.bubble-option[aria-checked='true'] { border-color: var(--btn-red); background: #fff; transform: translateY(-2px); color: var(--btn-red); }
/* :where = 우선순위 0 → 위의 .bubble-theme-* 가 항상 이긴다 */
:where(.bubble-swatch) {
  position: relative;
  padding: 3px 10px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  background: #fff;
  color: #2a2a2e;
  font-size: 13px;
  box-shadow: var(--ring, 0 0 transparent);
  pointer-events: none;
}

@keyframes bubble-pop {
  from { opacity: 0; transform: translateX(-50%) scale(0.7); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}

.host-bubble.is-editing { width: min(76cqw, 320px); padding: 10px; }
.greeting-input {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 2px solid #d6d6dc;
  border-radius: 12px;
  font: inherit;
  font-size: 17px;
  line-height: 1.35;
  text-align: center;
  resize: none;
  outline: none;
}
.greeting-input:focus { border-color: var(--outline); }
.greeting-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.greeting-count { margin-right: auto; color: #9a9aa0; font-size: 13px; }
.greeting-btn {
  padding: 5px 12px;
  border-radius: 10px;
  background: #e4e4e8;
  font-size: 15px;
}
.greeting-btn.is-primary { background: var(--btn-red); color: #fff; }

/* 대표 캐릭터 고르기 (마을 만들기·계정 설정) */
.host-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.host-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  color: #4a4a50;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.host-option img { width: 100%; height: 56px; object-fit: contain; pointer-events: none; }
.host-option:hover { background: rgba(255, 255, 255, 0.9); }
.host-option[aria-checked='true'] { border-color: var(--btn-red); background: #fff; transform: translateY(-2px); color: var(--btn-red); }

.pages {
  display: flex;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.22, 0.8, 0.3, 1);
  will-change: transform;
}

.page {
  position: relative;
  flex: 0 0 100%;
  height: 100%;
}

/* 주민 배치: 세로 */
.slot-0 { --x: 32%; --y: 60%; }
.slot-1 { --x: 70%; --y: 58%; }
.slot-2 { --x: 54%; --y: 69%; }
.slot-3 { --x: 18%; --y: 74%; }
.slot-4 { --x: 82%; --y: 75%; }
.slot-5 { --x: 40%; --y: 82%; }

/* 주민 배치: 가로 */
@media (orientation: landscape) {
  .slot-0 { --x: 33%; --y: 77%; }
  .slot-1 { --x: 67%; --y: 77%; }
  .slot-2 { --x: 50%; --y: 85%; }
  .slot-3 { --x: 17%; --y: 85%; }
  .slot-4 { --x: 83%; --y: 85%; }
  .slot-5 { --x: 31%; --y: 93%; }
}

.resident {
  --h: min(9.5cqh, 25cqw);
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: calc(var(--h) * 0.85);
  height: var(--h);
  transform: translate(-50%, -100%);
  transition: opacity 0.3s ease;
  touch-action: manipulation;
}

@media (orientation: landscape) {
  .resident { --h: min(14cqh, 12cqw); }
}

.resident::before {
  /* 그림자 */
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4%;
  width: 92%;
  height: 14%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--shadow);
  filter: blur(1px);
}

.resident img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  transform-origin: 50% 100%;
  animation: idle 3.2s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.resident:hover img,
.resident:focus-visible img { animation: hop 0.5s ease; }

.resident:focus-visible { outline: none; }
.resident:focus-visible .resident-name { text-decoration: underline; }

.resident.is-new { animation: arrive 0.7s cubic-bezier(0.3, 1.4, 0.5, 1) both; }

.resident.is-hidden { opacity: 0; pointer-events: none; }

.resident.is-poked img { animation: poke 0.5s ease; }

@keyframes poke {
  0%, 100% { transform: translateY(0) rotate(0); }
  30% { transform: translateY(-12%) rotate(-4deg); }
  60% { transform: translateY(0) rotate(4deg); }
}

.resident-name {
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 160%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(12px, 1.8cqh, 18px);
  color: var(--white);
  text-shadow:
    0 0 3px rgba(40, 40, 90, 0.9),
    0 1px 2px rgba(40, 40, 90, 0.9);
}

@keyframes idle {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.02, 0.98); }
}

@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10%); }
}

@keyframes arrive {
  0% { opacity: 0; transform: translate(-50%, -160%) scale(0.6); }
  100% { opacity: 1; transform: translate(-50%, -100%) scale(1); }
}

.empty-hint {
  position: absolute;
  left: 50%;
  top: 74%;
  transform: translateX(-50%);
  margin: 0;
  color: rgba(70, 72, 120, 0.7);
  font-size: clamp(14px, 2.2cqh, 20px);
  white-space: nowrap;
}

/* 페이지 화살표 */
.page-arrow {
  position: absolute;
  top: 67%;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(220, 224, 236, 0.85);
  box-shadow: 0 2px 6px rgba(40, 40, 90, 0.18);
  transform: translateY(-50%);
  transition: transform 0.15s ease, background 0.15s ease;
}
.page-arrow:hover { background: rgba(240, 242, 250, 0.95); }
.page-arrow:active { transform: translateY(-50%) scale(0.92); }
.page-arrow.prev { left: 3cqw; }
.page-arrow.next { right: 3cqw; }
.page-arrow svg { width: 20px; height: 20px; fill: none; stroke: #2b2b33; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

@media (orientation: landscape) {
  .page-arrow { top: 80%; width: 44px; height: 44px; }
  .page-arrow svg { width: 24px; height: 24px; }
}

/* 하단 */
.bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 3cqh);
  z-index: 7;
  display: flex;
  justify-content: center;
  padding: 0 6cqw;
  pointer-events: none;
}
.bottom-bar > * { pointer-events: auto; }

.primary-btn {
  min-height: 46px;
  padding: 8px 26px;
  border-radius: 16px;
  background: var(--btn-red);
  color: var(--white);
  font-size: 22px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 12px rgba(80, 30, 30, 0.25);
  transition: transform 0.12s ease, background 0.15s ease;
}
.primary-btn:hover:not(:disabled) { background: var(--btn-red-hover); }
.primary-btn:active:not(:disabled) { transform: scale(0.97); }

.write-btn { width: min(100%, 420px); min-height: 52px; font-size: 26px; }
/* 11월 25일 전: 눌리긴 하지만(안내 표시) 잠긴 것처럼 흐리게 */
.write-btn.is-locked {
  background: rgba(120, 110, 130, 0.85);
  font-size: 21px;
}
.write-btn.is-locked:hover { background: rgba(120, 110, 130, 0.95); }

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.share-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.owner-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 16px rgba(40, 40, 90, 0.2);
  font-size: 17px;
}
.owner-nav > button,
.owner-nav .lang-toggle { padding: 6px 14px; border-radius: 999px; }
.owner-nav > button:hover,
.owner-nav .lang-toggle:hover { background: rgba(0, 0, 0, 0.06); }
.owner-nav .divider { width: 1px; height: 16px; background: rgba(0, 0, 0, 0.18); }

/* ---------- 언어 드롭다운 ---------- */
.lang-select { position: relative; }

.lang-select .lang-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.flag {
  display: inline-flex;
  flex: 0 0 auto;
  width: 22px;
  height: 15px;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.flag svg { width: 100%; height: 100%; display: block; }

.lang-chevron {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s ease;
}
.lang-select.is-open .lang-chevron { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  min-width: 150px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(20, 20, 60, 0.28);
  color: #1f1f22;
  animation: menu-in 0.16s ease;
  transform-origin: top right;
}
.lang-select.drop-up .lang-menu {
  top: auto;
  bottom: calc(100% + 14px);
  transform-origin: bottom right;
}

.lang-select .lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 17px;
  text-align: left;
  white-space: nowrap;
}
.lang-select .lang-option:hover,
.lang-select .lang-option:focus-visible { background: rgba(0, 0, 0, 0.06); outline: none; }
.lang-select .lang-option[aria-selected='true'] { background: rgba(168, 86, 86, 0.12); color: var(--btn-red); }

@keyframes menu-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

/* 상단 플로팅 (손님/첫 화면) */
.lang-floating {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: 14px;
  z-index: 8;
}
.lang-floating .lang-toggle {
  background: rgba(255, 255, 255, 0.22);
  color: var(--white);
  font-size: 15px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.lang-floating .lang-toggle:hover,
.lang-floating.is-open .lang-toggle { background: rgba(255, 255, 255, 0.35); }

/* ---------- 공통 말풍선 ---------- */
.bubble {
  background: var(--bubble-bg);
  border: 5px solid var(--outline);
  border-radius: 44px;
  box-shadow: 0 10px 30px rgba(10, 10, 30, 0.25);
}

.dim {
  position: absolute;
  inset: 0;
  background: rgba(30, 30, 50, 0.5);
  opacity: 0;
  transition: opacity 0.35s ease;
}

/* ---------- 편지 보기 ---------- */
.letter-view {
  --bigW: min(70cqw, 38cqh);
  --visible: calc(var(--bigW) * 0.74);
  position: absolute;
  inset: 0;
  z-index: 20;
}
.letter-view.is-open .dim { opacity: 1; }

.big-char {
  position: absolute;
  left: 50%;
  top: calc(100% - var(--visible));
  width: var(--bigW);
  transform: translate(-50%, 110%);
  transition: transform 0.45s cubic-bezier(0.25, 0.9, 0.35, 1);
  pointer-events: none;
  user-select: none;
}
.letter-view.char-up .big-char { transform: translate(-50%, 0); }
/* 삭제: 내려가지 않고 그 자리에서 작아지며 사라짐 */
.letter-view.char-removed .big-char {
  transform: translate(-50%, 10%) scale(0.4);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.4s ease;
}

.letter-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(var(--visible) + 22px);
  width: min(92cqw, 520px);
  max-height: calc(100cqh - var(--visible) - 22px - max(4cqh, 16px));
  display: flex;
  flex-direction: column;
  padding: clamp(18px, 4cqh, 32px) clamp(20px, 6cqw, 34px) clamp(16px, 3cqh, 26px);
  transform: translate(-50%, 0) scale(0.6);
  transform-origin: 50% 100%;
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.3, 1.4, 0.5, 1), opacity 0.2s ease;
}
.letter-bubble::after,
.letter-bubble::before {
  /* 말풍선 꼬리 */
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-style: solid;
  border-color: transparent;
}
.letter-bubble::before {
  bottom: -26px;
  border-width: 22px 17px 0;
  border-top-color: var(--outline);
}
.letter-bubble::after {
  bottom: -16px;
  border-width: 15px 11px 0;
  border-top-color: var(--bubble-bg);
}
.letter-view.bubble-in .letter-bubble { transform: translate(-50%, 0) scale(1); opacity: 1; }

.letter-content {
  min-height: 0;
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
  overscroll-behavior: contain;
}
.letter-view.text-in .letter-content { opacity: 1; }

.letter-from {
  margin: 0 0 clamp(14px, 3.5cqh, 28px);
  font-size: clamp(24px, 3.6cqh, 32px);
  color: #2a2a2e;
  word-break: break-all;
}
.from-label { color: #6b6b70; margin-right: 1px; }

.letter-body {
  font-size: clamp(16px, 2.4cqh, 21px);
  line-height: 1.55;
  color: #1f1f22;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.letter-actions {
  display: flex;
  gap: 12px;
  margin-top: clamp(16px, 4cqh, 34px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.letter-view.text-in .letter-actions { opacity: 1; }

.delete-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--btn-red);
  transition: background 0.15s ease, transform 0.12s ease;
}
.delete-btn:hover { background: var(--btn-red-hover); }
.delete-btn:active { transform: scale(0.94); }
.delete-btn svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.close-btn {
  flex: 1;
  height: 48px;
  border-radius: 18px;
  background: var(--btn-gray);
  color: #1f1f22;
  font-size: 22px;
  transition: background 0.15s ease, transform 0.12s ease;
}
.close-btn:hover { background: #979797; }
.close-btn:active { transform: scale(0.98); }

/* ---------- 편지 쓰기 ---------- */
.write-view {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
}
.write-view.is-open .dim { opacity: 1; }

.write-card {
  position: relative;
  width: min(100%, 480px);
  max-height: calc(100cqh - 32px);
  overflow-y: auto;
  padding: 26px 24px 22px;
  border-radius: 36px;
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.write-view.is-open .write-card { opacity: 1; transform: none; }

.write-title {
  margin: 0 0 18px;
  font-size: clamp(20px, 3.2cqh, 26px);
  font-weight: normal;
  text-align: center;
  color: #2a2a2e;
}

.char-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.char-option {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 0.85;
  padding: 12px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.55);
  border: 3px solid transparent;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.char-option img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.char-option:hover { background: rgba(255, 255, 255, 0.8); }
.char-option[aria-checked='true'] {
  border-color: var(--btn-red);
  background: #fff;
  transform: translateY(-3px);
}
.char-option[aria-checked='true'] img { animation: hop 0.5s ease; }

.write-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.write-actions .primary-btn { flex: 1.4; }

.ghost-btn {
  flex: 1;
  min-height: 46px;
  border-radius: 16px;
  background: var(--btn-gray);
  color: #1f1f22;
  font-size: 20px;
  transition: background 0.15s ease;
}
.ghost-btn:hover { background: #979797; }

.write-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}
.write-head .write-title { margin: 0; }
.picked-char { width: 40px; height: 46px; object-fit: contain; }

.field { position: relative; display: block; margin-top: 10px; }
.field-label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #6b6b70;
  font-size: 20px;
  pointer-events: none;
}
.field-label + .text-input { padding-left: 66px; }

.text-input {
  width: 100%;
  padding: 12px 16px;
  border: 3px solid transparent;
  border-radius: 18px;
  background: #fff;
  font: inherit;
  font-size: 19px;
  color: #1f1f22;
  outline: none;
  transition: border-color 0.15s ease;
}
.text-input:focus { border-color: var(--outline); }
.text-input::placeholder { color: #a6a6ad; }

.message-input {
  display: block;
  min-height: 200px;
  height: 34cqh;
  max-height: 340px;
  resize: none;
  line-height: 1.5;
  padding-bottom: 30px;
}

.char-count {
  position: absolute;
  right: 16px;
  bottom: 10px;
  color: #9a9aa0;
  font-size: 14px;
  pointer-events: none;
}

/* ---------- 첫 화면 (로그인 전) ---------- */
.intro {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  /* 배경 마을 위에 밤하늘처럼 어둡게 깔아서 글씨가 잘 보이게 */
  background: linear-gradient(180deg, rgba(14, 15, 44, 0.78) 0%, rgba(20, 22, 60, 0.55) 45%, rgba(14, 15, 44, 0.82) 100%);
  color: #fff;
}

.intro-main {
  position: relative;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.2cqh, 22px);
  padding: calc(env(safe-area-inset-top, 0px) + 70px) 20px 20px;
  text-align: center;
}
.intro-main > :not(.intro-snow) { position: relative; z-index: 1; }

.intro-title {
  margin: 0;
  font-size: clamp(32px, min(9cqw, 6.5cqh), 60px);
  font-weight: normal;
  line-height: 1.15;
  text-shadow: 0 3px 12px rgba(10, 10, 40, 0.6);
  word-break: keep-all;
}

.intro-sub {
  margin: 0;
  font-size: clamp(16px, min(4.2cqw, 2.6cqh), 22px);
  opacity: 0.92;
  text-shadow: 0 2px 8px rgba(10, 10, 40, 0.6);
  word-break: keep-all;
}

/* 지금까지 만들어진 마을 수: 가로로 긴 반투명 알약 */
.intro-stat {
  margin: 0;
  padding: 2px 22px;
  min-width: min(100%, 300px);
  line-height: 1.35;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  font-size: clamp(14px, min(3.8cqw, 2.3cqh), 19px);
  text-shadow: 0 1px 6px rgba(10, 10, 40, 0.5);
  word-break: keep-all;
}

.intro-moon {
  --moon: min(64cqw, 38cqh, 380px);
  display: grid;
  place-items: center;
  width: var(--moon);
  height: var(--moon);
  margin: clamp(4px, 1.5cqh, 16px) 0;
  border-radius: 50%;
  overflow: hidden; /* 그림의 네모난 흰 모서리를 달 모양으로 잘라냄 */
  background: radial-gradient(circle at 38% 32%, #fffdf6 0%, #f8efd6 55%, #ecdcb2 100%);
  box-shadow:
    0 0 50px rgba(255, 238, 190, 0.55),
    0 0 130px rgba(255, 228, 160, 0.28),
    inset -14px -18px 40px rgba(205, 180, 120, 0.35);
  isolation: isolate;
  animation: moon-float 4.5s ease-in-out infinite;
}
.intro-moon img {
  width: 70%;
  height: 76%;
  margin-top: 6%;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(150, 120, 60, 0.25));
  user-select: none;
  -webkit-user-drag: none;
}

@keyframes moon-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.intro-google {
  position: relative;
  width: min(100%, 480px);
  min-height: 54px;
  margin-top: clamp(6px, 2cqh, 20px);
  border: 0;
  border-radius: 14px;
  color: #5f6368;
  font-size: 19px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.intro-google .google-logo { position: absolute; left: 22px; top: 50%; transform: translateY(-50%); }

.intro-notice { width: min(100%, 480px); background: rgba(255, 255, 255, 0.9); }

.intro-foot {
  flex: 0 0 auto;
  padding: 14px 20px calc(env(safe-area-inset-bottom, 0px) + 16px);
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
}
.intro-foot p { margin: 2px 0; }
.intro-legal a { color: rgba(255, 255, 255, 0.82); }

/* 내리는 눈 */
.intro-snow {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.7;
  background-image:
    radial-gradient(2px 2px at 30px 40px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 120px 90px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 200px 160px, #fff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 80px 200px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 170px 20px, #fff 50%, transparent 51%);
  background-size: 240px 240px;
  animation: snow-fall 14s linear infinite;
}
@keyframes snow-fall {
  from { background-position: 0 0; }
  to { background-position: 40px 480px; }
}

/* 첫 화면에선 언어 선택을 가운데 위에 */
.app[data-screen='login'] .lang-floating {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}
.app[data-screen='login'] .lang-floating .lang-menu {
  right: auto;
  left: 50%;
  margin-left: -75px;
  transform-origin: top center;
}

@media (orientation: landscape) {
  .intro-moon { --moon: min(40cqw, 36cqh, 360px); }
}

@media (prefers-reduced-motion: reduce) {
  .intro-moon, .intro-snow { animation: none; }
  /* 마을 눈은 멈추지 않고 천천히만 (윈도우 '애니메이션 효과' 끔 등에서도 눈이 내리게) */
  .village-snow::before { animation-duration: 16s; }
  .village-snow::after { animation-duration: 22s; }
}

/* ---------- 마을 만들기 ---------- */
.landing {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.landing > .landing-card { margin: auto; flex-shrink: 0; }

.landing-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(100%, 420px);
  padding: 30px 26px;
  text-align: center;
}
.landing-title { margin: 0; font-size: 30px; font-weight: normal; color: #2a2a2e; }
.landing-desc { margin: 0 0 4px; font-size: 18px; line-height: 1.45; color: #4a4a50; }
.text-link { align-self: center; color: #4a4a50; font-size: 17px; text-decoration: underline; cursor: pointer; }

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 20px;
  border-radius: 16px;
  background: #fff;
  border: 2px solid #d6d6db;
  color: #1f1f22;
  font-size: 20px;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(20, 20, 60, 0.1);
  transition: background 0.15s ease, transform 0.12s ease;
}
.google-btn:hover { background: #f6f6f8; }
.google-btn:active { transform: scale(0.98); }
.google-btn.is-disabled { opacity: 0.5; }
.google-logo { width: 22px; height: 22px; flex: 0 0 auto; }


.notice {
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(168, 86, 86, 0.12);
  color: var(--btn-red);
  font-size: 16px;
  line-height: 1.4;
}

.landing-card .field { margin: 0; text-align: left; }
.field-caption {
  display: block;
  margin: 0 0 6px 6px;
  font-size: 17px;
  color: #4a4a50;
}

.title-preview {
  margin: 2px 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(160deg, #2c2f6e, #4a4f96);
  color: #fff;
  font-size: 22px;
  text-shadow: 0 2px 6px rgba(20, 20, 60, 0.45);
  word-break: keep-all;
}

/* ---------- 햄버거 버튼 ---------- */
.menu-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px;
  z-index: 8;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: #fff;
  transition: background 0.15s ease;
}
.menu-btn:hover { background: rgba(255, 255, 255, 0.15); }
.menu-btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* ---------- 왼쪽 슬라이드 메뉴 ---------- */
.drawer {
  --drawer-bg: #23262f;
  --drawer-text: #f1f2f6;
  --drawer-muted: #a9adbb;
  --drawer-line: rgba(255, 255, 255, 0.14);
  --drawer-accent: #6fd6c8;
  position: absolute;
  inset: 0;
  z-index: 40;
}

.drawer-dim {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 25, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.drawer.is-open .drawer-dim { opacity: 1; }

.drawer-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: min(80cqw, 300px);
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  overflow-y: auto;
  background: var(--drawer-bg);
  color: var(--drawer-text);
  box-shadow: 8px 0 30px rgba(0, 0, 0, 0.35);
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.9, 0.35, 1);
}
.drawer.is-open .drawer-panel { transform: none; }

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 20px;
}
.drawer-who { min-width: 0; }
.drawer-name {
  margin: 0;
  color: var(--drawer-accent);
  font-size: 26px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  color: #c9cde0;
  font-size: 15px;
  line-height: 1.35;
}
.g-mark {
  font-family: Arial, sans-serif;
  font-weight: 700;
  font-size: 14px;
  background: conic-gradient(from -45deg, #ea4335 0 25%, #4285f4 0 50%, #34a853 0 75%, #fbbc05 0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.drawer-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: -4px -6px 0 0;
  border-radius: 10px;
  color: #fff;
}
.drawer-close:hover { background: rgba(255, 255, 255, 0.1); }
.drawer-close svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }

.drawer-login {
  min-height: 46px;
  margin-bottom: 16px;
  border: 0;
  font-size: 18px;
  box-shadow: none;
}

.drawer-list { display: flex; flex-direction: column; gap: 2px; }

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -8px;
  width: calc(100% + 16px);
  padding: 10px 8px;
  border-radius: 10px;
  color: var(--drawer-text);
  font-size: 19px;
  text-align: left;
  transition: background 0.15s ease;
}
.drawer-item:hover,
.drawer-item:focus-visible { background: rgba(255, 255, 255, 0.07); outline: none; }
.drawer-item svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--drawer-muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drawer-sep {
  width: 100%;
  margin: 14px 0;
  border: 0;
  border-top: 1px solid var(--drawer-line);
}

.drawer-lang { justify-content: space-between; }
.drawer-lang-current {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--drawer-muted);
  font-size: 15px;
}

.drawer-langs { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.drawer-lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  border-radius: 10px;
  color: var(--drawer-text);
  font-size: 17px;
  text-align: left;
}
.drawer-lang-option:hover { background: rgba(255, 255, 255, 0.07); }
.drawer-lang-option[aria-pressed='true'] { color: var(--drawer-accent); background: rgba(111, 214, 200, 0.1); }

.drawer-foot {
  margin: auto 0 0;
  padding-top: 24px;
  color: var(--drawer-muted);
  font-size: 13px;
}
.drawer-foot p { margin: 0; }
/* 운영자 X(트위터) 바로가기 */
.drawer-sns {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-bottom: 10px;
  border-radius: 7px;
  background: #000;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
  transition: transform 0.15s ease;
}
.drawer-sns:hover { transform: scale(1.08); }
.drawer-sns svg { width: 17px; height: 17px; fill: currentColor; }

/* ---------- 삭제 확인 ---------- */
.confirm-view { z-index: 35; }
.confirm-card { width: min(100%, 380px); text-align: center; }
.confirm-card .write-title { margin-bottom: 10px; }
.confirm-desc {
  margin: 0;
  color: #4a4a50;
  font-size: 17px;
  line-height: 1.45;
  word-break: keep-all;
}

/* ---------- 가입 동의 ---------- */
.consent-view { z-index: 45; }
.consent-card { width: min(100%, 440px); }
.consent-card .write-title { margin-bottom: 8px; }
.consent-card .confirm-desc { text-align: center; margin-bottom: 14px; }

.consent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 4px;
  font-size: 17px;
  color: #2a2a2e;
}
.consent-row label,
label.consent-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
label.consent-row { justify-content: flex-start; }
.consent-row a { flex: 0 0 auto; color: #6b6b70; font-size: 15px; }

.consent-row input[type='checkbox'] {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--btn-red);
  cursor: pointer;
}

.consent-all {
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff;
  font-size: 19px;
}

.consent-list { margin-top: 8px; padding: 0 10px; }

.consent-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 0 0 6px 32px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  color: #4a4a50;
  font-size: 14px;
  line-height: 1.45;
}
.consent-summary dt { color: #6b6b70; white-space: nowrap; }
.consent-summary dd { margin: 0; }

.consent-refuse {
  margin: 0 0 6px 32px;
  color: #6b6b70;
  font-size: 13.5px;
  line-height: 1.45;
}

/* ---------- 약관 링크 ---------- */
.legal-links {
  margin: 4px 0 0;
  color: #8a8a90;
  font-size: 15px;
}
.legal-links a { color: #6b6b70; }

.send-notice {
  margin: 10px 4px 0;
  color: #6b6b70;
  font-size: 14px;
  line-height: 1.45;
}
.send-notice a { color: #6b6b70; }

.drawer-foot .drawer-legal { margin-bottom: 6px; }
.drawer-legal a { color: var(--drawer-muted); }

/* ---------- 계정 설정 ---------- */
.settings-card { display: flex; flex-direction: column; gap: 4px; }
.settings-card .write-title { margin-bottom: 10px; }
.settings-card .field-caption { margin-top: 8px; }
.settings-card .title-preview { margin-top: 12px; text-align: center; }
.settings-card .text-link { margin-top: 14px; }
.settings-card .danger-link { margin-top: 6px; color: var(--btn-red); font-size: 15px; }
.danger-link:disabled { opacity: 0.5; }
.settings-email {
  margin: 0;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  color: #4a4a50;
  font-size: 17px;
  overflow-wrap: anywhere;
}

/* ---------- 토스트 ---------- */
.toast {
  position: absolute;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 60px);
  z-index: 50;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 20px;
  text-align: center;
  border-radius: 20px;
  background: rgba(30, 30, 50, 0.85);
  color: #fff;
  font-size: 17px;
  line-height: 1.4;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; }
}

/* 계정 설정: 내 이름 · 마을 이름 한 줄 */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row .field { min-width: 0; }
.referral-code {
  margin: 8px 0 0 4px;
  font-size: 14px;
  color: #6b6b70;
}
.referral-code strong {
  font-weight: normal;
  letter-spacing: 0.08em;
  color: var(--ink);
  user-select: all;
}

/* 설정 창: 계정 + 항목 목록 */
.prefs-list {
  display: flex;
  flex-direction: column;
  margin: 14px 0 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.prefs-item {
  display: block;
  width: 100%;
  padding: 14px 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  color: #3a3a40;
  font-size: 17px;
  text-align: left;
  text-decoration: none;
}
.prefs-item:hover { background: rgba(255, 255, 255, 0.5); }
.prefs-item.danger-link { color: var(--btn-red); }
.prefs-card .write-actions .ghost-btn { flex: 1; }
.prefs-card .prefs-item.danger-link { margin-top: 0; font-size: 17px; }

/* ---------- 마을 테두리 (마을 꾸미기에서 켜고 끔) ----------
   그림은 tools/make_frame.py 가 public/frame/ 에 만든다.
   가랜드는 한 조각을 이어 붙이고(화면 비율이 달라도 늘어나지 않음), 모서리·스티커는 크기 고정.
   --fw: 가랜드 굵기. 글씨·버튼보다 아래(z-index 4), 누르기는 통과 */
.village-frame {
  --fw: clamp(30px, 9.5cqmin, 58px);
  --line: calc(var(--fw) * 0.22); /* 화면 끝에서 가랜드 가운데까지 (벽에 붙임) */
  --sline: calc(var(--fw) * 0.4); /* 스티커 가운데 (화면 밖으로 잘리지 않게 조금 안쪽) */
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}
.frame-edge, .frame-corner, .frame-lights, .frame-sticker { position: absolute; }
.frame-edge.is-top,
.frame-edge.is-bottom {
  left: 0;
  right: 0;
  height: var(--fw);
  background: url('/frame/pine-h.svg') 0 0 / auto 100% repeat-x;
}
.frame-edge.is-top { top: calc(var(--line) - var(--fw) / 2); }
.frame-edge.is-bottom { bottom: calc(var(--line) - var(--fw) / 2); transform: scaleY(-1); background-position-x: 37%; }
.frame-edge.is-left,
.frame-edge.is-right {
  top: 0;
  bottom: 0;
  width: var(--fw);
  background: url('/frame/pine-v.svg') 0 0 / 100% auto repeat-y;
}
.frame-edge.is-left { left: calc(var(--line) - var(--fw) / 2); }
.frame-edge.is-right { right: calc(var(--line) - var(--fw) / 2); transform: scaleX(-1); background-position-y: 61%; }
.frame-corner {
  width: calc(var(--fw) * 2.6);
  height: calc(var(--fw) * 2.6);
  background: url('/frame/corner.svg') 0 0 / contain no-repeat;
}
.frame-corner.is-tl { left: calc(var(--fw) * -0.38); top: calc(var(--fw) * -0.38); }
.frame-corner.is-tr { right: calc(var(--fw) * -0.38); top: calc(var(--fw) * -0.38); transform: scaleX(-1); }
.frame-corner.is-bl { left: calc(var(--fw) * -0.38); bottom: calc(var(--fw) * -0.38); transform: scaleY(-1); }
.frame-corner.is-br { right: calc(var(--fw) * -0.38); bottom: calc(var(--fw) * -0.38); transform: scale(-1); }

/* 가랜드에 감긴 작은 전구: 두 겹이 번갈아 반짝인다 */
.frame-lights {
  --dot: radial-gradient(circle, #fffbe0 0 1.6px, rgba(255, 214, 110, 0.9) 2.6px, rgba(255, 190, 80, 0) 7px);
  --gap: calc(var(--fw) * 1.35);
  inset: 0;
  background:
    var(--dot) 0 calc(var(--line) - 7px) / var(--gap) 14px repeat-x,
    var(--dot) calc(var(--gap) / 2) calc(100% + 7px - var(--line)) / var(--gap) 14px repeat-x,
    var(--dot) calc(var(--line) - 7px) calc(var(--gap) / 3) / 14px var(--gap) repeat-y,
    var(--dot) calc(100% + 7px - var(--line)) calc(var(--gap) * 0.8) / 14px var(--gap) repeat-y;
  animation: frame-twinkle 2.6s ease-in-out infinite;
}
.frame-lights.is-alt {
  background-position:
    calc(var(--gap) / 2) calc(var(--line) - 7px),
    0 calc(100% + 7px - var(--line)),
    calc(var(--line) - 7px) calc(var(--gap) * 0.83),
    calc(100% + 7px - var(--line)) calc(var(--gap) * 0.3);
  animation-delay: -1.3s;
}
@keyframes frame-twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

/* 스티커: 가랜드 가운데 선 위에 붙인다 (위치는 app.js 의 FRAME_STICKERS) */
.frame-sticker {
  width: calc(var(--fw) * 0.95);
  height: calc(var(--fw) * 0.95);
  background: center / contain no-repeat;
  filter: drop-shadow(0 1px 2px rgba(30, 20, 10, 0.35));
  transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
}
.frame-sticker.is-left { left: var(--sline); top: var(--pos); }
.frame-sticker.is-right { left: calc(100% - var(--sline)); top: var(--pos); }
.frame-sticker.is-top { top: var(--sline); left: var(--pos); }
.frame-sticker.is-bottom { top: calc(100% - var(--sline)); left: var(--pos); }
.frame-sticker.is-ginger { background-image: url('/frame/ginger.svg'); }
.frame-sticker.is-candy { background-image: url('/frame/candy.svg'); }
.frame-sticker.is-gift { background-image: url('/frame/gift.svg'); }
.frame-sticker.is-snowflake { background-image: url('/frame/snowflake.svg'); }
.frame-sticker.is-cone { background-image: url('/frame/cone.svg'); }

@media (prefers-reduced-motion: reduce) {
  .frame-lights { animation: none; }
}

/* 마을 꾸미기: 테두리 고르기 (말풍선 테마 칸과 같은 정사각형) */
.frame-swatch {
  position: relative;
  width: 70%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #cfd6ef url('/bg/크리스마스때먹으면안되는음식은울면곱뺴기.png') center top / cover;
  pointer-events: none;
}
.frame-swatch .village-frame { --fw: 9px; }
.frame-swatch .frame-sticker, .frame-swatch .frame-lights { display: none; }
.frame-swatch.is-none::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top right, transparent calc(50% - 1px), rgba(200, 50, 60, 0.7) 50%, transparent calc(50% + 1px));
}
