/* 반구대 — 따뜻한 돌 색. 참가자 화면(app.js). */
:root {
  --sand: #efe6d8;
  --sand-d: #e3d6c2;
  --card: #f8f3ea;
  --rock: #5b4636;
  --rock-d: #3e2f24;
  --sub: #85705e;
  --faint: #b4a28f;
  --line: #dccdb8;
  --ochre: #c8752b;
  --ochre-d: #a95f1f;
  --red: #b8432f;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Noto Sans KR", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--rock);
  background: var(--sand-d);
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
h1, h2, p, ul, ol, dl, dd, dt { margin: 0; padding: 0; }
ul, ol { list-style: none; }
[hidden] { display: none !important; }

#app {
  max-width: 520px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--sand);
}
.noscript { padding: 40px 24px; text-align: center; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: enter .28s ease both;
}
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 위쪽 줄 ---------- */
.top { display: flex; align-items: center; gap: 6px; height: 56px; padding: 0 16px 0 6px; flex: none; }
.back, .back-gap { flex: none; width: 48px; height: 48px; }
.back { display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--rock); }
.back:active { background: rgba(91, 70, 54, .1); }
.back svg { width: 26px; height: 26px; }
.top-title { font-size: 16px; font-weight: 700; color: var(--rock); }

/* ---------- 본문 ---------- */
.body { padding: 16px 24px 28px; }
.title { font-size: 27px; line-height: 1.34; font-weight: 800; letter-spacing: -.025em; white-space: pre-line; color: var(--rock-d); }
.hint { margin-top: 10px; font-size: 16px; line-height: 1.55; color: var(--sub); }
.center { text-align: center; }
.label { display: block; margin-top: 28px; font-size: 15px; font-weight: 700; color: var(--sub); }
.field { margin-top: 30px; }
.label + .field { margin-top: 6px; }
.input {
  display: block;
  width: 100%;
  padding: 8px 2px 12px;
  border: 0;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  background: none;
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -.01em;
  outline: none;
  transition: border-color .2s;
}
.input::placeholder { color: var(--faint); font-weight: 500; }
.input:focus { border-color: var(--ochre); }
.err { min-height: 22px; margin-top: 8px; font-size: 15px; font-weight: 600; color: var(--red); }

