/* 밸런스 게임 — 리소 인쇄 대결 포스터. 글꼴: 가석 원(Gasoek One, OFL) 서브셋 + 프리텐다드 */

:root {
  --paper: #FBFBF8;
  --ink: #000;
  --pink: #FF48B0;
  --navy: #3D5588;
  --a: #FF48B0; --at: #000; --b: #3D5588; --bt: #FFFDF5;
  --display: 'Gasoek One', 'Gasoek Rest', 'Black Han Sans', 'Pretendard Variable', sans-serif;
  --ui: 'Pretendard Variable', 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.1 0 0 0 -.42'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 400 16px/1.55 var(--ui);
  overflow-x: hidden; -webkit-text-size-adjust: 100%;
  word-break: keep-all; -webkit-tap-highlight-color: transparent;
}
body::after { /* 인쇄 입자: 종이·잉크 모두 위에 얹는다 */
  content: ''; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: var(--grain); opacity: .16; mix-blend-mode: multiply;
}
button, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ── 상단 ───────────────────────────── */
.top {
  position: absolute; z-index: 60; top: calc(env(safe-area-inset-top) + 12px); left: 16px; right: 16px;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
}
.logo {
  pointer-events: auto; text-decoration: none; color: var(--paper); background: var(--ink);
  font: 400 17px/1 var(--display); padding: 7px 9px 6px; letter-spacing: .02em;
}
.top-play { display: none; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.tag, .prog { font: 700 13px/1 var(--ui); padding: 7px 9px; background: var(--paper); color: var(--ink); white-space: nowrap; }
.tag { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.prog { flex-shrink: 0; }
.prog { font-variant-numeric: tabular-nums; }
.top-tools { display: none; gap: 4px; margin-left: auto; flex-shrink: 0; }
.tool {
  pointer-events: auto; width: 44px; height: 44px; padding: 0; border: 0; background: var(--paper); color: var(--ink); cursor: pointer;
  display: grid; place-items: center;
}
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tool:disabled { opacity: .35; cursor: default; }
#sound .mute { display: none; }
#sound[aria-pressed="false"] .wave { display: none; }
#sound[aria-pressed="false"] .mute { display: inline; }
body[data-view="play"] .top { position: fixed; }
body[data-view="play"] .top-play, body[data-view="play"] .top-tools { display: flex; }
body[data-view="play"] .logo { background: var(--paper); color: var(--ink); }
body[data-view="play"] { overflow: hidden; }
body[data-view="play"] .guide, body[data-view="play"] .toast-hide { display: none; }

/* ── 처음 화면 ───────────────────────── */
.view { min-height: 100svh; }
.home {
  padding: calc(env(safe-area-inset-top) + 64px) 16px 28px;
  max-width: 1180px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 0;
}
.title {
  position: relative; margin: 0; width: max-content; max-width: 100%;
  font: 400 clamp(84px, 27vw, 168px)/.9 var(--display); letter-spacing: -.02em;
  color: var(--pink); mix-blend-mode: multiply;
}
.title::after {
  content: attr(data-text); position: absolute; left: 0; top: 0; white-space: pre-line;
  color: var(--navy); mix-blend-mode: multiply; transform: translate(.045em, .035em);
  animation: pass2 .55s cubic-bezier(.2, .9, .25, 1.15) .25s both;
}
@keyframes pass2 {
  from { transform: translate(-.5em, -.12em) rotate(-2deg); opacity: 0; }
  60% { opacity: 1; }
  to { transform: translate(.045em, .035em); opacity: 1; }
}
.lede { margin: 18px 0 18px; max-width: 30em; font-size: 16px; line-height: 1.6; }
.count { display: flex; align-items: center; gap: 6px; margin: 0 0 14px; flex-wrap: wrap; }
.count-label { font-size: 14px; font-weight: 700; margin-right: 4px; }
.count button, .fmt button {
  height: 36px; padding: 0 12px; border: 2px solid var(--ink); background: transparent; cursor: pointer;
  font-weight: 700; font-size: 14px;
}
.count button[aria-checked="true"], .fmt button[aria-checked="true"] { background: var(--ink); color: var(--paper); }

.sets { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.band {
  --cut: 60%;
  position: relative; width: 100%; min-height: 78px; padding: 10px 14px; border: 0; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px;
  background: var(--a); color: var(--at); overflow: hidden; isolation: isolate;
  transition: transform .18s;
}
.band::before {
  content: ''; position: absolute; inset: 0; z-index: -1; background: var(--b);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% 100%, calc(var(--cut) - 9%) 100%);
  transition: clip-path .35s cubic-bezier(.2, .8, .2, 1);
}
.band:hover::before, .band:focus-visible::before { --cut: 66%; }
.band:active { transform: scale(.985); }
.band-name { font: 400 27px/1.05 var(--display); }
.band-ex { grid-column: 1; margin-top: 5px; font-size: 12.5px; line-height: 1.35; font-weight: 600; max-width: 62%;
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.band-n { grid-row: 1 / span 2; grid-column: 2; color: var(--bt); font: 400 15px/1 var(--display); text-align: right; }
.band-n b { display: block; font-size: 30px; font-weight: 400; }
.band.custom { background: var(--paper); color: var(--ink); outline: 2.5px solid var(--ink); outline-offset: -2.5px; }
.band.custom::before { background: repeating-linear-gradient(-45deg, var(--a) 0 10px, var(--b) 10px 20px); }
.band.custom .band-n { color: var(--paper); }

@media (min-width: 900px) {
  .home { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); column-gap: 56px; padding-top: 96px; align-items: start; }
  .home > .title, .home > .lede, .home > .count { grid-column: 1; }
  .home > .sets { grid-column: 2; grid-row: 1 / span 3; }
  .title { font-size: clamp(110px, 12vw, 176px); }
  .lede { font-size: 18px; }
  .band { min-height: 84px; }
}

/* ── 플레이: 화면을 반으로 가르는 두 잉크 ───── */
.play { position: fixed; inset: 0; z-index: 40; overflow: hidden; background: var(--ink); touch-action: manipulation; }
.half {
  position: absolute; left: 0; right: 0; margin: 0; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 64px 22px 30px;
  background: var(--a); color: var(--at);
  transition: height .46s cubic-bezier(.2, .85, .2, 1), width .46s cubic-bezier(.2, .85, .2, 1), transform .5s cubic-bezier(.55, 0, .8, .25);
  -webkit-user-select: none; user-select: none;
}
.half.a { top: 0; height: 50%; z-index: 1; }
.half.b { bottom: 0; height: 50%; background: var(--b); color: var(--bt); padding: 30px 22px 40px; }
.opt {
  display: block; max-width: 15em; text-align: center; overflow-wrap: anywhere;
  font: 400 var(--fs, 44px)/1.13 var(--display); letter-spacing: -.01em;
  text-shadow: .045em .04em 0 var(--shadow, transparent);
  transition: transform .5s cubic-bezier(.2, .9, .2, 1.2);
}
.half.a .opt { --shadow: color-mix(in srgb, var(--b) 55%, transparent); }
.half.b .opt { --shadow: color-mix(in srgb, var(--a) 55%, transparent); }
.half:focus-visible { outline: 4px solid currentColor; outline-offset: -10px; }
.opt-wrap { position: relative; display: block; }
.stamp {
  position: absolute; right: -6px; top: -46px; padding: 6px 12px 4px; border: 4px solid currentColor;
  font: 400 30px/1 var(--display); transform: rotate(-12deg) scale(2.4); opacity: 0; pointer-events: none;
}
.seam {
  position: absolute; z-index: 3; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px;
  display: grid; place-items: center; border-radius: 50%; background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); font: 400 21px/1 var(--display); pointer-events: none;
  transition: transform .3s cubic-bezier(.3, 1.6, .5, 1), opacity .2s;
}
.seam b { font-weight: 400; transform: translateY(1px); }

/* 고름: 고른 잉크가 다 덮고, 다른 잉크는 비스듬히 쓸려 나간다 */
.play[data-pick="a"] .half.a { height: 100%; }
.play[data-pick="a"] .half.b { transform: translateY(110%) skewY(-9deg); }
.play[data-pick="b"] .half.b { height: 100%; z-index: 2; }
.play[data-pick="b"] .half.a { transform: translateY(-110%) skewY(-9deg); }
.play[data-pick] .seam { transform: scale(0) rotate(90deg); opacity: 0; }
.play[data-pick="a"] .half.a .opt, .play[data-pick="b"] .half.b .opt { transform: scale(1.08); }
.play[data-pick="a"] .half.a .stamp, .play[data-pick="b"] .half.b .stamp { animation: stamp .34s cubic-bezier(.3, 1.5, .5, 1) .12s forwards; }
@keyframes stamp { to { transform: rotate(-12deg) scale(1); opacity: 1; } }

/* 들어옴: 두 잉크가 위아래(좌우)에서 쾅 맞부딪친다 */
.play.pre .half, .play.pre .seam { transition: none !important; }
.play.pre .half.a { transform: translateY(-100%); }
.play.pre .half.b { transform: translateY(100%); }
.play.pre .seam { transform: scale(0); }
.play.slam .half { transition: transform .4s cubic-bezier(.25, 1.35, .5, 1); }
.play.slam .seam { transition-delay: .26s; }
.play.shake { animation: shake .26s .3s; }
@keyframes shake { 25% { transform: translate(0, 4px); } 55% { transform: translate(0, -3px); } 80% { transform: translate(0, 1px); } }

@media (min-aspect-ratio: 1/1) {
  .half { top: 0; bottom: 0; height: auto; padding: 80px 5vw 60px; }
  .half.a { left: 0; right: auto; width: 50%; height: auto; }
  .half.b { left: auto; right: 0; width: 50%; height: auto; padding: 80px 5vw 60px; }
  .seam { width: 84px; height: 84px; margin: -42px 0 0 -42px; font-size: 28px; }
  .play[data-pick="a"] .half.a { width: 100%; height: auto; }
  .play[data-pick="a"] .half.b { transform: translateX(110%) skewX(-9deg); }
  .play[data-pick="b"] .half.b { width: 100%; height: auto; }
  .play[data-pick="b"] .half.a { transform: translateX(-110%) skewX(-9deg); }
  .play.pre .half.a { transform: translateX(-100%); }
  .play.pre .half.b { transform: translateX(100%); }
  @keyframes shake { 25% { transform: translate(4px, 0); } 55% { transform: translate(-3px, 0); } 80% { transform: translate(1px, 0); } }
}

/* ── 카드·소개·공개·만들기 공통 ─────────── */
.card-in, .intro-in, .reveal-in, .maker-in {
  max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 66px) 16px 40px;
}
.v-title { margin: 0; font: 400 38px/1.05 var(--display); letter-spacing: -.01em; }
.v-title.big { font-size: clamp(40px, 11vw, 64px); }
.v-sub { margin: 10px 0 18px; font-size: 15.5px; line-height: 1.6; }
.name-field { display: grid; gap: 4px; margin: 0 0 16px; }
.name-field span { font-size: 13.5px; font-weight: 700; }
.name-field input, .mk-rows input {
  width: 100%; min-width: 0; height: 48px; padding: 0 12px; border: 2.5px solid var(--ink); border-radius: 0; background: var(--paper);
  font-size: 17px; font-weight: 600; outline: none;
}
.name-field input:focus, .mk-rows input:focus { box-shadow: inset 0 -5px 0 var(--a); }
.fmt { display: flex; gap: 6px; margin: 0 0 12px; }
.preview { margin: 0 0 16px; display: grid; place-items: center; }
.preview img { display: block; max-width: 100%; max-height: 64svh; width: auto; height: auto; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); background: var(--paper); }
.preview img:not([src]) { width: 100%; aspect-ratio: 9 / 16; max-height: 64svh; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acts.minor { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; margin-top: 14px; }
.btn {
  height: 54px; padding: 0 14px; border: 2.5px solid var(--ink); border-radius: 0; background: var(--paper); cursor: pointer;
  font-weight: 800; font-size: 16px; white-space: nowrap;
}
.btn.primary { background: var(--a); color: var(--at); }
.btn.wide { width: 100%; margin-top: 4px; }
.btn:active { transform: translateY(2px); }
.link {
  background: none; border: 0; padding: 10px 2px; cursor: pointer; font-size: 14.5px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1.5px;
}
.card-in > .acts { margin-bottom: 18px; }
@media (min-width: 900px) {
  .card-in { max-width: 1040px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 470px); column-gap: 56px; align-items: start; }
  .card-in > * { grid-column: 1; }
  .card-in > .preview { grid-column: 2; grid-row: 1 / span 9; }
  .card-in .preview img { max-height: calc(100svh - 120px); }
  .card-in .v-title { font-size: 52px; }
}
.go { display: block; width: min(100%, 360px); margin: 0 auto 22px; font-size: 17px; animation: ring 1.6s ease-out infinite; }
.go[hidden] { display: none; }
@keyframes ring { from { box-shadow: 0 0 0 0 var(--ink); } to { box-shadow: 0 0 0 12px transparent; } }
.verdict.wait { opacity: .5; transform: none; font: 700 15px/1.6 var(--ui); }
.note { margin: 12px 0 0; font-size: 13.5px; line-height: 1.55; text-align: center; }

