:root {
    --pitch-green: #4CAF50;
    --pitch-line: rgba(255, 255, 255, 0.8);
    --player-color: #ffffff;
    --keeper-color: #FFEB3B;
    --field-color: #0047AB;
    --player-text: #333;
    --accent-color: #2196F3;
    --bg-color: #f0f2f5;
    --text-color: #333;
    --panel-bg: #fff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
}

header {
    margin-bottom: 20px;
}

h1 {
    margin: 0;
    color: #2e7d32;
}

.quarter-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.lineup-actions {
    display: flex;
    gap: 10px;
    margin-left: 20px;
    padding-left: 20px;
    border-left: 1px solid #ccc;
}

.q-btn {
    padding: 10px 20px;
    border: none;
    background-color: #ddd;
    cursor: pointer;
    border-radius: 5px;
    font-weight: bold;
    transition: background 0.3s;
}

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

/* Lock Toggle */
.lock-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
    padding-left: 20px;
    border-left: 1px solid #ccc;
    font-weight: bold;
    font-size: 14px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    inset: 0;
    background-color: #ccc;
    transition: background-color 0.3s;
    border-radius: 24px;
    cursor: pointer;
}

.switch .slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: transform 0.3s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background-color: #e53935;
}

.switch input:checked + .slider::before {
    transform: translateX(20px);
}

.game-area {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
}

.field-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Pitch Styling */
.pitch {
    position: relative;
    background-color: var(--pitch-green);
    height: 80vh;
    width: auto;
    max-width: 100%;
    aspect-ratio: 4/3;
    border: 5px solid white;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    overflow: hidden;
}

.grid-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(11, 1fr);
    pointer-events: none;
    z-index: 1;
}

.grid-cell {
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-sizing: border-box;
}

.pitch-line {
    position: absolute;
    background-color: var(--pitch-line);
}

.center-line {
    width: 100%;
    height: 2px;
    top: 0%;
    left: 0;
}

.center-circle {
    width: 100px;
    height: 100px;
    border: 2px solid var(--pitch-line);
    border-radius: 50%;
    top: 0%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: transparent;
}

.penalty-area {
    width: 40%;
    height: 15%;
    left: 30%;
    border: 2px solid var(--pitch-line);
    background: transparent;
}

.penalty-area.top {
    top: 0;
}

.penalty-area.bottom {
    bottom: 0;
}

/* Player Token */
.player-token {
    position: absolute;
    width: 80px;
    height: 80px;
    background-color: var(--player-color);
    color: var(--player-text);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    cursor: grab;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    user-select: none;
    border: 2px solid #333;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.player-token.keeper {
    background-color: var(--keeper-color);
}

.player-token.field {
    background-color: var(--field-color);
    color: white;
}

.player-token:active {
    cursor: grabbing;
}

/* Empty Slot Marker */
.empty-slot {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 2px dashed rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
    pointer-events: none;
    z-index: 5;
}

/* Sidebar Styling */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-panel, .roster-panel {
    background-color: var(--panel-bg);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.stats-list, .bench-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.bench-item {
    padding: 10px;
    margin: 8px 0;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: grab;
    text-align: center;
    font-weight: bold;
    transition: background 0.3s;
}

.bench-item:hover {
    background-color: #eee;
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    width: 400px;
    max-width: 90%;
}

.name-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.name-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.name-input-row span {
    width: 30px;
}

.name-input-row input {
    flex: 1;
    padding: 5px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

button {
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 5px;
    border: 1px solid #ccc;
}

/* Formation Selector Styling */
.formation-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 15px;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
}

.formation-selector label {
    white-space: nowrap;
    font-weight: bold;
    font-size: 14px;
}

.formation-selector select {
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 14px;
}

.formation-selector button {
    padding: 8px 12px;
    background-color: #4CAF50;
    color: white;
    border: none;
    font-size: 13px;
}

.formation-selector button:hover {
    background-color: #45a049;
}

.current-formation {
    font-weight: bold;
    color: var(--accent-color);
    font-size: 12px;
    white-space: nowrap;
    padding: 0 10px;
}

/* Formation Modal */
.formation-options {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.formation-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.formation-preview {
    width: 100%;
    height: 200px;
    background: linear-gradient(to bottom, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #4CAF50;
    border-radius: 5px;
    margin: 15px 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.formation-preview .position-dot {
    position: absolute;
    width: 25px;
    height: 25px;
    background: var(--field-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.formation-preview .position-dot.keeper {
    background: var(--keeper-color);
    width: 30px;
    height: 30px;
}

#formation-name-input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    box-sizing: border-box;
}
