:root { --primary: #ff6600; --bg: #111; --card: #181818; --text: #eee; }
body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); margin: 0; display: flex; }

nav { width: 260px; background: #000; height: 100vh; padding: 20px; border-right: 2px solid var(--primary); position: fixed; }
nav h1 { color: var(--primary); font-size: 1.2rem; letter-spacing: 1px; margin-bottom: 2rem; }

main { 
    margin-left: 300px; 
    padding: 40px; 
    width: auto; 
    min-width: 1800px; 
    display: block;
}

.view { 
    display: none !important; 
}
.view.active { 
    display: block !important; 
}

.card { background: var(--card); padding: 20px; border-radius: 12px; border: 1px solid #333; margin-bottom: 20px; position: relative; }

input, select { 
    background: #000; border: 1px solid var(--primary); color: white; 
    padding: 12px; border-radius: 6px; width: 100%; margin: 10px 0; box-sizing: border-box;
}

/* Navigaation nappien tyylit */
.nav-btn {
    display: block;          /* Pakottaa napin omalle rivilleen */
    width: 100%;             /* Täyttää koko sivupalkin leveyden */
    background: none;
    border: none;
    color: #aaa;
    padding: 12px 15px;      /* Lisää tilaa tekstin ympärille */
    text-align: left;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 5px;      /* Väli nappien välille */
    transition: 0.2s;        /* Pehmeä efekti vaihdossa */
}

.nav-btn:hover {
    background: #222;
    color: var(--primary);
}

.nav-btn.active {
    background: var(--primary) !important;
    color: white !important;
}

/* Nav-sectionin korjaus */
.nav-section {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #222;
}

/* KENTÄN TYYLIT */
#pitch-container {
    position: relative;
    width: 100%;
    max-width: 750px;
    height: 960px;
    margin: 20px auto;
    background: #2e7d32;
    border: 3px solid #fff;
    border-radius: 8px;
    overflow: hidden;
}

.pitch-player {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100px;
    z-index: 10;
}

.slot-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2.5px solid white;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.slot-circle img { width: 100%; height: 100%; object-fit: cover; }

.pitch-player span {
    font-size: 0.8rem;
    background: white;
    color: black !important;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 5px;
    white-space: nowrap;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    text-align: center;
}

.slot-picker {
    width: 80px;
    font-size: 0.7rem !important;
    height: 22px !important;
    background: #222 !important;
    color: white !important;
    margin-top: 4px;
}

/* --- JOUKKUENÄKYMÄN KOLMIJAKOINEN ASETTELU (Kuvan mukainen) --- */
.team-layout {
    display: flex;
    gap: 20px;
    height: calc(100vh - 160px);
    padding: 10px;
}

/* --- Pelaajan muokkausmodal --- */

#editPlayerModal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); display: none; align-items: center; justify-content: center; z-index: 1000;
}
#editPlayerContent {
    background: #181818; padding: 30px; border-radius: 15px; border: 1px solid #333;
    width: 700px; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

/* Pelaajakuvan tyylit kentällä ja listassa */
.player-avatar-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover; /* Pakottaa kuvan täyttämään ympyrän vääristymättä */
    display: block;
}

/* Harmaa oletushahmo jos kuvaa ei ole */
.default-avatar {
    width: 100%;
    height: 100%;
    background-color: #222;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://w3.org' viewBox='0 0 24 24' fill='%23555'%3E%3Cpath d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3E%3C/svg%3E");
    background-size: 65%;
    background-repeat: no-repeat;
    background-position: center bottom;
    border-radius: 50%;
}

/* Vasen paneeli: Musta pelaajaluettelo */
.side-panel {
    width: 220px;
    background: #000;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    border: 1px solid #222;
}

.scroll-area {
    overflow-y: auto;
    flex: 1;
}

.player-row {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid #111;
    cursor: pointer;
    transition: 0.2s;
}

.player-row:hover { color: var(--primary); }
.player-row.assigned { color: var(--primary); font-weight: bold; }
.p-num { color: var(--primary); width: 25px; font-weight: bold; }

/* Keskipaneeli: Valkoiset listat */
.center-panel {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.list-card {
    background: #ffffff; 
    border-radius: 10px;
    padding: 15px;
    color: #000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.list-title {
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.assigned-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.p-num-box {
    background: #000;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

/* Oikea paneeli: Vihreä pystykenttä */
.pitch-panel {
    flex: 1;
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border: 1px solid #333;
}

.soccer-pitch {
    width: 60%;
    height: 750px; /* Pakotetaan kentälle korkeus */
    background-color: #2d5a27;
    position: relative;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    overflow: hidden;
    /* Lisätään kentän keski- ja päätyviivat valkoisella */
    background-image: 
        linear-gradient(rgba(255,255,255,0.2) 2px, transparent 2px), /* Keski- tai päätyviiva */
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 100% 50%, 10% 100%;
}

/* Kentän pelaajapallot (Pienennys jotta mahtuvat pystykentälle) */
.soccer-pitch .pitch-player {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
}

.soccer-pitch .slot-circle {
    width: 45px; /* Pienennetty alkuperäisestä 60px:stä */
    height: 45px;
    border-radius: 50%;
    border: 2px solid white;
}

/* Nappien tyylit kuvan mukaan */
.btn-add-inline {
    width: 100%;
    background: none;
    border: 1px dashed #ccc;
    padding: 10px;
    margin-top: 10px;
    cursor: pointer;
    color: #888;
    border-radius: 6px;
    text-align: left;
    font-weight: bold;
}

.btn-add-inline:hover { background: #f0f0f0; color: #000; }

.btn-remove {
    background: none;
    border: none;
    color: #bbb;
    font-size: 1.2rem;
    cursor: pointer;
}
.btn-remove:hover { color: red; }

/* Pelaajakorttien ruudukko */
.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Säädä kokoa tarvittaessa */
    gap: 20px;
    padding: 20px;
}

/* Neliön muotoinen kortti */
.player-card-square {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    aspect-ratio: 1 / 1; /* Tekee kortista neliön */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 15px;
    transition: transform 0.2s;
}

.player-card-square:hover {
    transform: scale(1.03);
    border-color: #ff6600;
}

/* Pyöreä kuva kortin yläosassa */
.player-img-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: #222;
    margin-bottom: 15px;
    border: 2px solid #333;
}

.player-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Pelaajan Poistaminen Joukkueesta */

.edit-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #444;
    color: white;
    border: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.edit-badge:hover {
    background: #ff6600;
}

.player-name {
    font-weight: bold; 
    color: white; 
    margin-bottom: 2px;
}

.player-team-label {
    color: #ff6600; 
    font-size: 0.75rem; 
    font-weight: bold;
    letter-spacing: 0.5px;
}