/* 기본 스타일 및 레이아웃 */
body {
    font-family: 'Malgun Gothic', sans-serif;
    background-color: #1a472a; /* 어두운 녹색 배경 */
    color: #f0f0f0;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 1360px;
    background-color: #ffffff; /* 흰색 배경 */
    color: #333; /* 어두운 글자색 */
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

h1, h2, h3 {
    color: #1a472a;
    text-align: center;
}

/* 헤더 및 달력 */
.header-container {
    background-color: #2a6f47; /* 헤더 배경색 */
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.header-container h1 {
    color: #fff;
    margin: 0 0 20px 0;
    font-size: 2em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-container h1::before {
    content: '⚽';
    margin-right: 15px;
}

/* 달력과 경기 입력 레이아웃 */
.calendar-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    justify-content: flex-start;
}

#date-picker-container {
    background-color: #fff;
    padding: 15px;
    border-radius: 6px;
    flex-shrink: 0;
    margin-left: 20px;
}

.header-input-panel {
    background-color: #fff;
    padding: clamp(18px, 2.2vw, 30px);
    border-radius: 6px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 234px;
}

.header-input-panel h2 {
    margin: 0 0 clamp(18px, 2vw, 28px) 0;
    font-size: 1.45em;
}

.header-input-panel .game-form-container {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 52px minmax(240px, 1fr) minmax(110px, 0.38fr);
    align-items: end;
    width: min(960px, 100%);
    gap: clamp(14px, 1.8vw, 24px);
    margin: 0 auto;
}

.header-input-panel .team-section {
    align-items: stretch;
    min-width: 0;
    width: 100%;
}

.header-input-panel .team-label {
    text-align: left;
}

.header-input-panel .player-selectors,
.header-input-panel .team-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}

.header-input-panel .player-selectors select,
.header-input-panel .team-controls select,
.header-input-panel .team-controls input {
    width: 100%;
    min-height: 38px;
    box-sizing: border-box;
    padding: 8px 10px;
    font-size: 0.95rem;
}

.header-input-panel .vs-section,
.header-input-panel .submit-section {
    align-self: end;
    margin-top: 0;
}

.header-input-panel .vs-section span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    width: 52px;
}

.header-input-panel .submit-section button {
    width: 100%;
    min-height: 42px;
    padding: 0 14px;
}

#match-history-container {
    display: none;
}

#match-history-container h3 {
    margin: 0 0 10px 0;
    color: #2a6f47;
    font-size: 1.1em;
}

#match-months-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0px;
    overflow-y: auto;
    flex: 1;
    max-height: 280px;
    padding-right: 5px;
}

/* 스크롤바 스타일링 */
#match-months-list::-webkit-scrollbar {
    width: 6px;
}

#match-months-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#match-months-list::-webkit-scrollbar-thumb {
    background: #2a6f47;
    border-radius: 3px;
}

#match-months-list::-webkit-scrollbar-thumb:hover {
    background: #1a472a;
}

.month-badge {
    background: #2e7d4f;
    color: #fff;
    display: inline-block;
    margin: 2px;
    padding: 4px 8px;
    min-width: 80px;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.month-badge:hover {
    background-color: #1a472a;
}

.month-badge.active {
    background-color: #f0ad4e;
    color: #333;
}

/* 게임 폼 스타일 */
.game-form-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.team-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 200px;
}

.team-label {
    font-weight: bold;
    color: #2a6f47;
    margin-bottom: 5px;
}

.player-selectors {
    display: flex;
    gap: 5px;
}

