:root {
  --black: #0a0a0a;
  --blue: #213fa6;    /* 디자인 시스템의 파란 버튼 색. 맞게 친 글자에만 씀 */
  --white: #fff;
  --paper: #f4f4f4;   /* 프레임 안 배경 (2024 이벤트와 같은 연회색) */
  --outside: #e6e6e6; /* PC에서 프레임 바깥 */
  --sub: #777;
  --frame: 480px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  --display: "Archivo Black", var(--font);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--outside);
  color: var(--black);
  font-family: var(--font);
  line-height: 1.6;
  letter-spacing: -.01em;
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.frame { max-width: var(--frame); margin: 0 auto; min-height: 100vh; background: var(--paper); }

/* ── 헤더 ───────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 8px;
  background: var(--black); color: var(--white);
}
.wordmark { font-family: var(--display); font-size: 14px; letter-spacing: .01em; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; transition: background .2s, transform .2s var(--ease); }
.icon-btn:active { transform: scale(.9); }
@media (hover: hover) { .icon-btn:hover { background: rgba(255, 255, 255, .12); } }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.icon-btn svg .fill { fill: currentColor; stroke: none; }

/* ── 1. 첫 화면 ─────────────────────── */
.hero {
  --p: 0; /* 꾹 누른 정도 0~1, JS가 채움 */
  min-height: calc(100svh - 52px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 48px;
  padding: 24px 28px 72px;
  transition: opacity .45s var(--ease), transform .55s var(--ease);
}
.hero-char {
  width: 200px; height: auto;
  mix-blend-mode: multiply;
  /* 누를수록 커지고 떨림 */
  transform: scale(calc(1 + var(--p) * .12)) rotate(calc(var(--shake, 0) * 1deg));
  animation: fade .9s var(--ease) both;
}

/* 진행률 버튼 (lucianLabs #004 기반) */
.enter { position: relative; height: 66px; display: flex; justify-content: center; animation: fade .9s .12s var(--ease) both; }
.enter-btn {
  --p: 0;
  position: relative; overflow: hidden; isolation: isolate;
  display: block; width: 268px; height: 66px;
  border-radius: 999px;
  background: var(--black); color: var(--white);
  box-shadow: 0 22px 36px -22px rgba(0, 0, 0, .5);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none; /* 꾹 누르는 중 손가락이 조금 움직여도 스크롤로 넘어가며 끊기지 않게 */
  transition: width .6s var(--ease), transform .5s var(--spring);
}
@media (hover: hover) { .enter[data-state="idle"] .enter-btn:hover { transform: translateY(-2px); } }
.enter[data-state="run"] .enter-btn { transform: scale(.97); }
.enter-btn:focus-visible { outline: 2px solid var(--black); outline-offset: 4px; }
.enter-btn.is-nudge { animation: nudge .45s var(--spring); }
@keyframes nudge { 20% { transform: translateX(-6px); } 45% { transform: translateX(5px); } 70% { transform: translateX(-3px); } }

.enter-idle, .enter-run, .enter-ok {
  position: absolute; inset: 0;
  display: flex; align-items: center;
  transition: opacity .35s var(--ease), transform .5s var(--ease);
}
.enter-idle { gap: 14px; padding: 0 24px 0 9px; }
.enter-arw { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .14); overflow: hidden; }
.enter-arw svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.enter-a { transition: transform .5s var(--ease); }
@media (hover: hover) { .enter-btn:hover .enter-a { animation: bob 1s var(--ease) infinite; } }
@keyframes bob { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }
.enter-idle b { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }

/* 누르는 중: 버튼 바탕이 막대가 됨 */
.enter-track { position: absolute; inset: 0; background: #2b2b2b; opacity: 0; transition: opacity .4s var(--ease); }
.enter-bar { position: absolute; inset: 0; background: var(--white); transform-origin: 0 50%; transform: scaleX(var(--p)); border-radius: inherit; }
.enter-bar::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(0, 0, 0, .08) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: shine 1.3s linear infinite;
}
@keyframes shine { from { background-position: 120% 0; } to { background-position: -100% 0; } }
/* 흰 막대 위에서는 글자가 검게 뒤집힘 */
.enter-run { justify-content: space-between; padding: 0 26px; opacity: 0; transform: translateY(12px); color: var(--white); mix-blend-mode: difference; }
.enter-run b { font-size: 19px; font-weight: 760; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.enter-run small { font-size: 13px; font-weight: 600; opacity: .82; }

.enter-ok { justify-content: center; gap: 10px; opacity: 0; transform: scale(.6); }
.enter-ok i { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .18); }
.enter-ok svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.enter-ok path { stroke-dasharray: 18; stroke-dashoffset: 18; transition: stroke-dashoffset .45s var(--ease) .25s; }
.enter-ok > span { font-size: 16px; font-weight: 700; white-space: nowrap; max-width: 0; overflow: hidden; opacity: 0; transition: max-width .6s var(--ease), opacity .4s var(--ease); }

