/* Wrapper keeps fixed controls while inner area scrolls */
.mapa-wrapper { position: relative; }
.mapa-wrapper .mapa-remover-form { position:absolute; top:8px; right:8px; z-index:6; }
.mapa-wrapper .mapa-remover-form .btn { padding:6px 10px; }
.mapa-wrapper .mapa-zoom { position:absolute; top:8px; left:8px; z-index:7; display:flex; gap:6px; }
.mapa-wrapper .mapa-zoom .btn { padding:4px 8px; line-height:1; }
/* Vantagens: container com scroll e cabeçalho fixo */
.table-container {
  max-height: 250px;
  overflow-y: auto;
  position: relative;
}
#vantagens-table-container {
  scroll-padding-top: 0;
  padding-top: 0;
}
#tabela-vantagens {
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
}
#tabela-vantagens thead th {
  position: static;
  top: auto;
  z-index: 3;
  background: #232323 !important;
  color: var(--text-main) !important;
  padding: 8px 10px !important;
  font-weight: 700;
  line-height: 1.2;
}
.vantagens-table th, .vantagens-table td {
  padding: 6px 4px;
  white-space: normal;
  word-break: break-word;
  overflow: hidden;
}
.vantagens-table th {
  font-size: 1.05em;
  font-weight: bold;
}
.vantagens-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
/* Keep vantagens table on native table layout to avoid clipping from generic table rules. */
#tabela-vantagens,
#tabela-vantagens thead,
#tabela-vantagens tbody,
#tabela-vantagens tr,
#tabela-vantagens th,
#tabela-vantagens td {
  display: table;
}
#tabela-vantagens thead { display: table-header-group; }
#tabela-vantagens tbody { display: table-row-group; }
#tabela-vantagens tr { display: table-row; }
#tabela-vantagens th,
#tabela-vantagens td { display: table-cell; }
/* Alinhamento das colunas da tabela de vantagens */
.vantagens-table {
  table-layout: fixed;
  width: 100%;
}
.vantagens-table th:nth-child(1),
.vantagens-table td:nth-child(1) {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
  text-align: center;
}
.vantagens-table th:nth-child(2),
.vantagens-table td:nth-child(2) {
  width: 180px;
  min-width: 180px;
  max-width: 180px;
}
.vantagens-table th:nth-child(3),
.vantagens-table td:nth-child(3) {
  width: auto;
}
.table-scroll {
  table-layout: fixed;
  width: 100%;
}
.table-scroll th, .table-scroll td {
  padding: 8px 10px !important;
  overflow: hidden;
  word-break: break-word;
  box-sizing: border-box;
}
.table-scroll th {
  height: auto !important;
  min-height: 34px !important;
  line-height: 1.2 !important;
  padding: 8px 10px !important;
}
.table-scroll th:nth-child(1),
.table-scroll td:nth-child(1) {
  width: 60px;
  min-width: 60px;
  max-width: 60px;
  text-align: center;
}
.table-scroll th:nth-child(2),
.table-scroll td:nth-child(2) {
  width: 220px;
  min-width: 200px;
  max-width: 260px;
}
.table-scroll th:nth-child(3),
.table-scroll td:nth-child(3) {
  width: auto;
}
.table-scroll th:nth-child(4),
.table-scroll td:nth-child(4) {
  width: 150px;
  min-width: 140px;
  max-width: 180px;
}
.table-scroll th:nth-child(5),
.table-scroll td:nth-child(5) {
  width: 110px;
  min-width: 100px;
  max-width: 130px;
  text-align: right;
}
/* Reverter display padrões para evitar desalinhamento */
.table-scroll tbody {
  display: table-row-group;
  max-height: none;
  overflow: visible;
  width: auto;
}
.table-scroll thead, .table-scroll tfoot {
  display: table-header-group;
  width: auto;
  table-layout: fixed;
}
.table-scroll tr {
  display: table-row;
  width: auto;
  table-layout: fixed;
}
th {
  min-height: 2.5em !important;
  box-sizing: border-box !important;
  color: var(--text-main) !important;
  background: #232323 !important;
  font-weight: bold !important;
  padding: 1rem 1.5rem !important;
  border-bottom: 2px solid #444 !important;
  height: 2.2em !important;
  opacity: 1 !important;
  visibility: visible !important;
}
thead {
  display: table-header-group !important;
  background: #232323 !important;
}
/* Centraliza o formulário de poderes na tela */
.poder-form-outer {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
/* Botão remover (vermelho) para poderes */
.btn-danger {
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 1.5rem;
  padding: 0.4rem 1.3rem;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 1px 2px #0002;
}
.btn-danger:hover, .btn-danger:focus {
  background: #a93226;
}
/* Poderes - grid alinhado */
.poder-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  grid-auto-rows: auto;
  gap: 1.1rem 1.4rem;
  margin: 0 auto 1.2rem auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: #232323;
  border-radius: 14px;
  padding: 1.4rem 1.6rem 1.6rem 1.6rem;
  box-sizing: border-box;
}
/* Cada campo vira bloco (label em cima, input embaixo) */
.poder-form-grid .campo-poder { display:flex; flex-direction:column; gap:0.3rem; }
.poder-form-grid .campo-poder label { font-weight:600; font-size:0.9rem; margin:0; text-align:left; }
.poder-form-grid .campo-poder input,
.poder-form-grid .campo-poder select { width:100%; margin:0; }
/* Linhas que ocupam largura total */
.poder-form-grid .span-2 { grid-column:1 / -1; }
/* Espaçamento reduzido para checkboxes simples */
.poder-form-grid .linha-checkbox { display:flex; align-items:center; gap:0.6rem; }
/* Remover estilos antigos redundantes */

.poder-form-grid label,
.poder-form-grid .poder-label {
  font-weight: bold;
  margin-bottom: 0.2rem;
}
.poder-form-grid input,
.poder-form-grid select {
  width: 100%;
  min-width: 80px;
  max-width: 100%;
  box-sizing: border-box;
  margin-bottom: 0.2rem;
}
.poder-form-grid [type="checkbox"] {
  width: auto;
  margin-left: 0.5rem;
}
.poder-form-grid > div {
  margin-bottom: 0.2rem;
  min-width: 0;
  max-width: 100%;
}
.poder-form-grid .poder-remove {
  grid-column: 1 / span 2;
  text-align: right;
  margin-top: 1em;
}

