/* 수학이 자라는 농장 — 디자인 시스템 + 메인 화면
   원목 간판·양피지 보드·입체 버튼, 밝고 따뜻한 동화풍. 노란색은 강조에만 조금. */
:root {
  --wood-1: #c98a4b; --wood-2: #a8692f; --wood-3: #7a4a1f; --wood-edge: #5b3514;
  --paper: #fffaf1; --paper-2: #f7eedc; --paper-edge: #d6bd97; /* Phase 9-B: 누런 기운 줄임 (이전 #fff8ea·#f6e8cb·#d9b98a) */
  --leaf: #5aa83a; --leaf-dark: #3d7d25; --leaf-light: #8fd16a;
  --sky: #e9f6ff; --text: #3b2a1a; --text-soft: #6b5440; --white: #fff;
  --danger: #c0392b; --ok: #2e7d32;
  --radius: 18px; --shadow: 0 6px 0 rgba(91, 53, 20, .35), 0 10px 18px rgba(0, 0, 0, .18);
  --font: 'Pretendard', 'Malgun Gothic', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --tap: 44px;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); color: var(--text); background: #9fd36b; font-size: 16px; line-height: 1.45;
  overflow-x: hidden; -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; height: auto; display: block; }
button { font-family: inherit; }
.loading { padding: 40px 16px; text-align: center; font-size: 18px; }

/* ---------- 공통 부품 ---------- */
.btn {
  min-height: var(--tap); padding: 10px 20px; border-radius: 999px; border: 0; cursor: pointer;
  font-size: 17px; font-weight: 800; letter-spacing: -.2px; transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: translateY(3px); }
