/* SunnySideWorld — DESIGN.md 토큰 기반 스타일 */
/* 에셋 폰트: DNF BitBit v2 (한글 픽셀 폰트) — 타이틀·HUD·모달 제목·Day 라벨에 사용 */
@font-face {
  font-family: "DNFBitBit";
  src: url("../assets/fonts/DNFBitBitv2.otf") format("opentype");
  font-display: swap;
}

:root {
  --accent: #e8842c;
  --accent-text: #3b2a1a;
  --gold: #f2c14e;
  --danger: #c03a32;
  --success: #4e9c3f;
  --focus: #2e7fd0;
  --surface: #f6ebce;
  --surface-dark: #3b2a1a;
  --outline: #5c4632;
  --on-surface: #3b2a1a;
  --hud-scale: 1;
  --ui-bright: 1;
  --text-scale: 1;
  --auto-scale: 1;   /* 해상도 자동 스케일 — main.js resize()가 뷰포트 기준으로 산출 (0.75~1.6) */
  --font-px: "DNFBitBit", "Malgun Gothic", "Segoe UI", sans-serif;
  --font-base: "Malgun Gothic", "Segoe UI", "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: #1c2b16;
  font-family: var(--font-base);
  color: var(--on-surface);
  overflow: hidden;
  user-select: none;
}
img { image-rendering: pixelated; }
.px { font-family: var(--font-px); letter-spacing: .5px; }
.dim { color: #8a7a62; font-weight: 400; }
.gold { color: #b57e14; font-weight: 700; }
.poor { color: var(--danger); font-weight: 700; }   /* 골드 부족 — 모든 구매 가격 공통 */
.hidden { display: none !important; }

/* 아이콘 규칙: 이모지 금지 — 에셋 스프라이트만 사용 (사용자 지시 2026-07-13) */
.ic16 { width: 18px; height: 18px; object-fit: contain; vertical-align: -3px; image-rendering: pixelated; }
.ic24 { width: 26px; height: 26px; object-fit: contain; image-rendering: pixelated; }
.elabel { font-size: 12px; font-weight: 700; letter-spacing: .06em; color: #d8c9a8; }

button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ===== 화면/캔버스 ===== */
.screen { position: fixed; inset: 0; }
#lobby-canvas, #world-canvas {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  background: #6cbb48;
}
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(30, 18, 8, .30) 100%);
}

