/* Dice Calculator Styles */

.dice-section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
  text-align: center;
}

.dice-faces-section {
  margin-bottom: 32px;
}

.dice-faces-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.die-faces h3 {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 1.1rem;
}

.die-image {
  margin-bottom: 12px;
  text-align: center;
}

.die-image img {
  max-width: 100px;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.faces {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.face {
  padding: 8px 12px;
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  text-align: center;
  color: var(--text);
}

.dice-calculator {
  background: var(--bg-card);
  padding: 32px; /* Increased from 24px */
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.calculator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
  margin-left: auto;
  margin-right: auto;
  align-items: start;
}

.calculator-layout.single-column {
  grid-template-columns: 1fr;
  justify-items: center;
  max-width: 800px;
}

.dice-sections {
  display: flex;
  flex-direction: column;
  gap: 0px;
}

#customProbSection {
  background: var(--bg-solid);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  padding: 20px;
}

.add-roll-section {
  text-align: left;
  margin-bottom: 0px;
}

.btn-add {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.08s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

.btn-add:hover {
  background: var(--accent-hover);
}

.add-roll-section .btn-add:focus {
  outline: none;
  box-shadow: 0 6px 12px rgba(0,0,0,0.12), 0 0 0 4px var(--accent-glow);
}

.add-roll-section .btn-add:active {
  transform: translateY(1px) scale(0.995);
}

.add-roll-section {
  display: flex;
  justify-content: flex-start;
  width: 200px; /* match .dice-row width so left edges align */
  margin: 12px 0 0 0;
}

.dice-sections {
  display: flex;
  flex-direction: column;
}

.dice-sections.centered {
  align-items: center;
}

.dice-inputs {
  display: flex;
  flex-direction: column;
  gap: 20px; /* Increased from 12px */
  width: fit-content;
  background: var(--bg-solid);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  padding: 20px;
}

.dice-inputs-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.remove-dice-inputs-btn {
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--error);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-dice-inputs-btn:hover {
  background: var(--error-hover);
  transform: scale(1.1);
}

.remove-dice-inputs-btn:active {
  transform: scale(0.95);
}

.dice-inputs.centered {
  margin: 0 auto;
}

.dice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px; /* Reduced gap to match dice spacing */
  min-height: 80px; /* Increased from 60px */
  width: 612px; /* Updated fixed width */
}

.dice-label-btn {
  border: none;
  padding: 20px 20px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 140px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.assault-label {
  background: #83271c; /* Dark red/brown for assault */
}

.assault-label:hover {
  background: #6b1f16; /* Darker version for hover */
}

.skirmish-label {
  background: #4e7d84; /* Teal/blue-gray for skirmish */
}

.skirmish-label:hover {
  background: #3f656c; /* Darker version for hover */
}

.raid-label {
  background: #d07430; /* Orange/brown for raid */
}

.raid-label:hover {
  background: #b86329; /* Darker version for hover */
}

.dice-label-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.dice-label-btn:active {
  transform: scale(0.98);
}

.dice-clear-btn {
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-solid);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dice-clear-btn:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.1);
}

.dice-clear-btn:active {
  transform: scale(0.95);
}

/* Dice type specific colors */
#assaultLabel {
  background: #83271c; /* Dark red/brown for assault */
}

#assaultLabel:hover {
  background: #6b1f16; /* Darker version for hover */
}

#skirmishLabel {
  background: #4e7d84; /* Teal/blue-gray for skirmish */
}

#skirmishLabel:hover {
  background: #3f656c; /* Darker version for hover */
}

#raidLabel {
  background: #d07430; /* Orange/brown for raid */
}

#raidLabel:hover {
  background: #b86329; /* Darker version for hover */
}

.dice-visual {
  display: flex;
  flex-wrap: wrap;
  gap: 8px; /* Increased from 4px */
  min-height: 80px; /* Increased from 64px */
  width: 424px; /* Exact width for 6 dice */
  align-items: center;
  padding-left: 0px; /* No left padding to match dice gap */
}

