/* ========== VARIÁVEIS ========== */
:root {
    --pitch-bg: #1e261e;
    --pitch-line: rgba(255, 255, 255, 0.4);
    --corridor-line: rgba(255, 215, 0, 0.5);
    --zone-valid: rgba(46, 204, 113, 0.4);
    --zone-invalid: rgba(231, 76, 60, 0.2);
    --zone-lateral: rgba(0, 0, 0, 0.5);
    --token-error: #e74c3c;
    --token-valid: #2ecc71;
    --text-color: #eee;
}

/* ========== RESET E BASE ========== */
body {
    background-color: #111;
    color: var(--text-color);
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

/* ========== HEADER ========== */
header {
    height: 50px;
    width: 100%;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid #333;
    z-index: 100;
    box-sizing: border-box;
}

h2 {
    font-size: 0.9rem;
    margin: 0;
    color: #ccc;
}

.status-bar {
    font-size: 0.8rem;
    font-weight: bold;
    color: #555;
}

.toggle-group {
    display: flex;
    gap: 10px;
}

button {
    background: #333;
    color: #aaa;
    border: 1px solid #444;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

button:hover {
    background: #444;
}

button.active {
    background: #2ecc71;
    color: #111;
    border-color: #2ecc71;
    font-weight: bold;
}

/* ========== CAMPO ========== */
.pitch-wrapper {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

.pitch-container {
    aspect-ratio: 68/105;
    height: 90vh;
    background-color: var(--pitch-bg);
    border: 3px solid #555;
    position: relative;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(6, 1fr);
}

/* ========== LAYERS ========== */
.markings {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

.grid-layer {
    display: contents;
}

.players-layer {
    position: absolute;
    inset: 0;
    z-index: 20;
}

/* ========== LINHAS DO CAMPO ========== */
.line-white {
    position: absolute;
    background: var(--pitch-line);
}

.border-white {
    position: absolute;
    border: 2px solid var(--pitch-line);
}

.mid-line {
    top: 50%;
    width: 100%;
    height: 2px;
}

.center-circle {
    top: 50%;
    left: 50%;
    width: 18%;
    padding-bottom: 18%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    height: 0;
}

.box-top {
    top: 0;
    left: 20%;
    width: 60%;
    height: 16%;
    border-top: none;
}

.box-bottom {
    bottom: 0;
    left: 20%;
    width: 60%;
    height: 16%;
    border-bottom: none;
}

.small-box-top {
    top: 0;
    left: 36%;
    width: 28%;
    height: 6%;
    border-top: none;
}

.small-box-bottom {
    bottom: 0;
    left: 36%;
    width: 28%;
    height: 6%;
    border-bottom: none;
}

.arc-top {
    top: 16%;
    left: 50%;
    width: 15%;
    height: 5%;
    border-radius: 0 0 50% 50%;
    border-top: none;
    transform: translateX(-50%);
}

.arc-bottom {
    bottom: 16%;
    left: 50%;
    width: 15%;
    height: 5%;
    border-radius: 50% 50% 0 0;
    border-bottom: none;
    transform: translateX(-50%);
}

/* ========== CORREDORES DOURADOS ========== */
.corridor-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--corridor-line);
    z-index: 2;
    pointer-events: none;
}

.cl-left {
    left: 20%;
}

.cl-right {
    right: 20%;
}

/* ========== ZONAS ========== */
.zone {
    border: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 5;
    transition: all 0.2s;
}

.zone-lateral {
    background: var(--zone-lateral);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.zone.is-allowed {
    background: var(--zone-valid);
    border: 1px solid #2ecc71;
    color: white;
}

.zone.is-forbidden {
    background: var(--zone-invalid);
}

/* ========== MODOS DE VISÃO ========== */
.view-18 .zone-lateral {
    opacity: 0.2;
}

.view-18 .zone:not(.zone-lateral) {
    border: 1px dashed rgba(255, 215, 0, 0.3);
}

/* ========== JOGADORES ========== */
.token {
    width: 8%;
    aspect-ratio: 1/1;
    background: radial-gradient(circle at 30% 30%, #333, #111);
    border: 2px solid #aaa;
    border-radius: 50%;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    transform: translate(-50%, -50%);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.8);
    cursor: pointer;
    transition: border-color 0.1s, transform 0.1s;
    user-select: none;
}

.token:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.9);
}

.token:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.2);
    z-index: 100;
}

/* ========== ESTADOS DO JOGADOR ========== */
.token.valid-pos {
    border-color: var(--token-valid);
    box-shadow: 0 0 10px var(--token-valid);
}

.token.invalid-pos {
    border-color: var(--token-error);
    box-shadow: 0 0 10px var(--token-error);
    background: #300;
}

.token.pass-option {
    border-color: #FFD700;
    box-shadow: 0 0 15px #FFD700;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.15); }
}

/* ========== CORES POR POSIÇÃO ========== */
.tk-gk {
    color: yellow;
    border-color: #555;
}

.tk-def {
    border-color: #3498db;
}

.tk-mid {
    border-color: #2ecc71;
}

.tk-atk {
    border-color: #e74c3c;
}

/* ========== BOLA ========== */
.ball-token {
    background: radial-gradient(circle at 30% 30%, #fff, #ddd);
    border: 2px solid #000;
    font-size: 1.2rem;
    cursor: grab;
    z-index: 50;
}

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

/* ========== MENU DE POSIÇÕES ========== */
.position-menu {
    position: fixed;
    background: #222;
    border: 2px solid #444;
    border-radius: 8px;
    padding: 15px;
    min-width: 250px;
    max-width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    z-index: 1000;
    animation: menuSlide 0.2s ease-out;
}

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

.menu-header {
    font-size: 0.9rem;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #444;
    color: #fff;
}

.menu-category {
    margin-bottom: 12px;
}

.menu-category-title {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu-positions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.menu-pos-btn {
    padding: 8px 4px;
    background: #333;
    color: #fff;
    border: 2px solid #555;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.menu-pos-btn:hover {
    background: #444;
    transform: scale(1.05);
}

.menu-pos-btn.current {
    background: #2ecc71;
    border-color: #27ae60;
    color: #000;
}

.menu-close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 25px;
    height: 25px;
    padding: 0;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-close-btn:hover {
    background: #c0392b;
}