:root {
    --bg: #0f1115;
    --panel: #171a21;
    --panel-2: #1d222b;
    --border: #2b3240;
    --text: #e8ecf3;
    --muted: #9aa4b2;
    --accent: #4f8cff;
    --accent-hover: #3e78e6;
    --success: #2ea043;
    --danger: #dc3545;
    --warning: #f2c94c;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
}

.page {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 10px 0;
    background: rgba(15, 17, 21, 0.96);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
}

.match-header {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr) auto;
    align-items: center;
    gap: 18px;
    min-height: 72px;
}

.team-box {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.team-box.right {
    justify-content: flex-end;
    text-align: right;
}

.team-logo {
    width: 42px;
    height: 42px;
}

.team-name {
    font-size: 30px;
    font-weight: 700;
}

.match-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    min-width: 180px;
}

.match-tour {
    font-size: 21px;
    font-weight: 700;
}

.match-time,
.match-place {
    font-size: 15px;
    color: var(--muted);
    line-height: 1.2;
}

.header-actions.compact {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
}

.header-actions.compact form {
    margin: 0;
}

.header-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.header-icon:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.header-icon.danger {
    background: rgba(220, 53, 69, 0.18);
    border-color: rgba(220, 53, 69, 0.35);
}

.header-icon.danger:hover {
    background: rgba(220, 53, 69, 0.28);
}

#editModeToggle.active {
    background: rgba(242, 201, 76, 0.18);
    border-color: rgba(242, 201, 76, 0.45);
}

.btn {
    min-height: 36px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--panel-2);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, color 0.15s ease;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.04);
}

.content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 22px 24px 32px;
}

.tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.tab-link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.tab-link:hover {
    background: var(--panel-2);
    text-decoration: none;
}

.tab-link.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 440px;
    gap: 20px;
    align-items: start;
}

.game-main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lineups-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.match-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.match-toolbar-left,
.match-toolbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.timer-box {
    min-width: 122px;
    height: 46px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-2);
    border: 1px solid var(--border);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 1px;
}

.period-badge {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(79, 140, 255, 0.14);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}

.team-panel-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 14px;
}

.section-title {
    margin: 18px 0 10px;
    font-size: 15px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.section-title:first-child {
    margin-top: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 12px;
    background: var(--panel-2);
    table-layout: fixed;
}

th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 14px;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.02);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.num-col {
    width: 60px;
    text-align: center;
}

.num-cell {
    text-align: center;
    font-weight: 600;
}

.col-last {
    width: 36%;
}

.col-first {
    width: 22%;
}

.actions-col {
    width: 230px;
    text-align: right;
}

.player {
    position: absolute;
    transform: translate(-50%, -50%);
}

.players-layer {
    transform: translateX(1000px);
    /* подгони */
}

.player-name,
.player-first {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-name {
    font-weight: 600;
}

.player-first {
    color: var(--muted);
}

.gk-badge,
.captain-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 6px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.gk-badge {
    background: rgba(79, 140, 255, 0.2);
    color: #8ab4ff;
}

.captain-badge {
    background: rgba(255, 215, 0, 0.18);
    color: #ffd54a;
}

.row-actions {
    display: flex;
    flex-wrap: nowrap !important;
    gap: 4px;
    align-items: center;
}

.actions-col {
    white-space: nowrap;
    width: 1%;
}

.icon-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    font-size: 13px;
    font-weight: 700;
    transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.icon-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.icon-btn.goal {
    font-size: 15px;
}

.icon-btn.yellow-card,
.icon-btn.red-card {
    position: relative;
    overflow: hidden;
}

.icon-btn.yellow-card::before,
.icon-btn.red-card::before {
    content: "";
    width: 12px;
    height: 16px;
    border-radius: 2px;
    display: block;
}

.icon-btn.yellow-card::before {
    background: var(--warning);
}

.icon-btn.red-card::before {
    background: var(--danger);
}

.icon-btn.sub {
    position: relative;
    font-size: 16px;
}

.icon-btn.sub::before {
    content: "↗";
    position: absolute;
    left: 4px;
    top: 2px;
    color: #22c55e;
    font-size: 10px;
    font-weight: 900;
}

.icon-btn.sub::after {
    content: "↘";
    position: absolute;
    right: 4px;
    bottom: 2px;
    color: #ef4444;
    font-size: 10px;
    font-weight: 900;
}

.empty-box {
    padding: 18px;
    border-radius: 12px;
    background: var(--panel-2);
    color: var(--muted);
    border: 1px dashed var(--border);
}

.small-meta {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}

.coaches-block {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.coaches-block-right {
    text-align: right;
}

.coach-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.coach-line:last-child {
    margin-bottom: 0;
}

.coach-left,
.coach-right {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.coach-name {
    font-weight: 600;
    color: var(--text);
    font-size: 13px;
}

.coach-badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 8px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.coach-actions {
    display: inline-flex;
    gap: 6px;
}

.events-panel {
    position: sticky;
    top: 110px;
    padding: 16px;
}

.panel-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.events-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    padding-right: 4px;
}

.event-row {
    display: grid;
    grid-template-columns: 1fr 56px 1fr;
    gap: 10px;
    align-items: stretch;
}

.event-side {
    min-height: 64px;
}

.event-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-2);
    padding: 10px 12px;
    min-height: 64px;
}

