:root {
  --ink: #49352d;
  --green: #78bd62;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", Arial, sans-serif;
  background: linear-gradient(145deg, #e8f6d9, #fff4d8 55%, #dff1e7);
}
button {
  font: inherit;
}
header {
  text-align: center;
  color: #fff;
  padding: 13px;
  background: linear-gradient(135deg, #80c96b, #56a65d);
  border-bottom: 5px solid #fff;
  text-shadow: 0 2px #397c45;
}
header h1 {
  margin: 0;
  font-size: clamp(25px, 3vw, 42px);
}
header p {
  margin: 4px;
}
main {
  display: grid;
  grid-template-columns: 210px minmax(420px, 590px) 225px;
  grid-template-areas: "p board pow" "bot board pow";
  align-items: start;
  justify-content: center;
  gap: 14px;
  padding: 18px;
}
.panel {
  background: #fffdf7ef;
  border: 4px solid #fff;
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 6px 18px #52764e2b;
}
.player {
  grid-area: p;
  opacity: 0.72;
}
.player.bot {
  grid-area: bot;
}
.player.active {
  opacity: 1;
  outline: 4px solid #ffe074;
}
.identity {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-bottom: 9px;
}
.identity h2 {
  margin: 0;
  font-size: 18px;
}
.avatar {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #e87958;
  border: 3px solid #ffd2a9;
}
.bot .avatar {
  background: #6e86cb;
}
.progress {
  height: 26px;
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: #e4eadf;
  text-align: center;
}
.progress i {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #ef9c51, #f6c654);
  transition: width 0.3s;
}
.bot .progress i {
  background: #7798df;
}
.progress span {
  position: relative;
  line-height: 26px;
  font-weight: 900;
}
.inventory {
  display: grid;
  gap: 4px;
  margin-top: 9px;
}
.inv {
  display: grid;
  grid-template-columns: 27px 1fr auto;
  align-items: center;
  padding: 3px 7px;
  min-height: 33px;
  border: 1px solid #ede5d7;
  border-radius: 10px;
  background: #fff;
}
.inv i {
  font-style: normal;
  font-size: 20px;
}
.inv span {
  font-size: 11px;
  font-weight: 700;
}
.inv span small {
  display: block;
  font-size: 8px;
  color: #899;
}
.inv b small {
  font-size: 9px;
  color: #999;
}
.inv.free {
  opacity: 0.65;
  background: #f2f4ef;
}
.game {
  grid-area: board;
  padding: 12px;
  border-radius: 24px;
  background: #fffaf3;
  box-shadow: 0 8px 24px #52764e35;
}
#board {
  width: min(590px, calc(100vh - 180px));
  max-width: 100%;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1;
  gap: 5px;
  padding: 7px;
  border-radius: 18px;
  background: #bbd5b0;
  border: 4px solid #fff;
}
.tile {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-size: clamp(23px, 3vw, 40px);
  background: linear-gradient(145deg, #fff, var(--c));
  box-shadow:
    inset 0 0 0 2px #ffffffb8,
    0 2px 3px #63805e3d;
  transition: 0.16s;
}
.tile:hover:not(:disabled) {
  transform: scale(1.06);
}
.tile.selected {
  outline: 5px solid #ffbd3d;
  z-index: 2;
  transform: scale(1.08);
}
.tile.moss:after {
  content: "";
  position: absolute;
  width: 48%;
  height: 24%;
  bottom: 7%;
  border-radius: 50%;
  background: #86c86699;
  filter: blur(2px);
  animation: moss 1.8s infinite;
}
.tile.remove {
  transform: scale(0) rotate(20deg);
  opacity: 0;
}
#board.drop .tile {
  animation: drop 0.4s;
}
@keyframes moss {
  50% {
    transform: scale(1.25, 0.7) translateY(-4px);
    opacity: 0.5;
  }
}
@keyframes drop {
  from {
    transform: translateY(-65px);
    opacity: 0.2;
  }
}
#message {
  min-height: 44px;
  margin-top: 10px;
  padding: 11px;
  border-radius: 14px;
  background: #f0f7e8;
  text-align: center;
  font-weight: 800;
}
.powers {
  grid-area: pow;
  position: sticky;
  top: 12px;
}
.powers h2,
.powers > p {
  text-align: center;
  margin: 3px;
}
.powers > p {
  font-size: 11px;
  color: #788;
}
.power {
  width: 100%;
  position: relative;
  display: grid;
  grid-template-columns: 37px 1fr;
  gap: 6px;
  align-items: center;
  margin: 7px 0;
  padding: 7px;
  text-align: left;
  color: var(--ink);
  background: #fff4c9;
  border: 2px solid #efc25d;
  border-radius: 13px;
  cursor: pointer;
}
.power:hover:not(:disabled),
.power.armed {
  background: #ffe695;
  transform: translateY(-2px);
}
.power:disabled {
  opacity: 0.48;
}
.power .icon {
  font-size: 27px;
}
.power b,
.power small {
  display: block;
}
.power small {
  font-size: 9px;
}
.cost {
  grid-column: 1/-1;
  text-align: right;
  font-size: 11px;
  font-weight: 900;
}
.tip {
  display: none;
  position: absolute;
  z-index: 9;
  right: calc(100% + 8px);
  top: 0;
  width: 210px;
  padding: 10px;
  border-radius: 10px;
  color: #fff;
  background: #40362f;
  font-size: 12px;
}
.power:hover .tip,
.power:focus .tip {
  display: block;
}
.restart,
.modal button {
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 12px;
  background: #df7659;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #23351fbb;
}
.modal.hidden {
  display: none;
}
.modal > div {
  padding: 30px;
  text-align: center;
  border: 7px solid #fff;
  border-radius: 25px;
  background: #fff9e8;
}
.modal > div > strong {
  font-size: 55px;
}
@media (max-width: 800px) {
  main {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "board board" "p bot" "pow pow";
  }
  .powers {
    position: static;
  }
  #powers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .power {
    margin: 0;
  }
  .tip {
    right: auto;
    left: 0;
    top: 100%;
  }
}
@media (max-width: 500px) {
  main {
    display: flex;
    flex-direction: column;
    padding: 7px;
  }
  .panel,
  .game {
    width: 100%;
  }
  #board {
    gap: 2px;
    padding: 3px;
  }
  .tile {
    font-size: 8vw;
  }
  #powers {
    grid-template-columns: 1fr;
  }
}
