/* ── Reset básico ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
}

/* ── Overlay de dados: cubre toda la pantalla, encima de todo ── */
#dice-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 9999;
  pointer-events: none; /* no bloquea clics en la UI */
}

/* Cuando el desvanecimiento es "solo al hacer clic",
   activamos los eventos de ratón en el overlay */
#dice-overlay.clickable {
  pointer-events: auto;
  cursor: pointer;
}

#dice-overlay canvas {
  width: 100%;
  height: 100%;
}

/* ── Panel de control ── */
#panel {
  position: relative;
  z-index: 100;
  width: 360px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 20px auto;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 28px 24px;
  backdrop-filter: blur(6px);
}

h1 {
  font-size: 1.3rem;
  margin-bottom: 20px;
  text-align: center;
  color: #fff;
}

/* ── Campos del formulario ── */
.field {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label {
  font-size: 0.85rem;
  color: #aaa;
}

input[type="text"],
select {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 8px 10px;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color .2s;
}

input[type="text"]:focus,
select:focus {
  border-color: #5a9;
}

select option {
  background: #1a1a2e;
}

input[type="color"] {
  width: 50px;
  height: 36px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: none;
}

input[type="range"] {
  accent-color: #5a9;
}

.section {
  margin-top: 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  overflow: hidden;
}

.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #6ab;
  padding: 8px 12px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.section-title::-webkit-details-marker { display: none; }
.section-title::marker { content: ''; }

.section-title::after {
  content: '▸';
  font-size: 0.75rem;
  transition: transform .2s;
}

.section[open] > .section-title::after {
  transform: rotate(90deg);
}

.section-body {
  padding: 8px 12px 12px;
}

.field-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field-check label {
  color: #ccc;
  font-size: 0.85rem;
  cursor: pointer;
}

.field-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #5a9;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Selector visual de dados ── */
#dice-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.die-pick {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 4px 6px;
}

.die-pick .die-count {
  font-size: 1rem;
  font-weight: bold;
  color: #fff;
  min-width: 18px;
  text-align: center;
}

.die-pick .die-label {
  font-size: 0.8rem;
  color: #aaa;
  min-width: 28px;
  text-align: center;
}

.btn-minus, .btn-plus {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  padding: 0;
}

.btn-minus:hover, .btn-plus:hover {
  background: rgba(255,255,255,0.25);
}

.die-pick.active {
  border-color: #5a9;
  background: rgba(90,170,150,0.15);
}

.hint {
  font-size: 0.75rem;
  color: #777;
}

/* ── Botón lanzar ── */
#btn-roll {
  width: 100%;
  padding: 11px;
  background: #2e8555;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 20px;
  transition: background .2s;
}

#btn-roll:hover { background: #3aa066; }
#btn-roll:disabled { background: #555; cursor: not-allowed; }

/* ── Resultados ── */
#results {
  margin-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 16px;
}

#results h2 {
  font-size: 0.9rem;
  color: #aaa;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

#results-content {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

/* Cada dado individual */
.die-result {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.9rem;
  text-align: center;
  min-width: 42px;
}

.die-result .die-type {
  font-size: 0.7rem;
  color: #888;
  display: block;
}

.die-result .die-value {
  font-size: 1.1rem;
  font-weight: bold;
  color: #fff;
}

/* Resultado máximo resaltado */
.die-result.max .die-value { color: #ffd700; }
/* Resultado mínimo resaltado */
.die-result.min .die-value { color: #e06c6c; }

#results-total {
  font-size: 1rem;
  color: #ccc;
  text-align: right;
}

#results-total strong {
  color: #fff;
  font-size: 1.2rem;
}

.hidden { display: none; }