.event-card.home {
    text-align: right;
}

.event-card.away {
    text-align: left;
}

.event-time {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(79, 140, 255, 0.12);
    color: var(--accent);
    font-size: 14px;
    font-weight: 800;
    border: 1px solid rgba(79, 140, 255, 0.18);
}

.event-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
}

.event-sub {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

.event-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 6px;
}

@media (max-width: 1320px) {
    .game-layout {
        grid-template-columns: 1fr;
    }

    .events-panel {
        position: static;
    }

    .events-list {
        max-height: none;
    }
}

@media (max-width: 980px) {
    .match-header {
        grid-template-columns: 1fr;
    }

    .team-box.right {
        justify-content: flex-start;
        text-align: left;
    }

    .lineups-grid {
        grid-template-columns: 1fr;
    }
}


.lineups-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.team-panel-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 14px;
}

.section-title {
    margin: 18px 0 10px;
    font-size: 15px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 12px;
    background: var(--panel-2);
}

th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 14px;
}

th {
    color: var(--muted);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.02);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.num-col {
    width: 70px;
}

.empty-box {
    padding: 18px;
    border-radius: 12px;
    background: var(--panel-2);
    color: var(--muted);
    border: 1px dashed var(--border);
}

.small-meta {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}

.num-col {
    width: 60px;
    text-align: center;
}

.num-cell {
    text-align: center;
    font-weight: 600;
}

.player-name {
    font-weight: 600;
}

.player-first {
    color: var(--muted);
}

.gk-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 6px;
    background: rgba(79, 140, 255, 0.2);
    color: #8ab4ff;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.table-compact th,
.table-compact td {
    padding: 8px 10px;
}

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 8px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.status-scheduled {
    background: rgba(154, 164, 178, 0.18);
    color: #c2cad5;
}

.status-live {
    background: rgba(79, 140, 255, 0.18);
    color: #8ab4ff;
}

.status-finished {
    background: rgba(46, 160, 67, 0.18);
    color: #57d17a;
}

.col-last {
    width: 45%;
}

.col-first {
    width: 45%;
}

.num-col {
    width: 60px;
}

table {
    table-layout: fixed;
}

.player-name,
.player-first {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tour-table {
    table-layout: auto;
}

.tour-date-col {
    width: 1%;
    white-space: nowrap;
}

.tour-match-col {
    width: 52%;
}

.tour-meta-col {
    width: 1%;
    white-space: nowrap;
}

.tour-stadium-col {
    width: auto;
}

.tour-date-cell {
    white-space: nowrap;
    color: var(--text);
}

.tour-match-cell {
    font-weight: 600;
}

.tour-meta-cell {
    white-space: nowrap;
}

.tour-meta-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.score-badge {
    display: inline-block;
    min-width: 48px;
    text-align: center;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.stadium-cell {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
}

.standings-table .st-pos-col {
    width: 50px;
    text-align: center;
}

.standings-table .st-logo-col {
    width: 54px;
    text-align: center;
}

.standings-table .st-team-col {
    width: auto;
}

.standings-table .st-stat-col,
.standings-table .st-gfga-col,
.standings-table .st-points-col {
    width: 64px;
    text-align: center;
    white-space: nowrap;
}

.standings-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

.standings-row-home td {
    background: #FF00FF !important;
    color: #ffffff;
}

.standings-row-away td {
    background: #6E00A5 !important;
    color: #ffffff;
}

.standings-row-home:hover td,
.standings-row-away:hover td {
    background: inherit !important;
    color: #ffffff;
}

.standings-row-home .player-name,
.standings-row-away .player-name {
    color: #ffffff;
}

.standings-row-home img,
.standings-row-away img {
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.35));
}

