/* 번들 폰트: Galmuri11 (SIL OFL 1.1, assets/fonts/OFL.txt) — 기존 데모와 같은 글꼴 */
@font-face { font-family: "Galmuri11"; font-weight: 400; font-style: normal; font-display: block; src: url("assets/fonts/Galmuri11.woff2") format("woff2"); }
@font-face { font-family: "Galmuri11"; font-weight: 700; font-style: normal; font-display: block; src: url("assets/fonts/Galmuri11-Bold.woff2") format("woff2"); }
:root {
  --cream: #F1E4CF; --cream-light: #FBF4E6; --sage: #A7B5A0; --rose: #C88F8C;
  --wood: #B58B65; --blue: #737E99; --ink: #272638; --ink-soft: #3E3C52;
  --s: 2; /* 게임 픽셀 1칸 = 화면 CSS 픽셀 수 (Display.js가 갱신) */
  --font: "Galmuri11", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #19182a; overflow: hidden; overscroll-behavior: none; }
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#app { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#stage { position: relative; width: 960px; height: 540px; font-family: var(--font); color: var(--cream); }
#game { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui button { pointer-events: auto; font-family: var(--font); cursor: pointer; }

/* 상단 HUD: 게임 좌표 0~18px */
#hud-top {
  position: absolute; left: 0; right: 0; top: 0; height: calc(var(--s) * 18px);
  display: flex; align-items: center; gap: calc(var(--s) * 8px); padding: 0 calc(var(--s) * 6px);
  font-size: max(12px, calc(var(--s) * 8px)); letter-spacing: 0.04em; font-weight: 700;
}
#hud-space { color: var(--cream-light); }
#hud-mode { color: var(--rose); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dbg-btn, #info-btn {
  height: calc(var(--s) * 14px); min-width: calc(var(--s) * 16px); padding: 0; line-height: 1;
  background: transparent; color: var(--cream); border: calc(var(--s) * 1px) solid var(--blue); font-size: max(12px, calc(var(--s) * 8px));
}
#dbg-btn.on, #info-btn.on { background: var(--blue); color: var(--cream-light); }

/* 하단 HUD: 게임 좌표 228~270px — 카메라 전환 · 안내 · 화면 조작 버튼 */
#hud-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--s) * 42px);
  display: flex; align-items: center; gap: calc(var(--s) * 8px); padding: calc(var(--s) * 4px) calc(var(--s) * 8px);
}
/* 비교 조작: 2줄 × 3칸 (A·C·청소 / 1×·1.5×·2×) */
#ctrl { display: grid; grid-template-columns: repeat(3, auto); grid-template-rows: 1fr 1fr; gap: calc(var(--s) * 2px) calc(var(--s) * 3px); height: 100%; }
#ctrl button {
  min-width: calc(var(--s) * 30px); min-height: 22px; padding: 0 calc(var(--s) * 3px);
  font-size: max(11px, calc(var(--s) * 7px)); font-weight: 700; line-height: 1;
  background: var(--ink-soft); color: var(--cream); border: calc(var(--s) * 1px) solid var(--blue);
}
#ctrl button.on { background: var(--cream); color: var(--ink); border-color: var(--cream-light); }
#ctrl button:active { transform: translateY(calc(var(--s) * 1px)); }
#clean-btn.on { background: var(--sage); }
#info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: calc(var(--s) * 2px); font-size: max(11px, calc(var(--s) * 6.5px)); }
#info-found { color: var(--cream-light); font-weight: 700; }
#info-hint { color: var(--sage); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 화면 조작 버튼: 터치 기기에서만 (?pad 로 강제 표시) */
#pad { display: none; gap: calc(var(--s) * 3px); height: 100%; }
@media (pointer: coarse) { #pad { display: flex; } }
body.force-pad #pad { display: flex; }
#pad button {
  width: calc(var(--s) * 34px); min-width: 40px; height: 100%; padding: 0; font-size: max(14px, calc(var(--s) * 10px));
  background: var(--ink-soft); color: var(--cream-light); border: calc(var(--s) * 1px) solid var(--cream); touch-action: none;
}
#pad button.down { background: var(--cream); color: var(--ink); }

/* 물건 이름표 · 살펴봄 표시 (위치는 Hud.js가 카메라에 맞춰 갱신) */
#label, #pop {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--ink); color: var(--cream-light); white-space: nowrap;
  font-size: max(11px, calc(var(--s) * 6.5px)); font-weight: 700;
  padding: calc(var(--s) * 1px) calc(var(--s) * 4px);
  border: calc(var(--s) * 0.5px) solid var(--cream);
}
#pop { background: var(--sage); color: var(--ink); border-color: var(--ink); }
#label[hidden], #pop[hidden] { display: none; }

/* 청소 장소 표시 (원본 데모의 zone-tag와 같은 모양, 위치는 Hud.js가 카메라·확대에 맞춰 갱신) */
#tags { position: absolute; inset: 0; pointer-events: none; }
.zone-tag {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap; display: none;
  background: var(--ink-soft); color: var(--cream-light); border: calc(var(--s) * 0.5px) solid var(--blue);
  font-size: max(10px, calc(var(--s) * 6px)); font-weight: 700; padding: 0 calc(var(--s) * 3px);
}
body.cleaning .zone-tag { display: block; opacity: 0.85; }
.zone-tag.active { opacity: 1; border-color: var(--rose); }
.zone-tag.target { background: var(--sage); color: var(--ink); }
.zone-tag.full { color: var(--blue); border-style: dashed; }
.zone-tag.target.full { background: var(--rose); color: var(--cream-light); }

/* 디버그 글자 */
#debug {
  position: absolute; left: calc(var(--s) * 6px); top: calc(var(--s) * 21px); white-space: pre; line-height: 1.3;
  font-size: max(10px, calc(var(--s) * 5.5px)); color: #fff; background: rgba(39, 38, 56, 0.7); padding: calc(var(--s) * 2px) calc(var(--s) * 3px);
}
#debug[hidden] { display: none; }

#overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--ink); font-size: max(13px, calc(var(--s) * 8px)); transition: opacity 0.4s;
  text-align: center; padding: 2em; white-space: pre-line;
}
#overlay.gone { opacity: 0; pointer-events: none; }
#overlay.error { color: var(--rose); pointer-events: auto; user-select: text; -webkit-user-select: text; }

/* 세로 화면 안내 (기존 데모와 동일) */
#rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 600px) {
  #rotate-hint {
    display: flex; position: fixed; inset: 0; z-index: 20; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; background: rgba(25, 24, 42, 0.94); color: var(--cream-light); font-family: var(--font); text-align: center; padding: 24px;
  }
  #rotate-hint p { margin: 0; font-size: 17px; font-weight: 700; }
  #rotate-hint p.small { font-size: 13px; font-weight: 400; color: var(--cream); }
  #rotate-hint .phone-icon { width: 34px; height: 56px; border: 4px solid var(--cream); animation: rotate-phone 2s steps(4) infinite; }
  @keyframes rotate-phone { 0%, 40% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
}
