/* 운빨오락실 · 점집 알바
   Layout: 한 화면 게임(위) + 스크롤하면 나오는 설명 글(아래). 밝은 앱 톤에 오행 다섯 색과 행운의 빨강 하나. */
:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #e9edf6;
  --ink: #1b1f2e;
  --sub: #646b84;
  --line: #dde2ee;
  --accent: #ff4867;
  --accent-ink: #ffffff;
  --sun: #ffc23d;
  --wood: #22b567;
  --fire: #ff6436;
  --earth: #e09a22;
  --metal: #8593ab;
  --water: #2f80ff;
  --shadow: 0 6px 24px rgba(27, 31, 46, 0.08);
  --display: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --body: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11131b; --surface: #1b1e2b; --surface-2: #252939; --ink: #eef0f8; --sub: #9aa1bb; --line: #2c3043;
    --accent: #ff5e7a; --sun: #ffcf5c; --metal: #a3afc4; --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11131b; --surface: #1b1e2b; --surface-2: #252939; --ink: #eef0f8; --sub: #9aa1bb; --line: #2c3043;
  --accent: #ff5e7a; --sun: #ffcf5c; --metal: #a3afc4; --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.55; }
h1, h2, h3, .display { font-family: var(--display); font-weight: 400; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
p { margin: 0; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.stage { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 6px;
}
.logo { font-family: var(--display); font-size: 18px; color: var(--ink); text-decoration: none; letter-spacing: 0.04em; }
.logo b { color: var(--accent); font-weight: 400; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }

.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px; padding: 8px 16px calc(env(safe-area-inset-bottom, 0px) + 16px); }
.spacer { flex: 1; min-height: 0; }
.sub { color: var(--sub); }
.small { font-size: 13px; }
.center { text-align: center; }

.btn {
  min-height: 54px; border-radius: 16px; border: 0; padding: 10px 16px; font-size: 16px; font-weight: 700;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-family: var(--display); font-weight: 400; font-size: 20px; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--sub); font-weight: 400; }
.actions { display: grid; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px;
  background: var(--surface); font-size: 13px; font-weight: 700; box-shadow: var(--shadow);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }

