/* ============================================================
   DICE ROLLER — dice-roller.css
   Requer: Google Fonts Cinzel
   <link href="https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&display=swap" rel="stylesheet">
   ============================================================ */

/* ---------- Octógono: clip-path reutilizado ---------- */
/* 8 pontos simétricos formando octógono regular */
:root {
  --oct: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

/* ---------- Modal overlay ---------- */
.modal#diceModal {
  display: none;
}
.modal#diceModal[aria-hidden="false"] {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 2000;
}

/* ---------- Painel principal ---------- */
.dice-modal-content {
  width: min(860px, 96%);
  background: linear-gradient(145deg, #0d1018 0%, #161a26 50%, #0d1018 100%);
  border: 1px solid rgba(201, 169, 110, 0.3);
  border-radius: 6px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 60px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(201, 169, 110, 0.15);
}
.dice-modal-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='80' height='80' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M40 0L80 40L40 80L0 40Z' fill='none' stroke='rgba(201,169,110,0.025)' stroke-width='0.5'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* ---------- Título ---------- */
.modal-title {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  font-weight: 600;
  color: #c9a96e;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 20px;
  text-shadow: 0 0 20px rgba(201, 169, 110, 0.3);
}
.modal-title::before,
.modal-title::after {
  content: ' ✦ ';
  opacity: 0.5;
  font-size: 0.65em;
}

/* ---------- Botão fechar ---------- */
.menu-close#closeDiceBtn {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: 1px solid rgba(201, 169, 110, 0.2);
  color: #c9a96e;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 3px;
  font-size: 14px;
  display: grid;
  place-items: center;
  transition: background 0.2s, border-color 0.2s;
}
.menu-close#closeDiceBtn:hover {
  background: rgba(201, 169, 110, 0.1);
  border-color: #c9a96e;
}

/* ---------- Layout principal: controles | resultados ---------- */
.dice-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 20px;
  align-items: start;
}

/* ---------- Coluna de controles ---------- */
.dice-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ctrl-label {
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(201, 169, 110, 0.55);
  margin-bottom: 5px;
}

/* ---------- Spinner de quantidade ---------- */
.qty-spinner {
  display: flex;
  align-items: center;
}
.qty-btn {
  width: 30px;
  height: 34px;
  background: #111520;
  border: 1px solid rgba(201, 169, 110, 0.25);
  color: #c9a96e;
  cursor: pointer;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}
.qty-btn:first-child { border-radius: 4px 0 0 4px; }
.qty-btn:last-child  { border-radius: 0 4px 4px 0; }
.qty-btn:hover {
  background: rgba(201, 169, 110, 0.1);
  color: #e8d5a3;
}
.qty-display {
  min-width: 44px;
  height: 34px;
  display: grid;
  place-items: center;
  background: #0a0c12;
  border-top: 1px solid rgba(201, 169, 110, 0.25);
  border-bottom: 1px solid rgba(201, 169, 110, 0.25);
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: #e8d5a3;
}

/* ---------- Layout losango ---------- */
.dice-diamond {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative; /* necessário para o SVG de linhas ficar dentro */
}
.diamond-row {
  display: flex;
  position: relative;
  z-index: 1; /* acima do SVG de linhas */
}
.diamond-row.center  { justify-content: center; }
.diamond-row.sides   { justify-content: space-between; }

/* ---------- Wrapper octógono (cria efeito de borda via drop-shadow) ---------- */
.die-oct-wrap {
  clip-path: var(--oct);
  filter: drop-shadow(0 0 0px 0px rgba(201,169,110,0))
          drop-shadow(0 0 3px rgba(201, 169, 110, 0.55))
          drop-shadow(0 0 6px rgba(201, 169, 110, 0.25))
          drop-shadow(0 2px 6px rgba(0, 0, 0, 0.8));
  transition: filter 0.2s;
}

/* wrapper do d20 — levemente maior */
.die-oct-wrap--d20 {
  filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.6))
          drop-shadow(0 0 10px rgba(139, 92, 246, 0.3))
          drop-shadow(0 2px 8px rgba(0, 0, 0, 0.85));
}

/* quando o botão dentro está ativo, o wrapper brilha */
.die-oct-wrap:has(.die-btn.active) {
  filter: drop-shadow(0 0 10px rgba(255, 210, 80, 1))
          drop-shadow(0 0 22px rgba(255, 190, 50, 0.7))
          drop-shadow(0 2px 8px rgba(0, 0, 0, 0.8));
}
.die-oct-wrap--d20:has(.die-btn.active) {
  filter: drop-shadow(0 0 12px rgba(180, 130, 255, 1))
          drop-shadow(0 0 28px rgba(139, 92, 246, 0.75))
          drop-shadow(0 2px 10px rgba(0, 0, 0, 0.85));
}

/* hover no wrapper */
.die-oct-wrap:hover {
  filter: drop-shadow(0 0 6px rgba(201, 169, 110, 0.75))
          drop-shadow(0 0 12px rgba(201, 169, 110, 0.3))
          drop-shadow(0 2px 8px rgba(0, 0, 0, 0.8));
}
.die-oct-wrap--d20:hover {
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.7))
          drop-shadow(0 0 14px rgba(139, 92, 246, 0.35))
          drop-shadow(0 2px 10px rgba(0, 0, 0, 0.85));
}

