/* tama v2 화면(설계서 §1, 2026-10-20 UI 검토 ui_r1 개편). 모든 크기는 390×780 디자인 px이고 무대(.stage)가
   transform: scale(s)로 통째로 줄고 는다. 배치: 상단 바 0–64 · 도트 화면 64–384 · 상태 줄 384–424 · 안내 슬롯 424–480 ·
   도구 480–612 · 행동 612–700 · 하단 탭 700–772 · 여백 8. 작업 패널은 424–700을 바꿔 끼운다(배경을 어둡게 하지 않음).
   글자: 제목 20/26, 본문 16~17/22, 보조 14~15/20. 터치 대상 ≥ 48 디자인 px(배율이 작으면 44 CSS px가 되도록 키움).
   글꼴: 제목·숫자·버튼·탭·상태 = Galmuri11(도트, OFL), 본문·설명 = Pretendard(OFL, KS X 1001 서브셋 400·600). 모두 assets/fonts의 로컬 파일만. */

@font-face {
  font-family: 'Galmuri11';
  src: url('../assets/fonts/Galmuri11.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Galmuri11';
  src: url('../assets/fonts/Galmuri11-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('../assets/fonts/Pretendard-Regular.subset.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('../assets/fonts/Pretendard-SemiBold.subset.woff2') format('woff2');
  font-weight: 600 700;
  font-display: swap;
}

:root {
  --cream: #fff6ec;
  --paper: #fffbf5;
  --coral: #e87c5c;
  --coral-ink: #a84a2c;   /* 글자용 진한 산호(크림 위 대비 4.5 이상) */
  --btn: #b4532f;         /* 흰 글자를 올리는 주 버튼 바탕(흰 글자 대비 4.9) */
  --peach: #fcc8b4;
  --peach-soft: #fde3d6;
  --ink: #4a3530;
  --ink-soft: #6e5650;    /* 크림 위 6.3:1 */
  --line: #f0cdbb;
  --line-strong: #d9a58e;
  --mint: #cfeedd;
  --shadow: rgba(120, 70, 50, 0.16);
  --letterbox: #f6eee4;
  --good: #2f7a52;
  --warn: #9a4a22;        /* 흰 글자 대비 6.0 */
  --error: #8a2f22;
  --note-bg: #4a3530;     /* 결과 안내 바탕(밝은 글자) */
  --note-ink: #fffbf5;
  --font-pixel: 'Galmuri11', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-body: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --tap: clamp(48px, calc(44px / var(--s, 1)), 62px);
  --panel-scale: 1;
  color-scheme: light;
}

/* 게임 시계 밤(19:00~05:59)엔 어두운 판 */
:root[data-theme="night"] {
  --cream: #2f2a44;
  --paper: #3a3452;
  --coral: #f08f70;
  --coral-ink: #ffb59c;
  --btn: #c8613d;
  --peach: #6f5068;
  --peach-soft: #4a3f60;
  --ink: #f8ece4;
  --ink-soft: #d6c8de;
  --line: #5d5078;
  --line-strong: #7d6f9a;
  --mint: #34544a;
  --shadow: rgba(0, 0, 0, 0.35);
  --letterbox: #2b2540;
  --good: #2f7a52;
  --warn: #a8562c;
  --note-bg: #f8ece4;
  --note-ink: #2f2a44;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--letterbox);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 22px;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  font-family: var(--font-pixel);
  color: inherit;
  touch-action: manipulation;
  cursor: pointer;
}
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }

/* 안내(튜토리얼) 대상 = 2px 외곽선만(확대·점멸 없음). 선택 = 채움 + 밑줄, 잠금 = 자물쇠 — 서로 다른 규칙 */
.guide-target { outline: 2px solid var(--coral) !important; outline-offset: -2px; }
#pixel.guide-target { outline-offset: 2px; }

/* ------------------------------------------------------------ 무대·캔버스 */

.stage {
  position: fixed;
  left: 0;
  top: 0;
  width: 390px;
  height: 780px;
  transform-origin: 0 0;
  touch-action: none;
}
#ui-base { z-index: 1; background: var(--cream); overflow: hidden; }
#pixel {
  position: fixed;
  z-index: 2;
  left: 0;
  top: 0;
  width: 288px;
  height: 288px;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
  background: transparent;
}
#pixel:focus-visible { outline: 3px solid var(--coral); }
#ui-over { z-index: 3; pointer-events: none; }
#ui-over > * { pointer-events: auto; }
#ui-over > [hidden] { display: none !important; }

