/* V11.36 — screenshot-matched game controls and complete dialog chrome.
 * Important declarations in this named layer outrank the legacy unlayered
 * !important page skins, including Notification Center and editor ID rules.
 * Keep all existing picker engines, native values and open/close geometry.
 */
@layer aow-ui-consistency {
  /* Dialog inventory includes page markup and dynamically created chat/media,
     result-publication and team-replacement confirmations. The two role=dialog
     overlay containers are excluded: their inner panels receive the skin. */
  body.aow-masters-theme :is(
    [role='dialog']:not(.notif-detail-modal):not(.notif-media-viewer),
    .match-editor-modal, .notif-detail-panel, .notif-media-viewer-panel,
    .results-confirm-box, .phase5m-box, .aow-chat-media-dialog
  ) {
    box-sizing: border-box !important;
    border: 1px solid #619e9c !important;
    border-radius: 0 !important;
    background: repeating-linear-gradient(0deg, #284e4614 0 1px, transparent 1px 4px),
      linear-gradient(150deg, #102628, #061416 65%, #030d0e) !important;
    color: #edf7f3 !important;
    box-shadow: inset 0 1px 0 #85beb244, 0 18px 60px #000c !important;
    max-width: calc(100vw - 24px) !important;
  }
  body.aow-masters-theme :is(.phase5m-box, .results-confirm-box, .ms-bulk-dialog) {
    max-height: calc(100dvh - 32px) !important;
    overflow-y: auto !important;
  }
  /* Keep faction identity on team cards; don't change panel geometry/scrolling. */
  body.aow-masters-theme .is-confederation :is(.team-info-card, .participants-team-dialog),
  body.aow-masters-theme .chat-team-card.confederation {
    border-color: #579fbe !important;
  }
  body.aow-masters-theme .is-resistance :is(.team-info-card, .participants-team-dialog),
  body.aow-masters-theme .chat-team-card.resistance {
    border-color: #bf6265 !important;
  }
  body.aow-masters-theme :is(
    .result-correction-head, .match-editor-modal-head, .portal-dt-head,
    .notif-detail-head, .notif-media-viewer-toolbar, .chat-message-modal-footer,
    .match-chat-header, .aow-chat-media-toolbar
  ) {
    background: repeating-linear-gradient(125deg, #65a79712 0 1px, transparent 1px 5px), #081718 !important;
    border-color: #3d6869 !important;
    border-radius: 0 !important;
    color: #edf7f3 !important;
  }
  body.aow-masters-theme :is(
    .result-correction-current > div, .team-info-section,
    .participants-modal-section, .notif-detail-metadata > div,
    .notif-detail-body, .chat-history-message, .phase5m-change, .team-info-leader,
    .match-schedule-guide, .match-chat-mentions, .chat-emoji-picker,
    .phase5m-changes > div, .match-editor-summary, .ms-picker-summary
  ) {
    background: #051718 !important;
    border-color: #355f60 !important;
    border-radius: 0 !important;
    color: #dcefeb !important;
  }
  body.aow-masters-theme :is(
    .result-correction-kicker, .result-correction-current span,
    .correction-field-label, .phase5m-eyebrow,
    .participants-modal-label, .team-info-label
  ) {
    color: #86d0cd !important;
    font: 800 16px/1.25 var(--aow-heading, sans-serif) !important;
    letter-spacing: .06em !important;
  }
  body.aow-masters-theme .result-correction-current strong {
    color: #edf7f3 !important;
    font: 700 19px/1.25 var(--aow-heading, sans-serif) !important;
    overflow-wrap: anywhere !important;
  }
  body.aow-masters-theme :is(
    .result-correction-notice, .correction-technical-note,
    .phase5m-help, .phase5m-caution, .results-confirm-box p
  ) {
    color: #b4ceca !important;
    font: 500 16px/1.4 var(--aow-body, sans-serif) !important;
  }
  /* Consequential actions retain a readable amber warning, inside teal chrome. */
  body.aow-masters-theme :is(.result-correction-warning, .phase5m-caution, .ms-warning) {
    border: 1px solid #756337 !important;
    border-left: 3px solid #d7b44b !important;
    border-radius: 0 !important;
    background: #282414 !important;
  }
  body.aow-masters-theme .result-correction-warning strong {
    color: #f2d475 !important;
    font: 800 16px/1.25 var(--aow-heading, sans-serif) !important;
  }
  body.aow-masters-theme .phase5m-caution {
    padding: 10px 12px !important;
  }
  body.aow-masters-theme .result-correction-warning span {
    color: #e2d7b4 !important;
    font: 500 16px/1.35 var(--aow-body, sans-serif) !important;
  }
  body.aow-masters-theme :is(
    .result-correction-confirm, .correction-result-mode,
    .phase5m-actions button, .results-confirm-actions button,
    .chat-message-secondary, .chat-message-primary
  ) {
    box-sizing: border-box !important;
    min-height: 44px !important;
    border: 1px solid #6da8a8 !important;
    border-radius: 0 !important;
    background: linear-gradient(#225157, #15383c 49%, #0d292c 50%, #1b4043) !important;
    color: #edf8f4 !important;
    font: 800 18px/1.2 var(--aow-heading, sans-serif) !important;
    box-shadow: inset 0 1px 0 #83b9b3, inset 0 -2px 0 #07191a !important;
    padding: 10px 14px !important;
    white-space: normal !important;
  }
  body.aow-masters-theme .correction-result-mode.active {
    border-color: #98ded3 !important;
    background: linear-gradient(#347b7c, #205154) !important;
    box-shadow: inset 0 0 0 1px #7fcbc0 !important;
  }
  body.aow-masters-theme :is(
    .result-correction-close, .team-info-close, .participants-team-close,
    .modal-close, .chat-message-modal-x, .chat-team-card-close,
    .notif-detail-close, .match-editor-modal-close, .portal-dt-close
  ) {
    border: 1px solid #5c9392 !important;
    border-radius: 0 !important;
    color: #cfece7 !important;
    background: linear-gradient(#183c3e, #082022) !important;
  }
  body.aow-masters-theme .result-correction-close {
    width: 40px !important;
    height: 40px !important;
    flex: 0 0 40px !important;
  }
  body.aow-masters-theme .result-correction-head {
    gap: 12px !important;
  }
  body.aow-masters-theme .result-correction-head > div {
    min-width: 0 !important;
  }
  body.aow-masters-theme #result-correction-title {
    font-size: clamp(30px, 3.3vw, 44px) !important;
    overflow-wrap: anywhere !important;
  }
  body.aow-masters-theme .bracket-team-picker-trigger > span[aria-hidden='true'] {
    display: none !important;
  }
  body.aow-masters-theme :is(
    .portal-dt-time-title, .portal-dt-time-label, .match-chat-kicker,
    .match-chat-versus span, .chat-emoji-section-title, .chat-reply-preview-label,
    .phase5m-change small
  ) {
    color: #86c9c5 !important;
    font: 800 16px/1.3 var(--aow-heading, sans-serif) !important;
  }
  body.aow-masters-theme :is(
    .chat-message-edit-note, .chat-message-modal-footer > span,
    .match-chat-security, .notif-media-viewer-toolbar > span
  ) {
    color: #b4ceca !important;
    font: 500 16px/1.35 var(--aow-body, sans-serif) !important;
  }
  body.aow-masters-theme :is(.team-info-leader, .phase5m-change,
    .match-schedule-guide-item strong, .phase5m-change strong) {
    font: 700 18px/1.3 var(--aow-heading, sans-serif) !important;
    color: #edf7f3 !important;
  }
  body.aow-masters-theme :is(.match-chat-compose > button,
    .chat-unread-replies, .notif-media-viewer-navigation button) {
    font: 800 18px/1.2 var(--aow-heading, sans-serif) !important;
    min-height: 44px !important;
    border-radius: 0 !important;
    border-color: #619e9c !important;
    background: linear-gradient(#225157, #0d292c) !important;
    color: #edf8f4 !important;
  }
  /* These secondary panels escaped the original game skin. Keep their grid,
     spacing, content and bracket measurements; change only paint and corners. */
  body.aow-masters-theme :is(
    .admin-tools, .results-release-panel, .results-save-all-bar,
    .scheduler-info-note, .scheduler-combined-option, .scheduler-manual-breaks,
    .round-schedule-preview, .scheduler-pre-panel, .sat-metric,
    .ms-selection-section, .ms-info-panel, .bracket-toolbar,
    .match-management-shell, .management-section,
    .portal-dt-current, .portal-dt-calendar, .portal-dt-time
  ) {
    border-radius: 2px !important;
    border-color: #43686c !important;
    background: repeating-linear-gradient(0deg, transparent 0 3px, #00000013 3px 4px),
      linear-gradient(155deg, #163234fa, #071518fc 60%, #051012fc) !important;
    color: #dceceb !important;
    box-shadow: inset 0 1px 0 #a8e9e229, 0 6px 22px #0005 !important;
  }
  body.aow-masters-theme .admin-draft-status {
    border-radius: 2px !important;
  }
  body.aow-masters-theme .section:has(#scheduler-availability-tracker) div[style*='border-radius:12px'] {
    border-radius: 0 !important;
    border-color: #43686c !important;
  }
  body.aow-masters-theme :is(.portal-dt-time-list, .portal-dt-validation) {
    border-radius: 2px !important;
  }
  body.aow-masters-theme .portal-dt-time-list {
    background: repeating-linear-gradient(0deg, #28584c17 0 1px, transparent 1px 4px), #020b09 !important;
  }
  body.aow-masters-theme :is(.portal-dt-time-option, .portal-dt-day) {
    font: 700 18px/1.2 var(--aow-heading, sans-serif) !important;
    border-radius: 0 !important;
  }
  body.aow-masters-theme .portal-dt-time-option.selected {
    background: linear-gradient(#619a86, #4c846f) !important;
    border-color: #79b59d !important;
    color: #fff !important;
  }
  body.aow-masters-theme input[type='file']::file-selector-button {
    border: 1px solid #6da8a8 !important;
    border-radius: 0 !important;
    padding: 8px 12px !important;
    margin-right: 12px !important;
    background: linear-gradient(#225157, #15383c 49%, #0d292c 50%, #1b4043) !important;
    color: #edf8f4 !important;
    font: 700 18px/1.2 var(--aow-heading, sans-serif) !important;
    box-shadow: inset 0 1px 0 #83b9b3, inset 0 -2px 0 #07191a !important;
    cursor: pointer !important;
  }
  body.aow-masters-theme input[type='file']:disabled::file-selector-button {
    opacity: .5 !important;
    cursor: not-allowed !important;
  }
  html:has(body.aow-masters-theme), body.aow-masters-theme {
    scrollbar-color: #559b98 #061416 !important;
  }
  body.aow-masters-theme * {
    scrollbar-color: #559b98 #061416 !important;
  }
  html:has(body.aow-masters-theme)::-webkit-scrollbar,
  body.aow-masters-theme ::-webkit-scrollbar {
    width: 10px !important;
    height: 10px !important;
  }
  html:has(body.aow-masters-theme)::-webkit-scrollbar-track,
  body.aow-masters-theme ::-webkit-scrollbar-track {
    background: #061416 !important;
  }
  html:has(body.aow-masters-theme)::-webkit-scrollbar-thumb,
  body.aow-masters-theme ::-webkit-scrollbar-thumb {
    background: #559b98 !important;
    border: 2px solid #061416 !important;
    border-radius: 0 !important;
  }

  body.aow-masters-theme :is(
    .aow-select-trigger, .portal-select-trigger, .ms-ui-select-trigger,
    .ms-custom-select-trigger, .bracket-team-picker-trigger,
    .bracket-format-trigger, .results-custom-select-trigger,
    .results-team-select-trigger, .p6g-picker-trigger
  ) {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 48px !important;
    border: 1px solid #619e9c !important;
    border-radius: 0 !important;
    padding: 10px 48px 10px 13px !important;
    background: linear-gradient(#061514, #020909) !important;
    box-shadow: inset 0 1px 0 #477875, 0 0 0 2px #1c454540 !important;
    color: #f1f9f4 !important;
    font: 700 20px/1.2 var(--aow-heading, sans-serif) !important;
    text-align: left !important;
    text-transform: none !important;
    letter-spacing: .01em !important;
  }
  body.aow-masters-theme :is(
    .aow-select-trigger, .portal-select-trigger, .ms-ui-select-trigger,
    .ms-custom-select-trigger, .bracket-team-picker-trigger,
    .bracket-format-trigger, .results-custom-select-trigger,
    .results-team-select-trigger, .p6g-picker-trigger
  ):is(:hover, :focus-visible, [aria-expanded='true']):not(:disabled) {
    background: linear-gradient(#102b26, #03110e) !important;
    border-color: #8ad6ca !important;
  }
  body.aow-masters-theme :is(
    .aow-select-value, .portal-select-value, .ms-ui-select-value,
    .ms-custom-select-value, .results-custom-select-value,
    .results-team-select-current, .picker-current, .bracket-format-trigger strong
  ) {
    color: #f1f9f4 !important;
    font-size: 20px !important;
    line-height: 1.2 !important;
    min-width: 0 !important;
  }
  /* One opaque, striped menu surface across all nine picker engines. */
  body.aow-masters-theme :is(
    .aow-select-menu, .portal-select-menu, .ms-ui-select-menu,
    .ms-custom-select-menu, .ms-custom-select-options,
    .bracket-team-picker-menu, .bracket-format-menu,
    .results-custom-select-menu, .results-team-select-menu, .p6g-picker-menu
  ) {
    box-sizing: border-box !important;
    border: 1px solid #619e9c !important;
    border-radius: 0 !important;
    padding: 6px !important;
    background: repeating-linear-gradient(0deg, #28584c17 0 1px, transparent 1px 4px), #020b09 !important;
    box-shadow: inset 0 2px 0 #316863, 0 14px 32px #000d !important;
    color: #f1f9f4 !important;
    max-width: calc(100vw - 16px) !important;
    overscroll-behavior: contain !important;
  }
  /* Do not override fixed global-menu height: its JS calculates available space. */
  body.aow-masters-theme :is(
    .aow-select-menu:not(.aow-select-global-menu), .portal-select-menu,
    .ms-ui-select-menu, .ms-custom-select-menu, .ms-custom-select-options,
    .bracket-team-picker-menu, .bracket-format-menu,
    .results-custom-select-menu, .results-team-select-menu, .p6g-picker-menu
  ) {
    max-height: min(330px, 48dvh) !important;
    overflow-y: auto !important;
  }
  body.aow-masters-theme :is(
    .aow-select-option, .portal-select-option, .ms-ui-select-option,
    .ms-custom-select-option, .picker-option, .bracket-format-option,
    .results-custom-select-option, .results-team-select-option, .p6g-picker-option
  ) {
    box-sizing: border-box !important;
    min-height: 48px !important;
    padding: 10px 12px !important;
    border: 1px solid transparent !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #f1f9f4 !important;
    font: 700 20px/1.2 var(--aow-heading, sans-serif) !important;
    text-align: left !important;
    text-transform: none !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    text-shadow: 0 1px 1px #0008 !important;
  }
  body.aow-masters-theme :is(
    .aow-select-option, .portal-select-option, .ms-ui-select-option,
    .ms-custom-select-option, .picker-option, .bracket-format-option,
    .results-custom-select-option, .results-team-select-option, .p6g-picker-option
  ):is(:hover, :focus-visible):not(:disabled):not([aria-disabled='true']) {
    background: #214d40 !important;
    border-color: #71ac99 !important;
    color: #fff !important;
  }
  /* Green is the user's explicit V11.34 choice, matching reference image #3.
     Gold selection on cards, navigation and bracket rounds is unaffected. */
  body.aow-masters-theme :is(
    .aow-select-option, .portal-select-option, .ms-ui-select-option,
    .ms-custom-select-option, .picker-option, .bracket-format-option,
    .results-custom-select-option, .results-team-select-option, .p6g-picker-option
  ):is(.selected, .is-selected, [aria-selected='true']) {
    background: linear-gradient(#619a86, #4c846f) !important;
    border-color: #79b59d !important;
    box-shadow: inset 3px 0 #a0ddc3 !important;
    color: #fff !important;
    text-shadow: 0 1px 1px #163c34 !important;
  }
  body.aow-masters-theme :is(
    .aow-select-option, .portal-select-option, .ms-ui-select-option,
    .ms-custom-select-option, .picker-option, .bracket-format-option,
    .results-custom-select-option, .results-team-select-option, .p6g-picker-option
  ) :is(strong, b, .aow-select-team-name, .ms-ui-select-label) {
    color: inherit !important;
    font: 800 20px/1.2 var(--aow-heading, sans-serif) !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
  body.aow-masters-theme :is(
    .aow-select-option, .portal-select-option, .ms-ui-select-option,
    .ms-custom-select-option, .picker-option, .bracket-format-option,
    .results-custom-select-option, .results-team-select-option, .p6g-picker-option
  ) small {
    color: #b7d1c7 !important;
    font: 600 16px/1.3 var(--aow-heading, sans-serif) !important;
    letter-spacing: .01em !important;
  }
  body.aow-masters-theme :is(
    .aow-select-option, .portal-select-option, .ms-ui-select-option,
    .ms-custom-select-option, .picker-option, .bracket-format-option,
    .results-custom-select-option, .results-team-select-option, .p6g-picker-option
  ):is(.selected, .is-selected, [aria-selected='true']) small {
    color: #eefbf4 !important;
  }
  body.aow-masters-theme .portal-select-option {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
  }
  body.aow-masters-theme .portal-select-copy {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-width: 0 !important;
    gap: 4px !important;
  }
  /* Replace the legacy purple radio and duplicate faction tick with one check. */
  body.aow-masters-theme .portal-select-option :is(.portal-select-radio, .admin-faction-check, .portal-select-check) {
    display: none !important;
  }
  body.aow-masters-theme .portal-select-option.selected::after {
    content: '✓' !important;
    display: block !important;
    position: static !important;
    flex: 0 0 auto !important;
    margin-left: auto !important;
    color: #effff5 !important;
    font: 800 24px/1 var(--aow-heading, sans-serif) !important;
  }
  body.aow-masters-theme :is(
    .picker-check, .format-check, .aow-select-tick, .ms-custom-select-check,
    .results-custom-select-check, .results-team-select-check
  ) {
    color: #e5fff0 !important;
    border-color: #b3e4cd !important;
  }
  body.aow-masters-theme :is(.notification-faction-portal-select, .admin-faction-portal-select) .portal-select-option {
    grid-template-columns: none !important;
  }
  body.aow-masters-theme :is(.admin-faction-select-logo, .admin-faction-trigger-logo) {
    width: 32px !important;
    height: 32px !important;
    flex: 0 0 32px !important;
    object-fit: contain !important;
  }
  body.aow-masters-theme :is(.notification-faction-portal-select, .admin-faction-portal-select) .portal-select-value {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
  }
  body.aow-masters-theme :is(
    .aow-select-option, .portal-select-option, .ms-ui-select-option,
    .ms-custom-select-option, .picker-option, .bracket-format-option,
    .results-custom-select-option, .results-team-select-option, .p6g-picker-option,
    .aow-select-trigger, .portal-select-trigger, .ms-ui-select-trigger,
    .ms-custom-select-trigger, .bracket-team-picker-trigger, .bracket-format-trigger,
    .results-custom-select-trigger, .results-team-select-trigger, .p6g-picker-trigger
  ):is(:disabled, [aria-disabled='true']) {
    opacity: .5 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
  }
  @media (max-width: 760px) {
    body.aow-masters-theme :is(
      .aow-select-trigger, .portal-select-trigger, .ms-ui-select-trigger,
      .ms-custom-select-trigger, .bracket-team-picker-trigger, .bracket-format-trigger,
      .results-custom-select-trigger, .results-team-select-trigger, .p6g-picker-trigger,
      .aow-select-value, .portal-select-value, .ms-ui-select-value,
      .ms-custom-select-value, .results-custom-select-value, .results-team-select-current
    ) { font-size: 18px !important; }
  }
}
