/* 짝 맞추기 · 2026-09-22 전면 개편
   헌법 §7 재미 앱 표준(크림 줄무늬 · 검정 테두리 카드 · Black Han Sans · 빨강/노랑/남색) — 법정 공방과 같은 계열. */
:root {
  --cream: #FFF6E5;
  --ink: #1B1B1F;
  --ink-2: #3A3530;
  --mute: #6E6456;
  --red: #E8332A;
  --yellow: #FFD13F;
  --navy: #2E4374;
  --navy-2: #3A5490;
  --green: #2E8B57;
}
* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body {
  margin: 0; color: var(--ink); word-break: keep-all; line-height: 1.55;
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  background: var(--cream) repeating-linear-gradient(135deg, transparent 0 24px, rgba(233,196,128,.20) 24px 48px);
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}

/* ── 머리 ── */
.shin-header { display: block; padding: 9px 0; background: rgba(255,255,255,.55); border-bottom: 2px solid var(--ink); }
.shin-header-inner { max-width: 640px; margin: 0 auto; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 7px; text-decoration: none; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border: 2.5px solid var(--ink); border-radius: 8px; background: var(--ink); color: var(--cream); font-family: serif; font-weight: 700; font-size: 1.05rem; }
.brand-name { font-weight: 900; font-size: .92rem; letter-spacing: -.01em; }
.head-tools { display: flex; align-items: center; gap: 7px; flex: none; }
.tool-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 2px solid var(--ink); border-radius: 10px; background: #fff; color: inherit;
  font: inherit; font-size: 1rem; line-height: 1; cursor: pointer; text-decoration: none;
  box-shadow: 2px 2px 0 var(--ink); transition: transform .12s, box-shadow .12s;
}
.tool-btn:active { transform: translate(2px,2px); box-shadow: none; }
.tool-btn[aria-pressed="false"] { opacity: .55; }

.wrap { max-width: 640px; margin: 0 auto; padding: 12px 14px 36px; }

/* ── 히어로 ── */
.hero { position: relative; display: grid; grid-template-columns: 1fr 112px; gap: 4px; align-items: end; margin-bottom: 10px; }
.kicker { display: inline-block; margin: 0 0 6px; padding: 3px 10px; border: 2.5px solid var(--ink); border-radius: 99px; background: var(--yellow); font-weight: 900; font-size: .7rem; }
.logo { font-family: 'Black Han Sans', sans-serif; font-weight: 400; font-size: clamp(2rem, 8.6vw, 2.6rem); line-height: 1.1; margin: 0; text-shadow: 3px 3px 0 var(--yellow); }
.tagline { margin: 6px 0 0; font-size: .84rem; color: var(--ink-2); font-weight: 600; line-height: 1.5; }
.tagline b { background: linear-gradient(transparent 58%, var(--yellow) 58%); }
/* 🚨 캐릭터 컷은 바닥에 붙이지 않는다 — 머리가 잘린다(헌법 §7). 칸 안에서 위아래 여유를 둔다. */
.hero-jo { position: relative; align-self: stretch; display: flex; align-items: flex-end; justify-content: center; padding: 0; border: 0; background: none; cursor: pointer; }
.hero-jo img { display: block; width: 100%; height: auto; max-height: 150px; object-fit: contain; object-position: bottom;
  filter: drop-shadow(3px 3px 0 rgba(27,27,31,.14)); transform-origin: 50% 100%; animation: sway 5s ease-in-out infinite; }
.hero-jo.poke img { animation: poke .45s ease-out; }
@keyframes sway { 0%, 100% { transform: rotate(-1deg); } 50% { transform: rotate(1deg); } }
@keyframes poke { 0% { transform: translateY(0); } 35% { transform: translateY(-8px) rotate(-3deg); } 100% { transform: translateY(0); } }
.bubble {
  position: absolute; right: 70%; top: 2px; z-index: 3; width: max-content; max-width: 190px;
  padding: 7px 11px; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 3px 3px 0 var(--ink);
  font-size: .78rem; font-weight: 800; line-height: 1.4; color: var(--ink); text-align: left;
}
.bubble::after { content: ''; position: absolute; right: -9px; top: 16px; border: 8px solid transparent; border-left-color: var(--ink); }