/* ---------- Botão de dado — FORMA OCTÓGONA ---------- */
.die-btn {
  clip-path: var(--oct);
  width: 50px;
  height: 50px;
  background: #1e2640;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: background 0.18s, transform 0.15s;
  position: relative;
}
.die-btn svg {
  display: block;
  transition: transform 0.15s;
  pointer-events: none;
}
.die-btn span {
  font-family: 'Cinzel', serif;
  font-size: 0.42rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(201, 169, 110, 0.4);
  pointer-events: none;
  line-height: 1;
}

/* hover no botão */
.die-btn:hover {
  background: #263050;
  transform: translateY(-2px);
}
.die-btn:hover svg { transform: scale(1.1); }

/* ativo */
.die-btn.active {
  background: #3a3010;
}
.die-btn.active span {
  color: #ffe066;
  font-weight: 700;
}

/* ---------- d20 — maior ---------- */
.die-btn--d20 {
  width: 70px;
  height: 70px;
}
.die-btn--d20 span {
  font-size: 0.52rem;
  color: rgba(139, 92, 246, 0.55);
}
.die-btn--d20.active {
  background: #2a1a4a;
}
.die-btn--d20.active span {
  color: #d0aaff;
  font-weight: 700;
}

/* animação de tremida */
.die-oct-wrap.shake {
  animation: oct-shake 0.4s ease;
}
@keyframes oct-shake {
  0%   { transform: translateX(0) rotate(0deg); }
  20%  { transform: translateX(-5px) rotate(-8deg); }
  40%  { transform: translateX(5px) rotate(8deg); }
  60%  { transform: translateX(-3px) rotate(-4deg); }
  80%  { transform: translateX(3px) rotate(4deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

/* ---------- SVG das linhas de conexão ---------- */
#diceConnectionLines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
}

/* ---------- Botões de ação ---------- */
.roll-actions {
  display: flex;
  gap: 7px;
}
.btn-roll {
  flex: 1;
  padding: 10px 0;
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #7a4f10, #c9a96e, #7a4f10);
  border: 1px solid #c9a96e;
  color: #1a0f00;
  cursor: pointer;
  border-radius: 3px;
  transition: opacity 0.2s, transform 0.1s;
  position: relative;
  overflow: hidden;
}
.btn-roll::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transition: left 0.5s;
}
.btn-roll:hover::after  { left: 150%; }
.btn-roll:hover         { opacity: 0.9; transform: translateY(-1px); }
.btn-roll:active        { transform: translateY(0); }
.btn-roll:disabled      { opacity: 0.4; cursor: not-allowed; }

.btn-clear {
  padding: 10px 12px;
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid rgba(201, 169, 110, 0.2);
  color: rgba(201, 169, 110, 0.45);
  cursor: pointer;
  border-radius: 3px;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
}
.btn-clear:hover {
  border-color: rgba(201, 169, 110, 0.4);
  color: #c9a96e;
  background: rgba(201, 169, 110, 0.04);
}

/* ---------- Painel de resultados ---------- */
.dice-results-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dice-stage {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(201, 169, 110, 0.07);
  border-radius: 4px;
  padding: 14px;
  min-height: 200px;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* estado vazio */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  opacity: 0.2;
  pointer-events: none;
}
.empty-state p {
  font-family: 'Cinzel', serif;
  font-size: 0.58rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #c9a96e;
}

/* overlay de rolagem */
.rolling-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 12, 18, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  border-radius: 4px;
}
.rolling-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* dado girando no overlay */
.tumbling-die {
  animation: tumble var(--dur, 0.5s) ease-in-out infinite;
  transform-origin: center;
  display: flex;
  align-items: center;
  justify-content: center;
  /* aplica octógono também nos dados do overlay */
  clip-path: var(--oct);
}
@keyframes tumble {
  0%   { transform: rotate(0deg)   scale(0.9); }
  30%  { transform: rotate(180deg) scale(1.12); }
  60%  { transform: rotate(360deg) scale(0.88); }
  100% { transform: rotate(720deg) scale(0.9); }
}

/* lista de resultados */
.results-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
}

/* dado resultado individual */
.result-die {
  flex: 1 1 calc(25% - 6px);
  max-width: calc(25% - 6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: scale(0);
  animation: pop-in 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  cursor: default;
}
@keyframes pop-in {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(1.15) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.result-die svg {
  display: block;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.55));
  transition: filter 0.15s;
}

.result-die .die-val {
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: #e8d5a3;
  line-height: 1;
}
.result-die.is-max svg {
  filter: brightness(1.25) drop-shadow(0 0 6px rgba(255,215,0,0.9));
}
.result-die.is-max .die-val {
  color: #fff176;
  text-shadow: 0 0 10px rgba(255,230,0,0.9), 0 0 20px rgba(255,200,0,0.5);
}
.result-die.is-min svg  { filter: grayscale(0.6) brightness(0.65); }
.result-die.is-min .die-val { color: rgba(201, 169, 110, 0.35); }

/* ---------- Resumo / total ---------- */
.results-summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(201, 169, 110, 0.1);
}
.summary-label {
  font-family: 'Cinzel', serif;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(201, 169, 110, 0.45);
}
.summary-total {
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #c9a96e;
  text-shadow: 0 0 18px rgba(201, 169, 110, 0.35);
}
.summary-breakdown {
  font-size: 0.8rem;
  color: rgba(201, 169, 110, 0.3);
  font-style: italic;
}

/* ---------- Responsivo ---------- */
@media (max-width: 600px) {
  .dice-grid { grid-template-columns: 1fr; }
}