/* 딴짓 · 클릭 속도 테스트 — 택배 상자 위 뽁뽁이 */
:root {
  --kraft: #c8975b; --kraft-2: #b5844a; --kraft-3: #a8763d;
  --paper: #fbfaf5; --ink: #1b1a17; --ink-2: #4a463f; --ink-3: #8b8475;
  --red: #d42a1f; --tape: rgba(232, 214, 168, .9);
  --num: "Black Han Sans", "IBM Plex Sans KR", sans-serif;
  --ui: "IBM Plex Sans KR", system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
body {
  margin: 0; min-height: 100svh; color: var(--ink); font: 500 16px/1.6 var(--ui); overflow-x: hidden;
  background-color: var(--kraft);
  background-image:
    repeating-linear-gradient(90deg, rgba(90, 55, 15, .05) 0 2px, transparent 2px 11px),
    radial-gradient(ellipse at 20% 10%, rgba(255, 235, 200, .25), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(80, 45, 10, .18), transparent 60%);
}
button { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; max-width: 1080px; margin: 0 auto; position: relative; z-index: 2; }
.logo { font: 400 21px/1 var(--num); color: var(--ink); text-decoration: none; background: var(--paper); padding: 7px 10px 6px; border: 2px solid var(--ink); }
.chip { appearance: none; border: 2px solid var(--ink); background: var(--paper); padding: 6px 12px; min-height: 40px; font-weight: 700; font-size: 14px; cursor: pointer; border-radius: 999px; }
.chip[aria-pressed="false"] { background: transparent; }

/* 박스 테이프 */
.tape { position: absolute; left: 0; right: 0; top: 0; height: 64px; overflow: hidden; z-index: 1; pointer-events: none; }
.tape span { position: absolute; left: -5%; right: -5%; top: 8px; height: 46px; background: var(--tape); transform: rotate(-1.2deg); white-space: nowrap; overflow: hidden; box-shadow: 0 2px 0 rgba(90, 55, 15, .12);
  background-image: linear-gradient(180deg, rgba(255,255,255,.35), transparent 40%, rgba(120,90,40,.12));
  padding: 13px 0 0 8%; font: 700 15px/1 var(--ui); color: rgba(212, 42, 31, .75); letter-spacing: .08em; }

.stage { max-width: 1080px; margin: 0 auto; padding: 4px 16px 24px; display: grid; gap: 12px; }

/* 운송장 라벨 = 기록판 */
.label { position: relative; background: var(--paper); border: 2px solid var(--ink); padding: 0; box-shadow: 0 6px 0 rgba(90, 55, 15, .25); }
.l-head { display: flex; align-items: stretch; border-bottom: 2px solid var(--ink); }
.carrier { display: inline-flex; align-items: center; background: var(--ink); color: var(--paper); font: 400 16px/1 var(--num); padding: 0 10px; letter-spacing: .02em; }
.label h1 { margin: 0; padding: 8px 12px 7px; font: 700 20px/1.2 var(--ui); letter-spacing: -.01em; }
.label h1 small { font: 400 14px/1 var(--num); color: var(--paper); background: var(--red); padding: 3px 6px 2px; margin-left: 4px; vertical-align: 2px; }
.l-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.st { padding: 6px 10px 6px; border-right: 1px solid var(--ink); display: flex; flex-direction: column; }
.st:last-child { border-right: 0; }
.st span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.st b { font: 400 34px/1.05 var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.bar { display: block; height: 6px; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 5px); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); position: relative; }
.bar i { position: absolute; inset: 0; background: var(--red); transform-origin: 0 50%; transform: scaleX(0); }
.l-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
.modes { display: inline-flex; border: 2px solid var(--ink); }
.modes button { appearance: none; border: 0; border-right: 2px solid var(--ink); background: var(--paper); min-width: 56px; min-height: 40px; font-weight: 700; font-size: 15px; cursor: pointer; padding: 0 10px; }
.modes button:last-child { border-right: 0; }
.modes button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.modes button:disabled { cursor: not-allowed; opacity: .55; }
.best { margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: right; }
.best b { color: var(--ink); }
.vs { margin: 0; padding: 7px 10px; border-top: 2px dashed var(--ink); font-size: 14px; font-weight: 600; background: #fff3c4; }
.vs b { font: 400 17px/1 var(--num); color: var(--red); }
.vs .vsgo { appearance: none; margin-left: 4px; min-height: 36px; padding: 0 10px; border: 2px solid var(--ink); background: var(--paper); font-weight: 700; font-size: 13px; cursor: pointer; }
.stop { appearance: none; min-height: 40px; padding: 0 12px; border: 2px solid var(--red); background: var(--paper); color: var(--red); font-weight: 700; font-size: 14px; cursor: pointer; }
.stop[hidden] { display: none; }
.recent-box { display: none; border-top: 2px solid var(--ink); padding: 8px 12px 10px; }
.rlab { margin: 0 0 4px; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.recent { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.recent li { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed rgba(27,26,23,.25); }
.recent li b { font: 400 17px/1.2 var(--num); }
.recent li.none { color: var(--ink-3); border: 0; }

/* 뽁뽁이 판 */
.wrap { position: relative; height: clamp(320px, calc(100svh - 300px), 640px); border-radius: 6px; }
.wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#sheet { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; cursor: pointer; outline: none; border-radius: 6px; }
#sheet:focus-visible { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--ink); }
#fx { pointer-events: none; }
.hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; padding: 10px 18px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 16px; border-radius: 999px; pointer-events: none; white-space: nowrap; box-shadow: 0 4px 0 rgba(0,0,0,.2); animation: bob 1.6s ease-in-out infinite; }
.hint small { font-size: 12px; font-weight: 600; opacity: .8; }
@media (hover: none) { .hint small { display: none; } }
.hint[hidden] { display: none; }
.more { display: block; width: max-content; margin: 2px auto 0; padding: 12px 8px; color: var(--ink); font-weight: 700; font-size: 14px; text-underline-offset: 3px; }
@keyframes bob { 50% { transform: translate(-50%, calc(-50% - 5px)); } }

/* 결과 = 운송장 */
.result { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 92svh; overflow-y: auto; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); background: rgba(40, 26, 10, .55); display: flex; flex-direction: column; align-items: center; gap: 12px; animation: up .35s cubic-bezier(.2, .9, .3, 1.1) both; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.result[hidden] { display: none; }
@keyframes up { from { transform: translateY(100%); } }
.waybill { position: relative; flex-shrink: 0; width: min(100%, 420px); background: var(--paper); border: 2px solid var(--ink); padding: 0 0 14px; transform: rotate(-.8deg); box-shadow: 0 10px 0 rgba(0, 0, 0, .18); overflow: hidden; }
.w-head { display: flex; justify-content: space-between; align-items: stretch; margin: 0; border-bottom: 2px solid var(--ink); font-size: 13px; font-weight: 600; }
.w-head .carrier { padding: 6px 10px; }
.w-head > span:last-child { padding: 6px 10px; }
.w-head b { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.w-to { margin: 0; padding: 6px 12px; border-bottom: 1px solid var(--ink); font-size: 13px; color: var(--ink-2); display: flex; gap: 6px; align-items: baseline; }
.w-to b { color: var(--ink); font-size: 15px; }
.w-to span { font-weight: 700; color: var(--ink); border: 1.5px solid var(--ink); padding: 0 6px; font-size: 12px; }
.waybill h2 { margin: 10px 0 0; text-align: center; line-height: 1; }
.waybill h2 b { font: 400 clamp(84px, 26vw, 112px)/.95 var(--num); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.waybill h2 small { font: 400 26px/1 var(--num); margin-left: 6px; color: var(--red); }
.grade { margin: 6px 0 0; text-align: center; font: 400 28px/1.2 var(--num); }
.gdesc { margin: 2px 16px 0; text-align: center; font-size: 14px; color: var(--ink-2); word-break: keep-all; }
.w-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 12px 0 0; border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.w-grid div { padding: 6px 4px; text-align: center; border-right: 1px solid var(--ink); }
.w-grid div:last-child { border-right: 0; }
.w-grid dt { font-size: 11px; font-weight: 600; color: var(--ink-2); word-break: keep-all; line-height: 1.25; }
.w-grid dd { margin: 2px 0 0; font: 400 20px/1.1 var(--num); }
.w-note, .w-vs { margin: 10px 14px 0; font-size: 14px; font-weight: 600; text-align: center; word-break: keep-all; }
.w-note { color: var(--ink-2); }
.w-vs { text-wrap: balance; }
.result.lock .acts { pointer-events: none; opacity: .45; }
.result:focus { outline: none; }
.bars { margin: 10px 16px 0; }
.bars-in { display: flex; align-items: flex-end; gap: 3px; height: 46px; border-bottom: 2px solid var(--ink); }
.bars-in i { flex: 1; height: calc(6px + var(--h) * 40px); background: var(--ink); }
.bars p { margin: 3px 0 0; font-size: 11px; font-weight: 600; color: var(--ink-2); text-align: center; }
.copybox { margin: 0; width: min(100%, 420px); font-size: 14px; font-weight: 600; color: var(--paper); }
.copybox input { display: block; width: 100%; margin-top: 6px; min-height: 44px; padding: 8px 10px; border: 2px solid var(--ink); border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
.copybox[hidden] { display: none; }
.w-vs { background: #fff3c4; border: 1.5px solid var(--ink); padding: 6px 8px; }
.stamp.vs { font-size: 40px; line-height: 62px; }
.stamp.lose { border-color: rgba(35,72,179,.85); color: rgba(35,72,179,.85); }
.stamp { position: absolute; right: 8px; top: 30px; width: 74px; height: 74px; border: 4px solid rgba(212, 42, 31, .85); border-radius: 50%; color: rgba(212, 42, 31, .85); font: 400 17px/66px var(--num); text-align: center; transform: rotate(-16deg); pointer-events: none; }
.result:not([hidden]) .stamp { animation: stamp .3s .45s cubic-bezier(.2, 1.8, .4, 1) both; }
@keyframes stamp { from { transform: rotate(-16deg) scale(2.2); opacity: 0; } }
.barcode { display: block; height: 34px; margin: 12px 16px 0; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 7px, transparent 7px 8px, var(--ink) 8px 9px, transparent 9px 13px); }
.acts { width: min(100%, 420px); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn { appearance: none; min-height: 50px; border: 2px solid var(--ink); background: var(--paper); font-weight: 700; font-size: 16px; cursor: pointer; border-radius: 10px; box-shadow: 0 3px 0 var(--ink); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn.main { grid-column: 1 / -1; background: #fee500; font-size: 17px; }

/* 설명서 */
.guide { position: relative; max-width: 760px; margin: 28px auto 0; padding: 28px 20px 40px; background: var(--paper); border-top: 3px solid var(--ink); content-visibility: auto; contain-intrinsic-size: auto 1900px; }
.guide h2 { font: 400 25px/1.3 var(--num); margin: 28px 0 10px; text-wrap: balance; }
.guide section:first-of-type h2 { margin-top: 8px; }
.guide p, .guide li, .guide dd { word-break: keep-all; }
.guide ol { padding-left: 1.3em; }
.faq dl { margin: 0; }
.faq dt { font-weight: 700; margin-top: 14px; }
.faq dd { margin: 4px 0 0; color: var(--ink-2); }
.grades { padding-left: 1.1em; }
.grades b { font-variant-numeric: tabular-nums; }
.others { padding-left: 1.1em; }
.others a { font-weight: 700; color: var(--ink); display: inline-block; padding: 8px 0; }
.tips { padding-left: 1.1em; }
.tips b { margin-right: 4px; }
.site-foot { margin-top: 32px; font-size: 14px; display: flex; gap: 8px; }
.site-foot a { color: var(--ink-2); display: inline-block; padding: 12px 0; }

@media (min-width: 900px) {
  .stage { grid-template-columns: 340px 1fr; align-items: start; gap: 20px; padding-top: 18px; }
  .label { position: sticky; top: 16px; }
  .wrap { height: clamp(420px, calc(100svh - 150px), 640px); }
  .l-stats { grid-template-columns: 1fr; }
  .st { border-right: 0; border-bottom: 1px solid var(--ink); flex-direction: row; justify-content: space-between; align-items: baseline; padding: 8px 12px; }
  .st:last-of-type { border-bottom: 0; }
  .st b { font-size: 44px; }
  .l-foot { flex-direction: column; align-items: stretch; }
  .modes { width: 100%; } .modes button { flex: 1; }
  .best { text-align: left; }
  .recent-box { display: block; }
  .more { margin-left: 360px; }
  .result { align-items: center; justify-content: center; inset: 0; max-height: none; flex-direction: row; flex-wrap: wrap; align-content: center; }
  .acts { width: 300px; grid-template-columns: 1fr; }
  .btn.main { grid-column: auto; }
}
@media (orientation: landscape) and (max-height: 520px) and (max-width: 899px) {
  .stage { grid-template-columns: minmax(0, 300px) 1fr; align-items: start; padding-top: 6px; }
  .wrap { height: calc(100svh - 76px); min-height: 260px; }
  .l-stats { grid-template-columns: 1fr; }
  .st { border-right: 0; border-bottom: 1px solid var(--ink); flex-direction: row; justify-content: space-between; align-items: baseline; padding: 4px 10px; }
  .st b { font-size: 26px; }
  .tape { display: none; }
  .result { flex-direction: row; flex-wrap: wrap; justify-content: center; align-content: flex-start; }
  .acts { width: 240px; grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .hint, .result, .result:not([hidden]) .stamp { animation: none; }
}
