/* Keep the header search compact and on the same row as the account actions. */
.mtm-header-actions-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    white-space: nowrap;
}
#mtm-find-match-form.mtm-header-find {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    gap: 0;
    margin: 0;
    padding: 0;
    white-space: nowrap;
    vertical-align: middle;
}
#mtm-find-match-query {
    box-sizing: border-box;
    width: 112px;
    height: 30px;
    margin: 0;
    padding: 5px 9px;
    border: 1px solid #cbd5e1;
    border-right: 0;
    border-radius: 5px 0 0 5px;
    background: #fff;
    color: #172b4d;
    font: 13px Arial, sans-serif;
}
#mtm-find-match-query:focus { outline: 2px solid #60a5fa; outline-offset: -2px; }
#mtm-find-match-form button {
    box-sizing: border-box;
    height: 30px;
    margin: 0;
    padding: 0 11px;
    border: 1px solid #cbd5e1;
    border-radius: 0 5px 5px 0;
    background: #f1f5f9;
    color: #172b4d;
    font: bold 13px Arial, sans-serif;
    cursor: pointer;
}
#mtm-find-match-form button:hover { background: #dbeafe; }
#subMenu .mtm-header-find { margin-top: 12px; }

/* A native dialog puts the content and close control above its own backdrop. */
dialog.mtm-match-dialog {
    box-sizing: border-box;
    width: fit-content;
    min-width: min(540px, 80vw);
    max-width: 80vw;
    max-height: 90dvh;
    margin: auto;
    padding: 0;
    overflow: auto;
    border: 1px solid #dbe3ed;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
    color: #1e293b;
    font: 14px/1.5 Arial, sans-serif;
    text-align: left;
}
dialog.mtm-match-dialog:not([open]) { display: none; }
dialog.mtm-match-dialog::backdrop { background: rgba(15, 23, 42, .5); }
.mtm-match-titlebar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 64px;
    align-items: center;
    gap: 16px;
    padding: 14px 24px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}