.player-selectors select {
    width: 80px;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

.team-controls {
    display: flex;
    gap: 5px;
    align-items: center;
}

.team-controls select {
    width: 120px;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

.team-controls input {
    width: 60px;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
    text-align: center;
}

.formation-input input {
    width: 100px;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
    text-align: center;
    font-size: 0.9em;
}

.vs-section {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 30px;
}

.vs-section span {
    font-size: 1.2em;
    font-weight: bold;
    color: #2a6f47;
}

.submit-section {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 30px;
}

.submit-section button {
    padding: 10px 20px;
    background-color: #2a6f47;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

.submit-section button:hover {
    background-color: #1a472a;
}

.selectors {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

select {
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

#day-buttons-container {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.month-btn,
.day-btn {
    min-height: 56px;
    padding: 8px;
    border: none;
    border-radius: 4px;
    background-color: #edf3ef;
    color: #486258;
    cursor: pointer;
    transition: background-color 0.2s;
}

.month-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
}

.month-btn strong {
    font-size: 1rem;
}

.month-meta {
    font-size: 0.78rem;
    font-weight: 700;
}

.month-btn:hover {
    background-color: #dfece4;
}

.month-btn.has-data,
.day-btn {
    background-color: #2a6f47;
    color: white;
}

.month-btn.has-data:hover,
.day-btn:hover {
    background-color: #3a8f57;
}

.month-btn.has-multiple {
    padding: 7px;
}

.month-date-select {
    width: 100%;
    min-width: 0;
    margin-top: 2px;
    padding: 3px 4px;
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: 4px;
    background: #fff;
    color: #1a472a;
    font-size: 0.78rem;
}

.day-btn.has-data {
    font-weight: bold;
    background-color: #ff8c00; /* 데이터 있는 날 - 주황색 */
    color: white;
}

.month-btn.selected,
.day-btn.selected {
    background-color: #f0ad4e; /* 선택된 날 */
    color: #333;
}

.month-btn.selected .month-date-select {
    border-color: rgba(51,51,51,0.25);
}

/* 전적 섹션 */
.stats-section {
    margin-bottom: 20px;
}

.stats-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.period-buttons button, .view-mode-btn {
    padding: 8px 15px;
    border: 1px solid #ccc;
    background-color: #f0f0f0;
    cursor: pointer;
    border-radius: 5px;
}

.period-buttons button.active, .view-mode-btn.active {
    background-color: #2a6f47;
    color: white;
    border-color: #2a6f47;
}

/* 테이블 스타일 */
.stats-table-container, .stats-chart-container {
    display: flex;
    gap: 20px;
    justify-content: space-around;
    flex-wrap: wrap;
}

.stats-group, .chart-group {
    flex: 1;
    min-width: 400px;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.stats-table th, .stats-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
}

.stats-table th {
    background-color: #e9e9e9;
}

/* 숨김 클래스 */
.hidden {
    display: none;
}

.chart-group {
    flex: 1;
    min-width: 320px;
    max-width: 380px;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-group.chart-wide {
    max-width: none;
    flex-basis: 100%;
}

.chart-group canvas {
    max-width: 340px;
    width: 100%;
    height: 240px !important;
}

.chart-group.chart-wide canvas {
    max-width: 100%;
    height: 300px !important;
}



/* 포메이션 툴팁 스타일 */
.tooltip-container {
    position: relative;
    cursor: help;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.tooltip {
    position: absolute;
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: normal;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    
    /* 툴팁 위치 조정 */
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
}

.tooltip-container:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* 포메이션 정보 스타일 */
.formation-info {
    font-weight: bold;
    color: #4CAF50;
}

.formation-info::before {
    content: '⚽ ';
    color: #FFD700;
}

/* 편집 모달 스타일 */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-50px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    background-color: #2a6f47;
    color: white;
    padding: 15px 20px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: white;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    opacity: 0.7;
}

.edit-form-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 20px;
    border-top: 1px solid #ddd;
    background-color: #f9f9f9;
    border-radius: 0 0 10px 10px;
}

.btn-save {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.btn-save:hover {
    background-color: #218838;
}

.btn-delete {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.btn-delete:hover {
    background-color: #c82333;
}

.btn-cancel {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.btn-cancel:hover {
    background-color: #5a6268;
}

.edit-btn, .delete-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    margin-right: 5px;
}

.edit-btn:hover {
    background-color: #0056b3;
}

.delete-btn {
    background-color: #dc3545;
}

.delete-btn:hover {
    background-color: #c82333;
}

/* 비교 대시보드 */
.comparison-dashboard {
    margin: 18px 0 22px;
    padding: 18px;
    background: #f5f8f6;
    border: 1px solid #d8e6dc;
    border-radius: 8px;
}

.dashboard-title-row,
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dashboard-title-row h3,
.panel-header h3 {
    margin: 0;
    text-align: left;
}

#active-period-label {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: #1f6f8b;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0;
}

.summary-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 92px;
    padding: 14px;
    background: #fff;
    border: 1px solid #dde5e0;
    border-radius: 8px;
}

.summary-card-title,
.summary-card-meta {
    color: #66736c;
    font-size: 0.85rem;
}

.summary-card strong {
    color: #143b27;
    font-size: 1.25rem;
    line-height: 1.25;
}

.comparison-grid {
    display: grid;
    grid-template-columns: minmax(420px, 0.95fr) minmax(460px, 1.05fr);
    gap: 14px;
}

.comparison-panel {
    min-width: 0;
    padding: 14px;
    background: #fff;
    border: 1px solid #dde5e0;
    border-radius: 8px;
}

.table-scroll {
    overflow-x: auto;
}

.ranking-table th,
.ranking-table td,
.head-to-head-table th,
.head-to-head-table td {
    white-space: nowrap;
}

.rank-cell {
    width: 52px;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2a6f47;
    color: #fff;
    font-weight: 700;
}

.player-name-cell {
    font-weight: 700;
    color: #143b27;
}

.points-cell {
    font-weight: 700;
    color: #1f6f8b;
}

.head-to-head-table td strong,
.head-to-head-table td span {
    display: block;
}

.head-to-head-table td span {
    margin-top: 3px;
    color: #66736c;
    font-size: 0.82rem;
}

.head-to-head-empty {
    color: #9aa7a0;
    background: #f3f4f3;
}

.winner {
    color: #1f6f8b;
    font-weight: 700;
}

.draw {
    color: #6c757d;
    font-weight: 700;
}

.loading-cell {
    padding: 20px;
    color: #66736c;
    text-align: center;
}

@media (max-width: 980px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 12px;
    }

    .calendar-layout,
    .game-form-container {
        flex-direction: column;
        align-items: stretch;
    }

    #date-picker-container {
        margin-left: 0;
    }

    .header-input-panel {
        min-height: 0;
    }

    .header-input-panel .game-form-container {
        grid-template-columns: 1fr 52px 1fr;
        width: 100%;
    }

    .header-input-panel .submit-section {
        grid-column: 1 / -1;
        justify-self: center;
        width: min(240px, 100%);
    }

    .summary-cards,
    .comparison-grid {
        grid-template-columns: 1fr;
    }

    .stats-group,
    .chart-group {
        min-width: 0;
        width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 640px) {
    .header-container h1 {
        font-size: 1.35em;
    }

    .stats-header,
    .dashboard-title-row,
    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .period-buttons,
    #view-mode-selector {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .header-input-panel .game-form-container {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .header-input-panel .team-label {
        text-align: center;
    }

    .header-input-panel .vs-section,
    .header-input-panel .submit-section {
        align-self: stretch;
    }

    .header-input-panel .vs-section span {
        width: 100%;
    }

    .period-buttons button,
    .view-mode-btn,
    select {
        width: 100%;
    }

    .player-selectors,
    .team-controls {
        width: 100%;
    }

    .player-selectors select,
    .team-controls select,
    .team-controls input {
        flex: 1;
        width: auto;
    }
}

/* 2026 polished dashboard refresh */
:root {
    --page-bg: #edf2ef;
    --surface: #ffffff;
    --surface-soft: #f7faf8;
    --surface-tint: #eef6f1;
    --ink: #1b2922;
    --muted: #68766f;
    --line: #dbe6df;
    --line-strong: #c7d7ce;
    --green-900: #0f3527;
    --green-800: #16452f;
    --green-700: #1f6d46;
    --green-600: #2f8053;
    --teal: #1f6f8b;
    --amber: #f4b447;
    --amber-strong: #d98a12;
    --danger: #d34a4a;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 38, 27, 0.08);
    --shadow-md: 0 12px 28px rgba(15, 38, 27, 0.12);
    --shadow-lg: 0 24px 60px rgba(15, 38, 27, 0.18);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--page-bg);
}

body {
    min-height: 100vh;
    margin: 0;
    padding: clamp(14px, 2vw, 28px);
    display: block;
    background:
        linear-gradient(180deg, var(--green-900) 0, var(--green-800) 235px, var(--page-bg) 235px, var(--page-bg) 100%);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    line-height: 1.5;
}

.container {
    width: min(100%, 1400px);
    margin: 0 auto;
    padding: clamp(18px, 2vw, 28px);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.84);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
}

