/* Shared research controls, charts, tables and dialog surfaces. */
:is(.directory-filters, .profile-filters, .pp-extra-filters, .ref-directory__controls, .ref-detail-page, .referees-page) select:not([multiple]) {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m4 6 4 4 4-4' stroke='%23aebdce' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}
:is(.pp-extra-filters, .ref-directory__controls, .ref-detail-page, .referees-page) :is(select, input[type="search"]) {
    min-height: 44px;
    border: 1px solid #39404a;
    border-radius: 8px;
    background-color: #15181c;
    color: var(--text-primary);
    transition: border-color .15s, box-shadow .15s;
}
:is(.pp-extra-filters, .ref-directory__controls, .ref-detail-page, .referees-page) :is(select, input[type="search"]):hover { border-color: #596577; }
:is(.pp-extra-filters, .ref-directory__controls, .ref-detail-page, .referees-page) :is(select, input[type="search"]):focus-visible { border-color: var(--secondary-color); outline: 2px solid rgba(96,165,250,.3); outline-offset: 2px; }

:is(.prop-modal, .game-modal) {
    padding: 24px;
    background: rgba(5,8,13,.82);
    backdrop-filter: blur(5px);
    overflow: hidden;
}
:is(.prop-modal, .game-modal).active { align-items: center; justify-content: center; }
:is(.prop-modal, .game-modal) .modal-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1200px;
    max-height: calc(100dvh - 48px);
    margin: 0;
    overflow: hidden;
    border: 1px solid #363d48;
    border-radius: 14px;
    background: #13161b;
    box-shadow: 0 24px 80px rgba(0,0,0,.45);
}
:is(.prop-modal, .game-modal) .modal-header {
    flex-shrink: 0;
    position: relative;
    align-items: center;
    padding: 16px 24px;
    gap: 16px;
    background: #1b1f26;
    border-bottom: 1px solid #333a45;
}
.prop-modal .modal-header h2 { margin: 0; font-size: 1.2rem; line-height: 1.35; font-weight: 650; letter-spacing: -.025em; }
.prop-modal .modal-heading { min-width: 0; }
.prop-modal .modal-profile-link { display: inline-block; margin-top: 6px; color: var(--secondary-color); font-size: .75rem; }
:is(.prop-modal, .game-modal) .modal-close {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border: 1px solid #414955;
    border-radius: 8px;
    background: #242b35;
    color: #e2e8f0;
    transform: none;
}
:is(.prop-modal, .game-modal) .modal-close:hover { transform: none; background: #354152; }
.prop-modal .modal-body, .game-modal .modal-charts {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 20px 24px 24px;
}
.prop-modal .prop-buttons-container { justify-content: flex-start; padding: 0; margin: 0 0 12px; gap: 6px; }
.prop-modal .modal-period-selector { justify-content: flex-start; padding: 0; margin-bottom: 16px; gap: 6px; }
:is(.prop-modal, .game-modal) :is(.prop-button, .modal-period-button, .modal-toggle-btn) {
    border: 1px solid #39424e;
    border-radius: 7px;
    color: var(--text-secondary);
    background: #1a2029;
    min-height: 36px;
    padding: 8px 14px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.25;
}
:is(.prop-modal, .game-modal) :is(.prop-button, .modal-period-button, .modal-toggle-btn):hover { border-color: #64758c; color: var(--text-primary); }
:is(.prop-modal, .game-modal) :is(.prop-button, .modal-period-button, .modal-toggle-btn).active { color: #d6e8ff; background: #243d5e; border-color: #5179ad; box-shadow: none; }
.game-modal .modal-toggle { display: block; padding: 0; margin-bottom: 12px; background: transparent; border: 0; }
.game-modal .modal-toggle .button-group { justify-content: flex-start; }
.game-modal .modal-period-selector { margin-bottom: 20px; }
:is(.prop-modal, .game-modal) .analysis-context { color: var(--text-secondary); font-size: .75rem; line-height: 1.6; margin: 12px 0; }
.prop-modal .modal-stats-card-wrapper { padding: 16px; margin: 0 0 18px; border-color: #303845; background: #1b2028; border-radius: 10px; }
.prop-modal .modal-stat-label { font-size: .7rem; letter-spacing: .045em; }
.prop-modal .modal-stat-value.large { font-size: 1.3rem; }
.prop-modal :is(.modal-model-value, .modal-hit-value, .modal-ev-value) { font-variant-numeric: tabular-nums; }
.prop-modal .modal-ev-value.positive { color: var(--chart-green); }
.prop-modal .modal-ev-value.negative { color: var(--chart-red); }
.prop-modal .modal-charts-container { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0; gap: 16px; margin-bottom: 20px; }
.analysis-chart-card { min-width: 0; margin: 0; background: #1b2028; border: 1px solid #303845; border-radius: 10px; overflow: hidden; }
.analysis-chart-heading { padding: 16px 16px 0; }
.analysis-chart-heading h3 { margin: 0 0 5px; font-size: .85rem; font-weight: 600; }
.analysis-chart-heading p { margin: 0; font-size: .7rem; line-height: 1.5; color: var(--text-secondary); }
.prop-modal .analysis-chart-card .chart-container { background: transparent; border: 0; border-radius: 0; padding: 12px; height: 300px; }
.game-modal .charts-section { gap: 16px; margin-bottom: 20px; }
.game-modal .charts-section > div { display: flex; flex-direction: column; min-width: 0; padding: 16px 16px 8px; background: #1b2028; border: 1px solid #303845; border-radius: 10px; }
.game-modal .chart-title { text-align: left; font-size: .85rem; font-weight: 600; margin: 0 0 5px; }
.game-modal .chart-explanation { color: var(--text-secondary); font-size: .7rem; line-height: 1.5; margin: 0 0 14px; }
.game-modal .chart-container { background: transparent; border: 0; border-radius: 0; padding: 0; }
.game-modal .chart-container-compact { margin-top: auto; height: 260px; }
.game-modal .analysis-breakdown { border: 1px solid #303845; border-radius: 10px; background: #1b2028; padding: 16px; }
.game-modal .analysis-list > li { background: transparent; border-left: 0; padding: 0; }
.prop-modal .modal-ev-summary-section { margin: 20px 0 0; padding: 0; border: 0; background: transparent; }
.prop-modal .modal-ev-summary-section > h3 { font-size: 1rem; font-weight: 600; margin: 0 0 8px; }
.prop-modal .modal-ev-summary-section > h4 { font-size: .8rem; font-weight: 600; margin: 20px 0 10px; color: var(--text-secondary); }
.analysis-table-note { color: var(--text-secondary); font-size: .72rem; line-height: 1.5; margin: 0; }
.ev-summary-table-wrapper { overflow-x: auto; overscroll-behavior-x: contain; border: 1px solid #333b47; border-radius: 8px; }
.ev-summary-table { font-variant-numeric: tabular-nums; line-height: 1.4; }
.ev-summary-table thead th { font-size: .67rem; letter-spacing: .04em; padding: 11px 12px; background: #222832; border-bottom: 1px solid #3a4452; border-right-color: rgba(255,255,255,.055); }
.ev-summary-table tbody :is(td, th) { font-size: .78rem; padding: 10px 12px; font-weight: 500; border-bottom: 1px solid rgba(255,255,255,.065); border-right: 1px solid rgba(255,255,255,.055); }
.ev-summary-table tbody th { text-align: left; background: #1b2028; color: var(--text-primary); white-space: nowrap; }
.ev-summary-table tbody tr:last-child :is(td, th) { border-bottom: 0; }
.ev-summary-table tbody tr:hover th { background: #273244; }
.ev-summary-table :is(th, td):first-child { text-align: left; }
.ev-summary-table tbody td:not(.ev-cell) { color: var(--text-secondary); background: #1b2028; }
.prop-modal .ev-summary-table { min-width: 500px; }
:is(.profile-table-scroll, .ref-directory__scroll, .chart-data-scroll, .ev-table-wrap) { scrollbar-color: #536176 #191d24; scrollbar-width: thin; }
:is(.profile-table-scroll, .ref-directory__scroll, .chart-data-scroll) table { font-variant-numeric: tabular-nums; }
.chart-data tbody tr:hover { background: rgba(96,165,250,.06); }

.ref-chart-modal { z-index: 10000; background: rgba(5,8,13,.82); backdrop-filter: blur(5px); }
.ref-chart-modal__content { background: #1b2028; border-color: #363d48; border-radius: 14px; padding: 0; overflow: hidden; }
.ref-chart-modal__header { flex-shrink: 0; border-bottom: 1px solid #333b47; padding: 18px 68px 16px 24px; }
.ref-chart-modal__header h2 { margin: 0; font-size: 1rem; line-height: 1.4; }
.ref-chart-modal__header p { margin: 6px 0 0; color: var(--text-secondary); font-size: .75rem; }
.ref-chart-modal__close { width: 40px; height: 40px; border-radius: 8px; top: 12px; right: 16px; }
.ref-chart-modal__body { min-height: 0; overflow: hidden; padding: 20px; }
.ref-chart-modal__body .ref-chart-card__body { min-height: 0; max-height: none; }
.ref-chart-modal__body .team-chart-scroll { overflow-y: auto; scrollbar-gutter: stable; }

@media (max-width: 899px) { .prop-modal .modal-charts-container { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
    :is(.prop-modal, .game-modal) { padding: 8px; }
    :is(.prop-modal, .game-modal) .modal-content { max-height: calc(100dvh - 16px); border-radius: 10px; }
    :is(.prop-modal, .game-modal) .modal-header { padding: 12px; gap: 12px; }
    .prop-modal .modal-header h2 { font-size: 1rem; }
    .prop-modal .modal-profile-link { font-size: .7rem; }
    :is(.prop-modal, .game-modal) .modal-close { min-width: 44px; min-height: 44px; }
    .prop-modal .modal-body, .game-modal .modal-charts { padding: 12px; scrollbar-gutter: auto; }
    :is(.prop-modal, .game-modal) :is(.prop-button, .modal-period-button, .modal-toggle-btn) { min-height: 36px; padding: 8px 6px; font-size: .68rem; }
    .prop-modal .modal-stats-card-wrapper { padding: 0; margin-bottom: 14px; border: 0; background: transparent; }
    .prop-modal .modal-stat-label { font-size: 9px; letter-spacing: 0; }
    .prop-modal .modal-stat-value.large { font-size: 12px; }
    .prop-modal .analysis-chart-card .chart-container { height: 280px; padding: 10px; }
    .analysis-chart-heading { padding: 14px 12px 0; }
    .game-modal .charts-section > div { padding: 12px 10px 6px; }
    .game-modal .chart-container-compact { height: 250px; padding: 0; }
    .game-modal .analysis-breakdown { padding: 12px; }
    .prop-modal .ev-summary-table :is(th, td) { padding: 10px; font-size: .73rem; }
    .prop-modal .ev-summary-table thead th { font-size: .63rem; }
    .prop-modal .ev-summary-table tbody th { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 #3a4452; }
}
