/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    color: #2c3e50;
}

.controls {
    display: flex;
    gap: 10px;
}

#formation-select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

#reset-btn {
    padding: 5px 10px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

#reset-btn:hover {
    background-color: #2980b9;
}

/* 开关样式 */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
    margin-left: 10px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:focus + .slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.switch span {
    margin-right: 5px;
}

/* 球队颜色 */
.player.blue {
    background-color: #3498db;
}

.player.green {
    background-color: #2ecc71;
}

/* 线条样式 */
.lines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 50;
}

.line {
    position: absolute;
    height: 2px;
    background-color: rgba(255, 255, 255, 0.7);
    transform-origin: left center;
}

/* 场地容器 */
.field-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

/* 足球场地样式 */
.field {
    position: relative;
    width: 800px;
    height: 500px;
    background-color: #4CAF50;
    background-image: 
        linear-gradient(to right, rgba(76, 175, 80, 0.8) 50%, rgba(67, 160, 71, 0.8) 50%),
        linear-gradient(to right, rgba(76, 175, 80, 0.6) 50%, rgba(67, 160, 71, 0.6) 50%);
    background-size: 40px 100%, 40px 100%;
    background-position: 0 0, 20px 0;
    border: 2px solid #333;
    border-radius: 10px;
    overflow: hidden;
}

/* 场地线条 */
.field::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        /* 中线 */
        linear-gradient(to bottom, transparent 0%, white 0%, white 100%, transparent 100%),
        /* 中圈 */
        radial-gradient(circle at center, transparent 30px, white 30px, white 34px, transparent 34px),
        /* 左禁区 */
        linear-gradient(to right, transparent 10%, white 10%, white 25%, transparent 25%),
        linear-gradient(to bottom, transparent 35%, white 35%, white 65%, transparent 65%),
        linear-gradient(to right, transparent 10%, white 10%, white 18%, transparent 18%),
        linear-gradient(to bottom, transparent 45%, white 45%, white 55%, transparent 55%),
        /* 右禁区 */
        linear-gradient(to right, transparent 75%, white 75%, white 90%, transparent 90%),
        linear-gradient(to bottom, transparent 35%, white 35%, white 65%, transparent 65%),
        linear-gradient(to right, transparent 82%, white 82%, white 90%, transparent 90%),
        linear-gradient(to bottom, transparent 45%, white 45%, white 55%, transparent 55%);
    background-size: 2px 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
    background-position: center 0, center center, 0 0, 10% 0, 0 0, 10% 0, 0 0, 75% 0, 0 0, 82% 0;
    background-repeat: no-repeat;
}

/* 角球区 */
.field::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 10% 20%, transparent 15px, white 15px, white 17px, transparent 17px),
        radial-gradient(circle at 10% 80%, transparent 15px, white 15px, white 17px, transparent 17px),
        radial-gradient(circle at 90% 20%, transparent 15px, white 15px, white 17px, transparent 17px),
        radial-gradient(circle at 90% 80%, transparent 15px, white 15px, white 17px, transparent 17px);
    background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%;
    background-position: center center, center center, center center, center center;
    background-repeat: no-repeat;
}

/* 球员样式 */
.player {
    position: absolute;
    width: 50px;
    height: 50px;
    background-color: #3498db;
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    cursor: move;
    user-select: none;
    transition: all 0.2s ease;
    z-index: 1;
}

.player:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255,255,255,0.8);
}

.player:active {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255,255,255,1);
}

.player.dragging {
    z-index: 100;
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255,255,255,1);
}

.player .number {
    font-size: 16px;
    line-height: 1;
}

.player .position {
    font-size: 10px;
    line-height: 1;
    margin-top: 2px;
}

.player .name {
    font-size: 8px;
    line-height: 1;
    margin-top: 2px;
    text-align: center;
    word-break: break-all;
    max-width: 40px;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 300px;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: black;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.save-btn {
    width: 100%;
    padding: 10px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
}

.save-btn:hover {
    background-color: #45a049;
}

/* 底部样式 */
footer {
    text-align: center;
    padding: 10px;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 响应式设计 */
@media (max-width: 900px) {
    .field {
        width: 100%;
        height: 62.5vw;
        max-height: 500px;
    }
}

@media (max-width: 600px) {
    header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .controls {
        width: 100%;
        justify-content: space-between;
    }
}