* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { background: #10141c; height: 100%; font-family: "Segoe UI", Arial, sans-serif; }
#wrap { position: relative; width: 1280px; margin: 0 auto; }
canvas { display: block; background: #87b7e0; border-radius: 0 0 8px 8px; }

/* ---------- top bar ---------- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 54px;
  display: flex; align-items: center; gap: 22px; padding: 0 16px;
  background: linear-gradient(#2b3548, #1b2230); color: #ffffff;
  border-bottom: 3px solid #0d1119;
}
#brand { font-size: 22px; font-weight: 900; letter-spacing: 2px; color: #ffd75e; }
#levelname { font-size: 16px; font-weight: 700; color: #ffffff; }
#goalbox { font-size: 14px; font-weight: 700; color: #ffffff; display: flex; align-items: center; gap: 8px; }
#goalpct { color: #ffd75e; font-size: 16px; }
#goalbar { width: 150px; height: 12px; background: #0d1119; border: 1px solid #5a6a86; border-radius: 6px; overflow: hidden; }
#goalfill { height: 100%; width: 0%; background: linear-gradient(#ffb347, #ff7b2f); transition: width .3s; }
#partsbox { font-size: 14px; font-weight: 700; color: #ffffff; }
#partscount { color: #8fe388; font-size: 16px; }
#modebox {
  margin-left: auto; font-size: 15px; font-weight: 900; letter-spacing: 1px;
  background: #ffd75e; color: #1b2230; padding: 5px 14px; border-radius: 6px;
}
#modebox.run { background: #ff8c42; color: #1b2230; }

/* ---------- toolbar ---------- */
#toolbar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px;
  display: flex; align-items: stretch; gap: 8px; padding: 10px 12px;
  background: linear-gradient(#2b3548, #1b2230); border: 2px solid #0d1119; border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
}
.tool {
  width: 74px; padding: 6px 2px 4px; text-align: center; cursor: pointer;
  background: #39465e; border: 2px solid #57688a; border-radius: 8px; color: #ffffff;
  font-size: 12px; font-weight: 700; user-select: none;
}
.tool:hover { background: #46587a; }
.tool.sel { background: #ffd75e; color: #1b2230; border-color: #fff3c4; }
.tool kbd {
  display: block; margin-top: 2px; font-size: 10px; font-weight: 700;
  color: #c9d6ee; font-family: inherit;
}
.tool.sel kbd { color: #5a4a00; }
.icon { width: 34px; height: 34px; margin: 0 auto 3px; border-radius: 5px; position: relative; }
.ic-wood { background: linear-gradient(#b07b3f, #8a5a28); border: 2px solid #5e3c17; }
.ic-steel { background: linear-gradient(#c7d2de, #7e8fa3); border: 2px solid #4d5a6a; }
.ic-wheel { background: radial-gradient(circle, #d8dee8 0 26%, #23262b 28% 62%, #111 64%); border-radius: 50%; }
.ic-cannon { background: linear-gradient(90deg, #3a3f47 55%, #14161a 56%); border: 2px solid #14161a; }
.ic-bomb { background: radial-gradient(circle at 35% 30%, #6a7078, #14161a 70%); border-radius: 50%; }
.ic-balloon { background: radial-gradient(circle at 35% 30%, #ff9a9a, #d63b3b 70%); border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%; }
.ic-blade { background: linear-gradient(135deg, #e8eef5 0 45%, #8fa2b5 46% 55%, #e8eef5 56%); border: 2px solid #5a6a7a; }
.ic-erase { background: linear-gradient(135deg, #ff8f8f 0 48%, #ffffff 49% 51%, #ff8f8f 52%); border: 2px solid #8a3b3b; }
#toolsep { width: 2px; background: #57688a; margin: 4px 2px; }
.bigbtn {
  font-size: 17px; font-weight: 900; padding: 0 20px; border-radius: 8px; cursor: pointer;
  background: linear-gradient(#ffb347, #ff7b2f); color: #1b2230; border: 2px solid #a34a12;
}
.bigbtn:hover { filter: brightness(1.12); }
.bigbtn.ghost { background: #39465e; border-color: #57688a; color: #ffffff; }
.hidden { display: none !important; }

/* ---------- level select ---------- */
#levels { position: absolute; top: 64px; right: 12px; display: flex; flex-direction: column; gap: 6px; }
.lvl {
  font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: 7px; cursor: pointer;
  background: rgba(27,34,48,.88); color: #ffffff; border: 2px solid #57688a; text-align: left;
}
.lvl:hover { background: #39465e; }
.lvl.sel { background: #ffd75e; color: #1b2230; border-color: #fff3c4; }

/* ---------- help / toast / result ---------- */
#help {
  position: absolute; left: 12px; bottom: 122px; max-width: 380px; pointer-events: none;
  font-size: 13px; font-weight: 700; color: #ffffff; line-height: 1.45;
  background: rgba(13,17,25,.82); padding: 8px 12px; border-radius: 8px; border: 1px solid #57688a;
}
#toast {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
  font-size: 16px; font-weight: 900; color: #1b2230; background: #ffd75e;
  padding: 9px 20px; border-radius: 9px; border: 2px solid #a3831a; box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
#result {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 440px; text-align: center; padding: 26px 30px;
  background: linear-gradient(#2b3548, #1b2230); border: 3px solid #ffd75e; border-radius: 16px;
  box-shadow: 0 14px 44px rgba(0,0,0,.6); color: #ffffff;
}
#result-title { font-size: 34px; font-weight: 900; letter-spacing: 1px; color: #ffd75e; }
#result-stars { font-size: 40px; color: #ffd75e; margin: 6px 0; letter-spacing: 6px; }
#result-stats { font-size: 15px; font-weight: 700; color: #ffffff; line-height: 1.6; margin-bottom: 16px; }
#result-btns { display: flex; gap: 10px; justify-content: center; }
#result-btns .bigbtn { padding: 10px 18px; }
