/* =====================================================================
   이뭔그 — async.css
   그림 보내기 페이지(보내는 /send · 받는 /g/<id>) 공용. 변수·버튼·토스트는 style.css 를 그대로 쓴다.
   모바일(설계 §3-8): 캔버스는 화면 폭에 맞추고 4:3 유지, 도구 모음은 캔버스 아래 본 게임과 같은 모양(폰 2줄 격자, 팔레트는 가로로 밀어 보기), 입력 16px
   ===================================================================== */

.as-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* 상단: 첫 화면 로고(style.css .logo.is-compact — 홈 링크)만, 왼쪽 정렬 */
.as-top {
  width: 100%; max-width: 900px; margin: 0 auto; padding: 10px 16px 8px;
  display: flex; align-items: center; justify-content: flex-start; gap: 12px;
}

.as-main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 4px 12px 12px; }
/* 카드 종이·연필 테두리·모서리는 첫 화면 카드와 같은 style.css(.landing-card, .as-card) */
.as-card { padding: 20px; }
.as-center { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
/* .as-title 글꼴은 style.css(.card-title 과 같음) */
.as-sub { font-size: 14px; color: var(--muted); }
.as-msg { font-size: 14px; color: var(--muted); min-height: 1.2em; }
.as-msg:empty { min-height: 0; }
.as-msg.as-warn { color: var(--red); font-weight: 700; }

a.btn { text-decoration: none; }
.as-foot { text-align: center; padding: 8px 0 max(12px, env(safe-area-inset-bottom)); }

/* ---- 1. 제시어 고르기 ---- */
#send-pick .as-sub { margin-top: 6px; }
.pick-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 18px 0 14px; }
.pick-word {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 10px; border-radius: 14px; border: 2px solid var(--line); background: #fff;
  transition: border-color .15s, transform .08s, background .15s;
}
.pick-word:hover:not(:disabled) { border-color: var(--secondary); background: var(--blue-soft); }
.pick-word:active:not(:disabled) { transform: translateY(1px); }
.pick-word:disabled { opacity: .5; }
.pick-text { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; word-break: keep-all; }
.pick-meta { font-size: 13px; color: var(--muted); font-weight: 600; }
.pick-foot { display: flex; justify-content: center; }
#pick-msg { text-align: center; margin-top: 10px; }

/* ---- 2·3. 그리기 · 보내기 확인 ---- */
.as-draw { padding: 12px 14px 14px; }
.draw-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.draw-word { font-size: 15px; font-weight: 600; min-width: 0; }
.draw-word strong { font-size: 20px; font-weight: 800; color: var(--primary-dark); }
.draw-meta { font-size: 13px; color: var(--muted); font-weight: 600; }
.draw-timer {
  flex: 0 0 auto; min-width: 52px; padding: 2px 12px; border-radius: 999px; text-align: center;
  font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--secondary-soft); color: var(--secondary-dark);
}
.draw-timer.is-low { background: var(--red-soft); color: var(--red); }

