/* 점쟁이 고양이 냥도사 */
:root {
  --ink: #f6eeff;
  --muted: #c9b8e8;
  --gold: #ffd36b;
  --gold2: #e9a93a;
  --panel: rgba(28, 18, 52, .82);
  --panel2: rgba(255, 255, 255, .06);
  --line: rgba(255, 220, 150, .22);
  --pink: #ff9cc2;
  --fur: #f7b46a;
  --fur2: #e08a3c;
  --furLight: #fff3e2;
  --cw: min(74px, 15vw);
  font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', 'WenQuanYi Zen Hei', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #140c26;
  color: var(--ink);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ── 머리줄 ── */
.top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; background: linear-gradient(#1c1236, #180f2e);
  border-bottom: 1px solid var(--line); position: relative; z-index: 5;
}
.brand { font-weight: 900; letter-spacing: -.02em; font-size: 17px; white-space: nowrap; color: var(--gold); text-shadow: 0 0 12px rgba(255, 211, 107, .45); }
.aff { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.aff b { color: var(--pink); font-weight: 800; white-space: nowrap; }
.affbar { width: 84px; height: 7px; border-radius: 9px; background: rgba(255, 255, 255, .12); overflow: hidden; flex: none; }
.affbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff8fb8, #ffd36b); border-radius: 9px; transition: width .6s; }
#streak { white-space: nowrap; }
.tools { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.tool {
  position: relative; border: 1px solid var(--line); background: var(--panel2); border-radius: 10px;
  padding: 5px 9px; font-size: 13px; display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.tool:hover { background: rgba(255, 255, 255, .12); }
.tool .dot { position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: #ff5f8f; box-shadow: 0 0 8px #ff5f8f; display: none; animation: blink 1.2s infinite; }
.tool.new .dot { display: block; }
@keyframes blink { 50% { opacity: .3; } }

/* ── 본문 ── */
main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, 430px); min-height: 0; }

/* ── 무대 ── */
#scene { position: relative; overflow: hidden; display: flex; flex-direction: column; min-height: 420px; --sky1: #2b1a52; --sky2: #120b24; }
#sky { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 20%, var(--sky1), var(--sky2) 75%); }
.star { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; opacity: .2; animation: twinkle 3s ease-in-out infinite; }
.star.big { width: 4px; height: 4px; box-shadow: 0 0 6px #fff; }
@keyframes twinkle { 50% { opacity: .95; transform: scale(1.3); } }
.ptc { position: absolute; pointer-events: none; }
.ff { width: 6px; height: 6px; border-radius: 50%; background: #e7ff8a; box-shadow: 0 0 10px 3px rgba(220, 255, 120, .6); animation: firefly 7s ease-in-out infinite; }
@keyframes firefly { 0%, 100% { transform: translate(0, 0); opacity: .2; } 30% { opacity: 1; } 50% { transform: translate(30px, -26px); } 75% { transform: translate(-18px, -8px); opacity: .9; } }
.petal { width: 10px; height: 8px; border-radius: 10px 0 10px 0; background: #ffc4dc; top: -20px; animation: fall 9s linear infinite; opacity: .85; }
@keyframes fall { to { transform: translate(-60px, 110vh) rotate(540deg); } }
.shoot { width: 90px; height: 2px; background: linear-gradient(90deg, #fff, transparent); animation: shoot 6s ease-in infinite; opacity: 0; transform: rotate(-25deg); }
@keyframes shoot { 0%, 80% { opacity: 0; translate: 0 0; } 84% { opacity: 1; } 100% { opacity: 0; translate: -260px 120px; } }

.deco { position: absolute; pointer-events: none; }
.window { left: 7%; top: 9%; width: 92px; height: 92px; border-radius: 50%; border: 6px solid #4b3477;
  background: radial-gradient(circle at 62% 38%, #fff7cf 0 14px, rgba(255, 247, 207, .25) 15px 24px, transparent 25px), linear-gradient(#21346e, #121c44);
  box-shadow: 0 0 40px rgba(255, 240, 180, .25), inset 0 0 0 2px #2c1f4d; }
.window::before, .window::after { content: ''; position: absolute; background: #4b3477; }
.window::before { left: 50%; top: 0; bottom: 0; width: 5px; margin-left: -2.5px; }
.window::after { top: 50%; left: 0; right: 0; height: 5px; margin-top: -2.5px; }
.shelf { right: 6%; top: 14%; width: 132px; border-bottom: 6px solid #4b3477; display: flex; justify-content: space-around; font-size: 24px; filter: saturate(.8); }
.bigmoon { right: 10%; top: 8%; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle at 40% 40%, #fffbe6, #f4dc9a 70%); box-shadow: 0 0 60px 20px rgba(255, 236, 170, .25); }
.bushes { left: -5%; right: -5%; bottom: 34%; height: 90px; background:
  radial-gradient(circle at 10% 100%, #0d2a2a 0 60px, transparent 61px), radial-gradient(circle at 30% 100%, #12302f 0 80px, transparent 81px),
  radial-gradient(circle at 75% 100%, #0f2b2c 0 70px, transparent 71px), radial-gradient(circle at 95% 100%, #12302f 0 60px, transparent 61px); }
.tree { left: 4%; top: 6%; font-size: 70px; filter: drop-shadow(0 0 20px rgba(255, 170, 210, .5)); }
.planet { right: 9%; top: 10%; font-size: 54px; filter: drop-shadow(0 0 20px rgba(160, 200, 255, .5)); animation: floaty 6s ease-in-out infinite; }
.nebula { inset: 0; background: radial-gradient(ellipse at 25% 30%, rgba(120, 80, 255, .35), transparent 50%), radial-gradient(ellipse at 80% 20%, rgba(255, 90, 180, .25), transparent 45%); }
@keyframes floaty { 50% { transform: translateY(-10px); } }
.garland { left: 18%; right: 18%; top: 0; display: flex; justify-content: space-between; }
.hang { display: flex; flex-direction: column; align-items: center; font-size: 15px; transform-origin: 50% 0; animation: swing 4s ease-in-out infinite; filter: drop-shadow(0 0 6px rgba(255, 220, 140, .7)); }
.hang::before { content: ''; width: 1px; height: var(--len); background: rgba(255, 220, 150, .45); }
@keyframes swing { 0%, 100% { transform: rotate(5deg); } 50% { transform: rotate(-5deg); } }

/* 방 그림 (html.art-room): 다락방만. 나머지 방은 아직 CSS·이모지 장식 */
html.art-room #scene.room-attic #sky { background: #120b24 url(img/room-attic.webp) center 35% / cover no-repeat; }
html.art-room #scene.room-attic .deco.window, html.art-room #scene.room-attic .deco.shelf { display: none; }
html.art-room #scene.room-attic .star:not(.big) { display: none; }   /* 방 안이라 큰 반짝이만 */
#scene.room-garden { --sky1: #1b3a5c; --sky2: #0a1424; }
#scene.room-shrine { --sky1: #4a2140; --sky2: #1a0b1c; }
#scene.room-galaxy { --sky1: #1c1458; --sky2: #05030f; }

#stage { position: relative; flex: 1; display: flex; justify-content: center; align-items: flex-end; min-height: 230px; z-index: 1; }
#catWrap { position: relative; width: clamp(190px, 46vh, 340px); aspect-ratio: 240 / 250; margin-bottom: -2px; cursor: pointer; }
#catSvg { width: 100%; height: 100%; display: block; overflow: visible; }
#catSvg .fur { fill: var(--fur); }
#catSvg .fur2 { stroke: var(--fur2); }
#catSvg .furl { fill: var(--furLight); }
#catSvg .robe { fill: var(--robe); }
#catSvg .trim { stroke: var(--trim); }
#catSvg .hatc { fill: var(--hat); }
#catSvg .hatb { fill: var(--hatband); }
#catSvg .gold { fill: var(--gold); }
#catSvg .tail { transform-origin: 172px 236px; animation: tail 3.2s ease-in-out infinite; }
@keyframes tail { 50% { transform: rotate(-14deg); } }
#catSvg .head { transform-origin: 120px 168px; animation: tilt 7s ease-in-out infinite; }
@keyframes tilt { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-3deg); } 60% { transform: rotate(2.5deg); } }
#catSvg .earL { transform-origin: 80px 80px; }
#catSvg .earR { transform-origin: 160px 80px; }
#catSvg.twitch .earR { animation: twitch .45s ease-in-out 2; }
#catSvg.twitch2 .earL { animation: twitch .45s ease-in-out 2; }
@keyframes twitch { 50% { transform: rotate(12deg); } }
#catSvg .eye { transform-box: fill-box; transform-origin: center; }
#catSvg .e-open { animation: eyeblink 5s infinite; }
@keyframes eyeblink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
#catSvg .e-happy, #catSvg .e-closed, #catSvg .e-big, #catSvg .e-grumpy, #catSvg .e-sleepy, #catSvg .m-open, #catSvg .zzz { display: none; }
#catSvg.mood-happy .e-open, #catSvg.mood-think .e-open, #catSvg.mood-surprise .e-open, #catSvg.mood-grumpy .e-open, #catSvg.mood-sleepy .e-open { display: none; }
#catSvg.mood-happy .e-happy, #catSvg.mood-think .e-closed, #catSvg.mood-surprise .e-big, #catSvg.mood-grumpy .e-grumpy, #catSvg.mood-sleepy .e-sleepy { display: inline; }
#catSvg.mood-surprise .m-open, #catSvg.meow .m-open { display: inline; }
#catSvg.mood-surprise .m-cat, #catSvg.meow .m-cat { display: none; }
#catSvg.mood-sleepy .zzz { display: inline; }
#catSvg .zzz text { animation: zz 2.4s ease-in-out infinite; font-weight: 900; fill: #cfe3ff; }
#catSvg .zzz text:nth-child(2) { animation-delay: .8s; }
@keyframes zz { 0% { opacity: 0; transform: translate(0, 6px); } 50% { opacity: 1; } 100% { opacity: 0; transform: translate(10px, -16px); } }
#catSvg .blush { opacity: .45; transition: opacity .4s; }
#catSvg.mood-happy .blush { opacity: .85; }
#catSvg.mood-think .head { animation: think 2.4s ease-in-out infinite; }
@keyframes think { 50% { transform: rotate(-4deg) translateY(2px); } }
#catSvg.bounce { animation: bounce .5s ease; }
@keyframes bounce { 40% { transform: translateY(-10px) scale(1.02, .98); } }
#catSvg .acc { display: none; }
#catSvg[data-outfit=basic] { --robe: #6d4bbb; --trim: #ffd36b; --hat: #563aa6; --hatband: #ffd36b; }
#catSvg[data-outfit=star] { --robe: #24346f; --trim: #ffe08a; --hat: #1d2a61; --hatband: #9fd2ff; }
#catSvg[data-outfit=ribbon] { --robe: #e886b0; --trim: #fff0f6; --hat: #e886b0; --hatband: #fff; }
#catSvg[data-outfit=glasses] { --robe: #3c8a7a; --trim: #ffe08a; --hat: #2f6f63; --hatband: #ffe08a; }
#catSvg[data-outfit=crown] { --robe: #ece8ff; --trim: #b9a6ff; --hat: #fff; --hatband: #fff; }
#catSvg[data-outfit=gold] { --robe: #c88a1d; --trim: #fff3c4; --hat: #e2a628; --hatband: #fff3c4; }
#catSvg[data-outfit=basic] .acc-hat, #catSvg[data-outfit=star] .acc-hat, #catSvg[data-outfit=glasses] .acc-hat, #catSvg[data-outfit=gold] .acc-hat { display: inline; }
#catSvg[data-outfit=star] .acc-stars, #catSvg[data-outfit=gold] .acc-stars { display: inline; }
#catSvg[data-outfit=ribbon] .acc-ribbon { display: inline; }
#catSvg[data-outfit=glasses] .acc-glasses { display: inline; }
#catSvg[data-outfit=crown] .acc-crown { display: inline; }

/* 냥도사 그림 겹 (game.js buildCatArt). html.art-cat 일 때만 있고, 그때 예전 SVG 도형을 숨긴다 */
html.art-cat #catSvg > .robe, html.art-cat #catSvg > .acc-stars, html.art-cat #catSvg > .trim, html.art-cat #catSvg > circle,
html.art-cat #catSvg .tail > path, html.art-cat #catSvg .head > :not(.art):not(.zzz) { display: none; }
:where(#catSvg .art) image { display: none; }
#catSvg[data-outfit=basic] .o-basic, #catSvg[data-outfit=star] .o-star, #catSvg[data-outfit=ribbon] .o-ribbon,
#catSvg[data-outfit=glasses] .o-glasses, #catSvg[data-outfit=glasses] .o-specs, #catSvg[data-outfit=crown] .o-crown, #catSvg[data-outfit=gold] .o-gold { display: inline; }
/* 표정: 보통·놀람 = idle, 기쁨·야옹 = happy, 생각·졸림·뿔남 = think (2단계 표정 그림이 오기 전까지) */
#catSvg .h-idle { display: inline; }
#catSvg.mood-happy .h-idle, #catSvg.mood-think .h-idle, #catSvg.mood-sleepy .h-idle, #catSvg.mood-grumpy .h-idle, #catSvg.meow .h-idle { display: none; }
#catSvg.mood-happy .h-happy, #catSvg.meow .h-happy, #catSvg.mood-think .h-think, #catSvg.mood-sleepy .h-think, #catSvg.mood-grumpy .h-think { display: inline; }
/* 눈 깜빡임: 감은 눈(think) 머리를 잠깐 겹친다 */
#catSvg.mood-idle .h-think, #catSvg.mood-surprise .h-think { display: inline; opacity: 0; animation: blinkon 5s infinite; }
@keyframes blinkon { 0%, 95.5%, 99.5%, 100% { opacity: 0; } 96%, 99% { opacity: 1; } }
#catSvg .headart { transform-box: view-box; transform-origin: 120px 160px; }
#catSvg.twitch .headart { animation: headtwitch .45s ease-in-out 2; }
#catSvg.twitch2 .headart { animation: headtwitch .45s ease-in-out 2 reverse; }
@keyframes headtwitch { 50% { transform: rotate(2.5deg); } }

.hearts { position: absolute; left: 50%; top: 20%; pointer-events: none; }
.heart { position: absolute; font-size: 20px; animation: heartUp 1.3s ease-out forwards; }
@keyframes heartUp { from { opacity: 1; transform: translate(0, 0) scale(.6); } to { opacity: 0; transform: translate(var(--dx), -90px) scale(1.2); } }

/* 수정구슬 */
#ball { position: absolute; left: 50%; bottom: -6%; width: 48%; aspect-ratio: 1; transform: translateX(-50%); z-index: 2; }
#ball .glass {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .9) 0 6%, rgba(255, 255, 255, .15) 13%, transparent 30%),
    radial-gradient(circle at 50% 60%, #b99cff 0%, #6c48d6 45%, #2b1670 100%);
  box-shadow: 0 0 26px 6px rgba(170, 130, 255, .5), inset 0 -10px 20px rgba(20, 0, 60, .5);
  animation: ballglow 4s ease-in-out infinite;
}
@keyframes ballglow { 50% { box-shadow: 0 0 40px 12px rgba(170, 130, 255, .6), inset 0 -10px 20px rgba(20, 0, 60, .5); } }
#ball .mist { position: absolute; inset: -20%; background: conic-gradient(from 0deg, transparent, rgba(255, 190, 255, .55), transparent 40%, rgba(150, 230, 255, .5), transparent 70%); filter: blur(10px); animation: spin 9s linear infinite; opacity: .55; }
@keyframes spin { to { transform: rotate(360deg); } }
#ballEmo { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; opacity: 0; transition: opacity .8s, transform .8s; transform: scale(.6); filter: drop-shadow(0 0 10px #fff); }
#ballEmo.on { opacity: .9; transform: scale(1); animation: floaty 3s ease-in-out infinite; }
.thinking #ball .glass { animation: ballthink .9s ease-in-out infinite; }
.thinking #ball .mist { animation-duration: 1.6s; opacity: 1; }
@keyframes ballthink { 50% { box-shadow: 0 0 70px 28px rgba(220, 170, 255, .85), inset 0 -10px 20px rgba(20, 0, 60, .3); filter: brightness(1.35); } }
#ball .stand { position: absolute; left: 14%; right: 14%; bottom: -12%; height: 18%; border-radius: 40% 40% 12px 12px; background: linear-gradient(#ffd36b, #b9781c); box-shadow: 0 4px 10px rgba(0, 0, 0, .4); z-index: -1; }
.paw { position: absolute; top: 2%; width: 26%; height: 17%; border-radius: 50% 50% 45% 45%; background: var(--fur); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .08); z-index: 3; }
.paw::after { content: ''; position: absolute; left: 30%; right: 30%; bottom: 18%; height: 2px; border-left: 2px solid rgba(120, 60, 20, .35); border-right: 2px solid rgba(120, 60, 20, .35); }
.paw.l { left: 6%; transform: rotate(-24deg); }
.paw.r { right: 6%; transform: rotate(24deg); }
.thinking .paw.l { animation: rub .5s ease-in-out infinite alternate; }
.thinking .paw.r { animation: rub2 .5s ease-in-out infinite alternate; }
@keyframes rub { to { transform: rotate(-12deg) translate(6px, 3px); } }
@keyframes rub2 { to { transform: rotate(12deg) translate(-6px, 3px); } }

/* 수정구슬 그림 (html.art-ball). 빛 번짐·안개·생각 중 깜빡임은 계속 코드가 위에 그린다 */
html.art-ball #ball .glass { background: url(img/orb.webp) center / 100% 100% no-repeat; }
html.art-ball #ball .mist { opacity: .3; }
html.art-ball .thinking #ball .mist { opacity: .75; }
html.art-ball #ball .stand { left: 6%; right: 6%; bottom: -30%; height: 53%; border-radius: 0; box-shadow: none; background: url(img/stand.webp) center bottom / contain no-repeat; }
html.art-ball .paw { background: none; box-shadow: none; border-radius: 0; width: 22%; height: 26%; top: -9%; }
html.art-ball .paw.l { left: 9%; } html.art-ball .paw.r { right: 9%; }
html.art-ball .paw::after { content: none; }
html.art-ball .paw::before { content: ''; position: absolute; inset: 0; background: url(img/paw.webp) center / contain no-repeat; filter: drop-shadow(0 2px 2px rgba(40, 10, 60, .35)); }
html.art-ball .paw.r::before { transform: scaleX(-1); }
#ballEmo .pic { width: 58%; height: 58%; object-fit: contain; opacity: .8; }
html.art-ball .candle { background: url(img/candle.webp) center bottom / contain no-repeat; border-radius: 0; width: 50px; height: 49px; top: -45px; }
html.art-ball .candle.r { width: 42px; height: 41px; top: -37px; }
html.art-ball .candle::after { content: none; }
html.art-ball .flame { top: -21px; }

/* 탁자 */
#table {
  position: relative; z-index: 1; padding: 22px 70px 10px; min-height: calc(var(--cw) * 1.6 + 46px);
  background: linear-gradient(#5b2f86, #3f1d63 30%, #2b1347);
  border-top: 4px solid #ffd36b; box-shadow: 0 -8px 30px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
#table::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 14px; background: repeating-linear-gradient(90deg, rgba(255, 211, 107, .55) 0 6px, transparent 6px 18px); opacity: .5; }
.candle { position: absolute; top: -52px; width: 20px; height: 54px; border-radius: 5px 5px 3px 3px; background: linear-gradient(90deg, #f3e3c4, #fff8ea 40%, #e2cfa8); z-index: 2; }
.candle.l { left: 26px; } .candle.r { right: 26px; height: 40px; top: -38px; }
.candle::after { content: ''; position: absolute; left: -6px; right: -6px; bottom: -6px; height: 10px; border-radius: 50%; background: linear-gradient(#ffd36b, #a8691a); }
.flame { position: absolute; left: 50%; top: -24px; width: 14px; height: 24px; margin-left: -7px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 75%, #fff 0 20%, #ffd76a 40%, #ff8a2a 75%, transparent 76%); transform-origin: 50% 90%; animation: flick 1.6s infinite; filter: drop-shadow(0 0 8px #ffb347); }
.candle.r .flame { animation-delay: -.7s; }
.halo { position: absolute; left: 50%; top: -40px; width: 110px; height: 110px; margin-left: -55px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 190, 90, .35), transparent 65%); animation: halo 2.2s ease-in-out infinite; pointer-events: none; }
@keyframes flick { 0%, 100% { transform: scale(1) skewX(0); } 20% { transform: scale(.94, 1.08) skewX(3deg); } 40% { transform: scale(1.04, .95) skewX(-2deg); } 60% { transform: scale(.97, 1.05) skewX(2deg); } 80% { transform: scale(1.02, .97) skewX(-3deg); } }
@keyframes halo { 50% { opacity: .65; transform: scale(.92); } }

#spread { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot .pos { font-size: 11px; color: var(--gold); opacity: .9; white-space: nowrap; }
.slot .empty { width: var(--cw); height: calc(var(--cw) * 1.6); border-radius: 9px; border: 2px dashed rgba(255, 211, 107, .4); display: grid; place-items: center; color: rgba(255, 211, 107, .55); font-size: 22px; }
#tableHint { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: center; min-height: 1em; }

/* ── 카드 ── */
.card { width: var(--cw); height: calc(var(--cw) * 1.6); perspective: 700px; flex: none; position: relative; }
.card .inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, 1.4, .5, 1); }
.card.up .inner { transform: rotateY(180deg); }
.card .face { position: absolute; inset: 0; border-radius: 9px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.card .back {
  background: radial-gradient(circle at 50% 50%, #3a2a78 0 22%, transparent 23%), repeating-linear-gradient(45deg, #241a52 0 6px, #2d2163 6px 12px);
  border: 2px solid var(--gold); box-shadow: inset 0 0 0 3px #241a52, inset 0 0 0 4px rgba(255, 211, 107, .6), 0 4px 10px rgba(0, 0, 0, .4);
  display: grid; place-items: center; font-size: calc(var(--cw) * .32);
}
.card .back::after { content: '🐾'; filter: drop-shadow(0 0 4px rgba(255, 211, 107, .7)); }
html.art-back .card .back { background: #241a52 url(img/card-back.webp) center / cover no-repeat; }
html.art-back .card .back::after { content: none; }
.card .front {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 20% 15%, rgba(255, 255, 255, .5) 0 1px, transparent 2px) 0 0 / 14px 14px, linear-gradient(160deg, hsl(var(--h) 62% 34%), hsl(calc(var(--h) + 40) 55% 17%));
  border: 2px solid var(--gold); box-shadow: inset 0 0 0 3px hsl(var(--h) 55% 22%), inset 0 0 0 4px rgba(255, 211, 107, .55), 0 4px 12px rgba(0, 0, 0, .45);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 6% 4% 7%;
}
.card .num { font-size: calc(var(--cw) * .14); color: var(--gold); font-weight: 800; letter-spacing: .05em; font-family: Georgia, serif; }
.card .art { position: relative; width: 74%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 40% 35%, hsl(var(--h) 90% 85%), hsl(var(--h) 65% 52%) 70%); box-shadow: 0 0 12px hsla(var(--h), 90%, 75%, .6); }
.card .art::before, .card .art::after { content: ''; position: absolute; top: -9%; width: 30%; height: 30%; background: hsl(var(--h) 65% 60%); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.card .art::before { left: 6%; transform: rotate(-22deg); }
.card .art::after { right: 6%; transform: rotate(22deg); }
.card .emo { font-size: calc(var(--cw) * .36); position: relative; z-index: 1; line-height: 1; }
.card .nm { font-size: calc(var(--cw) * .15); font-weight: 800; text-align: center; line-height: 1.1; color: #fff; word-break: keep-all; }
.card .art .pic { display: none; }
/* 카드 그림 (html.art-cards): 색 원·귀 대신 그림. 틀·번호·이름·역 표시는 그대로 코드 */
html.art-cards .card .art { width: 100%; flex: 1 1 0; min-height: 0; aspect-ratio: auto; margin: 3% 0; border-radius: 0; background: radial-gradient(circle at 50% 55%, hsla(var(--h), 90%, 82%, .45), transparent 66%); box-shadow: none; }
html.art-cards .card .art::before, html.art-cards .card .art::after, html.art-cards .card .art .emo { display: none; }
html.art-cards .card .nm { text-shadow: 0 1px 3px rgba(0, 0, 0, .7); }
html.art-cards .card .art .pic { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(20, 8, 40, .45)); }
.card.rev .art { transform: rotate(180deg); }
.card .rv { position: absolute; top: 4px; right: 4px; font-size: 9px; background: #1b1036; color: #b8c8ff; border-radius: 5px; padding: 1px 3px; display: none; }
.card.rev .rv { display: block; }
.card.glow .front { animation: cardglow 1.2s ease-out; }
@keyframes cardglow { 0% { filter: brightness(2.2); } 100% { filter: none; } }
.card.tap { cursor: pointer; }
.card.tap:hover .inner { transform: rotateY(180deg) translateY(-4px); }
.card.deal { animation: deal .45s cubic-bezier(.2, 1.2, .4, 1) both; }
@keyframes deal { from { opacity: 0; transform: translateY(-60px) rotate(-12deg) scale(.7); } }

/* ── 오른쪽 판 ── */
#panel { background: var(--panel); border-left: 1px solid var(--line); padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; overflow-y: auto; }
.speaker { font-size: 12px; color: var(--gold); font-weight: 800; display: flex; align-items: center; gap: 6px; }
.speaker .mood { font-weight: 400; color: var(--muted); }
.bubbleBox { position: relative; background: #fffaf2; color: #2a1b3d; border-radius: 16px; padding: 13px 15px; box-shadow: 0 6px 20px rgba(0, 0, 0, .3); }
.bubbleBox::before { content: ''; position: absolute; left: -9px; top: 22px; border: 9px solid transparent; border-right-color: #fffaf2; border-left: 0; }
#bubble { min-height: 3.2em; max-height: 210px; overflow-y: auto; line-height: 1.6; font-size: 15px; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; }
#bubble.reveal { animation: reveal .7s ease-out; }
@keyframes reveal { from { opacity: 0; filter: blur(4px); transform: translateY(4px); } }
#bubble .dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
#notes { display: flex; flex-direction: column; gap: 4px; }
.note { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; background: var(--panel2); border-radius: 9px; padding: 6px 9px; border: 1px solid transparent; text-align: left; width: 100%; }
.note:hover { border-color: var(--line); }
.note .p { color: var(--gold); white-space: nowrap; font-weight: 700; }
.note .k { color: var(--muted); }

.label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel2); border-radius: 99px; padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.chip[aria-pressed=true] { background: linear-gradient(#ffe39a, #f2b84b); color: #3a2307; border-color: transparent; font-weight: 800; }
.chip.locked { opacity: .5; }
.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 0; }
.btn { border: 0; border-radius: 12px; padding: 9px 14px; font-weight: 800; background: linear-gradient(#8f6dff, #6a47d8); color: #fff; box-shadow: 0 3px 0 #4a2fa6; white-space: nowrap; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #4a2fa6; }
.btn.gold { background: linear-gradient(#ffe39a, #f2b84b); color: #3a2307; box-shadow: 0 3px 0 #b07a1c; }
.btn.ghost { background: var(--panel2); border: 1px solid var(--line); box-shadow: none; color: var(--ink); font-weight: 700; }

form#f { display: flex; gap: 8px; }
#q { flex: 1; min-width: 0; padding: 11px 13px; border-radius: 12px; border: 2px solid transparent; font-size: 16px; background: #fffaf2; color: #2a1b3d; }
#q:focus { outline: none; border-color: var(--gold); }
#q.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
#askBtn { padding: 10px 16px; border-radius: 12px; border: 0; background: linear-gradient(#ffe39a, #f2b84b); color: #3a2307; font-weight: 900; font-size: 15px; box-shadow: 0 3px 0 #b07a1c; white-space: nowrap; }
#askBtn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #b07a1c; }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
#count { font-weight: 700; }
.tip { font-size: 11.5px; color: var(--muted); opacity: .85; line-height: 1.5; }

/* ── 알림 ── */
#toasts { position: fixed; top: 54px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 60; pointer-events: none; width: min(92vw, 420px); }
.toast { background: rgba(30, 18, 58, .95); border: 1px solid var(--gold); color: var(--ink); padding: 8px 14px; border-radius: 12px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: toastIn .35s ease-out, toastOut .4s ease-in 3.2s forwards; text-align: center; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ── 모달 ── */
.modal { position: fixed; inset: 0; background: rgba(8, 4, 20, .72); display: none; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal.open { display: flex; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet { background: linear-gradient(#251846, #1a1033); border: 1px solid var(--line); border-radius: 18px; width: min(680px, 100%); max-height: 100%; overflow-y: auto; padding: 16px 18px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); position: relative; }
.sheet h2 { margin: 0 0 4px; font-size: 19px; color: var(--gold); }
.sheet .sub { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.x { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); font-size: 18px; line-height: 1; }

/* 카드 고르기 */
#pick .sheet { width: min(760px, 100%); text-align: center; }
#fan { position: relative; height: 230px; margin: 10px auto 0; max-width: 640px; }
#fan .card { position: absolute; left: 50%; top: 40px; margin-left: calc(var(--cw) / -2); transition: transform .5s cubic-bezier(.3, 1.3, .5, 1), opacity .35s; cursor: pointer; --cw: min(84px, 17vw); }
#fan .card:hover:not(.picked) { z-index: 30 !important; }
#fan .card.picked { opacity: 0; pointer-events: none; }
#pickMsg { font-size: 14px; color: var(--muted); }

/* 도감 */
.dexgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; --cw: 72px; }
.dexcell { display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; padding: 0; }
.dexcell .cnt { font-size: 10.5px; color: var(--muted); }
.dexcell.unseen .card { filter: grayscale(1) brightness(.6); }
.progress { height: 9px; background: rgba(255, 255, 255, .1); border-radius: 9px; overflow: hidden; margin: 6px 0 12px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #8f6dff, #ffd36b); }
.detail { display: flex; gap: 14px; align-items: center; background: var(--panel2); border-radius: 14px; padding: 12px; margin-bottom: 12px; --cw: 92px; }
.detail h3 { margin: 0 0 4px; font-size: 17px; }
.detail p { margin: 3px 0; font-size: 13px; line-height: 1.5; }
.rewards { font-size: 12.5px; color: var(--muted); margin-top: 12px; line-height: 1.7; }

/* 일지 */
.entry { background: var(--panel2); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: 13.5px; line-height: 1.55; }
.entry .meta { font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.entry .qq { font-weight: 800; margin: 3px 0; }
.entry .aa { color: #f3e4ff; white-space: pre-wrap; }
.mini { font-size: 11.5px; padding: 3px 8px; border-radius: 8px; }
.empty-msg { text-align: center; color: var(--muted); padding: 30px 0; }

/* 오늘의 운세 */
.daily { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; justify-content: center; --cw: 120px; }
.daily .info { flex: 1; min-width: 220px; }
.daily dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; font-size: 14px; }
.daily dt { color: var(--muted); }
.daily dd { margin: 0; font-weight: 700; }
.stars { color: var(--gold); letter-spacing: 2px; font-size: 18px; }
.catline { background: #fffaf2; color: #2a1b3d; border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.55; margin-top: 8px; }

/* 꾸미기 */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px; }
.tile { border: 1px solid var(--line); background: var(--panel2); border-radius: 12px; padding: 10px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.tile b { font-size: 14px; }
.tile span { font-size: 11.5px; color: var(--muted); }
.tile.on { border-color: var(--gold); background: rgba(255, 211, 107, .14); }
.tile.locked { opacity: .5; }
.unlocks { list-style: none; padding: 0; margin: 0; font-size: 13px; line-height: 1.9; }
.unlocks li.done { color: var(--muted); text-decoration: line-through; }

/* 수련(짝 맞추기) */
.memgrid { display: grid; grid-template-columns: repeat(4, var(--cw)); gap: 8px; justify-content: center; --cw: min(74px, 19vw); margin: 10px 0; }
.memgrid .card { cursor: pointer; }
.memgrid .card.done .front { box-shadow: 0 0 14px 3px rgba(255, 211, 107, .8); }
.memstat { display: flex; justify-content: center; gap: 16px; font-size: 13.5px; color: var(--muted); }

/* 결과 공유 */
.result { background: radial-gradient(circle at 50% 0, #4b2f8f, #1d1238 70%); border: 2px solid var(--gold); border-radius: 16px; padding: 16px; text-align: center; }
.result .cards { display: flex; justify-content: center; gap: 6px; margin: 10px 0; --cw: 58px; flex-wrap: wrap; }
.result .rq { font-weight: 800; margin: 6px 0; }
.result .ra { background: #fffaf2; color: #2a1b3d; border-radius: 12px; padding: 10px 12px; text-align: left; line-height: 1.6; font-size: 14px; white-space: pre-wrap; }
.result .sig { font-size: 12px; color: var(--gold); margin-top: 8px; }
#shareText { width: 100%; height: 84px; margin-top: 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, .25); color: var(--ink); font-family: inherit; font-size: 12px; line-height: 1.5; padding: 8px; resize: none; }

/* ── 좁은 화면 ── */
@media (max-width: 760px) {
  main { grid-template-columns: 1fr; }
  #scene { min-height: 0; }
  #stage { min-height: 0; flex: none; height: 196px; }
  #catWrap { width: 172px; }
  #spread { gap: 7px; }
  #tableHint { font-size: 11px; margin-top: 4px; }
  #panel { padding: 12px 14px; gap: 9px; }
  #bubble { max-height: 170px; }
  #panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .bubbleBox::before { left: 40px; top: -9px; border: 9px solid transparent; border-bottom-color: #fffaf2; border-top: 0; }
  .tool .t { display: none; }
  .tool { padding: 6px 8px; font-size: 15px; }
  .tools { margin-left: 0; width: 100%; justify-content: space-between; }
  .window { width: 64px; height: 64px; }
  .shelf { width: 100px; font-size: 18px; }
  .bigmoon { width: 70px; height: 70px; }
  #table { padding: 16px 10px 6px; }
  .candle.l { left: 10px; } .candle.r { right: 10px; }
  #fan { height: 200px; }
}
@media (max-height: 600px) and (min-width: 761px) {
  :root { --cw: 58px; }
  #catWrap { width: clamp(160px, 42vh, 260px); }
  #panel { gap: 7px; padding: 10px 12px; }
  #bubble { max-height: 130px; font-size: 14px; }
  .top { padding: 5px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