h1,
h2,
h3 {
    margin-top: 0;
    color: var(--green-900);
    letter-spacing: 0;
}

h2 {
    margin-bottom: 18px;
    font-size: clamp(1.25rem, 1.5vw, 1.55rem);
    font-weight: 800;
}

h3 {
    font-size: 1rem;
    font-weight: 800;
}

.header-container {
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
    padding: clamp(22px, 2.5vw, 34px);
    background:
        linear-gradient(135deg, rgba(15, 53, 39, 0.98), rgba(47, 128, 83, 0.98)),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 78px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), var(--shadow-md);
}

.header-container::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 0 48%, rgba(255, 255, 255, 0.12) 48% 52%, transparent 52%),
        linear-gradient(0deg, transparent 0 49%, rgba(255, 255, 255, 0.07) 49% 51%, transparent 51%);
    opacity: 0.45;
}

.header-container h1,
.calendar-layout {
    position: relative;
    z-index: 1;
}

.header-container h1 {
    margin-bottom: clamp(22px, 3vw, 32px);
    color: #fff;
    font-size: clamp(1.8rem, 3vw, 2.35rem);
    font-weight: 900;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.18);
}

.header-container h1::before {
    margin-right: 12px;
    font-size: 0.95em;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.22));
}

.calendar-layout {
    display: grid;
    grid-template-columns: minmax(218px, 250px) minmax(0, 1fr);
    align-items: stretch;
    gap: clamp(16px, 2vw, 24px);
}