/* Phase 9-B: 키보드 포커스 표시 공통 규칙(개별 규칙이 없는 버튼·링크·선택 요소도 파란 테두리) */
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible, [role="radio"]:not(.nl-tick):focus-visible, [role="button"]:focus-visible { outline: 4px solid #2b7bd6; outline-offset: 2px; }
.btn:focus-visible, .menu-tile:focus-visible, .btn-parent:focus-visible, input:focus-visible { outline: 4px solid #2b7bd6; outline-offset: 3px; }
.btn-primary {
  color: var(--white); background: linear-gradient(#7fcf4f, var(--leaf) 55%, var(--leaf-dark));
  box-shadow: 0 5px 0 #2f6619, 0 8px 14px rgba(0, 0, 0, .22); text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:disabled { filter: grayscale(.6); cursor: wait; }
.btn-wood {
  color: #fff7e6; background: linear-gradient(var(--wood-1), var(--wood-2));
  box-shadow: 0 5px 0 var(--wood-edge), 0 8px 14px rgba(0, 0, 0, .2); text-shadow: 0 1px 0 rgba(0, 0, 0, .3);
}
.btn-big { font-size: 20px; padding: 14px 28px; min-height: 56px; }
.wood {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 22px),
    linear-gradient(var(--wood-1), var(--wood-2));
  border: 3px solid var(--wood-edge); border-radius: var(--radius); box-shadow: var(--shadow);
}
.bar { height: 12px; border-radius: 999px; background: #ead7b3; border: 2px solid var(--wood-edge); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(var(--leaf-light), var(--leaf)); border-radius: 999px; min-width: 0; }

/* ---------- 배경 ---------- */
.scene-bg { position: fixed; inset: 0; z-index: -1; }
.scene-bg img { width: 100%; height: 100%; object-fit: cover; object-position: center 60%; }

/* ---------- 전체 틀 (PC·태블릿 가로) ---------- */
.app-shell {
  min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; gap: clamp(8px, 1.4vh, 16px);
  padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) calc(10px + var(--safe-b)) calc(14px + var(--safe-l));
  max-width: 1720px; margin: 0 auto;
}

/* 상단 상태 영역 */
.hud {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between;
  padding: 8px 12px; border-radius: 22px;
  background: linear-gradient(rgba(255, 250, 238, .92), rgba(255, 244, 222, .92));
  border: 3px solid var(--wood-edge); box-shadow: var(--shadow);
}
.title-sign {
  padding: 6px 18px 7px; border-radius: 16px; color: #fff8e8; min-width: 0;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .06) 0 2px, transparent 2px 20px), linear-gradient(var(--wood-1), var(--wood-2));
  border: 3px solid var(--wood-edge); box-shadow: 0 4px 0 rgba(91, 53, 20, .45);
}
.app-title { margin: 0; font-size: clamp(19px, 1.6vw, 26px); line-height: 1.15; text-shadow: 0 2px 0 rgba(0, 0, 0, .3); white-space: nowrap; }
.farm-line, .date-line { margin: 1px 0 0; font-size: 14px; font-weight: 700; color: #ffeccc; }
.farm-line .nick, .farm-line .farm-name { color: #fff; }
.date-line { font-weight: 600; opacity: .95; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; justify-content: flex-end; }
.stat {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px; min-height: var(--tap);
  background: var(--paper); border: 2px solid var(--paper-edge); border-radius: 14px;
}
.stat-icon { width: 34px; height: 34px; object-fit: contain; flex: none; }
.stat-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.stat-label { font-size: 12px; color: var(--text-soft); font-weight: 700; }
.stat-value { font-size: 18px; font-weight: 900; color: var(--text); white-space: nowrap; }
.stat-small { font-size: 12px; font-weight: 700; color: var(--text-soft); white-space: nowrap; }
.stat.bad { border-color: var(--danger); background: #fff0ee; }
.stat.bad .stat-label { color: var(--danger); }
.progress-stat { padding-left: 12px; min-width: 150px; }
.progress-stat .bar { margin-top: 3px; width: 100%; }
.btn-parent {
  display: flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 4px 14px 4px 6px; cursor: pointer;
  font-size: 15px; font-weight: 800; color: #fff7e6; border-radius: 14px; border: 2px solid var(--wood-edge);
  background: linear-gradient(var(--wood-1), var(--wood-2)); box-shadow: 0 4px 0 var(--wood-edge);
}
.btn-parent:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--wood-edge); }

/* 농장 장면: 캐릭터 | 농장 | 퀘스트 보드 */
.scene { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(320px, 1.35fr) minmax(260px, 1fr); gap: clamp(10px, 1.6vw, 28px); align-items: end; min-height: 0; }
.farmer-area { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; min-height: 0; height: 100%; }
.bubble {
  position: relative; background: var(--white); border: 3px solid var(--wood-edge); border-radius: 22px;
  padding: 12px 16px; font-size: clamp(15px, 1.1vw, 18px); font-weight: 700; box-shadow: 0 5px 0 rgba(91, 53, 20, .3);
  max-width: 360px; margin-bottom: 10px;
}
.bubble p { margin: 0; }
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -16px; transform: translateX(-50%);
  border: 13px solid transparent; border-top-color: var(--wood-edge); border-bottom: 0;
}
.bubble::before {
  content: ''; position: absolute; left: 50%; bottom: -11px; transform: translateX(-50%); z-index: 1;
  border: 10px solid transparent; border-top-color: var(--white); border-bottom: 0;
}
.farmer { width: auto; max-height: min(46vh, 420px); filter: drop-shadow(0 8px 6px rgba(0, 0, 0, .25)); }

.yard {
  display: grid; justify-items: center; gap: 4px; padding: 12px 14px 10px; align-self: end;
  background: rgba(255, 250, 236, .55); border-radius: 26px; border: 3px solid rgba(91, 53, 20, .35);
  backdrop-filter: blur(2px);
}
.yard-buildings { display: flex; align-items: flex-end; justify-content: center; gap: 4%; width: 100%; }
.b-cottage { width: 38%; max-height: 22vh; object-fit: contain; }
.b-barn { width: 42%; max-height: 23vh; object-fit: contain; }
.yard-field { display: flex; align-items: flex-end; justify-content: center; gap: 2%; width: 100%; }
.d-scarecrow { width: 17%; max-height: 22vh; object-fit: contain; align-self: center; }
.plots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; width: min(72%, 330px); }
.plot { position: relative; aspect-ratio: 189 / 174; }
.plot-tile { width: 100%; height: 100%; object-fit: contain; }
.plot.locked .plot-tile { filter: saturate(.35) brightness(.92); opacity: .8; }
.plot-lock { position: absolute; width: 42%; left: 29%; top: 22%; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.plot-crop { position: absolute; left: 12%; bottom: 22%; width: 76%; height: 70%; object-fit: contain; object-position: center bottom; pointer-events: none; }
.plot.ripe { filter: drop-shadow(0 0 6px #ffe27a); }
.d-fence { width: 56%; max-height: 9vh; object-fit: contain; margin-top: -6px; }
.yard-note { margin: 0; font-size: 14px; font-weight: 800; color: var(--text); background: var(--paper); padding: 2px 12px; border-radius: 999px; border: 2px solid var(--paper-edge); }

.quest-board {
  align-self: end; padding: 16px 18px 18px; border-radius: 22px;
  background: linear-gradient(var(--paper), var(--paper-2)); border: 4px solid var(--wood-edge); box-shadow: var(--shadow);
  position: relative;
}
.board-title {
  margin: -32px auto 8px; width: fit-content; padding: 6px 20px; font-size: 19px; color: #fff8e8;
  background: linear-gradient(var(--wood-1), var(--wood-2)); border: 3px solid var(--wood-edge); border-radius: 14px;
  box-shadow: 0 4px 0 rgba(91, 53, 20, .45); text-shadow: 0 2px 0 rgba(0, 0, 0, .3); white-space: nowrap;
}
.goal-big { margin: 4px 0 8px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 8px; }
.goal-big { line-height: 1.25; }
.goal-big strong { font-size: 52px; line-height: 1.25; color: var(--leaf-dark); text-shadow: 0 3px 0 #d6efc3; }
.goal-big span { font-size: 20px; font-weight: 800; }
.quest-progress { display: grid; gap: 4px; font-weight: 800; font-size: 15px; margin-bottom: 8px; }
.quest-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; font-size: 15px; font-weight: 700; }
.quest-list li { display: flex; align-items: center; gap: 8px; }
.check { width: 20px; height: 20px; border-radius: 6px; border: 3px solid var(--wood-2); background: var(--white); flex: none; }
.level-line { margin: 0 0 12px; font-size: 14px; color: var(--text-soft); font-weight: 700; }
.btn-start { width: 100%; margin: 4px 0 10px; }
.check { display: grid; place-items: center; font-size: 15px; font-weight: 900; line-height: 1; color: #fff; }
.check.on { background: var(--leaf); border-color: var(--leaf-dark); }
.quest-list li.done > span:nth-child(2) { color: var(--text-soft); }
.todo-done { font-size: 13px; color: var(--leaf-dark); font-weight: 900; }

/* 주요 메뉴 */
.dock { display: grid; grid-template-columns: repeat(8, 1fr); gap: clamp(6px, .8vw, 12px); }
.menu-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 4px;
  min-height: 96px; padding: 10px 6px 10px; cursor: pointer; overflow: hidden;
  background: linear-gradient(var(--paper), var(--paper-2)); border: 3px solid var(--wood-edge); border-radius: 18px;
  box-shadow: 0 5px 0 rgba(91, 53, 20, .45), 0 8px 12px rgba(0, 0, 0, .15); color: var(--text);
  transition: transform .1s ease;
}
.menu-tile:hover { transform: translateY(-2px); }
.menu-tile:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(91, 53, 20, .45); }
.menu-icon { width: clamp(44px, 4.2vw, 64px); height: clamp(44px, 4.2vw, 64px); display: grid; place-items: center; }
.menu-icon img { max-width: 100%; max-height: 100%; object-fit: contain; }
.menu-label { font-size: clamp(13px, 1vw, 16px); font-weight: 900; text-align: center; line-height: 1.2; word-break: keep-all; }
.soon-ribbon {
  position: absolute; top: 4px; right: 4px; white-space: nowrap;
  font-size: 10px; font-weight: 900; color: #fff; background: #6f7f8c; padding: 1px 6px; border-radius: 999px;
  border: 1px solid #fff;
}
.menu-icon { margin-top: 16px; }

/* 대화상자 */
.modal { border: 0; padding: 0; background: transparent; max-width: min(560px, calc(100vw - 24px)); width: 100%; }
.modal::backdrop { background: rgba(40, 30, 10, .55); }
.modal-box {
  background: linear-gradient(var(--paper), var(--paper-2)); border: 4px solid var(--wood-edge); border-radius: 24px;
  box-shadow: var(--shadow); padding: 18px 20px 20px; max-height: calc(100dvh - 24px); overflow: auto;
}
.modal-title { margin: 0 0 10px; font-size: 21px; text-align: center; }
.modal-actions { display: flex; justify-content: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.soon { display: flex; gap: 12px; align-items: center; font-size: 17px; font-weight: 700; }
.soon-farmer { width: 110px; flex: none; }
.soon-tag { color: #4b5b68; font-size: 15px; background: #eef3f6; border-radius: 10px; padding: 4px 10px; border: 2px dashed #9fb0bd; }

/* 최초 실행 */
.ob-form { display: grid; gap: 6px; }
.ob-hero { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.ob-farmer { width: 110px; flex: none; }
.ob-say { margin: 0; background: var(--white); border: 3px solid var(--wood-edge); border-radius: 16px; padding: 10px 12px; font-weight: 700; }
.ob-form label { font-weight: 800; margin-top: 6px; }
.ob-form input {
  font: inherit; font-size: 19px; min-height: 48px; padding: 8px 12px; border-radius: 12px; border: 3px solid var(--paper-edge); background: var(--white); width: 100%;
}
.farm-input { display: flex; align-items: center; gap: 8px; }
.farm-input input { min-width: 0; flex: 1; }
.farm-input span { font-weight: 800; font-size: 18px; white-space: nowrap; flex: none; }
.form-hint { margin: 0; font-size: 14px; color: var(--text-soft); }
.form-error { margin: 4px 0 0; min-height: 1.4em; color: var(--danger); font-weight: 800; }
.ob-form .btn { margin-top: 8px; }
.gift-hero { position: relative; display: grid; place-items: center; height: 190px; }
.gift-fx { position: absolute; width: 190px; opacity: .9; animation: spin-glow 6s linear infinite; }
.gift-farmer { position: relative; height: 180px; width: auto; }
.gift-say { text-align: center; font-weight: 800; margin: 6px 0 10px; }
.gift-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; }
.gift-list li { display: grid; justify-items: center; gap: 2px; background: var(--white); border: 2px solid var(--paper-edge); border-radius: 14px; padding: 8px 4px; }
.gift-list img { width: 54px; height: 54px; object-fit: contain; }
.gift-list strong { font-size: 18px; }
.gift-list span { font-size: 13px; font-weight: 700; color: var(--text-soft); }
@keyframes spin-glow { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.fatal { max-width: 560px; margin: 60px auto; padding: 20px; background: var(--paper); border: 4px solid var(--wood-edge); border-radius: 20px; }

/* ---------- 노트북 높이가 낮을 때 ---------- */
@media (max-height: 820px) and (min-width: 900px) and (orientation: landscape) {
  .farmer { max-height: 40vh; }
  .b-cottage, .b-barn { max-height: 17vh; }
  .d-scarecrow { max-height: 16vh; }
  .plots { width: min(60%, 250px); }
  .menu-tile { min-height: 84px; padding: 4px 4px 6px; gap: 2px; }
  .menu-icon { width: 40px; height: 40px; }
  .app-shell { gap: 8px; }
  .goal-big strong { font-size: 44px; }
  .quest-list { display: none; }
}

/* ---------- 태블릿 가로 (1024 이하) ---------- */
@media (max-width: 1100px) {
  .scene { grid-template-columns: minmax(180px, .8fr) minmax(300px, 1.3fr) minmax(250px, 1fr); }
  .menu-tile { min-height: 78px; padding: 6px 2px 8px; }
  .menu-icon { width: 40px; height: 40px; }
  .menu-label { font-size: 13px; }
  .farmer { max-height: 36vh; }
  .hud { gap: 8px; }
}

/* ---------- 세로 화면·스마트폰 ---------- */
@media (orientation: portrait), (max-width: 760px) {
  .app-shell { grid-template-rows: auto auto auto; padding-left: calc(10px + var(--safe-l)); padding-right: calc(10px + var(--safe-r)); }
  .hud { flex-direction: column; align-items: stretch; padding: 8px; }
  .title-sign { text-align: center; }
  .app-title { white-space: normal; }
  .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .stat { padding: 4px 8px 4px 4px; }
  .stat-icon { width: 28px; height: 28px; }
  .stat-value { font-size: 16px; }
  .progress-stat { grid-column: 1 / -1; min-width: 0; }
  .sync { grid-column: 1 / 3; }
  .btn-parent { justify-content: center; padding: 4px 8px; font-size: 14px; min-height: 48px; }
  .scene { grid-template-columns: 1fr; gap: 14px; align-items: start; }
  .farmer-area { flex-direction: row; align-items: flex-end; gap: 8px; height: auto; }
  .bubble { order: 2; margin-bottom: 40px; font-size: 16px; }
  .bubble::after, .bubble::before { left: -14px; bottom: 26px; transform: rotate(90deg); }
  .bubble::before { left: -9px; }
  .farmer { order: 1; width: 38%; max-width: 200px; max-height: none; }
  .quest-board { margin-top: 22px; order: 2; width: 100%; max-width: 560px; justify-self: center; }
  .farmer-area { order: 1; justify-content: center; }
  .yard { order: 3; padding: 10px; width: 100%; max-width: 460px; justify-self: center; }
  .b-cottage, .b-barn, .d-scarecrow { max-height: none; }
  .plots { width: 70%; }
  .dock { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .menu-tile { flex-direction: column; justify-content: flex-start; min-height: 92px; padding: 8px 2px; gap: 4px; }
  .menu-icon { width: 44px; height: 44px; margin-top: 16px; }
  .menu-label { text-align: center; font-size: 13px; }
}
@media (max-width: 480px) {
  .title-sign { padding: 4px 10px 5px; }
  .app-title { font-size: 19px; }
  .farm-line, .date-line { font-size: 13px; display: inline; }
  .date-line::before { content: ' · '; }
  .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
  .stats > .stat:nth-child(-n+3) { grid-column: span 2; flex-direction: column; gap: 0; padding: 4px 2px; text-align: center; }
  .stats > .stat:nth-child(-n+3) .stat-text { align-items: center; }
  .stats > .stat:nth-child(-n+3) .stat-icon { width: 26px; height: 26px; }
  .progress-stat { grid-column: 1 / -1; }
  .sync { grid-column: span 3; }
  .btn-parent { grid-column: span 3; min-height: 46px; height: auto; font-size: 13px; padding: 2px 6px; }
  .bubble { margin-bottom: 20px; font-size: 15px; padding: 10px 12px; }
  .quest-board { margin-top: 18px; padding: 12px 14px 14px; }
  .goal-big { margin: 0 0 4px; }
  .quest-list { gap: 2px; font-size: 14px; }
  .level-line { margin-bottom: 8px; }
  .btn-parent .stat-icon { width: 26px; height: 26px; }
  .stat-small { white-space: normal; }
  .menu-label { font-size: 12px; }
  .goal-big strong { font-size: 44px; }
  .farmer { width: 34%; }
}

/* ---------- 메뉴 상태 표시 ---------- */
.menu-tile.ready { border-color: var(--leaf-dark); box-shadow: 0 5px 0 #2f6619, 0 8px 12px rgba(0, 0, 0, .15); }
.done-ribbon { position: absolute; top: 4px; right: 4px; font-size: 10px; font-weight: 900; color: #fff; background: var(--leaf-dark); padding: 1px 6px; border-radius: 999px; border: 1px solid #fff; }

/* ---------- 수학 퀘스트 화면 ---------- */
.quest {
  min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; gap: 10px;
  padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l));
  background: linear-gradient(180deg, #dff1ff 0%, #eaf7dc 45%, #cfe9b2 100%); max-width: 100%;
}
.q-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 18px;
  background: var(--paper); border: 3px solid var(--wood-edge); box-shadow: 0 4px 0 rgba(91, 53, 20, .35);
}
.btn-small { min-height: var(--tap); padding: 6px 14px; font-size: 15px; font-weight: 800; border-radius: 12px; border: 0; cursor: pointer; }
.q-title { flex: 1 1 260px; min-width: 0; }
.q-unit { margin: 0; font-size: 15px; font-weight: 800; color: var(--text-soft); }
.q-level { margin: 2px 0 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lv-badge { background: var(--leaf-dark); color: #fff; font-weight: 900; font-size: 14px; padding: 2px 10px; border-radius: 999px; }
.mastery { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 800; background: #fff; border: 2px solid var(--paper-edge); border-radius: 999px; padding: 0 8px 0 2px; }
.m-icon { width: 24px; height: 24px; object-fit: contain; }
.tag { font-size: 12px; font-weight: 900; padding: 2px 8px; border-radius: 999px; background: #fde7c8; border: 2px solid #e8a650; }
.tag-review { background: #dceeff; border-color: #6aa5d8; }
.q-progress { flex: 0 1 200px; min-width: 150px; font-weight: 900; font-size: 18px; text-align: right; }
.q-progress p { margin: 0 0 4px; }
.quest:not(.result) { grid-template-rows: auto auto 1fr auto; }
.q-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; align-content: start; }
/* 농부·말풍선은 계산 영역을 가리지 않도록 문제 위 한 줄 */
.q-guide { display: flex; align-items: center; gap: 10px; min-width: 0; }
.q-farmer-img { height: 68px; width: auto; flex: none; filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .2)); }
.q-bubble { flex: 1; min-width: 0; background: #fff; border: 3px solid var(--wood-edge); border-radius: 18px; padding: 8px 14px; font-weight: 800; font-size: 16px; }
.q-bubble p { margin: 0; }
.q-stack { display: grid; gap: 12px; min-width: 0; }
.q-card {
  min-width: 0; background: linear-gradient(var(--paper), var(--paper-2)); border: 4px solid var(--wood-edge); border-radius: 24px;
  box-shadow: var(--shadow); padding: 16px 18px 18px; display: grid; gap: 12px;
}
.q-text { margin: 0; font-size: clamp(22px, 2.3vw, 32px); line-height: 1.4; word-break: keep-all; }
.svg-wrap { display: flex; justify-content: center; overflow-x: auto; }
.svg-wrap svg { max-width: 100%; height: auto; max-height: 260px; background: #fff; border-radius: 14px; border: 2px solid var(--paper-edge); padding: 6px; }
.answer-area { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: center; }
.ans-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.ans-input {
  width: 96px; min-height: 64px; font: inherit; font-size: 34px; font-weight: 900; text-align: center; color: var(--text);
  border: 4px solid var(--paper-edge); border-radius: 16px; background: #fff; caret-color: var(--leaf-dark);
}
.ans-input.wide { width: 200px; }
.ans-input:focus { border-color: var(--leaf); outline: none; box-shadow: 0 0 0 4px #bfe5a8; }
.ans-input:disabled { background: #f3efe6; }
.frac { display: grid; justify-items: center; gap: 4px; }
.frac .ans-input { width: 84px; min-height: 54px; font-size: 28px; }
.frac-line { width: 96px; height: 4px; background: var(--text); border-radius: 2px; }
.f-label, .f-unit { font-size: 20px; font-weight: 900; }
.keypad { display: grid; grid-template-columns: repeat(3, 64px); gap: 6px; }
.key {
  min-height: 52px; font: inherit; font-size: 24px; font-weight: 900; border-radius: 14px; cursor: pointer; color: var(--text);
  background: linear-gradient(#fff, #f2e9d6); border: 2px solid var(--wood-2); box-shadow: 0 4px 0 var(--wood-2);
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--wood-2); }
.key-next { grid-column: 1 / -1; font-size: 17px; }
.choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.choice {
  min-height: 56px; min-width: 110px; padding: 8px 16px; font: inherit; font-size: 22px; font-weight: 900; border-radius: 16px; cursor: pointer;
  background: #fff; border: 3px solid var(--paper-edge); color: var(--text);
}
.choices.cmp .choice { min-width: 76px; font-size: 32px; }
.choice.on { background: #e5f6d8; border-color: var(--leaf-dark); box-shadow: inset 0 0 0 2px var(--leaf); }
.choice.on::after { content: ' (선택)'; font-size: .55em; font-weight: 700; } /* 고른 답 표시: 정답 표시(✓)와 혼동하지 않게 글자로 */
.hint-box { background: #fff; border: 3px dashed #9cc7ea; border-radius: 18px; padding: 12px 14px; display: grid; gap: 10px; font-size: 17px; }
.hint-dir { margin: 0; font-weight: 700; }
.hint-box strong { color: #2b6aa8; }
.hint-vis, .hint-steps { display: grid; gap: 6px; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.steps li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 700; }
.step-input { width: 80px; min-height: 44px; font: inherit; font-size: 22px; font-weight: 900; text-align: center; border: 3px solid var(--paper-edge); border-radius: 10px; }
.btn-mini { min-height: 44px; padding: 4px 12px; border-radius: 10px; border: 2px solid var(--wood-2); background: #fff; font: inherit; font-weight: 800; cursor: pointer; }
.step-mark { font-weight: 900; }
.step-mark.ok { color: var(--ok); }
.step-mark.no { color: var(--danger); }
.graded-tag, .retry-tag { margin: 0; justify-self: start; font-weight: 900; font-size: 15px; padding: 3px 12px; border-radius: 999px; background: #eef3f6; border: 2px solid #9fb0bd; }
.graded-tag.ok { background: #e5f6d8; border-color: var(--leaf); }
.graded-tag.no { background: #fff0e0; border-color: #e8a650; }
.solution { background: #fffbe8; border: 3px solid #e8c96a; border-radius: 18px; padding: 10px 14px; font-weight: 700; }
.solution ol { margin: 6px 0; padding-left: 22px; }
.q-actions {
  position: sticky; bottom: 0; z-index: 4; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  padding: 10px 8px calc(10px + var(--safe-b)); margin: 0 -12px; background: rgba(255, 248, 234, .96); border-top: 3px solid var(--wood-edge);
}
.q-actions .btn { min-width: 108px; min-height: 50px; }
.btn-hint { color: #fff; background: linear-gradient(#69a9e0, #3b82c4); box-shadow: 0 5px 0 #275f93; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.grade-sum { display: grid; justify-items: center; gap: 4px; text-align: center; font-weight: 700; }
.grade-sum .big { font-size: 22px; font-weight: 900; margin: 0; }
.grade-fx { width: 110px; }
.rest { display: grid; justify-items: center; gap: 8px; text-align: center; font-weight: 700; }
.rest-img { width: 180px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 50; background: #2f6619; color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 800; box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center; }
.toast.bad { background: var(--danger); }
.quest.result { grid-template-rows: 1fr; padding-bottom: 20px; }
.result-card { max-width: 820px; width: 100%; margin: 0 auto; background: linear-gradient(var(--paper), var(--paper-2)); border: 4px solid var(--wood-edge); border-radius: 26px; box-shadow: var(--shadow); padding: 16px 18px 20px; text-align: center; }
.res-hero { position: relative; display: grid; place-items: center; height: 200px; }
.res-fx { position: absolute; width: 230px; opacity: .95; }
.res-farmer { position: relative; height: 190px; width: auto; }
.result-card h2 { margin: 6px 0 2px; font-size: 26px; }
.res-date { margin: 0; color: var(--text-soft); font-weight: 700; }
.res-msg { font-size: 18px; font-weight: 800; }
.res-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.res-grid div { background: #fff; border: 2px solid var(--paper-edge); border-radius: 14px; padding: 8px 4px; }
.res-grid dt { font-size: 13px; color: var(--text-soft); font-weight: 800; }
.res-grid dd { margin: 2px 0 0; font-size: 22px; font-weight: 900; }
.res-note { font-size: 13px; color: var(--text-soft); }
.res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

@media (max-width: 760px), (orientation: portrait) {
  .q-farmer-img { height: 54px; }
  .q-bubble { font-size: 15px; }
  .q-progress { flex: 1 1 100%; text-align: left; display: flex; align-items: center; gap: 10px; }
  .q-progress .bar { flex: 1; }
  .q-progress p { margin: 0; }
  .res-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .keypad { grid-template-columns: repeat(3, minmax(56px, 1fr)); width: 100%; max-width: 320px; }
}
@media (max-width: 480px) {
  .q-actions .btn { min-width: 0; flex: 1 1 30%; padding: 10px 8px; font-size: 15px; }
  .ans-input.wide { width: 170px; }
  .q-card { padding: 12px; gap: 8px; }
  .q-visual svg { max-height: 150px; }
  .q-head { gap: 6px; padding: 6px 10px; }
  .key { min-height: 48px; font-size: 22px; }
}

/* ---------- 세로셈 풀이 격자 (R29) ---------- */
/* PC: 세로셈(+힌트) | 자유 풀이 공책 | 공용 키패드 */
.ws-body { grid-template-columns: fit-content(560px) minmax(320px, 640px) 270px; justify-content: center; }
/* 하단 고정 버튼 높이(--nav-h, 화면에서 실제 값으로 설정)만큼 스크롤 여백: 칸 이동이 버튼 뒤로 숨지 않게 */
html { scroll-padding-bottom: calc(var(--nav-h, 0px) + 8px); }
.q-body { padding-bottom: 8px; }
.nb-body { grid-template-columns: minmax(0, 1fr) minmax(320px, 600px); justify-content: center; }
.ws-main { display: grid; gap: 10px; min-width: 0; align-content: start; }
.ws-main > .hint-box { contain: inline-size; } /* 힌트 글이 세로셈 열을 넓혀 공책 자리를 빼앗지 않게 */
.ws-card { justify-items: stretch; }
.ws-grid.active { border-color: var(--leaf-dark); box-shadow: 0 0 0 4px #bfe5a8; }
.ws-wrap { overflow-x: auto; display: flex; justify-content: center; padding: 4px; }
.ws-grid {
  --ws-cell: 60px; display: grid; gap: 6px; align-items: center; padding: 14px 18px; border-radius: 18px; border: 2px solid var(--paper-edge);
  background-color: #fffdf6; background-image: linear-gradient(#efe4cc 1px, transparent 1px), linear-gradient(90deg, #efe4cc 1px, transparent 1px); background-size: 22px 22px;
}
.ws-given { width: var(--ws-cell); height: var(--ws-cell); display: grid; place-items: center; font-size: calc(var(--ws-cell) * .62); font-weight: 900; color: var(--text); }
.ws-given.struck { color: #a08a6e; text-decoration: line-through; text-decoration-color: var(--danger); text-decoration-thickness: 3px; }
.ws-op { color: var(--leaf-dark); }
.ws-label { font-size: 13px; font-weight: 800; color: var(--text-soft); text-align: right; padding-right: 4px; white-space: nowrap; }
.ws-label.small { font-size: 11px; }
.ws-line { height: 3px; background: var(--text); border-radius: 2px; align-self: end; margin-bottom: -5px; pointer-events: none; }
.ws-cell {
  width: var(--ws-cell); height: var(--ws-cell); padding: 0; font: inherit; font-size: calc(var(--ws-cell) * .56); font-weight: 900; text-align: center; color: var(--text);
  border: 3px solid #d9c39b; border-radius: 12px; background: #fff; caret-color: transparent; cursor: pointer;
}
.ws-cell.small { height: calc(var(--ws-cell) * .75); font-size: calc(var(--ws-cell) * .38); color: #2b6aa8; border-width: 2px; border-style: dashed; background: #f7fbff; }
.ws-cell.small.two { font-size: calc(var(--ws-cell) * .34); letter-spacing: -1px; }
.ws-cell.sel { border-color: var(--leaf); border-style: solid; box-shadow: 0 0 0 4px #bfe5a8; outline: none; }
.ws-cell:read-only { cursor: default; background: #fbf7ee; }
.ws-cell.ok { border-color: var(--ok); border-style: solid; background: #eef9e6; }
.ws-cell.wrong { border-color: var(--danger); border-style: solid; background: #fff0ee; }
.ws-cell.wrong::after { content: '!'; }
.ws-cell.empty { border-color: #e8a650; border-style: dashed; }
.ws-cell.struck { color: #a08a6e; text-decoration: line-through; text-decoration-color: var(--danger); }
.ws-cell.hint-target { border-color: #3b82c4; border-style: solid; animation: ws-glow 1.1s ease-in-out infinite alternate; }
@keyframes ws-glow { from { box-shadow: 0 0 0 2px #cfe5fa; } to { box-shadow: 0 0 0 8px #9cc7ea; } }
.ws-tools { display: grid; gap: 8px; align-content: start; position: sticky; top: 8px; background: var(--paper); border: 3px solid var(--wood-edge); border-radius: 20px; padding: 10px; box-shadow: 0 4px 0 rgba(91, 53, 20, .3); }
.ws-keypad { grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
.ws-keypad .key { min-height: 54px; }
.key-zero { grid-column: span 2; }
.ws-tool-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.key-tool { font-size: 15px; min-height: 46px; }
.key-danger { color: var(--danger); }
.ws-auto { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; min-height: 44px; }
.ws-auto input { width: 22px; height: 22px; }
/* 공용 키패드: 입력 대상 표시 + 연산 기호(공책 선택 때만) */
.kp-target { margin: 0; font-size: 14px; font-weight: 900; text-align: center; padding: 4px 10px; border-radius: 999px; background: #eef3f6; border: 2px solid #9fb0bd; }
[data-target="nb"] > .kp-target { background: #e5f6d8; border-color: var(--leaf-dark); color: #2f6619; }
.op-pad { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.key-op { min-height: 44px; font-size: 20px; padding: 0; }
.key-op:disabled { opacity: .35; cursor: not-allowed; }
.ws-tools .op-pad { grid-template-columns: repeat(5, minmax(0, 1fr)); } /* 270px 너비에서 5칸 × 2줄, 각 44px 이상 */
.kp-shared { display: grid; gap: 8px; justify-items: center; }
.kp-shared .op-pad { width: 100%; max-width: 330px; min-width: 266px; } /* Phase 9-B: 5칸이 각 44px 이상 되도록 최소 너비(204px일 때 36px였음) */

/* ---------- 자유 풀이 공책 (R29): 칸 레이어 + 필기 레이어, 채점 없음 ---------- */
.nb { min-width: 0; display: grid; gap: 8px; align-content: start; background: linear-gradient(var(--paper), var(--paper-2)); border: 3px solid var(--wood-edge); border-radius: 20px; padding: 10px; box-shadow: 0 4px 0 rgba(91, 53, 20, .3); }
.nb.active { border-color: var(--leaf-dark); box-shadow: 0 0 0 4px #bfe5a8, 0 4px 0 rgba(91, 53, 20, .3); }
.nb-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.nb-head-tools { margin-left: auto; display: flex; gap: 6px; }
.nb-head h3 { margin: 0; font-size: 18px; }
.nb-note { font-size: 13px; font-weight: 700; color: var(--text-soft); }
.nb-toolbar, .nb-penbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.nb-btn { min-height: 44px; padding: 4px 11px; border-radius: 12px; border: 2px solid var(--wood-2); background: #fff; font: inherit; font-size: 15px; font-weight: 800; color: var(--text); cursor: pointer; }
.nb-btn[aria-pressed="true"] { background: #e5f6d8; border-color: var(--leaf-dark); box-shadow: inset 0 0 0 2px var(--leaf); }
.nb-btn:disabled { opacity: .45; cursor: not-allowed; }
.nb-danger { color: var(--danger); }
.nb-penbar { display: none; padding: 6px; border-radius: 12px; background: #fff8ea; border: 2px dashed var(--paper-edge); }
.nb[data-mode="draw"] .nb-penbar { display: flex; }
.nb-color { display: inline-flex; align-items: center; gap: 6px; }
.nb-dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .2); }
.nb-c-p .nb-dot { background: #55524c; } .nb-c-k .nb-dot { background: #1d1d1b; } .nb-c-b .nb-dot { background: #2364c4; } .nb-c-r .nb-dot { background: #d23a2e; }
.nb-sep { width: 2px; align-self: stretch; background: var(--paper-edge); }
.nb-scroll { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.nb-paper { --cell: 44px; position: relative; width: 100%; min-width: calc(var(--cols) * 44px + 4px); margin: 0 auto; aspect-ratio: var(--cols) / var(--rows); background: #fffdf7; border: 2px solid #cdb98f; border-radius: 6px; overflow: hidden; }
.nb-cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 1fr)); }
.nb-cell {
  min-width: 0; width: 100%; height: 100%; box-sizing: border-box; margin: 0; padding: 0; border: 0; border-radius: 0;
  border-right: 1px solid #e6d6b4; border-bottom: 1px solid #e6d6b4; background: transparent; outline: none;
  font: inherit; font-size: calc(var(--cell) * .62); font-weight: 800; line-height: 1; text-align: center; color: #1d1d1b; caret-color: transparent; cursor: pointer;
}
.nb-cell.sel { background: #fff3c9; box-shadow: inset 0 0 0 2px #d9b65a; }
.nb.active[data-mode="type"] .nb-cell.sel { background: #e3f3d6; box-shadow: inset 0 0 0 3px var(--leaf); }
.nb[data-mode="draw"] .nb-cell.sel { background: transparent; box-shadow: none; }
.nb-cell.is-line { background-image: linear-gradient(transparent calc(50% - 2px), #1d1d1b calc(50% - 2px), #1d1d1b calc(50% + 2px), transparent calc(50% + 2px)); }
.nb-ink { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.nb[data-mode="draw"] .nb-ink { pointer-events: auto; touch-action: none; cursor: crosshair; }
.nb[data-mode="draw"][data-tool="eraser"] .nb-ink { cursor: cell; }
.nb-zoom-keys { display: none; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; }
.nb.zoomed[data-mode="type"] .nb-zoom-keys, .nb.inline-keys[data-mode="type"] .nb-zoom-keys { display: grid; }
.nb-key { min-height: 44px; padding: 0; font-size: 20px; }
.nb-overlay { position: fixed; inset: 0; z-index: 60; display: flex; justify-content: center; align-items: flex-start; overflow: auto; background: rgba(43, 32, 14, .55); padding: calc(8px + var(--safe-t)) calc(8px + var(--safe-r)) calc(8px + var(--safe-b)) calc(8px + var(--safe-l)); }
.nb.zoomed { width: min(100%, 1200px); }
.nb.zoomed .nb-paper { max-width: max(320px, calc((100dvh - 250px) * var(--cols) / 8)); }
body.nb-lock { overflow: hidden; }

@media (orientation: landscape) and (min-width: 761px) {
  /* 8줄이 화면 높이 안에 들어오도록 공책 너비 제한 (줄을 늘리면 아래로 이어짐) */
  .nb:not(.zoomed) .nb-paper { max-width: max(320px, calc((100dvh - 320px) * var(--cols) / 8)); }
}
@media (max-height: 820px) and (orientation: landscape) and (min-width: 761px) {
  /* 높이가 낮은 화면: 계산 칸·버튼 크기는 그대로, 여백과 장식(농부 그림·말풍선)만 줄인다 */
  .quest { gap: 6px; padding-top: calc(4px + var(--safe-t)); }
  .q-head { padding: 4px 10px; gap: 8px; }
  .q-farmer-img { height: 44px; }
  .q-bubble { padding: 4px 12px; font-size: 15px; border-width: 2px; }
  .q-body { gap: 10px; }
  .q-card { padding: 10px 14px 12px; gap: 8px; }
  .q-actions { padding-top: 6px; padding-bottom: calc(6px + var(--safe-b)); }
  .nb { padding: 8px; gap: 6px; }
  .ws-keypad .key { min-height: 46px; }
  .ws-tools { gap: 6px; padding: 8px; }
  .key-tool { min-height: 44px; }
}
@media (max-width: 1100px) and (orientation: landscape) {
  /* 태블릿 가로: 세 영역 유지, 키패드를 좁게. 자동 이동 설정은 키패드 위로 */
  .quest { padding-left: calc(8px + var(--safe-l)); padding-right: calc(8px + var(--safe-r)); }
  .q-actions { margin: 0 -8px; }
  .ws-body { grid-template-columns: fit-content(400px) minmax(300px, 1fr) 216px; gap: 8px; }
  .ws-tools .ws-auto { order: -1; }
  .ws-tools .kp-target { order: -2; }
  .ws-tools .op-pad { grid-template-columns: repeat(4, minmax(0, 1fr)); } /* 216px에서 4칸 × 3줄, 각 44px 이상 */
  .ws-tools .ws-tool-row .key-tool { font-size: 14px; }
  .ws-grid { --ws-cell: 48px; padding: 10px 12px; }
}
@media (max-width: 760px), (orientation: portrait) {
  /* 모바일·세로: 문제·세로셈 → 공책 → 키패드 순서 */
  .ws-body, .nb-body { grid-template-columns: minmax(0, 1fr); }
  .ws-tools { position: static; }
  .ws-grid { --ws-cell: 52px; padding: 10px; }
  .nb:not(.zoomed) .nb-paper { max-width: 560px; }
  .nb-zoom-keys { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); } /* Phase 9-B: 360px에서 7칸이면 42px → 들어가는 만큼(각 44px 이상) */
  .nb-btn { padding: 4px 9px; font-size: 14px; }
  .nb { padding: 8px; }
  .nb-toolbar, .nb-penbar { gap: 5px; }
}
@media (max-width: 480px) {
  .ws-grid { --ws-cell: 46px; gap: 4px; padding: 8px; }
  .ws-label { display: none; }
  .ws-keypad .key { min-height: 50px; }
}

/* ---------- 결과 화면: 나의 농장 소식 (Phase 4) ---------- */
.res-farm { margin: 10px 0; padding: 10px 12px; border-radius: 16px; background: #eef8e2; border: 2px solid var(--leaf); text-align: left; }
.res-farm h3 { margin: 0 0 6px; font-size: 18px; color: #2f6619; }
.res-farm p { margin: 4px 0; font-weight: 700; }
.res-farm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 0; }
.res-farm-grid div { background: #fff; border: 2px solid #cfe5b8; border-radius: 12px; padding: 6px 4px; text-align: center; }
.res-farm-grid dt { font-size: 12px; font-weight: 800; color: var(--text-soft); }
.res-farm-grid dd { margin: 2px 0 0; font-size: 18px; font-weight: 900; }
.res-farm-tip { color: #2b6aa8; }
@media (max-width: 760px), (orientation: portrait) { .res-farm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- 농장 화면 (Phase 4, R11·R12) ---------- */
.farm-shell {
  min-height: 100dvh; display: grid; grid-template-rows: auto auto 1fr; gap: 10px; max-width: 1500px; margin: 0 auto;
  padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) calc(16px + var(--safe-b)) calc(12px + var(--safe-l));
}
.farm-hud {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 20px;
  background: linear-gradient(rgba(255, 250, 238, .94), rgba(255, 244, 222, .94)); border: 3px solid var(--wood-edge); box-shadow: 0 4px 0 rgba(91, 53, 20, .4);
}
.farm-sign {
  flex: 1 1 220px; min-width: 0; padding: 6px 16px; border-radius: 14px; color: #fff7e6; text-shadow: 0 2px 0 rgba(0, 0, 0, .3);
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .06) 0 2px, transparent 2px 20px), linear-gradient(var(--wood-1), var(--wood-2));
  border: 3px solid var(--wood-edge); box-shadow: 0 4px 0 rgba(91, 53, 20, .45);
}
.farm-sign h1 { margin: 0; font-size: clamp(20px, 2.2vw, 28px); line-height: 1.2; }
.farm-sign p { margin: 0; font-size: 13px; font-weight: 700; opacity: .95; }
.farm-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.fstat { display: flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 4px 12px 4px 6px; background: var(--paper); border: 2px solid var(--paper-edge); border-radius: 14px; font-size: 18px; }
.fstat-ic { width: 32px; height: 32px; object-fit: contain; }
.fstat.lv div { display: grid; gap: 2px; }
.xpbar { display: block; width: 72px; height: 8px; border-radius: 999px; background: #ead7b3; border: 1px solid var(--wood-edge); overflow: hidden; }
.xpbar span { display: block; height: 100%; background: linear-gradient(#ffd86b, #f0a830); }
.farm-guide { display: flex; align-items: center; gap: 10px; min-width: 0; }
.farm-farmer { height: 76px; width: auto; flex: none; filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .25)); }
.farm-bubble { flex: 1; min-width: 0; background: #fff; border: 3px solid var(--wood-edge); border-radius: 18px; padding: 8px 14px; font-weight: 800; font-size: 16px; }
.farm-bubble p { margin: 0; }
.farm-bubble.bad { border-color: #e8a650; background: #fff6e8; }

/* PC: 도구 | 농장 | 정보·창고 */
.farm-main { display: grid; gap: 12px; align-items: start; grid-template-columns: minmax(270px, 310px) minmax(0, 1fr) minmax(250px, 300px); grid-template-areas: "tools field info" "tools field store"; }
.farm-tools { grid-area: tools; } .farm-field { grid-area: field; } .farm-info { grid-area: info; } .farm-store { grid-area: store; }
.farm-card { background: linear-gradient(var(--paper), var(--paper-2)); border: 3px solid var(--wood-edge); border-radius: 20px; padding: 10px 12px; box-shadow: 0 4px 0 rgba(91, 53, 20, .3); display: grid; gap: 8px; align-content: start; min-width: 0; }
.farm-card h2 { margin: 2px 0 0; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.ftool-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ftool {
  position: relative; display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 6px; min-height: 56px; padding: 4px 8px;
  border-radius: 14px; border: 2px solid var(--wood-2); background: #fff; cursor: pointer; text-align: left; font: inherit; color: var(--text); box-shadow: 0 3px 0 var(--wood-2);
}
.ftool-img { grid-row: 1 / span 2; width: 40px; height: 40px; object-fit: contain; }
.ftool-label { font-weight: 900; font-size: 15px; line-height: 1.2; word-break: keep-all; }
.ftool-count { font-size: 13px; font-weight: 800; color: var(--text-soft); }
.ftool.on { background: #e5f6d8; border-color: var(--leaf-dark); box-shadow: 0 0 0 3px #bfe5a8, 0 3px 0 var(--leaf-dark); }
.ftool.on::after { content: '선택'; position: absolute; top: -8px; right: 6px; font-size: 11px; font-weight: 900; color: #fff; background: var(--leaf-dark); padding: 0 6px; border-radius: 999px; }
.ftool.empty { opacity: .6; }
.ftool:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--wood-2); }
.ftool-now { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 800; font-size: 14px; color: var(--text-soft); }

.farm-field {
  position: relative; display: grid; justify-items: center; gap: 4px; padding: 10px 12px 8px; border-radius: 26px;
  background: rgba(255, 250, 236, .5); border: 3px solid rgba(91, 53, 20, .35); backdrop-filter: blur(2px);
}
.farm-buildings { display: flex; align-items: flex-end; justify-content: space-between; width: 100%; gap: 4%; }
.fb-house { width: 34%; } .fb-house img { width: 100%; max-height: 18vh; object-fit: contain; }
.fb-barn { position: relative; width: 36%; padding: 0; border: 0; background: none; cursor: pointer; min-height: var(--tap); }
.fb-barn img { width: 100%; max-height: 19vh; object-fit: contain; }
.fb-label { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); padding: 1px 10px; border-radius: 999px; font-weight: 900; font-size: 13px; color: #fff7e6; background: var(--wood-2); border: 2px solid var(--wood-edge); }
.farm-plot-area { display: flex; align-items: center; justify-content: center; gap: 2%; width: 100%; }
.f-scarecrow { width: 14%; max-height: 22vh; object-fit: contain; }
.farm-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; width: min(100%, 560px, calc((100dvh - 330px) * 1.15)); min-width: 270px; }
.fplot {
  position: relative; aspect-ratio: 189 / 174; min-height: var(--tap); padding: 0; border: 0; border-radius: 16px; background: none; cursor: pointer;
  transition: transform .1s ease;
}
.fplot-tile { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.fplot-crop { position: absolute; left: 10%; right: 10%; bottom: 20%; height: 72%; width: 80%; object-fit: contain; object-position: center bottom; pointer-events: none; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .2)); }
.fplot-crop.stage-0 { height: 40%; } .fplot-crop.stage-1 { height: 50%; } .fplot-crop.stage-2 { height: 60%; }
.fplot.st-locked .fplot-tile { filter: saturate(.35) brightness(.9); opacity: .8; }
.fplot-lock { position: absolute; width: 40%; left: 30%; top: 22%; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.fplot-bar { position: absolute; left: 14%; right: 14%; bottom: 7%; height: 9px; border-radius: 999px; background: rgba(255, 255, 255, .85); border: 1px solid var(--wood-edge); overflow: hidden; }
.fplot-bar span { display: block; height: 100%; background: linear-gradient(var(--leaf-light), var(--leaf)); }
.fplot-tag { position: absolute; top: 4%; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; font-weight: 900; padding: 0 8px; border-radius: 999px; background: #fff; border: 2px solid var(--paper-edge); color: var(--text); }
.fplot-tag.dry { background: #e3f1ff; border-color: #6aa5d8; color: #1f5f99; }
.fplot-tag.harvestable { background: #fff3c4; border-color: #e0a400; color: #8a5a00; }
.fplot-tag.empty, .fplot-tag.tilled { background: rgba(255, 255, 255, .88); color: var(--text-soft); font-weight: 800; }
.fplot-pend { position: absolute; right: 4%; top: 30%; font-size: 11px; font-weight: 900; padding: 0 6px; border-radius: 999px; background: #fff0f6; border: 2px solid #e58bb3; color: #8a2152; }
.fplot.st-harvestable { animation: f-ripe 1.2s ease-in-out infinite alternate; }
@keyframes f-ripe { from { filter: drop-shadow(0 0 2px #ffe27a); } to { filter: drop-shadow(0 0 12px #ffcf3a); } }
.fplot.can { outline: 4px solid #ffd23a; outline-offset: -2px; animation: f-can 1s ease-in-out infinite alternate; }
@keyframes f-can { from { outline-color: #ffe98a; } to { outline-color: #f0a830; } }
.fplot.dim { opacity: .62; }
.fplot.sel { box-shadow: 0 0 0 4px #2b7bd6; }
.fplot:focus-visible { outline: 4px solid #2b7bd6; outline-offset: 2px; }
.fplot:active { transform: scale(.97); }
.fplot.shake { animation: f-shake .35s ease; }
@keyframes f-shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.fplot-fx { position: absolute; left: 15%; top: 0; width: 70%; pointer-events: none; animation: f-fx 1.2s ease-out forwards; }
@keyframes f-fx { 0% { opacity: 0; transform: scale(.6) translateY(10px); } 30% { opacity: 1; transform: scale(1.05); } 100% { opacity: 0; transform: scale(1) translateY(-24px); } }
.f-fence { width: 70%; max-height: 8vh; object-fit: contain; margin-top: -4px; }

.finfo { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: center; }
.finfo-img { width: 64px; height: 64px; object-fit: contain; }
.finfo dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; font-size: 14px; }
.finfo dt { color: var(--text-soft); font-weight: 800; } .finfo dd { margin: 0; font-weight: 900; }
.finfo-empty { margin: 0; font-weight: 700; font-size: 14px; color: var(--text-soft); }
.frules { margin: 0; padding-left: 18px; font-size: 13px; font-weight: 700; color: var(--text-soft); display: grid; gap: 2px; }
.farm-quest-btn { width: 100%; }
.fstore-ic { width: 30px; height: 24px; object-fit: contain; }
.fstore-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fstore-list li { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 8px; padding: 4px 8px; background: #fff; border: 2px solid var(--paper-edge); border-radius: 12px; font-weight: 800; }
.fstore-img { width: 44px; height: 44px; object-fit: contain; }
.fstore-note { margin: 0; font-size: 12px; color: var(--text-soft); font-weight: 700; }

@media (max-width: 1180px) and (orientation: landscape) {
  /* 태블릿 가로: 도구 | 농장, 아래에 정보·창고 */
  .farm-main { grid-template-columns: minmax(220px, 260px) minmax(0, 1fr); grid-template-areas: "tools field" "info store"; }
}
@media (max-height: 820px) and (orientation: landscape) and (min-width: 761px) {
  .farm-shell { gap: 6px; padding-top: calc(4px + var(--safe-t)); }
  .farm-hud { padding: 4px 10px; }
  .farm-farmer { height: 48px; }
  .farm-bubble { padding: 4px 12px; font-size: 15px; border-width: 2px; }
  .fb-house img { max-height: 14vh; } .fb-barn img { max-height: 15vh; }
}
@media (max-width: 760px), (orientation: portrait) {
  /* 휴대폰·세로: 도구 → 밭 → 정보 → 창고 (도구를 밭 바로 위에) */
  .farm-main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tools" "field" "info" "store"; }
  .farm-farmer { height: 56px; }
  .ftool-row { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .farm-grid { width: min(100%, 560px); min-width: 0; }
  .fb-house img, .fb-barn img { max-height: 15vh; }
}
@media (max-width: 480px) {
  .farm-hud { gap: 6px; }
  .fstat { font-size: 16px; padding: 2px 8px 2px 4px; }
  .fstat-ic { width: 26px; height: 26px; }
  /* 도구·씨앗 버튼을 작게(그림 위·글자 아래, 3열) → 밭이 첫 화면 가까이 */
  .ftool-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .ftool { grid-template-columns: 1fr; grid-template-rows: auto auto auto; justify-items: center; text-align: center; min-height: 64px; padding: 4px 2px; row-gap: 0; }
  .ftool-img { grid-row: auto; width: 32px; height: 32px; }
  .ftool-label { font-size: 13px; }
  .ftool-count { font-size: 12px; }
  .farm-card { padding: 8px 10px; gap: 6px; }
  .farm-card h2 { font-size: 15px; }
  .fplot-tag { font-size: 11px; padding: 0 5px; }
  .f-scarecrow { display: none; }
}

/* ---------- 상점·시장 (Phase 5) ---------- */
.farm-nav { display: flex; gap: 6px; }
.econ-sign { display: flex; align-items: center; gap: 10px; }
.econ-sign-art { width: 52px; height: 52px; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }
.econ-main { display: grid; gap: 12px; align-items: start; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); }
.econ-main.market { grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); grid-template-areas: "board sell" "board ledger"; }
.econ-main.market .market-board { grid-area: board; } .econ-main.market .sell-panel { grid-area: sell; } .econ-main.market .ledger { grid-area: ledger; }
.shop-front { background: linear-gradient(#fff8ea, #f3e8d0); }
.econ-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.econ-tab { min-height: var(--tap); padding: 6px 14px; border-radius: 14px 14px 6px 6px; border: 2px solid var(--wood-2); background: #fff; font: inherit; font-weight: 900; font-size: 15px; color: var(--text); cursor: pointer; }
.econ-tab.on { color: #fff7e6; background: linear-gradient(var(--wood-1), var(--wood-2)); border-color: var(--wood-edge); }
/* 원목 진열대 */
.shelf {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; padding: 12px; border-radius: 16px;
  background: repeating-linear-gradient(180deg, transparent 0 128px, var(--wood-2) 128px 140px), linear-gradient(#e8c48d, #d9ab6b); border: 3px solid var(--wood-edge);
}
.shelf-item {
  position: relative; display: grid; justify-items: center; gap: 2px; padding: 8px 6px 10px; min-height: 150px; border-radius: 14px; cursor: pointer; font: inherit; color: var(--text);
  background: #fffdf5; border: 2px solid var(--paper-edge); box-shadow: 0 4px 0 rgba(91, 53, 20, .35);
}
.shelf-item.on { border-color: var(--leaf-dark); box-shadow: 0 0 0 3px #bfe5a8, 0 4px 0 var(--leaf-dark); }
.shelf-item.off { opacity: .7; cursor: default; }
.shelf-art { display: grid; place-items: center; height: 72px; width: 100%; }
.shelf-art img { max-height: 72px; max-width: 90%; object-fit: contain; }
.shelf-noart { font-size: 12px; font-weight: 800; color: var(--text-soft); border: 2px dashed var(--paper-edge); border-radius: 10px; padding: 14px 6px; }
.shelf-name { font-weight: 900; font-size: 15px; text-align: center; }
.shelf-owned { font-size: 12px; font-weight: 800; color: var(--text-soft); text-align: center; }
.price-tag { display: inline-flex; align-items: center; gap: 3px; padding: 1px 10px 1px 4px; border-radius: 999px; background: #fff3c4; border: 2px solid #e0a400; font-weight: 900; }
.price-tag .coin { width: 20px; height: 20px; object-fit: contain; }
.buy-panel, .sell-panel { position: sticky; top: 8px; }
.buy-head { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; }
.buy-head h2 { margin: 0; } .buy-head p { margin: 2px 0; font-weight: 700; font-size: 14px; color: var(--text-soft); }
.buy-img { width: 64px; height: 64px; object-fit: contain; }
.buy-label { font-weight: 900; font-size: 14px; }
.qty { display: grid; grid-template-columns: 56px minmax(56px, 90px) 56px; gap: 6px; align-items: center; }
.qty-btn { min-height: 52px; font: inherit; font-size: 28px; font-weight: 900; border-radius: 14px; border: 2px solid var(--wood-2); background: linear-gradient(#fff, #f2e9d6); box-shadow: 0 3px 0 var(--wood-2); cursor: pointer; color: var(--text); }
.qty-input { min-height: 52px; width: 100%; font: inherit; font-size: 26px; font-weight: 900; text-align: center; border: 3px solid var(--paper-edge); border-radius: 12px; background: #fff; }
.sell-qty { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.econ-dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 15px; }
.econ-dl dt { color: var(--text-soft); font-weight: 800; }
.econ-dl dd { margin: 0; font-weight: 900; text-align: right; }
.econ-dl dd.big { font-size: 22px; color: #2f6619; }
.econ-dl dd.bad, .econ-warn { color: var(--danger); }
.econ-dl dd.econ-note { grid-column: 1 / -1; text-align: left; }
.econ-warn { margin: 0; font-weight: 800; min-height: 1.4em; }
.econ-note { margin: 0; font-size: 13px; font-weight: 700; color: var(--text-soft); }
.btn-buy { width: 100%; min-height: 54px; font-size: 19px; }
.econ-confirm { display: grid; grid-template-columns: 80px 1fr; gap: 12px; align-items: center; min-width: min(360px, 80vw); }
.econ-confirm-img { width: 80px; height: 80px; object-fit: contain; }
.econ-mission-btn { justify-self: start; margin-top: 4px; }
.expand-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: min(100%, 420px); margin: 0 auto; }
.expand-cell { position: relative; aspect-ratio: 189 / 174; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 14px; }
.expand-cell img { width: 100%; height: 100%; object-fit: contain; }
.expand-cell.locked { outline: 3px dashed #e0a400; outline-offset: -3px; }
.expand-cell.open { cursor: default; }
.expand-lock { position: absolute; width: 40% !important; height: auto !important; left: 30%; top: 24%; }
.expand-open { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); font-weight: 900; background: #fff; border-radius: 999px; padding: 0 10px; border: 2px solid var(--leaf); }
/* 시세판·그래프 */
.price-board { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: 15px; }
.price-board caption { text-align: left; font-weight: 900; font-size: 18px; padding-bottom: 4px; }
.price-board th, .price-board td { padding: 6px 8px; text-align: left; background: #fff; }
.price-board thead th { background: transparent; font-size: 13px; color: var(--text-soft); }
.price-board tbody tr { cursor: pointer; }
.price-board tbody th { display: flex; align-items: center; gap: 6px; border-radius: 12px 0 0 12px; }
.price-board tbody td:last-child { border-radius: 0 12px 12px 0; }
.price-board tbody tr.on th, .price-board tbody tr.on td { background: #e5f6d8; }
.pb-img { width: 36px; height: 36px; object-fit: contain; }
.pb-now { font-weight: 900; font-size: 18px; }
.trend { font-weight: 900; white-space: nowrap; }
.trend.up { color: #c62828; } .trend.down { color: #1f5fa8; } .trend.same, .trend.none { color: #6b6b6b; }
.price-chart { margin: 8px 0 0; padding: 8px; background: #fff; border-radius: 14px; border: 2px solid var(--paper-edge); }
.price-chart { min-width: 0; } .price-chart .bars { overflow-x: auto; overflow-y: hidden; } /* Phase 9-B: 휴대폰에서 막대그래프가 카드 밖으로 넘치던 문제(격자 칸 min-width) */
.price-chart figcaption { font-weight: 900; font-size: 14px; margin-bottom: 4px; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; }
.bar-col { flex: 1; max-width: 64px; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; height: 100%; }
.bar-v { font-size: 13px; font-weight: 900; }
.bar-b { align-self: end; width: 70%; min-height: 4px; background: linear-gradient(#ffd86b, #f0a830); border: 2px solid #c98a1f; border-radius: 6px 6px 0 0; }
.bar-col.today .bar-b { background: linear-gradient(#8fd16a, var(--leaf)); border-color: var(--leaf-dark); }
.bar-d { font-size: 12px; font-weight: 800; color: var(--text-soft); }
.ledger-grid { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.ledger-grid div { background: #fff; border: 2px solid var(--paper-edge); border-radius: 12px; padding: 4px 8px; }
.ledger-grid dt { font-size: 12px; font-weight: 800; color: var(--text-soft); }
.ledger-grid dd { margin: 0; font-size: 18px; font-weight: 900; }
/* 꾸미기 마당 */
.decor-yard { width: 100%; display: grid; gap: 6px; }
.decor-slots { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; padding: 6px; border-radius: 16px; background: rgba(143, 209, 106, .35); border: 2px dashed rgba(61, 125, 37, .5); }
.decor-slot { position: relative; aspect-ratio: 1; min-height: var(--tap); display: grid; place-items: center; padding: 0; border-radius: 12px; background: rgba(255, 255, 255, .25); border: 2px solid transparent; font: inherit; }
.decor-slots.editing .decor-slot { cursor: pointer; border: 2px dashed var(--wood-2); background: rgba(255, 255, 255, .6); }
.decor-slot.can { border-color: #f0a830; box-shadow: 0 0 0 3px #ffe27a; }
.decor-slot.picked { border: 3px solid #2b7bd6; box-shadow: 0 0 0 3px #9cc7ea; }
.decor-img { width: 92%; height: 92%; object-fit: contain; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .2)); }
.decor-num { font-weight: 900; color: var(--text-soft); }
.decor-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; font-weight: 800; font-size: 14px; }
.decor-store { display: grid; gap: 4px; padding: 6px 8px; border-radius: 12px; background: #fff8ea; border: 2px solid var(--paper-edge); }
.decor-store-list { display: flex; flex-wrap: wrap; gap: 6px; }
.decor-pick { display: grid; justify-items: center; width: 84px; min-height: 84px; padding: 4px; border-radius: 12px; border: 2px solid var(--wood-2); background: #fff; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.decor-pick .decor-img { width: 52px; height: 52px; }
.decor-pick.on { border-color: #2b7bd6; box-shadow: 0 0 0 3px #9cc7ea; }

@media (min-width: 1101px) {
  /* PC: 진열대를 넓게, 상품을 크게 */
  .shelf { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; padding: 16px; background: repeating-linear-gradient(180deg, transparent 0 196px, var(--wood-2) 196px 210px), linear-gradient(#e8c48d, #d9ab6b); }
  .shelf-item { min-height: 196px; }
  .shelf-art { height: 112px; } .shelf-art img { max-height: 112px; }
  .shelf-name { font-size: 17px; }
  .price-tag { font-size: 17px; }
}
@media (max-width: 1100px) and (orientation: landscape) {
  .econ-main, .econ-main.market { grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); }
}
@media (max-width: 760px), (orientation: portrait) {
  .econ-main, .econ-main.market { grid-template-columns: minmax(0, 1fr); grid-template-areas: none; }
  .econ-main.market .market-board, .econ-main.market .sell-panel, .econ-main.market .ledger { grid-area: auto; }
  .buy-panel, .sell-panel { position: static; }
  .decor-slots { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); background: linear-gradient(#e8c48d, #d9ab6b); }
  .price-board { font-size: 13px; }
  .price-board th, .price-board td { padding: 4px; }
  .pb-img { width: 26px; height: 26px; }
  .ledger-grid dd { font-size: 16px; }
}

/* ---------- 장기 학습 화면 (Phase 6) ---------- */
.prog-main { display: grid; gap: 12px; align-content: start; max-width: 1200px; width: 100%; margin: 0 auto; }
.prog-praise { margin: 0; padding: 8px 14px; border-radius: 14px; background: #eef8e2; border: 2px solid var(--leaf); font-weight: 800; }
/* 원목 배지 진열장 */
.badge-shelf { background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .06) 0 2px, transparent 2px 22px), linear-gradient(#c98a4b, #a8692f); border-color: var(--wood-edge); }
.badge-shelf h2 { color: #fff7e6; text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.badge-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding-bottom: 6px; border-bottom: 10px solid #7a4a1f; }
.badge-slot { display: grid; justify-items: center; gap: 3px; padding: 8px 4px; min-height: 150px; border-radius: 14px; border: 2px solid rgba(255, 255, 255, .5); background: rgba(255, 248, 234, .92); cursor: pointer; font: inherit; color: var(--text); }
.badge-img { width: 84px; height: 84px; object-fit: contain; }
.badge-slot.locked .badge-img, .bd-img.locked { filter: grayscale(1) opacity(.45); }
.badge-name { font-weight: 900; font-size: 14px; text-align: center; word-break: keep-all; }
.badge-tag { font-size: 12px; font-weight: 800; padding: 0 8px; border-radius: 999px; background: #eef3f6; border: 1px solid #9fb0bd; }
.badge-tag.got { background: #fff3c4; border-color: #e0a400; }
.badge-detail { display: grid; gap: 10px; justify-items: center; min-width: min(360px, 80vw); }
.bd-img { width: 120px; height: 120px; object-fit: contain; }
.badge-detail .econ-dl, .badge-detail .bar { width: 100%; }
/* 농작물 도감 책 */
.book { background: linear-gradient(90deg, var(--paper-2) 0 49.6%, #c9a46a 49.6% 50.4%, var(--paper-2) 50.4%); border-width: 5px; border-color: #7a4a1f; }
.book-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding: 8px; }
.book-card { display: grid; justify-items: center; gap: 4px; padding: 10px 6px; min-height: 180px; border-radius: 14px; border: 2px dashed #c9a46a; background: #fffdf5; cursor: pointer; font: inherit; color: var(--text); }
.book-card.found { border-style: solid; border-color: var(--leaf); }
.book-img { width: 96px; height: 96px; object-fit: contain; }
.silhouette { filter: brightness(0) opacity(.25); }
.book-name { font-weight: 900; font-size: 17px; } .book-sub { font-size: 13px; font-weight: 800; color: var(--text-soft); }
.crop-detail { display: grid; gap: 10px; min-width: min(420px, 82vw); }
.cd-stages { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.cd-stages figure { margin: 0; text-align: center; } .cd-stages img { width: 100%; height: 56px; object-fit: contain; }
.cd-stages figcaption { font-size: 11px; font-weight: 800; color: var(--text-soft); }
.cd-desc { margin: 0; font-weight: 700; }
/* 성장 기록 */
.lv-card { grid-template-columns: 90px 1fr; align-items: center; }
.lv-fx { width: 90px; height: 90px; object-fit: contain; }
.lv-card h2 { margin: 0; } .lv-card p { margin: 2px 0 6px; font-weight: 700; }
.growth-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.bars.many { gap: 2px; } .bars.many .bar-d { font-size: 10px; } .bars.many .bar-v { font-size: 10px; }
.bar-none { align-self: end; font-weight: 900; color: #b9a98a; }
/* 출석 달력 */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-head h2 { margin: 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-weight: 900; font-size: 13px; color: var(--text-soft); }
.cal-cell { position: relative; display: grid; justify-items: center; align-content: start; min-height: 58px; padding: 3px 2px; border-radius: 12px; background: #fff; border: 2px solid #eadcbd; }
.cal-cell.empty { background: transparent; border: 0; }
.cal-cell.today { box-shadow: 0 0 0 3px #2b7bd6; }
.cal-num { font-weight: 900; font-size: 14px; }
.cal-lab { font-size: 11px; font-weight: 900; }
.cal-star { position: absolute; right: 2px; top: 2px; width: 20px; height: 20px; }
.st-visit { background: #eef3f6; border-color: #9fb0bd; } .st-learn { background: #e5f6d8; border-color: var(--leaf); } .st-complete { background: #fff3c4; border-color: #e0a400; }
.cal-legend { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px; font-weight: 800; font-size: 13px; }
.cal-legend li { display: flex; align-items: center; gap: 6px; }
.cal-key { width: 18px; height: 18px; border-radius: 6px; border: 2px solid; display: inline-block; }
.att-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.att-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 6px 10px; background: #fff; border: 2px solid var(--paper-edge); border-radius: 12px; font-weight: 700; }
.att-item.done { border-color: var(--leaf); background: #f3fbec; }
.att-st { font-size: 13px; color: var(--text-soft); font-weight: 800; }
/* 주간 미션 게시판 */
.mission-board { background: repeating-linear-gradient(180deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 26px), linear-gradient(#c98a4b, #a8692f); }
.mission-board h2, .mission-board > .econ-note { color: #fff7e6; }
.mission-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mission { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; background: #fffdf5; border: 2px solid var(--paper-edge); box-shadow: 0 3px 0 rgba(91, 53, 20, .35); }
.mission.done { border-color: var(--leaf); }
.mission-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; align-items: center; }
.mission-st { font-size: 13px; font-weight: 800; color: var(--text-soft); }
/* 오답 노트 공책 */
.notebook-card { background-color: #fffdf6; background-image: linear-gradient(transparent 27px, #d6e6f5 28px); background-size: 100% 28px; border-left: 14px solid #e58b6b; }
.note-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.note-card { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .92); border: 2px solid var(--paper-edge); display: grid; gap: 4px; }
.note-card.solved { border-color: var(--leaf); }
.note-card p { margin: 0; }
.note-concept { font-size: 12px; font-weight: 800; color: var(--text-soft); }
.note-q { font-weight: 900; font-size: 17px; word-break: keep-all; }
.note-my { font-size: 14px; font-weight: 700; }
.note-err { font-size: 14px; color: #8a5a00; }
.note-ok { font-weight: 900; color: #2f6619; }
.note-ans { font-weight: 900; color: #2b6aa8; }
.note-actions { display: flex; flex-wrap: wrap; gap: 6px; }
/* 축하 창 */
.cel { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; min-width: min(420px, 82vw); }
.cel-farmer { width: 120px; }
.cel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cel-item { display: flex; align-items: center; gap: 8px; font-weight: 900; }
.cel-badge { width: 48px; height: 48px; object-fit: contain; }
/* 메인 요약 */
.main-sum { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: 100%; }
.sum-chip { display: grid; gap: 0; text-align: left; min-height: var(--tap); padding: 4px 10px; border-radius: 12px; border: 2px solid var(--paper-edge); background: #fff; font: inherit; color: var(--text); cursor: pointer; }
.sum-chip:disabled { cursor: default; }
.sum-k { font-size: 11px; font-weight: 800; color: var(--text-soft); }
.sum-chip strong { font-size: 14px; }
@media (max-width: 480px) {
  .badge-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book-pages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-cell { min-height: 46px; } .cal-lab { font-size: 10px; }
  .cel { grid-template-columns: 1fr; justify-items: center; }
  .lv-card { grid-template-columns: 1fr; }
  .att-item { grid-template-columns: auto 1fr; } .att-st { grid-column: 1 / -1; }
}

/* 움직임 줄이기 (R28) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
[data-animation="off"] *, [data-animation="off"] *::before { animation: none !important; transition: none !important; }

/* ---------- 부모님 관리 (Phase 7): 차분한 아이보리·초록, 큰 터치 영역, 캐릭터 최소 ---------- */
.pa-shell { --pa-bg: #fbf8ef; --pa-card: #fffdf6; --pa-line: #e4dcc6; --pa-green: #3f7a3a; --pa-green-2: #e5f0dc; --pa-text: #2f3a2b; --pa-soft: #6a705f;
  min-height: 100vh; background: var(--pa-bg); color: var(--pa-text); padding: calc(12px + var(--safe-t)) calc(14px + var(--safe-r)) calc(28px + var(--safe-b)) calc(14px + var(--safe-l)); }
.pa-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; max-width: 1100px; margin: 0 auto 12px; }
.pa-title h1 { margin: 0; font-size: 24px; color: var(--pa-green); }
.pa-title p { margin: 2px 0 0; color: var(--pa-soft); font-size: 15px; }
.pa-head-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.pa-btn { min-height: var(--tap); padding: 8px 16px; border-radius: 12px; border: 1.5px solid var(--pa-line); background: #fff; color: var(--pa-text); font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit; }
.pa-btn-main { background: var(--pa-green); border-color: var(--pa-green); color: #fff; }
.pa-btn:focus-visible, .pa-tab:focus-visible, .pa-chip:focus-visible, .pa-seg-btn:focus-visible, .pa-qitem:focus-visible { outline: 3px solid #2b7bd6; outline-offset: 2px; }
.pa-seg, .pa-tabs, .pa-period, .pa-body { max-width: 1100px; margin-left: auto; margin-right: auto; }
.pa-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #efe9d8; padding: 5px; border-radius: 14px; margin-bottom: 10px; }
.pa-seg-btn { min-height: 48px; border: 0; border-radius: 10px; background: transparent; font-size: 17px; font-weight: 800; color: var(--pa-soft); cursor: pointer; font-family: inherit; }
.pa-seg-btn.on { background: #fff; color: var(--pa-green); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.pa-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: thin; }
.pa-tab { flex: 0 0 auto; min-height: var(--tap); padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--pa-line); background: #fff; font-size: 15px; font-weight: 700; color: var(--pa-text); cursor: pointer; font-family: inherit; }
.pa-tab.on { background: var(--pa-green-2); border-color: var(--pa-green); color: var(--pa-green); }
.pa-period { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pa-chip { min-height: var(--tap); padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--pa-line, #e4dcc6); background: #fff; font-size: 15px; font-weight: 700; cursor: pointer; color: var(--pa-text, #2f3a2b); font-family: inherit; }
.pa-chip.on { background: var(--pa-green, #3f7a3a); border-color: var(--pa-green, #3f7a3a); color: #fff; }
.pa-body { display: grid; gap: 12px; }
.pa-card { background: var(--pa-card); border: 1px solid var(--pa-line); border-radius: 16px; padding: 16px; min-width: 0; }
.pa-card h2 { margin: 0 0 10px; font-size: 19px; color: var(--pa-green); }
.pa-card h3 { margin: 10px 0 6px; font-size: 16px; }
.pa-gate { max-width: 440px; margin: 24px auto; display: grid; gap: 12px; }
.pa-field { display: grid; gap: 4px; font-weight: 700; margin-bottom: 8px; }
.pa-field input { min-height: 48px; font-size: 18px; padding: 8px 12px; border: 1.5px solid var(--pa-line); border-radius: 10px; background: #fff; font-family: inherit; width: 100%; }
.pa-field small { font-weight: 500; color: var(--pa-soft); }
.pa-pin { letter-spacing: 6px; font-size: 24px !important; text-align: center; }
.pa-msg { min-height: 1.4em; margin: 4px 0; color: #9a3b1f; font-weight: 700; }
.pa-note { margin: 8px 0 0; color: var(--pa-soft, #6a705f); font-size: 14px; }
.pa-empty { margin: 4px 0; color: var(--pa-soft); }
.pa-forgot summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--pa-soft); }
.pa-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.pa-stat { background: #fff; border: 1px solid var(--pa-line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; min-width: 0; align-content: start; }
.pa-stat-l { font-size: 13px; color: var(--pa-soft); }
.pa-stat strong { font-size: 21px; overflow-wrap: anywhere; } /* 긴 봇 이름 등도 잘리지 않게 */
.pa-stat small { font-size: 12px; color: var(--pa-soft); overflow-wrap: anywhere; }
.pa-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pa-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.pa-table th, .pa-table td { border-bottom: 1px solid var(--pa-line, #e4dcc6); padding: 8px 6px; text-align: left; vertical-align: top; }
.pa-table thead th { background: #f3eedf; font-size: 13px; white-space: nowrap; }
.pa-table caption { text-align: left; font-weight: 700; padding-bottom: 6px; }
.pa-chart { width: 100%; height: auto; max-height: 260px; display: block; }
.pa-chart-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pa-banner { max-width: 1100px; margin: 0 auto 10px; padding: 10px 14px; border-radius: 12px; border: 2px solid #c0392b; background: #fff4f2; color: #7a2018; font-weight: 700; }
.pa-banner p { margin: 0 0 6px; }
.pa-range { max-width: 1100px; margin: -4px auto 10px; font-size: 15px; font-weight: 700; color: var(--pa-soft, #6a705f); }
@media (max-width: 600px) { .pa-chart { min-width: 520px; max-height: none; } .pa-chart .pa-axis { font-size: 14px; } } /* 휴대폰에서 그래프 글자 약 11px 이상 유지(넘치면 그래프만 가로 스크롤) */
.pa-chart .pa-grid { stroke: #e7e0cc; stroke-width: 1; }
.pa-chart .pa-axis { font-size: 12px; fill: #6a705f; }
.pa-chart .pa-bar { fill: #cfe3c0; }
.pa-chart .pa-line { fill: none; stroke: #3f7a3a; stroke-width: 3; }
.pa-chart .pa-dot { fill: #3f7a3a; }
.pa-legend { font-size: 13px; color: var(--pa-soft); margin: 4px 0; }
.pa-details summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; font-weight: 700; color: var(--pa-green, #3f7a3a); }
.pa-qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pa-qitem { width: 100%; min-height: 52px; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 8px; align-items: center; text-align: left; background: #fff; border: 1px solid var(--pa-line); border-radius: 12px; padding: 8px 10px; font-size: 15px; cursor: pointer; font-family: inherit; color: var(--pa-text); }
.pa-q-date { color: var(--pa-soft); font-size: 13px; }
.pa-q-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pa-q-tag { font-size: 13px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #eee; white-space: nowrap; }
.pa-q-tag.ok { background: #dcefd4; color: #2e6b26; }
.pa-q-tag.fix { background: #fdf0cf; color: #7a5a0a; }
.pa-q-tag.todo { background: #f3e3dc; color: #8a3b22; }
.pa-modal { max-width: min(820px, calc(100vw - 16px)); }
.pa-modal .modal-box { max-height: calc(100vh - 32px); overflow: auto; background: #fffdf6; }
.pa-detail { display: grid; gap: 10px; text-align: left; min-width: 0; }
.pa-d-q { font-size: 18px; font-weight: 800; margin: 0; }
.pa-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; margin: 0; }
.pa-dl div { background: #fff; border: 1px solid #e4dcc6; border-radius: 10px; padding: 6px 10px; min-width: 0; }
.pa-dl dt { font-size: 12px; color: #6a705f; }
.pa-dl dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.pa-ws { overflow-x: auto; min-width: 0; }
.pa-ws .ws-grid { --ws-cell: 42px; }
.pa-nb { width: 100%; max-width: 520px; height: auto; background: #fff; border: 1px solid #e4dcc6; border-radius: 8px; }
.pa-nb .pa-nb-grid { stroke: #e6eef7; stroke-width: 1; }
.pa-nb .pa-nb-ch { font-size: 20px; font-weight: 700; fill: #1d1d1b; }
.pa-rec { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.pa-rec li { background: #fff; border: 1px solid var(--pa-line); border-radius: 12px; padding: 8px 10px; }
.pa-rec small { display: block; color: var(--pa-soft); margin-top: 2px; }
.pa-reasons { display: grid; gap: 4px; margin-top: 4px; }
.pa-reason { display: block; }
.pa-check { display: flex; gap: 10px; align-items: flex-start; min-height: var(--tap); padding: 6px 0; cursor: pointer; }
.pa-check input { width: 24px; height: 24px; flex: 0 0 24px; margin: 2px 0 0; accent-color: #3f7a3a; }
.pa-units { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.pa-unit { border: 1px solid var(--pa-line); border-radius: 12px; padding: 4px 12px 8px; margin: 0; background: #fff; min-width: 0; }
.pa-unit legend { padding: 0 4px; }
.pa-concept { padding-left: 14px; font-size: 15px; }
.pa-concept input:disabled + span { color: #aaa; }
.pa-sub { margin: 12px 0 4px; font-weight: 700; }
.pa-radios { display: flex; flex-wrap: wrap; gap: 6px; }
.pa-radio { display: flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 4px 12px; border: 1.5px solid var(--pa-line); border-radius: 999px; background: #fff; cursor: pointer; }
.pa-radio input { width: 20px; height: 20px; accent-color: #3f7a3a; }
.pa-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pa-sticky { position: sticky; bottom: calc(8px + var(--safe-b)); z-index: 2; justify-content: center; }
.pa-file { min-height: 48px; font-size: 16px; max-width: 100%; }
.pa-restore { margin-top: 12px; display: grid; gap: 10px; }
.pa-warn { color: #8a4b0f; background: #fdf3dc; border: 1px solid #f0d9a5; border-radius: 10px; padding: 8px 12px 8px 28px; margin: 6px 0; }
p.pa-warn { padding-left: 12px; }
.pa-meter { height: 16px; background: #efe9d8; border-radius: 999px; overflow: hidden; }
.pa-meter span { display: block; height: 100%; background: #6aa55a; }
/* 리포트(이미지로 저장되는 영역만): 외부 이미지 없음 → 캔버스 오염 없음 */
.rp { background: #fffdf6; color: #2f3a2b; padding: 20px; border-radius: 14px; border: 2px solid #cfe3c0; max-width: 760px; width: 100%; margin: 0 auto; }
.rp-head h2 { margin: 0; color: #3f7a3a; font-size: 22px; }
.rp-head p { margin: 2px 0 10px; color: #6a705f; }
.rp-praise { background: #eef6e6; border-radius: 10px; padding: 10px 12px; font-weight: 700; margin: 0 0 12px; }
.rp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.rp-row { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed #e4dcc6; padding: 6px 2px; }
.rp-row span { color: #6a705f; }
.rp-sec h3 { margin: 14px 0 4px; font-size: 16px; color: #3f7a3a; }
.rp-sec ul { margin: 0; padding-left: 20px; }
.rp-foot { margin: 14px 0 0; font-size: 12px; color: #8a8f80; text-align: right; }
@media (max-width: 520px) {
  .pa-title h1 { font-size: 21px; }
  .pa-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pa-stat strong { font-size: 18px; }
  .pa-qitem { grid-template-columns: 44px minmax(0, 1fr); }
  .pa-q-tag { grid-column: 2; justify-self: start; }
  .pa-card { padding: 12px; }
  .rp { padding: 14px; }
}

/* ---------- 문제 번호 이동 (Phase 7 보완): 상태는 글자(aria-label·title)+모양+색으로 구분 ---------- */
.q-nav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 4px; padding: 6px 8px; background: rgba(255, 248, 234, .92); border-radius: 14px; border: 2px solid var(--paper-edge); }
.qn { min-width: 46px; min-height: 46px; padding: 0 8px; border-radius: 12px; border: 2px solid var(--paper-edge); background: #fff; font: 800 17px/1 var(--font); color: var(--text); cursor: pointer; }
.qn-empty { background: #fff; border-style: dashed; color: var(--text-soft); }
.qn-done { background: #dff0d2; border-color: var(--leaf); }
.qn-need { background: #fff1cc; border-color: #d9a520; }
.qn-ok { background: #dff0d2; border-color: var(--leaf); }
.qn-no, .qn-retry { background: #fde4dc; border-color: #d27a5c; }
.qn-blank-graded { background: #eee; border-color: #aaa; }
.qn-solved { background: #d7ecff; border-color: #2b7bd6; color: #1d4f8f; }
.qn-studied { background: #eee; border-color: #bbb; color: #777; }
.qn-cur { outline: 4px solid #2b7bd6; outline-offset: 1px; transform: translateY(-1px); }
.qn:disabled { cursor: default; opacity: .85; }
.qn:focus-visible { outline: 4px solid #2b7bd6; outline-offset: 2px; }
.qn-legend { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-soft); margin-left: 4px; }
.qn-dot { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--paper-edge); }
.qn-dot.qn-empty { border-style: dashed; }
.grade-dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 8px 0; text-align: left; }
.grade-dl div { background: #fff; border: 1px solid var(--paper-edge); border-radius: 10px; padding: 6px 10px; }
.grade-dl dt { font-size: 13px; color: var(--text-soft); }
.grade-dl dd { margin: 0; font-weight: 800; font-size: 18px; }
@media (max-width: 520px) { .qn { min-width: 46px; font-size: 16px; } .q-nav { gap: 5px; padding: 6px; } .qn-legend { width: 100%; margin: 2px 0 0; } }

/* 외부 연결(Phase 8) */
.pa-code { letter-spacing: 3px; text-transform: uppercase; font-size: 20px !important; }

/* ---------- 그림 선택형·수직선 (Phase 9-A): 고른 보기는 테두리·'(선택)' 글자로 표시, 정답 여부는 채점 전 비공개 ---------- */
.pic-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 8px 0; }
.pic-choice { display: grid; grid-template-rows: auto 1fr; gap: 4px; min-height: 120px; padding: 8px; border: 3px solid var(--paper-edge); border-radius: 16px; background: #fff; cursor: pointer; font-family: inherit; color: var(--text); touch-action: manipulation; }
.pic-choice:hover:not(:disabled) { border-color: var(--leaf); }
.pic-choice.on { border-color: var(--leaf-dark); background: #eef8e6; box-shadow: inset 0 0 0 2px var(--leaf); }
.pic-choice:focus-visible { outline: 4px solid #2b7bd6; outline-offset: 2px; }
.pic-choice:disabled { cursor: default; }
.pic-num { justify-self: start; font-weight: 900; font-size: 17px; padding: 2px 10px; border-radius: 999px; background: var(--paper-2); }
.pic-choice.on .pic-num::after { content: ' (선택)'; font-size: .8em; }
.pic-art { display: grid; place-items: center; min-height: 0; }
.pic-art svg { width: 100%; height: auto; max-height: 170px; }
.nl-pick { margin: 8px 0; min-width: 0; max-width: 100%; } /* 격자 칸 안에서 카드 폭을 넘기지 않고 가로 스크롤 */
.nl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 4px 0; }
.nl-svg { display: block; margin: 0 auto; touch-action: manipulation; }
.nl-tick { cursor: pointer; outline: none; }
.nl-tick .nl-mark { opacity: 0; }
.nl-tick.on .nl-mark { opacity: 1; }
.nl-tick.on .nl-line { stroke: #f08a24; stroke-width: 5; }
.nl-tick:hover .nl-hit { fill: rgba(90, 168, 58, .12); }
.nl-tick:focus-visible .nl-hit { fill: rgba(43, 123, 214, .15); stroke: #2b7bd6; stroke-width: 2; }
.nl-pick.disabled .nl-tick { cursor: default; }
.nl-status { margin: 2px 0 0; font-size: 14px; color: var(--text-soft); text-align: center; }
@media (max-height: 820px) and (min-width: 900px) { .pic-choice { min-height: 0; padding: 6px; } .pic-art svg { max-height: 118px; } }
@media (max-width: 520px) { .pic-choices { gap: 8px; } .pic-choice { min-height: 104px; padding: 6px; } .pic-art svg { max-height: 130px; } }
