:root {
  --ink: #2a2520;
  --ink2: #6b6152;
  --paper: #f6f0e3;
  --paper2: #ece3d1;
  --indigo: #1f3a5f;
  --indigo2: #2c4f7c;
  --red: #a8432e;
  --gold: #c98a3f;
  --sans: "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", system-ui, sans-serif;
  --serif: "Nanum Myeongjo", "Noto Serif KR", "Noto Serif CJK KR", "AppleMyungjo", "Batang", serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1f2f4d; }
body { font-family: var(--sans); color: var(--ink); font-size: 18px; line-height: 1.45; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button { font-family: inherit; }
[hidden] { display: none !important; }

#view { position: fixed; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; display: block; touch-action: none; }
body.no3d #view { display: none; }
body.no3d { background: linear-gradient(#7fa9d6, #dfe6e0 55%, #b9a77a 55%, #9c8d62); }

#labels { position: fixed; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; font-size: 15px; font-weight: 700; color: #fff; padding: 4px 11px; border-radius: 999px; background: rgba(22, 26, 36, 0.55); box-shadow: 0 2px 8px rgba(0,0,0,.18); will-change: transform; }
.lbl.mine { background: var(--red); font-size: 16px; }
.lbl.mine::after { content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--red); border-bottom: 0; }
.lbl small { font-weight: 500; opacity: .9; }

/* 위쪽 정보 */
#hud { position: fixed; left: 0; right: 0; top: 0; padding: calc(10px + var(--safe-t)) 14px 0; display: flex; align-items: flex-start; gap: 10px; pointer-events: none; }
#hud .brand { display: flex; flex-direction: column; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.45); }
#hud .brand strong { font-family: var(--serif); font-size: 23px; letter-spacing: .02em; line-height: 1.15; }
#hud .brand span { font-size: 14px; opacity: .95; }
#hud .counter { margin-left: auto; text-align: right; background: rgba(20, 26, 40, 0.55); color: #fff; border-radius: 14px; padding: 6px 12px 7px; display: flex; flex-direction: column; line-height: 1.2; }
#hud .counter .big { font-size: 15px; }
#hud .counter .big b { font-size: 22px; font-variant-numeric: tabular-nums; }
#hud .counter .small { font-size: 13px; opacity: .9; }
#hud .icon { pointer-events: auto; width: 46px; height: 46px; border-radius: 14px; border: 0; background: rgba(20, 26, 40, 0.55); color: #fff; display: grid; place-items: center; }
#hud .icons { position: relative; display: flex; flex-direction: column; gap: 8px; }
#hud .icon .mute { display: none; }
body.muted #soundBtn .mute { display: block; }
body.muted #soundBtn .wave { display: none; }
#musicBtn .off { opacity: .85; }
#musicBtn.on { background: rgba(201, 138, 63, 0.92); }
#musicBtn.on .off { display: none; }
#hud .tip { pointer-events: auto; position: absolute; right: 56px; top: 58px; white-space: nowrap; background: rgba(246, 240, 227, 0.97); color: var(--ink); font-size: 16px; font-weight: 700; padding: 9px 13px; border-radius: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.22); animation: tipIn .35s ease-out; }
#hud .tip::after { content: ""; position: absolute; right: -7px; top: 50%; transform: translateY(-50%); border: 7px solid transparent; border-left-color: rgba(246, 240, 227, 0.97); border-right: 0; }
@keyframes tipIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }

/* 산고양이 쓰다듬기 */
.pet { position: absolute; left: 0; top: 0; pointer-events: auto; border: 0; border-radius: 999px; padding: 10px 16px; font-size: 16px; font-weight: 800; color: var(--ink); background: rgba(246, 240, 227, 0.95); box-shadow: 0 3px 10px rgba(0,0,0,.25); will-change: transform; }
.pet::after { content: ""; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); border: 6px solid transparent; border-top-color: rgba(246, 240, 227, 0.95); border-bottom: 0; }
.heart { position: fixed; color: #e0605a; font-style: normal; font-size: 24px; pointer-events: none; transform: translate(-50%, 0); animation: heartUp 1.4s ease-out forwards; opacity: 0; text-shadow: 0 1px 4px rgba(0,0,0,.2); }
@keyframes heartUp { 0% { opacity: 0; transform: translate(-50%, 0) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -14px) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -70px) scale(1); } }

/* 첫 화면 */
#intro { position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; justify-content: space-between; padding: calc(56px + var(--safe-t)) 20px calc(22px + var(--safe-b)); color: #fff; background: linear-gradient(rgba(12,20,38,.62), rgba(12,20,38,0) 32%, rgba(12,20,38,0) 46%, rgba(12,20,38,.82)); transition: opacity .5s; }
#intro.out { opacity: 0; pointer-events: none; }
#intro h1 { font-family: var(--serif); font-size: 58px; margin: 0; text-align: center; letter-spacing: .06em; text-shadow: 0 3px 18px rgba(0,0,0,.4); font-weight: 800; }
#intro .tag { text-align: center; margin: 4px 0 0; font-size: 20px; opacity: .95; text-shadow: 0 1px 8px rgba(0,0,0,.5); }
#intro .intro-bottom { max-width: 480px; width: 100%; margin: 0 auto; }
#intro .count { font-size: 21px; font-weight: 700; text-align: center; margin: 0 0 6px; text-shadow: 0 1px 8px rgba(0,0,0,.5); }
#intro .count b { font-size: 26px; font-variant-numeric: tabular-nums; }
#intro .how { text-align: center; font-size: 16px; margin: 0 0 16px; opacity: .92; }
#intro .fine { text-align: center; font-size: 14px; margin: 12px 0 0; opacity: .8; }
.shared { background: rgba(246, 240, 227, 0.96); color: var(--ink); border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; font-size: 17px; text-align: center; }
.shared q { display: block; font-family: var(--serif); font-size: 19px; word-break: keep-all; font-weight: 800; quotes: "“" "”"; margin-bottom: 4px; }
.shared small { display: block; color: var(--ink2); font-size: 15px; margin-top: 4px; }