.captain-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 6px;
    background: rgba(255, 215, 0, 0.18);
    color: #ffd54a;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.coaches-block {
    margin-bottom: 10px;
}

.coach-line {
        display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.3;
    color: var(--muted);
}

.coach-name {
    font-weight: 600;
    color: var(--text);
}

.coach-left {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1 1 auto;
    min-width: 0;
}

.coach-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    position: relative;
    z-index: 5;
}

.coach-actions .icon-btn {
    position: relative;
    z-index: 6;
    pointer-events: auto;
}

.coach-role {
    color: var(--muted);
}

.coaches-block-right {
    text-align: right;
}

.coaches-block {
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.coach-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 3px 8px;
    font-size: 11px;
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;

    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.formation-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.formation-select {
    min-height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
}

.pitch {
    position: relative;
    width: 800px;
    max-width: 100%;
    margin: 0 auto;
}

.pitch-img {
    width: 100%;
    display: block;
}

.players-layer {
    position: absolute;
    inset: 0;
    /* важно */
}

.wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

.pitch-half {
    position: relative;
    width: 100%;
    height: 980px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.18);
    background: #4b0b68;
}

/* Контур поля */
.pitch-half::before {
    content: "";
    position: absolute;
    inset: 14px;
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-bottom: none;
    pointer-events: none;
}

.pitch-half::after {
    content: "";
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 72px;
    border: 3px solid rgba(255, 255, 255, 0.6);
    border-top: none;
    pointer-events: none;
}

/* Центральный круг нижней части */
.pitch-center-circle {
    position: absolute;
    left: 50%;
    bottom: 64px;
    transform: translateX(-50%);
    width: 180px;
    height: 180px;
    border: 3px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    pointer-events: none;
}

