/* Tower Defence Militar — campo top-down e controles */
.tower-defense {
  max-width: 1000px;
  margin: 0 auto;
}
.td-status {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.td-status > div {
  min-width: 0;
  padding: 9px 6px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.td-status span {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.td-status strong {
  display: block;
  overflow: hidden;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}
.td-mensagem {
  min-height: 25px;
  margin: 0 0 9px;
  font-size: 14px;
  font-weight: 650;
  text-align: center;
  color: var(--text-2);
}
.td-quadro {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 8 / 5;
  background: #425d36;
  border: 3px solid #263a28;
  border-radius: 16px;
  box-shadow: 0 10px 28px rgba(20, 32, 21, 0.24);
}
#td-tela {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
#td-tela:focus-visible {
  outline: 4px solid var(--ring);
  outline-offset: -5px;
}
.td-carregando {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: #fff;
  background: rgba(20, 32, 21, 0.86);
}
.td-carregando[hidden] {
  display: none;
}
.td-carregando span {
  width: 34px;
  height: 34px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: td-girar 0.8s linear infinite;
}
.td-carregando p {
  margin: 0;
}
@keyframes td-girar {
  to { transform: rotate(360deg); }
}
.td-arsenal {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.td-torre {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 82px;
  padding: 8px 12px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}
.td-torre:hover:not(:disabled) {
  background: var(--soft-1);
  transform: translateY(-1px);
}
.td-torre[aria-pressed="true"] {
  background: var(--soft-1);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--ring);
}
.td-torre:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.td-torre img {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  object-fit: contain;
}
.td-torre span {
  min-width: 0;
}
.td-torre strong,
.td-torre small {
  display: block;
}
.td-torre strong {
  font-size: 15px;
}
.td-torre small {
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.25;
  color: var(--muted);
}
.td-torre kbd {
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 10px;
  color: var(--muted);
  background: transparent;
}
.td-selecionada {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.td-selecionada[hidden] {
  display: none;
}
.td-selecionada > div {
  flex: 1 1 240px;
}
.td-selecionada strong,
.td-selecionada span {
  display: block;
}
.td-selecionada span {
  margin-top: 3px;
  font-size: 13px;
  color: var(--muted);
}
.td-vender {
  min-height: 42px;
  padding: 8px 15px;
  font-weight: 700;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  cursor: pointer;
}
.td-controles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 14px;
}
.td-controles .button,
.td-controles .som-botao {
  min-height: 44px;
}
.td-ajuda {
  max-width: 760px;
  margin: 12px auto 0;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  color: var(--muted);
}
.td-confirmacao {
  width: min(420px, calc(100% - 32px));
  padding: 24px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}
.td-confirmacao::backdrop {
  background: rgba(10, 18, 12, 0.65);
  backdrop-filter: blur(3px);
}
.td-confirmacao h2 {
  margin: 0 0 8px;
}
.td-confirmacao p {
  margin: 0;
  line-height: 1.5;
  color: var(--muted);
}
.td-confirmacao-botoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.td-quadro:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  background: #1d2a20;
  border: 0;
  border-radius: 0;
}
.td-quadro:fullscreen #td-tela {
  width: min(100vw, 160vh);
  height: min(100vh, 62.5vw);
  margin: auto;
  position: absolute;
  inset: 0;
}
@media (max-width: 700px) {
  .td-status {
    gap: 5px;
  }
  .td-status > div {
    padding: 7px 2px;
  }
  .td-status span {
    font-size: 10px;
  }
  .td-status strong {
    font-size: 17px;
  }
  .td-arsenal {
    gap: 6px;
  }
  .td-torre {
    flex-direction: column;
    justify-content: center;
    gap: 0;
    min-height: 108px;
    padding: 5px 3px;
    text-align: center;
  }
  .td-torre img {
    width: 52px;
    height: 52px;
  }
  .td-torre strong {
    font-size: 12px;
  }
  .td-torre small {
    font-size: 10px;
  }
  .td-torre kbd {
    display: none;
  }
  .td-controles .button {
    padding: 8px 12px;
    font-size: 13px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .td-carregando span {
    animation: none;
  }
  .td-torre {
    transition: none;
  }
}
