:root {
  --bg: #0d1023;
  --panel: #171c38;
  --chip: #26305d;
  --text: #f3f7ff;
  --accent: #7ad8ff;
  --danger: #ff6a8c;
  --success: #73f3b7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 20% 10%, #2b2f54 0%, #0b0f22 50%, #050710 100%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  padding: 10px;
}

.game-shell {
  width: min(430px, 100vw - 12px);
  height: 100vh;
  max-height: 100vh;
  display: grid;
  grid-template-rows: auto 28% 1fr;
  gap: 6px;
  padding-bottom: 8px;
}

.hud-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.chip {
  background: linear-gradient(180deg, #2f3a72 0%, #21294c 100%);
  border: 1px solid #5f74d1;
  border-radius: 12px;
  text-align: center;
  padding: 7px 8px;
  font-weight: 700;
  font-size: 13px;
}

.battle-zone {
  position: relative;
  background: linear-gradient(180deg, #352f47 0%, #272533 70%, #1e1e2b 100%);
  border: 2px solid #5f668a;
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 0.95fr 1.2fr 1fr;
  align-items: end;
  padding: 8px;
}

.enemy-stack {
  align-self: stretch;
  display: grid;
  grid-template-rows: 1fr auto;
}

.rat-row {
  display: flex;
  justify-content: space-around;
  align-items: end;
  margin-top: -8px;
}

.entity {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: center;
}

.entity img {
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 5px 4px rgba(0,0,0,0.5));
  user-select: none;
  pointer-events: none;
}

.hero { max-height: 95%; }
.hero img { width: 92%; }

.boar img { width: 75%; }
.worm img { width: 100%; }

.rat {
  width: 31%;
}

.rat img {
  width: 100%;
}

.hp-wrap {
  position: absolute;
  top: 2px;
  width: 76%;
  height: 8px;
  background: rgba(20,20,20,0.8);
  border: 1px solid #c8dcff;
  border-radius: 999px;
  overflow: hidden;
}

.hp-wrap.small {
  width: 90%;
  height: 6px;
  top: -2px;
}

.hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #5ef6b6 0%, #3bd78d 100%);
  transition: width 180ms ease;
}

.hp-fill.enemy { background: linear-gradient(90deg, #ffa15f 0%, #ff6b5e 100%); }
.hp-fill.boss { background: linear-gradient(90deg, #ef6aff 0%, #cf40ff 100%); }

.battle-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating {
  position: absolute;
  color: #fff1a6;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  font-size: 15px;
  font-weight: 700;
  animation: floatUp 680ms ease-out forwards;
}

@keyframes floatUp {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-30px); opacity: 0; }
}

.board-zone {
  position: relative;
  background: linear-gradient(180deg, #1a2040 0%, #131934 36%, #0e1228 100%);
  border: 2px solid #47508a;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#boardCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 72px;
  transform: translateX(-50%);
  background: rgba(7, 10, 24, 0.85);
  border: 1px solid #6a84ff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 180ms;
  pointer-events: none;
}

.toast.show { opacity: 1; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 18, 0.85);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  font-size: 24px;
  font-weight: 800;
  z-index: 10;
}

.hidden { display: none; }
