@font-face {
  font-family: 'Pretendard';
  src: url('https://cdn.jsdelivr.net/npm/pretendard@1.3.9/dist/web/variable/woff2/PretendardVariable.woff2') format('woff2-variations'),
       url('https://cdn.jsdelivr.net/npm/pretendard@1.3.9/dist/web/variable/woff2/PretendardVariable.woff2') format('woff2');
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #2f2925;
  --ink-2: #6f655d;
  --ink-3: #a1968c;
  --line: #ece4da;
  --bg: #faf7f2;
  --card: #ffffff;
  --accent: #ff7d95;
  --accent-d: #ef6680;
  --accent-soft: #fff0f3;
  --green: #5fb85a;
  --green-soft: #ecf8e8;
  --yellow-soft: #fff6d6;
  --glass: rgba(255, 255, 255, 0.82);
  --shadow-s: 0 1px 2px rgba(40, 25, 10, 0.06), 0 2px 8px rgba(40, 25, 10, 0.06);
  --shadow: 0 8px 28px rgba(40, 25, 10, 0.14);
  --r: 16px;
  --gap: clamp(10px, 2vmin, 16px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: clamp(13px, 0.35vw + 11.5px, 16px); -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  color: var(--ink);
  line-height: 1.5;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, #bfe7ff 0%, #e4f6ff 50%, #fff3dc 100%);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  transition: background 0.8s;
}
/* 하늘색: 날씨 */
body[data-sky='cloudy-day'] { background: linear-gradient(180deg, #cdd8e2, #e8eef3 55%, #f3efe7); }
body[data-sky='rain-day'], body[data-sky='storm-day'] { background: linear-gradient(180deg, #8e9db0, #b9c5d2 55%, #dad8d2); }
body[data-sky='snow-day'] { background: linear-gradient(180deg, #dfe8f2, #f2f6fa 55%, #ffffff); }
body[data-sky='fog-day'] { background: linear-gradient(180deg, #dfe4e8, #eef1f3 60%, #f5f3ef); }
body[data-sky$='-dawn'] { background: linear-gradient(180deg, #8fa6d8, #f3c1c6 55%, #ffe3c4); }
body[data-sky$='-sunset'] { background: linear-gradient(180deg, #6f7fc4, #f29d8f 55%, #ffd29a); }
body[data-sky$='-night'] { background: linear-gradient(180deg, #141b3d, #2a3463 55%, #46426e); }
body[data-scene='cabin'] { background: radial-gradient(circle at 50% 40%, #5d4332, #2e2119); }
body[data-scene='gallery'] { background: radial-gradient(circle at 50% 40%, #5b606c, #2e313a); }
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.3; }

#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* ───── 버튼 ───── */
button { cursor: pointer; color: inherit; font: inherit; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45em;
  border: 1px solid var(--line); border-radius: 12px; padding: 0.62em 1.1em; background: #fff; color: var(--ink);
  font-weight: 600; font-size: 0.95rem; line-height: 1.2; white-space: nowrap;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s, opacity 0.15s;
}
.btn:hover { background: #faf7f3; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-d); }
.btn.green { background: var(--green-soft); border-color: transparent; color: #3c8a37; }
.btn.ghost { background: transparent; }
.btn.danger { background: #fff0ee; border-color: transparent; color: #d4483b; }
.btn.block { width: 100%; padding: 0.8em 1em; font-size: 1rem; }
.btn.sm { padding: 0.45em 0.8em; font-size: 0.85rem; border-radius: 10px; }
.btn.on { background: #fff6d6; border-color: #f4d77a; }

/* ───── 전체 화면 ───── */
.screen {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  padding: calc(var(--gap) + var(--safe-t)) var(--gap) calc(var(--gap) + var(--safe-b)); z-index: 20;
}
.screen.show { display: flex; }
#loading { background: linear-gradient(180deg, #bfe7ff, #fff3dc); z-index: 50; }
.loader { text-align: center; font-weight: 600; color: var(--ink-2); }
.loader span { display: inline-block; font-size: 3rem; animation: hop 0.8s ease-in-out infinite; }
@keyframes hop { 50% { transform: translateY(-12px) rotate(-6deg); } }
.muted { color: var(--ink-2); font-size: 0.88rem; margin: 0.2em 0 0.9em; }

/* ───── 로그인 페이지 ───── */
.auth { background: linear-gradient(135deg, #fff4ea 0%, #ffeef2 45%, #e9f5ff 100%); overflow: auto; align-items: safe center; }
.auth-shell {
  width: min(960px, 100%); display: grid; grid-template-columns: 1.1fr 1fr; background: var(--card);
  border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; margin: auto;
}
.auth-hero {
  padding: clamp(24px, 5vmin, 48px); background: linear-gradient(160deg, #ffe3ea, #fff1d9 60%, #e3f3ff);
  display: flex; flex-direction: column; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; color: #7b4a2a; }
.brand span { font-size: 1.4rem; }
.auth-hero h1 { margin: 4px 0 0; font-size: clamp(1.6rem, 4.2vmin, 2.3rem); font-weight: 800; color: #3a2a20; }
.features { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 8px; font-size: 0.93rem; color: #5b4a3e; }
.features li { display: flex; align-items: center; gap: 10px; }
.features span { width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, 0.75); display: grid; place-items: center; flex: none; }
.hero-animals { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 10px; }
.hero-animals img { width: clamp(46px, 7vmin, 64px); aspect-ratio: 1; border-radius: 14px; background: rgba(255, 255, 255, 0.7); }
.auth-panel { padding: clamp(24px, 5vmin, 44px); display: flex; flex-direction: column; justify-content: center; }
.auth-panel h2 { margin: 0; font-size: 1.45rem; font-weight: 800; }
.hint { font-size: 0.78rem; color: var(--ink-3); margin: 6px 0 0; text-align: center; }
.tabs { display: flex; background: #f4efe9; border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.tab { flex: 1; border: none; background: transparent; padding: 0.5em; border-radius: 10px; font-size: 0.92rem; font-weight: 600; color: var(--ink-2); }
.tab.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-s); }
.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-2); margin: 0 0 4px 2px; }
input, textarea {
  width: 100%; font: inherit; font-size: 0.95rem; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 11px; padding: 0.65em 0.85em; outline: none; transition: border 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 125, 149, 0.15); }
.err { color: #d4483b; min-height: 1.2em; margin: 2px 0 10px; font-size: 0.85rem; }
.demo-note { font-size: 0.8rem; color: #8a6d1f; margin: 14px 0 0; background: var(--yellow-soft); padding: 0.6em 0.8em; border-radius: 10px; text-align: center; }
@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { gap: 10px; }
  .features { display: none; }
  .hero-animals { margin-top: 4px; }
}

/* ───── 동물 고르기 ───── */
#select { background: rgba(250, 247, 242, 0.97); align-items: stretch; }
.select-wrap { width: min(1080px, 100%); display: flex; flex-direction: column; min-height: 0; margin: 0 auto; }
.select-wrap header { text-align: center; }
.select-wrap h2 { margin: 0.2em 0 0; font-size: clamp(1.25rem, 3.6vmin, 1.7rem); font-weight: 800; }
.nick-inline { max-width: 320px; margin: 0 auto 10px; text-align: left; }
.animal-grid {
  flex: 1; min-height: 0; overflow: auto; display: grid; gap: 10px; padding: 4px 2px 12px;
  grid-template-columns: repeat(auto-fill, minmax(clamp(110px, 18vmin, 150px), 1fr)); align-content: start;
}
.animal {
  border: 1.5px solid var(--line); background: #fff; border-radius: 16px; padding: 6px 6px 10px; text-align: center;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.animal:hover { transform: translateY(-2px); box-shadow: var(--shadow-s); }
.animal.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(255, 125, 149, 0.15); }
.animal img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; }
.animal span { display: block; font-size: 0.82rem; font-weight: 600; line-height: 1.3; word-break: keep-all; }
.select-wrap footer { display: flex; gap: 8px; justify-content: center; padding-top: 8px; }
.select-wrap footer .btn { min-width: 160px; padding: 0.75em 1.2em; }

/* ───── HUD ───── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button { pointer-events: auto; }
.glass { background: var(--glass); backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4); border: 1px solid rgba(255, 255, 255, 0.7); box-shadow: var(--shadow-s); }
.hud-top {
  position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px; padding: calc(var(--gap) + var(--safe-t)) var(--gap) 0;
}
.profile { display: flex; align-items: center; gap: 8px; border-radius: 999px; padding: 4px 14px 4px 4px; min-width: 0; max-width: 46vw; text-align: left; }
.profile img { width: 38px; height: 38px; border-radius: 50%; background: #fff; flex: none; }
.profile .pt { min-width: 0; display: block; }
.profile b { display: block; font-size: 0.92rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile small { display: block; color: var(--ink-2); font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.weather { display: flex; align-items: center; gap: 6px; border-radius: 999px; padding: 0 14px 0 10px; height: 46px; }
.weather > span:first-child { font-size: 1.15rem; }
.weather .wt { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.weather #w-time { color: var(--ink); font-weight: 600; }
.weather b { font-size: 0.95rem; font-weight: 700; }
.weather small { font-size: 0.75rem; color: var(--ink-2); }
.group { display: flex; border-radius: 999px; padding: 3px; gap: 2px; }
.ib { width: 38px; height: 38px; border-radius: 50%; border: none; background: transparent; font-size: 1.05rem; display: grid; place-items: center; color: var(--ink); }
.ib:hover { background: rgba(0, 0, 0, 0.05); }
.hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end;
  gap: 8px; padding: 0 var(--gap) calc(var(--gap) + var(--safe-b));
}
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 999px; padding: 0.35em 0.75em; font-size: 0.78rem; font-weight: 600; box-shadow: var(--shadow-s); white-space: nowrap; color: var(--ink);
}
.chip.done { background: rgba(236, 248, 232, 0.92); color: #3c8a37; }
.chip.todo { background: rgba(255, 246, 214, 0.94); color: #8a6d1f; }
.room-btns { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.room-btns .btn { box-shadow: var(--shadow-s); }
@media (max-width: 600px) {
  .weather #w-text { display: none; }
  .weather { padding: 0 12px 0 9px; height: 40px; }
  .ib { width: 34px; height: 34px; }
  .profile img { width: 32px; height: 32px; }
  .hud-bottom { flex-direction: column-reverse; align-items: stretch; }
  .room-btns { margin-left: 0; }
}

.tip {
  position: fixed; z-index: 15; pointer-events: none; background: rgba(32, 26, 22, 0.88); color: #fff; font-weight: 600;
  padding: 0.3em 0.65em; border-radius: 8px; font-size: 0.78rem; transform: translate(-50%, -150%); white-space: nowrap;
}
/* 알림: 작고 가볍게 */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 70px); transform: translate(-50%, -6px); z-index: 40;
  background: rgba(32, 26, 22, 0.86); color: #fff; padding: 0.5em 0.95em; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; opacity: 0; transition: opacity 0.2s, transform 0.2s;
  pointer-events: none; max-width: min(88vw, 420px); text-align: center; word-break: keep-all; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sleep {
  position: fixed; inset: 0; z-index: 12; background: rgba(18, 22, 52, 0.42); display: grid; place-items: end center;
  padding-bottom: calc(12vh + var(--safe-b)); color: #fff; font-weight: 700; font-size: 1.05rem; text-align: center; pointer-events: none;
}
.sleep small { display: block; font-weight: 500; font-size: 0.82rem; opacity: 0.85; }
.fade { position: fixed; inset: 0; background: #faf7f2; opacity: 0; pointer-events: none; z-index: 45; transition: opacity 0.3s; }
.fade.on { opacity: 1; pointer-events: auto; }

/* ───── 아래 메뉴 ───── */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgba(30, 20, 10, 0.18); }
.sheet-card {
  width: min(400px, 100%); background: var(--card); border-radius: 18px 18px 0 0; padding: 16px var(--gap) calc(16px + var(--safe-b));
  box-shadow: var(--shadow); animation: up 0.2s ease-out;
}
@media (min-width: 600px) { .sheet { align-items: center; } .sheet-card { border-radius: 18px; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.sheet-card h3 { margin: 0 0 10px; text-align: center; font-size: 1rem; font-weight: 700; }
.sheet-btns { display: grid; gap: 6px; }
.sheet-btns.grid { grid-template-columns: repeat(4, 1fr); }
.sheet-btns .btn { width: 100%; }
.seed-btn { flex-direction: column; gap: 2px; padding: 0.6em 0.3em; font-size: 0.8rem; }
.seed-btn em { font-style: normal; font-size: 1.5rem; line-height: 1.1; }
.sheet-btns .close { grid-column: 1 / -1; }

/* ───── 창 ───── */
.modal { position: fixed; inset: 0; z-index: 35; background: rgba(30, 20, 10, 0.28); display: grid; place-items: center; padding: calc(var(--gap) + var(--safe-t)) var(--gap) calc(var(--gap) + var(--safe-b)); }
.modal-card {
  position: relative; width: min(440px, 100%); max-height: 100%; overflow: auto; background: var(--card); border-radius: 18px;
  box-shadow: var(--shadow); padding: clamp(16px, 3.5vmin, 22px); animation: pop 0.18s ease-out;
}
.modal-card.wide { width: min(620px, 100%); }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } }
.modal-card h2 { margin: 0 0 2px; font-size: 1.12rem; font-weight: 800; padding-right: 2.2em; }
.modal-card h3 { margin: 14px 0 6px; font-size: 0.88rem; font-weight: 700; color: var(--ink-2); }
.modal-card .x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: none; background: #f4efe9; font-size: 0.85rem; color: var(--ink-2); }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.row.between { justify-content: space-between; }
textarea { min-height: 8em; resize: vertical; line-height: 1.65; }
.past { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; max-height: 36vh; overflow: auto; }
.past li { background: var(--bg); border-radius: 10px; padding: 0.55em 0.75em; white-space: pre-wrap; word-break: break-word; font-size: 0.88rem; }
.past li b { display: block; font-size: 0.75rem; color: var(--ink-3); font-weight: 600; margin-bottom: 2px; }
details summary { cursor: pointer; font-size: 0.85rem; font-weight: 600; margin-top: 12px; color: var(--ink-2); }
.stat-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.stat-row .chip { box-shadow: none; background: var(--bg); backdrop-filter: none; }

.swatches { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.sw { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); padding: 0; }
.sw.on { box-shadow: 0 0 0 2.5px var(--accent); }
.swatches input[type='color'] { width: 40px; height: 34px; padding: 2px; border-radius: 9px; }

/* 날씨 창 */
.wx { display: flex; align-items: center; gap: 14px; background: var(--bg); border-radius: 14px; padding: 12px 14px; margin-top: 6px; }
.wx .big { font-size: 2.4rem; line-height: 1; }
.wx b { font-size: 1.6rem; font-weight: 800; }
.wx-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.wx-grid div { background: var(--bg); border-radius: 10px; padding: 8px; text-align: center; font-size: 0.75rem; color: var(--ink-2); }
.wx-now { margin-top: 10px; background: #fff6ea; border-radius: 12px; padding: 9px 12px; font-size: 0.82rem; color: var(--ink-2); line-height: 1.5; }
.wx-now b { color: var(--ink); }
.wx-grid b { display: block; font-size: 0.95rem; color: var(--ink); }
.pills { display: flex; flex-wrap: wrap; gap: 5px; }

/* 그림 그리기 */
.draw-wrap { display: grid; gap: 8px; margin-top: 8px; }
.draw-canvas { width: 100%; aspect-ratio: 4 / 3; background: #fff; border-radius: 12px; border: 1px solid var(--line); touch-action: none; display: block; cursor: crosshair; }
.tools { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.tools .sw { width: 26px; height: 26px; }
.tools .size { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 0 0.6em; height: 30px; font-size: 0.8rem; font-weight: 600; }
.tools .size.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 480px) { .two { grid-template-columns: 1fr; } }

.art-view img { width: 100%; border-radius: 10px; border: 6px solid #e8c063; background: #fff; display: block; margin-top: 8px; }
.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-top: 8px; }
.art-grid button { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 5px; text-align: left; }
.art-grid img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; background: #fff; }
.art-grid span { display: block; font-size: 0.82rem; font-weight: 700; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art-grid small { font-size: 0.72rem; color: var(--ink-3); }

.friends { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.friends li { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: 12px; padding: 7px 9px; }
.friends img { width: 44px; height: 44px; border-radius: 50%; background: #fff; flex: none; }
.friends .f-info { flex: 1; min-width: 0; }
.friends .f-info b { display: block; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friends .f-info small { color: var(--ink-3); font-size: 0.75rem; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #34c759; margin-right: 5px; vertical-align: middle; }
.empty { text-align: center; padding: 1.2em 0.5em; color: var(--ink-3); font-size: 0.88rem; }

@media (max-height: 520px) {
  .auth-hero { display: none; }
  .auth-shell { grid-template-columns: 1fr; width: min(420px, 100%); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