/* ---- 시작 */
.hero { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding-top: 8px; }
.hero h1 { font-size: 46px; line-height: 1.05; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lede { font-size: 17px; color: var(--sub); }
.shopfront { position: relative; width: 100%; display: flex; justify-content: center; gap: 0; padding: 12px 0 0; }
.shopfront .crowd { display: flex; align-items: flex-end; }
.shopfront .crowd svg { width: 64px; height: 64px; margin: 0 -6px; }
.shopfront .crowd svg:nth-child(odd) { transform: translateY(6px); }
.boss-card { display: flex; gap: 12px; align-items: center; background: var(--surface); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
.boss-card svg { width: 48px; height: 48px; flex: none; }
.boss-card .who { font-size: 12px; color: var(--sub); }
.boss-card .say { font-size: 15px; }
.today { display: flex; justify-content: center; }
.scroll-hint { text-align: center; font-size: 12px; color: var(--sub); }

/* ---- 영업 */
.hud { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-variant-numeric: tabular-nums; }
.hud div { background: var(--surface); border-radius: 14px; padding: 6px 8px; text-align: center; box-shadow: var(--shadow); }
.hud span { display: block; font-size: 11px; color: var(--sub); }
.hud b { font-size: 18px; }
.cycle { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 12px; color: var(--sub); }
.cycle i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.cycle i svg { width: 13px; height: 13px; }
.cycle .arr { opacity: .5; }
.cycle .lbl { margin-left: 6px; }

.guest { position: relative; background: var(--surface); border-radius: 24px; padding: 14px 16px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.guest .avatar { width: 92px; height: 92px; }
.guest .name { font-family: var(--display); font-size: 22px; }
.guest .tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.guest .tags .chip { box-shadow: none; background: var(--surface-2); }
.guest .tags .urgent { background: var(--accent); color: var(--accent-ink); }
.bubble { background: var(--surface-2); border-radius: 16px; padding: 12px 14px; font-size: 17px; text-align: center; width: 100%; min-height: 54px; display: grid; place-items: center; }
.timer { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; width: 100%; }
.timer i { display: block; height: 100%; background: var(--sun); transform-origin: left; border-radius: 99px; }
.pop {
  position: absolute; top: 14px; right: 14px; padding: 6px 12px; border-radius: 99px;
  font-family: var(--display); font-size: 18px; color: #fff; animation: pop .3s cubic-bezier(.3,1.6,.5,1);
}
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.tip { font-size: 14px; }

.remedies { display: grid; gap: 10px; }
.remedy {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; text-align: left;
  min-height: 62px; padding: 8px 14px; border-radius: 18px; border: 0; background: var(--surface); box-shadow: var(--shadow);
  transition: transform .08s ease;
}
.remedy:active { transform: scale(.97); }
.remedy .ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; }
.remedy .ic svg { width: 24px; height: 24px; }
.remedy .tx { font-size: 16px; font-weight: 700; }
.remedy .el { font-size: 12px; color: var(--sub); }
.remedy.mine::after { content: "내 특기"; font-size: 11px; font-weight: 700; color: var(--accent); }
.remedy[disabled] { opacity: .45; }

/* ---- 마감 */
.closing h2 { font-size: 30px; text-align: center; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; font-variant-numeric: tabular-nums; }
.stats div { background: var(--surface); border-radius: 16px; padding: 10px; text-align: center; box-shadow: var(--shadow); }
.stats b { display: block; font-family: var(--display); font-size: 26px; font-weight: 400; }
.stats span { font-size: 12px; color: var(--sub); }

/* ---- 생년월일 */
.picked { display: flex; gap: 8px; min-height: 34px; align-items: center; flex-wrap: wrap; }
.picked span { font-family: var(--display); font-size: 22px; }
.picked .ph { font-family: var(--body); font-size: 15px; color: var(--sub); }
.grid { display: grid; gap: 8px; align-content: start; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g7 { grid-template-columns: repeat(7, 1fr); }
.cell { min-height: 48px; border-radius: 14px; border: 0; background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-variant-numeric: tabular-nums; }
.cell:active { background: var(--surface-2); }
.privacy { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--sub); }
.privacy svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }

/* ---- 내 사주, 운세 */
.typecard { background: var(--surface); border-radius: 24px; padding: 20px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.typecard .avatar { width: 120px; height: 120px; }
.typecard h2 { font-size: 32px; }
.typecard .saju { font-size: 13px; color: var(--sub); }
.skill { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; font-size: 14px; width: 100%; }
.fortune { background: var(--surface); border-radius: 24px; padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.fortune .date { font-size: 13px; color: var(--sub); }
.fortune h2 { font-size: 28px; }
.fortune .kind { font-size: 13px; font-weight: 700; color: var(--accent); }
.fortune dl { margin: 0; display: grid; grid-template-columns: 64px 1fr; gap: 10px 8px; }
.fortune dt { font-size: 13px; color: var(--sub); padding-top: 2px; }
.fortune dd { margin: 0; font-size: 15px; }
.fortune .note { font-size: 13px; color: var(--sub); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.fine { font-size: 12px; color: var(--sub); text-align: center; }
.cardimg { width: 100%; border-radius: 18px; box-shadow: var(--shadow); -webkit-touch-callout: default; user-select: auto; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 24px); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 9; }

/* ---- 설명 글 */
.guide { max-width: 480px; margin: 0 auto; padding: 32px 16px 64px; display: flex; flex-direction: column; gap: 28px; }
.guide section { display: flex; flex-direction: column; gap: 10px; }
.guide h2 { font-size: 24px; }
.guide p, .guide li { font-size: 15px; color: var(--ink); max-width: 65ch; }
.guide ul, .guide ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.types { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; list-style: none; padding: 0 !important; }
.types li { background: var(--surface); border-radius: 14px; padding: 10px 12px; font-size: 14px; }
.types b { display: block; font-family: var(--display); font-weight: 400; font-size: 17px; }
.log { font-size: 14px; }
.site-foot { border-top: 1px solid var(--line); padding-top: 16px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.site-foot a { color: var(--sub); }

@media (max-height: 640px) {
  .guest .avatar { width: 70px; height: 70px; }
  .hero h1 { font-size: 38px; }
  .remedy { min-height: 54px; }
}

/* ---- 한자 장식: 정보는 한글, 한자는 곁들임 */
.hj { font-family: "Noto Serif KR", serif; font-weight: 700; font-size: .82em; opacity: .55; margin-left: 2px; }
.typecard { position: relative; overflow: hidden; }
.typecard > * { position: relative; }
.typecard .wm { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); font-family: "Noto Serif KR", serif; font-weight: 700; font-size: 220px; line-height: 1; color: var(--ink); opacity: .05; pointer-events: none; }

/* ---- 속도, 양력/음력 스위치 */
.seg { display: flex; align-items: center; justify-content: center; gap: 4px; background: var(--surface); border-radius: 99px; padding: 4px; box-shadow: var(--shadow); align-self: center; }
.seg-lbl { font-size: 12px; color: var(--sub); padding: 0 6px 0 8px; }
.seg button { border: 0; background: transparent; border-radius: 99px; min-width: 52px; min-height: 36px; padding: 0 12px; font-weight: 700; font-size: 14px; color: var(--sub); font-variant-numeric: tabular-nums; }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.picked .small-seg { margin-left: auto; box-shadow: none; background: var(--surface-2); padding: 3px; }
.picked .small-seg button { min-width: 44px; min-height: 30px; font-size: 13px; padding: 0 10px; }

/* ---- 움직임 (prefers-reduced-motion이면 core/orak.css가 모두 멈춘다) */
.blob .body, .blob .feet, .blob .eyes, .blob .sprout, .boss .tail, .boss .eyes, .boss [class^="ear"] { transform-box: fill-box; }
.blob .body { transform-origin: 50% 100%; animation: breathe 2.4s ease-in-out infinite var(--d, 0s); }
.blob .eyes { transform-origin: center; animation: blink 4.2s infinite var(--d, 0s); }
.blob .sprout { transform-origin: 50% 100%; animation: sway 1.8s ease-in-out infinite var(--d, 0s); }
@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.03, .97); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes sway { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

.boss .tail { transform-origin: 0% 100%; animation: wag 1.2s ease-in-out infinite; }
.boss .eyes { transform-origin: center; animation: blink 3.6s infinite 1s; }
.boss .ear-l { transform-origin: 80% 100%; animation: twitch 5s infinite; }
.boss .ear-r { transform-origin: 20% 100%; animation: twitch 5s infinite 2.5s; }
@keyframes wag { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(14deg); } }
@keyframes twitch { 0%, 90%, 100% { transform: rotate(0); } 93% { transform: rotate(-12deg); } 96% { transform: rotate(6deg); } }
.boss-card .boss { width: 48px; height: 48px; flex: none; }

.shopfront .crowd > * { animation: hop 1.6s ease-in-out infinite; }
.shopfront .crowd > *:nth-child(2) { animation-delay: -.3s; } .shopfront .crowd > *:nth-child(3) { animation-delay: -.6s; }
.shopfront .crowd > *:nth-child(4) { animation-delay: -.9s; } .shopfront .crowd > *:nth-child(5) { animation-delay: -1.2s; }
.shopfront .crowd .sprite { width: 64px; height: 64px; margin: 0 -6px; object-fit: contain; }
@keyframes hop { 0%, 100% { translate: 0 0; } 40% { translate: 0 -8px; } 55% { translate: 0 0; } }

.sprite { object-fit: contain; -webkit-user-drag: none; }
.face { display: grid; place-items: center; }
.face.enter { animation: enter .55s cubic-bezier(.3, 1.4, .5, 1) both; }
.face.enter.hurry { animation: enter .35s cubic-bezier(.3, 1.4, .5, 1) both, jitter .15s linear .35s infinite; }
@keyframes enter { 0% { transform: translateX(140%) scale(.7, 1.1); } 60% { transform: translateX(-6%) scale(1.12, .88); } 100% { transform: none; } }
@keyframes jitter { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(1.5px); } }
.face.react-great { animation: jump .6s cubic-bezier(.3, 1.6, .5, 1); }
.face.react-ok { animation: nod .5s ease-in-out; }
.face.react-bad { animation: no .45s ease-in-out; }
.face.leave { animation: leave .9s ease-in .3s both; }
@keyframes jump { 0% { transform: scale(1.15, .8); } 35% { transform: translateY(-26px) scale(.9, 1.12); } 70% { transform: translateY(0) scale(1.1, .9); } 100% { transform: none; } }
@keyframes nod { 30% { transform: translateY(5px); } 60% { transform: translateY(-2px); } }
@keyframes no { 20% { transform: translateX(-9px) rotate(-5deg); } 40% { transform: translateX(8px) rotate(5deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
@keyframes leave { to { transform: translateX(-160%) rotate(-12deg); opacity: 0; } }

.guest.hot { box-shadow: 0 0 0 3px var(--sun), var(--shadow); }
.guest.flash { animation: flash .45s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--accent), var(--shadow); } 100% { box-shadow: var(--shadow); } }
.screen.shake { animation: shake .35s ease-in-out; }
@keyframes shake { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, 1px); } 80% { transform: translate(2px, 0); } }