#date-picker-container,
.header-input-panel,
.comparison-dashboard,
.stats-group,
.chart-group,
.comparison-panel,
.summary-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

#date-picker-container {
    margin-left: 0;
    padding: 16px;
    align-self: start;
}

.selectors {
    margin-bottom: 12px;
}

select,
input {
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

select:focus,
input:focus {
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px rgba(47, 128, 83, 0.16);
}

.selectors select {
    width: 100%;
    font-weight: 700;
}

#day-buttons-container {
    gap: 9px;
}

.month-btn,
.day-btn {
    min-height: 72px;
    padding: 10px 8px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: #eef4f1;
    color: #53685e;
    font-weight: 800;
    box-shadow: none;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease, border-color 0.14s ease;
}

.month-btn:hover,
.day-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 38, 27, 0.12);
}

.month-btn strong {
    font-size: 1.05rem;
}

.month-meta {
    color: currentColor;
    font-size: 0.78rem;
    opacity: 0.92;
}

.month-btn.has-data,
.day-btn {
    background: linear-gradient(180deg, var(--green-700), #286b46);
    color: #fff;
}

.month-btn.has-data:hover,
.day-btn:hover {
    background: linear-gradient(180deg, var(--green-600), var(--green-700));
}

.month-btn.selected,
.day-btn.selected {
    background: linear-gradient(180deg, #f8c66a, var(--amber));
    border-color: rgba(151, 94, 9, 0.22);
    color: #2b2417;
    box-shadow: 0 10px 20px rgba(160, 101, 11, 0.18);
}

.month-date-select {
    min-height: 30px;
    margin-top: 4px;
    border-color: rgba(255, 255, 255, 0.76);
    color: var(--green-900);
    font-size: 0.78rem;
    font-weight: 700;
}

.header-input-panel {
    min-height: 0;
    padding: clamp(22px, 3vw, 38px);
}

.header-input-panel h2 {
    margin-bottom: clamp(18px, 2vw, 26px);
    color: var(--green-900);
}

.header-input-panel .game-form-container {
    width: 100%;
    max-width: 1020px;
    grid-template-columns: minmax(230px, 1fr) 54px minmax(230px, 1fr) minmax(112px, 0.36fr);
    gap: clamp(16px, 2vw, 26px);
}

.team-section {
    gap: 10px;
}

.team-label {
    margin-bottom: 0;
    color: var(--green-700);
    font-size: 0.94rem;
    font-weight: 900;
}

.header-input-panel .player-selectors,
.header-input-panel .team-controls,
.player-selectors,
.team-controls {
    gap: 9px;
}

.header-input-panel .player-selectors select,
.header-input-panel .team-controls select,
.header-input-panel .team-controls input {
    min-height: 42px;
}

.vs-section span,
.header-input-panel .vs-section span {
    min-width: 44px;
    min-height: 44px;
    border-radius: 50%;
    background: var(--surface-tint);
    color: var(--green-700);
    font-size: 0.88rem;
    font-weight: 900;
}

.submit-section button,
.btn-save,
.edit-btn {
    border: 0;
    border-radius: 7px;
    background: linear-gradient(180deg, var(--green-600), var(--green-700));
    color: #fff;
    font-weight: 800;
    box-shadow: 0 10px 18px rgba(31, 109, 70, 0.18);
    transition: transform 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease;
}

.submit-section button:hover,
.btn-save:hover,
.edit-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(180deg, #3a9360, var(--green-700));
    box-shadow: 0 14px 24px rgba(31, 109, 70, 0.22);
}

.header-input-panel .submit-section button {
    min-height: 44px;
}

.stats-section {
    margin: 26px 0 0;
}

.stats-section > h2 {
    margin-bottom: 14px;
}

.stats-header {
    gap: 10px;
    margin-bottom: 18px;
    padding: 10px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.period-buttons,
#view-mode-selector {
    display: inline-flex;
    gap: 6px;
}

.period-buttons button,
.view-mode-btn {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: #fff;
    color: #43534b;
    font-weight: 800;
    transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.14s ease;
}

.period-buttons button:hover,
.view-mode-btn:hover {
    transform: translateY(-1px);
    border-color: var(--green-600);
}

.period-buttons button.active,
.view-mode-btn.active {
    background: var(--green-700);
    border-color: var(--green-700);
    color: #fff;
}

#season-selector,
#chart-player-selector {
    min-width: 86px;
    font-weight: 700;
}

.comparison-dashboard {
    margin: 0 0 22px;
    padding: clamp(16px, 2vw, 22px);
    background: linear-gradient(180deg, #f8fbf9, #f2f7f4);
}

.dashboard-title-row {
    margin-bottom: 14px;
}

.dashboard-title-row h3,
.panel-header h3,
.stats-group h3,
.chart-group h3 {
    color: var(--green-900);
}

#active-period-label {
    min-height: 30px;
    background: var(--teal);
    border-radius: 999px;
    box-shadow: 0 8px 16px rgba(31, 111, 139, 0.16);
}

.summary-cards {
    gap: 12px;
    margin: 0 0 14px;
}

.summary-card {
    position: relative;
    min-height: 102px;
    padding: 15px;
    overflow: hidden;
}

.summary-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--green-600);
}

