/* 삽장법사의 마당 — 화면 공통 (2-7c 디자인 적용)
   방향: 을지로 콜라주(한지 바탕, 종이를 오려 붙인 쪽빛 현판·버튼) + 민화 마당의 쪽빛 캡슐 하단 메뉴.
   기준 시안: docs/시안6/. 틀은 종이 질감 그림을 border-image(9조각)로 붙인다: 모서리는 그대로, 가운데만 늘어난다.
   그림 글자는 없다. 글자는 을지로체(제목·버튼)와 함렛(본문). 기준 폭 390px. */

@font-face { font-family: "Euljiro"; src: url("../fonts/euljiro.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Hahmlet"; src: url("../fonts/hahmlet.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: light;
  --hanji: #F3EBDD;      /* 바탕 한지 */
  --paper: #FBF6EA;      /* 글 읽는 종이 */
  --ink: #3A2A1E;        /* 먹갈색: 글자·선 */
  --soft: #7A6A57;
  --indigo: #2D4373;     /* 쪽빛: 현판·버튼·메뉴 */
  --indigo-d: #22335A;
  --gold: #E0B23A;       /* 금박: 희귀·활성 */
  --red: #C8371E;        /* 주사: 도장·새 인연에만 */
  --jade: #4E8A76;
  --line: 2px solid var(--ink);
  --display: "Euljiro", "Apple SD Gothic Neo", "Noto Sans CJK KR", sans-serif;
  --body: "Hahmlet", "AppleMyungjo", "Noto Serif CJK KR", serif;
  --ui: -apple-system, "Apple SD Gothic Neo", "Noto Sans CJK KR", "Malgun Gothic", sans-serif;
  --t-xs: 12px; --t-s: 14px; --t-m: 16px; --t-l: 20px; --t-xl: 28px; --t-xxl: 44px;
  --img: url("../data/images/");
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
  background: var(--hanji) url("../data/images/skin/hanji.webp") 0 0 / 512px;
  color: var(--ink);
  font: 400 var(--t-m)/1.6 var(--body);
  -webkit-text-size-adjust: 100%;
  word-break: keep-all; overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.shell {
  max-width: 480px; margin: 0 auto;
  height: 100svh; overflow: hidden; /* 한 화면 고정 (P-홈-06) */
  display: flex; flex-direction: column;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.display { font-family: var(--display); font-weight: 400; letter-spacing: -0.01em; }

/* ---- 종이 틀 (border-image). 높이를 고정해 모서리 크기가 늘 같다 */
.skin-btn, .btn {
  border: 0 solid transparent;
  border-image: url("../data/images/skin/btn_secondary.webp") 50% 14% fill / 27px 40px stretch;
}
.skin-tag, .chip, .back, .top .link, .grade, .filter[aria-pressed="true"], .story-link, .related a {
  border: 0 solid transparent;
  border-image: url("../data/images/skin/btn_secondary.webp") 50% 14% fill / 20px 22px stretch;
}

/* 위 막대: 왼쪽 꼬리표(뒤로), 오른쪽 인연 수 */
.top {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: calc(10px + env(safe-area-inset-top, 0px)) 6px;
}
.back, .top .link {
  font: 400 var(--t-m)/1 var(--display); color: var(--indigo); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 16px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px;
  font: 400 var(--t-s)/1 var(--display); color: var(--indigo); text-decoration: none; white-space: nowrap;
}
.chip b { font-weight: 400; font-size: var(--t-m); }
/* 탭 화면 제목: 찢은 가장자리 쪽빛 종이 + 테이프 한 조각 */
.top .title {
  position: relative; margin: 0; min-height: 60px; padding: 0 26px; display: inline-flex; align-items: center;
  font: 400 26px/1 var(--display); color: var(--paper);
  border: 0 solid transparent;
  border-image: url("../data/images/skin/plate_torn.webp") 50% 8% fill / 30px 24px stretch;
}
.top .title::before {
  content: ""; position: absolute; left: 6px; top: -10px; width: 54px; height: 20px; transform: rotate(-12deg);
  background: url("../data/images/skin/tape.webp") center / contain no-repeat; pointer-events: none;
}

.tiny { font-size: var(--t-xs); color: var(--soft); }
.note { font-size: var(--t-s); color: var(--soft); margin: 0; }

/* 버튼: 종이 한 가지 모양. 주 버튼만 쪽빛 */
.btn {
  appearance: none; background: none; color: var(--indigo);
  font: 400 var(--t-l)/1 var(--display);
  min-height: 54px; padding: 0 28px; width: 100%;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; cursor: pointer;
  transition: transform .08s, filter .08s;
}
.btn:active { transform: translateY(2px) scale(.99); filter: brightness(.96); }
.btn.main { border-image-source: url("../data/images/skin/btn_primary.webp"); color: var(--paper); }
.btn.plain { border-image: none; background: transparent; color: var(--ink); text-decoration: underline; text-underline-offset: 4px; font: 400 var(--t-m)/1.2 var(--body); min-height: 44px; }
.btn:disabled { opacity: .45; transform: none; cursor: default; }
.btns { display: flex; flex-direction: column; gap: 10px; }

/* 자리표시 그림 (파일이 없을 때만) */
.ph {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: rgba(251, 246, 234, .6); color: var(--soft); font: 400 var(--t-xs)/1.4 var(--ui); padding: 6px;
  border: 2px dashed #B9A688; border-radius: 12px;
}

/* 삽장 한마디: 종이 말풍선 */
.saying {
  flex: none; position: relative;
  margin-block: 8px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--paper); border: var(--line); border-radius: 18px;
  padding: 10px 14px; font-size: var(--t-s); line-height: 1.5;
}
.saying .who { font: 400 var(--t-s)/1 var(--display); color: var(--indigo); display: block; margin-bottom: 4px; }

.notice { background: var(--indigo); color: var(--paper); border-radius: 10px; padding: 10px 12px; font: 400 var(--t-s)/1.5 var(--ui); margin-bottom: 8px; }

/* 떠오르는 반응 (새 인연!) */
.pop {
  position: absolute; pointer-events: none; z-index: 20;
  font: 400 var(--t-l)/1 var(--display); color: var(--paper);
  background: var(--red); padding: 7px 14px; border-radius: 4px;
  animation: pop 1.1s ease-out forwards;
}
@keyframes pop {
  0% { opacity: 0; transform: translateY(8px) scale(.8) rotate(var(--r, -6deg)); }
  20% { opacity: 1; transform: translateY(0) scale(1.05) rotate(var(--r, -6deg)); }
  100% { opacity: 0; transform: translateY(-36px) scale(1) rotate(var(--r, -6deg)); }
}

/* 놀이 화면 제목: 끈에 매단 쪽빛 현판 */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; padding-top: 4px; justify-content: center; }
.stage h1, .plate {
  align-self: center; max-width: 100%; margin: 0 0 6px; min-height: 78px; padding: 26px 34px 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font: 400 var(--t-xl)/1.15 var(--display); color: var(--paper); text-wrap: balance;
  border: 0 solid transparent;
  border-image: url("../data/images/skin/plate.webp") 60% 16% 40% fill / 47px 40px 31px stretch;
}

/* 긴 안내 문장은 현판 대신 글자로 */
.stage h1.ask { border: 0; border-image: none; min-height: 0; padding: 0; color: var(--indigo); font-size: var(--t-l); line-height: 1.35; margin: 4px 0; }

/* ===== 마당 (첫 화면) ===== */
.yardmain { display: flex; flex-direction: column; overflow: hidden !important; }
.madang {
  position: relative; flex: 1; min-height: 0; width: 100%;
  border-radius: 18px; overflow: hidden; background: var(--hanji);
  box-shadow: 0 0 0 2px var(--ink);
}
.madang > .art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }
.madang > .ph.art { border: 0; border-radius: 0; }
.spot {
  position: absolute; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 2px; text-decoration: none; min-width: 44px; min-height: 44px;
}
.spot .obj { flex: 1; min-height: 0; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.spot .obj img { max-height: 100%; width: auto; object-fit: contain; filter: drop-shadow(0 4px 0 rgba(58, 42, 30, .15)); }
.spot .obj .ph { width: 100%; height: 100%; }
.spot:active .obj img { transform: scale(.96); }
.spot .label { /* 이름표: 작은 종이 꼬리표 */
  font: 400 var(--t-xs)/1 var(--display); color: var(--indigo); white-space: nowrap; padding: 7px 12px; min-height: 26px;
  display: inline-flex; align-items: center;
  border: 0 solid transparent; border-image: url("../data/images/skin/btn_secondary.webp") 50% 14% fill / 13px 15px stretch;
}
.spot.today .label { border-image-source: url("../data/images/skin/btn_primary.webp"); color: var(--paper); }
.spot.rang .obj img { animation: rang 1.6s ease-in-out infinite; transform-origin: 50% 10%; }
@keyframes rang { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(2deg); } 75% { transform: rotate(-2deg); } }
.spot.closed { opacity: .45; pointer-events: none; }
.spot.closed .label::after { content: " · 준비 중"; }
.spot.new-story::after { content: attr(data-badge); position: absolute; top: 0; right: 0; font: 400 11px/1 var(--display); background: var(--red); color: var(--paper); border-radius: 3px; padding: 4px 7px; transform: rotate(6deg); }
.madang .sap { position: absolute; z-index: 1; left: 50%; top: 34%; width: 26%; transform: translateX(-50%); pointer-events: none; }
.madang .sap.ph { aspect-ratio: 3 / 5; }

.critter { position: absolute; z-index: 4; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; transform: translate(-50%, -100%); animation: idle 2.6s ease-in-out infinite; }
.critter:nth-of-type(2n) { animation-delay: -1.1s; } .critter:nth-of-type(3n) { animation-delay: -.6s; }
.critter .face { width: 56px; height: 64px; display: flex; align-items: flex-end; justify-content: center; }
.critter .face > img { max-width: 100%; max-height: 100%; object-fit: contain; }
.critter .face > .ph { width: 100%; height: 100%; border-radius: 50%; font-size: 10px; }
.critter .nm { font: 400 11px/1 var(--display); color: var(--indigo); background: var(--paper); border: 1.5px solid var(--indigo); border-radius: 99px; padding: 3px 7px; white-space: nowrap; }
.critter.new .nm { background: var(--red); border-color: var(--red); color: var(--paper); }
@keyframes idle { 50% { transform: translate(-50%, calc(-100% - 3px)); } }
.hang { animation: glow 1.4s ease-in-out infinite alternate; }
@keyframes glow { from { filter: drop-shadow(0 0 0 rgba(224, 178, 58, 0)); } to { filter: drop-shadow(0 0 10px rgba(224, 178, 58, .95)); } }
.steam { position: absolute; z-index: 3; width: 30px; height: 7%; pointer-events: none; }
.steam i { position: absolute; bottom: 0; width: 6px; height: 100%; border-radius: 99px; background: rgba(255, 255, 255, .9); animation: rise 1.8s ease-out infinite; }
.steam i:nth-child(2) { left: 11px; animation-delay: -.6s; } .steam i:nth-child(3) { left: 22px; animation-delay: -1.2s; }
@keyframes rise { from { transform: translateY(6px) scaleY(.6); opacity: 0; } 40% { opacity: 1; } to { transform: translateY(-12px) scaleY(1.2); opacity: 0; } }
.empty-hint { position: absolute; left: 14%; right: 14%; top: 3%; z-index: 2; text-align: center; font: 400 var(--t-s)/1.35 var(--display); color: var(--indigo); background: rgba(251, 246, 234, .9); border-radius: 12px; padding: 6px 8px; pointer-events: none; }
.yard-talk { margin-top: 8px; }

.foot { flex: none; padding-block: 8px calc(10px + env(safe-area-inset-bottom, 0px)); font-size: var(--t-xs); color: var(--soft); }
.foot a { color: var(--ink); }

/* ===== 뽑기: 봉투 ===== */
.env {
  position: relative; width: min(70vw, 270px, calc(40svh * 1024 / 841)); aspect-ratio: 1024 / 841; margin: 10px auto 6px;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
.env .body { position: absolute; inset: 0; background: url("../data/images/ui/envelope.webp") center / contain no-repeat; }
.env .body .ph { display: none; }
.env .seal { position: absolute; left: 50%; top: 69%; transform: translate(-50%, -50%); font: 400 var(--t-m)/1 var(--display); color: var(--paper); pointer-events: none; }
/* 윗부분 띠: 찢으면 오른쪽으로 끌려가며 떨어진다 */
.env .strip {
  position: absolute; left: 0; right: 0; top: 0; height: 30%;
  background: linear-gradient(transparent 76%, transparent 76%);
  border-bottom: 3px dashed var(--ink); opacity: .55;
  transform-origin: 0 100%;
  transform: translateX(calc(var(--tear, 0) * 46%)) rotate(calc(var(--tear, 0) * 9deg));
}
.env .cut { position: absolute; left: 4%; top: 30%; height: 3px; width: calc(var(--tear, 0) * 92%); background: var(--red); }
.env.snap .strip { transition: transform .25s; }
.env.gone .strip { transition: transform .45s ease-in, opacity .45s; transform: translate(130%, -60%) rotate(28deg); opacity: 0; }
.env.gone .body { transition: transform .35s .15s, opacity .35s .15s; transform: translateY(16px); opacity: 0; }
.hint { font: 400 var(--t-l)/1.3 var(--display); margin: 8px 0 2px; }

/* ===== 카드: 종이 틀(일반 먹선 · 희귀 금박 · 전설 자개), 뒤집힌다 ===== */
.card {
  appearance: none; border: 0; padding: 0; background: none; cursor: pointer; color: inherit; font: inherit;
  width: min(62vw, 236px, calc(36svh * 2 / 3)); aspect-ratio: 2 / 3; margin: 8px auto 6px; perspective: 900px; display: block;
  --fw: 34px;
}
.card .in { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.card.flip .in { transform: rotateY(180deg); }
.card .face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  padding: calc(var(--fw) * .6) calc(var(--fw) * .55) calc(var(--fw) * .95); display: flex; flex-direction: column; gap: 3px; text-align: center; align-items: center;
  border: 0 solid transparent;
  border-image: url("../data/images/skin/frame_normal.webp") 15% fill / var(--fw) stretch;
  filter: drop-shadow(4px 6px 0 rgba(58, 42, 30, .16));
}
.card[data-grade="희귀"] .face { border-image-source: url("../data/images/skin/frame_rare.webp"); }
.card[data-grade="전설"] .face { border-image-source: url("../data/images/skin/frame_legend.webp"); }
.card .face.back { transform: rotateY(180deg); justify-content: center; }
.card .art { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.card .art > img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card .art > .ph { width: 100%; height: 100%; }
.card .name { font: 400 var(--t-l)/1.15 var(--display); color: var(--ink); text-wrap: balance; }
.card .line { font-size: var(--t-xs); line-height: 1.45; color: var(--ink); }
.card .face .tiny { font: 400 var(--t-xs)/1 var(--display); color: var(--indigo); }
.card .back .win { width: 46%; aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 2px solid var(--ink); background: var(--paper); display: flex; }
.card .back .win img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; transform: scale(1.5); transform-origin: 50% 20%; }
.card .back .line { font-size: var(--t-s); text-align: left; padding: 0 4px; }
.grade { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; font: 400 var(--t-s)/1 var(--display); color: var(--indigo); border-image-width: 17px 17px; }
.grade.new { border-image-source: url("../data/images/skin/btn_primary.webp"); color: var(--paper); }
.reveal { animation: reveal .5s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(30px) scale(.85) rotate(4deg); } to { opacity: 1; transform: none; } }

.share-box { width: 100%; text-align: left; }
.share-box input, .share-box textarea { width: 100%; font: inherit; font-size: var(--t-s); padding: 10px; border: var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); resize: none; }
.share-box .note { margin: 0 0 6px; }
.count { font: 400 var(--t-xxl)/1 var(--display); color: var(--indigo); font-variant-numeric: tabular-nums; margin: 4px 0; }
.mini { width: 120px; margin: 8px auto; }
.mini .card { --fw: 18px; }
.mini .card .line, .mini .card .tiny { display: none; }
.mini .card .name { font-size: var(--t-s); }