/* ===== 공용 패널 룩 (9-slice 근사) ===== */
.panel {
  background: var(--surface); color: var(--on-surface);
  border: 3px solid var(--outline); border-radius: 6px;
  box-shadow: inset 0 -5px 0 rgba(92, 70, 50, .18), 0 5px 0 rgba(30, 18, 8, .35);
}
.pad-dark {
  background: rgba(59, 42, 26, .88); color: #f6ebce;
  border: 3px solid rgba(30, 18, 8, .9); border-radius: 6px;
  box-shadow: 0 4px 0 rgba(30, 18, 8, .35);
}
.wood {
  background: linear-gradient(#b97f47, #a9713f 65%, #966033); color: #f6ebce;
  border: 3px solid var(--outline); border-radius: 6px;
  box-shadow: inset 0 -6px 0 rgba(59, 42, 26, .35), 0 6px 0 rgba(30, 18, 8, .4);
}

.btn {
  padding: 10px 18px; font-size: 16px; font-weight: 700;
  background: var(--surface); color: var(--on-surface);
  border: 3px solid var(--outline); border-radius: 6px;
  box-shadow: 0 4px 0 rgba(30, 18, 8, .35);
  transition: transform .1s, filter .1s;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); transform: scale(1.03); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { filter: saturate(.4) brightness(.92); color: #8a7a62; cursor: default; }
.btn.primary { background: var(--accent); border-color: #9c5518; color: var(--accent-text); }
.btn.danger { background: var(--danger); border-color: #7e241e; color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; box-shadow: 0 3px 0 rgba(30, 18, 8, .3); }
.btn.small img { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }

/* ===== 로비 ===== */
.logo-board {
  position: absolute; top: 6vh; left: 50%; transform: translateX(-50%);
  padding: 18px 44px 22px; text-align: center; z-index: 2;
  zoom: var(--auto-scale);
}
.logo-board .t { font-size: 52px; font-weight: 800; line-height: 1.1; text-shadow: 0 3px 0 rgba(30, 18, 8, .45); }
.logo-board .s { font-size: 17px; color: var(--gold); margin-top: 4px; }

#lobby-menu {
  position: absolute; left: max(4vw, 24px); top: 30vh;
  display: flex; flex-direction: column; gap: 14px; z-index: 2;
  zoom: var(--auto-scale);
}
.mbtn {
  width: 320px; height: 62px;
  font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s, filter .1s;
}
.mbtn:hover:not(:disabled) { filter: brightness(1.05); transform: scale(1.04); }
.mbtn:active:not(:disabled) { transform: translateY(1px); }

.continue-card {
  width: 400px; min-height: 100px;
  display: flex; gap: 14px; align-items: center;
  padding: 10px 16px; text-align: left;
  transition: transform .1s, filter .1s;
}
.continue-card:hover:not(:disabled) { filter: brightness(1.04); transform: scale(1.02); }
.continue-card.disabled { filter: saturate(.45) brightness(.94); }
.continue-card .name { font-size: 21px; font-weight: 800; line-height: 1.25; }
.continue-card .meta { font-size: 13px; color: #6b5741; font-variant-numeric: tabular-nums; margin-top: 2px; }
.continue-card .cta { margin-left: auto; color: var(--accent); font-size: 26px; }
#continue-thumb {
  width: 88px; height: 51px; flex: none;
  border: 3px solid var(--outline); border-radius: 4px;
  image-rendering: pixelated; background: #6cbb48;
}

.hints {
  position: fixed; left: 24px; bottom: 24px; z-index: 2;
  font-size: 15px; color: #fff7e6; text-shadow: 0 2px 0 rgba(30, 18, 8, .6);
}
.hints kbd {
  background: rgba(59, 42, 26, .85); border: 2px solid rgba(30, 18, 8, .9);
  border-radius: 4px; padding: 1px 8px; font-family: inherit;
}
.version {
  position: fixed; right: 24px; bottom: 24px; z-index: 2;
  font-size: 13px; color: #fff3d9; text-shadow: 0 2px 0 rgba(30, 18, 8, .6);
}

/* ===== HUD ===== */
#hud {
  position: fixed; inset: 0; pointer-events: none; z-index: 10;
  filter: brightness(var(--ui-bright));
  zoom: calc(var(--hud-scale) * var(--auto-scale));
}
#hud > * { pointer-events: auto; }

.hud-time { position: absolute; left: 12px; top: 12px; padding: 7px 12px; min-width: 175px; }
.hud-time .d { font-size: 20px; font-weight: 800; }
.hud-time .t { font-size: 15px; color: #6b5741; font-variant-numeric: tabular-nums; margin: 2px 0 0; }

#map-tools {
  position: absolute; left: 12px; top: 114px; width: 182px; padding: 6px;
  background: rgba(255, 248, 224, .94);
}
.map-title {
  margin: 0 0 4px 2px; color: #6b5741; font-size: 11px; letter-spacing: 1px;
}
#minimap {
  display: block; width: 168px; height: 112px;
  border: 3px solid var(--outline); border-radius: 4px;
  background: #283b2b; cursor: crosshair; image-rendering: pixelated;
}
.zoom-controls { display: grid; grid-template-columns: 32px 1fr 32px; gap: 4px; margin-top: 5px; }
.zoom-controls button {
  height: 26px; padding: 0; border: 2px solid var(--outline); border-radius: 5px;
  background: #fffaf0; color: var(--on-surface); font-family: var(--font-px); font-weight: 800;
}
.zoom-controls button:hover:not(:disabled) { background: #fff0d3; transform: translateY(-1px); }
.zoom-controls button:disabled { opacity: .38; cursor: default; }
.zoom-reset { font-size: 12px; font-variant-numeric: tabular-nums; }
.zoom-btn { font-size: 20px; line-height: 1; }

.hud-cur { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.cur-strip { display: flex; gap: 16px; padding: 9px 16px; font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; }
.cur-strip .g { color: var(--gold); }
.cur-strip .d { color: #cfe6ff; }
.sysbtns { display: flex; gap: 6px; }
.sysbtn { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; font-size: 17px; padding: 0; transition: transform .1s, filter .1s; }
.sysbtn:hover { filter: brightness(1.06); transform: scale(1.05); }

/* 가방 — 우측 중앙 단독 배치 */
#btn-inv { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; }
#btn-inv:hover { transform: translateY(-50%) scale(1.05); }

/* 일꾼 도크 — 좌하단. 일꾼이 없으면 아이콘만, 있으면 얼굴 + 지금 하는 일 이모지 배지 */
#worker-dock {
  position: absolute; left: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  font-family: inherit; cursor: pointer; transition: filter .1s;
}
#worker-dock:hover { filter: brightness(1.12); }
#worker-dock .wd-cell {
  position: relative; width: 42px; height: 46px; padding: 0;
  background: none; border: none; cursor: pointer; transition: transform .1s;
}
#worker-dock .wd-cell:hover { transform: scale(1.12); }
#worker-dock .wd-cell canvas { width: 42px; height: 46px; image-rendering: pixelated; display: block; }
#worker-dock .wd-job {
  position: absolute; right: -7px; bottom: -4px; width: 20px; height: 20px;
  padding: 2px; background: rgba(43, 29, 16, .92); border: 1px solid var(--outline); border-radius: 50%;
  image-rendering: pixelated; pointer-events: none;
}
#worker-dock .wd-more { color: #d8c9a8; font-size: 16px; font-weight: 700; }

#hotbar {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  display: flex; gap: 5px; padding: 6px;
  background: rgba(59, 42, 26, .55); border: 2px solid rgba(30, 18, 8, .55); border-radius: 8px;
}
.slot {
  width: 46px; height: 46px; border-radius: 8px; position: relative;
  background: var(--surface); border: 3px solid var(--outline);
  display: flex; align-items: center; justify-content: center; padding: 0;
  transition: transform .1s;
}
.slot:hover { transform: scale(1.05); }
.slot .icon { width: 32px; height: 32px; object-fit: contain; }
.slot .k { position: absolute; left: 4px; top: 1px; font-size: 11px; color: #8a7a62; font-weight: 700; }
.slot .cnt {
  position: absolute; right: 2px; bottom: 0; font-size: 12px; font-weight: 800;
  color: #f6ebce; background: rgba(59, 42, 26, .9); border-radius: 4px; padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
.slot.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.slot.empty-seed { opacity: .4; filter: grayscale(.75); }
.slot.sel.empty-seed { opacity: 1; filter: none; }   /* 선택된 슬롯은 보유 0이어도 흐림 해제 */
.slot.empty { background: rgba(0, 0, 0, .12); border-style: dashed; }   /* 보유하지 않은 도구 — 빈 칸으로 표시 */
.slot.dragging { opacity: .35; }
.slot.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.slot .brk {
  position: absolute; inset: -8px; display: none; pointer-events: none;
  background-image: url("../assets/ui/selectbox_tl.png"), url("../assets/ui/selectbox_tr.png"),
    url("../assets/ui/selectbox_bl.png"), url("../assets/ui/selectbox_br.png");
  background-position: top left, top right, bottom left, bottom right;
  background-repeat: no-repeat; background-size: 21px;
  image-rendering: pixelated;
}
.slot.sel .brk { display: block; }

#slot-label {
  position: absolute; left: 50%; bottom: 137px; transform: translateX(-50%);
  padding: 4px 14px; font-size: 15px; opacity: 0; transition: opacity .25s;
  pointer-events: none;   /* 순수 정보 표시 — 아래 타일 클릭을 항상 가로채지 않도록 */
}
#slot-label.show { opacity: 1; }

/* 하단바 — 에너지 게이지 + 하루 마침 버튼, 핫바 바로 위 중앙 정렬 */
#bottom-bar {
  position: absolute; left: 50%; bottom: 82px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
}

