/* Xưởng Tre — full-screen layout. Canvas fills the whole window;
   HUD bars float over it. All text is bold on solid panels so it stays
   readable at any size (measured by the contrast check). */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #17351f;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }

.hidden { display: none !important; }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px;
  display: flex; align-items: center; gap: 14px; padding: 0 14px;
  background: #17351f; color: #ffffff; z-index: 10;
  border-bottom: 3px solid #d9a441;
}
#brand { font-size: 22px; font-weight: 800; letter-spacing: 1px; color: #ffd968; white-space: nowrap; }
#levelname { font-size: 15px; font-weight: 700; white-space: nowrap; }
#goalbox { font-size: 14px; font-weight: 600; color: #eaffea; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#budgetbox { margin-left: auto; font-size: 15px; font-weight: 700; white-space: nowrap; }
#budgetcount { color: #ffd968; }
#starsbox { font-size: 20px; font-weight: 800; color: #ffd968; white-space: nowrap; }
#modebox {
  font-size: 14px; font-weight: 800; padding: 5px 12px; border-radius: 6px;
  background: #ffd968; color: #17351f; white-space: nowrap;
}
#modebox.run { background: #ff7a45; color: #2b0d00; }

/* ---------- toolbar ---------- */
#toolbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 12px;
  display: flex; align-items: stretch; gap: 8px; padding: 10px 12px;
  background: #f3e3b3; border: 3px solid #8a6420; border-radius: 14px; z-index: 10;
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
}
.tool {
  width: 84px; padding: 6px 4px 5px; border-radius: 10px; cursor: pointer;
  background: #fff8e1; border: 2px solid #b98d3e; color: #3a2a08;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  user-select: none;
}
.tool:hover { background: #ffefbb; }
.tool.sel { background: #ffd968; border-color: #17351f; box-shadow: inset 0 0 0 2px #17351f; }
.tool span { font-size: 13px; font-weight: 800; }
.tool kbd {
  font-size: 11px; font-weight: 700; background: #17351f; color: #ffffff;
  border-radius: 4px; padding: 1px 6px; font-family: inherit;
}
.icon { width: 44px; height: 30px; border-radius: 5px; }
.ic-bamboo { background: repeating-linear-gradient(90deg,#7fae3f 0 9px,#5d8a2c 9px 12px); border: 2px solid #3f6219; }
.ic-rope { background: repeating-linear-gradient(45deg,#c9a15c 0 5px,#a37f3d 5px 10px); border: 2px solid #7a5a22; }
.ic-wheel { background: radial-gradient(circle,#8a5a2b 0 6px,#c9974f 7px 12px,#8a5a2b 13px 15px); border: 2px solid #5d3d17; border-radius: 50%; width: 30px; }
.ic-kite { background: linear-gradient(135deg,#ff5d5d 0 50%,#ffb84d 50% 100%); border: 2px solid #8a2b1d; clip-path: polygon(50% 0,100% 45%,50% 100%,0 45%); }
.ic-firework { background: repeating-linear-gradient(0deg,#e33e2b 0 6px,#ffd968 6px 9px); border: 2px solid #7c1d10; width: 20px; }
.ic-erase { background: linear-gradient(135deg,#ffffff 0 55%,#e33e2b 55% 100%); border: 2px solid #555555; }
#toolsep { width: 3px; background: #8a6420; border-radius: 2px; margin: 2px 2px; }
.bigbtn {
  font-size: 16px; font-weight: 800; padding: 0 18px; border-radius: 10px; cursor: pointer;
  background: #2e7d32; color: #ffffff; border: 2px solid #17351f; font-family: inherit;
}
.bigbtn:hover { background: #388e3c; }
.bigbtn.ghost { background: #fff8e1; color: #3a2a08; border-color: #8a6420; }
.bigbtn.ghost:hover { background: #ffefbb; }

/* ---------- level select ---------- */
#levels { position: fixed; top: 62px; left: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 10; }
.lvl {
  font-size: 14px; font-weight: 800; text-align: left; padding: 7px 12px; border-radius: 9px;
  background: #fff8e1; color: #3a2a08; border: 2px solid #8a6420; cursor: pointer; font-family: inherit;
}
.lvl:hover { background: #ffefbb; }
.lvl.sel { background: #ffd968; border-color: #17351f; box-shadow: inset 0 0 0 2px #17351f; }

/* ---------- help / toast / result ---------- */
#help {
  position: fixed; left: 12px; bottom: 122px; max-width: 380px; z-index: 9;
  font-size: 13px; font-weight: 700; color: #ffffff; background: #17351f;
  padding: 8px 12px; border-radius: 9px; border: 2px solid #d9a441;
}
#toast {
  position: fixed; top: 66px; left: 50%; transform: translateX(-50%); z-index: 11;
  font-size: 16px; font-weight: 800; color: #ffffff; background: #17351f;
  padding: 9px 18px; border-radius: 10px; border: 2px solid #ffd968;
}
#result {
  position: fixed; inset: 0; z-index: 12; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 30, 16, 0.45);
}
#result-card {
  background: #fff8e1; border: 4px solid #8a6420; border-radius: 18px;
  padding: 26px 38px; text-align: center; box-shadow: 0 12px 34px rgba(0,0,0,.5);
}
#result-title { font-size: 30px; font-weight: 800; color: #17351f; }
#result-stars { font-size: 44px; font-weight: 800; color: #9c6500; letter-spacing: 6px; margin: 4px 0; }
#result-stats { font-size: 16px; font-weight: 700; color: #3a2a08; margin-bottom: 16px; }
#result-btns { display: flex; gap: 10px; justify-content: center; }
#result-btns .bigbtn { padding: 10px 18px; }
