/* style.css : 색과 글꼴은 맨 위 :root에서 바꿔요 */
:root {
  --ink: #17161B;        /* 먹 바탕 */
  --ink2: #141318;
  --paper: #F2ECE1;      /* 한지색 글자 */
  --mute: #A39D93;       /* 보조 글자 (먹 바탕 대비 6:1) */
  --line: #34313A;
  --accent: #E0622F;     /* 단청 주홍: 장식과 강조 */
  --button: #C8501F;     /* 버튼 바탕 (흰 글자 대비 4.5:1) */
  --gold: #C9A462;
  --serif: "Nanum Myeongjo", "AppleMyungjo", "Batang", serif;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--paper); font-family: var(--font); word-break: keep-all; overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sub { margin: 0; color: var(--mute); font-size: 13px; }
.center { text-align: center; line-height: 1.6; }
.pc-only { display: none; }

.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 54px; border-radius: 27px; border: 0; background: var(--button); color: #fff; font-weight: 700; font-size: 17px; text-decoration: none; letter-spacing: 0.02em; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--paper); min-height: 48px; font-size: 15px; }
.text-btn { background: none; border: 0; color: var(--mute); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; font-size: 14px; width: 100%; }

/* 입구 */
.gate { position: fixed; inset: 0; z-index: 50; background: linear-gradient(#2B2832, var(--ink) 60%); display: flex; flex-direction: column; justify-content: space-between; padding: calc(64px + env(safe-area-inset-top)) 28px calc(40px + env(safe-area-inset-bottom)); overflow: hidden; }
.gate-art { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 64%; }
.gate-top, .gate-bottom { position: relative; max-width: 440px; width: 100%; margin: 0 auto; }
.gate-title { font: 800 44px/1.2 var(--serif); margin: 8px 0 0; }
.gate-tag { margin: 8px 0 0; color: #d6cfc2; font-size: 16px; }
.gate-bottom .sub { margin-top: 14px; font-size: 12px; }
.gate.leaving { animation: fadeOut .5s ease forwards; }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }

/* 배치 */
.app { min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; gap: 10px; }
.brand { font: 800 20px var(--serif); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.nav { display: none; }
.top-right { display: flex; align-items: center; gap: 12px; }
.date { display: none; color: var(--mute); font-size: 13px; }
.sound { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 13px; color: var(--paper); }
.sound[aria-pressed="false"] { color: var(--mute); }
.main { flex: 1; display: flex; flex-direction: column; }
.view { flex: 1; display: flex; flex-direction: column; padding: 8px 28px 16px; }
.side { display: none; }

.counter { padding-top: 8px; }
.big-num { margin: 2px 0; font: 800 54px/1 var(--serif); font-variant-numeric: tabular-nums; }
.mid-num { margin: 4px 0 0; font: 800 34px var(--serif); }
.mid-num .of { font-size: 18px; color: var(--mute); }

/* 목탁 */
.moktak-area { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 340px; }
.moktak { width: min(70vw, 280px); background: none; border: 0; padding: 10px; border-radius: 50%; touch-action: manipulation; transition: transform .08s ease; }
.moktak svg { width: 100%; display: block; }
.moktak:active, .moktak.hit { transform: scale(0.95); }
.moktak .stick { transform-origin: 155px 70px; transition: transform .1s ease; }
.moktak.hit .stick { transform: rotate(-14deg); }
.moktak-area.shake { animation: shake .12s linear; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.hint { margin-top: 14px; }
.floats { position: absolute; inset: 0; pointer-events: none; }
.floats span { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font: 700 22px var(--serif); color: var(--accent); animation: rise .9s ease-out forwards; white-space: nowrap; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } 20% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -60px); } }
.milestone { min-height: 22px; margin: 8px 0 0; font: 700 16px var(--serif); color: var(--gold); text-align: center; }

/* 염주 */
.beads-area { position: relative; width: min(82vw, 330px); aspect-ratio: 1; margin: 12px auto 0; touch-action: none; cursor: pointer; }
.beads-area svg { width: 100%; height: 100%; display: block; }
.beads-area circle.bead { transition: fill .2s; }
.lotus { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; animation: bloom 1.2s ease-out; }
.lotus svg { width: 58%; height: auto; }
.lotus-text { font: 700 20px var(--serif); margin: 10px 0 0; color: var(--paper); }
@keyframes bloom { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.breath { text-align: center; font: 700 20px var(--serif); margin: 18px 0 0; }
.bead-actions { margin-top: auto; padding-top: 16px; display: grid; gap: 10px; }
.chips { display: flex; justify-content: center; gap: 8px; }
.chips button { min-height: 40px; min-width: 64px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line); background: transparent; color: #d8d1c4; font-size: 13px; }
.chips button[aria-checked="true"] { border-color: var(--gold); color: var(--paper); font-weight: 700; }

/* 연등 */
#view-lantern { background: linear-gradient(var(--ink2), #22202A); }
.sky { position: relative; flex: 1; min-height: 240px; overflow: hidden; }
.star { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: #fff; opacity: .45; }
.lantern { position: absolute; bottom: 0; width: 64px; transform: translateX(-50%); animation: fly 3.2s ease-in forwards; }
.lantern.stay { animation: none; opacity: .5; }
.lantern.old { animation: none; width: 30px; opacity: .28; transform: translateX(-50%); }
.lantern svg { width: 100%; display: block; }
@keyframes fly { 0% { transform: translate(-50%, 0) scale(1); opacity: 1; } 100% { transform: translate(-40%, -260px) scale(.55); opacity: .4; } }
.wish { display: grid; gap: 10px; }
.wish-box { position: relative; }
.wish-box input { width: 100%; height: 54px; border-radius: 14px; border: 1px solid var(--line); background: #1C1B21; padding: 0 64px 0 16px; font-size: 16px; color: var(--paper); }
.wish-box input::placeholder { color: #8e887f; }
.count { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--mute); }
.colors { border: 0; margin: 0; padding: 0; }
.color-picks { display: flex; gap: 12px; }
.color-picks label { position: relative; width: 40px; height: 40px; }
.color-picks input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.color-picks span { display: block; width: 100%; height: 100%; border-radius: 50%; }
.color-picks input:checked + span { outline: 2px solid var(--paper); outline-offset: 3px; }
.color-picks input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 3px; }
.care { margin: 0; padding: 12px 14px; border-radius: 12px; background: #2a2620; border: 1px solid #5a4a30; color: var(--paper); font-size: 14px; line-height: 1.6; }
#view-lantern > .btn.ghost { margin-top: 10px; }

/* 아래 탭 (휴대폰) */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; height: calc(74px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #121115; border-top: 1px solid #2a2830; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; font-size: 12px; color: #8f897f; text-decoration: none; }
.tabs i { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid currentColor; }
.tabs a[aria-current="page"] { color: var(--paper); font-weight: 700; }
.tabs a[aria-current="page"] i { border-color: var(--accent); background: var(--accent); }

/* 카드 미리보기 */
.card-dlg { border: 0; border-radius: 20px; padding: 16px; background: #222027; color: var(--paper); width: min(92vw, 420px); }
.card-dlg::backdrop { background: rgba(0,0,0,.6); }
.card-dlg img { width: 100%; border-radius: 12px; display: block; margin-bottom: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(16px); background: var(--paper); color: var(--ink); padding: 12px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 태블릿: 한 칸 그대로, 글자와 목탁을 키운다 */
@media (min-width: 768px) {
  .view { max-width: 640px; width: 100%; margin: 0 auto; }
  .moktak { width: 320px; }
  .big-num { font-size: 64px; }
}

/* PC: 위 가로 메뉴, 가운데 내용, 오른쪽 기록 칸 */
@media (min-width: 1024px) {
  .pc-only { display: inline; }
  .mobile-only { display: none !important; }
  .app { display: grid; grid-template-columns: 1fr 360px; grid-template-rows: 72px 1fr; padding-bottom: 0; height: 100vh; }
  .top { grid-column: 1 / -1; padding: 0 48px; border-bottom: 1px solid #2a2830; }
  .brand { font-size: 24px; }
  .nav { display: flex; gap: 36px; position: absolute; left: 50%; transform: translateX(-50%); }
  .nav a { text-decoration: none; color: var(--mute); font-size: 16px; padding: 10px 2px 8px; border-bottom: 2px solid transparent; }
  .nav a[aria-current="page"] { color: var(--paper); border-bottom-color: var(--accent); }
  .date { display: inline; }
  .tabs { display: none; }
  .main { position: relative; overflow: hidden; background: radial-gradient(ellipse at 50% 110%, #24222A 0 40%, transparent 41%); }
  .view { max-width: none; padding: 24px 48px; justify-content: center; }
  .moktak { width: 330px; }
  .floats span { font-size: 28px; top: 16%; }
  .side { display: block; background: var(--ink2); border-left: 1px solid #2a2830; padding: 40px 36px; overflow-y: auto; }
  .side .big-num { font-size: 64px; }
  .side .gap { margin-top: 30px; margin-bottom: 8px; }
  .side .btn { margin-top: 36px; min-height: 48px; font-size: 15px; }
  .side .small { margin-top: 10px; font-size: 12px; line-height: 1.5; }
  .bar { height: 8px; border-radius: 4px; background: #2a2830; overflow: hidden; }
  .bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s; }
  .bar-text { margin: 8px 0 0; font-size: 14px; }
  .quote { margin: 0; font: 700 21px/1.55 var(--serif); }
  #view-beads .counter { display: none; }
  .beads-area { width: min(52vh, 380px); }
  .bead-actions { margin: 16px auto 0; width: 320px; }
  #view-lantern { display: grid; grid-template-columns: 1fr 380px; gap: 40px; align-items: center; padding: 0 48px 0 0; }
  #view-lantern[hidden] { display: none !important; }
  .sky { height: 100%; min-height: 0; }
  @keyframes fly { 0% { transform: translate(-50%, 0) scale(1); opacity: 1; } 100% { transform: translate(-40%, -480px) scale(.55); opacity: .4; } }
  .toast { bottom: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