/* ── 난이도 ── */
.levels { display: grid; grid-template-columns: repeat(3, 1fr) 1.1fr; gap: 7px; margin-bottom: 10px; }
.lv {
  font: inherit; cursor: pointer; padding: 7px 4px 6px; color: var(--ink);
  font-family: 'Black Han Sans', sans-serif; font-size: 1.12rem; line-height: 1.15;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 3px 3px 0 var(--ink);
  transition: transform .1s, box-shadow .1s, background .15s;
}
.lv small { display: block; font-family: -apple-system, BlinkMacSystemFont, 'Malgun Gothic', sans-serif; font-size: .68rem; font-weight: 700; color: var(--mute); margin-top: 2px; }
.lv[aria-pressed="true"] { background: var(--yellow); }
.lv:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }
/* 👥 둘이 대결 단추(2026-11-06) — 난이도 줄 끝 칸 · 켜면 빨강 */
.duel-btn { font-size: 1rem; white-space: nowrap; }
.duel-btn small { font-size: .62rem; white-space: nowrap; }
.duel-btn[aria-pressed="true"] { background: var(--red); color: #fff; }
.duel-btn[aria-pressed="true"] small { color: rgba(255,255,255,.9); }

/* ── 상태 ── */
.hud { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; padding: 7px 8px;
  background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 4px 4px 0 var(--ink); text-align: center; }
.hud-cell b { display: block; font-family: 'Black Han Sans', sans-serif; font-weight: 400; font-size: 1.28rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.hud-cell span { font-size: .68rem; color: var(--mute); font-weight: 700; }
.hud-cell b.bump { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.25); color: var(--red); } }
/* 연속으로 맞히면 «맞춘 짝» 이름표가 «🔥 N연속» 으로 바뀐다 — 따로 띄우면 난이도 단추를 덮는다(2026-09-22 스크린샷) */
.hud-cell span.hot { color: var(--red); font-weight: 900; display: inline-block; }
.hud-cell span.hot.pop { animation: comboPop .4s cubic-bezier(.3,1.6,.5,1); }
@keyframes comboPop { 0% { transform: scale(.4); } 100% { transform: scale(1); } }

