/* Harvest Grove — UI theme. Cream panels, wood accents, chunky kid-friendly buttons.
   Palette mirrors js/config.js design tokens. */

:root {
  --cream: #fdf6e3;
  --cream-dark: #f2e6c8;
  --wood: #996b3d;
  --wood-dark: #6e4a26;
  --ink: #4a3520;            /* warm dark text, never pure black */
  --green: #7ab84f;
  --green-dark: #5a9439;
  --gold: #ffd23e;
  --outline: #4a3222;
  --danger: #d9534f;
  --shadow: rgba(74, 50, 34, .25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden;
  font-family: "Comic Sans MS", "Chalkboard SE", "Segoe Print", sans-serif;
  background: #87c7e0;
}

#game-root { position: fixed; inset: 0; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#game-canvas.dragging { cursor: grabbing; }

/* ---------- Top HUD ---------- */
#hud-top {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
}
#hud-top > * { pointer-events: auto; }
.hud-spacer { flex: 1; }

.hud-chip {
  background: var(--cream);
  border: 3px solid var(--outline);
  border-radius: 14px;
  padding: 6px 12px;
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: bold; color: var(--ink);
  box-shadow: 0 3px 0 var(--shadow);
}
.coin-icon {
  width: 20px; height: 20px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe98a, var(--gold) 60%, #d9a520);
  border: 2px solid #b8860b; display: inline-block;
}

#chip-level { gap: 6px; font-size: 15px; }
.xp-bar {
  width: 90px; height: 12px; border-radius: 6px;
  background: var(--cream-dark); border: 2px solid var(--outline); overflow: hidden;
}
#xp-fill { height: 100%; width: 0%; background: linear-gradient(#9fd86a, var(--green)); transition: width .3s; }
#xp-label { font-size: 11px; color: #7c6647; min-width: 52px; }

.hud-btn {
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--cream);
  border: 3px solid var(--outline);
  font-size: 22px; cursor: pointer;
  box-shadow: 0 3px 0 var(--shadow);
  transition: transform .08s;
}
.hud-btn:hover { transform: translateY(-1px); }
.hud-btn:active { transform: translateY(2px); box-shadow: none; }
.hud-btn.active { background: var(--gold); }