/* ===== 도감: 둥근 창호 창 앨범 ===== */
main > .meter { margin-top: 2px; }
.meter { height: 14px; border: var(--line); border-radius: 99px; background: var(--paper); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--indigo); transform-origin: 0 50%; transform: scaleX(0); transition: transform .6s; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.filter {
  appearance: none; font: 400 var(--t-s)/1 var(--display); color: var(--soft); cursor: pointer;
  min-height: 36px; padding: 0 14px; border: 0 solid transparent; background: transparent;
}
.filter[aria-pressed="true"] { color: var(--indigo); border-image-width: 18px 18px; }
.dex { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 8px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; min-width: 0; }
.tile .art {
  width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 16%;
  background: url("../data/images/skin/window.webp") center / contain no-repeat;
}
.tile .art > img { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 0 0 #fff) drop-shadow(0 0 3px #fff); }
.tile .nm { font: 400 var(--t-xs)/1.25 var(--display); text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .gd { font-size: 10px; color: var(--soft); }
.tile[data-grade="희귀"] .nm { color: #9A6B00; }
.tile[data-grade="전설"] .art { filter: drop-shadow(0 0 6px rgba(224, 178, 58, .9)); }
.tile .times { position: absolute; top: 0; right: 0; font: 400 10px/1 var(--display); background: var(--indigo); color: var(--paper); border-radius: 99px; padding: 4px 7px; }
.tile:active .art { transform: scale(.97); }
.tile.locked .art > img { filter: brightness(0); opacity: .14; }
.tile.locked .nm { color: var(--soft); }
.dex-sub { font: 400 var(--t-l)/1.2 var(--display); color: var(--indigo); margin: 24px 0 10px; }
.pot-dex { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; padding-bottom: 12px; }
.ptile { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; text-decoration: none; font: 400 var(--t-xs)/1.25 var(--display); }
.ptile .art { width: 72%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.ptile .art img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ptile.locked .art img { filter: brightness(0); opacity: .14; }
.ptile.locked { color: var(--soft); }

/* ===== 기분풀이 ===== */
.target {
  position: relative; width: min(74vw, 290px, 34svh); aspect-ratio: 1; margin: 4px auto 0;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; cursor: pointer;
}
.figure { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.figure > img { max-width: 100%; max-height: 100%; object-fit: contain; }
.figure > .ph { flex: 1; border-radius: 50%; }
.figure.squish { animation: squish .32s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes squish { 0% { transform: scale(1.12, .86); } 100% { transform: none; } }
.figure.shout { animation: shout .22s ease-out; }
@keyframes shout { 0% { transform: translateY(6px) scale(.96); } 60% { transform: translateY(-4px) scale(1.05); } 100% { transform: none; } }
.figure.chomp { animation: chomp .36s ease-out; }
@keyframes chomp { 0%, 100% { transform: none; } 40% { transform: scale(1.08, .92); } }
.hitbubble {
  position: absolute; left: 50%; top: -6px; transform: translateX(-50%); z-index: 2; max-width: 92%;
  background: var(--paper); border: var(--line); border-radius: 18px 18px 18px 4px; padding: 8px 14px;
  font: 400 var(--t-m)/1.3 var(--display); word-break: keep-all;
  box-shadow: inset 0 0 0 999px rgba(200, 55, 30, calc(var(--crack, 0) * .35));
}
.hitbubble.hit { animation: hit .2s; }
@keyframes hit { 25% { transform: translateX(calc(-50% - 7px)) rotate(-3deg); } 75% { transform: translateX(calc(-50% + 7px)) rotate(3deg); } }
.hitbubble.fly { transition: transform .55s cubic-bezier(.5, 0, .9, .4), opacity .55s; transform: translate(140%, -180%) rotate(40deg); opacity: 0; }
/* 숨 게이지: 칸 나뉜 종이 막대, 노란 칸이 떼는 자리 */
.shoutgauge { position: relative; height: 22px; margin: 12px 8% 0; border-radius: 6px; background: var(--paper) repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), var(--ink) calc(10% - 2px) 10%); }
.shoutgauge i { background: var(--indigo); transition: none; position: relative; z-index: 1; opacity: .92; }
.shoutgauge .zone { position: absolute; top: 0; bottom: 0; background: rgba(224, 178, 58, .85); z-index: 0; }
.mouth {
  /* 카드마다 그림 속 입 위치가 달라서, 인연 그림 전체가 받는 자리다. 글자는 읽어 주기용으로만 */
  position: absolute; inset: 6%; border-radius: 50%; font-size: 0; color: transparent; pointer-events: none;
}
.slips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 8px; margin-top: 10px; }
.slip {
  touch-action: none; user-select: none; cursor: grab; background: var(--paper); border: 1.5px solid var(--ink);
  border-radius: 3px; padding: 8px 12px; font-size: var(--t-s); max-width: 100%; min-height: 44px;
  display: flex; align-items: center; position: relative; z-index: 3; box-shadow: 2px 3px 0 rgba(58, 42, 30, .15);
}
.slip:nth-child(odd) { transform: rotate(-2deg); }
.slip.drag { cursor: grabbing; box-shadow: 0 8px 0 rgba(58, 42, 30, .2); }
.slip.eaten { transition: transform .4s ease-in, opacity .4s; transform: scale(.1) rotate(30deg) !important; opacity: 0; }
.tool-input { display: flex; gap: 8px; margin-top: 10px; }
.tool-input input { flex: 1; min-width: 0; font: inherit; font-size: var(--t-m); padding: 0 30px; min-height: 52px; color: var(--ink); background: none; border: 0 solid transparent; border-image: url("../data/images/skin/btn_secondary.webp") 50% 14% fill / 26px 30px stretch; }
.tool-input .btn { width: auto; flex: none; font-size: var(--t-m); padding: 0 20px; }
.top-r { display: flex; align-items: center; gap: 6px; }
.snd { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--indigo) center / 24px no-repeat; cursor: pointer; font-size: 0; }
.snd[aria-pressed="true"] { background-image: url("../data/images/icon/sound_on.webp"); }
.snd[aria-pressed="false"] { background-image: url("../data/images/icon/sound_off.webp"); }

/* ===== 놀이 공통 ===== */
.ico { width: 100%; height: 100%; object-fit: contain; }
.ph.ico { border-radius: 50%; font-size: 10px; padding: 2px; }
.lead-text { font-size: var(--t-m); text-align: left; margin: 12px 2px 16px; }
.tag { display: inline-block; font: 400 var(--t-xs)/1 var(--display); padding: 6px 10px; border-radius: 4px; background: #E9DDC4; color: #6B4A00; }
.tag[data-kind="fact"] { background: var(--indigo); color: var(--paper); }
.tag[data-kind="legend"] { background: #E8C873; color: #4A3300; }
.tag[data-kind="fiction"] { background: #EBC7BB; color: #7D2212; }

/* ===== 전생 조회 ===== */
.qbar { display: flex; gap: 6px; height: 12px; margin: 6px 0 4px; }
.qbar { border: 0; background: none; position: relative; }
.qbar::before { content: ""; position: absolute; inset: 0; border-radius: 99px; background: var(--paper); box-shadow: inset 0 0 0 2px var(--indigo); }
.qbar i { position: relative; display: block; height: 100%; border-radius: 99px; background: var(--indigo); transition: width .25s ease-out; }
.bubble-q {
  text-align: left; background: var(--paper); border: var(--line); border-radius: 6px;
  padding: 14px 16px; font: 500 var(--t-l)/1.45 var(--body); margin: 10px 0 14px; text-wrap: balance;
  box-shadow: 3px 4px 0 rgba(58, 42, 30, .14);
}
.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  appearance: none; display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; cursor: pointer;
  background: none; color: var(--ink); padding: 10px 22px; min-height: 56px; font: 500 var(--t-m)/1.35 var(--body);
  border: 0 solid transparent; border-image: url("../data/images/skin/btn_secondary.webp") 50% 14% fill / 28px 34px stretch;
}
.choice:active { transform: translateY(2px); }
.choice { padding-inline: 34px 30px; }
.b-head { position: relative; display: flex; justify-content: center; }
.b-head .sato { position: absolute; right: -10px; top: 6px; width: 78px; pointer-events: none; }
.b-head h1 { margin-right: 40px; }
.results { display: flex; flex-direction: column; gap: 16px; }
.result-card {
  position: relative; text-align: left; padding: 22px 20px;
  border: 0 solid transparent; border-image: url("../data/images/skin/sheet.webp") 12% fill / 26px stretch;
}
.result-card .who-tag { position: absolute; top: -10px; right: 14px; font: 400 var(--t-s)/1 var(--display); background: var(--indigo); color: var(--paper); border-radius: 4px; padding: 6px 12px; }
.alias { font: 400 var(--t-xl)/1.2 var(--display); color: var(--indigo); margin: 2px 0 10px; text-align: center; text-wrap: balance; }
.past-art { width: 136px; height: 170px; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.past-art > img { max-width: 100%; max-height: 100%; object-fit: contain; }
.past-rows { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin: 12px 0 8px; }
.past-rows dt { font: 400 var(--t-xs)/1.2 var(--display); color: var(--paper); background: var(--indigo); border-radius: 4px; padding: 6px 8px; white-space: nowrap; align-self: start; }
.past-rows dd { margin: 0; font-size: var(--t-s); line-height: 1.5; }
.match { background: var(--paper); border: var(--line); border-radius: 6px; padding: 10px 14px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.match b { font: 400 var(--t-l)/1.25 var(--display); color: var(--indigo); }
.match p { margin: 0; }
.comment { background: var(--hanji); border-radius: 4px 14px 14px 14px; padding: 10px 12px; margin: 0 0 8px; }
.comment b { font-family: var(--display); font-weight: 400; color: var(--indigo); }
.past-hopae { position: relative; width: max-content; margin: 0 auto; }
/* 직인: 빈 낙관 그림 위에 글자 */
.past-stamp {
  position: absolute; right: -46px; bottom: -4px; transform: rotate(-10deg);
  width: 62px; height: 62px; display: flex; align-items: center; justify-content: center; text-align: center;
  font: 400 15px/1.05 var(--display); color: var(--red); word-break: break-all; padding: 0 14px;
  background: url("../data/images/skin/seal.webp") center / contain no-repeat;
}
.past-sticker { position: absolute; left: -18px; top: 6px; width: 48px; height: 48px; transform: rotate(-8deg); font-size: 0; background: center / contain no-repeat; }
.past-mark-desc { margin: 10px 0 0; }
.results.compare { flex-direction: row; overflow-x: auto; scroll-snap-type: x mandatory; gap: 12px; padding: 14px 4px 8px; margin: 0 -4px; scrollbar-width: none; }
.results.compare::-webkit-scrollbar { display: none; }
.results.compare .result-card { flex: 0 0 86%; scroll-snap-align: center; }
.results.compare .disc, .results.compare .past-rows, .results.compare .past-mark-desc { display: none; }
.results.compare .past-art { width: 72px; height: 72px; }
@media (max-height: 800px) {
  .past-art { width: 108px; height: 136px; }
  .alias { font-size: var(--t-l); margin-bottom: 6px; }
  .result-card { padding: 16px; }
  .results.compare .past-art { width: 48px; height: 48px; }
}

/* ===== 액땜 굿 ===== */
.pick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.pick {
  appearance: none; display: flex; align-items: center; gap: 10px; padding: 10px 18px; min-height: 64px; cursor: pointer;
  background: none; color: var(--ink); font: 400 var(--t-m)/1.2 var(--display); text-align: left;
  border: 0 solid transparent; border-image: url("../data/images/skin/btn_secondary.webp") 50% 14% fill / 32px 26px stretch;
}
.pick .ico { width: 40px; height: 40px; flex: none; }
/* 굿판: 한지 위 징 한 대, 아래 장단 줄 */
.gutstage {
  position: relative; height: min(540px, 56svh); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  border-radius: 18px; background: rgba(251, 246, 234, .55); box-shadow: inset 0 0 0 2px var(--ink);
}
.gutstage .heat { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, rgba(224, 178, 58, var(--heat, 0)), transparent 70%); pointer-events: none; }
.drapes { display: none; }
.gutsang { position: absolute; left: 50%; top: 14%; width: 62%; aspect-ratio: 920 / 892; transform: translateX(-38%); background: url("../data/images/ui/jing.webp") center / contain no-repeat; }
.gsap { position: absolute; left: 2%; width: 40%; bottom: 26%; transform-origin: 50% 100%; pointer-events: none; display: flex; z-index: 2; }
.gsap > * { width: 100%; }
.gsap .ph { aspect-ratio: 3 / 5; border-radius: 40px; }
.lane { position: absolute; left: 8px; right: 8px; bottom: 6%; height: 64px; background: var(--paper); border: var(--line); border-radius: 8px; }
.hitring { position: absolute; left: 14%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; border: 4px solid var(--indigo); background: rgba(45, 67, 115, .08); }
.hitring.flash { animation: ring .18s ease-out; }
@keyframes ring { from { transform: scale(1.35); box-shadow: 0 0 22px 8px rgba(224, 178, 58, .9); } }
.beat { position: absolute; left: 0; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 400 var(--t-s)/1 var(--display); border: 2px solid var(--indigo); color: var(--indigo); background: var(--paper); }
.beat.k { background: var(--indigo); color: var(--paper); width: 50px; height: 50px; margin: -25px 0 0 -25px; }
.ghud { position: absolute; left: 12px; right: 12px; top: 10px; display: flex; justify-content: space-between; color: var(--indigo); pointer-events: none; z-index: 15; }
.ghud .lab { display: block; font: 400 11px/1.2 var(--display); }
.ghud .big { font: 400 30px/1 var(--display); font-variant-numeric: tabular-nums; }
.judge { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font: 400 44px/1 var(--display); color: var(--red); text-shadow: 0 3px 0 var(--paper), 0 -2px 0 var(--paper); z-index: 16; pointer-events: none; opacity: 0; }
.judge.show { animation: judge .5s ease-out; }
@keyframes judge { 0% { opacity: 0; transform: scale(.6) rotate(-6deg); } 25% { opacity: 1; transform: scale(1.15) rotate(-6deg); } 100% { opacity: 0; transform: translateY(-20px) rotate(-6deg); } }
.count-in { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 400 72px/1 var(--display); color: var(--indigo); text-shadow: 0 4px 0 var(--paper); z-index: 16; pointer-events: none; }
.gauge { height: 20px; }
.gauge i { background: var(--indigo); transition: transform .08s; }
/* 확인증: 두꺼운 한지 증서 + 낙관 하나 */
.cert {
  position: relative; text-align: center; padding: 34px 28px 30px; font-family: var(--body);
  border: 0 solid transparent; border-image: url("../data/images/skin/sheet.webp") 12% fill / 30px stretch;
}
.cert h2 { font: 400 var(--t-m)/1.2 var(--display); color: var(--paper); margin: 0 -6px 12px; display: block; padding: 13px 30px; border: 0 solid transparent; border-image: url("../data/images/skin/btn_primary.webp") 50% 14% fill / 23px 30px stretch; }
.cert-item { font: 600 var(--t-l)/1.3 var(--body); margin: 0 0 6px; }
.cert p { margin: 6px 0; }
.cert .tiny { max-width: 66%; margin-inline: 2% auto; text-align: left; }
.cert #c-score { font: 400 var(--t-m)/1.4 var(--display); color: var(--indigo); border-block: 1.5px solid var(--ink); padding: 6px 0; max-width: none; }
.stamp {
  position: absolute; right: 18px; bottom: 18px; width: 66px; height: 66px; transform: rotate(-10deg);
  display: flex; align-items: center; justify-content: center; font: 400 var(--t-m)/1 var(--display); color: var(--red);
  background: url("../data/images/skin/seal.webp") center / contain no-repeat;
}

/* ===== 조합소 ===== */
.pot { position: relative; width: min(66vw, 260px, 28svh); aspect-ratio: 1014 / 926; margin: 4px auto 0; display: flex; background: url("../data/images/ui/gamasot.webp") center / contain no-repeat; }
.pot .ph { display: none; }
.pot.boom { animation: boom .45s ease-out; }
@keyframes boom { 0% { transform: scale(1); } 20% { transform: scale(1.12) rotate(-4deg); } 40% { transform: translateX(-8px) rotate(3deg); } 60% { transform: translateX(6px); } 100% { transform: none; } }
.pot.brew { animation: brew .45s ease-in-out; }
@keyframes brew { 50% { transform: translateY(-6px) scale(1.04); } }
.pot-items { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.pot-item {
  appearance: none; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; cursor: pointer;
  background: transparent; border: 0; border-radius: 14px; color: var(--ink); font: 400 var(--t-xs)/1.2 var(--display);
}
.pot-item .ico { width: 56px; height: 52px; }
.pot-item[aria-pressed="true"] { background: rgba(45, 67, 115, .1); }
.pot-item[aria-pressed="true"]::after { content: ""; position: absolute; top: 2px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--indigo) url("../data/images/icon/check.webp") center / 14px no-repeat; }
.recipe-card { position: relative; padding: 26px 22px; margin-top: 10px; text-align: left; border: 0 solid transparent; border-image: url("../data/images/skin/sheet.webp") 12% fill / 26px stretch; }
.recipe-card .art { width: 52%; aspect-ratio: 1; margin: 0 auto 8px; display: flex; align-items: center; justify-content: center; }
.recipe-card .art > img { max-width: 100%; max-height: 100%; object-fit: contain; }
.recipe-card h2 { font-size: var(--t-xl); color: var(--indigo); margin: 0; text-align: center; }
.recipe-card .tiny { text-align: center; margin: 2px 0 10px; }
.recipe-card p { font-size: var(--t-s); line-height: 1.6; }

/* ===== 이야기 ===== */
.story-list { display: flex; flex-direction: column; }
.story-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1.5px solid rgba(58, 42, 30, .35); text-decoration: none; }
.story-row .art { width: 64px; height: 64px; flex: none; display: flex; border-radius: 50%; overflow: hidden; border: 2px solid var(--ink); background: var(--paper); }
.story-row .art > img { flex: 1; object-fit: contain; padding: 4px; }
.story-row .art > .ph { flex: 1; border-radius: 50%; border: 0; }
.story-row .txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.story-row b { font-size: var(--t-m); line-height: 1.3; }
.story-row .tags { display: flex; gap: 4px; flex-wrap: wrap; }
.story-row .tag { padding: 4px 7px; font-size: 11px; }
.head { font: 400 var(--t-xs)/1.2 var(--display); color: var(--red); } /* 야담 말머리 (P-글-06) */
.story-row .head { font-size: 11px; align-self: center; }
.story-link { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; font: 400 var(--t-s)/1.2 var(--display); color: var(--indigo); text-decoration: none; }
.story-at { margin: 6px 0 0; text-align: center; }
.foot-links { margin: 8px 0 0; }
/* 글 본문: 함렛, 좁은 단, 넓은 줄 간격 */
.article { padding-bottom: 12px; }
.article h1 { font: 400 var(--t-xl)/1.25 var(--display); color: var(--indigo); margin: 8px 0 4px; text-wrap: balance; }
.article h2 { font: 400 var(--t-l)/1.3 var(--display); color: var(--indigo); margin: 26px 0 8px; }
.article p { font-family: var(--body); font-size: 16.5px; line-height: 1.85; margin: 4px 0 16px; max-width: 34em; }
.article .note { font-size: var(--t-s); }
.article .tag { margin-top: 6px; }
.article .hero { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: 12px; border: var(--line); }
.sources { border-top: var(--line); margin-top: 24px; padding-top: 10px; font-size: var(--t-s); }
.sources b { font: 400 var(--t-s)/1 var(--display); color: var(--indigo); }
.sources p { font-size: var(--t-xs); margin: 4px 0; }
.related { display: flex; flex-wrap: wrap; gap: 8px; }
.related a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; text-decoration: none; font: 400 var(--t-s)/1.2 var(--display); color: var(--indigo); }
.rel-title { margin-top: 28px; }
.ad-slot:empty { display: none; } /* 광고 자리: 광고가 없으면 보이지 않는다 (P-글-03) */
.ad-slot { margin: 20px 0; }
.about-sap { width: 44%; margin: 6px auto 0; display: flex; }
.about-sap > * { width: 100%; }
.contact { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.contact .mail { font-size: var(--t-l); user-select: all; -webkit-user-select: all; }
.contact .btn { width: auto; }

/* ===== 한 화면 틀 (P-홈-06·07) ===== */
.shell > main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.shell > main::-webkit-scrollbar { display: none; }
/* 하단 메뉴: 떠 있는 쪽빛 캡슐 (민화 마당 시안) */
.tabbar {
  flex: none; display: flex; justify-content: space-around; align-items: center;
  margin: 6px 0 calc(8px + env(safe-area-inset-bottom, 0px)); padding: 6px;
  background: var(--indigo); border-radius: 999px; box-shadow: 0 4px 0 var(--indigo-d), 0 0 0 2px var(--ink);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 54px; justify-content: center; text-decoration: none; color: var(--paper); font: 400 var(--t-s)/1 var(--display); border-radius: 999px; position: relative; }
.tabbar a + a::before { content: ""; position: absolute; left: 0; top: 22%; bottom: 22%; width: 1px; background: rgba(251, 246, 234, .35); }
.tabbar img { width: 30px; height: 24px; object-fit: contain; }
.tabbar a[aria-current="page"] { box-shadow: inset 0 0 0 2px var(--gold); }
.tabbar a[aria-current="page"]::before, .tabbar a[aria-current="page"] + a::before { display: none; }
.has-tabbar .saying, .has-tabbar .yard-talk { margin-bottom: 4px; }

/* 한 화면에 맞추기 */
.stage .btns { gap: 8px; }
.stage .btn { min-height: 50px; font-size: var(--t-m); border-image-width: 25px 36px; }

/* ===== 공유 창 ===== */
.sheet { margin: auto auto 0; width: min(100%, 480px); max-width: 100%; max-height: 92svh; border: var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; background: var(--paper); color: var(--ink); padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; }
.sheet::backdrop { background: rgb(30 20 12 / .45); }
.sheet[open] { animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font: 400 var(--t-l)/1 var(--display); color: var(--indigo); }
.sheet-x { border: 0; background: none; font-size: 28px; line-height: 1; padding: 4px 8px; color: var(--ink); cursor: pointer; }
.sheet-prev { display: grid; place-items: center; height: min(46svh, 420px); background: var(--hanji); border-radius: 12px; }
.sheet-prev img { max-height: 100%; max-width: 100%; border-radius: 6px; -webkit-touch-callout: default; user-select: auto; }
.sheet .note { min-height: 1.4em; margin: 10px 0 6px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== 2-7c 연출 ===== */
/* 희귀·전설 카드: 앞면을 빛이 한 번 훑고, 전설은 자개빛이 천천히 돈다 */
.card[data-grade="희귀"] .face.front::after, .card[data-grade="전설"] .face.front::after {
  content: ""; position: absolute; inset: 6%; pointer-events: none; border-radius: 6px;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 246, 220, .75) 48%, transparent 60%) no-repeat;
  background-size: 250% 100%; background-position: 120% 0; mix-blend-mode: soft-light;
}
.card.reveal[data-grade="희귀"] .face.front::after, .card.reveal[data-grade="전설"] .face.front::after { animation: sheen 1.1s .35s ease-out both; }
@keyframes sheen { to { background-position: -40% 0; } }
.card[data-grade="전설"] .face.front { animation: najeon 4s linear infinite; }
@keyframes najeon { 0%, 100% { filter: drop-shadow(4px 6px 0 rgba(58,42,30,.16)) drop-shadow(0 0 6px rgba(159,227,217,.7)); } 50% { filter: drop-shadow(4px 6px 0 rgba(58,42,30,.16)) drop-shadow(0 0 10px rgba(199,184,240,.85)); } }
/* 카드 등장: 아래에서 휙 올라와 살짝 넘쳤다가 선다(전설은 더 높이) */
.reveal { animation: reveal .55s cubic-bezier(.2, 1.5, .4, 1) both; }
.card.reveal[data-grade="전설"] { animation-duration: .8s; }
@keyframes reveal { 0% { opacity: 0; transform: translateY(60px) scale(.7) rotate(6deg); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
/* 봉투: 손가락을 대면 살짝 들린다 */
.env:active .body { transform: translateY(-3px) rotate(-1deg); transition: transform .12s; }
.gutsang { transform-origin: 50% 8%; }
.past-stamp, .stamp { will-change: transform; }

/* ===== PC·태블릿: 휴대폰 한 장 크기의 판을 가운데에 놓는다 ===== */
@media (min-width: 720px) and (min-height: 640px) {
  body { display: flex; align-items: center; justify-content: center; }
  .shell {
    width: 440px; max-width: 440px; height: min(900px, calc(100svh - 48px)); margin: 24px auto;
    border-radius: 28px; background: var(--hanji) url("../data/images/skin/hanji.webp") 0 0 / 512px;
    box-shadow: 0 0 0 2px var(--ink), 0 18px 0 -6px rgba(45, 67, 115, .25), 0 30px 60px rgba(58, 42, 30, .18);
    padding-left: 20px; padding-right: 20px;
  }
  .top { padding-top: 16px; }
  .btn:hover, .choice:hover, .pick:hover { filter: brightness(1.04); }
  .spot:hover .obj img, .critter:hover { transform: translateY(-2px); }
}
@media (min-width: 720px) {
  body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: linear-gradient(rgba(45, 67, 115, .06), rgba(45, 67, 115, .06)); }
}
/* 작은 휴대폰(360×780 등): 기분풀이 그림을 조금 줄여 한 화면에 맞춘다 */
@media (max-height: 800px) { .target { width: min(70vw, 270px, 30svh); } }