#energy-wrap {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 15px;
}
#hud-energy-img { height: 20px; image-rendering: pixelated; }
#hud-energy-num { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; }
#energy-wrap.low #hud-energy-num { color: #ff9d94; }
#energy-wrap.low { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { box-shadow: 0 4px 0 rgba(30, 18, 8, .35), 0 0 0 3px var(--danger); } }

/* 하루 목표 — 우하단. 클릭하면 아침 팝업을 다시 펼친다 */
#daily-goals {
  position: absolute; right: 12px; bottom: 12px; cursor: pointer;
  min-width: 190px; max-width: 260px; padding: 7px 11px; text-align: left;
  animation: dgIn .3s ease both;
}
#daily-goals:hover { box-shadow: 0 4px 0 rgba(30, 18, 8, .35), 0 0 0 2px var(--accent); }
#daily-goals.hidden { display: none; }
.dg-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: #d8c9a8; letter-spacing: 1px; margin-bottom: 4px;
}
#dg-list { list-style: none; margin: 0; padding: 0; }
#dg-list li {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 14px; line-height: 1.5; font-weight: 700;
}
#dg-list li .dg-mark { color: var(--accent); font-weight: 800; }
#dg-list li .dg-n { color: #d8c9a8; font-size: 12px; font-variant-numeric: tabular-nums; margin-left: auto; }
#dg-list li.done { color: #a9c98d; }
#dg-list li.done .dg-mark { color: #a9c98d; }
#dg-list li.done .dg-t { text-decoration: line-through; opacity: .75; }
@keyframes dgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* 아침 하루 목표 팝업 — 새 날이 밝을 때 화면 중앙. 모달이 아니라(시간 정지 없음) 클릭하면 닫히는 안내 카드 */
#daily-popup {
  position: fixed; inset: 0; z-index: 115; zoom: var(--auto-scale);
  display: flex; align-items: center; justify-content: center;
  background: rgba(12, 8, 4, .45);
}
#daily-popup.hidden { display: none; }
.dp-card {
  width: min(440px, 86vw); padding: 20px 24px 18px; text-align: center;
  animation: dpIn .32s cubic-bezier(.2, 1.4, .5, 1) both;
}
.rm .dp-card { animation: none; }
@keyframes dpIn { from { opacity: 0; transform: scale(.88) translateY(10px); } to { opacity: 1; transform: none; } }
.dp-day { font-family: var(--font-px); font-size: 13px; letter-spacing: 2px; color: #b09a78; }
.dp-h { margin: 2px 0 14px; font-family: var(--font-px); font-size: 22px; color: var(--accent); }
#dp-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
#dp-list li {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 9px 12px; font-size: 16px; font-weight: 700;
  background: #fff3de; border: 2px solid var(--outline); border-radius: 8px;
}
#dp-list li .dg-mark { color: var(--accent); font-weight: 800; }
#dp-list li .dg-n { margin-left: auto; color: #9c5518; font-size: 14px; font-variant-numeric: tabular-nums; }
.dp-bonus { font-size: 14px; color: #6b5741; margin-bottom: 14px; }
#dp-ok { min-width: 130px; }

/* ===== 튜토리얼: 스포트라이트 · 캐릭터 다이얼로그 · 글로우 ===== */
/* 스포트라이트 — 화면 전체 어둠에 다중 구멍(도구 슬롯/버튼 + 월드 오브젝트)을 뚫는 SVG 마스크 (zoom 미적용: 뷰포트 px 직접 사용) */
#tut-spot {
  position: fixed; inset: 0; width: 100vw; height: 100vh;
  z-index: 46; pointer-events: none;
}
#tut-spot.hidden { display: none; }