/* 아래쪽 안내와 버튼 */
#dock { position: fixed; left: 0; right: 0; bottom: 0; padding: 0 14px calc(14px + var(--safe-b)); pointer-events: none; }
#dock > * { pointer-events: auto; max-width: 520px; margin-left: auto; margin-right: auto; }
.bubble { background: rgba(246, 240, 227, 0.95); border-radius: 16px; padding: 12px 16px; margin: 0 0 10px; font-size: 18px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.bubble:empty { display: none; }
.progress { height: 10px; background: rgba(246, 240, 227, 0.5); border-radius: 99px; overflow: hidden; margin-bottom: 10px; }
.progress i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 99px; transition: width .3s linear; }
.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .row { display: flex; gap: 10px; }
.actions .row > * { flex: 1; }

.btn { appearance: none; border: 0; border-radius: 16px; min-height: 60px; padding: 12px 18px; font-size: 21px; font-weight: 800; color: #fff; background: var(--indigo); box-shadow: 0 6px 18px rgba(16, 30, 56, .28); cursor: pointer; width: 100%; letter-spacing: -.01em; }
.btn:active { transform: translateY(1px); background: var(--indigo2); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.light { background: var(--paper); color: var(--indigo); box-shadow: 0 4px 14px rgba(0,0,0,.14); border: 2px solid rgba(31, 58, 95, .35); }
.btn.red { background: var(--red); }
.btn.kakao { background: #fee500; color: #191919; box-shadow: 0 6px 18px rgba(60, 50, 0, .22); }
.btn.kakao:active { background: #f2d900; }
.btn.small { min-height: 48px; font-size: 17px; padding: 8px 14px; }
.btn .sub { display: block; font-size: 14px; font-weight: 600; opacity: .85; margin-top: 2px; }

/* 고르기 시트 */
.sheet { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(10, 14, 22, 0.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; background: var(--paper); border-radius: 24px 24px 0 0; padding: 14px 18px calc(18px + var(--safe-b)); box-shadow: 0 -8px 30px rgba(0,0,0,.25); animation: up .28s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.steps { display: flex; gap: 6px; justify-content: center; margin: 2px 0 12px; }
.steps i { width: 28px; height: 6px; border-radius: 9px; background: var(--paper2); }
.steps i.on { background: var(--indigo); }
.sheet h2 { font-size: 23px; margin: 0 0 4px; letter-spacing: -.02em; }
.sheet .hint { color: var(--ink2); font-size: 16px; margin: 0 0 14px; }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.opts.two { grid-template-columns: repeat(2, 1fr); }
.opt { appearance: none; border: 2px solid transparent; background: #fff; border-radius: 16px; padding: 10px 6px; min-height: 64px; font-size: 18px; font-weight: 700; color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; box-shadow: 0 2px 6px rgba(60, 40, 10, .08); text-align: center; }
.opt small { font-size: 13px; font-weight: 500; color: var(--ink2); }
.opt.on { border-color: var(--indigo); background: #eef2f8; }
.opt svg { width: 64px; height: 44px; }
.opt .rare { font-size: 12px; color: var(--red); font-weight: 800; }
.sheet textarea { width: 100%; font: inherit; font-size: 19px; border-radius: 14px; border: 2px solid var(--paper2); padding: 12px 14px; resize: none; background: #fff; color: var(--ink); }
.sheet textarea:focus { outline: none; border-color: var(--indigo); }
.sheet .note { font-size: 15px; color: var(--ink2); margin: 8px 0 14px; }
.sheet .back { appearance: none; border: 0; background: none; color: var(--ink2); font-size: 16px; padding: 10px 4px; margin-top: 4px; }

/* 번호 공개, 공유 */
.modal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(10, 14, 22, 0.5); display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal-card { width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto; background: var(--paper); border-radius: 24px; padding: 24px 20px 20px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.35); animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.modal .day { color: var(--ink2); font-size: 17px; margin: 0; }
.modal .num { font-family: var(--serif); font-size: 52px; font-weight: 800; margin: 2px 0 4px; letter-spacing: -.01em; color: var(--ink); line-height: 1.15; }
.modal .num em { font-style: normal; color: var(--red); }
.modal .who { font-size: 19px; font-weight: 700; margin: 0 0 6px; }
.modal .before { font-size: 17px; color: var(--ink2); margin: 0 0 14px; }
.modal .badge { display: inline-block; background: #fbecd5; color: #8a5317; border-radius: 999px; padding: 7px 14px; font-weight: 800; font-size: 16px; margin: 0 0 14px; }
.modal .actions { margin-top: 6px; }
.modal img.card { width: 100%; border-radius: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18); margin: 4px 0 12px; }
.modal h2 { font-size: 22px; margin: 0 0 8px; }
.modal p.plain { font-size: 17px; color: var(--ink2); margin: 0 0 14px; }

.toast { position: fixed; left: 50%; top: calc(78px + var(--safe-t)); transform: translateX(-50%); width: max-content; background: rgba(22, 26, 36, 0.9); color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 17px; font-weight: 600; max-width: calc(100% - 28px); text-align: center; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.fade { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: #0d1424; opacity: 0; pointer-events: none; transition: opacity .35s; }
.fade.on { opacity: 1; }
.noscript { color: #fff; padding: 20px; }

@media (min-width: 700px) {
  #intro h1 { font-size: 72px; }
}