/* 캔버스: 폭에 맞추되 화면 높이 안에 들어오게(가로 화면에서도 4:3 유지) */
.pad-wrap { width: 100%; max-width: calc((100vh - 320px) * 4 / 3); margin: 8px auto 0; min-width: 240px; }
@supports (height: 100dvh) { .pad-wrap { max-width: calc((100dvh - 320px) * 4 / 3); } }
/* 폰 가로(낮은 화면): 제목줄 + 캔버스가 한 화면에 들어오는 만큼만 남기고 키운다(도구·버튼은 바로 아래로 밀어 본다) */
@media (max-height: 500px) and (orientation: landscape) {
  .pad-wrap { max-width: calc((100vh - 120px) * 4 / 3); }
  @supports (height: 100dvh) { .pad-wrap { max-width: calc((100dvh - 120px) * 4 / 3); } }
}
.pad {
  display: block; width: 100%; height: auto; aspect-ratio: 4 / 3;
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
  touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* 그리기 도구: 본 게임 도구 모음 그대로(style.css .toolbar·.tool·.palette·.swatch·.sizes·.size-btn — 폰 2줄 격자 포함).
   여기서는 캔버스와의 간격과 그림이 없을 때 막히는 되돌리기·전체 지우기만 */
#pad-tools { margin-top: 8px; }
#pad-tools .tool:disabled { opacity: .4; cursor: default; }
#pad-tools .tool:disabled:hover { transform: none; background: #fff; }
#pad-tools .tool:disabled:hover svg { fill: var(--text); }

#draw-limit { margin-top: 6px; padding: 6px 10px; border-radius: 10px; background: var(--amber-soft); color: #7a5200; font-weight: 700; text-align: center; }
#draw-limit.is-over { background: var(--red-soft); color: var(--red); }

.draw-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin-top: 10px; }
#review-msg { flex-basis: 100%; text-align: center; }
.as-draw[data-stage="draw"] .review-only { display: none; }
.as-draw[data-stage="review"] .draw-only,
.as-draw[data-stage="review"] #pad-tools { display: none; }
.as-draw[data-stage="review"] .pad { cursor: default; }