/* 캐릭터 다이얼로그 — 하단(에너지/하루마침 바 위) 중앙. 초상화 + 말풍선 */
/* #hint-banner(튜토리얼 이후 골드 기준 안내)도 같은 모양을 쓴다 — 둘은 서로 배타적이라 겹치지 않는다 */
#tut-dialog, #hint-banner {
  position: fixed; left: 50%; bottom: 152px; transform: translateX(-50%);
  z-index: 48; zoom: var(--auto-scale);
  display: flex; align-items: flex-end; gap: 6px;
  width: min(660px, 92vw); pointer-events: none;
  animation: tutDlgIn .3s ease both;
}
#tut-dialog.hidden, #hint-banner.hidden { display: none; }
@keyframes tutDlgIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
/* 패널(목장 등)이 열렸을 때 — 모달(z100) 위로 올라오고 하단으로 이동해 목록을 덜 가림 */
#tut-dialog.tut-onpanel { z-index: 120; bottom: 14px; }

.tut-portrait {
  flex: none; width: 118px; height: 118px; position: relative; overflow: hidden;
  border-radius: 14px; border: 3px solid var(--outline);
  background: linear-gradient(180deg, #bfe0ff 0%, #d9f0e0 62%, #a9d68a 100%);
  box-shadow: 0 4px 0 rgba(30, 18, 8, .35);
  animation: tutBob 2.4s ease-in-out infinite;
}
@keyframes tutBob { 50% { transform: translateY(-4px); } }
.tut-char {
  position: absolute; left: 50%; bottom: -6px; width: 174px; height: 116px;
  transform: translateX(-50%);
  background-repeat: no-repeat; background-size: 900% 100%; background-position: 0 0;
  image-rendering: pixelated;
}
.tut-char.base { background-image: url("../assets/characters/IDLE/base_idle_strip9.png"); }
.tut-char.hair { background-image: url("../assets/characters/IDLE/shorthair_idle_strip9.png"); }

.tut-bubble {
  flex: 1; position: relative; margin-bottom: 10px;
  background: var(--surface); border: 3px solid var(--outline); border-radius: 12px;
  padding: 12px 16px; text-align: left;
  box-shadow: 0 4px 0 rgba(30, 18, 8, .35), 0 0 0 3px var(--accent);
}
/* 골드 기준 안내 배너 닫기 — 사방 확장까지 돈을 모으는 동안 치워둘 수 있게 */
#hint-close {
  position: absolute; right: 6px; top: 6px; width: 26px; height: 26px;
  background: none; border: none; color: #8a7a62; font-size: 15px; font-weight: 800;
  cursor: pointer; line-height: 1;
}
#hint-close:hover { color: var(--danger); }
.tut-bubble::after {   /* 초상화를 향하는 말풍선 꼬리 */
  content: ""; position: absolute; left: -12px; bottom: 20px;
  border: 7px solid transparent; border-right-color: var(--outline);
}
.tut-name {
  display: flex; align-items: center; gap: 6px;
  font-weight: 800; font-size: 14px; color: var(--accent); margin-bottom: 4px;
}
.tut-say { font-weight: 700; font-size: 16px; line-height: 1.45; color: var(--on-surface); }
.tut-caret { color: var(--accent); font-weight: 800; animation: tutCaret 1s steps(2) infinite; }
.tut-caret.done { display: none; }
@keyframes tutCaret { 50% { opacity: 0; } }
.tut-meta { margin-top: 6px; display: flex; align-items: center; gap: 10px; }
.tut-meta .p { color: #b09a78; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
#tut-next { margin-left: auto; pointer-events: auto; }
#tut-next.hidden { display: none; }

/* 대상은 스포트라이트 구멍(투명)으로 그대로 비쳐 밝게 보인다 — 별도 z-index 승격 불필요 */
.tut-glow { animation: tutGlow 1s steps(2) infinite; }
@keyframes tutGlow { 50% { box-shadow: 0 0 0 4px var(--accent), 0 0 14px 4px rgba(232, 132, 44, .75); } }
.rm .tut-glow { animation: none; box-shadow: 0 0 0 4px var(--accent); }

/* ===== 프롬프트/토스트/FX (줌 미적용 레이어 — 페이지 좌표 기반) ===== */
#prompt {
  position: fixed; z-index: 40; pointer-events: none;
  zoom: var(--auto-scale);
  padding: 6px 14px; font-size: 16px; opacity: 0; transition: opacity .12s;
}
#prompt.show { opacity: 1; }
#prompt.blocked { color: #ff9d94; }