.poder-form-grid .poder-custo-detalhe {
  display: block;
  grid-column: 1 / -1;
  justify-self: stretch;
  align-self: start;
  text-align: left !important;
  font-size: clamp(0.72rem, 1.75vw, 0.85rem) !important;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  line-height: 1.35;
}
/* Somar Força checkbox wrapper: ensure it stays inside the grid */
.poder-form-grid .somar-forca-wrap {
  align-self: start;
  white-space: normal; /* allow wrapping */
  grid-column: 1 / -1; /* span both columns */
  display: flex;           /* override .campo-poder column layout */
  flex-direction: row;     /* ensure horizontal */
  justify-content: flex-start; /* keep content together on the left */
  align-items: center;
  font-size: 0.7rem;       /* match hint line */
  color: #cfcfe1;
  opacity: 0.95;
  margin-top: 0.2rem;
  gap: 1rem;
}
.poder-form-grid .somar-forca-wrap label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: normal; /* override any inline nowrap */
  line-height: 1.2;
}
.poder-form-grid .somar-forca-wrap .somar-forca-left { display:flex; align-items:center; gap:0.45rem; }
.poder-form-grid .somar-forca-wrap .somar-forca-right {
  white-space:nowrap;
  margin-left: 1.25rem; /* bring it closer to the label, not flush right */
}
.poder-form-grid .somar-forca-wrap .label-total-dano{ margin-right:0.25rem; }
.poder-form-grid .somar-forca-wrap input[type="checkbox"] {
  margin-left: 0; /* rely on gap */
}
/* Perícias em duas colunas */
.pericias-duas-colunas {
  display: flex;
  gap: 2.5rem;
  margin-bottom: 2rem;
  justify-content: center;
  width: 100%;
}
.pericias-coluna {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: 50%;
  min-width: 220px;
  box-sizing: border-box;
}
/* Nova grade de perícias 4 colunas */
.pericias-grid-4 {
  width:100%;
}
.pericias-grid-4 .pericia-campo label { font-weight:700; color:#fff; text-align:center; }
.pericias-grid-4 .pericia-campo input { text-align:center; max-width:80px; }
@media (max-width: 1100px) {
  .pericias-grid-4 { grid-template-columns: repeat(3, minmax(140px,1fr)); }
}
@media (max-width: 820px) {
  .pericias-grid-4 { grid-template-columns: repeat(2, minmax(140px,1fr)); }
}
@media (max-width: 520px) {
  .pericias-grid-4 { grid-template-columns: repeat(1, minmax(140px,1fr)); }
}
@media (max-width: 900px) {
  .pericias-duas-colunas {
    flex-direction: column;
    gap: 1.2rem;
  }
  .pericias-coluna {
    width: 100%;
    min-width: 0;
  }
}
.linha-nome-full {
  width: 100%;
  margin-bottom: 1.1rem;
}
.campo-nome-full {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1.2rem;
}
.campo-nome-full label {
  min-width: 60px;
  font-weight: 600;
}
.campo-nome-full input[type="text"] {
  width: 100%;
  min-width: 180px;
  max-width: 100%;
}

.linha-foto-np {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}
.campo-foto, .campo-np {
  width: 50%;
  min-width: 220px;
  max-width: 50%;
  display: flex;
  flex-direction: column;
  margin-bottom: 0.7rem;
  box-sizing: border-box;
}
.campo-foto input[type="file"] {
  max-width: 95%;
  box-sizing: border-box;
}
.campo-np input[type="number"] {
  max-width: 100%;
}
.campo-foto, .campo-np {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  max-width: 100%;
}
.campo-foto label, .campo-np label {
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.campo-foto input[type="file"], .campo-np input[type="number"] {
  width: 100%;
  min-width: 120px;
  max-width: 100%;
}
/* Agrupamento visual para campos de características e defesas */
.caracteristicas-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
  margin-bottom: 1.5rem;
  justify-content: center;
  width: 100%;
}
@media (max-width: 900px) {
  .linha-foto-np {
    flex-direction: column;
    gap: 1.2rem;
  }
  .campo-foto, .campo-np {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
  .campo-foto input[type="file"] {
    max-width: 100%;
  }
  .caracteristicas-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 1rem 1.2rem;
  }
}
.caracteristicas-grid .campo-carac {
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}
.caracteristicas-grid label {
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 0.3rem;
  text-align: center;
  font-size: 1.08rem;
  letter-spacing: 0.5px;
}
.caracteristicas-grid input {
  text-align: center;
  font-size: 1.1rem;
  max-width: 70px;
  min-width: 60px;
  margin: 0 auto;
}
.espacamento-campos > div {
  margin-bottom: 0.7rem;
}
.defesas-duas-colunas {
  display: flex;
  gap: 2.5rem;
  margin-bottom: 2rem;
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
}
.defesas-coluna:first-child {
  margin-top: 0.7rem;
}
.defesas-coluna {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  width: 50%;
  min-width: 180px;
  box-sizing: border-box;
}
.defesas-coluna .campo-def {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-width: 120px;
  max-width: 100%;
  box-sizing: border-box;
}
/* Novo layout grid de defesas */
.defesas-grid .campo-def {
  display:flex;
  flex-direction:column;
  align-items:center;
}
.defesas-grid .campo-def label { display:block; margin-bottom:0.3rem; font-weight:700; color:#fff; text-align:center; }
.defesas-grid .campo-def input { display:block; text-align:center; max-width:120px; margin:0 auto; }

/* Alinhar checkboxes de resistências e imunidades (Django CheckboxSelectMultiple) */
.checkbox-grid ul { list-style: none; padding: 0; margin: 0; }
.checkbox-grid li { display: flex; align-items: center; gap: 0.4rem; margin: 0; }
.checkbox-grid li label { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-weight: normal; }
.checkbox-grid input[type="checkbox"] { margin: 0; flex-shrink: 0; }

@media (max-width: 900px) {
  .defesas-duas-colunas {
    flex-direction: column;
    gap: 1.2rem;
  }
  .defesas-coluna {
    width: 100%;
    min-width: 0;
  }
}
.defesas-coluna label {
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 0.3rem;
  text-align: center;
  font-size: 1.08rem;
  letter-spacing: 0.5px;
}
.defesas-coluna input {
  text-align: center;
  font-size: 1.1rem;
  max-width: 70px;
  min-width: 60px;
  margin: 0 auto;
}

/* Nome, NP e Foto em linha */
.linha-nome-foto-np {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2.2rem;
  margin-bottom: 1.5rem;
}
.linha-nome-foto-np > div {
  display: flex;
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 10px 20px;
  background: #222;
  border-radius: 14px;
  border: 2px solid #fff;
  padding: 32px 32px 24px 32px;
  margin: 0 auto 20px auto;
  max-width: 520px;
  box-shadow: 0 0 0 2px #222, 0 2px 16px 0 #000a;
}

.foto-np-group {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 1.2rem;
}
.linha-nome-foto-np label {
  min-width: 48px;
  font-weight: 600;
}
.linha-nome-foto-np input[type="text"],
.linha-nome-foto-np input[type="number"],
.linha-nome-foto-np input[type="file"] {
  min-width: 120px;
  max-width: 320px;
}
.personagem-form-fields input[type="number"],
.personagem-form-fields input[type="text"],
.personagem-form-fields select {
  max-width: 260px;
  min-width: 80px;
  width: auto;
  display: inline-block;
  margin-right: 1.2rem;
}

/* Para campos longos (ex: textarea, file), manter largura total */
.personagem-form-fields textarea,
.personagem-form-fields input[type="file"] {
  max-width: 100%;
  width: 100%;
}

/* Alinhar label e campo lado a lado */
.personagem-form-fields > div {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-bottom: 0.5rem;
}
/* Exception: vantagem list container must stay in normal block flow.
   The generic flex rule above can vertically center the table and clip first rows. */
.personagem-form-fields > .table-container,
.personagem-form-fields > #vantagens-table-container {
  display: block !important;
  margin-bottom: 0.5rem;
}
.personagem-form-fields > div > label {
  min-width: 120px;
  margin-bottom: 0;
}

/* Ajuste para títulos de seção */
.personagem-form-fields h2 {
  display: block;
  width: 100%;
  margin-top: 2.2rem;
  margin-bottom: 0.7rem;
}
/* Centralização e estilo para criar/editar personagem */
.personagem-form-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: 100%;
  min-height: 60vh;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.personagem-form-center > form {
  width: min(100%, 1120px);
  max-width: 100%;
  min-width: 0;
}
.personagem-form-title {
  font-size: 2.3rem;
  margin-bottom: 2rem;
  color: var(--gold);
  text-align: center;
}
.personagem-form-fields {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  padding: 2.2rem 2.5rem 2.2rem 2.5rem;
  max-width: 700px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  box-sizing: border-box;
  min-width: 0;
}

.personagem-form-fields,
.personagem-form-fields > div,
.personagem-form-fields .table-container,
.personagem-form-fields .resistencias-grid-wrap,
.personagem-form-fields .resistencias-grid,
.personagem-form-fields .resist-tabela-wrap,
.personagem-form-fields .poder-form-outer,
.personagem-form-fields .poder-form-list,
.personagem-form-fields #poderes-formset,
.personagem-form-fields #poderes-main-list,
.personagem-form-fields #poderes-formset-item,
.personagem-form-fields #item-poderes-list {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.personagem-form-fields .resistencias-grid-wrap,
.personagem-form-fields .resist-tabela-wrap {
  overflow-x: auto;
}

.personagem-form-fields .resistencias-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1.6fr) minmax(92px, auto) minmax(92px, auto);
  gap: 0.8rem 1.25rem;
  align-items: center;
  width: max-content;
  min-width: 100%;
}

.personagem-form-fields .resistencias-grid > label {
  text-align: left !important;
}

.personagem-form-fields .poder-form-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: stretch !important;
  width: 100%;
}

.personagem-form-fields .resist-table {
  min-width: 560px;
}
/* Opção B: expandir largura em telas maiores mantendo legibilidade */
@media (min-width: 1100px) {
  .personagem-form-fields { max-width: 900px; }
}
@media (min-width: 1400px) {
  .personagem-form-fields { max-width: 1040px; }
}
.personagem-form-fields h2 {
  color: var(--gold);
  margin-top: 2.2rem;
  margin-bottom: 0.7rem;
  font-size: 1.3rem;
}
.personagem-form-fields label {
  font-size: 1.08rem;
  margin-bottom: 0.2rem;
  color: var(--text-main);
  font-weight: 500;
}
.personagem-form-fields input,
.personagem-form-fields select,
.personagem-form-fields textarea {
  width: 100%;
  margin-bottom: 0;
}

.personagem-form-fields > .caracteristicas-grid,
.personagem-form-fields > .defesas-grid,
.personagem-form-fields > .pericias-grid-4,
.personagem-form-fields > .inventario-largo {
  width: 100%;
  align-items: stretch;
}

.personagem-form-fields .caracteristicas-grid,
.personagem-form-fields .defesas-grid,
.personagem-form-fields .pericias-grid-4 {
  justify-items: stretch !important;
}

.personagem-form-fields .caracteristicas-grid .campo-carac,
.personagem-form-fields .defesas-grid .campo-def,
.personagem-form-fields .pericias-grid-4 .pericia-campo {
  width: 100%;
  min-width: 0;
}

.personagem-form-fields .caracteristicas-grid input {
  width: min(100%, 78px);
  max-width: 78px;
  min-width: 60px;
  margin: 0 auto;
}

.personagem-form-fields .defesas-grid .campo-def input {
  width: min(100%, 132px);
  max-width: 132px;
  min-width: 72px;
  margin: 0 auto;
}

.personagem-form-fields .pericias-grid-4 .pericia-campo input {
  width: min(100%, 88px);
  max-width: 88px;
  min-width: 68px;
  margin: 0 auto;
}

.personagem-form-fields .pericias-grid-4 .pericia-campo label,
.personagem-form-fields .defesas-grid .campo-def label,
.personagem-form-fields .caracteristicas-grid .campo-carac label {
  width: 100%;
  line-height: 1.25;
}

.personagem-form-fields .inventario-largo {
  align-items: stretch;
}

.personagem-form-fields .inventario-moedas-inline {
  width: 100%;
  justify-content: flex-start;
  align-items: center;
}

.personagem-form-fields .inventario-moedas-inline input {
  flex: 0 1 220px;
  width: min(100%, 220px);
  max-width: 220px;
  margin: 0;
}

.personagem-form-fields .inventario-filtros,
.personagem-form-fields .inventario-tabela-wrapper,
.personagem-form-fields #painel-efeitos-itens {
  width: 100%;
}

