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

body {
    font-family: "Segoe UI", Tahoma, sans-serif;
    background: linear-gradient(135deg, #0b3d2e, #0a2a5e);
    min-height: 100vh;
    padding: 12px;
    color: #fff;
}

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

.header {
    text-align: center;
    margin-bottom: 15px;
}

.team-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.team-logo {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: white;
}

.card {
    background: #fff;
    color: #111;
    padding: 14px;
    border-radius: 12px;
    margin-bottom: 12px;
    overflow-x: auto;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.stat {
    background: white;
    color: black;
    padding: 10px;
    border-radius: 10px;
    text-align: center;
    font-weight: bold;
}

.stat span {
    display: block;
    font-size: 20px;
    color: #00c853;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.tab-btn {
    flex: 1;
    min-width: 90px;
    padding: 8px 5px;
    border: none;
    background: #ddd;
    color: #111;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 12px;
}

.tab-btn.active {
    background: #00c853;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

input,
select,
textarea {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

textarea {
    font-family: inherit;
    min-height: 70px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.checkbox-row input {
    width: auto;
    margin: 0;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.media-item {
    background: #f6f6f6;
    border-radius: 8px;
    padding: 8px;
}

.media-item img,
.media-item video {
    width: 100%;
    max-height: 220px;
    border-radius: 6px;
    object-fit: cover;
    background: #111;
}

table {
    width: 100%;
    border-collapse: collapse;
}

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

th {
    background: #f2f2f2;
    color: black;
}

.att-box {
    display: flex;
    gap: 4px;
}

.block {
    width: 24px;
    height: 24px;
    background: #ccc;
    color: #111;
    border-radius: 4px;
    text-align: center;
    line-height: 24px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.block.present {
    background: #00c853;
    color: white;
}

.block.absent {
    background: #e53935;
    color: white;
}

button {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: #00c853;
    color: white;
    cursor: pointer;
    font-weight: bold;
    margin-top: 8px;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.danger {
    background: #e53935;
}

.muted {
    color: #666;
    font-size: 13px;
    margin-top: 8px;
}

.error {
    color: #e53935;
    font-size: 13px;
    margin-top: 8px;
}

#loginOverlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0b3d2e, #0a2a5e);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    z-index: 10;
}

.login-box {
    background: white;
    padding: 20px;
    border-radius: 12px;
    color: black;
    width: 320px;
}

/* Pitch styles - Mobile friendly */
.pitch-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pitch {
    position: relative;
    width: 100%;
    min-width: 320px;
    max-width: 650px;
    height: 380px;
    margin: 0 auto;
    background: linear-gradient(145deg, #2d7a3e, #1a5c2a);
    border-radius: 15px;
    border: 2px solid white;
    overflow: visible;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Grass pattern */
.pitch::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(90deg,
            rgba(255, 255, 255, 0.05) 0px,
            rgba(255, 255, 255, 0.05) 2px,
            transparent 2px,
            transparent 15px);
    pointer-events: none;
    border-radius: 15px;
}

.pitch-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Touchline (sideline) */
.pitch-lines::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border: 1.5px solid rgba(255, 255, 255, 0.7);
    border-radius: 6px;
}

/* Center circle */
.center-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* Center line */
.center-line {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 1.5px;
    height: calc(100% - 16px);
    background: rgba(255, 255, 255, 0.6);
}

/* Penalty boxes */
.penalty-box-left {
    position: absolute;
    left: 8px;
    top: 50%;
    width: 60px;
    height: 100px;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    border-left: none;
    transform: translateY(-50%);
}

.penalty-box-right {
    position: absolute;
    right: 8px;
    top: 50%;
    width: 60px;
    height: 100px;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    border-right: none;
    transform: translateY(-50%);
}

/* Goal areas */
.goal-area-left {
    position: absolute;
    left: 8px;
    top: 50%;
    width: 25px;
    height: 50px;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-left: none;
    transform: translateY(-50%);
}

.goal-area-right {
    position: absolute;
    right: 8px;
    top: 50%;
    width: 25px;
    height: 50px;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-right: none;
    transform: translateY(-50%);
}

/* Penalty spots */
.penalty-spot-left {
    position: absolute;
    left: 35px;
    top: 50%;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    transform: translateY(-50%);
}

.penalty-spot-right {
    position: absolute;
    right: 35px;
    top: 50%;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    transform: translateY(-50%);
}

/* Player cards with images */
.player-card {
    position: absolute;
    background: linear-gradient(135deg, #1a5f7a, #0d3b4f);
    color: white;
    padding: 3px 6px;
    border-radius: 30px;
    cursor: grab;
    text-align: center;
    font-size: 8px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
    z-index: 10;
    min-width: 55px;
    border: 1.5px solid rgba(255, 215, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 4px;
    backdrop-filter: blur(2px);
}

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

.player-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.player-card:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg, #227a9e, #12526b);
    border-color: #ffd700;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.player-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: #1a5f7a;
    flex-shrink: 0;
}

.player-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.player-info {
    text-align: left;
    overflow: hidden;
}

.player-name {
    font-size: 7px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 45px;
}

.player-role {
    font-size: 6px;
    opacity: 0.8;
    color: #ffd700;
}

/* Players pool (bench) */
.players-pool {
    background: linear-gradient(135deg, #2c2c2c, #1a1a1a);
    border-radius: 12px;
    padding: 10px;
    margin-top: 15px;
    border: 1px solid #444;
}

.players-pool h4 {
    margin-bottom: 8px;
    color: #ffd700;
    font-size: 12px;
}

.pool-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 60px;
    max-height: 120px;
    overflow-y: auto;
    padding: 5px;
}

.pool-player {
    background: linear-gradient(135deg, #444, #333);
    padding: 4px 10px;
    border-radius: 25px;
    cursor: grab;
    font-size: 10px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #555;
}

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

.pool-player:hover {
    background: linear-gradient(135deg, #00c853, #009624);
    transform: scale(1.02);
    border-color: #ffd700;
}

.pool-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
}

.pool-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.empty-pool-msg {
    color: #888;
    padding: 10px;
    font-style: italic;
    text-align: center;
    font-size: 11px;
}

.formation-controls {
    margin-bottom: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.formation-controls label {
    font-size: 12px;
    color: #333;
}

.formation-controls select {
    width: auto;
    margin-top: 0;
    padding: 6px 10px;
    font-size: 12px;
}

.formation-controls button {
    margin-top: 0;
    padding: 6px 12px;
    font-size: 11px;
}

@media (max-width: 700px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    th,
    td {
        padding: 6px;
        font-size: 11px;
    }
    .tab-btn {
        min-width: 70px;
        font-size: 10px;
        padding: 6px 3px;
    }
    .player-card {
        min-width: 48px;
        padding: 2px 4px;
    }
    .player-name {
        font-size: 6px;
        max-width: 35px;
    }
    .player-avatar {
        width: 18px;
        height: 18px;
        font-size: 8px;
    }
    .pitch {
        height: 350px;
        min-width: 300px;
    }
}

:root {
    --psg-blue: #071a3d;
    --psg-blue-2: #0b2b63;
    --team-green: #00c853;
    --gold: #f7d154;
}

body {
    background:
        radial-gradient(circle at top left, rgba(0, 200, 83, 0.24), transparent 32%),
        linear-gradient(135deg, var(--psg-blue), var(--psg-blue-2) 58%, #063f2d);
}

.container {
    animation: appRise 0.45s ease both;
}

@keyframes appRise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    background: rgba(7, 26, 61, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 14px;
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22);
}

.team-banner h1 {
    letter-spacing: 0.2px;
}

.team-logo {
    display: grid;
    place-items: center;
    color: var(--psg-blue);
    font-weight: 900;
    overflow: hidden;
    border: 2px solid var(--gold);
}

.team-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#roleText {
    display: none;
}

.stat {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(239, 246, 255, 0.94));
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}

.card {
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
    animation: cardIn 0.28s ease both;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ghost-btn {
    background: #e8eef7;
    color: var(--psg-blue);
}

.player-tools {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.player-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.profile-card {
    position: relative;
    min-height: 265px;
    padding: 14px;
    border-radius: 18px;
    color: white;
    overflow: hidden;
    background:
        linear-gradient(150deg, rgba(7, 26, 61, 0.95), rgba(0, 83, 58, 0.92)),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 8px, transparent 8px 16px);
    border: 1px solid rgba(247, 209, 84, 0.42);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.2);
}

.profile-card::after {
    content: "";
    position: absolute;
    inset: auto -30px -42px auto;
    width: 120px;
    height: 120px;
    background: rgba(247, 209, 84, 0.15);
    border-radius: 50%;
}

.card-photo {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    object-fit: cover;
    display: grid;
    place-items: center;
    background: white;
    color: var(--psg-blue);
    border: 3px solid var(--gold);
    font-size: 28px;
    font-weight: 900;
}

.card-photo-img {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gold);
}

.card-name {
    margin-top: 10px;
    font-size: 18px;
    font-weight: 900;
}

.card-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-top: 12px;
    font-size: 12px;
}

.card-meta span {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 9px;
    padding: 7px;
}

.lineup-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 14px;
    align-items: start;
}

.pitch {
    max-width: none;
    height: 560px;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 8%, transparent 8% 16%),
        linear-gradient(145deg, #238647, #125c33);
}

.player-card {
    width: 86px;
    min-width: 86px;
    padding: 5px;
    border-radius: 14px;
    flex-direction: column;
    gap: 3px;
    background: rgba(7, 26, 61, 0.92);
    border: 2px solid var(--gold);
}

.player-avatar {
    width: 46px;
    height: 46px;
    overflow: hidden;
    border: 2px solid #fff;
}

.player-avatar img,
.pool-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.player-info {
    text-align: center;
    width: 100%;
}

.player-name {
    font-size: 10px;
    max-width: 76px;
}

.player-role {
    font-size: 9px;
    font-weight: 900;
}

.bench-panel {
    background: rgba(7, 26, 61, 0.9);
    color: white;
    border-radius: 14px;
    padding: 12px;
    min-height: 560px;
    border: 1px solid rgba(247, 209, 84, 0.35);
}

.bench-panel h4 {
    color: var(--gold);
    margin-bottom: 10px;
}

.pool-container {
    display: grid;
    grid-template-columns: 1fr;
    max-height: 495px;
}

.pool-player {
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.1);
}

.pool-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.pool-meta small {
    color: var(--gold);
}

.media-item {
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.media-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.14);
}

.media-item img,
.media-item video {
    height: 190px;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(3, 10, 25, 0.78);
    padding: 14px;
}

.modal.open {
    display: flex;
}

.modal-card {
    width: min(760px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: white;
    color: #111;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.modal-viewer img,
.modal-viewer video {
    width: 100%;
    max-height: 76vh;
    object-fit: contain;
    background: #050b17;
    border-radius: 12px;
}

/* NEW STYLES: Camera and photo upload */
.photo-upload-group {
    grid-column: span 2;
}

.photo-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--gold);
}

.photo-preview-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.camera-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.camera-modal.open {
    display: flex;
}

.camera-container {
    width: 100%;
    max-width: 500px;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
}

#cameraVideo {
    width: 100%;
    height: auto;
    max-height: 60vh;
    background: #000;
}

.camera-controls {
    display: flex;
    gap: 12px;
    padding: 16px;
    justify-content: center;
    background: #1a1a1a;
}

.camera-controls button {
    margin: 0;
    padding: 12px 20px;
}

/* Attendance icon styles */
.attendance-icon-present {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    margin: 0 2px;
    border-radius: 6px;
    background: #4CAF50;
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

.attendance-icon-absent {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    margin: 0 2px;
    border-radius: 6px;
    background: #f44336;
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}

.attendance-icon-empty {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    margin: 0 2px;
    border-radius: 6px;
    background: #e0e0e0;
    color: #666;
    cursor: pointer;
    font-size: 16px;
}

@media (max-width: 850px) {
    .lineup-layout {
        grid-template-columns: 1fr;
    }

    .bench-panel {
        min-height: auto;
    }
}

/* Login overlay styles */
#loginOverlay button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.login-box input,
.login-box select {
    margin-bottom: 12px;
}

#loginError {
    margin-top: 12px;
    padding: 8px;
    background: rgba(229, 57, 53, 0.1);
    border-radius: 6px;
    font-size: 12px;
    white-space: pre-line;
}

/* Additional fix for attendance icons in table */
td .attendance-icon-present,
td .attendance-icon-absent,
td .attendance-icon-empty {
    display: inline-block;
    margin: 2px;
}

/* Fix for player card photo in table */
td .card-photo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gold);
}

/* Make sure modals work properly on mobile */
@media (max-width: 600px) {
    .modal-card {
        padding: 12px;
        margin: 10px;
    }
    
    .modal-head h3 {
        font-size: 16px;
    }
    
    .photo-preview {
        width: 70px;
        height: 70px;
    }
}