body {
    margin: 0;
    padding: 0;
    background-color: #111827;
    font-family: 'Inter', sans-serif;
    color: #fff;
    overflow-x: hidden;
}

/* UI Elements */
.player-card {
    cursor: grab;
    transition: all 0.2s ease-in-out;
}
.player-card:active {
    cursor: grabbing;
    transform: scale(1.05);
}
.drop-zone {
    transition: background-color 0.2s ease;
}
.drop-zone.drag-over, #squad-list.drag-over, #bench-list.drag-over {
    background-color: rgba(34, 197, 94, 0.2);
    border-style: dashed;
}
.pitch-bg {
    background-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.5) 100%), url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><g fill="%23008000" fill-opacity="0.6"><rect x="0" y="0" width="50" height="100" /><rect x="50" y="0" width="50" height="100" fill="%23007000" /></g></svg>');
    background-size: 200px 100px, auto;
}

/* Match Engine Styles */
.match-active-bg {
    background-color: #0f172a;
    height: 100vh;
    height: 100svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: fixed;
    top:0;
    left:0;
    width: 100%;
    z-index: 100;
}
.pitch-container {
    position: relative;
    display: inline-block;
}

/* Custom Tactics Tokens */
.tactics-token {
    transition: box-shadow 0.2s, transform 0.1s;
    z-index: 10;
}
.tactics-token:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 20;
}

#footballPitch {
    background-color: #333;
    border: 4px solid #fff;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    max-width: 95vw;
    max-height: 75vh;
    aspect-ratio: 105 / 68;
    display: block;
}
#info-bar {
    position: relative;
    width: 100%;
    padding: 12px 16px;
    background-color: #1e293b;
    border-radius: 8px;
    margin-bottom: 12px;
    text-align: center;
    box-sizing: border-box;
    max-width: 95vw;
    border: 1px solid #334155;
    display: flex;
    justify-content: center;
    align-items: center;
}
#scoreboard {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 1.4em;
    font-weight: 800;
    color: white;
    text-shadow: 1px 1px 2px #000;
    width: 100%;
}
.sb-team {
    padding-bottom: 2px;
    letter-spacing: 0.05em;
    font-size: 0.85em;
    transition: border-bottom-color 0.3s;
}
.sb-score {
    background-color: #0f172a;
    padding: 2px 12px;
    border-radius: 6px;
    border: 1px solid #334155;
    font-family: monospace;
    font-size: 1.15em;
    min-width: 80px;
    text-align: center;
}
#gameClock {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    font-weight: bold;
    color: #cbd5e1;
}
#matchMessage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5em;
    font-weight: bold;
    color: #facc15;
    text-shadow: 4px 4px 10px rgba(0,0,0,0.8);
    display: none;
    z-index: 10;
    pointer-events: none;
}
#results-summary {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.95);
    padding: 30px;
    border-radius: 12px;
    border: 2px solid #eab308;
    display: none;
    z-index: 20;
    min-width: 400px;
    box-shadow: 0 0 40px rgba(0,0,0,0.9);
    text-align: center;
}

/* Table & Bracket Styles */
.group-table th {
    background-color: #1f2937;
    position: sticky;
    top: 0;
}
.bracket-round {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    min-width: 200px;
    padding: 0 20px;
    border-right: 2px dashed #374151;
}
.bracket-match {
    background: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    margin: 10px 0;
    padding: 10px;
    font-size: 0.9em;
}
.bracket-winner {
    font-weight: bold;
    color: #34d399;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #111827;
}
::-webkit-scrollbar-thumb {
    background: #374151;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #4b5563;
}

/* Device Rotation Warning */
#landscape-prompt {
    display: none;
}

@media (max-width: 768px) and (orientation: portrait) {
    #landscape-prompt {
        display: flex;
        position: fixed;
        inset: 0;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        z-index: 200;
        backdrop-blur: 10px;
    }
}

@keyframes rotatePhone {
    0%, 10% { transform: rotate(0deg); }
    40%, 60% { transform: rotate(-90deg); }
    90%, 100% { transform: rotate(0deg); }
}

/* Mobile Landscape Optimization */
@media (orientation: landscape) and (max-height: 550px) {
    .match-active-bg {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        padding: 8px;
        gap: 12px;
        height: 100vh;
        height: 100svh;
    }
    
    #info-bar {
        position: relative;
        flex-direction: column;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 150px;
        height: calc(100vh - 16px);
        height: calc(100svh - 16px);
        max-height: 680px;
        margin-bottom: 0;
        padding: 16px 8px;
        box-sizing: border-box;
    }

    #gameClock {
        position: static;
        transform: none;
        order: 1;
        font-size: 1.3em;
        background-color: #0f172a;
        padding: 4px 10px;
        border-radius: 6px;
        border: 1px solid #334155;
        width: 90%;
        text-align: center;
    }

    #scoreboard {
        order: 2;
        flex-direction: column;
        gap: 12px;
        width: 100%;
        font-size: 1.1em;
    }
    
    .sb-team {
        text-align: center;
        font-size: 0.7em;
        line-height: 1.2;
        width: 100%;
        word-wrap: break-word;
        white-space: normal;
        padding-bottom: 4px;
    }

    .sb-score {
        padding: 4px 10px;
        font-size: 1.2em;
        min-width: 70px;
    }
    
    #info-bar button {
        position: static;
        transform: none;
        order: 3;
    }

    #footballPitch {
        max-height: calc(100vh - 16px);
        max-height: calc(100svh - 16px);
        max-width: calc(100vw - 180px);
    }

    #matchMessage {
        font-size: 3em;
    }
    
    #results-summary {
        padding: 16px 20px;
        min-width: 280px;
        max-width: 90%;
        max-height: calc(100vh - 20px);
        max-height: calc(100svh - 20px);
        overflow-y: auto;
    }
    
    #results-summary h2 {
        font-size: 1.5rem;
        margin-bottom: 4px;
    }
    
    #final-score-display {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }
    
    #results-summary button {
        padding: 8px 12px;
        font-size: 1rem;
    }

    #shootout-card {
        padding: 12px 16px;
        max-width: 90%;
        max-height: calc(100vh - 20px);
        max-height: calc(100svh - 20px);
        overflow-y: auto;
    }
    
    #shootout-card h2 {
        font-size: 1.2rem;
        margin-bottom: 8px;
    }
}