.personagem-form-fields .inventario-tabela-wrapper {
  overflow: auto;
}
.personagem-form-btns {
  display: flex;
  gap: 1rem;
  margin: 1.5rem 0 0.5rem 0;
  justify-content: flex-end;
}
.personagem-form-center .btn,
.personagem-form-fields .btn {
  background: var(--accent);
  color: #fff !important;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.5rem 1.2rem;
  font-weight: 600;
  margin-left: 0;
  margin-top: 0.5rem;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(197,49,49,0.12);
  width: fit-content;
  align-self: flex-end;
  font-size: 1.08rem;
  cursor: pointer;
}
.personagem-form-center .btn:hover,
.personagem-form-fields .btn:hover {
  background: var(--gold);
  color: var(--text-dark) !important;
}
/* Centralização e estilo para página de Meus Personagens */
.personagens-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 60vh;
  margin-top: 2rem;
}
.personagens-title {
  font-size: 2.3rem;
  margin-bottom: 2rem;
  color: var(--gold);
  text-align: center;
}
.personagens-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 760px; /* widen to fit actions without overflow */
}
.personagens-list li {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  margin-bottom: 1.2rem;
  padding: 1.2rem 1.5rem;
  display: flex;
  flex-direction: column; /* stack top and owner rows */
  gap: 0.6rem;
  font-size: 1.13rem;
}
.personagem-top { display:flex; align-items:center; justify-content:space-between; gap:1rem; }
.personagem-info { display:flex; align-items:center; gap:0.6rem; flex:1 1 auto; min-width:0; }
.personagem-acoes { display:flex; align-items:center; gap:0.6rem; flex:0 0 auto; white-space:nowrap; }
.personagem-owner { color:#ccc; font-size:0.95rem; }
.personagens-list .btn { padding: 0.35rem 0.9rem; font-size: 0.95rem; }
.personagem-link {
  color: var(--gold);
  font-weight: 600;
  text-decoration: none;
  font-size: 1.15rem;
  margin-right: 0.5rem;
}
.personagem-link:hover {
  text-decoration: underline;
  color: #fff;
}
.personagem-np {
  color: var(--text-main);
  margin-right: auto;
  font-size: 1.08rem;
}
.btn {
  background: var(--accent);
  color: #fff !important;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.4rem 1.1rem;
  font-weight: 600;
  font-size: 1rem;
  margin-left: 0.3rem;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(197,49,49,0.12);
  cursor: pointer;
}
.btn:hover {
  background: var(--gold);
  color: var(--text-dark) !important;
}
.btn-excluir {
  background: #a32a2a;
}
.btn-excluir:hover {
  background: #e6c200;
  color: var(--text-dark) !important;
}
/* ===== NPCs list in one line ===== */
.personagens-list.npcs-inline li.npc-item {
  flex-direction: row;              /* one row */
  align-items: center;
  justify-content: space-between;   /* left info | right actions */
  gap: 0.8rem;
}
.personagens-list.npcs-inline li.npc-item .npc-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1 1 auto;
  min-width: 0;
}
.personagens-list.npcs-inline li.npc-item .npc-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;              /* keep buttons on one line */
  flex: 0 0 auto;
}

@media (max-width: 980px) {
  .personagens-list.npcs-inline li.npc-item {
    flex-direction: column;
    align-items: stretch;
  }

  .personagens-list.npcs-inline li.npc-item .npc-actions {
    width: 100%;
    flex-wrap: wrap;
    white-space: normal;
    justify-content: flex-start;
  }

  .personagens-list.npcs-inline li.npc-item .npc-actions > a {
    flex: 1 1 120px;
    min-width: 0;
  }

  .personagens-list.npcs-inline li.npc-item .npc-actions .btn {
    width: 100%;
    margin-left: 0;
    text-align: center;
  }
}
/* Área responsiva para título, filtros e tabela de itens */
.itens-area-responsive {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto 2rem auto;
  overflow-x: auto;
  padding: 0 2.5vw 2rem 2.5vw;
  box-sizing: border-box;
}
.itens-title {
  margin-left: 0.2rem;
  margin-top: 0;
  margin-bottom: 1.2rem;
}
.itens-filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.2rem;
  padding-left: 0.2rem;
}
.itens-filtros input,
.itens-filtros select {
  min-width: 180px;
  max-width: 260px;
}
/* Responsividade para tabelas longas */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 0;
  max-height: 400px;
  overflow-y: auto;
  /* Agora o padding está na .itens-area-responsive */
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 0;
}

.table-responsive > table,
.inventario-tabela,
.ficha-inv-tabela,
.table-scroll {
  min-width: 640px;
}

.vantagens-table {
  min-width: 540px;
}

th, td {
  padding: 1rem 1.5rem;
  text-align: left;
  border: 1px solid #444;
}

@media (max-width: 900px) {
  .table-responsive {
    min-width: 0;
    overflow-x: auto;
  }
  table {
    min-width: 0;
    font-size: 0.95rem;
  }
}

/* Centralizar formulário de criação de item */
.item-form-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 480px;
  width: min(100%, 480px);
  margin: 0 auto 2rem auto;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  padding: 2rem 2.5rem 1.5rem 2.5rem;
  box-sizing: border-box;
}
.item-form-center h2 {
  margin-top: 0;
}
.item-form-center form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.item-form-center label {
  font-size: 1.08rem;
  margin-bottom: 0.2rem;
  color: var(--text-main);
  font-weight: 500;
}

.item-form-center input,
.item-form-center select,
.item-form-center textarea {
  width: 100%;
  margin-bottom: 0;
}

.item-form-center button[type="submit"] {
  background: var(--accent);
  color: #fff !important;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.5rem 1.2rem;
  font-weight: 600;
  margin-left: 0;
  margin-top: 0.5rem;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(197,49,49,0.12);
  width: fit-content;
  align-self: flex-end;
}
.item-form-center button[type="submit"]:hover {
  background: var(--gold);
  color: var(--text-dark) !important;
}


/*
  Estilo inspirado no D&D Beyond
  Paleta: tons escuros, vermelho, dourado, branco
  Tipografia elegante, cards, botões destacados
*/

:root {
  --primary-bg: #23272a;
  --secondary-bg: #2c2f33;
  --accent: #c53131;
  --gold: #e6c200;
  --text-main: #f5f5f5;
  --text-dark: #23272a;
  --card-bg: #262626;
  --card-shadow: 0 4px 16px rgba(0,0,0,0.18);
  --border-radius: 12px;
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  background: var(--primary-bg);
  color: var(--text-main);
  font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
  margin: 0;
  min-height: 100vh;
}

img {
  max-width: 100%;
  height: auto;
}

/* Centralização para formulários de autenticação (login/cadastro) */
.auth-form-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 60vh;
  padding-top: 2.5rem;
  gap: 1rem;
}
.auth-form-center h1, .auth-form-center h2 {
  margin: 0 0 1.2rem 0;
  text-align: center;
}
.auth-form {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  padding: 2rem 2.4rem 1.8rem 2.4rem;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-sizing: border-box;
}
.auth-form .form-group { display: flex; flex-direction: column; }
.auth-form label { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.25rem; }
.auth-form input { width: 100%; margin-bottom: 0; }
.auth-form .error { color: #ff6b6b; font-size: 0.8rem; margin-top: 0.2rem; }
.auth-form button[type="submit"] { align-self: flex-end; }
.auth-alt-link { text-align: center; font-size: 0.95rem; }
.auth-alt-link a { color: var(--gold); text-decoration: none; font-weight: 600; }
.auth-alt-link a:hover { text-decoration: underline; }

/* Form Criar Sala centralizado */
.sala-form-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 55vh;
  padding-top: 2.2rem;
  gap: 1.2rem;
}
.sala-form-center h2 { margin:0 0 1rem 0; text-align:center; }
.sala-form {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  padding: 2rem 2.4rem 2rem 2.4rem;
  width: 100%;
  max-width: 500px;
  box-sizing: border-box;
}
.sala-form p { margin:0 0 0.9rem 0; }
.sala-form label { font-weight:600; font-size:0.95rem; }
.sala-form input, .sala-form select, .sala-form textarea { width:100%; margin-bottom:0.6rem; }
.sala-form .btn { margin-top:0.5rem; }

