* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, "Noto Sans TC", sans-serif; background: #f5f6f8; color: #1d2330; }
header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: #1d2330; color: #fff; }
main { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
.card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 16px; }
input, select, button { font: inherit; padding: 8px 10px; border: 1px solid #c8ccd4; border-radius: 6px; }
button { background: #2f6fed; color: #fff; border-color: #2f6fed; cursor: pointer; }
button.secondary { background: #fff; color: #1d2330; border-color: #c8ccd4; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #e3e6eb; }
.error { color: #c62828; min-height: 1.2em; }
.login { max-width: 360px; margin: 12vh auto; }
.login input, .login button { width: 100%; margin-top: 10px; }

/* ---- 3D tower defense game ---- */
#game { position: relative; width: 100%; min-width: 640px; height: 560px; }
#cv { display: block; position: absolute; inset: 0; width: 100%; height: 100%; }
#padlayer { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
#hudtop {
  position: absolute; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 6px 10px; background: rgba(24, 30, 40, 0.72); color: #fff;
  font-size: 15px; border-radius: 0 0 10px 10px;
}
#hudbot {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px 10px; background: rgba(24, 30, 40, 0.78); color: #fff;
  border-top: 2px solid #3b62c4; border-radius: 10px 10px 0 0;
}
#cards { display: flex; gap: 10px; }
.hero-card {
  display: flex; flex-direction: column; gap: 2px; min-width: 128px;
  padding: 6px 8px; border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px; cursor: pointer; background: rgba(255, 255, 255, 0.07); color: #fff;
}
.hero-card.sel { border: 3px solid #ffd23c; background: rgba(255, 210, 60, 0.22); }
.hero-card.poor { opacity: 0.55; }
.hname { font-weight: 700; font-size: 15px; }
.hcost { font-size: 13px; color: #8fd6f2; }
.hdesc { font-size: 12px; color: #cfd8e8; }
.gemswrap { font-size: 17px; font-weight: 700; color: #8fd6f2; }
.gemswrap #gems { color: #fff; }
.herocount { font-size: 13px; color: #cfd8e8; }
#msg {
  position: absolute; left: 0; right: 0; bottom: 118px; z-index: 45;
  text-align: center; font-size: 15px; color: #ffe9a8;
  background: rgba(24, 30, 40, 0.66); padding: 4px 8px; border-radius: 8px;
  pointer-events: none;
}
#msg:empty { background: transparent; }
#btn-wave { color: #fff; background: #3b62c4; border: 1px solid #3b62c4; }
#btn-wave[disabled] { opacity: 0.55; }
#btn-pause, #mute-btn { background: rgba(255, 255, 255, 0.1); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35); }
#overlay {
  position: absolute; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(10, 14, 24, 0.78); color: #fff; text-align: center;
}
#overlay .hidden { display: none; }
#overlay.hidden { display: none; }
#overlay button, #overlay div { font-size: 26px; }
#overlay button { padding: 12px 18px; border-radius: 12px; background: #2f6fed; color: #fff; border: 1px solid #fff; cursor: pointer; }
.padbtn {
  position: absolute; top: 0; left: 0; width: 42px; height: 42px; border-radius: 999px;
  background: rgba(20, 26, 34, 0.3); border: 2px dashed rgba(255, 255, 255, 0.7);
  color: transparent; font-size: 1px; padding: 0; cursor: pointer; pointer-events: auto;
}
.padbtn.taken { border: 3px solid #ffd23c; background: rgba(20, 26, 34, 0.45); border-style: solid; }
.padbtn.free { border-style: dashed; }
.padbtn.sel { border-style: solid; border-color: #6fe8ff; animation: padpulse 1.2s infinite; }
@keyframes padpulse { 0% { box-shadow: 0 0 0 0 rgba(111, 232, 255, 0.6); } 100% { box-shadow: 0 0 0 12px rgba(111, 232, 255, 0); } }
.padmenu {
  position: absolute; top: 0; left: 0; width: 66px; padding: 6px;
  background: rgba(24, 30, 40, 0.92); color: #ffe9a8; border: 1px solid #ffd23c;
  border-radius: 8px; font-size: 13px; cursor: pointer; pointer-events: auto; white-space: nowrap;
}
.flash { background: #c62828; }