/* ---- 4. 링크 화면 ---- */
.done-link { max-width: 440px; text-align: center; }
input.done-link { font-size: 16px; } /* iOS 확대 방지 */
.done-actions, .done-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.done-qr { margin: 4px 0 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.done-qr canvas { width: 150px; height: 150px; image-rendering: pixelated; border-radius: 8px; }
.done-qr figcaption { font-size: 12px; color: var(--muted); }

/* ==== 받는 페이지(/g/<id>) ==== */
.g-gone-icon { font-size: 44px; line-height: 1; }
.g-main { padding: 12px 14px 10px; }
.g-main:not([data-view="play"]) .play-only,
.g-main:not([data-view="result"]) .result-only,
.g-main:not([data-view="sender"]) .sender-only,
.g-main[data-view="sender"] .report-only { display: none; }

/* 머리줄: 🙂 ○○님이 보낸 그림 퀴즈 (좁으면 줄바꿈 — 가로 스크롤 없음). 카테고리·글자 수·빈칸은 그림 아래 .g-quiz */
.g-from { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 15px; font-weight: 600; min-width: 0; }
.g-av {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; background: var(--gray-soft);
  display: inline-flex; align-items: center; justify-content: center; font-size: 17px; line-height: 1;
}
.g-from-text { min-width: 0; overflow-wrap: anywhere; }
.g-from-text strong { font-weight: 800; }

/* 맞힐 것(그림 바로 아래 · 입력칸 위): [동물] 무엇인지 맞혀 보세요 · 3글자예요 + 정답 빈칸 */
.g-quiz { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 10px; }
.g-quiz-ask { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; font-size: 16px; font-weight: 700; text-align: center; }
.g-quiz-ask strong { font-weight: 800; color: var(--secondary-dark); }
.g-cat { padding: 2px 10px; border-radius: 999px; background: var(--secondary-soft); color: var(--secondary-dark); font-size: 13px; font-weight: 800; }
.g-cat[hidden] { display: none; }
/* 정답 빈칸: 본 게임 맞히기 화면의 밑줄 칸(style.css .mask·.mask-box)을 크게 · 바탕을 칠해 한눈에.
   단어마다 묶어(.g-mask-word) 좁으면 단어 단위로 줄바꿈, 글자 수가 많으면 칸을 줄인다(data-size s ≤6 · m 7–10 · l 11+) */
.g-mask { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 8px 18px; max-width: 100%; }
.g-mask .g-mask-word { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 100%; }
.g-mask .mask-box {
  width: 44px; height: 50px; font-family: inherit; font-size: 28px; font-weight: 800; line-height: 1; /* 초성은 본문 글꼴로(고정폭 대체 글꼴은 ㅊ이 한자처럼 보임) */
  background: var(--gray-soft); border-bottom: 4px solid var(--text); border-radius: 8px 8px 2px 2px;
}
.g-mask[data-size="m"] .mask-box { width: 36px; height: 44px; font-size: 24px; }
.g-mask[data-size="l"] .mask-box { width: 30px; height: 38px; font-size: 20px; border-bottom-width: 3px; }
.g-mask .mask-box.revealed { background: var(--primary-soft); color: var(--primary-dark); }
/* 초성 힌트가 방금 열린 칸: 노란 칸 + 한 번 튀어 오름(오답으로 다시 그려도 색은 다음 힌트까지 남음 — .is-last) */
.g-mask .mask-box.is-new, .g-mask .mask-box.is-last { background: var(--amber-soft); color: #7a5200; border-bottom-color: var(--amber); box-shadow: inset 0 0 0 2px var(--amber); }
.g-mask .mask-box.is-new { animation: g-mask-pop .6s ease-out; }
@keyframes g-mask-pop { 0% { transform: scale(.6); } 55% { transform: scale(1.18); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .g-mask .mask-box.is-new { animation: none; } }

/* 캔버스: 폭에 맞추고 4:3. --g-fit = async.js 가 잰 "입력칸까지 한 화면" 최대 폭 */
.g-canvas-wrap { position: relative; width: 100%; max-width: min(640px, var(--g-fit, 640px)); min-width: 200px; margin: 8px auto 0; }
.g-canvas { cursor: default; touch-action: auto; } /* 보기만 하는 캔버스 — 폰에서 위로 밀어 스크롤할 수 있게 */
.g-progress { position: absolute; left: 10px; right: 10px; bottom: 6px; height: 4px; border-radius: 4px; background: rgba(43, 45, 66, .08); overflow: hidden; pointer-events: none; }
.g-progress span { display: block; height: 100%; width: 0; background: var(--secondary); border-radius: 4px; }
.g-main[data-replay="done"] .g-progress { opacity: 0; transition: opacity .4s; }
.g-speed {
  position: absolute; right: 8px; bottom: 14px; padding: 6px 12px; border-radius: 999px; border: 0;
  background: rgba(43, 45, 66, .78); color: #fff; font-size: 13px; font-weight: 700; line-height: 1.2;
}
.g-speed:hover { background: rgba(43, 45, 66, .9); }

.g-feedback { min-height: 22px; margin: 4px 0 0; text-align: center; font-size: 14px; font-weight: 700; color: var(--muted); }
.g-feedback.is-close { color: #a36200; }
.g-feedback.is-wrong, .g-feedback.is-slow { color: var(--red); }
.g-feedback.is-hint { color: var(--secondary-dark); }
.g-form { display: flex; gap: 8px; margin-top: 4px; }
.g-form .g-input { flex: 1 1 auto; min-width: 0; font-size: 16px; } /* iOS 확대 방지 */
.g-form .btn { flex: 0 0 auto; }
.g-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px; margin-top: 10px; }
.g-stars-now { flex-basis: 100%; order: 3; text-align: center; font-size: 13px; color: var(--muted); }
.g-giveup.is-armed { color: var(--red); }

/* 결과 */
.g-result { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 12px; text-align: center; }
.g-stars { font-size: 40px; line-height: 1; letter-spacing: 4px; color: var(--amber); }
.g-stars.is-zero { color: #c9c6d3; }
.g-answer { font-size: 17px; }
.g-answer strong { font-size: 22px; font-weight: 800; color: var(--primary-dark); }
.g-word-cat { color: var(--muted); font-size: 14px; font-weight: 600; }
.g-result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 4px; }
.g-sender { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 12px; text-align: center; }
/* 보낸 사람 화면: 열어 본 사람 · 맞힌 사람 · 평균 점수(x.x점, 5점 만점) */
.g-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; max-width: 440px; margin: 0; }
.g-stat { display: flex; flex-direction: column-reverse; align-items: center; justify-content: flex-end; gap: 2px; padding: 10px 6px; border-radius: 12px; background: var(--secondary-soft); }
.g-stat dt { font-size: 12px; font-weight: 700; color: var(--muted); }
.g-stat dd { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.1; color: var(--secondary-dark); font-variant-numeric: tabular-nums; }
#st-avg { color: var(--amber); }
#st-avg.is-none { font-size: 15px; line-height: 1.75; color: var(--muted); }
.g-delete { font-size: 13px; margin-top: 2px; }
.g-delete.is-armed { color: var(--red); font-weight: 700; }
.g-delete:disabled { opacity: .6; cursor: default; }

/* 🏓 핑퐁 n번째(받는·보낸 사람 화면 머리줄 위) · 보내는 페이지 "핑퐁 답장 중"·링크 화면 */
.g-pingpong, .send-reply-note {
  display: block; width: fit-content; max-width: 100%; margin: 0 0 6px; padding: 3px 12px; border-radius: 999px;
  background: var(--amber-soft); color: #7a5200; font-size: 13px; font-weight: 700;
}
.as-main > .send-reply-note { margin: 0 auto 8px; }
.done-stats { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 4px; }
.g-report-row { display: flex; justify-content: flex-end; margin-top: 8px; }
.g-report-btn { font-size: 12px; }
.g-report-btn:disabled { opacity: .6; cursor: default; text-decoration: none; }

/* 신고 사유 */
.g-report-back { position: fixed; inset: 0; z-index: 50; background: rgba(43, 45, 66, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.g-report-box { width: 100%; max-width: 360px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.g-report-title { font-size: 18px; font-weight: 800; }
.g-report-reasons { display: flex; flex-direction: column; gap: 8px; width: 100%; }

/* 키보드가 올라온 동안(async.js fit): 캔버스 + 입력칸만 */
body.g-kb .as-top, body.g-kb .as-foot, body.g-kb .g-tools, body.g-kb .report-only { display: none; }
body.g-kb .as-main { padding-top: 2px; padding-bottom: 2px; }
body.g-kb .g-main { padding: 6px 8px; }
body.g-kb .g-canvas-wrap { margin-top: 4px; }
body.g-kb .g-quiz-ask { display: none; } /* 빈칸만 남긴다 */
body.g-kb .g-quiz { margin-top: 6px; }
body.g-kb .g-mask:not([data-size="l"]) .mask-box { width: 30px; height: 34px; font-size: 20px; border-bottom-width: 3px; }

/* ---- 모바일 ---- */
@media (max-width: 600px) {
  .as-top { padding: 8px 12px 4px; }
  .as-main { padding: 2px 6px 8px; }
  .as-card { padding: 16px 14px; }
  .as-draw { padding: 8px; }
  .pick-list { grid-template-columns: minmax(0, 1fr); gap: 8px; margin: 14px 0 12px; }
  .pick-word { flex-direction: row; justify-content: space-between; padding: 14px 16px; }
  .pick-text { font-size: 20px; }
  .draw-word strong { font-size: 18px; }
  .draw-timer { font-size: 20px; min-width: 48px; }
  .pad-wrap { margin-top: 6px; }
  #pad-tools { margin-top: 6px; } /* 도구 모음 배치(2줄 격자·팔레트 가로 밀기)는 style.css 본 게임 규칙 그대로 */
  .btn-lg { padding: 12px 20px; }
  .g-main { padding: 10px 10px 8px; }
  .g-from { font-size: 14px; }
  .g-av { width: 26px; height: 26px; font-size: 15px; }
  .g-canvas-wrap { margin-top: 6px; }
  .g-quiz { margin-top: 8px; gap: 6px; }
  .g-quiz-ask { font-size: 15px; }
  .g-mask { gap: 6px 14px; }
  .g-mask .g-mask-word { gap: 5px; }
  .g-mask .mask-box { width: 38px; height: 44px; font-size: 24px; }
  .g-mask[data-size="m"] .mask-box { width: 30px; height: 38px; font-size: 20px; }
  .g-mask[data-size="l"] .mask-box { width: 24px; height: 32px; font-size: 17px; }
  .g-result-actions .btn-lg { flex: 1 1 100%; }
}
