/* base.css — palette, layout layers and the shared UI pieces (panel, buttons, bars, toasts, dialogs). */
:root {
  --moss: #5e7d3a; --moss-d: #2f4420; --cream: #fbf3dd; --parch: #f3e6c4; --ochre: #c98a3a;
  --berry: #b8455a; --ink: #3b2a1a; --gold: #f2c14e; --sky: #8fd0f0;
  --font: "Trebuchet MS", sans-serif;
  --outline: 0 2px 0 #3b2a1a, 2px 0 0 #3b2a1a, -2px 0 0 #3b2a1a, 0 -2px 0 #3b2a1a, 1.5px 1.5px 0 #3b2a1a, -1.5px 1.5px 0 #3b2a1a, 1.5px -1.5px 0 #3b2a1a, -1.5px -1.5px 0 #3b2a1a, 0 4px 0 rgba(40,25,10,.55);
  --soft: 0 1px 0 rgba(255,255,255,.6);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d2414; touch-action: none; user-select: none; -webkit-user-select: none; }
body { font-family: var(--font); color: var(--ink); }
#stage { position: fixed; inset: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#labels, #hud, #panelHost, #toastHost { position: absolute; inset: 0; pointer-events: none; }
#hud > *, #panelHost > *, #labels > * { pointer-events: auto; }
#labels > .nolabel { pointer-events: none; }
#fade { position: absolute; inset: 0; background: #1d2414; opacity: 0; pointer-events: none; transition: opacity .35s ease; z-index: 50; }
#fade.on { opacity: 1; pointer-events: auto; }
.screen { position: absolute; inset: 0; z-index: 30; }
.hidden { display: none !important; }

/* outlined display text */
.otext { color: var(--cream); font-weight: 900; text-shadow: var(--outline); letter-spacing: .02em; }