/* 친구가 받은 화면 */
.intro { background: var(--a); color: var(--at); }
.intro .name-field input { background: var(--paper); color: var(--ink); }
.intro .btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.intro .link { display: block; margin: 8px auto 0; }
.intro-from { margin: 0 0 8px; font-weight: 800; font-size: 15px; }
.intro-in { padding-top: calc(env(safe-area-inset-top) + 92px); }
.intro-qh { margin: 0 0 6px; font-size: 13.5px; font-weight: 800; }
.intro-q { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 6px; }
.intro-q li { display: flex; align-items: stretch; font-weight: 700; font-size: 13.5px; line-height: 1.35; }
.intro-q span { flex: 1; overflow-wrap: anywhere; padding: 8px 10px; background: var(--paper); color: var(--ink); }
.intro-q span + span { background: var(--b); color: var(--bt); }

/* 일치율 공개 */
.reveal-in { text-align: center; }
.reveal-head { position: sticky; top: 0; z-index: 3; background: var(--paper); padding: 6px 0 4px; margin: 0 -16px; }
.reveal.done .reveal-head { position: static; }
.after .acts { margin: 0 0 22px; }
.pair { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 0; font: 400 22px/1 var(--display); }
.who { padding: 8px 12px 6px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who.a { background: var(--a); color: var(--at); }
.who.b { background: var(--b); color: var(--bt); }
.pct { position: relative; margin: 12px 0 0; font: 400 clamp(104px, 32vw, 210px)/.9 var(--display); letter-spacing: -.03em;
  color: var(--a); font-variant-numeric: tabular-nums; }
.pct span { display: inline-block; min-width: 1.2ch; text-shadow: .045em .035em 0 color-mix(in srgb, var(--b) 80%, transparent); }
.pct small { font-size: .38em; vertical-align: .9em; margin-left: .04em; }
.verdict { margin: 8px 0 22px; min-height: 1.2em; font: 400 26px/1.2 var(--display); opacity: 0; transform: scale(1.8) rotate(-4deg); }
.verdict.on { animation: verdict .4s cubic-bezier(.3, 1.5, .5, 1) forwards; }
@keyframes verdict { to { opacity: 1; transform: scale(1) rotate(-2deg); } }
.rows { list-style: none; margin: 0 0 26px; padding: 0; display: grid; gap: 6px; text-align: left; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 2px solid var(--ink); opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .22s; position: relative; }
.row.on { opacity: 1; transform: none; }
.row .cell { overflow-wrap: anywhere; padding: 9px 10px 8px; font-size: 13.5px; font-weight: 700; line-height: 1.35; display: flex; flex-direction: column; gap: 6px; }
.row .cell + .cell { border-left: 2px solid var(--ink); }
.row .tags { display: flex; gap: 4px; flex-wrap: wrap; min-height: 20px; }
.row .t { font: 800 11.5px/1 var(--ui); padding: 4px 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .t.a { background: var(--a); color: var(--at); }
.row .t.b { background: var(--b); color: var(--bt); }
.row.split { border-width: 3px; }
.row.split::after {
  content: '갈림'; position: absolute; right: -6px; top: -10px; padding: 3px 6px 2px; background: var(--ink); color: var(--paper);
  font: 400 13px/1 var(--display); transform: rotate(6deg);
}
.row.same .cell.picked { background: color-mix(in srgb, var(--a) 22%, var(--paper)); }
.after { opacity: 0; visibility: hidden; transition: opacity .4s, visibility 0s .4s; }
.after.on { opacity: 1; visibility: visible; transition: opacity .4s; }

/* 직접 만들기 */
.mk-rows { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 12px; counter-reset: mk; }
.mk-rows li { display: grid; grid-template-columns: 1fr auto; gap: 4px 6px; counter-increment: mk; position: relative; padding-left: 28px; }
.mk-rows li::before { content: counter(mk); position: absolute; left: 0; top: 12px; font: 400 18px/1 var(--display); }
.mk-rows input { height: 44px; font-size: 16px; }
.mk-rows input.a { border-color: var(--ink); box-shadow: inset 6px 0 0 var(--a); padding-left: 16px; }
.mk-rows input.b { grid-column: 1; box-shadow: inset 6px 0 0 var(--b); padding-left: 16px; }
.mk-rows .del { grid-row: 1 / span 2; grid-column: 2; width: 36px; border: 0; background: none; cursor: pointer; font-size: 22px; line-height: 1; }
.mk-err { min-height: 1.4em; margin: 6px 0; font-size: 14px; font-weight: 700; color: #B3122E; }
.maker .link { display: block; margin: 6px auto 0; }
#mkAdd { margin: 0; }

.toast {
  position: fixed; z-index: 95; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 22px); transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px); padding: 11px 16px; background: var(--ink); color: var(--paper); font-size: 14.5px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── 아래 설명서 ─────────────────────── */
.guide { position: relative; z-index: 5; background: var(--paper); border-top: 3px solid var(--ink); content-visibility: auto; contain-intrinsic-size: auto 2200px; }
.guide-in { max-width: 680px; margin: 0 auto; padding: 44px 20px 64px; }
.guide h2 { margin: 0 0 14px; font: 400 27px/1.2 var(--display); }
.guide h3 { margin: 36px 0 10px; font: 800 19px/1.4 var(--ui); }
.guide p, .guide li, .guide dd { font-size: 16px; line-height: 1.75; }
.guide p { margin: 0 0 12px; }
.guide a { color: var(--ink); text-underline-offset: 3px; }
.steps { margin: 0; padding-left: 1.3em; }
.steps li { margin: 0 0 10px; }
.steps b, .more b { display: block; }
.samples, .faq { margin: 0; }
.samples > div, .faq .qa { padding: 12px 0; border-top: 1.5px solid var(--ink); }
.samples dt, .faq dt { font-weight: 800; }
.samples dd, .faq dd { margin: 4px 0 0; }
.when { margin: 0; padding-left: 1.2em; }
.more ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.more a { display: block; padding: 10px 12px; border: 2px solid var(--ink); text-decoration: none; }
.more a:hover { background: var(--ink); color: var(--paper); }
.fallback { padding: 16px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}
