* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #0f1420;
  color: #e8e8f0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

#wrap { padding: 12px; max-width: 1060px; width: 100%; }

header { display: flex; align-items: center; gap: 20px; margin-bottom: 8px; flex-wrap: wrap; }
h1 { font-size: 1.4rem; color: #ffd45e; letter-spacing: 1px; }

#topbar { display: flex; align-items: center; gap: 18px; flex: 1; flex-wrap: wrap; }
.stat { font-size: 0.95rem; white-space: nowrap; }
.stat.gold { color: #ffd45e; font-weight: 600; }
.stat small { color: #9aa; }

.hpbars { display: flex; gap: 14px; flex: 1; min-width: 260px; }
.hpwrap { display: flex; align-items: center; gap: 6px; flex: 1; }
.lbl { font-size: 0.7rem; font-weight: 700; }
.lbl.you { color: #5eb1ff; }
.lbl.foe { color: #ff6e6e; }
.hpbg { flex: 1; height: 12px; background: #262c3d; border-radius: 6px; overflow: hidden; }
.hpfill { height: 100%; width: 100%; transition: width 0.2s; }
.hpfill.you { background: linear-gradient(90deg, #2f7fd4, #5eb1ff); }
.hpfill.foe { background: linear-gradient(90deg, #d43b3b, #ff6e6e); }

canvas {
  display: block;
  width: 100%;
  background: #17203a;
  border: 2px solid #2c3554;
  border-radius: 6px;
  cursor: crosshair;
}

#controls { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.ctl {
  background: #223052;
  color: #e8e8f0;
  border: 1px solid #3a4d80;
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}
.ctl:hover:not(:disabled) { background: #2e4270; }
.ctl:disabled { opacity: 0.45; cursor: not-allowed; }
.ctl.active { background: #3d5a9e; border-color: #6d8fd4; }
.ctl.up { background: #2c4030; border-color: #4a7050; }
.ctl.up:hover:not(:disabled) { background: #3a5540; }
.cost { color: #ffd45e; font-size: 0.85rem; }
.ctl { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 3px 6px; text-align: left; }
.stats { flex-basis: 100%; font-size: 0.72rem; color: #9fb4d8; margin-top: 1px; }
.stats .atk { color: #ff9d7a; }
.stats .def { color: #7ad0ff; }
.stats .rng { color: #b7e07a; }

#hint { margin-top: 8px; color: #8892a8; font-size: 0.82rem; line-height: 1.4; }

#overlay {
  position: fixed; inset: 0;
  background: rgba(8, 10, 18, 0.82);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
#overlay.hidden { display: none; }
#overlayBox {
  background: #1a2338;
  border: 2px solid #3a4d80;
  border-radius: 12px;
  padding: 36px 48px;
  text-align: center;
}
#overlayBox h2 { font-size: 2rem; margin-bottom: 10px; }
#overlayBox p { color: #9aa5bd; margin-bottom: 22px; }
#btnRestart {
  background: #ffd45e; color: #1a1a2e; border: none;
  padding: 12px 30px; font-size: 1.05rem; font-weight: 700;
  border-radius: 8px; cursor: pointer;
}
#btnRestart:hover { background: #ffe28a; }
