:root {
  color-scheme: light;
  --bg: #f3efe6;
  --panel: #fffaf0;
  --line: #d4c7aa;
  --text: #2d2418;
  --wall: #6a5a46;
  --soft: #c7a56b;
  --floor: #efe4cf;
  --bomb: #202020;
  --flame: #df5b2d;
  --player: #2f7d4a;
  --enemy: #a83d2b;
  --bomb-up: #26547c;
  --shoe-up: #7a3e9d;
  --flame-up: #c44536;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(100%, 760px);
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 20px;
  box-shadow: 0 10px 30px rgba(65, 44, 20, 0.08);
}

.hud {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.hud-label,
.hud-value,
.help p {
  margin: 0;
}

.hud-label {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
}

.hud-value {
  font-size: 1.3rem;
}

.board-wrap {
  position: relative;
}

.status {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.board {
  display: grid;
  width: 100%;
  gap: 2px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(0, 0, 0, 0.04)),
    var(--line);
  border: 2px solid var(--line);
  aspect-ratio: 13 / 11;
  min-height: 320px;
  grid-template-columns: repeat(13, 1fr);
  grid-template-rows: repeat(11, 1fr);
  touch-action: none;
}

.cell {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.4), rgba(0, 0, 0, 0.03)),
    var(--floor);
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.cell.wall {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.2)),
    repeating-linear-gradient(
      0deg,
      #6b5b47 0,
      #6b5b47 12px,
      #5b4b38 12px,
      #5b4b38 13px
    );
}

.cell.soft {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.16)),
    repeating-linear-gradient(
      45deg,
      #caa86b 0,
      #caa86b 10px,
      #bd975b 10px,
      #bd975b 20px
    );
}

.cell.bomb::after,
.cell.player::after,
.cell.enemy::after,
.cell.flame::after,
.cell.powerup::after {
  content: "";
  position: absolute;
  inset: 16%;
}

.cell.bomb::after {
  background:
    radial-gradient(circle at 35% 35%, #7b7b7b 0, #4c4c4c 24%, #1c1c1c 72%);
  border-radius: 50%;
  box-shadow: inset -3px -4px 0 rgba(255, 255, 255, 0.08);
}

.cell.bomb::before {
  content: "";
  position: absolute;
  width: 22%;
  height: 14%;
  top: 14%;
  left: 53%;
  border-radius: 999px;
  background: #f1c75a;
  transform: translateX(-50%) rotate(26deg);
}

.cell.flame::after {
  inset: 12%;
  background:
    radial-gradient(circle at 50% 30%, #ffd77e 0, #ff9e4a 34%, #df5b2d 72%);
  clip-path: polygon(50% 0%, 68% 24%, 100% 44%, 74% 58%, 84% 100%, 50% 78%, 16% 100%, 26% 58%, 0% 44%, 32% 24%);
}

.cell.player::after {
  background:
    radial-gradient(circle at 35% 35%, #7fd493 0, #2f7d4a 65%);
  border-radius: 50%;
}

.cell.player::before,
.cell.enemy::before {
  content: "";
  position: absolute;
  inset: 34% 28% auto;
  height: 10%;
  background:
    radial-gradient(circle, #fff 0, #fff 48%, transparent 52%) left center / 40% 100% no-repeat,
    radial-gradient(circle, #fff 0, #fff 48%, transparent 52%) right center / 40% 100% no-repeat;
  z-index: 1;
}

.cell.enemy::after {
  background:
    radial-gradient(circle at 35% 35%, #ffb09a 0, var(--enemy) 65%);
  border-radius: 50%;
}

.cell.enemy-a::after {
  background:
    radial-gradient(circle at 35% 35%, #f9aa9d 0, #b74234 65%);
}

.cell.enemy-b::after {
  background:
    radial-gradient(circle at 35% 35%, #f9dc9d 0, #b9782c 65%);
}

.cell.enemy-c::after {
  background:
    radial-gradient(circle at 35% 35%, #d6b9ff 0, #6f4bb6 65%);
}

.cell.powerup-bomb::after {
  inset: 20%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 35%, #97c6ea 0, var(--bomb-up) 68%);
}

.cell.powerup-shoes::after {
  inset: 18%;
  background: var(--shoe-up);
  clip-path: polygon(10% 72%, 26% 30%, 58% 24%, 74% 42%, 92% 58%, 92% 74%, 10% 74%);
}

.cell.powerup-flame::after {
  inset: 16%;
  background: var(--flame-up);
  clip-path: polygon(50% 0%, 70% 24%, 92% 52%, 72% 64%, 80% 100%, 50% 80%, 20% 100%, 28% 64%, 8% 52%, 30% 24%);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(35, 24, 14, 0.54);
  color: #fffaf0;
  font-size: 1.1rem;
  text-align: center;
}

.hidden {
  display: none;
}

.actions,
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

button {
  border: 1px solid var(--wall);
  background: #f7f1e3;
  color: var(--text);
  font: inherit;
  padding: 10px 14px;
  cursor: pointer;
}

.legend {
  font-size: 0.95rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 14px;
  height: 14px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.swatch.wall {
  background: var(--wall);
}

.swatch.soft {
  background: var(--soft);
}

.swatch.bomb {
  background: var(--bomb);
}

.swatch.flame {
  background: var(--flame);
}

.swatch.player {
  background: var(--player);
}

.swatch.enemy {
  background: var(--enemy);
}

.swatch.power {
  background: linear-gradient(135deg, var(--bomb-up), var(--flame-up));
}

.help {
  margin-top: 16px;
  line-height: 1.5;
}

.mobile-controls {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}

.mobile-controls-row {
  display: flex;
  gap: 8px;
}

@media (max-width: 720px) {
  .panel {
    padding: 14px;
  }

  .hud {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mobile-controls {
    display: flex;
    flex-direction: column;
  }

  .mobile-controls button {
    min-width: 88px;
  }

  .board {
    min-height: 260px;
  }
}
