/* Fairy-tale wood & cream RPG interface. Kept compact so the world stays visible. */
.wood-box {
  background: var(--cream); border: 2px solid var(--ink); border-radius: 8px;
  box-shadow: inset 0 0 0 2px var(--wood), inset 0 -3px 0 2px #d9bf8c, 0 2px 0 rgba(0,0,0,.35);
}
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }

/* ---- top left status */
#hud-tl { position: absolute; left: calc(6px + var(--sal)); top: calc(6px + var(--sat)); display: flex; gap: 6px; padding: 5px 8px 5px 5px; align-items: center; }
#hud-portrait { width: 40px; height: 40px; border-radius: 6px; background: #c9e2a4; border: 2px solid var(--ink); }
.hud-stats { display: flex; flex-direction: column; gap: 3px; min-width: 96px; }
.hud-name { font-weight: 800; font-size: 13px; display: flex; gap: 6px; align-items: baseline; white-space: nowrap; max-width: 130px; overflow: hidden; }
.lv { font-size: 11px; color: #fff; background: var(--green-d); border-radius: 4px; padding: 0 4px; }
.bar { position: relative; }
.bar.xp { height: 5px; background: #c8b38a; border-radius: 3px; overflow: hidden; border: 1px solid var(--ink-soft); }
.bar.xp i { display: block; height: 100%; background: #6cb6e8; width: 0; }
.bar.energy { display: flex; align-items: center; gap: 3px; }
.bar.energy img { width: 16px; height: 16px; }
.bar.energy .track { flex: 1; height: 9px; background: #4a3326; border: 1px solid var(--ink); border-radius: 3px; overflow: hidden; }
.bar.energy i { display: block; height: 100%; background: linear-gradient(#8fe07a, #4ca83a); width: 100%; }
.bar.energy i.low { background: linear-gradient(#f0a060, #d05a2a); }
#hud-energy-t { font-size: 11px; font-weight: 700; min-width: 28px; text-align: right; }

/* ---- top centre */
#hud-tc { position: absolute; left: 50%; transform: translateX(-50%); top: calc(6px + var(--sat)); padding: 4px 10px; font-weight: 800; font-size: 13px; display: flex; flex-direction: column; gap: 1px; align-items: center; min-width: 128px; }
#hud-tc .row { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
#hud-tc img { width: 16px; height: 16px; }
.gold { display: inline-flex; align-items: center; gap: 2px; color: #8a5a10; }

/* ---- top right */
#hud-tr { position: absolute; right: calc(6px + var(--sar)); top: calc(6px + var(--sat)); display: grid; grid-template-columns: repeat(2, 38px); gap: 4px; }
.hud-btn { position: relative; width: 38px; height: 38px; padding: 0; border: 2px solid var(--ink); border-radius: 8px; background: var(--cream); box-shadow: inset 0 -3px 0 #d9bf8c, 0 2px 0 rgba(0,0,0,.35); display: grid; place-items: center; }
.hud-btn img { width: 24px; height: 24px; }
.hud-btn:active { transform: translateY(1px); }
.hud-btn.soon { opacity: .55; }
.hud-btn .dot { position: absolute; right: -3px; top: -3px; width: 10px; height: 10px; background: var(--red); border: 2px solid var(--ink); border-radius: 50%; }
#quest-track { position: absolute; left: calc(6px + var(--sal)); top: calc(66px + var(--sat)); max-width: min(62vw, 300px); background: rgba(42,28,22,.78); color: var(--cream); font-size: 12px; padding: 4px 8px; border-radius: 6px; line-height: 1.35; pointer-events: auto; }
#quest-track b { color: #ffe08a; }
#save-ind { position: absolute; right: calc(8px + var(--sar)); top: calc(92px + var(--sat)); font-size: 11px; color: var(--cream); background: rgba(42,28,22,.7); padding: 2px 6px; border-radius: 4px; display: flex; gap: 3px; align-items: center; }
#save-ind img { width: 12px; height: 12px; }

/* ---- bottom controls (portrait first) */
#hotbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(6px + var(--sab)); display: flex; align-items: center; gap: 2px; padding: 3px; }
#hb-slots { display: flex; gap: 2px; }
.hb-arrow { width: 26px; height: var(--slot); border: 0; background: none; padding: 0; display: grid; place-items: center; }
.hb-arrow img { width: 16px; height: 16px; }
#hb-row { position: absolute; right: 2px; top: -14px; font-size: 10px; background: var(--ink); color: var(--cream); border-radius: 4px; padding: 0 4px; }
.slot { position: relative; width: var(--slot); height: var(--slot); background: #e6cf9f; border: 2px solid var(--wood-d); border-radius: 6px; display: grid; place-items: center; box-shadow: inset 0 2px 0 rgba(0,0,0,.12); touch-action: none; }
.slot img.icon { width: 32px; height: 32px; pointer-events: none; }
.slot .qty { position: absolute; right: 2px; bottom: 0; font-size: 11px; font-weight: 900; color: #fff; text-shadow: 1px 0 0 var(--ink), -1px 0 0 var(--ink), 0 1px 0 var(--ink), 0 -1px 0 var(--ink); pointer-events: none; }
.slot .star { position: absolute; left: 0; bottom: 0; width: 16px; height: 16px; pointer-events: none; }
.slot .key { position: absolute; left: 3px; top: 0; font-size: 9px; color: var(--ink-soft); pointer-events: none; }
.slot.sel { border-color: #d33; box-shadow: 0 0 0 2px #ffd34a, inset 0 2px 0 rgba(0,0,0,.12); background: #fff2c8; }
.slot.picked { border-color: #2f7ad3; box-shadow: 0 0 0 2px #8cc4ff; }
.slot.dim { opacity: .35; }
.slot.hotrow { background: #eadbb2; }
.slot .meter { position: absolute; left: 4px; right: 4px; bottom: 2px; height: 3px; background: #3a2418; border-radius: 2px; overflow: hidden; pointer-events: none; }
.slot .meter i { display: block; height: 100%; background: #6cb6e8; }

#joy-zone { position: absolute; left: 0; bottom: calc(var(--slot) + 22px + var(--sab)); width: 55vw; height: 42vh; touch-action: none; }
#joy-base { position: absolute; left: 70px; top: calc(100% - 70px); width: 104px; height: 104px; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(250,240,215,.16); border: 3px solid rgba(58,36,24,.35); opacity: .45; transition: opacity .15s; pointer-events: none; }
#joy-base.active { opacity: .95; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; border-radius: 50%; background: rgba(247,233,201,.85); border: 3px solid rgba(58,36,24,.7); transform: translate(-50%, -50%); }
@media (hover: hover) and (pointer: fine) { #joy-base:not(.active) { opacity: .0; } }

#act-btn { position: absolute; right: calc(14px + var(--sar)); bottom: calc(var(--slot) + 30px + var(--sab)); width: 78px; height: 78px; border-radius: 50%; border: 3px solid var(--ink); background: radial-gradient(circle at 40% 35%, #ffe9a0, #f0b840 60%, #c88420); box-shadow: inset 0 -4px 0 rgba(0,0,0,.2), 0 3px 0 rgba(0,0,0,.4); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 0; touch-action: none; }
#act-btn.down { transform: translateY(2px) scale(.97); }
#act-btn.idle { opacity: .55; filter: saturate(.4); }
#act-icon img { width: 32px; height: 32px; display: block; }
#act-label { font-weight: 900; font-size: 13px; line-height: 1.1; text-align: center; max-width: 70px; }
#water-gauge { position: absolute; right: calc(98px + var(--sar)); bottom: calc(var(--slot) + 34px + var(--sab)); width: 8px; height: 60px; background: #3a2418; border: 2px solid var(--ink); border-radius: 4px; display: flex; align-items: flex-end; overflow: hidden; }
#water-gauge i { display: block; width: 100%; background: #6cb6e8; }

/* landscape / desktop: everything on one baseline */
@media (min-aspect-ratio: 5/4) {
  #joy-zone { bottom: 0; height: 55vh; width: 40vw; }
  #joy-base { left: 90px; top: calc(100% - 90px); }
  #act-btn { bottom: calc(14px + var(--sab)); right: calc(18px + var(--sar)); }
  #water-gauge { bottom: calc(18px + var(--sab)); right: calc(104px + var(--sar)); }
  #quest-track { top: calc(64px + var(--sat)); }
}

/* ---- toasts */
#toasts { position: absolute; left: 50%; top: calc(62px + var(--sat)); transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 4px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { background: rgba(42,28,22,.9); color: var(--cream); padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; border: 2px solid #6e4426; animation: toastIn .18s ease-out; text-align: center; }
.toast.good { border-color: #6cbf4a; } .toast.warn { border-color: #e08a3a; } .toast.info { border-color: #6cb6e8; }
@keyframes toastIn { from { transform: translateY(-6px); opacity: 0; } }

/* ---- dialogue */
#dialog { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--slot) + 24px + var(--sab)); width: min(96vw, 640px); z-index: 30; display: flex; gap: 8px; padding: 8px; background: var(--cream); border: 3px solid var(--ink); border-radius: 10px; box-shadow: inset 0 0 0 3px var(--wood), 0 4px 0 rgba(0,0,0,.4); }
#dlg-portrait { flex: none; width: 96px; height: 96px; background: #c9e2a4; border: 2px solid var(--ink); border-radius: 6px; display: grid; place-items: center; overflow: hidden; }
#dlg-portrait:empty { display: none; }
#dlg-portrait canvas { width: 96px; height: 96px; }
#dlg-body { flex: 1; min-height: 84px; position: relative; display: flex; flex-direction: column; gap: 6px; }
#dlg-name { align-self: flex-start; background: var(--wood); color: #fff; font-weight: 800; padding: 1px 10px; border-radius: 4px; border: 2px solid var(--ink); font-size: 13px; }
#dlg-text { font-size: 15px; line-height: 1.5; font-weight: 600; white-space: pre-wrap; min-height: 44px; }
#dlg-choices { display: flex; flex-wrap: wrap; gap: 6px; }
#dlg-next { position: absolute; right: 2px; bottom: -4px; font-size: 12px; color: var(--wood-d); animation: bob 0.8s infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }

/* ---- generic buttons */
.btn { border: 2px solid var(--ink); border-radius: 7px; background: #fff4d6; padding: 7px 12px; font-weight: 800; font-size: 14px; box-shadow: inset 0 -3px 0 #d9bf8c, 0 2px 0 rgba(0,0,0,.3); min-height: 40px; cursor: pointer; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: #9ad06a; box-shadow: inset 0 -3px 0 #5c9a3e, 0 2px 0 rgba(0,0,0,.3); }
.btn.danger { background: #f2a28e; box-shadow: inset 0 -3px 0 #c4432f, 0 2px 0 rgba(0,0,0,.3); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.small { min-height: 32px; padding: 3px 9px; font-size: 13px; }
.chip { border: 2px solid var(--wood-d); border-radius: 999px; padding: 3px 10px; background: #fff4d6; font-weight: 700; font-size: 12px; }
.chip.on { background: var(--wood); color: #fff; }
.soon-tag { font-size: 11px; background: #8a7a6a; color: #fff; border-radius: 4px; padding: 0 5px; margin-left: 4px; }

/* ---- panels */
#panel-layer, #modal-layer { position: absolute; inset: 0; z-index: 35; pointer-events: none; }
#modal-layer { z-index: 50; }
.veil { position: absolute; inset: 0; background: rgba(20,12,8,.45); pointer-events: auto; display: flex; align-items: center; justify-content: center; padding: calc(8px + var(--sat)) calc(8px + var(--sar)) calc(8px + var(--sab)) calc(8px + var(--sal)); }
.panel { position: relative; width: min(96vw, 560px); max-height: 100%; display: flex; flex-direction: column; background: var(--cream); border: 3px solid var(--ink); border-radius: 12px; box-shadow: inset 0 0 0 3px var(--wood), 0 6px 0 rgba(0,0,0,.45); overflow: hidden; }
.panel.wide { width: min(98vw, 760px); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 6px; border-bottom: 2px dashed #c9a878; }
.panel-head h2 { margin: 0; font-size: 17px; flex: 1; }
.panel-close { width: 36px; height: 36px; border: 2px solid var(--ink); border-radius: 8px; background: #fff4d6; display: grid; place-items: center; padding: 0; }
.panel-close img { width: 20px; height: 20px; }
.panel-body { padding: 10px; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.tabs { display: flex; gap: 4px; padding: 6px 8px 0; flex-wrap: wrap; }
.tab { border: 2px solid var(--ink); border-bottom: 0; border-radius: 8px 8px 0 0; padding: 5px 10px; background: var(--cream2); font-weight: 800; font-size: 13px; display: flex; gap: 4px; align-items: center; }
.tab img { width: 16px; height: 16px; }
.tab.on { background: #fff4d6; }
.grid { display: grid; grid-template-columns: repeat(8, var(--slot)); gap: 3px; justify-content: center; }
.grid .rowgap { grid-column: 1 / -1; height: 2px; }
.detail { margin-top: 10px; background: #fff4d6; border: 2px solid var(--wood-d); border-radius: 8px; padding: 8px; display: flex; gap: 8px; min-height: 64px; }
.detail img { width: 48px; height: 48px; flex: none; }
.detail .d-name { font-weight: 900; }
.detail .d-desc { font-size: 13px; color: var(--ink-soft); margin: 2px 0 6px; }
.detail .d-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.filters { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; align-items: center; }
.filters .grow { flex: 1; }
.hint { font-size: 12px; color: var(--ink-soft); margin: 6px 2px; }
.ghost { position: fixed; z-index: 99; width: 40px; height: 40px; pointer-events: none; transform: translate(-50%, -60%); }

.list { display: flex; flex-direction: column; gap: 6px; }
.row-item { display: flex; align-items: center; gap: 8px; background: #fff4d6; border: 2px solid var(--wood-d); border-radius: 8px; padding: 6px 8px; }
.row-item img.icon { width: 32px; height: 32px; flex: none; }
.row-item .grow { flex: 1; min-width: 0; }
.row-item .t { font-weight: 800; }
.row-item .s { font-size: 12px; color: var(--ink-soft); }
.row-item.locked { opacity: .55; }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper button { width: 30px; height: 30px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; font-weight: 900; padding: 0; }
.stepper span { min-width: 26px; text-align: center; font-weight: 800; }
.price { font-weight: 900; color: #8a5a10; display: inline-flex; gap: 2px; align-items: center; white-space: nowrap; }
.price img { width: 14px; height: 14px; }

.shop-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.shop-head canvas { width: 72px; height: 72px; border: 2px solid var(--ink); border-radius: 6px; background: #c9e2a4; flex: none; }
.bubble { background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: 6px 8px; font-size: 13px; font-weight: 600; flex: 1; }

table.report { width: 100%; border-collapse: collapse; font-size: 13px; }
table.report td, table.report th { padding: 4px 3px; border-bottom: 1px dashed #c9a878; text-align: right; }
table.report td:first-child, table.report th:first-child { text-align: left; }
table.report img { width: 20px; height: 20px; vertical-align: middle; margin-right: 3px; }
.total { font-size: 18px; font-weight: 900; text-align: right; margin-top: 8px; color: #8a5a10; }

.form-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.form-row label { width: 86px; font-weight: 800; font-size: 13px; flex: none; }
.form-row input[type=text] { flex: 1; min-width: 0; font-size: 16px; padding: 7px 9px; border: 2px solid var(--ink); border-radius: 7px; background: #fff; }
.form-row input[type=range] { flex: 1; }
.picker { flex: 1; display: flex; align-items: center; gap: 4px; }
.picker button { width: 34px; height: 34px; border: 2px solid var(--ink); border-radius: 7px; background: #fff4d6; padding: 0; display: grid; place-items: center; }
.picker button img { width: 16px; height: 16px; }
.picker span { flex: 1; text-align: center; font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; border: 2px solid var(--ink); display: inline-block; }

.skill-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed #c9a878; }
.skill-row .name { width: 60px; font-weight: 800; }
.skill-row .pips { display: flex; gap: 2px; flex: 1; }
.skill-row .pips i { width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 3px; background: #e6cf9f; }
.skill-row .pips i.on { background: var(--green); }

/* ---- title & creation screens */
#screen-layer { position: absolute; inset: 0; z-index: 45; pointer-events: none; }
.screen { position: absolute; inset: 0; pointer-events: auto; display: flex; align-items: center; justify-content: center; overflow: auto; touch-action: pan-y; padding: calc(10px + var(--sat)) 10px calc(10px + var(--sab)); }
.screen canvas.bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.title-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 20px; width: min(92vw, 380px); }
.logo { font-size: 30px; font-weight: 900; letter-spacing: 1px; color: #ffe9a8; text-shadow: 0 3px 0 #6e4426, 3px 0 0 #6e4426, -3px 0 0 #6e4426, 0 -3px 0 #6e4426, 0 6px 0 rgba(0,0,0,.35); text-align: center; line-height: 1.1; }
.logo small { display: block; font-size: 13px; letter-spacing: 3px; color: #fff; text-shadow: 0 2px 0 #3a2418; margin-top: 6px; }
.title-box .btn { width: 100%; }
.ver { font-size: 11px; color: #fff; opacity: .8; text-shadow: 0 1px 0 #000; }
.save-sum { font-size: 12px; color: var(--ink-soft); text-align: center; }
.create { width: 100%; display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.create .preview { flex: none; width: 150px; display: flex; flex-direction: column; gap: 6px; align-items: center; margin: 0 auto; }
.create .preview canvas { width: 128px; height: 192px; background: #9ccc64; border: 3px solid var(--ink); border-radius: 8px; }
.create .opts { flex: 1; min-width: 250px; }

.day-card { position: absolute; inset: 0; z-index: 61; display: flex; align-items: center; justify-content: center; color: var(--cream); font-size: 24px; font-weight: 900; text-align: center; pointer-events: none; text-shadow: 0 3px 0 #000; }
.day-card small { display: block; font-size: 14px; opacity: .85; margin-top: 6px; }

/* ---- dev */
#dev-btn { position: absolute; left: calc(6px + var(--sal)); bottom: calc(50% - 20px); z-index: 20; background: #432; color: #ffd; border: 2px solid #ffd; border-radius: 6px; font-size: 11px; padding: 4px 6px; pointer-events: auto; }
#fps { position: absolute; left: 50%; top: calc(56px + var(--sat)); transform: translateX(-50%); color: #0f0; background: rgba(0,0,0,.6); font: 11px monospace; padding: 1px 4px; z-index: 20; pointer-events: none; }
.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
pre.json { font-size: 10px; max-height: 50vh; overflow: auto; background: #222; color: #cfc; padding: 6px; border-radius: 6px; white-space: pre-wrap; word-break: break-all; -webkit-user-select: text; user-select: text; }

@media (max-width: 380px) {
  #hud-tl .hud-stats { min-width: 78px; }
  .hud-name { max-width: 90px; font-size: 12px; }
  #hud-tc { font-size: 12px; min-width: 110px; padding: 3px 6px; }
  #hud-tr { grid-template-columns: repeat(2, 34px); }
  .hud-btn { width: 34px; height: 34px; }
  #hud-portrait { width: 34px; height: 34px; }
}

/* narrow portrait phones: date/gold box moves under the status box */
@media (max-width: 560px) {
  #hud-tc { left: calc(6px + var(--sal)); transform: none; top: calc(60px + var(--sat)); flex-direction: row; gap: 8px; min-width: 0; padding: 3px 8px; }
  #quest-track { top: calc(92px + var(--sat)); }
  #toasts { top: calc(124px + var(--sat)); }
}
.price img.icon, .price img { width: 14px; height: 14px; }
.shop-row { flex-wrap: wrap; }
.shop-row .grow { min-width: 140px; }
.shop-row .ctrl { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* 캐릭터 선택 카드 (v0.4.0) */
.preset-cards { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 4px 0 6px; }
.preset-card { padding: 4px 6px; background: #f6e7c8; border: 2px solid #c9a978; border-radius: 6px; cursor: pointer; line-height: 0; }
.preset-card.on { border-color: #5c9a3a; background: #e3f2cf; box-shadow: 0 0 0 2px #9ccc64; }
.preset-name { flex: 1; text-align: center; font-weight: bold; }
