/* =========================
   Dice Modal
========================= */

.dice-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 2000;
}

.dice-overlay.active {
  display: block;
}

.dice-panel {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 95%;
  max-width: 500px;
  max-height: 90vh;
  background: var(--surface);
  border: 2px solid var(--gold);
  border-radius: 24px;
  z-index: 2001;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  overflow: hidden;
}

.dice-panel.active {
  display: flex;
}

.dice-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.5rem 0.75rem 1.5rem;
  border-bottom: 1px solid rgba(212,175,55,0.3);
}

.dice-header h2 {
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 1.5rem;
  margin: 0;
}

.dice-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  padding: 0 0.5rem;
  line-height: 1;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.dice-close:hover {
  color: var(--gold);
}

.dice-body {
  color: var(--text);
  font-family: 'Crimson Text', serif;
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 80px);
  flex: 1;
}

.dice-buttons {
  display: flex;
  justify-content: space-around;
  gap: 0.7rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  -webkit-tap-highlight-color: transparent;
}

.dice-btn {
  text-align: center;
  flex: 1;
  min-width: 80px;
  -webkit-tap-highlight-color: transparent;
}

.dice-btn button {
  width: 100%;
  aspect-ratio: 1;
  background: var(--surface-light);
  border: 2px solid rgba(212, 175, 55, 0.3);
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--gold);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Cinzel', serif;
  -webkit-tap-highlight-color: transparent;
}

.dice-btn button:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

/* Área de ações */
.dice-actions {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
}

.dice-actions button {
  flex: 1;
  padding: 1rem;
  background: transparent;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 20px;
  font-weight: bold;
  font-size: 1rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Crimson Text', serif;
  -webkit-tap-highlight-color: transparent;
}

.dice-actions button:hover {
  background: var(--surface-light);
  border-color: var(--gold);
}

#roll-button {
  background: var(--gold);
  color: #1a1a1a;
  border-color: var(--gold);
  -webkit-tap-highlight-color: transparent;
}

#roll-button:hover {
  background: #e5c25c;
}

.dice-result {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: 12px;
  padding: 1.2rem;
  margin-bottom: 0.5rem;
  margin-top: 0.5rem;
}

.dice-result div {
  margin: 0.5rem 0;
  font-size: 1.1rem;
  color: var(--text);
}

#result-output, #total-output {
  font-weight: bold;
  color: var(--gold);
  margin-left: 0.5rem;
  font-family: 'Cinzel', serif;
}

.dice-history {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 175, 55, 0.15);
  border-radius: 12px;
  padding: 1.2rem;
}

.dice-history h3 {
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 0.5rem;
}

.dice-history ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
  max-height: 200px;
  overflow-y: auto;
}

.dice-history li {
  padding: 0.5rem 0;
  border-bottom: 1px dashed rgba(212, 175, 55, 0.2);
  font-family: 'Crimson Text', serif;
  color: var(--text);
  font-size: 1rem;
}

.dice-history li:last-child {
  border-bottom: none;
}

#clear-history {
  width: 100%;
  padding: 0.8rem;
  background: transparent;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 20px;
  color: var(--text);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Crimson Text', serif;
  -webkit-tap-highlight-color: transparent;
}

#clear-history:hover {
  background: var(--surface-light);
  border-color: var(--gold);
}

.dice-body::-webkit-scrollbar,
.dice-history ul::-webkit-scrollbar {
  width: 8px;
}

.dice-body::-webkit-scrollbar-track,
.dice-history ul::-webkit-scrollbar-track {
  background: rgba(212, 175, 55, 0.1);
  border-radius: 10px;
}

.dice-body::-webkit-scrollbar-thumb,
.dice-history ul::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 10px;
}

/* Alerta sem dados */
.empty-pool.warning {
  color: var(--gold);
  font-weight: bold;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 1rem;
}

/* Indicador de limite */
.dice-pool.full {
  border-color: #ff4444 !important;
  box-shadow: 0 0 10px rgba(255, 68, 68, 0.3);
}

/* Estilos para o pool de dados */
.dice-pool-container {
  margin-bottom: 0.5rem;
}

.dice-pool-container h3 {
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 0.5rem;
}

.dice-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 100px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  padding: 0.8rem;
}

.empty-pool {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  width: 100%;
  padding: 2rem;
}

/* Responsivo*/
@media (max-height: 700px) {
  .dice-panel { max-height: 95vh; }
  .dice-body { padding: 1rem; }
  .dice-buttons { margin-bottom: 0.8rem; gap: 0.5rem; }
  .dice-btn { 
    min-width: 0; 
    width: 50px; 
    flex: 0 0 auto; 
    -webkit-tap-highlight-color: transparent;
  }
  .dice-btn button { 
    font-size: 1.2rem; 
    width: 50px; 
    height: 50px; 
    -webkit-tap-highlight-color: transparent;
  }
  .dice-history ul { max-height: 150px; }
}

@media (max-width: 400px) {
  .dice-header h2 { font-size: 1.2rem; }
  .dice-buttons { gap: 0.5rem; }
  .dice-btn { 
    min-width: 0; 
    width: 60px; 
    flex: 0 0 auto; 
    -webkit-tap-highlight-color: transparent;
  }
  .dice-btn button { 
    font-size: 1.2rem; 
    width: 60px; 
    height: 60px; 
    -webkit-tap-highlight-color: transparent;
  }
}

/* Garantia de visibilidade sem scroll excessivo */
@media (max-height: 600px) {
  .dice-history ul { max-height: 100px; }
  .dice-actions button,
  #clear-history { padding: 0.6rem; }
  .dice-btn { 
    min-width: 0; 
    width: 80px; 
    flex: 0 0 auto; 
    -webkit-tap-highlight-color: transparent;
  }
  .dice-btn button { 
    width: 80px; 
    height: 80px; 
    -webkit-tap-highlight-color: transparent;
  }
}