/* Floating forms share a header and spacing. The schedule and bracket editors keep their wider canvases. */
:is(dialog.entry-dialog, dialog#dialog, .modal-backdrop > .modal) {
  --dialog-pad: clamp(20px, 3vw, 32px);
  --dialog-ink: #173d36;
  --dialog-tint: #e3f1eb;
  --dialog-line: #c2d7cd;
  box-sizing: border-box;
  color: var(--dialog-ink);
  background: #fdfefb;
  border: 1px solid var(--dialog-line);
  border-radius: 14px;
  box-shadow: 0 18px 58px rgb(7 36 29 / 18%);
  max-height: min(90dvh, calc(100dvh - 32px));
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-block: 14px;
}

dialog.modal-backdrop {
  inset: 0;
  width: 100%;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
}
dialog.modal-backdrop:not([open]) { display: none; }
dialog.modal-backdrop::backdrop { background: transparent; }
dialog.entry-dialog { padding: 0; }
dialog#dialog, .modal-backdrop > .modal { padding: var(--dialog-pad); }

dialog.entry-dialog > .dialog-form {
  min-width: 0;
  padding: var(--dialog-pad);
  gap: 17px;
}

dialog.entry-dialog::backdrop, dialog#dialog::backdrop, .modal-backdrop {
  background: rgb(10 31 27 / 52%);
}

:where(.dialog-form, .modal, #dialog) > :is(.section-head, .dialog-top, h2):first-child {
  overflow-wrap: anywhere;
}

dialog.entry-dialog > .dialog-form > :is(.section-head, h2):first-child,
.modal-backdrop > .modal > .section-head:first-child,
dialog#dialog > .dialog-top:first-child {
  margin: calc(-1 * var(--dialog-pad)) calc(-1 * var(--dialog-pad)) 0;
  padding: 18px var(--dialog-pad);
  background: var(--dialog-tint);
  border-bottom: 1px solid var(--dialog-line);
}

.modal-backdrop > .modal > .section-head:first-child,
dialog#dialog > .dialog-top:first-child { margin-bottom: 18px; }

:where(.entry-dialog > .dialog-form, .modal-backdrop > .modal, dialog#dialog) > :is(.section-head, .dialog-top):first-child {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

:is(dialog.entry-dialog, dialog#dialog, .modal-backdrop > .modal) h2 {
  min-width: 0;
  margin: 0;
  color: var(--dialog-ink);
  font-family: var(--platform-font, Manrope, system-ui, sans-serif);
  font-size: clamp(22px, 2.4vw, 28px);
  line-height: 1.13;
  letter-spacing: -.035em;
  font-weight: 700;
  overflow-wrap: anywhere;
}

dialog.entry-dialog .section-head > .text-btn,
.modal-backdrop > .modal > .section-head > .text-btn,
dialog#dialog .dialog-top > .close {
  flex: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  align-self: center;
  min-height: 44px;
  min-width: 44px;
  margin: 0;
  padding: 0 10px;
  color: var(--dialog-ink);
  background: transparent;
  border: 1px solid #acc7bb;
  border-radius: 11px;
}

:is(dialog.entry-dialog, .modal-backdrop > .modal, dialog#dialog) :is(.actions, .modal-actions):last-child {
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--dialog-line);
}

dialog.entry-dialog :is(label, fieldset),
.modal-backdrop > .modal fieldset { min-inline-size: 0; }
dialog.entry-dialog textarea {
  background: #fff;
  color: var(--dialog-ink);
  font-weight: 400;
}
dialog.entry-dialog label > small { color: #50665b; font-weight: 400; }
dialog.entry-dialog .dialog-form > [data-result-preview]:empty { display: none; }
dialog.entry-dialog :is(p, small) { overflow-wrap: anywhere; }
dialog.entry-dialog .btn.primary, .modal-backdrop .modal-actions .btn.primary, dialog#dialog .btn.primary {
  color: #173e39;
  background: var(--platform-accent, #81d8d0);
  border-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  :is(dialog.entry-dialog, dialog#dialog, .modal-backdrop > .modal) :is(.section-head, .dialog-top) > :is(.text-btn, .close):hover {
    background: #cfe6db;
  }
}

@media (max-width: 600px) {
  .modal-backdrop { padding: 0; align-items: end; }
  :is(dialog.entry-dialog, dialog#dialog, .modal-backdrop > .modal, .modal-backdrop > .modal:has(.gd-editor)) {
    --dialog-pad: 20px;
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top)));
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
  }
  dialog.entry-dialog, dialog#dialog {
    position: fixed;
    inset: auto 0 0;
    margin: 0;
  }
  dialog#dialog, dialog.entry-dialog > .dialog-form, .modal-backdrop > .modal {
    padding-bottom: calc(var(--dialog-pad) + env(safe-area-inset-bottom));
  }
  dialog.entry-dialog > .dialog-form > :is(.section-head, h2):first-child,
  .modal-backdrop > .modal > .section-head:first-child,
  dialog#dialog > .dialog-top:first-child {
    padding-block: 15px;
  }
}

