:root {
  --pink: #ff3ea5; --lime: #c6f432; --aqua: #35d6e8; --lilac: #b8a1ff;
  --yellow: #ffe53d; --ink: #17151f; --stage: #35d6e8;
}
* { box-sizing: border-box; margin: 0; }
body {
  min-height: 100dvh; color: var(--ink); background: var(--yellow);
  font: 16px/1.5 Pretendard, "Malgun Gothic", system-ui, sans-serif;
  display: flex; flex-direction: column;
}
body[data-step="cord"] { --stage: var(--lilac); }
body[data-step="knot"] { --stage: var(--lime); }
body[data-step="thread"] { --stage: #ff9ad0; }
body[data-step="attach"] { --stage: var(--aqua); }
body[data-step="share"], body[data-step="gift"] { --stage: var(--lilac); }

.marquee { overflow: hidden; white-space: nowrap; background: var(--pink); color: #fff; font-weight: 800; border-bottom: 3px solid var(--ink); }
.marquee span { display: inline-block; padding: 4px 0; animation: slide 24s linear infinite; }
@keyframes slide { to { transform: translateX(-50%); } }

header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; }
.logo { font-size: 2.2rem; font-weight: 900; letter-spacing: -.04em; color: var(--pink); text-decoration: none; text-shadow: 3px 3px 0 var(--ink); }
.logo i { display: inline-block; width: 14px; height: 24px; margin-left: 6px; border: 3px solid var(--ink); border-radius: 10px; transform: rotate(25deg); }
#progress { display: flex; gap: 6px; list-style: none; padding: 0; }
#progress li { padding: 2px 10px; border: 2px solid var(--ink); border-radius: 99px; background: #fff; font-size: .8rem; font-weight: 700; }
#progress li.on { background: var(--ink); color: var(--lime); }

main { flex: 1; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr); gap: 20px; padding: 0 20px 20px; min-height: 0; }
.stage, .panel { border: 3px solid var(--ink); border-radius: 28px; box-shadow: 6px 6px 0 var(--ink); }
.stage {
  position: relative; display: flex; justify-content: center; align-items: center; overflow: hidden;
  background: radial-gradient(#ffffff90 2px, transparent 3px) 0 0 / 26px 26px, var(--stage);
  transition: background-color .35s;
}
canvas { width: 100%; height: min(70vh, 760px); object-fit: contain; touch-action: none; cursor: grab; }
body[data-step="knot"] canvas { cursor: ew-resize; }
#hint { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); width: max-content; max-width: 92%; background: #fff; border: 2px solid var(--ink); border-radius: 99px; padding: 4px 14px; font-weight: 700; font-size: .85rem; text-align: center; }
#hint:empty { display: none; }

.panel { background: #fff; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
h1 { font-size: 1.8rem; line-height: 1.25; letter-spacing: -.03em; word-break: keep-all; }
h2 { font-size: .9rem; margin: 6px 0; }
#controls { flex: 1; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
button, input { font: inherit; color: inherit; }
.btn, .chip, .part, .swatch { border: 2px solid var(--ink); cursor: pointer; min-height: 44px; transition: transform .15s; }
.btn:hover, .chip:hover, .part:hover, .swatch:hover { transform: translateY(-2px) rotate(-1deg); }
.btn:active, .chip:active, .part:active { transform: scale(.94); }
.btn { display: inline-flex; align-items: center; text-decoration: none; padding: 10px 20px; border-radius: 99px; background: var(--pink); color: #fff; font-weight: 800; box-shadow: 3px 3px 0 var(--ink); }
.btn.ghost { background: #fff; color: var(--ink); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.chip { padding: 8px 14px; border-radius: 99px; background: #fff; font-weight: 700; }
.chip[aria-pressed="true"] { background: var(--lime); }
.swatch { width: 44px; height: 44px; border-radius: 50%; }
.swatch[aria-pressed="true"] { outline: 4px solid var(--pink); outline-offset: 2px; }
.parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 8px; }
.part { aspect-ratio: 1; border-radius: 18px; background: #fff7b8; padding: 4px; }
.part canvas { width: 100%; height: 100%; cursor: pointer; }
input[type="text"] { width: 100%; min-height: 46px; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 12px; }
small { display: block; color: #55515f; margin-top: 4px; }
.nav { display: flex; justify-content: space-between; gap: 8px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.logo { line-height: 0; text-shadow: none; }
.logo img { width: 150px; height: auto; }
@media (max-width: 760px) {
  main { grid-template-columns: 1fr; padding: 0 12px 16px; }
  canvas { height: 52vh; }
  header { padding: 10px 14px; }
  #progress li:not(.on) { font-size: 0; width: 14px; height: 14px; padding: 0; }
}
@media (prefers-reduced-motion: reduce) { .marquee span { animation: none; } }

/* 버튼 display 지정이 hidden 속성을 덮지 않게 */
[hidden] { display: none !important; }

/* 모바일 이미지 저장 시트 */
.save-sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(20, 16, 30, .6); }
.save-card { width: min(420px, 100%); max-height: 100%; overflow: auto; background: #fff; border: 2px solid var(--ink); border-radius: 20px; padding: 14px; text-align: center; }
.save-card img { width: 100%; height: auto; border-radius: 12px; -webkit-touch-callout: default; user-select: auto; }
.save-card p { margin: 10px 0; }