.dice-icon {
  width: 64px; /* Increased from 48px */
  height: 64px; /* Increased from 48px */
  border-radius: 8px; /* Increased from 6px */
  border: 2px solid var(--border);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
  transition: transform 0.1s;
  position: relative;
}

.dice-icon:hover {
  transform: scale(1.1);
}

.dice-text-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 1;
}

.dice-btn {
  width: 44px; /* Increased from 32px */
  height: 44px; /* Increased from 32px */
  border: 2px solid var(--border); /* Increased from 1px */
  border-radius: var(--radius-sm);
  background: var(--bg-solid);
  color: var(--text);
  font-size: 1.4rem; /* Increased from 1.2rem */
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.dice-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.dice-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-selector,
.desired-input {
  display: flex;
  align-items: center;
  gap: 16px; /* Increased from 12px */
  margin-bottom: 20px; /* Increased from 16px */
}

.icon-selector .calc-label,
.desired-input .calc-label {
  font-size: 1rem; /* Increased from 0.9rem */
  font-weight: 500;
  color: var(--text-muted);
  min-width: 80px; /* Increased from 60px */
}

.roll-section {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px; /* Increased from 16px */
}

.btn-roll {
  background: var(--accent);
  color: white;
  border: none;
  padding: 16px 32px; /* Increased from 12px 24px */
  border-radius: var(--radius-sm);
  font-size: 1.2rem; /* Increased from 1rem */
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-roll:hover {
  background: var(--accent-hover);
}

.btn-roll:active {
  transform: scale(0.95);
}

.roll-section {
  margin-top: 8px;
  text-align: center;
}

.simulation-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.simulation-table th,
.simulation-table td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: center;
}

.simulation-table th {
  background: var(--bg-card);
  font-weight: 600;
}

.calc-select,
.calc-input {
  padding: 12px 16px; /* Increased from 8px 12px */
  border: 2px solid var(--border); /* Increased from 1px */
  border-radius: var(--radius-sm);
  background: var(--bg-solid);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem; /* Increased from 0.9rem */
}

.calc-select:focus,
.calc-input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 16px 32px; /* Increased from 12px 24px */
  border-radius: var(--radius-sm);
  font-size: 1.2rem; /* Increased from 1rem */
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 24px; /* Increased from 20px */
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.calc-result {
  padding: 8px 12px; /* Reasonable padding */
  background: var(--bg-solid);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border); /* Increased from 1px */
  font-size: 1.3rem; /* Increased from 1.1rem */
  text-align: center;
  color: var(--text);
  width: fit-content;
  margin: 0 auto;
}

.results-table {
  margin: 0 auto;
  width: fit-content;
}

.result-line {
  margin-bottom: 8px;
}

.result-line:last-child {
  margin-bottom: 0;
}

.results-header {
  display: grid;
  grid-template-columns: 70px 50px 100px 100px;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  margin-bottom: 4px; /* Reduced from 8px */
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

.header-ev, .header-chance, .header-rolled {
  text-align: center;
}

.header-select {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  font-size: inherit;
  font-weight: 600;
  font-family: inherit;
  min-width: 50px;
  cursor: pointer;
}

.header-select:focus {
  outline: none;
  border-color: var(--accent);
}

.header-select option {
  background: var(--bg-solid);
  color: var(--text);
}

.icon-result {
  display: grid;
  grid-template-columns: 70px 50px 100px 100px;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 4px;
}

.icon-result:last-child {
  margin-bottom: 0;
}

.result-ev, .result-chance, .result-rolled {
  text-align: center;
  font-weight: 500;
}

.result-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

/* Smaller icon for rolled column */
.result-rolled-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  vertical-align: -3px; /* Lower the icon slightly */
}