/* ---------- Tool dock ---------- */
#tool-dock {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; align-items: flex-end;
  background: var(--cream);
  border: 4px solid var(--outline); border-radius: 18px;
  padding: 8px 10px;
  box-shadow: 0 5px 0 var(--shadow), 0 12px 24px rgba(0,0,0,.18);
  max-width: calc(100vw - 20px);
  overflow-x: auto;
}
.tool-btn {
  min-width: 58px; padding: 6px 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border-radius: 12px; border: 3px solid transparent;
  background: transparent; cursor: pointer; color: var(--ink);
  font-family: inherit; font-size: 11px; font-weight: bold;
}
.tool-btn .ticon { font-size: 24px; line-height: 1; filter: drop-shadow(0 2px 0 var(--shadow)); }
.tool-btn:hover { background: var(--cream-dark); }
.tool-btn.selected { border-color: var(--outline); background: #fff3c2; box-shadow: 0 2px 0 var(--shadow) inset; }
.tool-sep { width: 3px; height: 44px; background: var(--cream-dark); border-radius: 2px; margin: 0 2px; }

/* ---------- Panels ---------- */
.panel {
  position: absolute; top: 70px; right: 10px; bottom: 84px;
  width: 320px; max-width: calc(100vw - 20px);
  background: var(--cream);
  border: 4px solid var(--outline); border-radius: 16px;
  box-shadow: 0 6px 0 var(--shadow), 0 16px 32px rgba(0,0,0,.22);
  display: flex; flex-direction: column;
  animation: pop-in .18s ease-out;
  z-index: 30;
}
@keyframes pop-in { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.hidden { display: none !important; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 3px dashed var(--cream-dark);
}
.panel-head h2 { margin: 0; font-size: 19px; color: var(--ink); }
.panel-close {
  border: 2px solid var(--outline); background: var(--cream-dark); color: var(--ink);
  width: 30px; height: 30px; border-radius: 9px; cursor: pointer; font-size: 14px; font-weight: bold;
}
.panel-body { flex: 1; overflow-y: auto; padding: 10px 12px 14px; }

.shop-cat { margin: 10px 0 4px; font-size: 14px; color: var(--wood-dark); text-transform: uppercase; letter-spacing: .06em; }
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shop-item {
  border: 3px solid var(--outline); border-radius: 12px;
  background: #fffaf0; padding: 8px; text-align: center;
  cursor: pointer; position: relative;
  transition: transform .08s;
}
.shop-item:hover:not(.locked) { transform: translateY(-2px); background: #fff; }
.shop-item.locked { opacity: .45; cursor: not-allowed; }
.shop-item .s-emoji { font-size: 30px; line-height: 1.15; }
.shop-item .s-name { font-size: 12px; font-weight: bold; color: var(--ink); margin: 2px 0; }
.shop-item .s-price { font-size: 12px; color: #8a6a1f; font-weight: bold; }
.shop-item .s-sub { font-size: 10px; color: #93825f; }
.lock-tag { position: absolute; top: 4px; right: 4px; font-size: 10px; background: var(--outline); color: var(--cream); padding: 2px 6px; border-radius: 8px; }

/* inspect panel */
.insp-title { font-size: 17px; font-weight: bold; color: var(--ink); }
.insp-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink); padding: 3px 0; }
.insp-row .k { color: #8a7550; }
.readybar { height: 14px; border: 2px solid var(--outline); border-radius: 8px; overflow: hidden; background: var(--cream-dark); margin: 6px 0; }
.readyfill { height: 100%; background: linear-gradient(90deg, #bfe08a, var(--green)); transition: width .4s; }
.insp-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.act-btn {
  border: 3px solid var(--outline); border-radius: 11px;
  padding: 8px; font-family: inherit; font-size: 13px; font-weight: bold;
  cursor: pointer; color: var(--ink); background: var(--cream-dark);
  box-shadow: 0 2px 0 var(--shadow);
}
.act-btn.primary { background: var(--green); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.act-btn.gold { background: var(--gold); }
.act-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.factlet { font-size: 11.5px; color: #7c6647; background: #f7efd8; border-radius: 8px; padding: 6px 8px; margin-top: 8px; line-height: 1.35; }

/* journal */
.j-entry { border: 2px solid var(--outline); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; background: #fffaf0; }
.j-entry h3 { margin: 0 0 2px; font-size: 14px; color: var(--ink); }
.j-entry p { margin: 0; font-size: 11.5px; color: #6f5c40; line-height: 1.4; }
.j-progress { font-size: 11px; color: #93825f; margin: 2px 0 6px; }

/* help */
.help-step { display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-start; }
.help-step .h-ico { font-size: 24px; }
.help-step p { margin: 0; font-size: 13px; color: var(--ink); line-height: 1.4; }

/* ---------- toasts ---------- */
#toast-area {
  position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; align-items: center; gap: 6px;
  pointer-events: none; z-index: 40;
}
.toast {
  background: var(--cream); border: 3px solid var(--outline); border-radius: 12px;
  padding: 6px 14px; font-size: 14px; font-weight: bold; color: var(--ink);
  box-shadow: 0 3px 0 var(--shadow);
  animation: toast-in .2s ease-out, toast-out .4s ease-in 2.2s forwards;
}
.toast.reward { background: #fff3c2; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(-8px); opacity: 0; } }

/* ---------- fact card ---------- */
#fact-card {
  position: absolute; inset: 0; z-index: 60;
  background: rgba(74, 50, 34, .35);
  display: flex; align-items: center; justify-content: center;
}
.fact-inner {
  width: min(420px, 86vw);
  background: var(--cream); border: 4px solid var(--outline); border-radius: 18px;
  padding: 20px 22px 16px; text-align: center;
  box-shadow: 0 10px 0 var(--shadow), 0 24px 48px rgba(0,0,0,.3);
  animation: pop-in .2s ease-out;
}
.fact-title { font-size: 18px; font-weight: bold; color: var(--green-dark); margin-bottom: 8px; }
.fact-body { font-size: 14.5px; color: var(--ink); line-height: 1.5; margin-bottom: 14px; }
#fact-close {
  border: 3px solid var(--outline); background: var(--green); color: white;
  font-family: inherit; font-size: 15px; font-weight: bold;
  border-radius: 12px; padding: 8px 26px; cursor: pointer;
  box-shadow: 0 3px 0 var(--shadow);
}
#fact-close:active { transform: translateY(2px); box-shadow: none; }

/* ---------- splash ---------- */
#splash {
  position: absolute; inset: 0; z-index: 80;
  background: linear-gradient(#a5d8ee, #87c7e0 55%, #9ccf6b);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: opacity .6s; 
}
#splash.gone { opacity: 0; pointer-events: none; }
.splash-logo { font-size: 72px; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-10px);} }
#splash h1 { color: var(--ink); font-size: 42px; margin: 8px 0 4px; text-shadow: 0 3px 0 rgba(255,255,255,.5); }
#splash p { color: #5d7a43; font-size: 16px; font-weight: bold; }

/* ---------- mobile ---------- */
@media (max-width: 700px) {
  .panel { top: 64px; bottom: 96px; right: 6px; left: 6px; width: auto; }
  #tool-dock { bottom: 8px; }
  .hud-btn { width: 40px; height: 40px; font-size: 19px; }
  .hud-chip { font-size: 15px; padding: 5px 9px; }
  .xp-bar { width: 60px; }
}