/* 상세 스텟 툴팁 (아이템/일꾼 호버 — 페이지 좌표, 줌 미적용) — 모달(z:100) 위에 표시 */
#tooltip {
  position: fixed; z-index: 200; pointer-events: none;
  zoom: var(--auto-scale);
  min-width: 176px; max-width: 264px; padding: 10px 12px;
  font-size: 13px; line-height: 1.55; text-align: left;
  opacity: 0; transition: opacity .1s;
}
#tooltip.show { opacity: 1; }
#tooltip .tt-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
#tooltip .tt-head img { width: 26px; height: 26px; object-fit: contain; image-rendering: pixelated; flex: none; }
#tooltip .tt-name { font-family: var(--font-px); font-size: 15px; font-weight: 800; line-height: 1.15; }
#tooltip .tt-tag { display: inline-block; margin-top: 2px; font-size: 10px; font-weight: 800; letter-spacing: .04em;
  padding: 1px 7px; border-radius: 4px; background: var(--outline); color: #f6ebce; }
#tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; }
#tooltip .tt-row .k { color: #6b5741; white-space: nowrap; }   /* 값이 아이콘 게이지라 폭이 줄어도 라벨은 안 쪼개지게 */
#tooltip .tt-row .v { font-weight: 700; font-variant-numeric: tabular-nums; }
#tooltip .tt-row .v.gold { color: #b57e14; }
#tooltip .tt-desc { color: #6b5741; margin-top: 6px; font-size: 12px; line-height: 1.5; }
/* 아이콘 수량 표기 (툴팁·패널 공용) — 최대치만큼 깔고 채워진 것만 밝게, 많으면 아이콘 ×N */
.tt-pips { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; }
.tt-pips .pip { width: 15px; height: 15px; object-fit: contain; image-rendering: pixelated; }
.tt-pips .pip.off { opacity: .3; filter: grayscale(.9) brightness(.75); }
.tt-pips .pip-x { margin-left: 1px; font-weight: 700; font-variant-numeric: tabular-nums; }
#tooltip .tt-sub { margin-left: 8px; color: #6b5741; font-weight: 400; }
#tooltip .tt-row .v { display: inline-flex; align-items: center; gap: 4px; }
#tooltip hr { border: none; border-top: 1px dashed rgba(92, 70, 50, .35); margin: 6px 0; }

