/* 둥근 고딕: 나눔스퀘어라운드 (네이버 한글 웹폰트 CDN) */
@font-face { font-family: 'NSR'; font-weight: 400; font-display: swap; src: url(https://hangeul.pstatic.net/hangeul_static/webfont/NanumSquareRound/NanumSquareRoundR.woff2) format('woff2'); }
@font-face { font-family: 'NSR'; font-weight: 700; font-display: swap; src: url(https://hangeul.pstatic.net/hangeul_static/webfont/NanumSquareRound/NanumSquareRoundB.woff2) format('woff2'); }
@font-face { font-family: 'NSR'; font-weight: 800; font-display: swap; src: url(https://hangeul.pstatic.net/hangeul_static/webfont/NanumSquareRound/NanumSquareRoundEB.woff2) format('woff2'); }

:root {
  --bg: #fffbea;
  --ink: #3f2c27;
  --ink-2: #77605a;
  --usa: #ffdb5c;       /* 우사기 노랑 */
  --usa-2: #ffcf2e;
  --stripe-a: #ffe48f;
  --stripe-b: #fff0bd;
  --note: #fffcc9;
  --hl: #ffeb99;
  --sans: 'NSR', -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --round: 'Jua', var(--sans);
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; margin: 0; }
html {
  color: var(--ink); -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cpath d='M39.5 25.0 L43.6 32.6 L52.2 33.5 L46.3 39.8 L48.1 48.2 L40.3 44.5 L32.8 48.8 L33.9 40.3 L27.5 34.5 L36.0 32.9Z' fill='%23ffd4dc' stroke='%23ffd4dc' stroke-width='3.6' stroke-linejoin='round'/%3E%3Cpath d='M150.4 14.0 L152.5 18.9 L157.7 19.9 L153.7 23.4 L154.4 28.7 L149.8 26.0 L145.0 28.2 L146.1 23.0 L142.5 19.1 L147.8 18.6Z' fill='%23ffe69b' stroke='%23ffe69b' stroke-width='2.2' stroke-linejoin='round'/%3E%3Cpath d='M250.4 46.0 L251.3 55.9 L260.0 60.8 L250.8 64.7 L248.8 74.5 L242.3 67.0 L232.4 68.1 L237.5 59.6 L233.4 50.5 L243.1 52.7Z' fill='%23ffe69b' stroke='%23ffe69b' stroke-width='4.2' stroke-linejoin='round'/%3E%3Cpath d='M94.7 101.0 L97.5 106.3 L103.5 107.0 L99.3 111.3 L100.5 117.1 L95.1 114.5 L89.9 117.4 L90.8 111.5 L86.4 107.5 L92.2 106.4Z' fill='%23ffe69b' stroke='%23ffe69b' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M200.1 128.0 L203.6 135.2 L211.4 136.4 L205.7 141.9 L207.0 149.8 L200.0 146.0 L192.9 149.7 L194.3 141.8 L188.6 136.2 L196.5 135.1Z' fill='%23ffe69b' stroke='%23ffe69b' stroke-width='3.4' stroke-linejoin='round'/%3E%3Cpath d='M28.8 160.0 L31.2 166.2 L37.7 167.6 L32.6 171.9 L33.2 178.5 L27.6 175.0 L21.5 177.6 L23.1 171.2 L18.8 166.2 L25.4 165.7Z' fill='%23ffd4dc' stroke='%23ffd4dc' stroke-width='2.8' stroke-linejoin='round'/%3E%3Cpath d='M125.9 185.6 L132.6 193.0 L142.5 191.7 L137.5 200.3 L141.8 209.3 L132.0 207.2 L124.8 214.1 L123.8 204.2 L115.0 199.4 L124.1 195.4Z' fill='%23ffe69b' stroke='%23ffe69b' stroke-width='4.2' stroke-linejoin='round'/%3E%3Cpath d='M265.1 211.0 L267.7 216.4 L273.6 217.3 L269.3 221.4 L270.2 227.3 L265.0 224.5 L259.6 227.2 L260.7 221.3 L256.5 217.1 L262.4 216.3Z' fill='%23ffe69b' stroke='%23ffe69b' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M71.2 251.1 L73.7 257.9 L80.8 259.8 L75.0 264.3 L75.4 271.6 L69.4 267.5 L62.6 270.1 L64.6 263.1 L60.0 257.4 L67.3 257.2Z' fill='%23ffe69b' stroke='%23ffe69b' stroke-width='3.1' stroke-linejoin='round'/%3E%3Cpath d='M192.0 262.3 L193.1 267.5 L198.0 269.5 L193.4 272.2 L192.9 277.5 L189.0 273.9 L183.8 275.1 L186.0 270.2 L183.3 265.7 L188.5 266.3Z' fill='%23ffe69b' stroke='%23ffe69b' stroke-width='2.2' stroke-linejoin='round'/%3E%3Cpath d='M282.9 134.4 L285.8 137.1 L289.7 136.3 L288.0 139.9 L290.0 143.3 L286.0 142.8 L283.4 145.8 L282.6 141.9 L279.0 140.2 L282.5 138.3Z' fill='%23ffd4dc' stroke='%23ffd4dc' stroke-width='1.7' stroke-linejoin='round'/%3E%3Cpath d='M9.0 84.1 L11.3 87.3 L15.3 87.2 L13.0 90.4 L14.3 94.2 L10.5 93.0 L7.4 95.4 L7.3 91.4 L4.1 89.1 L7.8 87.9Z' fill='%23ffe69b' stroke='%23ffe69b' stroke-width='1.7' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 300px;
}
body { font-family: var(--sans); font-weight: 700; min-height: 100svh; display: flex; flex-direction: column; }
::selection { background: var(--hl); color: var(--ink); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--ink); outline-offset: 3px; border-radius: 14px; }
.defs { position: absolute; }
.ic { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* 세로 줄무늬 띠 */
.band { background: repeating-linear-gradient(90deg, var(--stripe-a) 0 20px, var(--stripe-b) 20px 40px); }
.top {
  text-align: center; padding: max(22px, env(safe-area-inset-top)) 16px 18px;
  border-bottom: 2px solid var(--ink);
}
.title {
  font-family: var(--round); font-weight: 400; font-size: 2rem; line-height: 1.15; letter-spacing: .04em;
  color: var(--ink); -webkit-text-stroke: 7px #fff; paint-order: stroke fill;
}
.sub { margin-top: 4px; font-size: .72rem; font-weight: 800; letter-spacing: .28em; color: var(--ink); opacity: .7; }

.page {
  width: 100%; max-width: 520px; margin: 0 auto; flex: 1;
  padding: 26px 16px 8px; display: flex; flex-direction: column;
}

/* 카드: 굵은 갈색 테두리 + 왼쪽 위 꼬리표 */
.card { position: relative; isolation: isolate; background: #fff; border: 2px solid var(--ink); border-radius: 18px; padding: 40px 18px 12px; }
.tag {
  position: absolute; left: -2px; top: -2px;
  background: var(--ink); color: #fff; font-size: .8rem; font-weight: 800; letter-spacing: .06em;
  padding: 7px 14px 6px 15px; border-radius: 18px 0 14px 0;
}

.src textarea {
  display: block; width: 100%; border: 0; outline: 0; resize: none; background: none;
  font: inherit; font-weight: 700; font-size: 1.1rem; line-height: 1.6; color: var(--ink); caret-color: #e0a400;
  min-height: calc(1.6em * 3); field-sizing: content; max-height: 12em;
}
.src textarea::placeholder { color: var(--ink-2); font-weight: 400; }
.row { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-height: 28px; margin-top: 2px; }
.count { font-size: .75rem; font-weight: 400; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.clear { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: var(--ink-2); margin-right: -6px; }
.clear:hover { background: var(--note); color: var(--ink); }

.arrow { display: block; width: 18px; height: 24px; margin: 12px auto 12px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.out { background: var(--note); min-height: 140px; isolation: auto; }
.usagi { font-family: var(--round); font-size: 1.55rem; line-height: 1.5; word-break: keep-all; overflow-wrap: anywhere; }
.usagi .w { white-space: nowrap; }
.usagi.ko { font-family: var(--sans); font-size: 1.2rem; font-weight: 800; line-height: 1.6; }
.usagi.empty, .usagi.err { color: var(--ink-2); }
.usagi.err { font-family: var(--sans); font-size: 1rem; line-height: 1.5; }
.usagi.fresh { animation: fresh .28s var(--ease); }
@keyframes fresh { from { opacity: .35; } }

/* 결과가 나오면 단어가 하나씩 폴짝 */
.usagi.hop .w { display: inline-block; animation: hop .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes hop {
  0% { transform: none; }
  35% { transform: translateY(-.3em) rotate(-4deg); }
  70% { transform: translateY(.04em) rotate(1deg); }
}

/* 결과 칸 뒤로 귀 두 개, 쫑긋할 때 놀람 선 */
.ears {
  position: absolute; right: 26px; top: -44px; width: 54px; height: 54px; z-index: -1; overflow: visible;
  fill: #f7e5b8; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; cursor: pointer; /* 우사기 몸 색 */
}
.ears path { transform-box: fill-box; transform-origin: 50% 100%; }
.ears .l { transform: rotate(-6deg); }
.ears .r { transform: rotate(5deg); }
.ears.perk .l { animation: perk-l .7s var(--ease); }
.ears.perk .r { animation: perk-r .7s var(--ease) .06s; }
@keyframes perk-l { 30% { transform: rotate(-16deg) translateY(-4px); } 60% { transform: rotate(0deg); } }
@keyframes perk-r { 30% { transform: rotate(14deg) translateY(-5px); } 60% { transform: rotate(-1deg); } }
.ema {
  position: absolute; right: 80px; top: -48px; width: 28px; height: 28px; overflow: visible; pointer-events: none;
  fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round;
  opacity: 0; transform: scale(.6); transform-origin: 100% 100%;
}
.ema.on { animation: ema .8s var(--ease); }
@keyframes ema { 15%, 60% { opacity: 1; transform: none; } 100% { opacity: 0; transform: scale(1.06); } }

/* 버튼: 둥근 알약 */
.acts { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; margin-top: 18px; }
.pill {
  display: flex; align-items: center; justify-content: center; gap: 7px; height: 54px;
  background: #fff; border: 2px solid var(--ink); border-radius: 99px;
  font-size: 1.05rem; font-weight: 800; letter-spacing: .06em;
  transition: transform .12s var(--ease), background-color .15s;
}
.pill:hover { background: var(--note); }
.pill.primary { background: var(--usa); }
.pill.primary:hover { background: var(--usa-2); }
.pill:active { transform: scale(.96); }
.pill:disabled { background: #fff; color: #b9aaa3; border-color: #cbbdb6; pointer-events: none; }

/* 링크로 받은 말 */
.got { margin-bottom: 22px; padding: 16px 18px 18px; text-align: center; }
.shout { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: .95rem; font-weight: 800; letter-spacing: .08em; margin-bottom: 10px; }
.shout i { width: 2.4px; height: 18px; background: var(--ink); border-radius: 2px; transform: rotate(-28deg); }
.shout i:last-child { transform: rotate(28deg); }
.reveal { display: inline-flex; margin-top: 14px; height: 44px; padding: 0 24px; background: var(--usa); font-size: 1rem; }
.reveal:hover { background: var(--usa-2); }
.usagi.ko { animation: reveal .5s var(--ease); }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); filter: blur(3px); } }

.foot {
  margin-top: 40px; border-top: 2px solid var(--ink); text-align: center;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.foot p { display: inline-block; background: #fff; border: 2px solid var(--ink); border-radius: 99px; padding: 6px 14px; font-size: .72rem; line-height: 1.5; color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: calc(30px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  background: var(--ink); color: #fff; font-size: .95rem; font-weight: 800; padding: 11px 20px; border-radius: 99px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .3s var(--ease);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

[hidden] { display: none !important; }

@media (min-width: 640px) {
  .top { padding-top: 40px; padding-bottom: 26px; }
  .title { font-size: 2.4rem; }
  .page { padding-top: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
