* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: transparent; overflow: hidden;
  font-family: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-size: 14px; color: #2B1B0E; user-select: none;
}
#stageHost, #stage { position: absolute; inset: 0; display: block; }
.tag { position: absolute; transform: translate(-50%, -100%); background: rgba(255,253,245,.92); border: 2px solid #2B1B0E; border-radius: 8px; padding: 2px 8px; font-size: 13px; font-weight: bold; white-space: nowrap; pointer-events: none; }
.icon { position: absolute; transform: translate(-50%, -100%); font-size: 26px; pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.hidden { display: none !important; }

/* 말풍선 */
#bubbles { position: absolute; inset: 0; pointer-events: none; }
.bubble {
  position: absolute; transform: translate(-50%, -100%);
  background: #FFFDF5; border: 2px solid #2B1B0E; border-radius: 12px;
  padding: 6px 10px; font-size: 13px; white-space: nowrap; max-width: 260px;
  box-shadow: 2px 2px 0 #2B1B0E; pointer-events: none;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; margin-left: -6px;
  border: 6px solid transparent; border-top-color: #2B1B0E; border-bottom: 0;
}
.bubble.big { font-size: 20px; padding: 10px 16px; }

/* 타이머 알약 */
#timerPill {
  position: absolute; right: 16px; bottom: 16px;
  background: #2B1B0E; color: #FFF; border-radius: 999px;
  padding: 8px 16px; font-size: 16px; font-weight: bold; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
#timerPill.break { background: #2E9E63; }
#timerPill.class { background: #D9534F; }
#timerPill.ending { animation: blink .6s steps(2) infinite; }
@keyframes blink { to { opacity: .4; } }

/* 메뉴 패널 */
#panel {
  /* 화면 가운데. 아이들이 쓰는 화면이라 구석에 붙어 있으면 잘 못 찾는다. */
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 28px)); max-height: 78vh; display: flex; flex-direction: column;
  z-index: 45;   /* 덮개(#dim, 44) 보다 위 */
  background: #FFFDF5; border: 3px solid #2B1B0E; border-radius: 16px;
  box-shadow: 4px 4px 0 #2B1B0E; overflow: hidden;
}
.tabs { display: flex; background: #FFE9A8; border-bottom: 3px solid #2B1B0E; }
.tabs button {
  flex: 1; border: 0; background: transparent; padding: 10px 4px; font: inherit;
  font-weight: bold; cursor: pointer; color: #6B5B3E; box-shadow: none; border-radius: 0;
}
.tabs button.active { background: #FFFDF5; color: #2B1B0E; }
.tabs button.close { flex: 0 0 40px; }
.tab { display: none; padding: 14px; overflow: auto; }
.tab.active { display: block; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.label { font-weight: bold; margin-right: 4px; }
.hint { color: #7A6A4F; font-size: 12px; margin: 6px 0 0; line-height: 1.5; }
button {
  font: inherit; border: 2px solid #2B1B0E; background: #FFF; border-radius: 10px;
  padding: 6px 12px; cursor: pointer; box-shadow: 2px 2px 0 #2B1B0E;
}
button:active { transform: translate(2px, 2px); box-shadow: none; }
button.primary { background: #FFD93D; }
button.danger { background: #FFB4A8; }
button.small { padding: 3px 8px; font-size: 12px; box-shadow: 1px 1px 0 #2B1B0E; }
input[type=number], input[type=text], textarea {
  font: inherit; border: 2px solid #2B1B0E; border-radius: 8px; padding: 6px 8px; background: #FFF;
}
input[type=number] { width: 64px; }
input[type=text] { flex: 1; }
textarea { width: 100%; height: 120px; resize: vertical; }
label { display: inline-flex; align-items: center; gap: 4px; }

/* 펫 카드 */
.petCard {
  border: 2px solid #2B1B0E; border-radius: 12px; padding: 10px; margin-bottom: 8px; background: #FFF;
}
.petCard.selected { background: #FFF6CC; }
.petCard .head { display: flex; align-items: center; gap: 8px; }
.petCard .name { font-weight: bold; font-size: 15px; }
.petCard .stage { font-size: 12px; color: #7A6A4F; }
.bar { height: 10px; background: #EEE6D6; border: 1px solid #2B1B0E; border-radius: 6px; overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; background: #FFB347; }
.bar.happy > i { background: #FF8AA8; }
.bar.water > i { background: #6FB7FF; }
.bar.clean > i { background: #C8B88A; }
.bar.amm > i { background: #9CCB7A; }
.bar.amm.smell > i { background: #E8C45A; }
.bar.amm.bad > i { background: #E0654F; }
.bar.bed > i { background: #D9B86A; }
.lampDial { display: flex; gap: 3px; }
.lampDial button { padding: 3px 9px; font-size: 12px; box-shadow: 1px 1px 0 #2B1B0E; }
.supply .stat span { font-size: 12px; color: #7A6A4F; }
.bar.exp > i { background: #7EC8E3; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 4px; }
.stat b { width: 44px; }
.petCard .actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
#adoptButtons { display: flex; gap: 6px; flex-wrap: wrap; }

.timerBig { font-size: 48px; font-weight: bold; text-align: center; letter-spacing: 2px; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.pickResult { min-height: 48px; font-size: 28px; font-weight: bold; text-align: center; padding: 10px; border-radius: 12px; background: #FFF6CC; margin-top: 8px; }
#todoList { list-style: none; padding: 0; margin: 8px 0 0; }
#todoList li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #D9CFB8; }
#todoList li.done span { text-decoration: line-through; color: #A09070; }
#todoList li span { flex: 1; }
.help { background: #FFF6CC; border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.6; margin: 8px 0; }
.help ul { margin: 4px 0 0; padding-left: 18px; }
.version { font-size: 12px; color: #7A6A4F; margin-left: auto; }
.tabs button:active { transform: none; }

/* 닭장 */
.supply { background: #FFF6CC; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.supply .stat b { width: 70px; }
.supply .stat button { margin-left: 4px; }
.row.tiny { font-size: 13px; gap: 14px; margin: 6px 0 0; }
.petCard .sex { font-size: 12px; padding: 1px 6px; border-radius: 6px; background: #EEE6D6; }
.petCard .sex.f { background: #FFD6E0; } .petCard .sex.m { background: #CFE4FF; }

/* 알림 카드 */
#toasts { position: absolute; right: 16px; bottom: 70px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { background: #FFFDF5; border: 2px solid #2B1B0E; border-radius: 12px; padding: 8px 14px; font-size: 14px; box-shadow: 3px 3px 0 #2B1B0E; animation: toastIn .3s ease-out; max-width: 320px; }
.toast.big { font-size: 17px; font-weight: bold; }
@keyframes toastIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 앨범 */
#journalModal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.25); }
.modalCard { background: #FFFDF5; border: 3px solid #2B1B0E; border-radius: 16px; padding: 18px; width: 420px; max-height: 70vh; overflow: auto; box-shadow: 4px 4px 0 #2B1B0E; }
.modalCard h3 { margin: 0 0 10px; }
.albumItem { border-bottom: 1px dashed #D9CFB8; padding: 8px 0; font-size: 13px; }
.albumItem b { font-size: 15px; }


/* 숫자 대신 말 */
.say { flex: 1; font-size: 13px; color: #4A4034; }
.say.smell { color: #9A7B1E; }
.say.bad { color: #B23C25; font-weight: 700; }
.nums { font-size: 11px; color: #8B8070; padding: 2px 0 0 2px; letter-spacing: -.2px; }
.chk { font-size: 12px; color: #6B6153; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }

/* 할머니 — 게임 NPC 대화창. 초상은 왼쪽 아래, 대사는 오른쪽. */
#granny {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 58;
  display: flex; align-items: flex-end; gap: 0;
  padding: 0 clamp(10px, 4vw, 52px) clamp(10px, 2.5vh, 26px);
  pointer-events: none;                       /* 마당은 계속 보인다 */
  animation: gIn .3s cubic-bezier(.2,1.2,.5,1);
}
@keyframes gIn { from { opacity: 0; transform: translateY(18px); } }
#granny.hidden, #gAsk.hidden { display: none; }
#gImg {
  width: auto; height: clamp(130px, 22vh, 210px);   /* 예시 화면의 절반 정도 */
  margin: 0 -14px -6px 0; flex: none; pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(43,27,14,.28));
}
#granny .gBox {
  flex: 1; min-width: 0; pointer-events: auto;
  background: rgba(255,253,245,.97); border: 3px solid #2B1B0E; border-radius: 16px;
  padding: 13px 18px 15px; box-shadow: 0 5px 0 rgba(43,27,14,.22);
}
#granny .gName {
  font-size: 12px; font-weight: 700; color: #8A6B3A; letter-spacing: .5px;
  margin-bottom: 3px;
}
#granny p { margin: 0; font-size: clamp(14px, 1.5vw, 16px); line-height: 1.7; color: #2B2620; }
/* 모이통이 둘일 때 — 어느 통 이야기인지 색으로 알 수 있게 */
.feedRow { display: flex; align-items: center; gap: 7px; margin: 3px 0; }
.feedRow.hidden { display: none; }
.feedDot { width: 13px; height: 13px; border-radius: 4px; border: 2px solid #2B1B0E; flex: none; }
.feedDot.red { background: #E0524E; }
.feedDot.blue { background: #6FA8DC; }

/* 화면 안에서 묻기 — prompt() 는 미리보기·내장 브라우저에서 막힌다 */
/* 화면 안에서 묻는 입력창 — 브라우저 prompt() 대신 쓴다 (내장 브라우저에서 막히기 때문) */
#askModal { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: rgba(30, 24, 16, .3); }
.askCard { width: min(380px, calc(100vw - 32px)); padding: 16px; }
.askCard p { margin: 0 0 10px; font-size: 14px; line-height: 1.6; color: #2B2620; white-space: pre-line; }
.askCard input {
  width: 100%; box-sizing: border-box; padding: 9px 11px; font-size: 15px;
  border: 2px solid #2B1B0E; border-radius: 10px; background: #FFFDF5; color: #2B2620;
}
.askCard .btnRow { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }

/* 할머니의 가게 */
.shopCard { width: min(560px, calc(100vw - 28px)); max-height: 84vh; display: flex; flex-direction: column; }
.shopTabs { display: flex; gap: 6px; padding: 0 14px 8px; flex-wrap: wrap; }
.shopTabs .stab {
  flex: 1 1 0; min-width: 76px; padding: 7px 4px; border-radius: 10px; cursor: pointer;
  border: 2px solid #2B1B0E; background: #FFFDF5; font-size: 13px; box-shadow: 1px 1px 0 #2B1B0E;
}
.shopTabs .stab.on { background: #FFD966; font-weight: 700; }
#shopHint { margin: 0 14px 8px; color: #7A6A50; }
.shopGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 9px; padding: 0 14px 14px; overflow-y: auto; }
.shopItem {
  border: 2px solid #2B1B0E; border-radius: 12px; background: #FFFDF5; padding: 9px 7px;
  text-align: center; cursor: pointer; box-shadow: 2px 2px 0 #2B1B0E; font-size: 12.5px;
}
.shopItem .si { font-size: 26px; line-height: 1.1; display: block; }
.shopItem .sn { display: block; margin-top: 3px; font-weight: 700; color: #2B2620; }
.shopItem .sp { display: block; margin-top: 2px; color: #7A5A20; }
.shopItem.own { background: #F1F7EA; }
.shopItem.on { background: #FFD966; }
.shopItem.cant { opacity: .55; }
#shopCoins { font-weight: 700; color: #7A5A20; margin-right: 6px; }

/* 오늘의 날씨 — 왼쪽 위. 늘 보이지만 작고, 마당을 가리지 않는다 */
#wxBadge {
  position: fixed; top: 12px; left: 14px; z-index: 30;
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,253,245,.9); border: 2px solid #2B1B0E; border-radius: 12px;
  padding: 5px 10px 5px 8px; box-shadow: 2px 2px 0 #2B1B0E;
  font-size: clamp(12px, 1.3vw, 14px); color: #2B2620; pointer-events: none;
  transition: opacity .35s ease;
}
#wxBadge #wxIcon { font-size: 1.25em; line-height: 1; }
#wxBadge b { font-weight: 700; color: #7A5A20; }
#wxBadge b:empty { display: none; }
#wxBadge #wxTemp { color: #7A6A50; }
#wxBadge #wxTemp:empty { display: none; }
#wxBadge #wxTemp.warn { color: #C2571F; font-weight: 700; }
#wxBadge.hidden { display: none; }
body.uiIdle #wxBadge { opacity: .4; }

/* QR — 휴대폰 사진기로 비추는 그림. 흰 테두리를 잘라내면 안 읽힌다 */
#granny .gQr { margin: 8px 0 0; text-align: center; }
#granny .gQr svg { border-radius: 8px; box-shadow: 0 2px 8px rgba(43,27,14,.18); vertical-align: top; }

/* 농장 코드 — 눈으로 따라 읽어야 하는 글자라, 말풍선 글씨와 섞이면 안 된다 */
#granny .gCode {
  margin: 8px 0 2px; padding: 8px 10px; border-radius: 10px;
  background: #FFF6DC; border: 1.5px solid #E8D9A8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(11px, 1.15vw, 13px); line-height: 1.55; letter-spacing: .02em;
  color: #4A3B1E; word-break: break-all; user-select: all; max-height: 26vh; overflow-y: auto;
}
#gBtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#gBtns button {
  font: inherit; font-size: 14px; border: 2px solid #2B1B0E; border-radius: 12px;
  background: #FFF; padding: 9px 16px; cursor: pointer; text-align: left; line-height: 1.35;
}
#gBtns button:hover { background: #FFE9A8; }
#gBtns button.primary { background: #FFD873; font-weight: 700; }
#gBtns button small { display: block; font-size: 11px; opacity: .6; font-weight: 400; margin-top: 2px; }
/* 큰 선택지 — 고르는 순간에는 버튼이 크고 시원해야 한다 */
#granny.choose .gBox { padding: 20px 22px 22px; }
#granny.choose p { font-size: clamp(16px, 1.9vw, 20px); font-weight: 700; }
#granny.choose #gBtns { gap: 10px; }
#granny.choose #gBtns button { flex: 1 1 150px; padding: 14px 16px; font-size: 15px; text-align: center; }
#granny.choose #gBtns button small { text-align: center; }
#gAsk {
  position: fixed; left: 14px; bottom: 16px; z-index: 56;
  font: inherit; font-size: 13px; border: 2px solid #2B1B0E; border-radius: 999px;
  background: rgba(255,253,245,.94); padding: 8px 14px; cursor: pointer;
  box-shadow: 0 3px 0 rgba(43,27,14,.2);
}
#gAsk:hover { background: #FFE9A8; }
body.uiIdle #gAsk { opacity: 0; pointer-events: none; transition: opacity .55s; }
@media (max-width: 640px) { #gImg { height: 110px; margin-right: -10px; } }

/* 메뉴가 떠 있으면 마당을 살짝 가라앉힌다.
   ::before(쌓임 맥락 문제)도 퍼지는 그림자(잘림 문제)도 아닌, 그냥 덮개 한 장이 제일 안전하다. */
#dim { position: fixed; inset: 0; z-index: 44; background: rgba(30, 24, 16, .22); display: none; }
body.menuOpen #dim { display: block; }
#moreBox.hidden { display: none; }

/* 관찰일지 */
.jCard { width: min(560px, calc(100vw - 28px)); max-height: 82vh; display: flex; flex-direction: column; }
.jHead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.jHead h3 { margin: 0; flex: 1; }
.jActs { display: flex; gap: 6px; }
#journalList { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.jItem {
  display: flex; gap: 11px; align-items: flex-start;
  background: #FFFDF5; border: 2px solid #E2DCCD; border-radius: 12px; padding: 9px;
}
.jShot { width: 100px; height: 65px; border-radius: 8px; object-fit: cover; flex: none; border: 2px solid #2B1B0E; }
.jShot.noshot {
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; background: #EFEADC; border-style: dashed; border-color: #CFC7B2;
}
.jBody { flex: 1; min-width: 0; }
.jTop { display: flex; align-items: baseline; gap: 8px; }
.jTop b { font-size: 14px; }
.jDay { font-size: 11px; color: #8B8070; margin-left: auto; }
.jBody p { margin: 4px 0 0; font-size: 13px; line-height: 1.6; color: #4A4034; }

/* 인쇄하면 일지만 나온다 — 그대로 관찰 기록장이 된다 */
@media print {
  body > * { display: none !important; }
  #journalModal, #journalModal * { display: revert !important; }
  #journalModal { position: static !important; background: none !important; }
  #journalModal .jCard {
    width: auto !important; max-height: none !important; border: 0 !important;
    box-shadow: none !important; padding: 0 !important;
  }
  .jActs { display: none !important; }
  #journalList { overflow: visible !important; }
  .jItem { break-inside: avoid; border-color: #BBB; }
}

#advBox.hidden, #helpBox.hidden { display: none; }
#advBox { border-top: 1px dashed #D9CFB8; margin-top: 8px; padding-top: 8px; }

/* 버튼처럼 안 생긴 버튼 — 펼치기·되돌리기처럼 눈에 덜 띄어야 하는 것들 */
.linky {
  border: 0; background: none; font: inherit; font-size: 12px; color: #7A6F5E;
  cursor: pointer; padding: 3px 2px; text-decoration: underline; text-underline-offset: 3px;
}
.linky:hover { color: #2B1B0E; }
.linky.danger { color: #B04A32; }
/* 저장·가져오기는 눈에 띄게 */
.saveRow .big { font-size: 14px; padding: 9px 14px; background: #FFF3D0; }
.saveRow .big:hover { background: #FFE9A8; }
/* 닭 카드 */
.petCard { position: relative; }
.iconBtn { border: 0; background: none; font-size: 13px; cursor: pointer; padding: 0 2px; line-height: 1; opacity: .55; }
.iconBtn:hover { opacity: 1; }
.petShot {
  position: absolute; right: 10px; top: 10px; width: 62px; height: 62px;
  border-radius: 12px; border: 2px solid #2B1B0E; object-fit: cover; background: #EFEADC;
}
.petShot.noshot { display: flex; align-items: center; justify-content: center; font-size: 24px; border-style: dashed; border-color: #CFC7B2; }
.petCard .head, .petCard .stat, .petCard .hint { padding-right: 76px; }
.petCard .actions { padding-right: 0; }

/* ── 설정: 묶어서 보여준다 ── */
.tab .card {
  background: #FFFBF0; border: 2px solid #E6DFCC; border-radius: 14px;
  padding: 12px 14px; margin-bottom: 10px;
}
.tab .card.sub { background: #F7F4EA; }
.tab .card h4 { margin: 0 0 6px; font-size: 14px; }
.tab .card > p { margin: 0 0 10px; font-size: 12.5px; color: #6B6153; line-height: 1.65; }
.tab .btnRow { display: flex; gap: 8px; }
.tab .btnRow.wrap { flex-wrap: wrap; gap: 4px 12px; }
.tab .btnRow .big { flex: 1; font-size: 14px; padding: 10px 8px; background: #FFF3D0; }
.tab .btnRow .big:hover { background: #FFE9A8; }
.row.center { justify-content: center; }
.tips { margin: 0; padding-left: 18px; }
.tips li { font-size: 12.5px; line-height: 1.75; color: #4A4034; }

/* 스위치 */
.sw { display: flex; align-items: center; gap: 10px; padding: 7px 0; cursor: pointer; font-size: 14px; }
.sw span { flex: 1; }
.sw input { position: absolute; opacity: 0; pointer-events: none; }
.sw i {
  flex: none; width: 42px; height: 24px; border-radius: 999px;
  background: #DDD5C4; border: 2px solid #2B1B0E; position: relative; transition: background .18s;
}
.sw i::after {
  content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #FFF; border: 2px solid #2B1B0E; transition: transform .18s;
}
.sw input:checked + i { background: #7FBF5A; }
.sw input:checked + i::after { transform: translateX(18px); }

/* 행동 도감 (관찰일지 맨 위) */
.dexBox { border-bottom: 2px dashed #D9CFB8; padding-bottom: 12px; margin-bottom: 10px; }
.dexHead { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; }
.dexGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin-top: 6px; }
.dexCell { border: 2px solid #E4DAC4; border-radius: 10px; padding: 6px; background: #F6F1E4; color: #A89B82; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.dexCell .di { font-size: 20px; }
.dexCell .dn { font-weight: bold; font-size: 13px; }
.dexCell.got { background: #FFFDF5; border-color: #2B1B0E; color: #2B2620; }
.dexCell .dw { font-size: 11px; line-height: 1.45; color: #5A4A38; }
.dexCell .dd { font-size: 10px; color: #A08868; }