#toast-root { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 60; zoom: var(--auto-scale); }
.toast {
  padding: 9px 20px; font-size: 15px; white-space: nowrap;
  opacity: 0; transform: translateY(-14px); transition: opacity .26s, transform .26s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===== 달성 팝업 (도감 등록·업적 달성 — 상단 중앙, 토스트 아래 줄) ===== */
#unlock-root { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 60; zoom: var(--auto-scale); pointer-events: none; }
.unlock-pop {
  display: flex; align-items: center; gap: 10px; padding: 9px 18px;
  background: rgba(45, 30, 16, .94); border: 3px solid var(--outline); border-radius: 10px;
  color: #f6ebce; white-space: nowrap;
  opacity: 0; transform: translateY(-16px); transition: opacity .25s, transform .25s;
}
.unlock-pop.show { opacity: 1; transform: translateY(0); }
.unlock-pop img { width: 28px; height: 28px; object-fit: contain; image-rendering: pixelated; flex: none; }
.unlock-pop .u-star { font-size: 22px; color: #f2c14e; flex: none; }
.unlock-pop .u-title { font-family: var(--font-px); font-size: 15px; letter-spacing: .5px; }
.unlock-pop .u-sub { font-size: 12px; color: #cdb48c; }

#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; zoom: var(--auto-scale); }
.float-text {
  position: fixed; font-size: 19px; font-weight: 800; color: #fff;
  text-shadow: 0 2px 0 rgba(30, 18, 8, .7), 0 0 6px rgba(30, 18, 8, .4);
  animation: floatUp 1.25s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(6px) scale(.8); }
  15% { opacity: 1; transform: translateY(0) scale(1.1); }
  100% { opacity: 0; transform: translateY(-64px) scale(1); }
}

.punch { animation: punchAnim .3s ease-out; }
@keyframes punchAnim { 30% { transform: scale(1.12); } }

/* ===== 하루 마침 페이드 (수면 전환) ===== */
#day-fade {
  position: fixed; inset: 0; z-index: 90;
  background: #140d06; opacity: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .55s ease;
}
#day-fade.show { opacity: 1; pointer-events: auto; }
#day-fade .df-inner {
  text-align: center; color: #f3e6c8;
  zoom: var(--auto-scale);
  opacity: 0; transform: translateY(8px);
  transition: opacity .4s ease .2s, transform .4s ease .2s;
}
#day-fade.show .df-inner { opacity: 1; transform: none; }
.df-day { font-size: 40px; letter-spacing: 2px; }
.df-sub { margin-top: 12px; font-size: 16px; color: #cdb48c; font-family: var(--font-px); letter-spacing: 1px; }

/* ===== 첫 입장 인트로 ===== */
#intro-body { display: flex; align-items: flex-start; gap: 14px; margin: 10px 0 4px; }
#intro-body img { width: 42px; height: 42px; object-fit: contain; image-rendering: pixelated; flex: none; margin-top: 2px; }
#intro-body p { margin: 0; line-height: 1.75; }
#intro-dots { display: flex; gap: 7px; justify-content: center; margin: 14px 0 12px; }
#intro-dots .dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(92, 70, 50, .25); }
#intro-dots .dot.on { background: var(--accent); }

/* 도감 */
.rec-row { cursor: default; }
.rec-big {
  display: inline-block; padding: 1px 7px; margin-left: 4px;
  font-size: 11px; font-weight: 800; border-radius: 8px;
  background: var(--gold); color: var(--accent-text);
}
.ach-mark { width: 22px; text-align: center; font-size: 17px; color: var(--gold); flex: none; }
.ach-locked { opacity: .5; }
.ach-locked .ach-mark { color: #b09a78; }

#sign-layer button {
  position: fixed; z-index: 12; background: transparent; border: none;
  cursor: pointer; border-radius: 6px;
}
#sign-layer button:hover { box-shadow: 0 0 0 3px var(--accent); }

/* ===== 모달 ===== */
#modal-root { position: fixed; inset: 0; z-index: 100; filter: brightness(var(--ui-bright)); zoom: calc(var(--text-scale) * var(--auto-scale)); }
#dim { position: absolute; inset: 0; background: rgba(20, 12, 6, .6); }
.modal {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 22px 26px; min-width: 380px; max-width: min(860px, 92vw);
  max-height: 86vh; overflow: auto;
}
.modal h2 { font-family: var(--font-px); font-size: 24px; margin: 0 0 14px; padding-right: 40px; }
.m-close {
  position: absolute; right: 12px; top: 12px;
  width: 36px; height: 36px; padding: 4px;
  background: transparent; border: none;
}
.m-close img { width: 100%; height: 100%; }
.m-close:hover { transform: scale(1.1); }
.modal .row { display: flex; gap: 10px; margin-top: 14px; }
.modal label { display: block; font-size: 14px; font-weight: 700; margin: 12px 0 4px; }
.modal input[type="text"] {
  width: 100%; padding: 10px 12px; font-size: 17px; font-family: var(--font-px); letter-spacing: .5px;
  background: #fffaf0; border: 3px solid var(--outline); border-radius: 6px;
}
.modal input[type="range"] { width: 220px; accent-color: var(--accent); vertical-align: middle; }
.modal input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); vertical-align: -4px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px dashed rgba(92, 70, 50, .35); }
.set-row .v { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

#nf-slots { display: flex; gap: 8px; }
#nf-slots button { flex: 1; padding: 10px 6px; font-size: 14px; background: #fffaf0; border: 3px solid var(--outline); border-radius: 6px; }
#nf-slots button.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); background: #fff3dd; }

.slot-card { padding: 14px 16px; margin-bottom: 12px; }
.slot-card .nm { font-size: 19px; font-weight: 800; }
.slot-card .meta { font-size: 13px; color: #6b5741; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }

/* 인벤토리 */
#inv-wrap { display: flex; gap: 18px; }
#inv-grid { display: grid; grid-template-columns: repeat(8, 56px); gap: 8px; }
.inv-cell {
  width: 56px; height: 56px; position: relative; border-radius: 8px;
  background: #fffaf0; border: 3px solid var(--outline);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.inv-cell img { width: 38px; height: 38px; object-fit: contain; }
.inv-cell .cnt {
  position: absolute; right: 2px; bottom: 0; font-size: 12px; font-weight: 800;
  color: #f6ebce; background: rgba(59, 42, 26, .9); border-radius: 4px; padding: 0 4px;
}
.inv-cell.empty { background: #efe3c2; border-color: #c9b48d; }
.inv-cell.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
#inv-detail { width: 220px; font-size: 15px; line-height: 1.7; }

/* 상점 */
.shop-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: -4px 0 14px; font-size: 13px;
}
.shop-head .cur-strip { padding: 7px 14px; font-size: 15px; }
#shop-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; min-width: 640px; }
#shop-cols h3 { font-size: 15px; margin: 0 0 8px; color: #6b5741; }
.shop-row {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; margin-bottom: 6px; font-size: 15px; text-align: left;
  background: #fffaf0; border: 3px solid var(--outline); border-radius: 6px;
  transition: transform .1s, filter .1s;
}
.shop-row:hover:not(:disabled) { filter: brightness(1.04); transform: scale(1.015); }
.shop-row:disabled { filter: saturate(.4) brightness(.95); color: #8a7a62; cursor: default; }
.shop-row img { width: 30px; height: 30px; object-fit: contain; }
.item-sprite {
  display: inline-block;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  background-repeat: no-repeat;
  background-size: 1024px 1024px;
  image-rendering: pixelated;
}
.shop-row .item-sprite { transform: scale(.9375); }
.inv-cell .item-sprite { transform: scale(1.1875); }
.shop-row .pr { font-weight: 800; font-variant-numeric: tabular-nums; }
/* 아직 해금 안 된 건물 — 가격 자리에 조건을 보여준다 (자물쇠 톤) */
.shop-row .pr.lock { color: #8b7a63; font-weight: 700; font-size: 13px; }
/* 골드가 모자라 못 사는 항목 — 가격을 빨간색으로 */
.shop-row .pr.poor { color: var(--danger); }

/* 확장 카드 */
#ex-cost { font-size: 19px; font-weight: 800; margin: 10px 0; }
#ex-warn { color: var(--danger); font-size: 14px; font-weight: 700; min-height: 20px; }

/* 일꾼 패널 */
#m-workers { min-width: 480px; }
.wk-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 10px;
  background: #fffaf0; border: 3px solid var(--outline); border-radius: 6px;
}
.wk-face {
  width: 44px; height: 48px; object-fit: contain; image-rendering: pixelated;
  background: #efe3c2; border: 2px solid var(--outline); border-radius: 6px; flex: none;
  padding: 4px;
}
.wk-info { flex: 1; font-size: 15px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 4px; border: 2px solid var(--outline); background: #fffaf0; }
.chip.sel { background: var(--accent); border-color: #9c5518; color: var(--accent-text); font-weight: 700; }
.crop-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; }
.crop-chip img { width: 22px; height: 22px; object-fit: contain; image-rendering: pixelated; }
/* 역할 탭 — 기본은 탭 줄만, 선택된 역할에 하위 옵션이 있으면 .wk-rolesub가 탭에 이어붙은 패널처럼 펼쳐진다 */
.wk-roletabs { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.role-tab { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; }
.role-tab img { width: 18px; height: 18px; object-fit: contain; image-rendering: pixelated; }
.role-tab.sel { border-radius: 4px 4px 0 0; }
.wk-rolesub {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 6px 8px; margin-top: -2px;
  background: #fff3de; border: 2px solid #9c5518; border-radius: 0 4px 4px 4px;
}
.wk-rolesub .crop-chip { background: #fffaf0; }
/* 선택된 하위 작업(담당 작물)도 역할 탭과 똑같이 주황 배경 — 위 규칙이 .chip.sel을 덮어써 선택 표시가 사라지던 문제 */
.wk-rolesub .crop-chip.sel { background: var(--accent); border-color: #9c5518; color: var(--accent-text); font-weight: 700; }

/* 목장 패널 */
#m-ranch { min-width: 520px; }
/* 확장 조건 미충족 사유(bad) / 사라질 밭 경고(warn) */
.ranch-note { margin: 6px 2px 0; font-size: 13px; font-weight: 700; }
.ranch-note.hidden { display: none; }
.ranch-note.bad { color: var(--danger); }
.ranch-note.warn { color: #b57e14; }
.ranch-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; margin-bottom: 12px; font-size: 15px;
  background: #fffaf0; border: 3px solid var(--outline); border-radius: 6px;
}
.ranch-sub { font-size: 15px; margin: 14px 0 8px; color: #6b5741; }
.ranch-ready { font-size: 13px; font-weight: 700; color: #3e7b32; margin-top: 4px; }
/* 동물 얼굴 — 4프레임 strip의 0번 프레임만 표시 (background-size 400%) */
.ani-face {
  width: 48px; height: 48px; flex: none;
  background-color: #efe3c2; border: 2px solid var(--outline); border-radius: 6px;
  background-repeat: no-repeat; background-size: 400% 100%; background-position: 0 0;
  image-rendering: pixelated;
}
.ani-face.sm { width: 32px; height: 32px; border: none; background-color: transparent; }
.ani-face.chicken { background-image: url("../assets/elements/spr_deco_chicken_01_strip4.png"); }
.ani-face.pig     { background-image: url("../assets/elements/spr_deco_pig_01_strip4.png"); }
.ani-face.sheep   { background-image: url("../assets/elements/spr_deco_sheep_01_strip4.png"); }
.ani-face.cow     { background-image: url("../assets/elements/spr_deco_cow_strip4.png"); }

/* 방치 정산 */
#m-offline { text-align: center; min-width: 380px; }
#off-gold { font-size: 18px; margin: 10px 0 4px; }

/* 일시정지 */
#m-pause { text-align: center; min-width: 320px; }
#m-pause .btn { display: block; width: 240px; margin: 10px auto 0; font-size: 18px; }

/* ===== 모션 감소 ===== */
body.rm *, body.rm *::before, body.rm *::after {
  transition: none !important; animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===== 로그인 화면 (율도) ===== */
#screen-login {
  z-index: 50;   /* 로비/게임 위 게이트 */
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, #6ba84a 0%, #4e8b39 45%, #2f5d26 100%);
}
.login-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(20, 34, 14, .55) 100%);
}
.login-card {
  position: relative; z-index: 2;
  width: min(88vw, 380px);
  padding: 32px 28px 26px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  text-align: center;
}
.login-logo .t { font-size: 40px; font-weight: 800; line-height: 1.1; text-shadow: 0 3px 0 rgba(30, 18, 8, .35); }
.login-logo .s { font-size: 15px; color: var(--gold); margin-top: 4px; }
.login-status {
  min-height: 20px; font-size: 14px; color: #6b5741; line-height: 1.4;
}
.login-status.ok { color: var(--success); font-weight: 700; }
.login-status.err { color: var(--danger); font-weight: 700; }
.login-actions {
  display: flex; flex-direction: column; gap: 12px; width: 100%;
}
.login-actions .btn { width: 100%; font-size: 18px; padding: 12px 18px; }
.login-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px solid rgba(92, 70, 50, .25); border-top-color: var(--accent);
  animation: login-spin .8s linear infinite;
}
@keyframes login-spin { to { transform: rotate(360deg); } }