.summary-card-title,
.summary-card-meta {
    color: var(--muted);
}

.summary-card strong {
    color: var(--green-900);
    font-size: 1.35rem;
    font-weight: 900;
}

.comparison-grid {
    grid-template-columns: minmax(420px, 0.95fr) minmax(460px, 1.05fr);
    gap: 14px;
}

.comparison-panel,
.stats-group,
.chart-group {
    padding: 16px;
}

.stats-table-container,
.stats-chart-container {
    gap: 16px;
}

.stats-group,
.chart-group {
    min-width: min(100%, 420px);
    background: var(--surface);
}

.chart-group {
    max-width: 410px;
    overflow: hidden;
}

.chart-group.chart-wide {
    max-width: none;
}

.stats-table {
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
}

.stats-table th,
.stats-table td {
    border: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 9px;
    color: var(--ink);
    vertical-align: middle;
}

.stats-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #edf4f0;
    color: #2f4037;
    font-size: 0.86rem;
    font-weight: 900;
}

.stats-table tbody tr:nth-child(even) {
    background: #fafcfb;
}

.stats-table tbody tr:hover {
    background: #f0f7f3;
}

.stats-table tbody tr:last-child td {
    border-bottom: 0;
}

.rank-badge {
    background: linear-gradient(180deg, var(--green-600), var(--green-700));
    box-shadow: 0 7px 12px rgba(31, 109, 70, 0.18);
}

