@import url('https://fonts.googleapis.com/css2?family=Courier+Prime:wght@700&family=Gaegu:wght@700&family=Noto+Serif+KR:wght@500;700;900&display=swap');

:root {
  --paper: #efe6d2;
  --card: #fbf7ee;
  --ink: #1d1a17;
  --ink-soft: #4a4036;
  --red: #b03a2e;
  --green: #2f6b3a;
  --line: #2b2620;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Noto Serif KR', serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 560px; margin: 0 auto; padding: 18px 14px 60px; }
h1 { font-family: 'Gaegu', cursive; font-size: 2.1rem; line-height: 1.15; margin: 6px 0 4px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
.sub { color: var(--ink-soft); font-size: .92rem; margin: 0 0 14px; }
.card {
  background: var(--card);
  border: 2.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 14px 12px;
  margin: 14px 0;
  box-shadow: 0 3px 0 var(--line);
}
.tag {
  display: inline-block; font-family: 'Courier Prime', monospace; font-size: .8rem;
  border: 1.5px solid var(--line); border-radius: 999px; padding: 0 10px; margin-bottom: 6px;
}
.q { font-size: 1rem; }
.q b { white-space: nowrap; }
.math { font-family: 'Courier Prime', monospace; white-space: nowrap; }
ul.rules { padding-left: 1.1em; margin: 6px 0; }
ul.rules li { margin: 3px 0; }
.warn { border-color: var(--red); box-shadow: 0 3px 0 var(--red); }
.warn h2 { color: var(--red); }

input[type=text], input[type=number], input.inp {
  font: inherit; font-size: 1.05rem; padding: 8px 10px; border: 2px solid var(--line);
  border-radius: 8px; background: #fff; width: 100%;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.coord-in { display: flex; align-items: center; gap: 4px; font-family: 'Courier Prime', monospace; font-size: 1.3rem; }
.coord-in input { width: 74px; text-align: center; font-family: 'Courier Prime', monospace; }
.btn {
  font: inherit; font-weight: 700; font-size: 1rem; cursor: pointer;
  background: var(--card); color: var(--ink); border: 2.5px solid var(--line);
  border-radius: 10px; padding: 8px 16px; box-shadow: 0 3px 0 var(--line);
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.btn.primary { background: var(--ink); color: var(--card); }
.btn.small { font-size: .85rem; padding: 4px 10px; }
.check-out { font-weight: 700; margin-top: 8px; min-height: 1.4em; }
.check-out.ok { color: var(--green); }
.check-out.no { color: var(--red); }
.hint-btn { margin-top: 8px; }
.hint { display: none; margin-top: 6px; padding: 8px 10px; border: 1.5px dashed var(--ink-soft); border-radius: 8px; font-size: .92rem; }
.hint.open { display: block; }

.shake { animation: shake .36s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(5px)} }

#toast {
  position: fixed; left: 50%; top: 18px; transform: translate(-50%, -20px); opacity: 0;
  background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 10px;
  font-weight: 700; font-size: .95rem; z-index: 99; transition: all .25s ease; max-width: 90vw; text-align: center;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* QR 조각 페이지 */
.piece-box { text-align: center; }
.piece-card { width: 62%; max-width: 260px; height: auto; display: block; margin: 6px auto 4px; }
.code {
  font-family: 'Courier Prime', monospace; font-size: 2rem; letter-spacing: 3px;
  border: 3px dashed var(--red); color: var(--red); border-radius: 10px; display: inline-block; padding: 2px 16px; margin: 6px 0;
}
.order {
  font-size: 1.05rem; border-left: 5px solid var(--red); padding: 6px 10px; text-align: left; background: #fff;
}
.dot { color: var(--red); }

/* 지도 */
.map-svg { width: 100%; height: auto; display: block; background: #fff; border: 2px solid var(--line); border-radius: 8px; }

/* 최종 퍼즐 */
.board-wrap { touch-action: none; }
#board { width: 100%; height: auto; display: block; background: #f6eedb; border: 2.5px solid var(--line); border-radius: 10px; touch-action: none; user-select: none; -webkit-user-select: none; }
.piece { cursor: grab; }
.piece.dragging { cursor: grabbing; }
.status-list { font-family: 'Courier Prime', monospace; font-size: .95rem; margin: 6px 0 0; padding: 0; list-style: none; }
.status-list li { margin: 2px 0; }
.slots { display: flex; gap: 10px; justify-content: center; margin: 4px 0 10px; }
.slot { width: 44px; height: 50px; border-bottom: 3px solid var(--ink); font-family: 'Courier Prime', monospace; font-size: 2rem; text-align: center; color: var(--red); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 300px; margin: 0 auto; }
.key { font-family: 'Courier Prime', monospace; font-size: 1.7rem; padding: 6px 0; }
.keyrow { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal.open { display: flex; }
.modal .card { max-width: 380px; width: 100%; text-align: center; }
.stamp { width: 84px; height: 84px; border: 4px solid var(--red); border-radius: 50%; color: var(--red); display: flex; align-items: center; justify-content: center; margin: 4px auto 10px; font-weight: 900; font-size: 1.3rem; transform: rotate(-12deg); }
.big { font-family: 'Courier Prime', monospace; font-size: 1.7rem; color: var(--red); letter-spacing: 4px; }
.foot { text-align: center; color: var(--ink-soft); font-size: .8rem; margin-top: 24px; }
a { color: var(--ink); }