/* 둘이 대결 — 왼쪽 칸 원고(남색) · 오른쪽 칸 피고(빨강) · 차례인 칸에 노란 불 */
.duel #hCellA b { color: var(--navy); }
.duel #hCellB b { color: var(--red); }
.hud-cell { border-radius: 10px; transition: background .2s, box-shadow .2s; }
.hud-cell.turn { background: #FFF1B8; box-shadow: inset 0 0 0 2px var(--ink); }
.hud-cell.turn span { color: var(--ink); font-weight: 900; }
/* 맞춘 카드 모서리 ✓ 대신 누가 맞혔는지 */
.duel .card.matched.by0::after { content: '원'; background: var(--navy); font-size: .62rem; }
.duel .card.matched.by1::after { content: '피'; background: var(--red); font-size: .62rem; }
.r-stars[hidden] { display: none; }

/* ── 판 ── */
.board-wrap { position: relative; }
.board { display: grid; gap: 7px; }
.board.c4 { grid-template-columns: repeat(4, 1fr); }
.board.c5 { grid-template-columns: repeat(5, 1fr); }
.board.c6 { grid-template-columns: repeat(6, 1fr); gap: 6px; }

.card { aspect-ratio: 1; border: 0; padding: 0; background: none; cursor: pointer; font: inherit; perspective: 700px; position: relative; }
/* ⚠️ button 안의 span 은 기본 inline 이라 width/height 100% 가 먹지 않는다 — display:block 을 지우면 카드가 2px 로 찌그러진다(2026-09-06) */
.card-inner { display: block; position: relative; width: 100%; height: 100%; transition: transform .38s cubic-bezier(.4,.1,.3,1); transform-style: preserve-3d; }
.card.flipped .card-inner, .card.matched .card-inner, .card.peek .card-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; display: block; border-radius: 11px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; border: 2.5px solid var(--ink); }
.face.back {
  display: grid; place-items: center;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.06) 0 6px, transparent 6px 12px), linear-gradient(150deg, var(--navy-2), var(--navy));
  color: var(--yellow); font-family: serif; font-weight: 800; font-size: clamp(1rem, 5vw, 1.7rem);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.2);
  text-shadow: 2px 2px 0 rgba(0,0,0,.35);
}
.card:not(.flipped):not(.matched):hover .face.back { filter: brightness(1.15); }
.face.front { background-color: #fff; transform: rotateY(180deg); background-image: url('assets/cards-16.webp'); background-size: 400% 400%; background-repeat: no-repeat; }
.card.jo .face.front { background-image: url('assets/jo-card.webp'); background-size: cover; background-position: center; border-color: var(--ink); box-shadow: inset 0 0 0 3px var(--yellow); }
.card { filter: drop-shadow(3px 3px 0 var(--ink)); }
.card.matched { cursor: default; }
.card.matched .face.front { box-shadow: inset 0 0 0 3px #7ED39A; }
.card.jo.matched .face.front { box-shadow: inset 0 0 0 3px var(--yellow); }
.card.matched::after {   /* 맞춘 카드 모서리 ✓ */
  content: '✓'; position: absolute; right: -4px; top: -5px; z-index: 2; display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%; background: var(--green); color: #fff; border: 2px solid var(--ink); font-size: .7rem; font-weight: 900;
}
/* 짝이 맞는 순간의 «일치» 도장 — 찍히고 사라진다 */
.card.just .face.front::before {
  content: '일치'; position: absolute; left: 50%; top: 50%; z-index: 2;
  padding: .1em .35em; border: 3px solid var(--red); border-radius: 8px; color: var(--red); background: rgba(255,255,255,.82);
  font-family: 'Black Han Sans', sans-serif; font-size: clamp(.72rem, 3.4vw, 1.05rem); letter-spacing: .04em;
  transform: translate(-50%,-50%) rotate(-14deg); animation: stamp 1.05s ease-out forwards;
}
@keyframes stamp {
  0% { transform: translate(-50%,-50%) rotate(-14deg) scale(2.3); opacity: 0; }
  22% { transform: translate(-50%,-50%) rotate(-14deg) scale(1); opacity: 1; }
  78% { opacity: 1; }
  100% { transform: translate(-50%,-50%) rotate(-14deg) scale(1); opacity: 0; }
}
.card.just .card-inner { animation: matchPop .42s ease-out; }
@keyframes matchPop { 0% { transform: rotateY(180deg) scale(1); } 45% { transform: rotateY(180deg) scale(1.12); } 100% { transform: rotateY(180deg) scale(1); } }
.card.nope { animation: shake .38s; }
.card.nope .face.front { box-shadow: inset 0 0 0 3px var(--red); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px) rotate(-2deg); } 40% { transform: translateX(5px) rotate(2deg); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }

/* 효과 — 불꽃 조각 · 떠오르는 글씨 */
.fx { position: absolute; inset: 0; pointer-events: none; overflow: visible; z-index: 4; }
.spark { position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; border: 1.5px solid var(--ink); animation: fly .75s ease-out forwards; }
@keyframes fly { 0% { transform: translate(0,0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; } }
.pop {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  font-family: 'Black Han Sans', sans-serif; font-size: 1.35rem; color: var(--yellow);
  -webkit-text-stroke: 1.5px var(--ink); text-shadow: 2px 2px 0 var(--ink); animation: rise .95s ease-out forwards;
}
@keyframes rise { 0% { transform: translate(-50%, -30%) scale(.6); opacity: 0; } 25% { transform: translate(-50%, -60%) scale(1.1); opacity: 1; } 100% { transform: translate(-50%, -150%) scale(1); opacity: 0; } }

/* 증거 공개 띠 */
/* 🚨 display 를 준 요소는 hidden 속성만으로는 안 숨는다(작성자 CSS 가 이긴다) — 띠가 늘 판 가운데 떠서 클릭을 막았다(2026-09-22 시험에서 발견) */
.reveal[hidden], .bubble[hidden] { display: none !important; }
.reveal {
  /* 판 위(상태판 자리)에 띄운다 — 판 가운데에 두면 공개된 카드를 가린다 */
  position: absolute; left: 50%; top: -8px; z-index: 5; transform: translate(-50%, -100%);
  display: flex; align-items: center; gap: 9px; padding: 8px 14px 8px 8px; width: max-content; max-width: 94%;
  background: var(--yellow); border: 3px solid var(--ink); border-radius: 16px; box-shadow: 5px 5px 0 var(--ink);
  font-size: .8rem; font-weight: 700; line-height: 1.35; animation: revealIn .35s cubic-bezier(.3,1.5,.5,1);
}
.reveal img { width: 46px; height: 46px; border-radius: 12px; border: 2.5px solid var(--ink); flex: none; }
.reveal b { display: block; font-family: 'Black Han Sans', sans-serif; font-weight: 400; font-size: 1.25rem; color: var(--red); }
@keyframes revealIn { 0% { transform: translate(-50%, -100%) scale(.5); opacity: 0; } 100% { transform: translate(-50%, -100%) scale(1); opacity: 1; } }

.note { margin: 12px 2px 0; font-size: .74rem; color: var(--mute); line-height: 1.55; }
.note b { color: var(--ink-2); }
.foot { text-align: center; margin-top: 18px; font-size: .74rem; color: var(--mute); }
.foot a { color: var(--mute); }

/* ── 판결(결과) ── */
.result-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(27,27,31,.55); }
.result-backdrop[hidden] { display: none; }
.result-card {
  position: relative; width: min(100%, 360px); padding: 14px 16px 16px; text-align: center;
  background: #fff; border: 3px solid var(--ink); border-radius: 18px; box-shadow: 6px 6px 0 var(--ink);
  animation: cardIn .45s cubic-bezier(.3,1.4,.5,1);
}
@keyframes cardIn { 0% { transform: translateY(30px) scale(.9); opacity: 0; } 100% { transform: none; opacity: 1; } }
.r-stamp { position: absolute; left: 12px; top: 12px; padding: 2px 9px; border: 3px solid var(--red); border-radius: 8px; color: var(--red);
  font-family: 'Black Han Sans', sans-serif; font-size: 1rem; transform: rotate(-12deg); background: rgba(255,255,255,.9); }
.r-jo { display: block; width: auto; height: 128px; margin: 0 auto 2px; object-fit: contain; }
.r-level { display: inline-block; margin: 0; padding: 1px 10px; border: 2px solid var(--ink); border-radius: 99px; background: var(--yellow); font-size: .72rem; font-weight: 900; }
.r-title { font-family: 'Black Han Sans', sans-serif; font-weight: 400; font-size: 1.7rem; line-height: 1.2; margin: 6px 0 2px; }
.r-stars { font-size: 1.9rem; line-height: 1; letter-spacing: 4px; margin: 2px 0 4px; }
.r-stars i { font-style: normal; color: #D8D2C4; -webkit-text-stroke: 1.5px var(--ink); display: inline-block; }
.r-stars i.on { color: var(--yellow); animation: starIn .45s cubic-bezier(.3,1.7,.5,1) both; }
.r-stars i.on:nth-child(2) { animation-delay: .18s; } .r-stars i.on:nth-child(3) { animation-delay: .36s; }
@keyframes starIn { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }
.r-num { margin: 0; font-size: .92rem; font-weight: 700; }
.r-num b { font-family: 'Black Han Sans', sans-serif; font-weight: 400; font-size: 1.6rem; color: var(--red); }
.r-desc { margin: 2px 0 12px; font-size: .82rem; color: var(--ink-2); line-height: 1.5; }
.r-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn { font: inherit; font-weight: 900; font-size: .92rem; cursor: pointer; padding: 11px 8px; color: var(--ink); background: #fff;
  border: 2.5px solid var(--ink); border-radius: 12px; box-shadow: 3px 3px 0 var(--ink); transition: transform .1s, box-shadow .1s; }
.btn.primary { background: var(--red); color: #fff; }
.btn:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--ink); }
.btn[hidden] { display: none; }
.r-actions:has(.btn[hidden]) { grid-template-columns: 1fr; }
.link-btn { margin-top: 10px; font: inherit; font-size: .82rem; font-weight: 800; background: none; border: 0; color: var(--navy); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.lawyer-cta { display: block; margin-top: 8px; font-size: .74rem; color: var(--mute); text-decoration: none; }
.lawyer-cta:hover { color: var(--navy); text-decoration: underline; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 70; transform: translate(-50%, 10px); max-width: min(86vw, 420px); padding: 9px 18px;
  background: var(--ink); color: #fff; border-radius: 99px; font-size: .84rem; font-weight: 700; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 폰 낮은 화면 — 판이 한 화면에 들어오게 머리를 줄인다(헌법 §7 «고르는 순간은 폰 한 화면에») */
@media (max-width: 599px) {
  .hero { grid-template-columns: 1fr 96px; }
  .tagline { font-size: .8rem; }
}
@media (max-width: 599px) and (max-height: 740px) {
  .kicker { display: none; }
  .tagline { display: none; }
  .hero { grid-template-columns: 1fr 70px; margin-bottom: 6px; }
  .hero-jo img { max-height: 76px; }
  .logo { font-size: 1.9rem; }
  .levels { margin-bottom: 7px; } .lv { padding: 5px 4px; font-size: 1rem; }
  .hud { padding: 5px 8px; margin-bottom: 7px; } .hud-cell b { font-size: 1.1rem; }
  .note, .foot { font-size: .7rem; }
}

/* 움직임 줄이기 — 반복 움직임·흔들기·불꽃은 끄고, 뒤집기·도장·결과처럼 게임의 뜻을 전하는 것은 짧게 남긴다(헌법 §7) */
@media (prefers-reduced-motion: reduce) {
  .hero-jo img, .hero-jo.poke img { animation: none; }
  .card-inner { transition-duration: .16s; }
  .card.nope, .card.just .card-inner, .hud-cell span.hot.pop, .hud-cell b.bump, .result-card, .reveal { animation: none; }
  .card.just .face.front::before { animation: stampFade 1s linear forwards; }
  @keyframes stampFade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }
  .spark, .pop { display: none; }
  .r-stars i.on { animation: none; }
}