/* Listagem de Salas */
.salas-center { width:100%; max-width:1180px; margin:0 auto 2.5rem auto; padding:1.5rem 2rem 2.5rem 2rem; box-sizing:border-box; }
.salas-title { margin:0 0 1.4rem 0; font-size:2.1rem; text-align:left; }
.salas-filtro-form { display:flex; gap:0.8rem; flex-wrap:wrap; margin:0 0 1.6rem 0; }
.salas-filtro-form input[type="text"] { flex:1 1 300px; max-width:420px; }
.sala-atual-card { background:var(--card-bg); border-radius:var(--border-radius); box-shadow:var(--card-shadow); padding:1.5rem 1.7rem 1.5rem 1.7rem; margin:0 0 2rem 0; position:relative; border:1px solid #333; }
.sala-atual-header { display:flex; flex-wrap:wrap; gap:0.6rem; align-items:center; margin-bottom:0.6rem; }
.sala-nome { color:var(--gold); font-size:1.15rem; letter-spacing:0.5px; }
.sala-codigo { color:#ccc; font-size:0.95rem; margin-left:0.25rem; }
.sala-meta { font-size:0.92rem; margin-bottom:0.8rem; color:#ddd; }
.participantes-list { list-style:none; margin:0.4rem 0 0.8rem 0; padding:0 0 0 0; display:flex; flex-direction:column; gap:0.3rem; }
.participantes-list li { font-size:0.9rem; display:flex; gap:0.6rem; align-items:center; flex-wrap:wrap; }
.participante-nome { font-weight:600; }
.sala-acoes { margin:0; }
.salas-list { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:0.9rem; }
.sala-item { background:var(--card-bg); border-radius:var(--border-radius); padding:1rem 1.3rem; box-shadow:var(--card-shadow); border:1px solid #333; transition:box-shadow var(--transition), transform var(--transition), border var(--transition); }
.sala-item:hover { box-shadow:0 6px 18px rgba(230,194,0,0.12); transform:translateY(-2px); border:1px solid var(--gold); }
.sala-item.atual { outline:2px solid #2e7d32; background:#1f2a1f; }
.sala-item-main { display:flex; justify-content:space-between; align-items:flex-start; gap:1rem; flex-wrap:wrap; }
.sala-item-info { display:flex; flex-wrap:wrap; gap:0.45rem; align-items:center; font-size:0.95rem; }
.sala-dono { color:#bbb; font-size:0.82rem; background:#1c1c1c; padding:0.25rem 0.55rem; border-radius:0.6rem; }
.sala-item-acoes { display:flex; gap:0.6rem; align-items:center; }
.inline-form { display:inline; margin:0; padding:0; }
.btn-sm { padding:0.35rem 0.9rem; font-size:0.85rem; border-radius:0.6rem; }
.btn-danger { background:#a42e2e; }
.btn-danger:hover { background:var(--gold); color:var(--text-dark)!important; }
.status-badge { font-size:0.65rem; text-transform:uppercase; letter-spacing:0.5px; font-weight:700; padding:0.3rem 0.55rem; border-radius:0.6rem; background:#333; color:#ddd; position:relative; top:-1px; }
.status-badge.online { background:#1b5e20; color:#c5f7c6; }
.status-badge.offline { background:#5e1b1b; color:#f7c5c5; }
.status-badge.gm { background:#004d80; color:#badeff; }
.status-badge.atual { background:#2e7d32; color:#d4ffd6; }
.badge { font-size:0.62rem; font-weight:700; letter-spacing:0.5px; padding:0.32rem 0.55rem; border-radius:0.55rem; background:var(--accent); color:#fff; }
.badge-atual { background:#2e7d32; }
.sala-item.vazio { text-align:center; }
@media (max-width:640px){
  .sala-item-main { flex-direction:column; align-items:flex-start; }
  .sala-item-acoes { width:100%; justify-content:flex-start; }
  .salas-center { padding:1.2rem 1rem 2rem 1rem; }
}

/* ================= Páginas de Combate ================= */
.combate-center, .combate-detalhes-center { width:100%; max-width:1700px; margin:0 auto 2.5rem auto; padding:1.5rem 2rem 2.5rem 2rem; box-sizing:border-box; }
.combate-title { margin:0 0 1.6rem 0; font-size:2.2rem; text-align:left; }
.combate-subtitle { margin:0 0 1.2rem 0; font-size:1.9rem; }
.combate-card { background:var(--card-bg); border-radius:var(--border-radius); box-shadow:var(--card-shadow); padding:1.4rem 1.6rem 1.5rem 1.6rem; margin:0 0 1.6rem 0; border:1px solid #333; box-sizing:border-box; }
.combate-card hr { border:none; border-top:1px solid #333; margin:1.2rem 0; }
.combate-form-selecao { display:flex; flex-direction:column; gap:1rem; }
/* Barra superior do turno e ações globais */
.turno-topbar { display:flex; flex-direction:column; gap:0.9rem; margin:0 0 1.2rem 0; }
.turno-topbar-row { display:flex; justify-content:space-between; align-items:center; gap:1rem; }
.turno-topbar-info { font-size:1.05rem; }
.turno-topbar-actions { display:flex; gap:0.6rem; flex-wrap:wrap; }
.turno-topbar .btn-sm { padding:0.35rem 0.9rem; font-size:0.9rem; }
/* Grid 1/3 - 2/3 para a página de detalhes do combate */
/* Sidebar é position:fixed, então não afeta o layout normal do grid */
.combate-layout-grid { 
  display:grid; 
  grid-template-columns: 600px 1fr; 
  column-gap:3rem; 
  row-gap:2.2rem; 
  align-items:start; 
  width: 100%;
  box-sizing: border-box;
}
.combate-col-left, .combate-col-right { min-width:0; }
/* Garante que a coluna esquerda nunca seja coberta visualmente */
.combate-col-left { max-width:600px; position:relative; overflow:clip; }
/* Mantém a coluna direita contida no grid sem invadir a esquerda */
.combate-col-right { position:relative; overflow:clip; }
/* Os cards/áreas dentro da coluna direita nunca excedem o espaço disponível */
.combate-col-right > * { max-width:100%; min-width:0; }
.combate-col-right .mapa-area { width:100%; }
.combate-col-right .combate-card { width:100%; box-sizing:border-box; }
/* Mantém o form de upload do mapa responsivo sem ultrapassar a coluna */
.combate-col-right .mapa-upload-form { width:min(100%, 640px); }
@media (max-width: 1180px){
  .combate-layout-grid { grid-template-columns: 1fr; }
  .combate-col-left { max-width:none; }
}
.personagens-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:0.8rem 1rem; }
.personagem-check { background:#1e1e1e; border:1px solid #333; padding:0.65rem 0.75rem; border-radius:0.7rem; display:flex; flex-direction:column; gap:0.25rem; cursor:pointer; font-size:0.9rem; }
.personagem-check input { margin-right:0.4rem; }
.personagem-check:hover { border-color:var(--gold); }
.personagem-nome { font-weight:600; color:var(--gold); }
.personagem-prontidao { font-size:0.72rem; text-transform:uppercase; letter-spacing:0.5px; color:#bbb; }
.combate-form-acoes { display:flex; justify-content:flex-end; }
.combates-list { list-style:none; margin:0 0 1.4rem 0; padding:0; display:flex; flex-direction:column; gap:0.9rem; }
.combate-item { background:var(--card-bg); border:1px solid #333; padding:0.95rem 1.2rem; border-radius:var(--border-radius); display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:0.8rem; box-shadow:var(--card-shadow); }
.combate-item:hover { border-color:var(--gold); box-shadow:0 6px 18px rgba(230,194,0,0.12); }
.combate-id { font-size:0.9rem; font-weight:700; background:#1c1c1c; padding:0.3rem 0.6rem; border-radius:0.5rem; }
.combate-data { font-size:0.75rem; color:#bbb; margin-left:0.5rem; }
.combate-item-info { display:flex; align-items:center; }
.combate-item-acoes { display:flex; gap:0.6rem; }
.combate-novo-wrap { display:flex; justify-content:flex-end; }
.combate-inline-form { display:flex; align-items:center; gap:0.7rem; margin:0.8rem 0 0.2rem 0; flex-wrap:wrap; }
.combate-flex-form { display:flex; gap:0.7rem; flex-wrap:wrap; align-items:flex-end; margin-bottom:0.8rem; }
.combate-section-title { margin:2rem 0 0.8rem 0; font-size:1.4rem; }
.mapa-header-row { display:flex; align-items:center; justify-content:space-between; gap:0.8rem; margin:2rem 0 0.8rem 0; }
.mapa-header-row .combate-section-title { margin:0; }
.mapa-header-actions { display:flex; align-items:center; gap:0.5rem; }
#combate-content .combat-log-actions-row {
  display:flex;
  justify-content:flex-end;
  align-items:center;
  min-height:0;
  margin:0 0 0.5rem 0;
  padding:0;
}
#combate-content .combat-log-actions-row .combate-inline-form { margin:0; }
.select-sm { max-width:180px; width:180px; padding:0.25rem 0.6rem; font-size:0.9rem; }
.sr-only { position:absolute !important; width:1px !important; height:1px !important; padding:0 !important; margin:-1px !important; overflow:hidden !important; clip:rect(0,0,0,0) !important; white-space:nowrap !important; border:0 !important; }
.turno-ativo-banner { background:#1c2833; border-left:4px solid var(--accent); padding:0.6rem 0.9rem; border-radius:0.4rem; margin:1rem 0 1rem 0; font-size:0.95rem; letter-spacing:0.3px; }
.ataque-card { display:flex; flex-direction:column; gap:0.7rem; width:100%; max-width:none; }
.select-md, .multiselect-alvos { max-width:300px; }
.combate-col-left { display:flex; flex-direction:column; align-items:stretch; }
.combate-col-left .combate-card,
.combate-col-left .combate-inline-form,
.combate-col-left .combate-flex-form { width:100%; }
.combate-col-left .select-md,
.combate-col-left .multiselect-alvos { max-width:100%; width:100%; }
/* Perícia e Característica em uma linha com botão */
#form-pericia.combate-inline-form, #form-caracteristica.combate-inline-form { flex-wrap: nowrap; align-items: flex-end; }
#form-pericia .select-md, #form-caracteristica .select-md { flex: 0 0 300px; width: 300px; max-width: 300px; }
#form-pericia label, #form-caracteristica label { margin: 0 0.5rem 0 0; }
#form-pericia .btn, #form-caracteristica .btn { white-space: nowrap; }
@media (max-width: 560px){
  #form-pericia .select-md, #form-caracteristica .select-md { flex: 1 1 auto; width: auto; max-width: 100%; }
}
/* Linha do topo: select de personagem + Rolar d20 */
.acao-top-row { display:flex; align-items:center; gap:0.7rem; margin:0.2rem 0 0.8rem 0; }
.combate-col-left .acao-top-row .select-md { flex:1 1 320px; max-width:480px; }
@media (max-width: 640px){
  .acao-top-row { flex-direction:column; align-items:stretch; }
  .acao-top-row .select-md { max-width:100%; flex:1 1 auto; }
  .acao-top-row .btn { align-self:flex-end; }
}
/* Linhas alinhadas: label | select | botão */
.acao-row { display:grid; grid-template-columns: max-content auto max-content; gap:0.8rem; align-items:center; }
.acao-row label { margin:0; }
.acao-row .select-md { width:300px; max-width:100%; }
.acao-row .btn { justify-self:end; }
@media (max-width: 680px){
  .acao-row { grid-template-columns: 1fr; }
  .acao-row .btn { justify-self:end; }
  .acao-row .select-md { width:100%; }
}
.multiselect-alvos { min-height:120px; }
.form-gap { margin-top:0.6rem; }
.turnos-list { list-style:none; margin:0 0 1.6rem 0; padding:0; display:flex; flex-direction:column; gap:0.6rem; max-width:none; width:100%; }
.turno-item { background:#1e1e1e; border:1px solid #2e2e2e; border-radius:0.6rem; padding:0.65rem 0.85rem; font-size:0.85rem; }
.turno-item.ativo { border-color:var(--gold); box-shadow:0 0 0 1px var(--gold) inset; }
.turno-header { display:flex; flex-wrap:wrap; gap:0.6rem; align-items:center; margin-bottom:0.25rem; }
.turno-data { font-size:0.68rem; letter-spacing:0.5px; background:#151515; padding:0.25rem 0.5rem; border-radius:0.5rem; color:#bbb; }
.turno-desc { line-height:1.3; }
.turno-desc .hist-acao { padding:6px 10px; border-left:3px solid #3a3a3a; border-radius:6px; }
.turno-desc .hist-acao:nth-child(odd) { background:#191919; }
.turno-desc .hist-acao:nth-child(even) { background:#141414; }
.turno-desc .hist-acao + .hist-acao { margin-top:6px; }
.hist-tag { display:inline-block; font-size:0.68rem; text-transform:uppercase; letter-spacing:0.5px; font-weight:800; padding:0.16rem 0.45rem; border-radius:0.55rem; background:#2a2a2a; color:#ddd; margin-right:6px; position:relative; top:-1px; }
.hist-tag.tag-sustentado { background:#1f2a1f; color:#bfe8c0; }
.hist-tag.tag-concentracao { background:#2a1f1f; color:#f1b7b7; }
.hist-tag.tag-encadeado { background:#1f2430; color:#b7c9f1; }
.hist-key { font-weight:700; color:var(--gold); }
.hist-key.dano { color:#ffb3b3; }
.hist-key.aflicao { color:#c5e1ff; }
.hist-num { font-weight:800; color:#fff; }
/* Collapsible rounds */
.turno-item.collapsed .turno-desc { display:none; }
.turno-item .turno-header { position:relative; padding-right:22px; }
.turno-item .turno-header::after { content:'▾'; position:absolute; right:0; top:50%; transform:translateY(-50%); opacity:0.6; }
.turno-item.collapsed .turno-header::after { content:'▸'; }
.historico-scroll { overflow-y:auto; }
.mapa-area { position:relative; width:100%; max-width:100%; height:75vh; border:1px solid #333; border-radius:0.6rem; overflow:auto; background:#111; margin:0 0 1.2rem 0; box-shadow:0 4px 14px #000a; }
/* Histórico: altura estável baseada no viewport, independente do status à direita */
#historico-card { max-height: 70vh; overflow-y: auto; }
@media (max-width: 1180px){
  #historico-card { max-height: none; overflow-y: visible; }
}
/* A área real do mapa (tamanho natural da imagem) */
.mapa-canvas { position: relative; display:inline-block; }
/* Transform origin at top-left for predictable scaling */
.mapa-canvas { transform-origin: 0 0; }
/* Renderiza o mapa em tamanho natural para permitir scroll */
.mapa-img { display:block; max-width:none; height:auto; width:auto; position: relative; z-index:1; }

/* Zoom controls overlay */
.mapa-zoom { position:absolute; top:8px; left:8px; z-index:5; display:flex; gap:6px; }
.mapa-zoom .btn { padding:4px 8px; line-height:1; }
.mapa-token {
  position: absolute;
  width: 40px;
  height: 40px;
  cursor: move;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #000b, 0 2px 6px #000c;
  z-index: 100;
  overflow: hidden; /* impede a imagem de sair das bordas do token */
}
.mapa-token.token-fallback { background:#555; display:flex; align-items:center; justify-content:center; font-size:0.8rem; font-weight:700; color:#fff; letter-spacing:0.5px; }
.mapa-remover-form { position:absolute; top:6px; right:6px; }
.mapa-upload-form { max-width:640px; }
/* Linha única para seleção de mapa + botões */
.mapa-row { display:grid; grid-template-columns:max-content minmax(220px, 1fr) max-content max-content; gap:0.8rem; align-items:end; margin-bottom:0.6rem; }
.mapa-row label { margin:0; align-self:center; }
.mapa-row .select-md { width:100%; max-width:100%; }
@media (max-width:800px){
  .mapa-row { grid-template-columns:1fr; }
  .mapa-row .btn { justify-self:end; }
}
@media (max-width:820px){
  .mapa-area { width:100%; height:320px; }
  .ataque-card { max-width:100%; }
  .turnos-list { max-width:100%; }
  .select-md, .multiselect-alvos { max-width:100%; }
}

/* ================= Mapas (globais e adição) ================= */
.mapas-center { width:100%; max-width:1400px; margin:0 auto 2.5rem auto; padding:1.5rem 2rem 2.8rem 2rem; box-sizing:border-box; display:flex; flex-direction:column; align-items:center; }
.mapas-header { width:100%; max-width:980px; display:flex; flex-direction:column; align-items:center; gap:0.9rem; margin-bottom:1.6rem; text-align:center; }
.mapas-header .btn { align-self:center; margin-top:0.2rem; }
/* Ajuste da lista para centralizar linhas com poucos itens */
.mapas-list { list-style:none; margin:0; padding:0; width:100%; max-width:1100px; display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,300px)); gap:1.25rem 1.25rem; justify-content:center; }
.mapa-item { background:var(--card-bg); border:1px solid #333; border-radius:var(--border-radius); padding:0.9rem 1rem 1rem 1rem; display:flex; flex-direction:column; gap:0.7rem; position:relative; box-shadow:var(--card-shadow); width:100%; max-width:300px; margin:0 auto; }
.mapa-item:hover { border-color:var(--gold); box-shadow:0 8px 24px rgba(230,194,0,0.12); }
.mapa-thumb-wrapper { width:100%; aspect-ratio:4/3; background:#151515; border:1px solid #222; border-radius:0.6rem; overflow:hidden; display:flex; align-items:center; justify-content:center; }
.mapa-thumb { width:100%; height:100%; object-fit:cover; display:block; }
.mapa-thumb.placeholder { font-size:0.75rem; color:#777; font-weight:600; letter-spacing:1px; }
.mapa-info { display:flex; flex-direction:column; gap:0.6rem; }
.mapa-info-top { display:flex; flex-direction:column; gap:0.3rem; }
.mapa-nome { font-size:1rem; color:var(--gold); letter-spacing:0.5px; }
.mapa-data { font-size:0.65rem; text-transform:uppercase; letter-spacing:0.6px; background:#1c1c1c; padding:0.3rem 0.55rem; border-radius:0.55rem; align-self:flex-start; color:#bbb; }
.mapa-remover-form { margin:0; }
.mapa-form-card { max-width:560px; margin-left:auto; margin-right:auto; }
.mapa-form { display:flex; flex-direction:column; gap:0.7rem; }
.mapa-form-acoes { display:flex; justify-content:flex-end; }
@media (max-width:640px){
  .mapas-list { grid-template-columns:repeat(auto-fit,minmax(180px,240px)); }
}

/* Botões/acões em tabela de participantes */
.btn-link-ficha { display:inline-block; padding:0.35rem 0.7rem; font-size:0.7rem; font-weight:600; letter-spacing:0.5px; text-transform:uppercase; background:#1e1e1e; border:1px solid #3a3a3a; border-radius:0.55rem; color:var(--gold) !important; text-decoration:none; transition:background var(--transition), color var(--transition), border var(--transition), box-shadow var(--transition); }
.btn-link-ficha:hover { background:var(--gold); color:var(--text-dark) !important; border-color:var(--gold); box-shadow:0 4px 14px rgba(230,194,0,0.18); }
.form-remover-participante { display:inline; margin:0; padding:0; }
.btn-remover-participante { background:#7a2323; color:#fff !important; border:none; padding:0.35rem 0.8rem; font-size:0.7rem; font-weight:600; letter-spacing:0.5px; text-transform:uppercase; border-radius:0.55rem; cursor:pointer; transition:background var(--transition), box-shadow var(--transition); box-shadow:0 2px 6px rgba(0,0,0,0.3); }
.btn-remover-participante:hover { background:#c53131; box-shadow:0 4px 16px rgba(197,49,49,0.4); }

/* ================= Ficha de Personagem ================= */
.ficha-center { width:100%; max-width:1500px; margin:0 auto 3rem auto; padding:1.4rem 2rem 2.5rem 2rem; box-sizing:border-box; }
.ficha-header { display:flex; gap:1.8rem; align-items:flex-start; flex-wrap:wrap; margin-bottom:1.8rem; }
.ficha-foto-wrap { width:160px; height:160px; border:2px solid #333; border-radius:12px; overflow:hidden; box-shadow:0 4px 14px #000a; background:#111; }
.ficha-foto { width:100%; height:100%; object-fit:cover; display:block; }
.ficha-header-info { display:flex; flex-direction:column; gap:0.8rem; }
.ficha-title { margin:0; font-size:2.4rem; line-height:1.1; }
.ficha-meta { display:flex; gap:0.6rem; flex-wrap:wrap; }
.ficha-meta .badge { background:#1c1c1c; color:var(--gold); border:1px solid #444; }
.ficha-sections-grid { display:grid; gap:1.5rem; grid-template-columns: 1fr; align-items:stretch; }
.ficha-card { background:var(--card-bg); border-radius:var(--border-radius); border:1px solid #333; box-shadow:var(--card-shadow); padding:1.1rem 1.3rem 1.2rem 1.3rem; display:flex; flex-direction:column; gap:0.7rem; position:relative; }
.ficha-section-title { margin:0; font-size:1.25rem; letter-spacing:0.5px; }
.ficha-subtitle { margin:1.1rem 0 0.4rem 0; font-size:1.05rem; color:var(--gold); }
.ficha-list { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:0.35rem; font-size:0.9rem; }
.ficha-list.cols-2 li, .ficha-list.cols-3 li { display:grid; gap:0.4rem 0.6rem; align-items:center; }
.ficha-list.cols-2 li { grid-template-columns:1fr auto; }
.ficha-list.cols-3 li { grid-template-columns:1fr auto; }
.ficha-list .lbl { font-weight:600; color:var(--gold); }
.ficha-list .val { font-weight:500; text-align:right; }
.ficha-list .desc { color:#bbb; font-weight:400; }
.ficha-list .item-origem { color:var(--gold); font-weight:600; }
.ficha-inventario { grid-column:1 / -1; }
.ficha-moedas { margin-bottom:0.8rem; }
.ficha-inv-tabela-wrapper { max-height:300px; overflow:auto; border:1px solid #333; border-radius:0.6rem; background:#151515; }
.ficha-inv-tabela { border-collapse:collapse; width:100%; font-size:0.85rem; }
.ficha-inv-tabela th, .ficha-inv-tabela td { padding:0.55rem 0.7rem; border:1px solid #333; text-align:left; }
.ficha-inv-tabela th { position:sticky; top:0; background:#232323; z-index:2; }
.ficha-inv-tabela a { color: var(--gold); text-decoration: none; font-weight: 600; }
.ficha-inv-tabela a:hover, .ficha-inv-tabela a:focus { color: #fff; text-decoration: underline; }
.ficha-acoes { display:flex; gap:0.8rem; justify-content:flex-end; margin-top:2rem; }
@media (max-width:860px){
  .ficha-sections-grid { grid-template-columns: 1fr; }
  .ficha-title { font-size:2rem; }
  .ficha-foto-wrap { width:140px; height:140px; }
}
@media (max-width:560px){
  .ficha-header { flex-direction:column; align-items:center; text-align:center; }
  .ficha-header-info { align-items:center; }
  .ficha-acoes { justify-content:center; flex-wrap:wrap; }
}

/* NAVBAR E DROPDOWNS */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--secondary-bg);
  padding: 0 2rem;
  height: 64px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-bar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.85rem;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-toggle:hover,
.nav-toggle:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--gold);
  color: var(--gold);
}

.nav-group {
  display: flex;
  align-items: center;
  height: 64px;
  gap: 0.5rem;
}

.nav-bar .nav-group > a,
.nav-bar .dropbtn {
  color: var(--text-main) !important;
  background: none;
  border: none;
  font-size: 1.1rem;
  font-weight: 500;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  cursor: pointer;
  text-decoration: none;
  outline: none;
  min-width: 120px;
  box-sizing: border-box;
  background-clip: padding-box;
}

.nav-bar .nav-group > a:hover,
.nav-bar .dropbtn:hover,
.nav-bar .dropbtn:focus {
  background: var(--accent);
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(197,49,49,0.18);
}

.dropdown {
  position: relative;
  display: flex;
  align-items: center;
  height: 64px;
}

.dropdown .dropbtn {
  width: 100%;
}

.dropdown-content {
  display: none;
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  background: var(--secondary-bg);
  min-width: 180px;
  max-width: calc(100vw - 2rem);
  box-shadow: var(--card-shadow);
  border-radius: var(--border-radius);
  z-index: 200;
  margin-top: 0.4rem;
  overflow: hidden;
  padding-top: 0.4rem;
}

.nav-group > .dropdown:first-child .dropdown-content {
  left: 0;
  transform: none;
}

/* Centralizar mensagem da home */
.home-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 40vh;
  text-align: center;
}

.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content,
.dropdown.desktop-open .dropdown-content {
  display: block;
}

.dropdown-content a {
  color: var(--text-main) !important;
  padding: 0.75rem 1.25rem;
  display: block;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.dropdown-content a:hover {
  background: var(--accent);
  color: #fff !important;
}

.dropdown-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 0.5rem 0;
}

.dropdown-subtitle {
  color: rgba(255, 255, 255, 0.5);
  padding: 0.5rem 1.25rem 0.3rem;
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  pointer-events: none;
  cursor: default;
}

.logout-form button {
  background: var(--accent);
  color: #fff !important;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.5rem 1.2rem;
  font-weight: 600;
  margin-left: 1rem;
  transition: background var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 8px rgba(197,49,49,0.12);
}

.logout-form {
  margin: 0;
}

.logout-form button:hover {
  background: var(--gold);
  color: var(--text-dark) !important;
}

.sidebar {
  position: fixed;
  left: 0;
  top: 64px;
  width: 320px;
  height: calc(100vh - 64px);
  background: var(--card-bg);
  box-shadow: 2px 0 12px rgba(0,0,0,0.18);
  border-radius: 0 16px 16px 0;
  padding: 2rem 1.2rem 6.5rem 1.2rem; /* larger bottom padding so sticky buttons are never cut */
  color: var(--text-main);
  overflow-y: auto;
  overscroll-behavior: contain; /* prevent page scroll hijacking */
  -webkit-overflow-scrolling: touch; /* smooth on mobile */
  scrollbar-gutter: stable; /* avoid layout shift with scrollbar */
  z-index: 90;
  transition: left 0.3s cubic-bezier(.4,0,.2,1), width 0.3s cubic-bezier(.4,0,.2,1);
}
.sidebar.closed {
  left: 0;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
  overflow: hidden;
}
.sidebar.closed > *:not(.sidebar-toggle) {
  display: none !important;
}
.sidebar.closed .sidebar-toggle {
  display: flex !important;
}
.sidebar .sidebar-toggle {
  position: fixed; /* stay visible while scrolling the sidebar */
  left: 352px; /* move further outside to avoid overlapping the title */
  top: 84px; /* below navbar */
  width: 36px;
  height: 36px;
  background: var(--secondary-bg);
  color: var(--gold);
  border: none;
  border-radius: 0 18px 18px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  cursor: pointer;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: left 0.3s cubic-bezier(.4,0,.2,1), top 0.2s;
}

/* When the sidebar is collapsed to mini width */
.sidebar.closed .sidebar-toggle { left: 8px; border-radius: 18px; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 18, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 120;
}

.sidebar-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

body.sidebar-overlay-active {
  overflow: hidden;
}

@media (max-width: 1180px) {
  .sidebar {
    --sidebar-mobile-width: min(320px, calc(100vw - 56px));
    height: calc(100dvh - 64px);
    max-height: calc(100dvh - 64px);
    width: var(--sidebar-mobile-width);
    max-width: var(--sidebar-mobile-width);
    padding-top: 4.5rem;
    padding-bottom: 6rem;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    z-index: 140;
  }

  .sidebar.closed {
    left: calc(-1 * var(--sidebar-mobile-width));
    width: var(--sidebar-mobile-width);
    min-width: var(--sidebar-mobile-width);
    max-width: var(--sidebar-mobile-width);
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .sidebar .sidebar-toggle,
  .sidebar.closed .sidebar-toggle {
    left: 12px;
    top: 76px;
    border-radius: 18px;
  }

  .sidebar:not(.closed) .sidebar-toggle {
    left: calc(var(--sidebar-mobile-width) + 12px);
    border-radius: 0 18px 18px 0;
  }
}

/* Sidebar readability: ensure links have high contrast and visited color isn't purple on dark bg */
.sidebar a { color: #e8e8ff !important; text-decoration: none; }
.sidebar a:visited { color: #cfd6ff !important; }
.sidebar a:hover, .sidebar a:focus { color: var(--gold) !important; text-decoration: underline; }
.sidebar ul, .sidebar ol { padding-left: 1.2rem; margin: 0.4rem 0 1rem 0; }
.sidebar li { color: var(--text-main); line-height: 1.35; }

/* If there are action buttons at the bottom, make them sticky so they are always reachable */
.sidebar .sidebar-actions-sticky { position: sticky; bottom: 8px; background: linear-gradient(180deg, transparent 0, rgba(0,0,0,0.25) 35%, var(--card-bg) 65%); padding-top: 0.6rem; padding-right: 14px; margin-top: 0.6rem; padding-bottom: 0.6rem; }
.sidebar .sidebar-actions-sticky .btn { width: 100%; margin: 0.4rem 0 0 0; display:block; box-sizing: border-box; }
/* As a safety net, kill any residual margins on buttons in the sidebar (inline styles or global rules) */
.sidebar .btn, .sidebar .button { margin-left: 0 !important; margin-right: 0 !important; max-width: 100%; }
/* Prevent global .btn margin-left from causing horizontal overflow inside the sidebar */
.sidebar .btn { margin-left: 0; }

.card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
  color: var(--text-main);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: 0 8px 32px rgba(230,194,0,0.12);
  transform: translateY(-2px) scale(1.01);
}

.btn, .button {
  background: var(--accent);
  color: #fff !important;
  border: none;
  border-radius: var(--border-radius);
  padding: 0.6rem 1.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), color var(--transition);
  box-shadow: 0 2px 8px rgba(197,49,49,0.12);
  text-decoration: none;
  display: inline-block;
}

.btn:hover, .button:hover {
  background: var(--gold);
  color: var(--text-dark) !important;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--gold);
  font-family: 'Georgia', 'Times New Roman', serif;
  font-weight: 700;
  letter-spacing: 1px;
}

input, select, textarea {
  background: #222;
  color: var(--text-main);
  border: 1px solid #444;
  border-radius: var(--border-radius);
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  font-size: 1rem;
  transition: border var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
  border: 1.5px solid var(--gold);
  box-shadow: 0 0 0 2px rgba(230,194,0,0.15);
  outline: none;
}

@media (max-width: 900px) {
  .nav-bar {
    height: auto;
    padding: 0.75rem 1rem;
    align-items: stretch;
    gap: 0.75rem;
  }
  .nav-toggle {
    display: inline-flex;
    align-self: flex-start;
  }
  .nav-bar-content {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    width: 100%;
  }
  .nav-bar.nav-open .nav-bar-content {
    display: flex;
  }
  .nav-group {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    gap: 0.35rem;
    width: 100%;
  }
  .nav-bar .nav-group > a,
  .nav-bar .dropbtn {
    width: 100%;
    min-width: 0;
    height: auto;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    border-radius: 0.85rem;
  }
  .dropdown {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: auto;
  }
  .dropdown-content {
    position: static;
    transform: none;
    min-width: 0;
    width: 100%;
    margin-top: 0.35rem;
    border-radius: 0.85rem;
  }
  .dropdown.mobile-open .dropdown-content {
    display: block;
  }
  .logout-form button {
    width: 100%;
    margin-left: 0;
  }
}

::-webkit-scrollbar {
  width: 8px;
  background: #222;
}
::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 8px;
}

/* ===== Custo por Poder (badge) ===== */
.poder-form { position: relative; }
.poder-custo-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  background: #1e1e1e;
  border: 1px solid #444;
  color: var(--gold);
  padding: 0.15rem 0.55rem;
  border-radius: 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
/* Small inline chip next to section titles (Características, Defesas, etc.) */
.section-cost-badge {
  display: inline-block;
  margin-left: 0.6rem;
  background: #1e1e1e;
  border: 1px solid #444;
  color: var(--gold);
  padding: 0.15rem 0.5rem;
  border-radius: 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.25;
  vertical-align: middle;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ---------------- Inventário largo dentro do form (criar/editar personagem) ---------------- */
.inventario-largo { width:100%; margin-top:1.5rem; background:transparent; padding:0 0 0.8rem 0; border-radius:0; box-shadow:none; display:flex; flex-direction:column; gap:0.8rem; }
.inventario-moedas-inline { font-weight:600; display:flex; flex-wrap:wrap; gap:1.2rem; align-items:center; }
.inventario-filtros { display:flex; flex-wrap:nowrap; gap:1.2rem; align-items:center; }
.check-inline { display:flex; align-items:center; gap:0.55rem; font-weight:600; white-space:nowrap; }
@media (max-width: 680px) { .inventario-filtros { flex-wrap:wrap; } }
.inventario-filtros input[type="text"] { flex:1 1 240px; min-width:200px; max-width:400px; }
.inventario-tabela-wrapper { max-height:350px; overflow-y:auto; border:1px solid #333; border-radius:0.4rem; background:#151515; }
.inventario-tabela { margin:0; table-layout:fixed; width:100%; }
.inventario-tabela th:nth-child(1), .inventario-tabela td:nth-child(1) { width:60px; max-width:60px; min-width:55px; text-align:center; }
.inventario-tabela th:nth-child(2), .inventario-tabela td:nth-child(2) { width:180px; min-width:150px; max-width:220px; }
.inventario-tabela th:nth-child(3), .inventario-tabela td:nth-child(3) { width:150px; min-width:130px; max-width:190px; }
.inventario-tabela th:nth-child(4), .inventario-tabela td:nth-child(4) { width:120px; min-width:110px; max-width:150px; }
.inventario-tabela th:nth-child(5), .inventario-tabela td:nth-child(5) { width:auto; }
.inventario-tabela th:nth-child(6), .inventario-tabela td:nth-child(6) { width:110px; max-width:130px; text-align:right; }
.inventario-largo input[type="text"] { width:auto; }
/* Fim do estilo D&D Beyond */
/* ====== Sidebar de Ações (apenas combate) ====== */
#combate-sidebar-acoes {
  --combat-sidebar-width: 320px;
  --combat-sidebar-toggle-top: 84px;
}

#combate-sidebar-mapa {
  --combat-sidebar-width: 320px;
  --combat-sidebar-toggle-top: 128px;
}

#combate-sidebar-tokens {
  --combat-sidebar-width: 320px;
  --combat-sidebar-toggle-top: 172px;
}

#combate-sidebar-notes {
  --combat-sidebar-width: min(420px, 92vw);
  --combat-sidebar-toggle-top: 216px;
}

.combate-sidebar-acoes {
  --combat-sidebar-width: 320px;
  --combat-sidebar-toggle-top: 84px;
  position: fixed;
  right: 0;
  top: 64px;
  width: var(--combat-sidebar-width);
  height: calc(100vh - 64px);
  background: var(--card-bg);
  box-shadow: -2px 0 12px rgba(0,0,0,0.18);
  border-radius: 16px 0 0 16px;
  padding: 2rem 1.2rem 6.5rem 1.2rem;
  color: var(--text-main);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
  z-index: 260;
  transition: right 0.3s cubic-bezier(.4,0,.2,1), width 0.3s cubic-bezier(.4,0,.2,1);
}

.combate-sidebar-acoes.closed {
  right: calc(-1 * var(--combat-sidebar-width));
  width: var(--combat-sidebar-width);
  min-width: var(--combat-sidebar-width);
  max-width: var(--combat-sidebar-width);
  padding-left: 1.2rem;
  padding-right: 1.2rem;
  overflow: hidden;
}

.combate-sidebar-acoes.closed > *:not(.sidebar-toggle) {
  display: none !important;
}

.combate-sidebar-acoes.closed .sidebar-toggle {
  display: flex !important;
}

.combate-sidebar-acoes .sidebar-toggle {
  position: fixed;
  right: calc(var(--combat-sidebar-width) + 32px);
  top: var(--combat-sidebar-toggle-top);
  width: 36px;
  height: 36px;
  background: var(--secondary-bg);
  color: var(--gold);
  border: none;
  border-radius: 18px 0 0 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  cursor: pointer;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 320;
  transition: right 0.3s cubic-bezier(.4,0,.2,1), top 0.2s;
}

.combate-sidebar-acoes.closed .sidebar-toggle {
  right: 8px;
  border-radius: 18px;
}

.combate-sidebar-acoes h3 {
  margin-top: 0;
  color: var(--gold);
}

.combate-sidebar-acoes .acao-top-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 1rem;
}

.combate-sidebar-acoes .acao-top-row select {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  height: auto;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  line-height: 1.3;
}
/* Evita que o select cresça verticalmente por causa da regra global
   .acao-top-row .select-md { flex: 1 1 320px } quando estamos no sidebar */
.combate-sidebar-acoes .acao-top-row .select-md {
  flex: 0 0 auto;
  max-width: 100%;
}


.combate-sidebar-acoes .acao-top-row form {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.combate-sidebar-acoes .dice-roll-form {
  gap: 6px;
}

.combate-sidebar-acoes .dice-roll-controls {
  display: grid;
  grid-template-columns: minmax(64px, 0.8fr) minmax(84px, 1fr) minmax(84px, 1fr);
  gap: 6px;
  width: 100%;
}

.combate-sidebar-acoes .dice-roll-controls input,
.combate-sidebar-acoes .dice-roll-controls select {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  height: auto;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  line-height: 1.3;
}

.combate-sidebar-acoes .acao-top-row button {
  width: 100%;
}

.combate-sidebar-acoes .ataque-card {
  padding: 1rem;
  margin-top: 1rem;
}

.combate-sidebar-acoes label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.combate-sidebar-acoes .acao-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.combate-sidebar-acoes .acao-row button {
  width: 100%;
}

@media (max-width: 1200px) {
  .combate-sidebar-acoes {
    --combat-sidebar-width: 280px;
    width: var(--combat-sidebar-width);
    padding: 1.5rem 1rem 6rem 1rem;
  }

  #combate-sidebar-notes {
    --combat-sidebar-width: min(420px, 92vw);
  }
}

@media (max-width: 1180px) {
  .combate-sidebar-acoes {
    --combat-sidebar-mobile-width: min(var(--combat-sidebar-width), calc(100vw - 56px));
    height: calc(100dvh - 64px);
    max-height: calc(100dvh - 64px);
    width: var(--combat-sidebar-mobile-width);
    max-width: var(--combat-sidebar-mobile-width);
    padding: 1.5rem 1rem 6rem 1rem;
    padding-top: 4.5rem;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    z-index: 260;
  }
  .combate-sidebar-acoes.closed {
    right: calc(-1 * var(--combat-sidebar-mobile-width));
    width: var(--combat-sidebar-mobile-width);
    min-width: var(--combat-sidebar-mobile-width);
    max-width: var(--combat-sidebar-mobile-width);
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .combate-sidebar-acoes .sidebar-toggle,
  .combate-sidebar-acoes.closed .sidebar-toggle {
    right: 12px;
    top: var(--combat-sidebar-toggle-top);
    border-radius: 18px;
    display: flex !important;
    visibility: visible;
    opacity: 1;
  }
  .combate-sidebar-acoes:not(.closed) .sidebar-toggle {
    right: calc(var(--combat-sidebar-mobile-width) + 12px);
    border-radius: 18px 0 0 18px;
  }
}

@media (max-width: 900px) {
  .auth-form-center,
  .sala-form-center,
  .personagem-form-center {
    min-height: auto;
    padding: 0 1rem 2rem;
    align-items: stretch;
  }
  .personagem-form-center > form {
    width: 100%;
  }
  .auth-form,
  .sala-form,
  .personagem-form-fields,
  .item-form-center {
    padding: 1.25rem;
  }
  .personagens-center,
  .salas-center,
  .mapas-center,
  .combate-center,
  .combate-detalhes-center,
  .ficha-center {
    padding: 1rem;
  }
  .personagens-list {
    max-width: 100%;
  }
  .personagem-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .personagem-acoes {
    width: 100%;
    flex-wrap: wrap;
    white-space: normal;
  }
  .personagem-form-fields {
    max-width: 100%;
  }
  .personagem-form-fields > div > label {
    min-width: 0;
  }
  .personagem-form-fields .resistencias-grid {
    gap: 0.75rem 1rem;
  }
  .linha-topo {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1rem !important;
  }
  .linha-topo > * {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  .caracteristicas-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr)) !important;
    gap: 1rem 1rem !important;
  }
  .defesas-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr)) !important;
    gap: 1rem 1rem !important;
  }
  .pericias-grid-4 {
    grid-template-columns: repeat(2, minmax(140px, 1fr)) !important;
    gap: 1rem 1rem !important;
  }
  .poder-form-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr)) !important;
    padding: 1rem !important;
    gap: 1rem !important;
  }
  .poder-form-grid > div,
  .personagem-form-fields input,
  .personagem-form-fields select,
  .personagem-form-fields textarea {
    min-width: 0;
  }
  .personagem-form-fields .inventario-moedas-inline {
    gap: 0.8rem;
  }
  .inventario-moedas-inline,
  .inventario-filtros,
  .personagem-form-btns {
    flex-wrap: wrap;
  }
  .inventario-filtros > * {
    flex: 1 1 220px;
    min-width: 0 !important;
    width: 100%;
  }
  .itens-area-responsive {
    padding: 0 0 1.5rem 0;
  }
  .itens-filtros {
    gap: 0.75rem;
  }
  .itens-filtros input,
  .itens-filtros select {
    min-width: 0;
    max-width: none;
    flex: 1 1 100%;
  }
  .mapa-header-row {
    flex-direction: column;
    align-items: stretch;
  }
  .mapa-header-actions {
    flex-wrap: wrap;
    width: 100%;
  }
  .mapa-header-actions > * {
    flex: 1 1 160px;
    min-width: 0;
  }
  .select-sm {
    width: 100%;
    max-width: 100%;
  }
  #status-card {
    overflow-x: auto;
  }
  #tabela-participantes {
    min-width: 920px;
  }
  #tabela-participantes .acoes-participante {
    display: grid;
    grid-template-columns: repeat(4, minmax(48px, max-content));
    gap: 4px;
    align-items: stretch;
    justify-content: start;
    min-width: 320px;
  }
  #tabela-participantes .acoes-participante .form-acao-participante {
    display: block !important;
    margin: 0 !important;
  }
  #tabela-participantes .acoes-participante .btn-acao-mini,
  #tabela-participantes .acoes-participante .btn-acao-small {
    width: 100%;
  }
}

@media (max-width: 1200px) {
  .personagem-form-fields .caracteristicas-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .personagem-form-fields .defesas-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .personagem-form-fields .defesas-grid > div:last-child {
    grid-column: 1 / -1;
  }

  .personagem-form-fields .pericias-grid-4 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 1.1rem 1rem !important;
  }

  .personagem-form-fields .inventario-filtros {
    flex-wrap: wrap;
  }

  .personagem-form-fields .inventario-filtros > * {
    flex: 1 1 220px;
    min-width: 0;
  }
}

@media (max-width: 1024px) {
  .personagem-form-fields .pericias-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  .personagem-form-title,
  .personagens-title,
  .combate-title,
  .ficha-title,
  .salas-title {
    font-size: clamp(1.7rem, 7vw, 2.2rem);
  }
  .auth-form button[type="submit"],
  .personagem-form-center .btn,
  .personagem-form-fields .btn,
  .sala-form .btn,
  .item-form-center button[type="submit"] {
    width: 100%;
    align-self: stretch;
    text-align: center;
  }
  .personagem-form-btns {
    flex-direction: column;
  }
  .caracteristicas-grid,
  .defesas-grid,
  .pericias-grid-4,
  .poder-form-grid {
    grid-template-columns: 1fr !important;
  }
  .poder-form-grid .somar-forca-wrap,
  .linha-ataque-info {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  .poder-form-grid .somar-forca-wrap .somar-forca-right {
    margin-left: 0;
    white-space: normal;
  }
  .section-cost-badge {
    margin: 0.5rem 0 0;
  }
  #badge-pod {
    display: block;
    width: 100%;
    margin-left: 0;
    font-size: 0.78rem;
  }
  .poder-form-grid .poder-custo-detalhe {
    text-align: left !important;
    font-size: 0.76rem !important;
  }
  .personagem-form-fields .resistencias-grid {
    grid-template-columns: minmax(132px, 1fr) minmax(72px, auto) minmax(72px, auto);
    gap: 0.65rem 0.75rem;
    font-size: 0.95rem;
  }
  .personagem-form-fields .inventario-moedas-inline input,
  .personagem-form-fields .inventario-filtros > * {
    flex-basis: 100%;
    max-width: 100%;
    width: 100%;
  }
  #tabela-participantes .acoes-participante {
    grid-template-columns: repeat(2, minmax(72px, 1fr));
    min-width: 180px;
  }
}

/* Estilos para botões de ação nos participantes */
.acoes-participante {
  display: flex;
  flex-direction: row;
  gap: 1px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  height: auto;
  min-height: 28px;
  line-height: 28px;
  max-height: none;
  overflow: visible;
}

.form-acao-participante {
  display: inline-flex !important;
  margin: 0 !important;
  padding: 0 !important;
  vertical-align: middle !important;
}

.acoes-coluna {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin: 0;
  padding: 0;
}

.btn-acao-mini {
  padding: 0 3px;
  font-size: 0.7rem;
  min-width: 28px;
  border: 1px solid #444;
  background: #2a2a2a;
  color: #ddd;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  line-height: 1;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  flex-shrink: 0;
  vertical-align: middle;
}

.btn-acao-mini:hover {
  background: #3a3a3a;
  border-color: var(--gold);
  transform: translateY(-1px);
}

.btn-acao-mini.btn-success {
  background: #1f4d1f;
  border-color: #2d6b2d;
  color: #a8f3a8;
}

.btn-acao-mini.btn-success:hover {
  background: #2d6b2d;
  border-color: #3d8b3d;
}

.btn-acao-mini.btn-danger {
  background: #4d1f1f;
  border-color: #6b2d2d;
  color: #f3a8a8;
}

.btn-acao-mini.btn-danger:hover {
  background: #6b2d2d;
  border-color: #8b3d3d;
}

.btn-acao-small {
  padding: 0 3px;
  font-size: 0.75rem;
  border: 1px solid #444;
  background: #2a2a2a;
  color: #ddd;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  line-height: 1;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  flex-shrink: 0;
  vertical-align: middle;
}

.btn-acao-small:hover {
  background: #3a3a3a;
  border-color: var(--gold);
  transform: translateY(-1px);
}

.btn-acao-small.btn-warning {
  background: #4d3d1f;
  border-color: #6b562d;
  color: #f3d8a8;
}

.btn-acao-small.btn-warning:hover {
  background: #6b562d;
  border-color: #8b763d;
}

.btn-acao-small.btn-info {
  background: #1f3d4d;
  border-color: #2d566b;
  color: #a8d8f3;
}

.btn-acao-small.btn-info:hover {
  background: #2d566b;
  border-color: #3d768b;
}

@media (min-width: 901px) {
  #tabela-participantes {
    margin: 0 auto;
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
  }

  #tabela-participantes th,
  #tabela-participantes td {
    border: 1px solid #444;
    text-align: center;
    vertical-align: middle;
    min-height: 28px;
    padding: 0.2rem 0.4rem;
    line-height: 1.15;
    box-sizing: border-box;
  }

  #tabela-participantes th {
    padding: 0.35rem 0.4rem;
    line-height: 1.1;
  }

  #tabela-participantes td.acoes-participante {
    text-align: left;
    padding: 0.2rem;
    min-width: 420px;
    overflow: hidden;
    vertical-align: middle;
    white-space: nowrap;
    box-sizing: border-box;
    line-height: 1;
    font-size: 0;
  }
}

@media (max-width: 900px) {
  #status-card {
    overflow-x: visible;
  }
}

@media (max-width: 900px) {
  .acoes-btn-group {
    flex-wrap: wrap;
  }
}

/* Seção de participantes centralizada abaixo do grid */
.participantes-section-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 2rem;
  padding: 0 1rem;
  box-sizing: border-box;
}

.participantes-section {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 1000px) {
  .participantes-section-wrapper {
    margin-top: 1.5rem;
  }
}

/* ================= Tokens (biblioteca global) ================= */
.token-library-center {
  text-align: center;
}

.token-library-header {
  align-items: center;
}

.token-library-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 1100px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 240px));
  gap: 1.25rem;
  justify-content: center;
  justify-items: center;
}

.token-library-card {
  background: var(--card-bg);
  border: 1px solid #333;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  box-sizing: border-box;
  width: 100%;
  max-width: 240px;
  min-height: 170px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  text-align: center;
}

.token-library-card:hover {
  border-color: var(--gold);
  box-shadow: 0 8px 24px rgba(230,194,0,0.12);
}

.token-library-thumb-wrapper {
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.token-library-thumb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
}

.token-library-thumb.token-fallback {
  position: static;
  cursor: default;
}

.token-library-name {
  color: var(--gold);
  overflow-wrap: anywhere;
}

.token-library-size {
  font-size: 0.8rem;
  color: #bbb;
}

.token-form-card {
  width: min(100%, 560px);
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

.token-form-actions {
  justify-content: center;
}

.token-library-back {
  margin-top: 1rem;
  text-align: center;
}


.combate-sidebar-notes {
  width: var(--combat-sidebar-width);
  overflow-y: auto;
}

.notes-drawer-section {
  border-top: 1px solid rgba(255,255,255,0.12);
  margin-top: 0.8rem;
  padding-top: 0.8rem;
}

.notes-drawer-section h4 {
  margin: 0 0 0.5rem;
}

.notes-form,
.notes-inline-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.notes-form input,
.notes-form textarea,
.notes-form select,
.notes-inline-form input {
  width: 100%;
}

.note-card {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
  margin-bottom: 0.55rem;
  padding: 0.55rem;
}

.note-card summary {
  cursor: pointer;
}

.note-badge,
.note-owner {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  font-size: 0.78rem;
}

.notes-actions-row {
  display: flex;
  gap: 0.4rem;
}

/* Separa o botão Salvar (edit form) do Excluir (delete form) dentro do card */
.note-card .note-edit-form {
  margin-bottom: 0.6rem;
}

.note-card .note-edit-form + .notes-inline-form {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.notes-empty {
  opacity: 0.75;
  font-style: italic;
}