.remedies .remedy { animation: rise .35s cubic-bezier(.3, 1.3, .5, 1) both; animation-delay: calc(.15s + var(--k, 0) * .06s); }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
.remedy.picked-great { outline: 3px solid var(--wood); opacity: 1 !important; animation: pick .3s ease-out; }
.remedy.picked-ok { outline: 3px solid var(--sun); opacity: 1 !important; }
.remedy.picked-bad { outline: 3px solid var(--accent); opacity: 1 !important; }
@keyframes pick { 50% { transform: scale(1.04); } }
.timer.low i { animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .55; } }

.spark { position: absolute; left: 50%; top: 32%; width: 9px; height: 9px; border-radius: 50%; pointer-events: none; z-index: 2;
  animation: spark .85s cubic-bezier(.2, .8, .4, 1) forwards; }
.spark.star { border-radius: 2px; width: 11px; height: 11px; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
@keyframes spark { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--r)) scale(1); opacity: 0; } }
.float { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); font-family: var(--display); font-size: 30px; color: var(--accent);
  text-shadow: 0 2px 0 var(--surface); pointer-events: none; z-index: 3; animation: floatUp 1s ease-out forwards; white-space: nowrap; }
.float.mine { top: 54%; font-size: 20px; color: var(--wood); }
@keyframes floatUp { 0% { transform: translate(-50%, 10px) scale(.6); opacity: 0; } 25% { transform: translate(-50%, 0) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -40px) scale(1); opacity: 0; } }