/* Starting styles run on opening, including quick reopen, without delaying native close/focus. */
@media (prefers-reduced-motion: no-preference) {
  :root[data-pointer-ui] :is(dialog.entry-dialog[open], dialog#dialog[open], .modal-backdrop:not(.modal-continuation) > .modal) {
    transition: opacity 150ms ease-out, transform 180ms cubic-bezier(.23,1,.32,1);
  }
  @starting-style {
    :root[data-pointer-ui] :is(dialog.entry-dialog[open], dialog#dialog[open], .modal-backdrop:not(.modal-continuation) > .modal) {
      opacity: .5;
      transform: translateY(7px) scale(.985);
    }
  }
  @media (max-width: 600px) {
    @starting-style {
      :root[data-pointer-ui] :is(dialog.entry-dialog[open], dialog#dialog[open], .modal-backdrop:not(.modal-continuation) > .modal) {
        opacity: .8;
        transform: translateY(24px);
      }
    }
  }
}

/* Category and form choices share the glass surface approved for the tournament picker. */
dialog.tournament-picker {
  position: fixed;
  inset: auto;
  box-sizing: border-box;
  width: min(256px, 85vw);
  max-width: 100vw;
  max-height: min(248px, 48dvh);
  margin: 0;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  color: #183d34;
  font-family: var(--platform-font, Manrope, system-ui, sans-serif);
  background: linear-gradient(135deg, #fcfffcf5, #f1faf4ed);
  border: 1px solid #ffffffed;
  border-radius: 17px;
  box-shadow: 0 0 0 1px #94b5a247, 0 8px 18px -10px #0b3d2a54,
    0 28px 65px -18px #174b3c45, inset 0 1px 0 #fff;
  backdrop-filter: blur(24px) saturate(120%);
}
html:has(.tournament-picker[open]) { overflow: hidden; }
.tournament-picker[open] { display: flex; flex-direction: column; }
.tournament-picker:not([open]), .tournament-picker [hidden] { display: none; }
.tournament-picker::backdrop { background: #163b290a; }

.tournament-picker > header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 6px 2px 14px;
}
.tournament-picker h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}
.tournament-picker .picker-close {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: inherit;
  font: 500 21px/1 var(--platform-font, Manrope, sans-serif);
  border: 0;
  border-radius: 50%;
  background: transparent;
}
.tournament-picker .picker-search {
  flex: none;
  width: auto;
  min-height: 44px;
  margin: 0 8px 5px;
  padding: 6px 10px;
  color: inherit;
  font: inherit;
  background: #ffffffc9;
  border: 1px solid #b6cfc0;
  border-radius: 11px;
}

.tournament-picker .picker-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.tournament-picker .picker-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 8px 8px;
  scrollbar-width: thin;
  scrollbar-color: #a5c7b3 transparent;
}
.tournament-picker .picker-option {
  position: relative;
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: 7px 34px 7px 10px;
  color: inherit;
  text-align: start;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
}
.tournament-picker .picker-title { display: block; font-weight: 700; letter-spacing: -.02em; }
.tournament-picker .picker-description, .tournament-picker .fit-caption {
  display: block;
  margin-top: 3px;
  color: #496457;
  font-size: 13px;
}
.tournament-picker .picker-option:is([aria-selected="true"], [data-selected], [aria-pressed="true"]) {
  border-color: #9dc8ad80;
  background: linear-gradient(110deg, #deeee3, #eaf5ec);
  box-shadow: inset 0 1px 0 #ffffffc9;
}
.tournament-picker .picker-mark {
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  translate: 0 -50%;
  color: #147354;
  font-size: 17px;
  line-height: 1;
}
.tournament-picker .picker-empty:empty { display: none; }
.tournament-picker .picker-option:is(:disabled, [aria-disabled="true"]) {
  color: #64776d;
  cursor: not-allowed;
  opacity: .75;
}
.tournament-picker :is(.picker-close, .picker-search, .picker-option):focus-visible {
  outline: 2px solid #167b61;
  outline-offset: -2px;
}
.tournament-picker .picker-empty { margin: 0; padding: 10px 22px 22px; color: #496457; }
@media (hover: hover) and (pointer: fine) {
  .tournament-picker .picker-option:not(:disabled, [aria-selected="true"], [aria-disabled="true"]):hover,
  .tournament-picker .picker-close:hover { background: #dfeee3a8; }
}
.tournament-picker .picker-option[data-highlighted] { outline: 2px solid #488d7a; outline-offset: -2px; }
@media (max-width: 640px) {
  .tournament-picker .picker-search { font-size: 16px; }
}
@media (max-height: 450px) {
  .tournament-picker > header { padding-block: 0; }
  .tournament-picker .picker-search { margin-bottom: 2px; }
}

.replacement-dialog [hidden] { display: none; }
.replacement-dialog :is(h3, p, ul) { margin: 0; }
.replacement-dialog ul { padding-inline-start: 1.3em; }
.replacement-dialog section h3 { margin-bottom: 4px; font-size: 1em; }
.replacement-dialog [data-warning] { color: #774b1b; }
.replacement-dialog select { width: 100%; }

.schedule-export-dialog [hidden], .schedule-export-dialog [role=status]:empty { display: none; }
.schedule-export-dialog [role=status] { margin: 0; }
.schedule-export-dialog .dialog-form fieldset { display: grid; gap: 0; }
.schedule-export-dialog .dialog-form label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.schedule-export-dialog .check input[type=radio] { width: 18px; height: 18px; min-height: 0; margin: 0; }
.schedule-export-dialog select { width: 100%; }
.schedule-mode-bar .schedule-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-inline-start: auto; }
.schedule-mode-bar .schedule-actions .btn { margin-inline-start: 0; }
