:root {
  --cream: #fffaee;
  --cream-2: #f6eedb;
  --ink: #5b4636;
  --ink-soft: #8a7462;
  --leaf: #7fbf5a;
  --leaf-deep: #4f9a3a;
  --line: #e7dbc0;
  --shadow: 0 4px 0 #e0d1b0, 0 8px 20px rgba(60, 40, 20, 0.15);
  --kakao: #fee500;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe3ef; font-family: "Gowun Dodum", -apple-system, "Apple SD Gothic Neo", sans-serif; color: var(--ink); -webkit-tap-highlight-color: transparent; }
canvas#scene { display: block; width: 100vw; height: 100vh; touch-action: none; }
h1, h2, b, button, .jua { font-family: "Jua", "Gowun Dodum", sans-serif; font-weight: 400; }
p { margin: 0; }

.card { background: var(--cream); border: 2px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.hud { position: fixed; left: 16px; top: 16px; display: flex; flex-direction: column; gap: 12px; width: min(320px, calc(100vw - 32px)); pointer-events: none; }
.hud .card { pointer-events: auto; padding: 12px 16px; }
.title h1 { margin: 0; font-size: 22px; color: var(--leaf-deep); letter-spacing: -0.01em; }
.title p { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.mine { cursor: pointer; }
.mine-top { display: flex; align-items: center; gap: 8px; font-size: 18px; }
.mine-icon { font-size: 20px; }
.grown { margin-left: auto; font-family: "Jua"; font-size: 14px; color: var(--ink-soft); }
#milestone { font-size: 13.5px; margin-top: 4px; }
.bar { height: 10px; border-radius: 6px; background: var(--cream-2); margin-top: 8px; overflow: hidden; border: 1.5px solid var(--line); }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #9bd36e, var(--leaf)); border-radius: 6px; transition: width 1s linear; }
.next { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }

.fab { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.round { width: 54px; height: 54px; border-radius: 50%; border: 2px solid var(--line); background: var(--cream); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; color: var(--ink); transition: transform 0.15s; padding: 0; }
.round:hover { transform: translateY(-2px); }
.round:active { transform: translateY(2px); box-shadow: 0 1px 0 #e0d1b0; }
.round svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.round svg .fill { fill: currentColor; stroke: none; }
.round.active { background: #e7f5d6; border-color: #bfe0a0; color: var(--leaf-deep); }
#btnSound .wave { display: none; }
#btnSound[aria-pressed="true"] .wave { display: inline; }
#btnSound[aria-pressed="true"] .mute { display: none; }

#labels { position: fixed; inset: 0; pointer-events: none; }
.tag { pointer-events: auto; cursor: pointer; position: absolute; transform: translate(-50%, -100%); background: var(--cream); color: var(--ink); border: 2px solid var(--line); border-radius: 12px; padding: 3px 10px; font-family: "Jua"; font-size: 13px; white-space: nowrap; box-shadow: 0 2px 0 #e0d1b0; animation: bob 2.4s ease-in-out infinite; }
.tag::after { content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--cream); border-bottom: 0; }
@keyframes bob { 50% { margin-top: -4px; } }

.bubble { position: fixed; transform: translate(-50%, calc(-100% - 10px)); background: var(--cream); border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; font-size: 13px; box-shadow: var(--shadow); pointer-events: none; opacity: 0; transition: opacity 0.25s; white-space: nowrap; }
.bubble.show { opacity: 1; pointer-events: auto; cursor: pointer; }
.bubble .hint { font-size: 11px; color: #9a8f78; }
.toast { position: fixed; left: 50%; top: 20px; transform: translate(-50%, -12px); background: var(--cream); border: 2px solid var(--line); border-radius: 999px; padding: 10px 18px; font-family: "Jua"; font-size: 15px; box-shadow: var(--shadow); opacity: 0; transition: opacity 0.4s, transform 0.4s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 마이페이지 시트 */
.sheet { position: fixed; top: 16px; right: 84px; max-height: calc(100vh - 32px); width: min(360px, calc(100vw - 32px)); background: var(--cream); border: 2px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); padding: 18px; overflow-y: auto; overflow-x: hidden; transform: translateX(calc(100% + 120px)); transition: transform 0.35s cubic-bezier(.2,.9,.3,1.1); }
.sheet.open { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 21px; color: var(--leaf-deep); }
.close { border: 0; background: var(--cream-2); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; color: var(--ink); font-size: 15px; }
@media (max-width: 600px) {
  .hud { width: calc(100vw - 100px); gap: 8px; }
  .hud .card { padding: 10px 12px; }
  .title h1 { font-size: 18px; }
  .title p, #milestone { font-size: 12px; }
  .next { display: none; }
  .round { width: 48px; height: 48px; }
  .sheet { top: auto; right: 0; left: 0; bottom: 0; width: 100%; max-height: 86vh; border-radius: 26px 26px 0 0; transform: translateY(105%); }
  .sheet.open { transform: none; }
}

.weather { font-size: 13px; color: var(--ink); margin-top: 4px; }
.who { font-size: 13px; color: var(--ink-soft); margin: 4px 0 2px; cursor: pointer; }
.who b { color: var(--ink); font-size: 14px; }
.who u { text-decoration-color: var(--leaf); text-underline-offset: 3px; }
.tag.other { font-size: 11.5px; padding: 2px 8px; border-radius: 10px; opacity: 0.92; animation: none; background: rgba(255, 250, 238, 0.9); }
.tag.other::after { border-top-color: rgba(255, 250, 238, 0.9); }
.bubble { white-space: normal; line-height: 1.55; max-width: 260px; }

/* 마이페이지 */
.sheet-head { margin-bottom: 6px; }
.me { padding: 6px 2px 18px; border-bottom: 1.5px dashed var(--line); }
.me-name { display: flex; align-items: center; gap: 8px; }
.me-name b { font-size: 22px; color: var(--ink); line-height: 1.25; word-break: keep-all; }
.me-meta { margin-top: 4px; font-size: 13px; color: var(--ink-soft); }
.icon-btn { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--cream-2); color: var(--ink); display: grid; place-items: center; cursor: pointer; font-family: "Jua"; font-size: 18px; padding: 0; }
.icon-btn:hover { background: #efe4cb; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.icon-btn svg .dot { fill: currentColor; stroke: none; }

.login { padding: 20px 0; text-align: center; border-bottom: 1.5px dashed var(--line); }
.login p { margin-top: 8px; font-size: 12.5px; color: var(--ink-soft); }
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px; border-radius: 12px; border: 0; cursor: pointer; font-size: 16px; text-decoration: none; }
.btn-kakao { background: var(--kakao); color: rgba(0, 0, 0, 0.85); }
.btn-kakao:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-kakao svg { width: 20px; height: 20px; }

.log { padding: 16px 0; border-bottom: 1.5px dashed var(--line); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head b { font-size: 17px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal i { font-style: normal; }
.cal .dow { text-align: center; font-size: 11px; color: var(--ink-soft); padding-bottom: 2px; }
.day { aspect-ratio: 1; border: 0; border-radius: 10px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font: 12px "Gowun Dodum", sans-serif; color: #c2b39d; padding: 0; }
.day em { font-style: normal; font-size: 16px; line-height: 1; }
.day.has { background: #fff; color: var(--ink); cursor: pointer; box-shadow: inset 0 0 0 1.5px var(--line); }
.day.today span { color: var(--leaf-deep); font-weight: 700; }
.day.sel { background: #e7f5d6; box-shadow: inset 0 0 0 2px var(--leaf); }
.day-detail { margin-top: 10px; font-size: 13.5px; text-align: center; min-height: 20px; }

.settings { padding-top: 6px; }
.row { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 14px 2px; font-size: 14.5px; color: var(--ink); }
.row + .row { border-top: 1px solid var(--line); }
.plain { border: 0; background: none; cursor: pointer; font: inherit; color: var(--ink-soft); text-align: left; }
.switch { width: 44px; height: 26px; appearance: none; background: var(--cream-2); border: 2px solid var(--line); border-radius: 999px; position: relative; cursor: pointer; flex: none; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .2s; }
.switch:checked { background: var(--leaf); border-color: var(--leaf); }
.switch:checked::after { transform: translateX(18px); }

/* 이름 바꾸기 팝업 */
.edit-btn { flex: none; border: 0; background: var(--cream-2); color: var(--ink-soft); border-radius: 8px; padding: 5px 10px; font: 13px "Jua", sans-serif; cursor: pointer; }
.edit-btn:hover { color: var(--ink); background: #efe4cb; }
.modal { position: fixed; inset: 0; background: rgba(40, 30, 20, 0.35); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal[hidden] { display: none; }
.modal-card { width: min(340px, 100%); background: var(--cream); border: 2px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 20px; }
.modal-card h3 { margin: 0 0 14px; font-size: 18px; text-align: center; color: var(--ink); }
.name-pick { display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 8px 8px 8px 14px; }
.name-pick span { flex: 1; min-width: 0; font-size: 19px; }
.name-pick span.pop { animation: pop .3s ease; }
@keyframes pop { 0% { transform: scale(.92); opacity: .4; } 100% { transform: none; opacity: 1; } }
.dice { flex: none; width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--leaf); color: #fff; display: grid; place-items: center; cursor: pointer; transition: transform .15s; }
.dice:active { transform: rotate(-20deg) scale(.94); }
.dice svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.dice svg .dot { fill: currentColor; stroke: none; }
.modal-msg { min-height: 18px; margin: 8px 2px 4px; font-size: 12.5px; color: #c8553d; text-align: center; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal-actions button { height: 44px; border-radius: 12px; border: 0; font-size: 15px; cursor: pointer; }
.btn-cancel { background: var(--cream-2); color: var(--ink); }
.btn-save { background: var(--leaf); color: #fff; }
.btn-save:disabled { opacity: 0.4; cursor: default; }

.tag:hover { border-color: var(--leaf); }

/* 촬영용 (?clean=1) */
body.clean .hud, body.clean .fab, body.clean #labels, body.clean .toast, body.clean .bubble { display: none !important; }