/* Only invert icon colors in dark mode */
[data-theme="dark"] .result-icon,
[data-theme="dark"] .result-rolled-icon {
  filter: invert(1);
}

/* Bell Curves Section */
#bellCurvesSection {
  margin-top: 24px;
  width: 100%;
  max-width: calc(100vw - 40px);
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.bell-curves-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
}

.bell-curves-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 20px;
}

.histogram-mode {
  position: absolute;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text);
}

.histogram-mode select {
  background: var(--bg-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: inherit;
  cursor: pointer;
}

.histogram-mode select:focus {
  outline: none;
  border-color: var(--accent);
}

.bell-curves-container {
  display: flex;
  flex-direction: column;
  gap: 30px;
  width: 100%;
  overflow-x: auto;
}

.bell-curve-item {
  width: 100%;
  background: var(--bg-solid);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.bell-curve-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}

.bell-curve-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.bell-curve-chart {
  display: flex;
  gap: 12px;
  align-items: end;
  height: 160px;
  padding: 0 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.bell-curve-chart::-webkit-scrollbar {
  height: 4px;
}

.bell-curve-chart::-webkit-scrollbar-track {
  background: var(--bg-solid);
  border-radius: 2px;
}

.bell-curve-chart::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 2px;
}

.bell-curve-bar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bell-curve-bar {
  background: var(--accent);
  width: 100%;
  border-radius: 4px 4px 0 0;
  transition: opacity 0.2s ease;
  cursor: pointer;
}

.bell-curve-bar:hover {
  opacity: 0.8;
}

.bell-curve-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  margin-top: 4px;
}

.bell-curve-percent {
  font-size: 0.8rem;
  color: var(--text);
  opacity: 0.7;
  margin-top: 2px;
}

.bell-curve-deterministic {
  text-align: center;
  padding: 40px 20px;
  color: var(--text);
  font-style: italic;
  opacity: 0.8;
}

/* Dark mode adjustments */
[data-theme="dark"] .bell-curve-icon {
  filter: invert(1);
}

/* Custom Probability Calculator */
#customProbSection {
  margin-top: 0px; /* reduced to position higher */
  width: 100%;
  max-width: calc(100vw - 40px);
  padding: 8px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.custom-prob-title {
  margin: 0 0 4px 0;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
}

.custom-prob-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.custom-prob-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--bg-solid);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.custom-prob-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.custom-prob-name {
  font-weight: 500;
  color: var(--text);
  min-width: 80px;
}

.custom-prob-input {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  text-align: center;
}

.custom-prob-input:focus {
  outline: none;
  border-color: var(--accent);
}

.custom-prob-result {
  font-weight: 600;
  color: var(--accent);
  min-width: 50px;
  text-align: right;
}

/* Dark mode adjustments for custom prob */
[data-theme="dark"] .custom-prob-icon {
  filter: invert(1);
}

.custom-prob-combined {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 4px;
  padding: 15px;
  background: var(--bg-solid);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.btn-calculate {
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s ease;
}

.btn-calculate:hover {
  background: var(--accent-hover);
}

#combinedResult {
  font-weight: 600;
  color: var(--accent);
  font-size: 1.1rem;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: var(--bg-card);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px;
  border-radius: var(--radius-lg);
  width: 80%;
  max-width: 400px;
  border: 1px solid var(--border);
}

.modal-content h3 {
  margin-top: 0;
  color: var(--text);
}

#assaultFacesCheckboxes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.face-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: move;
  background: var(--bg-solid);
  transition: background 0.2s, border-color 0.2s;
  user-select: none;
}

.face-option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.face-option.dragging {
  opacity: 0.8;
  transform: rotate(5deg);
}

.face-label {
  font-size: 0.8rem;
  color: var(--text);
}

/* Modal button styles */
.btn-modal-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  margin-right: 10px;
}

.btn-modal-primary:hover {
  background: var(--accent-hover);
}

.btn-modal-secondary {
  background: var(--bg-solid);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}