/* ---------- 아래 단추 ---------- */
.bar {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  background: linear-gradient(to top, var(--sand) 75%, rgba(239, 230, 216, 0));
}
.btn {
  width: 100%;
  min-height: 60px;
  padding: 0 20px;
  border: 0;
  border-radius: 16px;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -.01em;
  transition: transform .1s, background .2s, opacity .2s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary { background: var(--ochre); color: #fff; box-shadow: 0 6px 16px rgba(200, 117, 43, .28); }
.btn.primary:active:not(:disabled) { background: var(--ochre-d); }
.btn.primary:disabled { background: #d9c7b0; color: #fff; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--rock); border: 2px solid var(--line); }
.btn.danger { background: var(--red); color: #fff; }
.link { min-height: 48px; border: 0; background: none; color: var(--rock); font-size: 16px; font-weight: 650; text-decoration: underline; text-underline-offset: 4px; }

/* ---------- 첫 화면 ---------- */
.cover-art {
  height: 34vh;
  min-height: 190px;
  background:
    radial-gradient(ellipse at 30% 110%, rgba(62, 47, 36, .35), transparent 60%),
    url("/static/wall-rock.webp") center 40% / cover;
  border-radius: 0 0 28px 28px;
  position: relative;
}
.cover-art::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(to bottom, rgba(239, 230, 216, 0) 55%, var(--sand));
}
.cover-body { padding: 0 24px 8px; margin-top: -18px; position: relative; }
.eyebrow { font-size: 14px; font-weight: 700; color: var(--ochre-d); letter-spacing: .02em; }
.cover-title { margin-top: 8px; font-size: 32px; line-height: 1.28; font-weight: 850; letter-spacing: -.03em; white-space: pre-line; color: var(--rock-d); }
.cover-text { margin-top: 14px; font-size: 16.5px; line-height: 1.6; color: var(--sub); }
.cover-steps { margin-top: 22px; display: grid; gap: 10px; }
.cover-steps li { display: flex; align-items: center; gap: 12px; font-size: 16px; font-weight: 600; }
.cover-steps b {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
  background: var(--rock); color: var(--sand); font-size: 15px;
}

/* ---------- 동의 ---------- */
.terms { margin-top: 22px; padding: 6px 18px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.terms-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.terms-row:last-child { border-bottom: 0; }
.terms dt { font-size: 14px; font-weight: 750; color: var(--ochre-d); }
.terms dd { margin-top: 4px; font-size: 16px; line-height: 1.5; }
.check {
  display: flex; align-items: center; gap: 14px; margin-top: 20px; padding: 16px 18px; min-height: 64px;
  border-radius: 16px; background: var(--card); border: 2px solid var(--line); font-size: 17px; font-weight: 700; cursor: pointer;
}
.check input { flex: none; width: 28px; height: 28px; margin: 0; accent-color: var(--ochre); }
.check:has(input:checked) { border-color: var(--ochre); }

/* ---------- 그림판 ---------- */
body.drawing { overflow: hidden; overscroll-behavior: none; position: fixed; inset: 0; width: 100%; }
.screen.draw { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; animation: none; }
.draw .top { height: 48px; }
.pad-area { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.pad-hint { flex: none; margin: 0; padding: 0 16px; text-align: center; font-size: 15.5px; font-weight: 700; color: var(--rock); }
/* 그림판은 가로 3:2 (app.js PAD_ASPECT). 폭에 맞추되 화면이 낮으면(가로 폰) 높이에 맞춘다 */
.pad-box { flex: 0 1 auto; min-height: 0; max-height: 100%; aspect-ratio: 3 / 2; width: 100%; display: flex; align-items: center; justify-content: center; padding: 0 10px; box-sizing: border-box; }
.pad {
  display: block;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6), 0 4px 18px rgba(62, 47, 36, .16);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: crosshair;
}
.tools { flex: none; display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px 0; }
.tool-group { display: flex; gap: 6px; }
.tool {
  width: 52px; height: 52px; display: grid; place-items: center; border: 2px solid transparent; border-radius: 14px;
  background: var(--card); color: var(--rock);
}
.tool svg { width: 26px; height: 26px; }
.tool[aria-pressed="true"] { border-color: var(--ochre); background: #fff; }
.tool:disabled { opacity: .35; }
.tool.pen i { display: block; border-radius: 50%; background: #000; }
.draw-bar { position: static; padding-top: 10px; background: none; }

/* ---------- 선택 (AI · 무엇을) ---------- */
.options { margin-top: 18px; display: grid; gap: 16px; }
.opt { padding: 18px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.opt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.opt-title { display: block; font-size: 19px; font-weight: 800; color: var(--rock-d); }
.switch {
  flex: none; width: 66px; height: 38px; padding: 4px; border: 0; border-radius: 19px; background: #cbb9a2; position: relative; transition: background .2s;
}
.switch i { display: block; width: 30px; height: 30px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--ochre); }
.switch[aria-checked="true"] i { transform: translateX(28px); }
.switch-say { margin-top: 10px; font-size: 15.5px; line-height: 1.6; color: var(--faint); }
.switch-say .on { color: var(--rock); font-weight: 700; }
.chips { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px; border: 2px solid var(--line); border-radius: 22px; background: #fff;
  font-size: 16px; font-weight: 650;
}
.chip[aria-pressed="true"] { border-color: var(--ochre); background: var(--ochre); color: #fff; }
.opt .field { margin-top: 14px; }

/* ---------- 기다리기 (끌로 쪼는 움직임) ---------- */
.center-screen { justify-content: center; align-items: center; padding: 24px; text-align: center; }
.center-screen .bar { position: static; background: none; width: 100%; }
.chisel { display: flex; gap: 10px; justify-content: center; height: 40px; align-items: flex-end; }
.chisel i { width: 14px; height: 14px; border-radius: 3px; background: var(--rock); animation: tap 1.1s ease-in-out infinite; }
.chisel i:nth-child(2) { animation-delay: .18s; }
.chisel i:nth-child(3) { animation-delay: .36s; }
@keyframes tap { 0%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-18px) rotate(12deg); opacity: 1; } }
.wait-title { margin-top: 18px; font-size: 20px; font-weight: 800; color: var(--rock-d); }

/* ---------- 결과 ---------- */
.result .body { padding-top: 26px; text-align: center; }
.dup { display: inline-block; margin-bottom: 14px; padding: 8px 14px; border-radius: 20px; background: var(--rock); color: var(--sand); font-size: 15px; font-weight: 700; }
.num-label { font-size: 16px; font-weight: 700; color: var(--sub); }
.num {
  margin-top: 2px; font-size: 76px; line-height: 1.05; font-weight: 900; letter-spacing: .08em; color: var(--rock-d);
  font-variant-numeric: tabular-nums; -webkit-user-select: all; user-select: all;
}
.guide { margin-top: 12px; font-size: 18px; font-weight: 750; color: var(--ochre-d); }
.guide-sub { margin-top: 4px; font-size: 15px; color: var(--sub); }
.preview { margin: 22px auto 0; max-width: 360px; aspect-ratio: 1125 / 2000; border-radius: 18px; overflow: hidden; background: #8c7a68; position: relative; }
.preview-img { display: block; width: 100%; height: 100%; object-fit: cover; animation: reveal .9s ease both; }
@keyframes reveal { from { opacity: 0; filter: brightness(1.4) blur(4px); } }
.carving {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 24px;
  background: url("/static/wall-rock.webp") center / cover; color: #fff;
}
.carving::before { content: ""; position: absolute; inset: 0; background: rgba(40, 30, 22, .55); }
.carving > * { position: relative; }
.carving .chisel i { background: var(--sand); }
.carving .wait-title { color: #fff; }
.carving .hint { color: #eadfce; }
.carving .btn { margin-top: 18px; max-width: 240px; }
.notes { margin-top: 12px; display: grid; gap: 6px; }
.note { font-size: 14px; color: var(--sub); }
.lock-note { font-size: 15px; font-weight: 650; color: var(--sub); text-align: center; padding: 8px 0; }

/* ---------- 확인 창 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 16px; background: rgba(40, 30, 22, .5); animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } }
.modal-card { width: 100%; max-width: 480px; padding: 26px 22px 20px; border-radius: 24px; background: var(--sand); box-shadow: 0 10px 40px rgba(0, 0, 0, .3); animation: enter .25s ease both; }
.modal-title { font-size: 21px; font-weight: 850; color: var(--rock-d); }
.modal-text { margin-top: 10px; font-size: 16.5px; line-height: 1.55; }
.modal-actions { margin-top: 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions .btn { min-height: 56px; font-size: 17px; }
@media (min-width: 700px) { .modal { align-items: center; } }

/* 그림판 방향 (가로 · 세로) */
.orient { flex: none; display: flex; justify-content: center; gap: 8px; padding: 0 16px; }
.orient-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--rock); font: inherit; font-size: 15.5px; font-weight: 700;
}
.orient-btn i { display: block; width: 22px; height: 15px; border: 2px solid currentColor; border-radius: 3px; background: #fff; }
.orient-btn[data-o="tall"] i { width: 15px; height: 22px; }
.orient-btn[aria-pressed="true"] { border-color: var(--ochre); background: var(--ochre); color: #fff; }
.pad-box.tall { aspect-ratio: auto; flex: 1 1 auto; }

/* 결과 화면 [초기화] — 새로 하기 위에 작게 */
.link.wipe { justify-self: center; min-height: 36px; padding: 0 12px; font-size: 14px; font-weight: 600; color: var(--faint); }
.link.wipe { background: rgba(251, 247, 240, .92); border-radius: 999px; padding: 0 16px; min-height: 34px; text-decoration: none; border: 1px solid var(--line); }