#mtm-find-match-title { grid-column: 2; margin: 0; color: #334155; font-size: 16px; font-weight: bold; text-align: center; overflow-wrap: anywhere; }
#mtm-find-match-close {
    grid-column: 3;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    font: 26px/30px Arial, sans-serif;
    cursor: pointer;
}
#mtm-find-match-close:hover { background: #e2e8f0; color: #0f172a; }
#mtm-find-match-close:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.mtm-match-body { padding: 24px; }
#mtm-find-match-status:not(:empty) {
    padding: 16px 18px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e40af;
}
.mtm-match-layout { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 28px; }
.mtm-match-info { flex: 1 1 320px; min-width: 0; max-width: 100%; }
.mtm-match-cards { flex: 2 1 440px; min-width: 0; max-width: 100%; }
.mtm-match-summary { margin-bottom: 22px; }
.mtm-match-tournament { display: flex; align-items: center; gap: 10px; }
.mtm-match-tournament-logo { width: 32px; height: 32px; margin-right: 8px; object-fit: contain; vertical-align: middle; }
.mtm-match-eyebrow { color: #64748b; font-size: 13px; font-weight: bold; overflow-wrap: anywhere; }
#mtm-find-match .mtm-match-summary h2 { margin: 10px 0 8px; color: #0f172a; font-size: 26px; line-height: 1.25; }
.mtm-match-description { margin: 0; color: #64748b; overflow-wrap: anywhere; }
.mtm-match-teams {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.25fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding: 18px;
    border-radius: 10px;
    background: #f1f5f9;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    overflow-wrap: anywhere;
}
.mtm-match-teams strong { min-width: 0; color: #1d4ed8; font-size: 23px; white-space: normal; overflow-wrap: anywhere; }
#mtm-find-match .mtm-match-details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 24px;
    margin: 0;
    padding: 0 0 22px;
    border-bottom: 1px solid #e2e8f0;
}
.mtm-match-details dt { margin: 0 0 3px; color: #64748b; font-size: 12px; font-weight: normal; }
.mtm-match-details dd { margin: 0; color: #1e293b; font-size: 14px; font-weight: bold; overflow-wrap: anywhere; }
#mtm-find-match .mtm-match-cards h3 { margin: 0 0 12px; color: #334155; font-size: 14px; }
.mtm-match-note { margin: 12px 0 0; color: #64748b; font-size: 13px; }
.mtm-match-note:empty { display: none; }
.mtm-match-docs-container { display: flex; flex-wrap: wrap; gap: 16px; color: #64748b; }
.mtm-match-document { flex: 1 1 280px; min-width: 0; max-width: 100%; overflow: hidden; border: 1px solid #dbe3ed; border-radius: 8px; }
.mtm-match-card-pdf { display: block; box-sizing: border-box; width: 100%; height: 65vh; border: 0; }
.mtm-match-document > .mtm-match-note { padding: 0 16px 12px; }
@media (max-width: 600px) {
    .mtm-match-titlebar { padding: 12px 16px; }
    .mtm-match-body { padding: 16px; }
    .mtm-match-layout { gap: 20px; }
    .mtm-match-teams { gap: 10px; padding: 14px 10px; font-size: 14px; }
    #mtm-find-match .mtm-match-details { gap: 14px; }
}
.mtm-match-actions { grid-column: 1; }
.mtm-match-actions button, .mtm-card-reset {
    padding: 7px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #1d4ed8;
    font: bold 13px Arial, sans-serif;
    cursor: pointer;
}
.mtm-match-actions button:hover, .mtm-card-reset:hover { background: #eff6ff; }
.mtm-match-actions button[hidden] { display: none; }
#mtm-find-match-close { justify-self: end; }
#mtm-find-match.mtm-match-expanded { width: 80vw; }
.mtm-match-editor { display: block; width: 100%; height: 72vh; border: 0; background: #fff; }
.mtm-match-document-caption { padding: 12px 16px; color: #334155; font: bold 14px/1.5 Arial, sans-serif; }
.mtm-card-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 0 12px 12px; }
.mtm-card-control { flex: 1 1 120px; min-width: 0; color: #334155; font-size: 13px; }
.mtm-card-control > span { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.mtm-card-control output { color: #64748b; }
.mtm-card-control input { display: block; box-sizing: border-box; width: 100%; margin: 0; accent-color: #2563eb; }
.mtm-card-viewport { height: clamp(260px, 55vh, 680px); min-height: 220px; margin: 0 12px 12px; overflow: auto; border: 1px solid #cbd5e1; border-radius: 8px; background: #e2e8f0; }
.mtm-card-stage { position: relative; min-width: 100%; min-height: 100%; }
.mtm-card-viewer-image { position: absolute; top: 50%; left: 50%; max-width: none; max-height: none; transform-origin: center; object-fit: contain; }

.mtm-match-team-avatar img { display: block; width: 36px; height: 36px; object-fit: contain; }
@media (max-width: 600px) {
    .mtm-match-teams { gap: 6px; }
    .mtm-match-team-avatar img { width: 28px; height: 28px; }
}

.mtm-card-viewport.mtm-card-pannable { cursor: grab; touch-action: none; }
.mtm-card-viewport.mtm-card-dragging { cursor: grabbing; }
.mtm-card-viewer-image { user-select: none; -webkit-user-drag: none; }

#mtm-find-match .mtm-match-summary .mtm-match-number { margin-bottom: 3px; color: #1d4ed8; font-size: 32px; overflow-wrap: anywhere; }
.mtm-match-id { color: #64748b; font-size: 12px; font-weight: normal; white-space: nowrap; }
.mtm-match-score-parts:empty { display: none; }
.mtm-match-score-parts { margin-top: 14px; }
.mtm-match-score-parts table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 13px; text-align: center; }
.mtm-match-score-parts caption { margin-bottom: 8px; color: #64748b; font-size: 12px; text-align: left; }
.mtm-match-score-parts th, .mtm-match-score-parts td { padding: 7px 4px; border-bottom: 1px solid #e2e8f0; overflow-wrap: anywhere; }
.mtm-match-score-parts tbody th { font-weight: normal; }
.mtm-match-score-parts td { font-weight: bold; }

#mtm-find-match .mtm-match-score-parts table,
#mtm-find-match .mtm-match-score-parts tr,
#mtm-find-match .mtm-match-score-parts th,
#mtm-find-match .mtm-match-score-parts td { background: transparent; color: #1e293b; }

.mtm-match-search-group h3 { margin: 18px 0 10px; font-size: 14px; }
.mtm-match-search-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.mtm-match-search-result { display: grid; gap: 5px; width: 100%; padding: 14px 16px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: #1e293b; text-align: left; font: inherit; cursor: pointer; overflow-wrap: anywhere; }
.mtm-match-search-result:hover, .mtm-match-search-result:focus-visible { background: #eff6ff; border-color: #2563eb; }
.mtm-match-search-result strong { color: #1d4ed8; }
.mtm-match-search-result small { color: #64748b; }

.mtm-match-search-teams { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.mtm-match-search-team { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.mtm-match-search-team > span { min-width: 0; overflow-wrap: anywhere; }
.mtm-match-search-team img { width: 32px; height: 32px; flex-shrink: 0; object-fit: contain; }
.mtm-match-search-versus { color: #64748b; font-size: 12px; }
