/* 느티골 텃밭일기 — 패널·미니게임 UI (js/ui/panels.js가 만드는 DOM). 한지·나무 테두리 도트 프레임.
   글꼴은 style.css의 Galmuri11을 상속한다. PC는 가운데 창, 좁은 세로 화면은 아래에서 올라오는 시트. */

:root {
  --ng-hanji: #f5e8cb;
  --ng-hanji2: #ead9b4;
  --ng-ink: #3b2a1c;
  --ng-ink2: #6b5440;
  --ng-wood: #8a5a32;
  --ng-woodL: #c08a50;
  --ng-woodD: #4a2c16;
  --ng-woodDD: #2c1a0c;
  --ng-red: #c8553d;
  --ng-green: #4f8a35;
  --ng-greenL: #8cc66a;
  --ng-gold: #e0a83a;
  --ng-silver: #a9b6c2;
  --ng-blue: #4f7fb0;
  --ng-step: 6px;
}

/* ── 패널 겹 ── */
.ng-layer {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  font-family: inherit; color: var(--ng-ink);
  animation: ng-fade .14s ease-out;
}
.ng-layer.closing { animation: ng-fadeout .14s ease-in forwards; pointer-events: none; }
.ng-backdrop { position: absolute; inset: 0; background: rgba(28, 18, 10, .55); }
@keyframes ng-fade { from { opacity: 0; } }
@keyframes ng-fadeout { to { opacity: 0; } }

.ng-panel {
  position: relative; display: flex; flex-direction: column;
  width: min(560px, 96vw); max-height: min(86vh, 780px); max-height: min(86dvh, 780px);
  background-color: var(--ng-hanji);
  background-image:
    repeating-linear-gradient(17deg, rgba(150, 110, 60, .05) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(-23deg, rgba(150, 110, 60, .04) 0 1px, transparent 1px 13px);
  border: 4px solid var(--ng-woodD);
  box-shadow: inset 0 0 0 3px var(--ng-woodL), inset 0 0 0 5px var(--ng-wood), inset 0 0 0 7px var(--ng-woodD);
  clip-path: polygon(0 var(--ng-step), var(--ng-step) var(--ng-step), var(--ng-step) 0, calc(100% - var(--ng-step)) 0, calc(100% - var(--ng-step)) var(--ng-step), 100% var(--ng-step), 100% calc(100% - var(--ng-step)), calc(100% - var(--ng-step)) calc(100% - var(--ng-step)), calc(100% - var(--ng-step)) 100%, var(--ng-step) 100%, var(--ng-step) calc(100% - var(--ng-step)), 0 calc(100% - var(--ng-step)));
  animation: ng-pop .16s ease-out;
}
.ng-panel.wide { width: min(780px, 97vw); }
@keyframes ng-pop { from { transform: translateY(10px) scale(.98); opacity: .4; } }

.ng-head {
  display: flex; align-items: center; gap: 8px; flex: none;
  margin: 7px 7px 0; padding: 6px 6px 6px 14px;
  background: var(--ng-wood); color: #fff4d6;
  border-bottom: 3px solid var(--ng-woodD);
  box-shadow: inset 0 2px 0 var(--ng-woodL);
}
.ng-title { flex: 1; margin: 0; font-size: 1.05rem; font-weight: normal; letter-spacing: .02em; text-shadow: 1px 1px 0 var(--ng-woodDD); }
.ng-x {
  min-width: 44px; min-height: 44px; border: 3px solid var(--ng-woodDD); background: var(--ng-red); color: #fff;
  font: inherit; font-size: 1rem; cursor: pointer; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25);
}
.ng-x:hover { filter: brightness(1.1); }
.ng-body {
  flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 10px 14px 14px; margin: 0 7px 7px;
}