.closing { position: relative; }
.closing .spark { top: 40%; }
.typecard.reveal > .avatar { animation: popIn .7s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes popIn { 0% { transform: scale(.2) rotate(-30deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.typecard .spark { top: 22%; }

/* 스프라이트 그림일 때: 그림 전체를 말랑하게 움직인다 */
.guest .avatar.sprite, .typecard .avatar.sprite { transform-origin: 50% 100%; animation: breathe 2.4s ease-in-out infinite; }
.guest .avatar.sprite { width: 112px; height: 112px; }
.typecard .avatar.sprite { width: 140px; height: 140px; }
.boss-card .boss.sprite { width: 56px; height: 56px; transform-origin: 50% 100%; animation: breathe 3s ease-in-out infinite; }
@media (max-height: 720px) {
  .guest { padding: 10px 14px 12px; gap: 6px; }
  .guest .avatar, .guest .avatar.sprite { width: 76px; height: 76px; }
  .bubble { min-height: 46px; padding: 9px 12px; font-size: 16px; }
  .remedy { min-height: 54px; }
  .cycle .lbl { display: none; }
}

/* ---- 초심자 힌트: 정답 처방 테두리 (game.js가 --hint-w, --hint-c를 시간에 따라 올린다) */
.remedy { box-shadow: 0 0 0 var(--hint-w, 0px) var(--hint-c, transparent), var(--shadow); transition: transform .08s ease, box-shadow .2s linear; }

/* ---- 작은 화면 맞춤: game.js가 넘칠 때만 붙인다 */
.screen.measuring * { animation: none !important; }
.stage.fit1 .topbar { padding-top: 6px; padding-bottom: 2px; }
.stage.fit1 .screen { gap: 10px; padding-top: 4px; }
.stage.fit1 .hud div { padding: 4px 8px; }
.stage.fit1 .hud b { font-size: 16px; }
.stage.fit1 .guest { padding: 10px 14px 12px; gap: 6px; }
.stage.fit1 .guest .avatar, .stage.fit1 .guest .avatar.sprite { width: 76px; height: 76px; }
.stage.fit1 .bubble { min-height: 44px; padding: 8px 12px; font-size: 16px; }
.stage.fit1 .remedies { gap: 8px; }
.stage.fit1 .remedy { min-height: 52px; padding: 6px 12px; }
.stage.fit1 .remedy .ic { width: 38px; height: 38px; }
.stage.fit1 .hero h1 { font-size: 38px; }
.stage.fit1 .typecard .avatar, .stage.fit1 .typecard .avatar.sprite { width: 96px; height: 96px; }
.stage.fit2 .cycle, .stage.fit2 .tip, .stage.fit2 .scroll-hint { display: none; }
.stage.fit2 .guest .avatar, .stage.fit2 .guest .avatar.sprite { width: 60px; height: 60px; }
.stage.fit2 .guest .name { font-size: 19px; }
.stage.fit2 .btn { min-height: 48px; }
.stage.fit1 .scene { height: 170px; }
.stage.fit2 .scene { height: 104px; }
.stage.fit2 .scene-cat { width: 76px; height: 76px; margin-left: -38px; }
.stage.fit2 .scene-counter { width: 150px; height: 45px; margin-left: -75px; }
.stage.fit2 .walker { width: 46px; height: 46px; }

/* ---- 더 보기: 메뉴, 사주표, 오행 막대, 대운, 궁합 */
.mine-btn { min-height: 44px; font-size: 15px; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.menu { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { border: 0; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); padding: 10px 12px; text-align: left; display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
.tile b { font-size: 15px; }
.tile span { font-size: 12px; color: var(--sub); }
.tile:active { transform: scale(.97); }
.fortune h3 { font-size: 16px; margin-top: 6px; }
.fortune .small { font-size: 12px; }
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pillars > div { display: grid; gap: 4px; justify-items: center; padding: 6px 2px; border-radius: 14px; }
.pillars > div.me { background: var(--surface-2); }
.pillars span { font-size: 11px; color: var(--sub); white-space: nowrap; }
.pillars i, .daeun i { font-style: normal; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-family: var(--display); font-size: 22px; line-height: 1; position: relative; }
.pillars i small, .daeun i small { position: absolute; right: 4px; bottom: 3px; font-family: "Noto Serif KR", serif; font-size: 10px; opacity: .6; }
.pillars i.empty { background: var(--surface-2); color: var(--sub); }
.bars { display: grid; gap: 6px; }
.bars div { display: grid; grid-template-columns: 52px 1fr 20px; align-items: center; gap: 8px; font-size: 13px; }
.bars i { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bars i b { display: block; height: 100%; border-radius: 99px; }
.bars em { font-style: normal; text-align: right; color: var(--sub); }
.star { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; display: grid; gap: 2px; }
.star p { font-size: 14px; }
.star .big { font-size: 20px; font-family: var(--display); font-weight: 400; }
.daeun { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.daeun li { display: grid; grid-template-columns: 54px 40px 40px 1fr; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 14px; }
.daeun li.now { background: var(--surface-2); outline: 2px solid var(--accent); }
.daeun em { font-style: normal; font-size: 13px; color: var(--sub); font-variant-numeric: tabular-nums; }
.daeun i { width: 40px; height: 40px; font-size: 18px; }
.daeun span { display: grid; font-size: 13px; line-height: 1.35; }
.daeun small { color: var(--sub); font-size: 11px; }
.pair { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; text-align: center; }
.pair > div { display: grid; justify-items: center; gap: 2px; font-size: 12px; }
.pair .avatar { width: 84px; height: 84px; }
.pair b { font-size: 14px; }
.pair span { color: var(--sub); }
.pair .score b { font-family: var(--display); font-size: 44px; color: var(--accent); font-weight: 400; line-height: 1; }
.fortune p, .fortune h2, .daeun b, .tile { word-break: keep-all; }
.star small { font-size: 12px; font-weight: 400; }

/* ---- 살아 있는 시작 화면 */
.scene { position: relative; width: 100%; height: 210px; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); isolation: isolate; }
.scene-bg { position: absolute; inset: 0; background: #fff6ea; }
.scene-bg svg, .scene-bg img { width: 100%; height: 100%; display: block; object-fit: cover; }
.scene-counter { position: absolute; left: 50%; bottom: 22%; width: 200px; height: 60px; margin-left: -100px; z-index: 1; pointer-events: none; overflow: visible; }
.scene .lantern { animation: lsway 3.2s ease-in-out infinite; }
@keyframes lsway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.scene .lantern.l2 { animation-duration: 2.7s; animation-delay: -1s; }
.scene .cloud { animation: drift 9s linear infinite; }
.scene .ball { animation: glowball 2.4s ease-in-out infinite; }
@keyframes drift { from { transform: translateX(-30px); } to { transform: translateX(30px); } }
@keyframes glowball { 50% { fill: #fff3b0; } }
.scene-cat { position: absolute; left: 50%; bottom: 36%; width: 104px; height: 104px; margin-left: -52px; padding: 0; border: 0; background: none; z-index: 1; cursor: pointer; }
.scene-cat .boss { width: 100%; height: 100%; object-fit: contain; }
.scene-cat.cat-act { animation: nod .5s ease-out; }
.scene-cat.cat-jump { animation: jump .6s ease-out; }
.scene-floor { position: absolute; left: 0; right: 0; bottom: 0; height: 40%; z-index: 2; }
.walker { position: absolute; left: 0; width: 64px; height: 64px; will-change: transform; }
.walker .walker-face { width: 100%; height: 100%; object-fit: contain; animation: hop .42s ease-in-out infinite; }
.walker.rtl .walker-face { scale: -1 1; }
.puff { position: absolute; left: 50%; bottom: 30px; width: 70px; height: 40px; margin-left: -35px; border-radius: 50%; background: radial-gradient(#fff, rgba(255,255,255,0) 70%); animation: puff .7s ease-out forwards; pointer-events: none; }
@keyframes puff { from { transform: scale(.3); opacity: 1; } to { transform: scale(2); opacity: 0; } }
/* 흔들기는 잘라 내는 틀(.scene, overflow hidden + 둥근 모서리) 대신 안쪽 그림만. iOS WebKit은 그 틀을 움직이면 안에서 움직이는 손님 레이어를 순간 그리지 않는다. */
.scene.shake > .scene-bg, .scene.shake > .scene-front, .scene.shake > .scene-counter { animation: shake .35s; }

/* 그림 배경일 때: 비율을 고정해 배경·계산대 앞판·냥도사 위치가 어긋나지 않게 */
.scene.art { height: auto; aspect-ratio: 4 / 3; }
.scene.art .scene-bg img, .scene-front { object-fit: cover; object-position: 50% 50%; }
.scene-front { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.scene.art .scene-cat { width: 30%; height: auto; aspect-ratio: 1; margin-left: -15%; bottom: 39%; }
.scene.art .scene-floor { height: 30%; }
.stage.fit1 .scene.art { height: auto; width: 74%; align-self: center; }
.stage.fit2 .scene.art { height: auto; width: 50%; align-self: center; }
.stage.fit2 .scene.art .scene-cat { width: 30%; height: auto; margin-left: -15%; }
.stage.fit2 .scene.art .walker { width: 34px; height: 34px; }

/* ---- 시작 화면 말풍선 */
.say-bubble { position: absolute; z-index: 3; max-width: 46%; padding: 6px 10px; border-radius: 14px; background: #fff; color: #1b1f2e; font-size: 13px; line-height: 1.35; box-shadow: 0 4px 12px rgba(27, 31, 46, .16); word-break: keep-all; pointer-events: none; animation: bubbleIn .22s ease-out; }
.say-bubble b { color: #ff4867; }
.say-bubble::after { content: ''; position: absolute; width: 10px; height: 10px; background: #fff; transform: rotate(45deg); }
.say-bubble.on-cat { left: 63%; top: 9%; }
.say-bubble.on-cat::after { left: -4px; bottom: 9px; }
.say-bubble.on-guest { left: 50%; bottom: calc(100% + 6px); max-width: none; width: max-content; max-width: 170px; translate: -50% 0; }
.say-bubble.on-guest::after { left: calc(50% - 5px); bottom: -4px; }
.say-bubble.on-spot { bottom: 30%; }
.say-bubble.on-spot.left { right: 54%; }
.say-bubble.on-spot.right { left: 54%; }
.say-bubble.on-spot::after { display: none; }
.say-bubble.out { opacity: 0; transform: scale(.9); transition: opacity .25s, transform .25s; }
@keyframes bubbleIn { from { opacity: 0; transform: scale(.6) translateY(6px); } }
.stage.fit2 .say-bubble { font-size: 11px; padding: 4px 8px; }

/* ---- 손님 카드 좌우: 꼬마 냥도사, 대기 줄, 옅은 가게 배경 */
.guest { isolation: isolate; }
.guest::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--shop) center 45% / cover no-repeat; opacity: .14; pointer-events: none; }
.guest > .minicat { position: absolute; left: 10px; top: 12px; width: 68px; height: 68px; }
.minicat .boss { width: 100%; height: 100%; object-fit: contain; }
.minicat.mini-nod { animation: nod .5s ease-out; }
.minicat.mini-jump { animation: jump .6s ease-out; }
.guest > .queue { position: absolute; right: 10px; top: 14px; display: grid; justify-items: end; gap: 2px; }
.queue .line { display: flex; flex-direction: row-reverse; }
.queue .line i { width: 34px; height: 34px; margin-left: -8px; animation: qin .45s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: calc(var(--k) * 60ms); opacity: calc(1 - var(--k) * .2); }
.queue .q { width: 100%; height: 100%; object-fit: contain; }
.queue span { font-size: 11px; color: var(--sub); background: var(--surface); border-radius: 99px; padding: 1px 7px; }
.queue.last span { color: var(--accent); font-weight: 700; }
.guest.hot .queue .line i { animation: qin .45s both, hop .5s ease-in-out .45s infinite; }
@keyframes qin { from { transform: translateX(14px); opacity: 0; } }
.stage.fit2 .guest > .queue { display: none; }
.stage.fit2 .guest > .minicat { width: 50px; height: 50px; }
@media (prefers-reduced-motion: reduce) { .queue .line i, .minicat { animation: none !important; } }

/* ---------------------------------------------------------------- 영업 끝: 문 닫는 가게 + 손님 장부 */
/* 그림은 시작 화면과 같은 두 장(가게, 계산대 앞면)을 가로로 길게 잘라 쓴다. 두 장의 자르는 위치가 같아야 겹쳐 맞는다. */
.dusk { container-type: inline-size; position: relative; width: 100%; max-width: 100%; align-self: center; aspect-ratio: 2 / 1; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); isolation: isolate; flex: none; }
.dusk-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 35%; pointer-events: none; }
.dusk-bg + .dusk-cat + .dusk-bg { z-index: 1; }
.dusk-cat { position: absolute; left: 50%; bottom: 30%; width: 26.7%; aspect-ratio: 1; margin-left: -13.35%; }
.dusk-cat .boss { width: 100%; height: 100%; object-fit: contain; }
.dusk-cat.cat-act { animation: nod .5s ease-out; }
.dusk-floor { position: absolute; left: 0; right: 0; bottom: 0; height: 40%; z-index: 2; pointer-events: none; }
.dusk-floor .walker { bottom: 2px; width: 22%; height: auto; aspect-ratio: 1; }
/* 불이 꺼지는 저녁빛: 위는 노을, 아래는 어스름, 가운데 등불 */
.dusk-tint { position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity 1.6s ease;
  background: radial-gradient(ellipse 45% 55% at 50% 38%, rgba(255, 210, 140, .28), transparent 70%),
    linear-gradient(rgba(255, 140, 90, .22), rgba(52, 38, 104, .38)); mix-blend-mode: multiply; }
.dusk.lit .dusk-tint { opacity: 1; }
.dusk-sign { position: absolute; left: 6%; top: 0; z-index: 3; padding: 3.6cqw 2.6cqw 1.6cqw; background: #8a5a33; color: #fff3d6; border-radius: 0 0 10px 10px;
  font-family: var(--display); font-size: max(10px, 4.4cqw); line-height: 1; box-shadow: 0 4px 10px rgba(0, 0, 0, .18); transform-origin: 50% 0; animation: lsway 3.2s ease-in-out infinite; }
.dusk-say { position: relative; margin-top: -4px; padding: 9px 14px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); font-size: 15px; line-height: 1.4; text-align: center; word-break: keep-all; text-wrap: balance; opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }
.dusk-say.on { opacity: 1; transform: none; }
.dusk-say::before { content: ''; position: absolute; left: calc(50% - 7px); top: -6px; width: 14px; height: 14px; background: var(--surface); transform: rotate(45deg); border-radius: 3px; }
.dusk-say b { color: var(--accent); }
.stage.fit3 .stats div { display: flex; align-items: baseline; justify-content: center; gap: 4px; padding: 6px 4px; }
.stage.fit3 .stats b { display: inline; font-size: 18px; }
.stage.fit3 .closing h2 { font-size: 22px; }
.stage.fit4 .dusk { display: none; }
.stage.fit4 .dusk-say { margin-top: 0; }
.stage.fit4 .dusk-say::before { display: none; }
.stage.fit3 .lg-detail { font-size: 13px; min-height: 57px; }
.stage.fit1 .stats b { font-size: 22px; }
.stage.fit1 .stats div { padding: 6px; }
.stage.fit1 .closing h2 { font-size: 26px; }
.stage.fit2 .dusk-say { padding: 6px 12px; font-size: 14px; }

.ledger { background: var(--surface); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.lg-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lg-head b { font-family: var(--display); font-weight: 400; font-size: 17px; }
.lg-head span { font-size: 12px; color: var(--sub); }
.lg-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.lg { padding: 4px 0 2px; border: 0; border-radius: 10px; cursor: pointer; display: grid; place-items: center; transition: transform .15s, box-shadow .15s; }
.lg .lg-face { width: 100%; max-width: 34px; height: auto; aspect-ratio: 1; object-fit: contain; }
.lg.great { background: color-mix(in srgb, var(--wood) 18%, var(--surface)); }
.lg.ok { background: color-mix(in srgb, var(--sun) 22%, var(--surface)); }
.lg.bad { background: var(--surface-2); }
.lg.on { box-shadow: 0 0 0 2px var(--ink); transform: translateY(-2px); }
.lg-detail { min-height: 62px; font-size: 14px; line-height: 1.45; word-break: keep-all; }
.lg-detail p { margin: 0; }
.lg-empty { color: var(--sub); text-align: center; padding-top: 20px; }
.lg-who .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.lg-kind { float: right; margin-left: 6px; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; color: #fff; }
.lg-kind.great { background: var(--wood); }
.lg-kind.ok { background: var(--sun); color: #1b1f2e; }
.lg-kind.bad { background: var(--metal); }
.lg-ask { color: var(--sub); }
.lg-rx .el { font-size: 12px; color: var(--sub); }
.lg-detail > * { animation: rise .25s ease-out; }
.stage.fit2 .ledger { padding: 8px 10px; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .dusk-sign, .lg-detail > * { animation: none; } .dusk-tint { transition: none; } }