.pitch-center-line {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 154px;
    height: 0;
    border-top: 3px solid rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

/* Игрок */
.player-node {
    position: absolute;
    width: 150px;
    transform: translate(-50%, -50%);
    z-index: 5;
    user-select: none;
    cursor: default;
    margin-left: 0;
}

.player-node.dragging {
    cursor: grabbing;
    z-index: 20;
}

.player-photo {
    width: 110px;
    height: 138px;
    margin: 0 auto;
    display: block;
    object-fit: contain;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
    pointer-events: none;
}

.player-photo,
.player-silhouette {
    width: 95px;
    height: 120px;
}

.player-silhouette {
    position: relative;
    width: 110px;
    height: 138px;
    margin: 0 auto;
    border-radius: 18px 18px 8px 8px;
    background: linear-gradient(180deg, #f2f2f2 0%, #d9d9d9 100%);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.player-silhouette::before {
    content: "";
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #b8b8b8;
}

.player-silhouette::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    width: 66px;
    height: 62px;
    border-radius: 36px 36px 12px 12px;
    background: #b8b8b8;
}

.player-label {
    margin: -6px auto 0;
    width: 150px;
    min-height: 28px;
    padding: 4px 8px;
    background: #97ef1f;
    color: #2a2440;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.1;
    text-transform: uppercase;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.player-label-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.lineup-row-sub-in td {
    background: rgba(46, 160, 67, 0.14) !important;
}

.lineup-row-sub-out td {
    background: rgba(220, 53, 69, 0.14) !important;
}

.event-row-center {
    grid-template-columns: 1fr 56px 1fr;
}

.event-time-center-card {
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.event-card {
    position: relative;
}

.event-card.center {
    width: max-content;
    min-width: 180px;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
}

.event-delete-btn {
    position: absolute;
    top: 8px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.event-card.home .event-delete-btn {
    left: 8px;
    right: auto;
}

.event-card.away .event-delete-btn,
.event-card.center .event-delete-btn {
    right: 8px;
    left: auto;
}

.event-delete-btn:hover {
    background: rgba(220, 53, 69, 0.18);
    color: #ffd7dc;
}

.bench-pick-hint {
    display: none;
    margin: 6px 0 10px;
    font-size: 12px;
    color: var(--accent);
}

.bench-pick-active {
    background: rgba(79, 140, 255, 0.12) !important;
    border-radius: 6px;
}

.score-box {
    min-width: 110px;
    height: 46px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-2);
    border: 1px solid var(--border);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 1px;
    padding: 0 14px;
}

.extra-time-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.extra-time-input {
    width: 76px;
    min-height: 38px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}


.lineup-row .player-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lineup-row .player-first {
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lineup-row-sub-in td {
    background: rgba(46, 160, 67, 0.14) !important;
}

.lineup-row-sub-out td {
    background: rgba(220, 53, 69, 0.14) !important;
}


.player-full {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 140px;
}

.player-name-line {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    overflow: hidden;
}

.last-name {
    font-weight: 700;
    white-space: nowrap;
}

.first-name {
    font-weight: 400;
    color: var(--muted);
    white-space: nowrap;
}

.player-badges {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
}


.row-actions button {
    flex: 0 0 auto;
}


/* === Game tab: one beautiful player column === */
.game-lineup-table {
    width: 100%;
    table-layout: fixed;
}

.game-lineup-table .num-col {
    width: 56px;
    text-align: center;
}

.game-lineup-table .player-col {
    width: auto;
}

.game-lineup-table .actions-col {
    width: 150px;
    text-align: right;
    white-space: nowrap;
}

.game-lineup-table th,
.game-lineup-table td {
    padding: 8px 10px;
    vertical-align: middle;
}

.game-lineup-table td.player-cell {
    min-width: 0;
}

.player-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-wrap: nowrap;
}

.player-inline-text {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
    line-height: 1.15;
}

.player-inline-text .last-name {
    font-weight: 700;
    color: var(--text);
}

.player-inline-text .first-name {
    font-weight: 400;
    color: var(--text);
    opacity: 0.92;
}

.player-inline .badges {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    white-space: nowrap;
}

.player-inline .gk-badge,
.player-inline .captain-badge {
    margin-left: 0;
    vertical-align: middle;
}

.game-lineup-table .row-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.game-lineup-table .icon-btn {
    width: 22px;
    height: 22px;
    font-size: 11px;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

.game-lineup-table .icon-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border: none;
}

.discipline-badge-yellow2,
.discipline-badge-red {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    border-radius: 6px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.discipline-badge-yellow2 {
    background: rgba(242, 201, 76, 0.18);
    color: #f2c94c;
}

.discipline-badge-red {
    background: rgba(220, 53, 69, 0.18);
    color: #ff7b88;
}

.lineup-row-expelled-hidden {
    display: none !important;
}


tr.lineup-row.lineup-row-expelled-hidden {
    display: none !important;
}

tr.lineup-row[data-role="expelled"] .row-actions {
    display: none !important;
}

.edit-mode-toggle-note {
    font-size: 12px;
    color: var(--muted);
}

body:not(.edit-mode-on) [data-edit-lock] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

body:not(.edit-mode-on) .player-node {
    cursor: default !important;
}

body:not(.edit-mode-on) .pitch-half::before,
body:not(.edit-mode-on) .pitch-half::after,
body:not(.edit-mode-on) .pitch-center-line,
body:not(.edit-mode-on) .pitch-center-circle {
    pointer-events: none;
}

body.edit-mode-on .player-node {
    cursor: grab !important;
}

body.edit-mode-on .player-node.dragging {
    cursor: grabbing !important;
}

#editModeToggle.btn-primary {
    box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.35), 0 10px 24px rgba(79, 140, 255, 0.18);
}

.extra-time-wrap {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.extra-time-control {
    display: inline-flex;
    align-items: stretch;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--panel-2);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.extra-time-input {
    width: 72px;
    height: 40px;
    padding: 0 10px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    appearance: textfield;
    -moz-appearance: textfield;
}

.extra-time-input::placeholder {
    color: var(--muted);
    font-weight: 600;
}

.extra-time-input::-webkit-outer-spin-button,
.extra-time-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.extra-time-arrows {
    display: flex;
    flex-direction: column;
    width: 30px;
    flex: 0 0 30px;
    border-left: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.extra-time-arrows button {
    all: unset;
    box-sizing: border-box;
    width: 30px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    font-size: 9px;
    line-height: 1;
    user-select: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

.extra-time-arrows button:first-child {
    border-bottom: 1px solid var(--border);
}

.extra-time-arrows button:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.extra-time-arrows button:active {
    background: rgba(79, 140, 255, 0.18);
    color: var(--accent);
    transform: scale(0.96);
}

.formation-modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 3000;
}

.formation-modal.show {
    display: block;
}

.formation-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.formation-modal-content {
    position: relative;
    z-index: 2;
    width: min(760px, 94vw);
    max-height: 88vh;
    overflow: auto;
    margin: 4vh auto 0;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
    padding: 20px;
}

.formation-modal-header,
.formation-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.formation-modal-title {
    font-size: 22px;
    font-weight: 700;
    color: #111;
}

.formation-modal-subtitle {
    margin-top: 6px;
    color: #666;
    font-size: 14px;
    font-weight: 600;
}

.formation-modal-body {
    margin-top: 18px;
}

.formation-input-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    table-layout: auto;
}

.formation-input-table th,
.formation-input-table td {
    border: 1px solid #e1e1e1;
    padding: 10px 12px;
    text-align: left;
    vertical-align: middle;
    color: #111;
}

.formation-input-table th {
    background: #f8f8f8;
    font-weight: 700;
}

.formation-number-input {
    width: 110px;
    padding: 8px 10px;
    border: 1px solid #bbb;
    border-radius: 8px;
    outline: none;
    background: #fff;
    color: #111;
}

.formation-number-input:focus {
    border-color: #222;
}

.formation-available-numbers {
    font-size: 12px;
    color: #666;
}

.formation-modal-footer {
    margin-top: 18px;
}



.squad-editor-modal-content {
    width: min(1320px, 96vw);
}

.squad-editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.squad-editor-team {
    background: #f7f8fb;
    border: 1px solid #e6e8ef;
    border-radius: 14px;
    padding: 14px;
}

.squad-editor-team-title {
    font-size: 18px;
    font-weight: 800;
    color: #111;
    margin-bottom: 12px;
}

.squad-editor-section {
    margin-bottom: 16px;
}

.squad-editor-section:last-child {
    margin-bottom: 0;
}

.squad-editor-section-title {
    font-size: 13px;
    font-weight: 800;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 8px;
}

.squad-editor-box {
    background: #fff;
    border: 1px solid #e1e4ea;
    border-radius: 12px;
    padding: 10px;
}

.squad-editor-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.squad-editor-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid #eceef3;
    border-radius: 10px;
    background: #fff;
}

.squad-editor-player {
    min-width: 0;
}

.squad-editor-player-name {
    font-size: 14px;
    font-weight: 700;
    color: #111;
}

.squad-editor-player-meta {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.squad-editor-actions {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

.squad-editor-btn {
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid #d7dbe5;
    border-radius: 8px;
    background: #fff;
    color: #111;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.squad-editor-btn:hover {
    background: #f2f4f8;
}

.squad-editor-btn.primary {
    background: #4f8cff;
    border-color: #4f8cff;
    color: #fff;
}

.squad-editor-btn.primary:hover {
    background: #3e78e6;
}

.squad-editor-btn.danger {
    background: #fff5f6;
    border-color: #f0c7cc;
    color: #b42318;
}

.squad-editor-btn.active {
    background: #fff7db;
    border-color: #f2c94c;
    color: #6b5500;
}

.squad-editor-select {
    width: 100%;
    min-height: 38px;
    border: 1px solid #d7dbe5;
    border-radius: 10px;
    background: #fff;
    color: #111;
    padding: 0 10px;
    margin-bottom: 8px;
}

.squad-editor-hint {
    font-size: 12px;
    color: #777;
    margin-top: 6px;
}

@media (max-width: 1100px) {
    .squad-editor-grid {
        grid-template-columns: 1fr;
    }
}

[data-edit-only] {
    display: none !important;
}

body.edit-mode-on [data-edit-only] {
    display: inline-flex !important;
}


.referee-edit-controls {
    display: none;
    margin-top: 12px;
    gap: 10px;
}

body.edit-mode-on .referee-edit-controls {
    display: flex !important;
}

body:not(.edit-mode-on) .referee-search {
    display: none !important;
}


.referee-search {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.referee-search input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
}

.referee-search-list {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid #2c3440;
    border-radius: 8px;
    background: #11161c;
}

.referee-search-item {
    padding: 8px 10px;
    cursor: pointer;
}

.referee-search-item:hover {
    background: #1f2933;
}

/* ===== Судьи: селект роли ===== */
.referee-search select,
#newRefereeRole {
    min-height: 40px;
    width: 240px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    outline: none;
    box-shadow: none;
}

.referee-search select:focus,
#newRefereeRole:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(79, 140, 255, 0.18);
}

/* ===== Судьи: кнопка удаления ===== */
.referee-delete-btn {
    width: 30px;
    height: 30px;
    border: 1px solid rgba(220, 53, 69, 0.35);
    border-radius: 8px;
    background: rgba(220, 53, 69, 0.12);
    color: #ff9aa5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease, color 0.15s ease;
}

.referee-delete-btn:hover {
    background: rgba(220, 53, 69, 0.22);
    border-color: rgba(220, 53, 69, 0.55);
    color: #ffd7dc;
    transform: translateY(-1px);
}

.referee-delete-btn:active {
    transform: translateY(0);
}

.event-edit-btn {
    position: absolute;
    top: 8px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.event-edit-btn:hover {
    background: rgba(79, 140, 255, 0.18);
    color: #cfe0ff;
}

.event-card-actions {
    position: absolute;
    top: 6px;
    display: inline-flex;
    gap: 4px;
    align-items: center;
    z-index: 20;
    pointer-events: auto;
}

.event-card.home .event-card-actions {
    left: 6px;
    right: auto;
}

.event-card.away .event-card-actions,
.event-card.center .event-card-actions {
    right: 6px;
    left: auto;
}

.event-delete-btn,
.event-edit-btn {
    position: static !important;
    z-index: 21;
    pointer-events: auto;
}

.formation-modal.open {
    display: block;
}

.goal-editor-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.goal-editor-player-btn {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.goal-editor-player-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(79, 140, 255, 0.4);
}

.goal-editor-player-number {
    min-width: 32px;
    height: 26px;
    padding: 0 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.goal-editor-player-name {
    flex: 1 1 auto;
    min-width: 0;
}

#goalEditorModal {
    z-index: 4000;
}

.event-card-clickable {
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.event-card-clickable:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(79, 140, 255, 0.35);
}

/* ===== Модалка: кнопки ===== */

.modal-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-close-btn:hover {
    background: rgba(220, 53, 69, 0.18);
    color: #ffd7dc;
    border-color: rgba(220, 53, 69, 0.45);
    transform: translateY(-1px);
}

/* Отмена */
.btn-cancel {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

/* Сохранить / Применить */
.btn-confirm {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    box-shadow: 0 6px 16px rgba(79, 140, 255, 0.25);
}

.btn-confirm:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
}

.matrix-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.93);
    overflow: hidden;
}

.matrix-loader.active {
    display: flex;
}

.matrix-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.matrix-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 24px 28px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(0, 255, 120, 0.25);
    box-shadow: 0 0 30px rgba(0, 255, 120, 0.12);
    backdrop-filter: blur(4px);
}