/* 좁은 세로 화면: 아래 시트 */
@media (max-width: 720px), (max-height: 520px) and (max-width: 900px) {
  .ng-layer { align-items: flex-end; padding: 0; }
  .ng-panel, .ng-panel.wide {
    width: 100%; max-height: 90vh; max-height: 90dvh;
    border-bottom: 0;
    clip-path: polygon(0 var(--ng-step), var(--ng-step) var(--ng-step), var(--ng-step) 0, calc(100% - var(--ng-step)) 0, calc(100% - var(--ng-step)) var(--ng-step), 100% var(--ng-step), 100% 100%, 0 100%);
    animation: ng-sheet .2s ease-out;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .ng-body { padding: 8px 10px 14px; }
  @keyframes ng-sheet { from { transform: translateY(40%); } }
}

/* ── 공용 요소 ── */
.ng-layer button, .ng-mg button { font: inherit; color: inherit; }
.ng-btn {
  min-height: 44px; padding: 6px 14px; cursor: pointer;
  background: var(--ng-hanji2); color: var(--ng-ink);
  border: 3px solid var(--ng-woodD);
  box-shadow: inset 0 -3px 0 rgba(74, 44, 22, .25), inset 0 2px 0 rgba(255, 255, 255, .5);
  touch-action: manipulation; white-space: nowrap;
}
.ng-btn:hover:not(:disabled) { background: #fff3d9; }
.ng-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 -1px 0 rgba(74, 44, 22, .25); }
.ng-btn.primary { background: var(--ng-green); color: #fff; text-shadow: 1px 1px 0 rgba(0, 0, 0, .35); }
.ng-btn.primary:hover:not(:disabled) { background: #5c9c40; }
.ng-btn.danger { background: var(--ng-red); color: #fff; }
.ng-btn.small { min-height: 44px; padding: 4px 10px; font-size: .88rem; }
.ng-btn.sq { min-width: 44px; padding: 0; }
.ng-btn.big { min-height: 52px; padding: 8px 22px; font-size: 1.05rem; }
.ng-btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.ng-layer :focus-visible, .ng-mg :focus-visible { outline: 3px solid var(--ng-gold); outline-offset: 1px; }

.ng-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ng-actions.end { justify-content: flex-end; }
.ng-actions.center { justify-content: center; }
.ng-hint { margin: 2px 0 8px; font-size: .86rem; color: var(--ng-ink2); line-height: 1.45; }
.ng-muted { color: var(--ng-ink2); font-size: .86rem; }
.ng-why { color: var(--ng-red); font-size: .84rem; }
.ng-empty { margin: 14px 0; text-align: center; color: var(--ng-ink2); line-height: 1.5; }
.ng-greet { margin: 0 0 8px; padding: 8px 10px; background: #fff8e6; border: 2px dashed var(--ng-woodL); line-height: 1.5; }
.ng-big { font-size: 1.15rem; margin: 6px 0; line-height: 1.45; }
.center { text-align: center; justify-content: center; }
.ng-sub { margin: 14px 0 6px; font-size: .96rem; font-weight: normal; color: var(--ng-woodD); border-bottom: 2px dotted var(--ng-woodL); padding-bottom: 3px; }
.ng-subrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ng-subrow .ng-sub { flex: 1; }
.ng-banner { margin: 0 0 8px; padding: 8px 10px; background: #fff3d1; border: 3px solid var(--ng-woodL); line-height: 1.5; display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; }
.ng-banner.market { background: #ffe7c2; border-color: var(--ng-gold); }
.ng-banner.warn { background: #fde0d8; border-color: var(--ng-red); }
.ng-total { white-space: nowrap; }

/* 아이콘 */
.ng-ico { width: 32px; height: 32px; image-rendering: pixelated; image-rendering: crisp-edges; flex: none; pointer-events: none; }
.ng-ico.big { width: 48px; height: 48px; }
.ng-ico.huge { width: 96px; height: 96px; }
.ng-ico.portrait { width: 64px; height: 64px; background: #d9c39a; border: 3px solid var(--ng-woodD); }
.ng-ico.portrait.big { width: 96px; height: 96px; }
.ng-ico.portrait.small { width: 44px; height: 44px; }
.ng-ico.portrait.stall { object-fit: contain; background: #c9e2f0; }
.ng-ico.stall { width: 64px; height: 64px; object-fit: contain; }
.ng-ico.chr { width: 48px; height: 96px; object-fit: contain; }
.ng-ico-none { visibility: hidden; }
.ng-ghost { position: fixed; z-index: 2000; width: 44px; height: 44px; transform: translate(-50%, -60%); pointer-events: none; filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, .35)); }

/* 아이템 칸 */
.ng-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 4px; }
.ng-grid-bag { grid-template-columns: repeat(10, minmax(44px, 1fr)); }
@media (max-width: 560px) { .ng-grid-bag { grid-template-columns: repeat(6, minmax(44px, 1fr)); } }
.ng-slot {
  position: relative; aspect-ratio: 1; min-width: 44px; min-height: 44px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: #e6cf9f; border: 3px solid var(--ng-wood);
  box-shadow: inset 2px 2px 0 rgba(74, 44, 22, .25), inset -2px -2px 0 rgba(255, 255, 255, .35);
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.ng-slot.empty { background: #dcc391; cursor: default; }
.ng-slot.locked { background: repeating-linear-gradient(45deg, #b9a07a 0 4px, #a88f6a 4px 8px); border-color: #7d6448; cursor: not-allowed; }
.ng-slot.hot { border-color: var(--ng-woodD); }
.ng-slot.cur { box-shadow: inset 0 0 0 2px var(--ng-gold); }
.ng-slot.sel { border-color: var(--ng-red); background: #fff1cf; }
.ng-slot.moving { opacity: .5; border-style: dashed; }
.ng-slot.dropover { border-color: var(--ng-green); background: #e3f2cf; }
/* 가방 칸: 세로 스크롤은 살리고, 길게 눌러 들어 올린 뒤에만 끌기(inventory.js) */
.ng-grid-bag .ng-slot { touch-action: pan-y; }
.ng-slot.lifted { transform: scale(1.08); border-color: var(--ng-gold); box-shadow: 0 0 0 3px rgba(224, 168, 58, .6); }
.ng-slot.dim { opacity: .38; }
.ng-slot.want { border-color: var(--ng-green); animation: ng-want 1.2s ease-in-out infinite; }
@keyframes ng-want { 50% { background: #eef6d6; } }
.ng-slot:disabled:not(.locked):not(.empty) { cursor: not-allowed; }
.ng-slot.q1 .ng-ico { filter: drop-shadow(0 0 0 var(--ng-silver)); }
.ng-slot.q1 { border-color: #8a9aa8; box-shadow: inset 0 0 0 2px var(--ng-silver); }
.ng-slot.q2 { border-color: #b07c1e; box-shadow: inset 0 0 0 2px var(--ng-gold); }
.ng-n { position: absolute; right: 2px; bottom: 0; font-size: .78rem; color: #fff; text-shadow: 1px 0 0 #2c1a0c, -1px 0 0 #2c1a0c, 0 1px 0 #2c1a0c, 0 -1px 0 #2c1a0c; pointer-events: none; }
.ng-q { position: absolute; left: 2px; top: 0; font-size: .66rem; color: var(--ng-silver); text-shadow: 1px 1px 0 #2c1a0c; pointer-events: none; }
.q2 > .ng-q { color: var(--ng-gold); }
.ng-hot { position: absolute; left: 3px; bottom: 0; font-size: .64rem; color: var(--ng-woodD); opacity: .75; pointer-events: none; }
.ng-price { position: absolute; right: 1px; top: 0; font-size: .62rem; color: #fff7d6; background: rgba(44, 26, 12, .7); padding: 0 2px; pointer-events: none; }
.ng-lock { width: 12px; height: 10px; margin-top: 6px; background: #6b5440; position: relative; opacity: .7; }
.ng-lock::before { content: ''; position: absolute; left: 2px; top: -7px; width: 4px; height: 6px; border: 2px solid #6b5440; border-bottom: 0; }

/* 탭 */
.ng-tabs { display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; margin: 0 -2px 8px; padding: 0 2px; border-bottom: 3px solid var(--ng-wood); }
.ng-tabs::-webkit-scrollbar { display: none; }
.ng-tab {
  flex: none; min-height: 44px; padding: 4px 12px; cursor: pointer;
  background: var(--ng-hanji2); border: 3px solid var(--ng-wood); border-bottom: 0; color: var(--ng-ink2);
}
.ng-tab.on { background: var(--ng-wood); color: #fff4d6; border-color: var(--ng-woodD); }

/* 가방 상세·장비 */
.ng-detail { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; padding: 10px; background: #fff8e8; border: 3px solid var(--ng-woodL); min-height: 72px; }
.ng-detail-ico { flex: none; padding: 4px; background: #e6cf9f; border: 3px solid var(--ng-wood); align-self: flex-start; }
.ng-detail-txt { flex: 1; min-width: 180px; }
.ng-detail-txt b { margin-right: 6px; font-size: 1.02rem; }
.ng-detail-txt p { margin: 4px 0; line-height: 1.45; }
.ng-detail .ng-actions { flex-basis: 100%; margin-top: 0; }
.ng-tag { display: inline-block; margin: 0 4px 0 0; padding: 1px 6px; font-size: .74rem; background: var(--ng-hanji2); border: 2px solid var(--ng-woodL); }
.ng-tag.q1 { border-color: var(--ng-silver); }
.ng-tag.q2 { border-color: var(--ng-gold); }
.ng-equip { margin-top: 10px; }
.ng-equip h3 { margin: 4px 0; font-size: .92rem; font-weight: normal; color: var(--ng-woodD); }
.ng-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; margin-bottom: 6px; }
.ng-tool { display: flex; align-items: center; gap: 6px; padding: 3px 6px; background: #f0e0bd; border: 2px solid var(--ng-woodL); font-size: .86rem; }
.ng-tool.lv1 { border-color: #c4733a; }
.ng-tool.lv2 { border-color: #8a9aa8; }
.ng-tool.lv3 { border-color: var(--ng-gold); }
.ng-tool.busy { opacity: .7; border-style: dashed; }

/* 목록 행 */
.ng-list { display: flex; flex-direction: column; gap: 6px; }
.ng-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; width: 100%; text-align: left;
  background: #fff8e8; border: 3px solid var(--ng-woodL);
}
button.ng-row { cursor: pointer; min-height: 56px; }
.ng-row.sel { border-color: var(--ng-red); background: #fff1cf; }
.ng-row.cant { background: #f1e4c9; }
.ng-row.locked { opacity: .65; }
.ng-row.done { border-color: var(--ng-green); background: #eff7df; }
.ng-row-ico { position: relative; flex: none; display: flex; align-items: center; }
.ng-row-ico .ng-n { right: -2px; bottom: -2px; }
.ng-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ng-row-main p { margin: 0; line-height: 1.4; }
.ng-row-main small { line-height: 1.35; }
.ng-row-act { flex: none; display: flex; gap: 6px; }
.ng-row-act.col { flex-direction: column; }
@media (max-width: 520px) {
  .ng-row:not(button) { flex-wrap: wrap; }
  .ng-row:not(button) .ng-row-act { flex-basis: 100%; justify-content: flex-end; }
}
.ng-needs { display: flex; flex-wrap: wrap; gap: 4px; }
.ng-needs.big { gap: 6px; }
.ng-need { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 2px; font-size: .84rem; background: #f3dfd8; border: 2px solid #d9a99a; }
.ng-need .ng-ico { width: 24px; height: 24px; }
.ng-needs.big .ng-need .ng-ico { width: 32px; height: 32px; }
.ng-need.ok { background: #e6f2d3; border-color: var(--ng-greenL); }
.ng-need.love { background: #fde3ea; border-color: #e58aa5; }
.ng-need.unknown { padding: 2px 8px; color: var(--ng-ink2); background: #eee2c8; border-style: dashed; border-color: var(--ng-woodL); }
.ng-need.q1 { border-color: var(--ng-silver); }
.ng-need.q2 { border-color: var(--ng-gold); }
.ng-itemline { display: inline-flex; align-items: center; gap: 6px; }
.ng-itemline .ng-ico { width: 24px; height: 24px; }
.ng-bar { position: relative; height: 10px; background: #d9c39a; border: 2px solid var(--ng-woodD); }
.ng-bar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ng-green); }
.ng-bar.time > i { background: var(--ng-gold); transition: width .1s linear; }
.ng-stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.ng-stars i { width: 10px; height: 10px; background: #cdb88f; clip-path: polygon(50% 0, 63% 35%, 100% 38%, 72% 60%, 82% 100%, 50% 78%, 18% 100%, 28% 60%, 0 38%, 37% 35%); }
.ng-stars i.on { background: var(--ng-gold); }
.ng-hearts { display: inline-flex; gap: 3px; }
.ng-hearts i { width: 16px; height: 14px; background: #d8c3a5; clip-path: polygon(25% 0, 50% 20%, 75% 0, 100% 20%, 100% 50%, 50% 100%, 0 50%, 0 20%); }
.ng-hearts i.full { background: #e0566f; }
.ng-hearts i.half { background: linear-gradient(90deg, #e0566f 50%, #d8c3a5 50%); }
.ng-bday { color: #c0392b; font-size: .88rem; }
.ng-fav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ng-row.friend { align-items: flex-start; }

/* 스위치·세그먼트 */
.ng-switch { min-width: 72px; min-height: 44px; border: 3px solid var(--ng-woodD); background: #c9b28a; cursor: pointer; position: relative; }
.ng-switch.on { background: var(--ng-green); color: #fff; }
.ng-seg { display: inline-flex; border: 3px solid var(--ng-woodD); }
.ng-segb { min-height: 44px; min-width: 52px; padding: 2px 10px; border: 0; background: var(--ng-hanji2); cursor: pointer; }
.ng-segb + .ng-segb { border-left: 2px solid var(--ng-woodD); }
.ng-segb.on { background: var(--ng-wood); color: #fff4d6; }
.ng-row.setting.warn { border-color: var(--ng-red); background: #fde8e1; }
.ng-help { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; font-size: .88rem; line-height: 1.5; }
.ng-help ul { margin: 4px 0 0; padding-left: 18px; }
.ng-help > p { grid-column: 1 / -1; margin: 0; }

/* 도감 */
.ng-grid-col { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.ng-col { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; background: #eadbb9; border: 2px solid var(--ng-woodL); font-size: .74rem; text-align: center; min-height: 64px; }
.ng-col .ng-ico { filter: brightness(0) opacity(.35); }
.ng-col.got { background: #fff8e8; }
.ng-col.got .ng-ico { filter: none; }

/* 출하함 */
.ng-shiplist { display: flex; flex-direction: column; gap: 4px; max-height: 32vh; overflow: auto; }
.ng-shiprow { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 3px 8px; background: #fff8e8; border: 2px solid var(--ng-woodL); cursor: pointer; text-align: left; }
.ng-shiprow .nm { flex: 1; }
.ng-shiprow .pr { font-size: .84rem; color: var(--ng-ink2); }
.ng-shiprow .ng-undo { font-size: .76rem; padding: 2px 6px; background: var(--ng-hanji2); border: 2px solid var(--ng-woodL); }
.ng-shiprow:hover { background: #fff1cf; }
@media (max-width: 520px) { .ng-shiprow .pr { display: none; } }

/* 우편 */
.ng-maillist { display: flex; flex-direction: column; gap: 4px; }
.ng-mailrow { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 4px 10px; background: #fff8e8; border: 2px solid var(--ng-woodL); text-align: left; cursor: pointer; }
.ng-mailrow.unread { border-color: var(--ng-red); background: #fff1e6; }
.ng-mailrow.unread b::after { content: ' ●'; color: var(--ng-red); font-size: .7rem; }
.ng-mail-ico { font-size: 1.4rem; }
.ng-mail-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ng-mail-t small { color: var(--ng-ink2); }
.ng-letter { background: #fffaf0; border: 3px solid var(--ng-woodL); padding: 12px 14px; background-image: repeating-linear-gradient(transparent 0 27px, rgba(160, 120, 70, .18) 27px 28px); }
.ng-letter-head { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.ng-letter-head b { font-size: 1.05rem; }
.ng-letter-body p { margin: 0; line-height: 28px; }
.ng-attach { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding: 8px; background: #fff1cf; border: 2px dashed var(--ng-gold); }

/* TV */
.ng-tv { display: flex; justify-content: center; margin-bottom: 8px; }
.ng-tv-frame { display: flex; gap: 8px; padding: 12px; background: #6b4423; border: 4px solid var(--ng-woodDD); box-shadow: inset 0 3px 0 #9a6a3a; width: min(440px, 100%); }
.ng-tv-screen { position: relative; flex: 1; min-height: 190px; padding: 10px 12px; overflow: hidden; background: radial-gradient(ellipse at center, #355c4a 0%, #1e3a2e 100%); color: #e9fbe7; border: 4px solid #1a1a1a; border-radius: 14px / 18px; text-shadow: 0 0 4px rgba(170, 255, 190, .5); }
.ng-tv-screen::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(transparent 0 2px, rgba(0, 0, 0, .18) 2px 3px); }
.ng-tv-content { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.ng-tv-content p { margin: 0; line-height: 1.5; }
.ng-tv-cap { font-size: .8rem; padding: 1px 8px; background: rgba(0, 0, 0, .3); }
.ng-tv-big { font-size: 1.2rem; }
.ng-tv-tip { font-size: 1rem; padding: 10px 4px; }
.ng-tv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.ng-tv-cols ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.ng-tv-cols li { display: flex; align-items: center; gap: 4px; font-size: .84rem; }
.ng-tv-cols li span { flex: 1; text-align: left; }
.ng-tv-cols .ng-ico { width: 24px; height: 24px; }
.up { color: #2e7d32; }
.down { color: #b23b2a; }
.ng-tv-cols .up { color: #a8ff9a; }
.ng-tv-cols .down { color: #ffb3a1; }
.ng-tv-noise { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.ng-tv-knobs { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 6px; color: #f3dcb4; font-size: .7rem; }
.ng-tv-knobs i { width: 22px; height: 22px; border-radius: 50%; background: #2d2016; border: 3px solid #c79a5e; }
.ng-wx { width: 32px; height: 32px; image-rendering: pixelated; vertical-align: middle; background: #7fa7c9; border: 2px solid var(--ng-woodD); }
.ng-wx.big { width: 64px; height: 64px; background: none; border: 0; }

/* 표 */
.ng-tablewrap { max-height: 56vh; overflow: auto; border: 3px solid var(--ng-woodL); }
.ng-table { width: 100%; border-collapse: collapse; font-size: .88rem; background: #fff8e8; }
.ng-table th { position: sticky; top: 0; background: var(--ng-wood); color: #fff4d6; font-weight: normal; padding: 6px; text-align: left; }
.ng-table td { padding: 3px 6px; border-top: 1px dotted var(--ng-woodL); }

/* 상점 */
.ng-shophead { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.ng-por { flex: none; }
.ng-bubble { position: relative; flex: 1; padding: 8px 10px; background: #fff; border: 3px solid var(--ng-woodD); line-height: 1.45; }
.ng-bubble::before { content: ''; position: absolute; left: -11px; top: 16px; border: 8px solid transparent; border-right-color: var(--ng-woodD); border-left: 0; }
.ng-bubble p { margin: 2px 0; }
.ng-price-tag { flex: none; padding: 2px 8px; background: var(--ng-gold); color: var(--ng-woodDD); border: 2px solid var(--ng-woodD); white-space: nowrap; }
.ng-buybar {
  position: sticky; bottom: -14px; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 10px -4px 0; padding: 8px; background: #f3e1b9; border: 3px solid var(--ng-woodD);
}
.ng-buybar b { flex: 1; min-width: 90px; }
.ng-qty { display: inline-flex; align-items: center; gap: 4px; }
.ng-qty-v { min-width: 44px; text-align: center; }

/* 게시판 */
.ng-order { position: relative; padding: 10px 12px; background: #fff7e0; border: 3px solid var(--ng-wood); box-shadow: 3px 3px 0 rgba(74, 44, 22, .25); }
.ng-order .ng-sub { margin-top: 0; }
.ng-order p { margin: 6px 0; }
.ng-stamp { position: absolute; right: 12px; top: 10px; padding: 4px 10px; color: #c0392b; border: 3px solid #c0392b; transform: rotate(-12deg); font-size: 1.1rem; opacity: .85; }
.ng-news { margin: 0; padding-left: 20px; line-height: 1.6; font-size: .9rem; }

/* 장터 기부 */
.ng-stallhead { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.ng-stallhead p { margin: 2px 0; }
.ng-reqs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.ng-req { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px; background: #fff8e8; border: 3px dashed var(--ng-woodL); text-align: center; font-size: .84rem; }
.ng-req.full { border-style: solid; border-color: var(--ng-green); background: #eff7df; }
.ng-req .ng-bar { width: 100%; }
.ng-req-ico { position: relative; }
.ng-check { position: absolute; right: -6px; bottom: -4px; color: #fff; background: var(--ng-green); padding: 0 4px; border: 2px solid var(--ng-woodD); font-size: .8rem; }
.ng-celebrate { margin: 12px 0 0; padding: 12px; text-align: center; background: #fff1c4; border: 3px solid var(--ng-gold); animation: ng-pop .3s ease-out; }
.ng-celebrate b { font-size: 1.1rem; }
.ng-confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.ng-confetti i { position: absolute; top: -10px; width: 6px; height: 8px; animation: ng-fall linear forwards; }
@keyframes ng-fall { to { transform: translateY(110vh) rotate(540deg); } }

/* 엘리베이터·잠 */
.ng-floors { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.ng-btn.floor { min-height: 64px; font-size: 1.1rem; background: #d8d2c4; }
.ng-btn.floor.cur { background: var(--ng-gold); }
.ng-sleep { text-align: center; padding: 8px 0; }
.ng-moon { width: 48px; height: 48px; margin: 4px auto 8px; background: #f7e08a; border-radius: 50%; box-shadow: inset -12px -4px 0 #d9b94c, 0 0 18px rgba(247, 224, 138, .7); }

/* 하루 정산 */
.ng-anim { opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
.ng-anim.shown { opacity: 1; transform: none; }
.ng-ledger { display: flex; flex-direction: column; gap: 3px; }
.ng-ledger-row { display: flex; align-items: center; gap: 8px; padding: 2px 6px; background: #fff8e8; border-bottom: 2px dotted var(--ng-woodL); }
.ng-ledger-row .nm { flex: 1; }
.ng-ledger-total { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; padding: 8px 10px; background: var(--ng-wood); color: #fff4d6; font-size: 1.1rem; }
.ng-ledger-total b { font-size: 1.3rem; color: #ffe38a; }
.ng-levelups { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ng-lvup { padding: 4px 10px; background: #fff1c4; border: 3px solid var(--ng-gold); animation: ng-glow 1s ease-in-out infinite alternate; }
@keyframes ng-glow { to { box-shadow: 0 0 10px rgba(224, 168, 58, .8); } }
.ng-summary .ng-news { margin-top: 8px; }
.ng-morning { margin-top: 10px; padding: 8px 10px; background: #e8f1f7; border: 3px solid #8fb1cc; }
.ng-morning p { margin: 4px 0; line-height: 1.5; }
.ng-season { font-size: 1.02rem; color: #7a3d14; }

/* 1년 결산 */
.ng-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ng-card { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: #fff8e8; border: 3px solid var(--ng-wood); box-shadow: 3px 3px 0 rgba(74, 44, 22, .2); }
.ng-card b { font-size: 1.25rem; color: var(--ng-woodD); }
.ng-card small { color: var(--ng-ink2); }
.ng-scene { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 10px; min-height: 200px; border: 4px solid var(--ng-woodDD); color: #fff4d6; overflow: hidden; }
.ng-scene.ending-feast { background: linear-gradient(#1d2448, #4a3a6a 70%, #8a5a32 70%); }
.ng-scene.ending-feast::before { content: ''; position: absolute; inset: 0 0 auto; height: 24px; background: repeating-linear-gradient(90deg, #e05a47 0 10px, transparent 10px 26px, #f7c948 26px 36px, transparent 36px 52px); opacity: .85; animation: ng-lantern 1.6s ease-in-out infinite alternate; }
@keyframes ng-lantern { to { opacity: .5; } }
.ng-scene.ending-hope { background: linear-gradient(#f2a65a, #f7d79a 65%, #6a8a3a 65%); color: #3b2a1c; }
.ng-scene.ending-quiet { background: linear-gradient(#5a6a80, #a9b8c8 65%, #e8eef2 65%); }
.ng-scene-title { position: relative; font-size: 1.3rem; text-shadow: 2px 2px 0 rgba(0, 0, 0, .35); }
.ng-scene-stalls { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.ng-scene-stalls .ng-ico { width: 48px; height: 48px; }
.ng-scene-people { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.ng-scene-lines { margin-top: 10px; padding: 10px 12px; background: #fffaf0; border: 3px solid var(--ng-woodD); min-height: 80px; }
.ng-scene-lines p { margin: 4px 0; line-height: 1.6; }
.ng-scene-lines p.type { animation: ng-type .6s steps(12) both; }
@keyframes ng-type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* 축제 결과·순위 */
.ng-rank { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; counter-reset: rk; }
.ng-rank li { display: flex; align-items: center; gap: 8px; padding: 4px 10px; background: #fff8e8; border: 2px solid var(--ng-woodL); counter-increment: rk; }
.ng-rank li::before { content: counter(rk) '등'; min-width: 32px; color: var(--ng-woodD); }
.ng-mg .ng-rank li::before { content: ''; min-width: 0; }
.ng-rank li span { flex: 1; }
.ng-rank li.me { border-color: var(--ng-red); background: #fff1cf; }
.ng-rank li.pop { animation: ng-pop .3s ease-out; }

/* ── 미니게임 ── */
.ng-mg {
  position: fixed; inset: 0; z-index: 1100; display: flex; align-items: center; justify-content: center;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  background: rgba(20, 30, 24, .78); color: var(--ng-ink); font-family: inherit;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.ng-mg-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 10px 12px 14px;
  background: var(--ng-hanji); border: 4px solid var(--ng-woodD);
  box-shadow: inset 0 0 0 3px var(--ng-woodL), inset 0 0 0 5px var(--ng-wood), inset 0 0 0 7px var(--ng-woodD);
}
.ng-mg-card { touch-action: none; }
.ng-mg-contest .ng-mg-card { touch-action: pan-y; } /* 출품 고르기 칸 목록은 스크롤 */
.ng-mg-head { width: 100%; padding: 6px 10px; background: var(--ng-wood); color: #fff4d6; text-align: center; font-size: 1.05rem; }
.ng-mg-main { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ng-mg-side { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ng-mg-help { margin: 0; font-size: .86rem; color: var(--ng-ink2); text-align: center; line-height: 1.45; }
.ng-mg-help:empty { display: none; }
.ng-mg-stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ng-mg-msg { min-height: 1.6em; text-align: center; line-height: 1.4; }
.ng-mg-msg.big { font-size: 1.25rem; }
.ng-mg-msg.go { color: var(--ng-green); }
.ng-mg-msg.bad { color: var(--ng-red); }
.ng-mg-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ng-mg-canvas { image-rendering: pixelated; image-rendering: crisp-edges; border: 3px solid var(--ng-woodDD); background: #2b4a3a; }
.ng-mg .ng-grid { width: 100%; }
.ng-judge { display: flex; align-items: center; gap: 10px; width: 100%; }
.ng-judge p { flex: 1; margin: 0; padding: 8px; background: #fff; border: 3px solid var(--ng-woodD); }
.ng-mg .ng-rank { width: 100%; }

/* 씨름 */
.ng-ssi { width: 100%; display: flex; flex-direction: column; gap: 12px; padding: 10px; background: linear-gradient(#f3dca4, #e2c27e); border: 3px solid var(--ng-wood); }
.ng-ssi.push { animation: ng-push .3s; }
.ng-ssi.shake, .ng-seq.shake { animation: ng-shake .3s; }
@keyframes ng-push { 50% { transform: translateX(8px); } }
@keyframes ng-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.ng-ssi-vs { display: flex; align-items: center; justify-content: space-around; }
.ng-ssi-p { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ng-ssi-x { font-size: 1.2rem; color: var(--ng-red); }
.ng-ssi-intro { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px; }
.ng-gauge { position: relative; height: 34px; background: #6b4423; border: 3px solid var(--ng-woodDD); }
.ng-gauge-zone { position: absolute; top: 0; bottom: 0; background: var(--ng-greenL); box-shadow: inset 0 0 0 2px var(--ng-green); }
.ng-gauge-mark { position: absolute; top: -8px; bottom: -8px; width: 6px; margin-left: -3px; background: #fff; border: 2px solid var(--ng-woodDD); }
.ng-ssi-score { text-align: center; }
.ng-pips { display: inline-flex; gap: 4px; vertical-align: middle; }
.ng-pips i { width: 14px; height: 14px; border: 2px solid var(--ng-woodD); background: #e9d6ad; }
.ng-pips.hit i.on { background: var(--ng-green); }
.ng-pips.miss i.on { background: var(--ng-red); }

/* 송편 */
.ng-song { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ng-song .ng-bar { width: 100%; }
.ng-seq { display: flex; gap: 8px; padding: 10px; background: #fff8e8; border: 3px solid var(--ng-woodL); }
.ng-arrow { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; font-size: 1.6rem; background: #e6cf9f; border: 3px solid var(--ng-wood); color: var(--ng-woodD); }
.ng-arrow.cur { background: #fff1c4; border-color: var(--ng-gold); transform: translateY(-3px); }
.ng-arrow.ok { background: var(--ng-greenL); color: #fff; }
.ng-song-tray { display: flex; align-items: center; gap: 6px; }
.ng-count { font-size: 1.2rem; }
.ng-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; min-height: 34px; }
.ng-tray .ng-ico { width: 28px; height: 28px; }
.ng-ico.pop { animation: ng-pop .25s ease-out; }
.ng-dpad { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 56px); gap: 4px; }
.ng-dir { min-width: 64px; min-height: 56px; font-size: 1.4rem; padding: 0; }
.ng-dir.up { grid-column: 2; grid-row: 1; }
.ng-dir.left { grid-column: 1; grid-row: 2; }
.ng-dir.right { grid-column: 3; grid-row: 2; }
.ng-dir.down { grid-column: 2; grid-row: 3; }

/* 김장 */
.ng-kim { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.ng-kim-top { display: flex; align-items: center; justify-content: center; gap: 16px; }
.ng-cabbage { position: relative; width: 96px; height: 96px; }
.ng-cabbage .ng-ico { position: relative; z-index: 1; }
.ng-cabbage-fill { position: absolute; left: 12%; right: 12%; bottom: 8%; height: 0; background: rgba(205, 50, 30, .55); z-index: 2; mix-blend-mode: multiply; transition: height .15s; }
.ng-cabbage.bump { animation: ng-bump .15s; }
@keyframes ng-bump { 50% { transform: scale(1.08); } }
.ng-judgeword { min-height: 1.4em; font-size: 1.05rem; }
.ng-judgeword.go { color: var(--ng-green); }
.ng-judgeword.bad { color: var(--ng-red); }
.ng-lane { position: relative; height: 56px; background: repeating-linear-gradient(90deg, #d9c08a 0 22px, #cfb57e 22px 44px); border: 3px solid var(--ng-woodD); overflow: hidden; }
.ng-lane.mash { background: repeating-linear-gradient(90deg, #f7c948 0 22px, #f0b030 22px 44px); }
.ng-lane-hit { position: absolute; top: 0; bottom: 0; width: 6px; margin-left: -3px; background: var(--ng-red); box-shadow: 0 0 0 3px rgba(200, 85, 61, .3); }
.ng-note { position: absolute; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px; background: #7cc25a; border: 3px solid #2f5e1e; border-radius: 40% 60% 40% 60%; }
.ng-note.done { background: #e05a47; border-color: #7a2414; transform: scale(.6); opacity: .5; }
.ng-note.miss { background: #9a8a6a; opacity: .5; }

/* 장터 간판 */
.ng-ico.emblem { width: 32px; height: 32px; }
.ng-stallpic { position: relative; display: inline-block; width: 64px; height: 64px; flex: none; }
.ng-stallpic .ng-ico.emblem { position: absolute; left: 50%; top: 4px; width: 28px; height: 28px; transform: translateX(-50%); filter: drop-shadow(1px 1px 0 rgba(44, 26, 12, .6)); }
.ng-emblems { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; margin-top: 8px; }
.ng-emblem-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; background: #f1e4c9; border: 3px dashed var(--ng-woodL); font-size: .84rem; text-align: center; }
.ng-emblem-cell small { color: var(--ng-ink2); }
.ng-emblem-cell.done { border-style: solid; border-color: var(--ng-gold); background: #fff3d1; }
.ng-emblem-cell.open { border-style: solid; border-color: var(--ng-green); background: #eff7df; }

/* 지도 */
.ng-map-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.ng-map-where { display: inline-flex; align-items: center; gap: 4px; }
.ng-map-where .dot { width: 10px; height: 10px; background: #ff4a3a; border: 2px solid #fff; box-shadow: 0 0 0 1px #2c1a0c; }
.ng-map-zoom { display: inline-flex; gap: 4px; }
.ng-map-view {
  position: relative; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y;
  height: min(56vh, 520px); height: min(56dvh, 520px); background: #2c3a2a; border: 4px solid var(--ng-woodD);
  box-shadow: inset 0 0 0 2px var(--ng-woodL); cursor: grab;
}
.ng-map-view.grab { cursor: grabbing; }
.ng-map-board { position: relative; margin: 0 auto; }
.ng-map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }
.ng-map-layer { position: absolute; inset: 0; pointer-events: none; }
.ng-map-layer > * { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; }
.ng-map-region, .ng-map-place { z-index: 1; }
.ng-map-region { font-size: .82rem; color: #fff4d6; background: rgba(74, 44, 22, .82); padding: 1px 6px; border: 2px solid var(--ng-woodD); }
.ng-map-place { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; }
.ng-map-place b { font-weight: normal; font-size: .74rem; color: #2c1a0c; background: rgba(255, 248, 230, .9); padding: 0 4px; border: 1px solid var(--ng-woodD); }
.ng-map-place.small b { font-size: .68rem; }
.ng-ico.pin { width: 20px; height: 20px; filter: drop-shadow(1px 1px 0 rgba(0, 0, 0, .5)); }
.ng-map-emblem { display: inline-flex; padding: 1px; background: rgba(255, 248, 230, .55); border: 2px dashed #6b5440; }
.ng-map-emblem.done { border: 2px solid var(--ng-gold); }
.ng-map-emblem.open { border: 2px solid #6cd65a; background: rgba(239, 247, 223, .9); }
.ng-map-npc { display: inline-flex; padding: 1px; background: #fff8e8; border: 2px solid var(--ng-woodD); }
.ng-map-npc.here { border-color: #4f7fb0; }
.ng-ico.face { width: 20px; height: 20px; }
.ng-map-me { width: 14px; height: 14px; z-index: 2; }
.ng-map-me i { position: absolute; inset: 0; background: #ff4a3a; border: 2px solid #fff; box-shadow: 0 0 0 2px #2c1a0c; animation: ng-blink .8s steps(2) infinite; }
.ng-map-me::after { content: ''; position: absolute; inset: -8px; border: 2px solid rgba(255, 74, 58, .7); animation: ng-ping 1.4s ease-out infinite; }
@keyframes ng-blink { 50% { background: #ffe14a; } }
@keyframes ng-ping { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
/* 멀리 볼 때는 작은 장소 이름을 숨겨 겹치지 않게 */
.ng-map-board.zoom-far .ng-map-place.small b { display: none; }
.ng-map-board.zoom-far .ng-map-place b { font-size: .64rem; }
.ng-map-board.zoom-far .ng-ico.pin, .ng-map-board.zoom-far .ng-ico.face { width: 14px; height: 14px; }
.ng-map-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 14px; }
.ng-map-people, .ng-map-hours { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: .86rem; }
.ng-map-people li { display: flex; align-items: center; gap: 6px; padding: 2px 6px; background: #fff8e8; border: 2px solid var(--ng-woodL); }
.ng-map-people li span { margin-left: auto; text-align: right; }
.ng-map-people .ng-ico.face { width: 28px; height: 28px; }
.ng-map-hours li { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 3px 6px; background: #f1e4c9; border: 2px solid var(--ng-woodL); }
.ng-map-hours li small { color: var(--ng-ink2); }
.ng-map-hours li.open { background: #eff7df; border-color: var(--ng-greenL); }
.ng-map-hours li.open small { color: var(--ng-green); }
@media (max-height: 500px) {
  .ng-map-view { height: calc(100vh - 200px); height: calc(100dvh - 200px); min-height: 160px; }
}

/* 낮은 가로 화면(폰 가로): 무대 | 안내·조작 좌우 배치 (minigames/common.js의 LOW와 같은 조건) */
@media (max-height: 500px) {
  .ng-mg { padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .ng-mg-card { width: min(900px, 100%); padding: 6px 10px 8px; gap: 4px; }
  .ng-mg-head { padding: 3px 10px; font-size: .95rem; }
  .ng-mg-main { flex-direction: row; align-items: center; gap: 12px; }
  .ng-mg-stage { flex: 1 1 0; min-width: 0; }
  .ng-mg-side { flex: 0 1 40%; }
  .ng-mg-msg.big { font-size: 1.05rem; }
  .ng-ssi { gap: 6px; padding: 6px; }
  .ng-ssi .ng-ico.chr { width: 32px; height: 64px; }
  .ng-ssi .ng-ico.portrait { width: 48px; height: 48px; }
  .ng-dpad { grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 48px); }
  .ng-dir { min-width: 56px; min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .ng-layer, .ng-panel, .ng-anim, .ng-slot.want, .ng-lvup, .ng-confetti i, .ng-scene-lines p.type, .ng-wx.bob { animation: none !important; transition: none !important; }
}

.ng-wx.bob { animation: ng-bob 1s steps(2) infinite; }
@keyframes ng-bob { 50% { transform: translateY(-3px); } }