/* ------------------------------------------------------------ 상단 바 (0,0,390,64) */

#topbar {
  position: absolute; left: 0; top: 0; width: 390px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 0 8px;
  background: var(--paper);
  border-bottom: 2px solid var(--line);
}
.tb-left {
  height: 56px; min-width: 120px; max-width: 220px;
  border: 0; background: transparent; border-radius: 12px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 0 8px; text-align: left;
}
.tb-left:active { background: var(--peach-soft); }
.tb-name { font-family: var(--font-pixel); font-size: 18px; line-height: 22px; font-weight: 700; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-sub { font-family: var(--font-pixel); font-size: 14px; line-height: 18px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.tb-right { display: flex; align-items: center; gap: 10px; }
.tb-doto { display: flex; align-items: center; gap: 4px; font-family: var(--font-pixel); font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tb-doto-icon { display: inline-flex; }
.tb-lv-btn {
  min-width: 56px; height: 48px; border-radius: 12px; border: 2px solid var(--line-strong);
  background: var(--paper); box-shadow: 0 2px 0 var(--line);
  display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 3px; padding: 0 8px;
}
.tb-lv-btn:active { transform: translateY(2px); box-shadow: none; }
.tb-lv { font-size: 15px; line-height: 18px; font-weight: 700; color: var(--coral-ink); white-space: nowrap; }
.tb-lv-bar { display: block; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.tb-lv-bar > i { display: block; height: 100%; width: 0; background: var(--coral); transition: width .4s; }

/* ------------------------------------------------------------ 보호된 도트 화면 (64–384, 캔버스는 #pixel이 그 위) */

#screen-slot {
  position: absolute; left: 16px; top: 68px; width: 358px; height: 312px;
  border-radius: 16px;
  background: var(--peach-soft);
  box-shadow: inset 0 0 0 2px var(--line);
}

/* ------------------------------------------------------------ 상태 줄 (384,40) — 보기 전용(평면) */

#status {
  position: absolute; left: 16px; top: 384px; width: 358px; height: 40px;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-pixel); font-size: 16px; line-height: 20px;
}
.st-main { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; white-space: nowrap; }
.st-item { display: inline-flex; align-items: center; gap: 4px; }
.st-item b { font-weight: 700; font-variant-numeric: tabular-nums; }
.st-item.warn b { color: var(--coral-ink); }
.st-sep { color: var(--ink-soft); }
.st-chips { display: flex; gap: 4px; }
.st-chip { height: 26px; border-radius: 8px; padding: 0 6px; display: inline-flex; align-items: center; font-size: 14px; background: var(--peach-soft); color: var(--ink); }
.st-chip.warn { background: var(--peach); font-weight: 700; }

/* ------------------------------------------------------------ 단일 안내·결과 슬롯 (424,56) / 패널 안 결과 줄 */

.notice {
  position: absolute; left: 16px; top: 424px; width: 358px; height: 56px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 4px 0 12px; border-radius: 14px;
  font-family: var(--font-body); font-size: 16px; line-height: 20px;
  overflow: hidden;
}
.notice.empty { padding: 0; }
.notice.l-hint { background: var(--paper); box-shadow: inset 0 0 0 2px var(--line); position: absolute; }
.notice.l-hint.urgent { background: var(--peach-soft); box-shadow: inset 0 0 0 2px var(--coral); }
.notice.l-onboard { background: var(--paper); box-shadow: inset 0 0 0 2px var(--line-strong); }
.notice.l-result { background: var(--note-bg); color: var(--note-ink); }
.notice.l-result.k-warn { background: var(--warn); color: #fff; }
.notice.l-result.k-big { background: var(--btn); color: #fff; }
.notice.l-error { background: var(--error); color: #fff; }
.n-text { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.n-main { font-weight: 400; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: keep-all; }
.n-sub { font-size: 14px; line-height: 18px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l-result .n-text:has(.n-sub) .n-main { -webkit-line-clamp: 1; }
.n-btn {
  flex: none; height: 48px; min-width: 56px; padding: 0 12px; border-radius: 12px;
  border: 2px solid currentColor; background: transparent; font-size: 14px; font-weight: 700; position: relative; z-index: 2;
}
.n-btn.primary { background: var(--paper); color: var(--btn); border-color: var(--paper); }
.l-onboard .n-btn.ghost, .l-hint .n-btn { color: var(--ink-soft); border-color: var(--line-strong); }
.n-btn.close { min-width: 48px; padding: 0; font-size: 18px; }
.n-go { position: absolute; inset: 0; border: 0; background: transparent; z-index: 1; }
.n-arrow { flex: none; width: 24px; text-align: center; font-family: var(--font-pixel); font-size: 22px; color: var(--coral-ink); }

/* ------------------------------------------------------------ 탭별 도구 (480–612) */

#tools {
  position: absolute; left: 16px; top: 484px; width: 358px; height: 124px;
  display: flex; flex-direction: column; gap: 8px;
}
.tool-row { display: flex; gap: 8px; height: 56px; }
.tool {
  flex: 1 1 0; min-width: 0; height: 56px; border-radius: 14px;
  display: flex; align-items: center; gap: 8px; padding: 0 10px; text-align: left;
}
.tool.grow { flex: 3 1 0; }
.tool.tool-jar { flex: 0 0 120px; padding: 0 8px; gap: 6px; } /* 도토리 단지: 구슬 진행 옆 고정 폭 */
.tool-info { background: transparent; box-shadow: inset 0 0 0 2px var(--line); } /* 평면 정보: 그림자·꺾쇠 없음 */
.tool-btn {
  border: 2px solid var(--line-strong); background: var(--paper); box-shadow: 0 2px 0 var(--line);
}
.tool-btn:active { transform: translateY(2px); box-shadow: none; }
.tool-btn.primary { background: var(--btn); border-color: var(--btn); color: #fff; }
.tool-btn.primary .tool-s { color: #fff; }
.tool-btn[aria-pressed="true"] { background: var(--peach-soft); border-color: var(--coral); }
.tool-ic { flex: none; width: 28px; display: flex; align-items: center; justify-content: center; }
.tool-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.tool-t { font-family: var(--font-pixel); font-size: 15px; line-height: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-s { font-family: var(--font-body); font-size: 14px; line-height: 18px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool.locked .tool-ic { opacity: .45; filter: grayscale(.6); }
.tool .bar { height: 8px; margin: 3px 0 0; }
.tool-row[data-n="3"] .tool { padding: 0 8px; justify-content: center; text-align: center; }
.tool-row[data-n="3"] .tool-ic { display: none; } /* 세 칸 줄은 글자가 읽히도록 아이콘 없이 */
.tool-row[data-n="3"] .tool-tx { align-items: center; }

/* ------------------------------------------------------------ 행동 버튼 (y 620–692, 높이 72) */

#actions {
  position: absolute; left: 16px; top: 620px; width: 358px; height: 72px;
  display: flex; justify-content: center; gap: 6px;
}
.left-hand #actions { flex-direction: row-reverse; }
.act {
  flex: 0 0 66.8px; height: 72px; border-radius: 14px;
  border: 2px solid var(--line-strong); background: var(--paper); box-shadow: 0 3px 0 var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 14px; line-height: 18px; font-weight: 700; padding: 2px 0 4px; position: relative;
}
#actions[data-n="6"] .act { flex-basis: calc((358px - 30px) / 6); }
.act:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.act.na { background: var(--cream); box-shadow: none; border-style: dashed; color: var(--ink-soft); }
.act.na .act-icon > canvas { opacity: .4; filter: grayscale(.7); } /* 아이콘만 약하게, 라벨은 읽히게 */
.act.suggest { background: var(--peach-soft); }
.act .act-icon { height: 34px; display: flex; align-items: center; justify-content: center; position: relative; }
.act .act-lock { position: absolute; right: -10px; bottom: -2px; }
.act .act-label { white-space: nowrap; }

/* ------------------------------------------------------------ 하단 탭 (700–772, 4 × 97.5) */

#tabs {
  position: absolute; left: 0; top: 700px; width: 390px; height: 72px;
  display: flex; background: var(--paper); border-top: 2px solid var(--line); border-bottom: 2px solid var(--line);
}
.tab {
  flex: 1 1 0; height: 70px; border: 0; background: transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 15px; line-height: 18px; font-weight: 700; color: var(--ink-soft); position: relative;
}
.tab .tab-icon { height: 36px; display: flex; align-items: center; justify-content: center; }
.tab.on { color: var(--coral-ink); background: var(--peach-soft); }
.tab.on::after { content: ""; position: absolute; bottom: 0; left: 18px; right: 18px; height: 4px; border-radius: 4px 4px 0 0; background: var(--coral); }
.tab.open { color: var(--coral-ink); box-shadow: inset 0 0 0 2px var(--coral-ink); border-radius: 12px; }
.badge {
  position: absolute; top: 4px; right: 18px; min-width: 22px; height: 22px; border-radius: 11px;
  background: var(--btn); color: #fff; font-size: 13px; font-weight: 700; line-height: 22px; padding: 0 5px; text-align: center;
}
.badge[hidden] { display: none; }

/* ------------------------------------------------------------ 하단 작업 패널 (0,424,390,276) */

.panel {
  position: absolute; left: 0; top: 424px; width: 390px; height: 276px;
  background: var(--paper); color: var(--ink);
  border-radius: 18px 18px 0 0; border-top: 2px solid var(--line-strong);
  box-shadow: 0 -4px 14px var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  animation: panel-in .14s ease-out;
}
@keyframes panel-in { from { transform: translateY(12px); } to { transform: none; } }
/* 목록이 긴 화면: 상단 바 아래(72)부터 하단 탭 위(700)까지 */
.panel.panel-tall { top: 72px; height: 628px; }
.panel.panel-mid { top: 330px; height: 370px; }
/* 패널이 바꿔 끼운 자리(안내·도구·행동)는 숨겨 읽기·탭 순서에서도 빠지게 */
:root.panel-open #notice, :root.panel-open #tools, :root.panel-open #actions { visibility: hidden; }
.panel-head { flex: none; height: 48px; display: flex; align-items: center; gap: 4px; padding: 0 4px 0 12px; }
.panel-back {
  flex: none; height: 44px; min-width: 48px; padding: 0 10px 0 6px; border: 0; border-radius: 12px; background: var(--peach-soft);
  display: inline-flex; align-items: center; gap: 2px; font-size: 14px; font-weight: 700; color: var(--coral-ink);
}
.panel-back { font-size: 14px; }
.panel-title { flex: 1; min-width: 0; margin: 0; font-family: var(--font-pixel); font-size: 20px; line-height: 26px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline: none; }
.panel-close { flex: none; width: 48px; height: 48px; border: 0; border-radius: 12px; background: transparent; font-size: 20px; font-weight: 700; color: var(--ink-soft); }
.panel-close:active, .panel-back:active { background: var(--peach); }
.panel-cats { flex: none; height: 44px; padding: 0 16px; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; }
.panel-cats[hidden] { display: none; }
.panel-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 2px 16px 10px;
  touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  font-size: calc(16px * var(--panel-scale)); line-height: 22px;
}
.panel-body p { margin: 6px 0; }
.panel-note { flex: none; min-height: 40px; display: flex; align-items: center; gap: 8px; margin: 0 8px 4px; padding: 0 4px 0 12px; border-radius: 12px; font-size: 15px; line-height: 20px; }
.panel-note[hidden], .panel-note.empty { display: none; }
.panel-note.l-result { background: var(--note-bg); color: var(--note-ink); }
.panel-note.l-result.k-warn { background: var(--warn); color: #fff; }
.panel-note.l-result.k-big { background: var(--btn); color: #fff; }
.panel-note.l-error { background: var(--error); color: #fff; }
.panel-note .n-main { -webkit-line-clamp: 1; }
.panel-note .n-btn { height: 36px; }
.panel-foot { flex: none; min-height: 52px; padding: 0 16px 4px; display: flex; align-items: center; border-top: 2px solid var(--line); }
.panel-foot[hidden] { display: none; }
.foot-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.foot-row > .btn { flex: 1; min-height: 44px; }
.foot-info { margin-left: auto; font-family: var(--font-pixel); font-size: 14px; color: var(--ink-soft); white-space: nowrap; }
.big-text { --panel-scale: 1.12; }

/* 패널 안 공통 부품 */
.lead { font-family: var(--font-body); font-size: 17px; line-height: 22px; font-weight: 400; margin: 8px 0 4px; }
.sec { margin: 12px 0 4px; font-family: var(--font-pixel); font-size: 15px; line-height: 20px; font-weight: 700; color: var(--coral-ink); }
.note { font-size: 14px; line-height: 20px; color: var(--ink-soft); margin: 6px 0; }
.why-line { font-size: 15px; line-height: 20px; color: var(--warn); margin: 6px 0; }
:root[data-theme="night"] .why-line { color: var(--coral-ink); }
.empty { padding: 16px 0; text-align: center; color: var(--ink-soft); font-size: 15px; }
.in-label { display: block; font-family: var(--font-pixel); font-size: 14px; line-height: 20px; color: var(--ink-soft); margin: 8px 0 4px; }

.btn {
  min-height: var(--tap); min-width: 48px; border-radius: 12px; padding: 0 14px;
  border: 2px solid var(--line-strong); background: var(--paper); box-shadow: 0 2px 0 var(--line);
  font-size: 15px; line-height: 18px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn.primary { background: var(--btn); border-color: var(--btn); color: #fff; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.wide { width: 100%; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.btn:disabled { background: var(--cream); border-style: dashed; color: var(--ink-soft); box-shadow: none; }
.btn[aria-pressed="true"] { background: var(--peach-soft); border-color: var(--coral); color: var(--coral-ink); }
.btn.primary[aria-pressed="true"] { background: var(--btn); color: #fff; }

/* 64px 목록 줄(음식·상품): 아이콘 40, 이름 16, 효과·가격 14, 실행 버튼 48 */
.irow { min-height: 64px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 4px 0; }
.irow .ic { flex: none; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.irow.off .ic, .irow.locked .ic { opacity: .45; filter: grayscale(.6); }
.irow .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.irow .nm { font-size: 16px; line-height: 20px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.irow .nm .ct { font-family: var(--font-pixel); font-size: 14px; color: var(--ink-soft); }
.irow .nm .tag { font-family: var(--font-pixel); font-size: 12px; background: var(--mint); color: var(--ink); border-radius: 6px; padding: 0 5px; margin-left: 6px; vertical-align: 1px; }
.irow .sb { font-size: 14px; line-height: 18px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.irow .why { font-size: 14px; line-height: 18px; color: var(--warn); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root[data-theme="night"] .irow .why { color: var(--coral-ink); }
.irow .row-act { flex: none; min-width: 64px; min-height: 48px; padding: 0 12px; }

/* 접힌 묶음(지금 못 먹는 음식 n종) */
.fold {
  width: 100%; min-height: 48px; margin: 8px 0 2px; padding: 0 12px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--cream); display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 700; color: var(--ink);
}
.fold span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fold-ar { font-size: 18px; color: var(--coral-ink); }

/* 켬/끔 상자(연속 주기) */
.toggle { min-height: 44px; border: 0; background: transparent; display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; padding: 0 4px; }
.tg-box { width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--line-strong); background: var(--paper); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.toggle.on .tg-box { background: var(--btn); border-color: var(--btn); color: #fff; }

/* 분류 줄(44px): 선택 = 채움 + 밑줄 */
.tabs-mini { display: flex; gap: 6px; height: 44px; align-items: stretch; }
.tabs-mini .btn {
  flex: 1 0 auto; min-height: 40px; height: 40px; margin-top: 2px; padding: 0 12px; border-radius: 10px 10px 0 0; border-width: 0 0 3px 0;
  border-color: transparent; background: transparent; box-shadow: none; color: var(--ink-soft); font-size: 15px;
}
.tabs-mini .btn[aria-selected="true"] { background: var(--peach-soft); border-color: var(--coral); color: var(--coral-ink); }
.panel-body .tabs-mini { position: sticky; top: 0; z-index: 1; background: var(--paper); }

/* 물건 칸: 2열이면 64px 가로 칸, 3·4열이면 세로 칸 */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0; }
.icard {
  position: relative; min-height: 64px; border-radius: 12px; border: 2px solid var(--line); background: var(--cream);
  display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 8px; align-items: center; align-content: center;
  padding: 6px 8px; text-align: left; font-family: var(--font-body); font-size: 15px; line-height: 20px; min-width: 0;
}
button.icard { box-shadow: 0 2px 0 var(--line); border-color: var(--line-strong); }
button.icard:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.icard .ic { grid-row: 1 / span 2; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.icard .nm { font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.icard .ln { font-size: 14px; line-height: 18px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.icard .ct { position: absolute; top: 2px; right: 4px; font-family: var(--font-pixel); font-size: 12px; background: var(--peach); border-radius: 6px; padding: 0 4px; color: var(--ink); }
.icard .tag { position: absolute; top: 2px; left: 4px; font-family: var(--font-pixel); font-size: 11px; background: var(--mint); border-radius: 6px; padding: 0 4px; color: var(--ink); }
.icard.off .ic, .icard:disabled .ic { opacity: .45; filter: grayscale(.6); }
.icard:disabled { color: var(--ink-soft); border-style: dashed; box-shadow: none; }
.icard.sel { border-color: var(--coral); background: var(--peach-soft); box-shadow: inset 0 -3px 0 var(--coral); }
.grid4 .icard { grid-template-columns: 1fr; grid-template-rows: 40px auto auto; justify-items: center; text-align: center; padding: 6px 4px; min-height: 84px; }
.grid4 .icard .ic { grid-row: auto; }
.grid4 .icard .nm, .grid4 .icard .ln { font-size: 13px; line-height: 16px; max-width: 100%; }

/* 만남(가족 잇기 전) */
.meet-who { margin: 0 0 4px; font-size: 14px; color: var(--ink-soft); }
.meet-who b { font-family: var(--font-pixel); font-size: 17px; color: var(--ink); font-weight: 400; }
.meet-line { margin: 0; padding: 6px 10px; border-radius: 10px; background: var(--peach-soft); font-size: 14px; line-height: 20px; }
.meet-acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0 4px; }
.meet-acts .btn { min-height: 44px; padding: 0 6px; }

/* 유전자 카드: 유전자 한 줄 = 제목·드러난 값 + 대립유전자 두 칸 */
.grow-gene { padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
.grow-gene:last-child { border-bottom: 0; }
.ghead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.gname { font-family: var(--font-pixel); font-size: 15px; color: var(--coral-ink, var(--ink)); }
.gsub { font-size: 14px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gpair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gchip { position: relative; display: grid; grid-template-columns: 28px 1fr; align-items: center; column-gap: 8px; height: 48px;
  padding: 0 10px; border: 2px solid var(--line); border-radius: 12px; background: var(--cream); min-width: 0; }
.gchip.on { border-color: var(--coral); background: var(--peach-soft); }
.gic { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
.gsw { display: block; width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--line-strong); box-sizing: border-box; }
.gsw.round { border-radius: 50%; }
.gsw.blank { border-style: dashed; background: transparent; }
.gnm { font-size: 15px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gtag { position: absolute; top: -8px; right: 8px; font-family: var(--font-pixel); font-size: 11px; line-height: 15px; padding: 0 5px;
  border-radius: 6px; background: var(--coral); color: #fff; }

.row { min-height: 56px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 4px 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-size: 16px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 14px; line-height: 18px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .btn { flex: none; padding: 0 10px; }

.seg-wrap { margin: 8px 0; }
.seg-label { font-family: var(--font-pixel); font-size: 15px; line-height: 20px; margin-bottom: 4px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg .btn { flex: 1 0 auto; padding: 0 8px; min-width: 44px; }
.bar { height: 12px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 4px 0; }
.bar > i { display: block; height: 100%; background: var(--coral); border-radius: 6px; }
.lock { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-pixel); font-size: 15px; color: var(--ink); padding: 12px 0; }
.field-in {
  width: 100%; height: 48px; border-radius: 12px; border: 2px solid var(--line-strong); background: var(--cream); color: var(--ink);
  font-family: var(--font-body); font-size: max(17px, calc(16px / var(--s, 1))); padding: 0 12px;
  user-select: text; -webkit-user-select: text; touch-action: manipulation;
}
.field-in:focus { border-color: var(--coral); outline: none; }
textarea.field-in { height: 120px; padding: 8px 12px; font-size: 14px; font-family: ui-monospace, Consolas, monospace; }
.swatch { display: inline-block; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--ink-soft); vertical-align: middle; }
.swatch.expr { border-width: 4px; border-color: var(--coral); }
.choice { justify-content: flex-start; margin: 6px 0; min-height: 56px; text-align: left; }
.choice-t { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.choice-s { font-family: var(--font-body); font-size: 14px; font-weight: 400; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.primary .choice-s { color: #fff; }
.away-list { padding-left: 20px; margin: 4px 0; }
.away-list li { margin: 2px 0; }
.gauge { display: flex; align-items: center; gap: 10px; margin: 6px 0; }
.gauge-tx { flex: 1; }
.gauge-t { font-family: var(--font-pixel); font-size: 15px; font-weight: 700; }

/* 메뉴: 2열 48px 줄, 잠긴 항목도 읽히게(자물쇠 · 마을 LvN) */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.menu-item {
  min-height: 52px; border-radius: 12px; border: 2px solid var(--line-strong); background: var(--paper); box-shadow: 0 2px 0 var(--line);
  display: flex; align-items: center; gap: 8px; padding: 0 10px; text-align: left; min-width: 0;
}
.menu-item:active { transform: translateY(2px); box-shadow: none; }
.menu-item.locked { background: var(--cream); border-style: dashed; box-shadow: none; }
.menu-item.locked .mi-ic { opacity: .45; filter: grayscale(.6); }
.mi-ic { flex: none; width: 28px; display: flex; justify-content: center; }
.mi-tx { display: flex; flex-direction: column; min-width: 0; }
.mi-t { font-size: 16px; line-height: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mi-s { font-size: 14px; line-height: 18px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 첫 실행: 알 색 고르기(체크 + 테두리) */
.egg-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.egg-opt { min-height: 56px; border-radius: 12px; border: 2px solid var(--line); background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 14px; }
.egg-opt.on { border: 3px solid var(--coral-ink); background: var(--peach-soft); }
.egg-sw { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #4a3530; font-size: 14px; font-weight: 700; border: 2px solid rgba(74,53,48,.4); }

/* 다른 담당 시트(도감·가족·기록)가 쓰는 부품 */
.dex-cell { min-height: 84px; border-radius: 12px; border: 2px solid var(--line); background: var(--cream); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px; font-size: 14px; line-height: 16px; text-align: center; overflow: hidden; }
.dex-cell.unknown { color: var(--ink-soft); }
.dex-face { width: 40px; height: 40px; border-radius: 50%; position: relative; border: 3px solid; margin-bottom: 3px; }
.dex-face i { position: absolute; width: 7px; height: 7px; border-radius: 50%; top: 14px; }
.dex-face i:first-child { left: 8px; } .dex-face i:last-child { right: 8px; }
.dex-face b { position: absolute; width: 9px; height: 9px; top: -5px; border-radius: 3px; transform: rotate(45deg); }
.dex-face b:first-of-type { left: 3px; } .dex-face b:last-of-type { right: 3px; }
.sheet-sub { font-size: 14px; color: var(--ink-soft); }

/* ------------------------------------------------------------ 키보드 모드(이름 입력, visualViewport) */

:root.kb #topbar { top: var(--kb-y0, 0px); height: 24px; padding: 0 12px; border-bottom-width: 1px; }
:root.kb .tb-left { height: 24px; flex-direction: row; gap: 8px; align-items: center; }
:root.kb .tb-name { font-size: 14px; line-height: 18px; }
:root.kb .tb-sub { font-size: 12px; }
:root.kb .tb-right { transform: scale(.6); transform-origin: right center; }
:root.kb #screen-slot, :root.kb #status, :root.kb #notice, :root.kb #tools, :root.kb #actions, :root.kb #tabs { visibility: hidden; }
:root.kb #panel { top: calc(var(--kb-y1, 780px) - 128px); height: 128px; border-radius: 12px 12px 0 0; animation: none; }
:root.kb .panel-head, :root.kb .panel-cats, :root.kb .kb-hide, :root.kb .panel-note { display: none; }
:root.kb .panel-body { padding-top: 8px; }

/* ------------------------------------------------------------ 픽셀 아이콘 */

.px { image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.px.smooth { image-rendering: auto; }

/* ------------------------------------------------------------ 부팅·오류 패널(무대 밖, 배율 없음) */

.boot { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--letterbox); color: var(--ink); }
.boot[hidden] { display: none; }
.boot-title { font-family: var(--font-pixel); font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.boot-msg { font-size: 16px; color: var(--ink-soft); margin: 0; min-height: 22px; }
.boot-pet { width: 96px; height: 96px; image-rendering: pixelated; margin-bottom: 12px; animation: boot-bob 1.2s ease-in-out infinite; }
.boot-tip { margin: 18px 24px 0; padding: 8px 14px; border-radius: 12px; background: var(--paper); border: 2px solid var(--line);
  font-size: 14px; line-height: 20px; color: var(--ink-soft); text-align: center; max-width: 320px; }
.boot-tip:empty { display: none; }
@keyframes boot-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .boot-pet { animation: none; } }
.boot-error {
  position: fixed; z-index: 30; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 520px); max-height: 90vh; overflow: auto;
  background: var(--paper); color: var(--ink); border-radius: 16px; padding: 20px;
  box-shadow: 0 0 0 3px var(--coral) inset, 0 10px 40px var(--shadow);
  font-size: 16px; line-height: 1.45; touch-action: pan-y; user-select: text; -webkit-user-select: text;
}
.boot-error[hidden] { display: none; }
.boot-error h1 { font-size: 20px; margin: 0 0 8px; }
.boot-error pre { white-space: pre-wrap; word-break: break-all; background: var(--cream); border-radius: 12px; padding: 10px; font-size: 14px; max-height: 40vh; overflow: auto; }
.boot-error ul { padding-left: 20px; margin: 6px 0; }
.boot-error button { min-height: 48px; min-width: 120px; border-radius: 12px; border: 0; background: var(--btn); color: #fff; font-weight: 700; font-size: 16px; margin: 6px 6px 0 0; padding: 0 16px; }
.boot-error button.ghost { background: var(--peach-soft); color: var(--ink); }

/* ------------------------------------------------------------ 움직임 줄이기 */

@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-on) *, :root:not(.motion-on) *::before, :root:not(.motion-on) *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }


/* ------------------------------------------------------------ 로그인·가입(2026-10-21, 꾸밈 그림 PixelLab assets/ui/login_*) */
.auth {
  position: fixed; inset: 0; z-index: 1000; overflow: auto;
  display: flex; /* 가운데 정렬은 .auth-stack의 margin: auto — 화면보다 길어도 위가 잘리지 않고 스크롤된다 */
  background: #f6d9cf url('../assets/ui/login_bg.png') center / cover no-repeat;
  image-rendering: pixelated; font-family: var(--font-body); color-scheme: light;
}
.auth-art img { position: fixed; image-rendering: pixelated; pointer-events: none; }
.auth-lantern { bottom: 9%; width: 62px; }
.auth-lantern.l { left: 3%; transform: scaleX(-1); }
.auth-lantern.r { right: 3%; }
.auth-flowers { bottom: 2%; width: 96px; }
.auth-flowers.l { left: -2%; }
.auth-flowers.r { right: -2%; transform: scaleX(-1); }
.auth-acorns { bottom: 3%; left: 50%; width: 60px; margin-left: -30px; }
/* 로그인·가입 카드 바로 아래 저작권 줄(2026-10-21) */
.auth-copy {
  margin: 2px 0 0; padding: 3px 10px; border-radius: 8px; background: rgba(255, 250, 244, 0.8);
  text-align: center; font-size: 12px; line-height: 16px; color: #6b3b2a; letter-spacing: 0.02em;
}
.auth-stack { position: relative; margin: auto; width: min(340px, calc(100vw - 32px)); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 0; }
.auth-sign { position: relative; width: 240px; display: flex; justify-content: center; }
.auth-sign-img { width: 240px; image-rendering: pixelated; }
.auth-title {
  position: absolute; top: 30%; left: 8%; right: 8%; margin: 0; text-align: center;
  font-family: var(--font-pixel); font-size: 22px; line-height: 26px; color: #6b3b2a;
  display: flex; flex-direction: column; align-items: center;
}
.auth-card {
  width: 100%; box-sizing: border-box; padding: 16px; border-radius: 16px;
  background: rgba(255, 250, 244, 0.94); border: 3px solid #d9a58e;
  box-shadow: 0 4px 0 rgba(160, 90, 60, 0.25); display: flex; flex-direction: column; gap: 10px;
}
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.auth-tab {
  height: 40px; border-radius: 10px; border: 2px solid #f0d6c8; background: #fff;
  font-family: var(--font-pixel); font-size: 15px; color: #8a6a60;
}
.auth-tab.on { border-color: #e87c5c; background: #fde3d6; color: #4a3530; }
.auth-in {
  height: 48px; padding: 0 14px; border-radius: 12px; border: 2px solid #f0d6c8;
  font-size: 16px; font-family: var(--font-body); background: #fff; color: #4a3530;
}
.auth-in:focus { outline: 3px solid #e87c5c; outline-offset: 0; }
.auth-warn { margin: 0; padding: 8px 10px; border-radius: 10px; background: #fff1e6; color: #b4552f; font-size: 14px; line-height: 20px; font-weight: 600; }
.auth-msg { margin: 0; min-height: 20px; font-size: 14px; line-height: 20px; color: #b4552f; }
.auth-go {
  height: 52px; border: 0; border-radius: 14px; background: #e87c5c; color: #fff;
  font-family: var(--font-pixel); font-size: 18px; box-shadow: 0 3px 0 #c45e40;
}
.auth-go:disabled { opacity: 0.6; }
.auth-go:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
@media (max-height: 640px) { .auth-sign, .auth-sign-img { width: 180px; } .auth-title { font-size: 17px; line-height: 20px; } }
