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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    background: #f5f5f5;
}

h1 {
    color: #333;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    margin-bottom: 5px;
}

.how-to-link {
    margin-bottom: 30px;
}

.how-to-link a {
    color: #2196F3;
    text-decoration: none;
    font-size: 0.9em;
}

.how-to-link a:hover {
    text-decoration: underline;
}

.formation-selector {
    margin-bottom: 30px;
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.formation-selector label {
    font-weight: 600;
    color: #444;
}

.formation-selector select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.formation-selector select:hover {
    border-color: #4CAF50;
}

.section {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h2 {
    color: #444;
    margin-bottom: 15px;
    font-size: 1.3em;
}

textarea {
    width: 100%;
    min-height: 150px;
    padding: 10px;
    font-family: monospace;
    font-size: 14px;
    border: 2px solid #ddd;
    border-radius: 4px;
    resize: vertical;
}

.help-text {
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
}

button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
    margin-right: 10px;
}

button:hover {
    background: #45a049;
}

button.secondary {
    background: #2196F3;
}

button.secondary:hover {
    background: #0b7dda;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th, td {
    padding: 10px;
    text-align: left;
    border: 1px solid #ddd;
}

th {
    background: #f8f8f8;
    font-weight: 600;
}

td input[type="text"],
td input[type="number"] {
    width: 100%;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

td input[type="number"].invalid-skill {
    background-color: #ffebee;
    border-color: #d32f2f;
    color: #d32f2f;
}

td input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.editable-cell {
    cursor: text;
    min-width: 80px;
}

.editable-cell:hover {
    background: #f9f9f9;
}

.editable-cell:focus {
    outline: 2px solid #4CAF50;
    background: #fff;
}

.editable-cell.duplicate-player {
    background-color: #ffebee;
    border: 2px solid #d32f2f;
}

.editable-cell.duplicate-player:hover {
    background-color: #ffcdd2;
}

.quarters-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 20px;
}

.field-visual {
    background: #2d5f2e url('field_background.png') center center / cover no-repeat;
    border-radius: 8px;
    padding: 20px;
    position: relative;
    min-height: 400px;
}

.field-markings {
    border: 3px solid rgba(255,255,255,0.5);
    border-radius: 4px;
    height: 100%;
    position: relative;
    padding: 20px;
}

.position {
    position: absolute;
    background: white;
    padding: 6px 8px;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-width: 80px;
    cursor: move;
    transition: transform 0.2s, box-shadow 0.2s;
}

.position:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.position.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.position.drag-over {
    background: #e3f2fd;
    border: 2px dashed #2196F3;
}

.position.duplicate-player {
    background: #ffebee;
    border: 2px solid #d32f2f;
}

.position.duplicate-player:hover {
    background: #ffcdd2;
}

.position-label {
    font-size: 0.65em;
    color: #666;
    display: block;
    pointer-events: none;
}

.player-name {
    font-size: 0.85em;
    color: #333;
    margin-top: 2px;
    pointer-events: none;
}

.quarter-title {
    color: white;
    margin-bottom: 10px;
    font-size: 1.1em;
    font-weight: bold;
}

.quarter-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 10px;
}

.bench-area {
    padding: 8px 10px;
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    flex: 0 1 auto;
}

.bench-title {
    color: white;
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 0.75em;
}

.bench-players {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.bench-player {
    background: rgba(255,255,255,0.9);
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 0.75em;
    cursor: move;
    transition: transform 0.2s;
}

.bench-player:hover {
    transform: scale(1.1);
    background: rgba(255,255,255,1);
}

.bench-player.dragging {
    opacity: 0.5;
}

.bench-player.unfair {
    background: #ffcdd2;
    border: 2px solid #d32f2f;
    font-weight: bold;
}

.bench-player.unfair:hover {
    background: #ef9a9a;
}

.bench-area.drag-over {
    background: rgba(33, 150, 243, 0.3);
    border: 2px dashed #2196F3;
}


#lineupTable th {
    background: #4CAF50;
    color: white;
}

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

    .section {
        padding: 15px;
    }

    table {
        font-size: 0.9em;
    }

    th, td {
        padding: 6px;
    }

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

    .position {
        min-width: 70px;
        font-size: 0.75em;
        padding: 4px 6px;
    }

    .field-visual {
        padding: 15px;
        min-height: 350px;
    }
}

@media print {
    @page {
        size: landscape;
        margin: 0.4cm;
    }

    body {
        background: white;
        padding: 0;
        margin: 0;
    }

    .section {
        box-shadow: none;
        padding: 5px;
        margin-bottom: 5px;
    }

    #inputSection,
    #playerTableSection,
    button,
    .no-print,
    .subtitle,
    .how-to-link,
    .formation-selector {
        display: none !important;
    }

    #lineupSection {
        page-break-inside: avoid;
        padding: 0 !important;
    }

    h2 {
        font-size: 1em;
        margin-bottom: 5px;
        color: black;
    }

    h1 {
        display: none;
    }

    table {
        font-size: 0.65em;
        margin-bottom: 8px;
    }

    th, td {
        padding: 3px 2px;
        border: 1px solid #333;
    }

    th {
        background: #ddd !important;
        color: black !important;
    }

    .quarters-grid {
        gap: 15px;
        margin-top: 5px;
    }

    .field-visual {
        page-break-inside: avoid;
        min-height: 190px;
        max-height: 190px;
        padding: 8px;
        background: white !important;
        border: 2px solid #333;
    }

    .field-markings {
        border: 1px solid #666;
        padding: 8px;
        position: relative;
        height: 160px;
    }

    .quarter-title {
        color: black !important;
        font-size: 0.85em;
        margin-bottom: 4px;
    }

    .quarter-header {
        margin-bottom: 5px;
    }

    .position {
        min-width: 55px;
        font-size: 0.6em;
        padding: 2px 4px;
        background: white !important;
        border: 1px solid #333;
        box-shadow: none;
    }

    .position-label {
        font-size: 0.55em;
        color: #333;
    }

    .player-name {
        font-size: 0.75em;
        color: black;
    }

    .bench-area {
        background: white !important;
        border: 1px solid #333;
        padding: 4px 6px;
    }

    .bench-title {
        color: black !important;
        font-size: 0.65em;
        margin-bottom: 3px;
    }

    .bench-players {
        gap: 3px;
    }

    .bench-player {
        font-size: 0.6em;
        padding: 2px 4px;
        background: #f0f0f0 !important;
        border: 1px solid #666;
    }

    .bench-player.unfair {
        background: #ddd !important;
        border: 2px solid #333 !important;
        font-weight: bold;
    }
}

.hidden {
    display: none;
}
