/* Shared <dialog>-based modal chrome (rating edit, difficulty comparisons, ...).
   Every modal dialog must carry the "modal" class or it falls back to the
   browser's default <dialog> chrome (visible border, no centering). */
dialog.modal {
  padding: 0;
  border: none;
  outline: none;
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: calc(100% - 2rem);
  max-height: 90vh;
  /* Browsers default <dialog> to overflow: auto, which turns the dialog
     itself into a second scrolling ancestor (on top of .modal-content)
     and clips/scroll-wraps anything that pops out past it, like an open
     dropdown. Only .modal-content--scrollable should ever scroll. */
  overflow: visible;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  background: var(--bg-secondary);
  color: var(--fg-primary);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}

dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

dialog.modal-lg {
  max-width: 700px;
}

.modal-content {
  background: var(--bg-secondary);
  color: var(--fg-primary);
  border-radius: var(--radius-lg);
}

/* Only for modals whose body can genuinely grow long (e.g. the difficulty
   picker's game list). Plain forms should stay off this: overflow: auto
   here would clip/scroll-wrap any dropdown that pops open past the
   modal's own height, instead of letting it float over the page. */
.modal-content--scrollable {
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-secondary);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.modal-close:hover {
  background: var(--bg-tertiary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-description {
  margin-bottom: 1.5rem;
}

.modal-footer {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal-footer-left {
  margin-right: auto;
}
