* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    padding: 20px;
    background-color: #f4f4f4;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

h2 {
    text-align: center;
    margin-bottom: 10px;
    color: #333;
}

.add-player-section {
    background: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.reset-btn {
    background: #ff4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
}

.reset-btn:hover {
    background: #cc0000;
}

.control-buttons-section {
    background: white;
    padding: 5px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sort-buttons {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
    width: 100%;
    align-items: center;
}

.random-buttons {
    display: flex;
    gap: 5px;
    margin-right: auto;
}

.sort-btn {
    padding: 5px 10px;
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.random-btn {
    padding: 5px 10px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.random-btn[data-type="male"] {
    background: #399ced;
    border: 1px solid #2980b9;
}

.random-btn[data-type="male"]:hover {
    background: #2980b9;
}

.random-btn[data-type="female"] {
    background: #ff56b6;
    border: 1px solid #e91e63;
}

.random-btn[data-type="female"]:hover {
    background: #e91e63;
}

.random-btn[data-type="mixed"] {
    background: linear-gradient(to right, #399ced 25%, #ff56b6 75%);
    border: 1px solid #2980b9;
}

.random-btn[data-type="mixed"]:hover {
    background: linear-gradient(to right, #2980b9 25%, #e91e63 75%);
}

.sort-btn:hover {
    background: #e0e0e0;
}

.sort-btn.active {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

form {
    display: flex;
    gap: 10px;
}

input, select, button {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

button {
    background: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
}

button:hover {
    background: #45a049;
}

.main-content {
    display: grid;
    grid-template-columns: 70% 30%;
    gap: 20px;
}

.left-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.right-section {
    height: 100%;
}

.players-area, .waiting-area, .courts-container {
    background: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.drop-area {
    min-height: 150px;
    border: 2px dashed #ccc;
    border-radius: 4px;
    padding: 10px;
}

.players-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px;
}

.waiting-area {
    height: 840px;
    background: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.waiting-groups {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    gap: 10px;
    height: 100%;
}

.waiting-group {
    height: 140px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.waiting-group-header {
    background: #e0e0e0;
    padding: 5px;
    border-radius: 3px;
    cursor: default;
    font-weight: bold;
    text-align: center;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1;
}

.waiting-group-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
    flex: 1;
    padding: 5px;
    background: #fff;
    border-radius: 3px;
    min-height: 0;
}

.waiting-group .player {
    width: 100%;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    vertical-align: middle;
}

.group-number {
    flex: 1;
    text-align: left;
    padding-left: 5px;
}

.court-buttons {
    display: flex;
    gap: 5px;
}

.assign-court {
    padding: 2px 5px;
    font-size: 0.8em;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    opacity: 0.5;
    pointer-events: none;
}

.assign-court.active {
    opacity: 1;
    pointer-events: auto;
    background: #4CAF50;
}

.assign-court.active:hover {
    background: #45a049;
}

.waiting-group.dragging {
    opacity: 0.5;
    border: 2px dashed #666;
}

.waiting-group .player {
    flex: 1;
    min-width: 0;
}

.courts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.court {
    border: 2px solid #333;
    border-radius: 4px;
    background: #f9f9f9;
    padding: 10px;
    min-width: 200px;
}

.court-header {
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
}

.court-content {
    min-height: 114px;
    margin-bottom: 10px;
}

.court-content .player {
    width: 100%;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1;
    vertical-align: middle;
}

.finish-game {
    width: 100%;
    background: #f44336;
}

.finish-game:hover {
    background: #d32f2f;
}

.player {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3px 6px;
    margin: 2px;
    border-radius: 3px;
    cursor: move;
    font-size: 0.8em;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
    height: 100%;
    line-height: 1;
    vertical-align: middle;
    position: relative;
}

.player:hover .delete-player-btn {
    display: block;
}

.delete-player-btn {
    display: none;
    position: absolute;
    right: 2px;
    top: 1px;
    width: 16px;
    height: 16px;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    text-align: center;
    z-index: 2;
}

.delete-player-btn:hover {
    background: #cc0000;
}

.male {
    background-color: #399ced;
    color: white;
}

.female {
    background-color: #ff56b6;
    color: white;
}

.team {
    border: 1px solid #ddd;
    padding: 5px;
    margin: 2px;
    border-radius: 4px;
    background: #fff;
    font-size: 0.9em;
}

.dragging {
    opacity: 0.5;
}

.sortable-ghost {
    opacity: 0.4;
    background: #F0F0F0;
}

.sortable-drag {
    opacity: 0.8;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
} 

.player-count {
    display: inline-flex;
    align-items: center;
    margin-left: 15px;
    font-size: 14px;
    font-weight: 1000;
    margin-right: 30px;
    color: #333;
    height: 100%;
}

.count-divider {
    margin: 0 8px;
    color: #ccc;
    display: inline-flex;
    align-items: center;
}

#addPlayerForm {
    display: flex;
    align-items: center;
    gap: 10px;
}

#addPlayerForm input,
#addPlayerForm select,
#addPlayerForm button {
    height: 35px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#addPlayerForm button {
    background-color: #4CAF50;
    color: white;
    border: none;
    cursor: pointer;
    padding: 0 20px;
}

#addPlayerForm button:hover {
    background-color: #45a049;
}

/* 선수 통계 테이블 스타일 */
.player-stats-container {
    display: flex;
    gap: 20px;
}

.stats-table {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 10px;
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.stats-table h3 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #333;
    text-align: center;
}

.stats-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.stats-table th {
    background-color: #f0f0f0;
    padding: 6px;
    text-align: center;
    border: 1px solid #ddd;
    font-weight: 600;
}

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

.stats-table .even-row {
    background-color: #ffffff;
    height: 24px;
}

.stats-table .odd-row {
    background-color: #f9f9f9;
    height: 24px;
}

.stats-table tr:hover {
    background-color: #f5f5f5;
}

/* 매치 히스토리 스타일 */
.match-history-section {
    width: 100%;
    margin-top: 20px;
    background: white;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 15px;
}

.match-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
}

.match-history-header h3 {
    color: #333;
    margin: 0;
    font-size: 20px;
}

.history-count {
    font-size: 14px;
    color: #666;
    font-weight: bold;
}

.match-history-content {
    /* max-height: 300px; */
    overflow-y: hidden;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #f9f9f9;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    align-content: start;
}

.match-history-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 1px solid #eee;
    background: white;
    border-radius: 5px;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.match-history-item:hover {
    background-color: #f5f5f5;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
}

.match-court {
    background: #6f6f6f;
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 12px;
    min-width: 65px;
    text-align: center;
}

.match-duration {
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.match-players {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 10px;
}

.match-player {
    background: #e9ecef;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid #dee2e6;
    text-align: center;
}

.match-player.male {
    background-color: #399ced;
    color: white;
    border-color: #399ced;
}

.match-player.female {
    background-color: #ff56b6;
    color: white;
    border-color: #ff56b6;
}

.match-time {
    color: #666;
    font-size: 11px;
    text-align: center;
    font-weight: 500;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 10px;
}

.no-history {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
    background: white;
    border-radius: 5px;
    border: 1px solid #eee;
}

/* 스크롤바 스타일 */
.match-history-content::-webkit-scrollbar {
    width: 8px;
}

.match-history-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.match-history-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.match-history-content::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 반응형 디자인 */
@media (max-width: 1400px) {
    .match-history-content {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1000px) {
    .match-history-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 모바일에서는 1열로 변경 */
@media (max-width: 768px) {
    .match-history-content {
        grid-template-columns: 1fr;
    }
    
    .match-history-section {
        padding: 10px;
    }
    
    .match-history-header h3 {
        font-size: 18px;
    }
}