/* ---- panel (9-slice wood frame) ---- */
.panel {
  position: absolute; pointer-events: auto; z-index: 20;
  border: 22px solid transparent; border-image: url(../assets/ui-panel.webp) 16% fill / 22px stretch;
  filter: drop-shadow(0 8px 14px rgba(20,15,5,.45));
  transform: scale(.85); opacity: 0; transition: transform .24s cubic-bezier(.3,1.6,.5,1), opacity .18s;
  max-height: calc(100% - 84px); display: flex; flex-direction: column;
}
.panel.in { transform: scale(1); opacity: 1; }
.panel.out { transform: scale(.9); opacity: 0; transition: transform .18s, opacity .18s; }
.panel.side-center { left: 50%; top: 50%; translate: -50% -46%; width: min(640px, 86vw); }
.panel.side-center.wide { width: min(880px, 92vw); }
.panel.side-right { right: 12px; top: 72px; width: min(420px, 46vw); max-height: calc(100% - 84px); }
.panel.side-left { left: 12px; top: 72px; width: min(420px, 46vw); }
.ptitle { font-weight: 900; font-size: 22px; text-align: center; color: var(--cream); text-shadow: var(--outline); margin: -4px 40px 6px; }
.pbody { overflow-y: auto; overflow-x: hidden; padding: 4px 6px 6px; flex: 1; min-height: 0; scrollbar-width: none; }
.pbody::-webkit-scrollbar { display: none; }
.pclose { position: absolute; top: -10px; right: -10px; width: 44px; height: 44px; border-radius: 12px; border: 3px solid #7a5428;
  background: var(--berry); color: var(--cream); font-size: 20px; font-weight: 900; cursor: pointer; box-shadow: 0 3px 0 #5a2a2a; }
.pclose.focus { outline: 3px solid var(--gold); }

/* ---- buttons (9-slice felt plate) ---- */
.btn {
  min-height: 48px; min-width: 48px; padding: 6px 16px; cursor: pointer; font-family: inherit;
  border: 12px solid transparent; border-image: url(../assets/ui-button.webp) 30% fill / 12px stretch;
  background: none; color: var(--cream); font-weight: 900; font-size: 17px; text-shadow: var(--outline);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; line-height: 1.1;
  transition: transform .12s, filter .12s;
}
.btn .ico { width: 28px; height: 28px; object-fit: contain; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.btn.small { min-height: 44px; font-size: 15px; padding: 2px 10px; }
.btn.primary { filter: hue-rotate(-55deg) saturate(1.4) brightness(1.08); }
.btn:hover, .btn.focus { transform: scale(1.06); filter: brightness(1.15); }
.btn.primary:hover, .btn.primary.focus { filter: hue-rotate(-55deg) saturate(1.4) brightness(1.25); }
.btn.disabled { filter: grayscale(.85) brightness(.85); opacity: .7; cursor: default; }
.btn.press, .ibtn.press { animation: press .22s; }
@keyframes press { 40% { transform: scale(.9, .86); } 100% { transform: scale(1); } }

/* small square icon plate (nav, corner buttons) */
.ibtn { width: 52px; height: 52px; padding: 0; border: none; cursor: pointer; position: relative;
  background: url(../assets/ui-pause.webp) center/100% 100% no-repeat; font-family: inherit; transition: transform .12s, filter .12s; }
.ibtn::before { content: ""; position: absolute; inset: 7px; border-radius: 8px; background: #5e7d3a; }
.ibtn img { position: relative; width: 38px; height: 38px; margin-top: 2px; object-fit: contain; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.ibtn .ilab { position: absolute; left: 50%; top: 100%; translate: -50% 1px; white-space: nowrap; font-size: 12px; font-weight: 900; color: var(--cream); text-shadow: var(--outline); }
.ibtn:hover, .ibtn.focus { transform: scale(1.08); filter: brightness(1.15); }
.ibtn.active::before { background: #c98a3a; }

/* icons, rows, bars */
.icon { object-fit: contain; vertical-align: middle; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.bar { position: relative; height: 14px; border-radius: 8px; background: #6b5432; box-shadow: inset 0 2px 0 rgba(0,0,0,.3); overflow: hidden; flex: 1; min-width: 60px; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#a6d46a, #6c9a3a); border-radius: 8px; transition: width .3s; }
.bar.low > i { background: linear-gradient(#f08a6a, #c0443a); }
.bar.xp > i { background: linear-gradient(#ffe08a, #e0a83a); }
.bar.hp > i { background: linear-gradient(#ff9fb0, #d65a78); }

/* toasts, banner, dialog */
#toastHost { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 74px; z-index: 40; }
.toast { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 14px; background: rgba(47,68,32,.92);
  border: 3px solid #c9a35a; color: var(--cream); font-weight: 900; font-size: 16px; text-shadow: 0 2px 0 #1d2414;
  animation: toastIn .3s cubic-bezier(.3,1.6,.5,1); max-width: 80vw; }
.toast img { width: 30px; height: 30px; object-fit: contain; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: .3s; }
@keyframes toastIn { from { transform: scale(.6); opacity: 0; } }
.banner { position: absolute; left: 50%; top: 38%; translate: -50% -50%; z-index: 45; pointer-events: none;
  font-size: clamp(28px, 6vw, 56px); font-weight: 900; color: #fff4c8; text-shadow: var(--outline), 0 0 24px rgba(255,220,120,.8);
  animation: slam .45s cubic-bezier(.3,1.8,.5,1); white-space: nowrap; }
.banner.out { opacity: 0; transition: .4s; }
@keyframes slam { from { transform: scale(2.2); opacity: 0; } }
.dialogWrap { position: absolute; inset: 0; z-index: 48; background: rgba(20,15,5,.45); }
.panel.dialog { left: 50%; top: 50%; translate: -50% -50%; width: min(440px, 86vw); }
.dtext { font-size: 18px; font-weight: 700; text-align: center; margin: 6px 4px 14px; color: var(--ink); }