.enter[data-state="run"] .enter-idle { opacity: 0; transform: translateY(-12px); }
.enter[data-state="run"] .enter-a { transform: translateX(26px); }
.enter[data-state="run"] .enter-track { opacity: 1; }
.enter[data-state="run"] .enter-run { opacity: 1; transform: none; }
.enter[data-state="fold"] .enter-idle, .enter[data-state="done"] .enter-idle { opacity: 0; }
.enter[data-state="fold"] .enter-btn { width: 66px; }
.enter[data-state="fold"] .enter-ok, .enter[data-state="done"] .enter-ok { opacity: 1; transform: none; }
.enter[data-state="fold"] .enter-ok path, .enter[data-state="done"] .enter-ok path { stroke-dashoffset: 0; }
.enter[data-state="done"] .enter-btn { width: 200px; transition-timing-function: var(--spring); }
.enter[data-state="done"] .enter-ok > span { max-width: 200px; opacity: 1; }
.enter-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.hero.is-done .hero-char { animation: gulp .5s var(--spring) forwards; }
.hero.is-leaving { opacity: 0; transform: translateY(-12px); }
@keyframes gulp { 40% { transform: scale(1.22) rotate(-6deg); } 100% { transform: scale(1.05); } }
@keyframes fade { from { opacity: 0; filter: blur(6px); } to { opacity: 1; filter: none; } }
@keyframes in { from { opacity: 0; transform: translateY(12px); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }

/* 화면 전환: 기본은 첫 화면, /#menu 이면 메뉴만 (JS 없이도 동작) */
.screen { display: none; scroll-margin-top: 52px; }
.screen:target { display: block; }
main:has(.screen:target) .hero { display: none; }

/* ── 2. 메뉴 ───────────────────────── */
/* 타이핑 입력창: 헤더 아래 붙어 있어 키보드가 올라와도 보임 */
.type {
  position: sticky; top: 52px; z-index: 5;
  display: block;
  padding: 24px 20px 16px;
  background: var(--paper);
}
.type-hint { display: block; font-size: 13px; font-weight: 600; color: var(--sub); }
.type-input {
  display: block; width: 100%;
  margin-top: 8px; padding: 6px 0 8px;
  border: 0; border-bottom: 2px solid var(--black); border-radius: 0;
  background: transparent; outline: none;
  font: inherit; font-size: 26px; font-weight: 800; letter-spacing: -.04em;
  caret-color: var(--black);
}
.type-input::placeholder { color: #c8c8c8; }
.type-input:focus::placeholder { color: transparent; } /* 누르면 예시 이름이 사라짐 */
.type-msg { display: block; min-height: 20px; margin-top: 6px; font-size: 13px; font-weight: 600; }
.type.is-wrong .type-input { animation: nudge .4s var(--spring); text-decoration: line-through; }

.list { list-style: none; border-top: 1.5px solid var(--black); }
.list li, .note { animation: in .7s var(--ease) both; animation-delay: calc(var(--i) * 70ms + 60ms); }
.list li { border-bottom: 1.5px solid var(--black); }

.row {
  --p: 0;
  position: relative;
  display: flex; flex-direction: column;
  padding: 26px 20px 24px;
  background: var(--paper);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
/* 꾹 누르는 동안 아래에서 차오름. 흰 막을 difference로 덮어서, 차오른 부분만 바탕은 검게·글자는 희게 뒤집힘 */
.row::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: var(--white); mix-blend-mode: difference;
  transform: scaleY(var(--p)); transform-origin: bottom;
  pointer-events: none;
}

/* 이름: 친 글자는 검정, 남은 글자는 회색, 그 사이에 깜빡이는 커서 */
.row-name { font-size: 30px; font-weight: 800; letter-spacing: -.045em; line-height: 1.2; color: #cfcfcf; }
.row-name .typed { color: var(--black); }
/* 이름을 다 맞게 치면 왼쪽부터 파랗게 쓸려 채워짐 */
.row.is-open .row-name .typed {
  color: transparent;
  background: linear-gradient(90deg, var(--blue) 50%, var(--black) 50%) 100% 0 / 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  animation: sweep .7s var(--ease) forwards;
}
@keyframes sweep { to { background-position: 0 0; } }
/* 누르는 동안엔 검정으로 돌려서 차오른 부분이 흰 글자로 뒤집히게 */
.row.is-open.is-holding .row-name .typed { color: var(--black); background: none; animation: none; }
.row-name .caret { display: inline-block; width: 2px; height: .9em; margin: 0 1px; vertical-align: -.08em; background: var(--black); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.row-desc { margin-top: 6px; font-size: 14px; opacity: .6; }

/* 이름을 다 치면 열림: 꾹 누르라는 표시가 나타남 */
.row-go {
  position: absolute; right: 20px; top: 50%;
  padding: 6px 12px; border-radius: 999px;
  background: var(--black); color: var(--white);
  font-size: 12px; font-weight: 700;
  opacity: 0; transform: translateY(-50%) scale(.8);
  transition: opacity .3s var(--ease), transform .4s var(--spring);
  pointer-events: none;
}
.row.is-open { cursor: pointer; touch-action: none; }
.row.is-open .row-go { opacity: 1; transform: translateY(-50%); }
.row:not(.is-open):not(.row--next) { cursor: text; }
.row--next { color: #aaa; }

.note { padding: 40px 20px 0; }
.note p { font-size: 14px; color: #444; }
.note p + p { margin-top: 10px; }
.note-link {
  display: inline-block; margin-top: 20px;
  font-size: 14px; font-weight: 600;
  border-bottom: 1.5px solid currentColor;
  transition: opacity .2s;
}
.note-link:active { opacity: .5; }

.foot { padding: 56px 20px calc(40px + env(safe-area-inset-bottom)); font-family: var(--display); font-size: 11px; color: #b0b0b0; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 999px;
  background: var(--black); color: var(--white); font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .hero-char, .enter, .enter-btn.is-nudge, .enter-bar::after, .list li, .note, .hero.is-done .hero-char { animation: none; }
}