.player-name-cell,
.points-cell,
.winner {
    color: var(--teal);
}

.draw {
    color: #77827c;
}

.head-to-head-empty {
    background: #f4f6f5;
}

.edit-btn {
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.78rem;
}

.btn-delete {
    background: var(--danger);
}

.btn-delete:hover {
    background: #bf3939;
}

.btn-cancel {
    background: #7b8580;
}

.btn-cancel:hover {
    background: #65706b;
}

.modal {
    background-color: rgba(12, 24, 17, 0.58);
    backdrop-filter: blur(4px);
}

.modal-content {
    border-radius: 12px;
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.28);
}

.modal-header {
    background: linear-gradient(135deg, var(--green-800), var(--green-700));
    border-radius: 12px 12px 0 0;
}

.modal-actions {
    background: var(--surface-soft);
}

.loading-cell {
    color: var(--muted);
}

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

    #date-picker-container {
        width: min(100%, 380px);
        justify-self: center;
    }

    .header-input-panel .game-form-container {
        grid-template-columns: minmax(220px, 1fr) 54px minmax(220px, 1fr);
    }

    .header-input-panel .submit-section {
        grid-column: 1 / -1;
        justify-self: center;
        width: min(260px, 100%);
    }

    .summary-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 720px) {
    body {
        padding: 10px;
        background:
            linear-gradient(180deg, var(--green-900) 0, var(--green-800) 160px, var(--page-bg) 160px, var(--page-bg) 100%);
    }

    .container {
        padding: 10px;
        border-radius: 12px;
    }

    .header-container {
        padding: 14px;
    }

    .header-container h1 {
        margin-bottom: 18px;
        font-size: 1.35rem;
        line-height: 1.2;
    }

    #date-picker-container {
        width: 100%;
        padding: 14px;
    }

    .month-btn,
    .day-btn {
        min-height: 72px;
    }

    .header-input-panel {
        padding: 18px;
    }

    .header-input-panel .game-form-container {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .header-input-panel .team-label {
        text-align: left;
    }

    .header-input-panel .vs-section span {
        width: 100%;
        min-height: 36px;
        border-radius: 7px;
    }

    .period-buttons,
    #view-mode-selector,
    .stats-header {
        width: 100%;
    }

    .stats-header,
    .dashboard-title-row,
    .panel-header {
        align-items: stretch;
    }

    .period-buttons,
    #view-mode-selector {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #season-selector,
    #chart-player-selector {
        width: 100%;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .stats-group,
    .chart-group,
    .comparison-panel {
        min-width: 0;
        width: 100%;
    }

    .stats-table th,
    .stats-table td {
        padding: 8px 7px;
        font-size: 0.82rem;
    }

    .modal-content {
        width: calc(100% - 20px);
        margin-top: 18px;
    }
}