.matrix-title {
    margin-bottom: 10px;
    font-size: 28px;
    font-weight: 700;
    color: #9dffb2;
    text-shadow: 0 0 10px rgba(0, 255, 120, 0.35);
}

.matrix-status {
    font-size: 15px;
    color: #d7ffe1;
    opacity: 0.95;
}

.matrix-loader.is-error .matrix-content {
    border-color: rgba(255, 90, 90, 0.35);
    box-shadow: 0 0 30px rgba(255, 90, 90, 0.12);
}

.matrix-loader.is-error .matrix-title {
    color: #ff9c9c;
    text-shadow: 0 0 10px rgba(255, 90, 90, 0.25);
}

.matrix-loader.is-error .matrix-status {
    color: #ffd4d4;
}

.matrix-loader.is-success .matrix-title {
    color: #9dffb2;
}

.player-link {
    cursor: pointer;
}

.player-link .last-name,
.player-link .first-name,
.coach-link-btn .coach-name,
.coach-left .coach-name {
    color: #8ab4ff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.player-link:hover .last-name,
.player-link:hover .first-name,
.coach-link-btn:hover .coach-name,
.coach-left:hover .coach-name {
    color: #a9c7ff;
}

.player-link-btn {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.player-link-btn .last-name,
.player-link-btn .first-name {
    color: #8ab4ff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.player-link-btn:hover .last-name,
.player-link-btn:hover .first-name {
    color: #a9c7ff;
}

.player-link-btn:focus-visible {
    outline: 2px solid rgba(138, 180, 255, 0.45);
    outline-offset: 2px;
    border-radius: 6px;
}

