/* ===== PROJECTOR MODE ===== */
/* Color scheme: chessboard green/white */
:root {
    --proj-green: #2d8a4e;
    --proj-green-dark: #1e6b3a;
    --proj-green-light: #3aad63;
    --proj-white: #ffffff;
    --proj-off-white: #f5f5f5;
    --proj-text-on-green: #ffffff;
    --proj-text-on-white: #1a1a1a;
    --proj-text-muted: #2d8a4e;
    --proj-gold: #b8860b;
}

#proiettore-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--proj-white);
    color: var(--proj-text-on-white);
    z-index: 9999;
    font-family: 'Segoe UI', Arial, sans-serif;
    overflow: hidden;
    flex-direction: column;
}

#proiettore-overlay.active { display: flex; }

.proj-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.5rem;
    background: var(--proj-green);
    border-bottom: 3px solid var(--proj-green-dark);
    flex-shrink: 0;
}

.proj-title-bar {
    font-size: 1rem;
    font-weight: 700;
    color: var(--proj-white);
    letter-spacing: 0.05em;
}

.proj-info-bar {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.85);
}

.proj-close-btn {
    background: #da3633;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.35rem 0.9rem;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
}

.proj-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 1.2rem 2rem;
    background: var(--proj-white);
}

.proj-screen-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--proj-green-dark);
    margin-bottom: 1rem;
    text-align: center;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    background: var(--proj-white);
    padding: 0.3rem 0;
}

.proj-screen-title .proj-emoji { font-size: 2.2rem; margin-right: 0.4rem; }

.proj-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.proj-scroll-inner {
    position: absolute;
    width: 100%;
    transition: transform 0.6s ease;
}

.proj-flex-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.proj-table {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 1.35rem;
}

.proj-table th {
    padding: 0.6rem 1rem;
    text-align: left;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 3px solid var(--proj-green-dark);
}

.proj-table td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid #c8e6c9;
}

/* Alternating green/white like chessboard */
.proj-table tbody tr:nth-child(odd)  td { background: var(--proj-green);     color: var(--proj-white); }
.proj-table tbody tr:nth-child(even) td { background: var(--proj-white);     color: var(--proj-text-on-white); }

/* Override global table CSS inside projector */
#proiettore-overlay tbody tr:nth-child(even) { background-color: transparent !important; }
#proiettore-overlay tbody tr:nth-child(odd)  { background-color: transparent !important; }
#proiettore-overlay tbody tr:hover td { filter: brightness(1.08) !important; }
#proiettore-overlay .proj-table td { border-bottom: 1px solid #c8e6c9 !important; }

.proj-table .proj-pos { font-weight: 800; text-align: center; font-size: 1.4rem; }

/* Pos medals */
.proj-table tbody tr:nth-child(1) td { background: var(--proj-green) !important; color: var(--proj-white) !important; }
.proj-table tbody tr:nth-child(1) td.proj-pos { color: #FFD700 !important; }
.proj-table tbody tr:nth-child(2) td { background: var(--proj-white) !important; color: var(--proj-text-on-white) !important; }
.proj-table tbody tr:nth-child(2) td.proj-pos { color: #808080 !important; }
.proj-table tbody tr:nth-child(3) td { background: var(--proj-green) !important; color: var(--proj-white) !important; }
.proj-table tbody tr:nth-child(3) td.proj-pos { color: #f4a460 !important; }

.proj-table .proj-pos-1 { color: #FFD700; }
.proj-table .proj-pos-2 { color: #808080; }
.proj-table .proj-pos-3 { color: #f4a460; }
.proj-table .proj-delta-pos { color: #0a6e2a; font-weight: 700; }
.proj-table .proj-delta-neg { color: #c0392b; font-weight: 700; }
.proj-table .proj-delta-zero { color: #555; }

/* On green rows delta colors need to be lighter */
.proj-table tbody tr:nth-child(odd) td .proj-delta-pos,
.proj-table tbody tr:nth-child(odd) .proj-delta-pos { color: #7fff7f !important; }
.proj-table tbody tr:nth-child(odd) .proj-delta-neg { color: #ff9999 !important; }

/* Dashboard podium */
.proj-podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 2rem;
    padding: 2rem 0;
    flex: 1;
    background: var(--proj-white);
}

.proj-podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.proj-podium-name {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--proj-green-dark);
    text-align: center;
}

.proj-podium-pts {
    font-size: 1.1rem;
    color: var(--proj-green);
}

.proj-podium-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px 12px 0 0;
    font-size: 3rem;
    font-weight: 900;
    min-width: 140px;
}

.proj-podium-block.gold   { background: linear-gradient(135deg,#b8860b,#FFD700); height:180px; color:#1a1a00; }
.proj-podium-block.silver { background: linear-gradient(135deg,#808080,#C0C0C0); height:140px; color:#0a0a0a; }
.proj-podium-block.bronze { background: linear-gradient(135deg,#8B4513,#CD7F32); height:110px; color:#1a0800; }

/* Round rows in projector */
.proj-round-row {
    display: flex;
    align-items: center;
    padding: 0.7rem 1rem;
    font-size: 1.25rem;
    gap: 1rem;
}

.proj-round-row.proj-round-header {
    background: #FFD700;
    color: #1a1a00;
    font-weight: 700;
    font-size: 0.95rem;
    border-bottom: 3px solid #b8a000;
}

.proj-round-row:not(.proj-round-header):nth-child(odd)  { background: var(--proj-green); color: var(--proj-white); }
.proj-round-row:not(.proj-round-header):nth-child(even) { background: var(--proj-white); color: var(--proj-text-on-white); border-bottom: 1px solid #c8e6c9; }

.proj-round-board  { width: 2.5rem; text-align: center; font-size: 1rem; font-weight: 700; }
.proj-round-white  { flex: 1; }
/* Larghezza 7rem (era 5rem) e white-space:nowrap così punteggi a mezzo
   punto come "2.5 - 1.5" non vanno a capo nella proiezione team. */
.proj-round-result { width: 7rem; text-align: center; font-weight: 800; font-size: 1.3rem; white-space: nowrap; }
.proj-round-black  { flex: 1; text-align: right; }

/* Progress bar for sequence */
.proj-progress {
    height: 4px;
    background: #c8e6c9;
    flex-shrink: 0;
}

.proj-progress-bar {
    height: 100%;
    background: var(--proj-green);
    transition: width linear;
}

/* Projector sortable list */
.proj-sortable-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.proj-sortable-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    cursor: default;
    user-select: none;
    transition: background 0.15s;
}

.proj-sortable-list li.dragging { opacity: 0.4; }
.proj-sortable-list li.drag-over { background: #d0e8ff; border-color: #3498db; }

.drag-handle {
    cursor: grab;
    color: #adb5bd;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.1rem;
}
.drag-handle:active { cursor: grabbing; }

/* Projector sticky table header */
.proj-sticky-header {
    flex-shrink: 0;
    width: 100%;
    /* NIENTE background qui — prima era #111 (nero) e creava una
       fascia nera a tutta larghezza dietro la tabella, visibile come
       una "riga nera bruttissima" ai lati (perché .proj-sticky-header
       è larga 100% mentre la tabella interna ha max-width:900px).
       Lo sfondo nero della testata lo dà già la cella <th>
       (background:#111111 più sotto), che si estende solo entro la
       larghezza effettiva della tabella. */
}

.proj-sticky-header table {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    border-collapse: collapse;
    table-layout: fixed;
}

.proj-sticky-header th {
    background: #111111;
    color: #ffffff;
    padding: 0.75rem 1.5rem;
    text-align: left;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 3px solid #333;
}

.proj-sticky-header th.th-pos   { text-align: center; width: 5rem; padding-left: 1.5rem; }
.proj-sticky-header th.th-pts   { text-align: center; width: 7rem; }
.proj-sticky-header th.th-elo   { text-align: center; width: 7rem; }
.proj-sticky-header th.th-var   { text-align: center; width: 9rem; white-space: nowrap; }
.proj-sticky-header th.th-games { text-align: center; width: 7rem; }

/* Scrolling tbody area */
.proj-data-rows {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 0;
}

.proj-data-rows .proj-scroll-inner { position: absolute; width: 100%; top: 0; left: 0; }

.proj-data-rows table {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 1.35rem;
}

.proj-data-rows td {
    padding: 0.65rem 1.5rem;
    border-bottom: 1px solid #c8e6c9;
    overflow: hidden;
}

.proj-data-rows td:nth-child(2) { text-overflow: ellipsis; white-space: nowrap; }

.proj-data-rows td.td-pos   { text-align: center; width: 6rem; font-weight: 800; font-size: 1.35rem; }
.proj-data-rows td.td-pts   { text-align: right; width: 6rem; }
.proj-data-rows td.td-elo   { text-align: right; width: 6.5rem; }
.proj-data-rows td.td-var   { text-align: right; width: 7rem; }
.proj-data-rows td.td-games { text-align: right; width: 6rem; }

.proj-data-rows tbody tr:nth-child(odd)  td { background: var(--proj-green); color: #fff; }
.proj-data-rows tbody tr:nth-child(even) td { background: #fff; color: #111; }

#proiettore-overlay .proj-data-rows td { border-bottom: 1px solid #c8e6c9 !important; }

.proj-data-rows tbody tr:nth-child(odd)  .proj-delta-pos { color: #7fff7f; font-weight:700; }
.proj-data-rows tbody tr:nth-child(even) .proj-delta-pos { color: #1a6e1a; font-weight:700; }
.proj-data-rows tbody tr:nth-child(odd)  .proj-delta-neg { color: #ffaaaa; font-weight:700; }
.proj-data-rows tbody tr:nth-child(even) .proj-delta-neg { color: #c0392b; font-weight:700; }
.proj-data-rows .proj-delta-zero { color: #888; }

.proj-data-rows .proj-pos-1 { color: #FFD700; }
.proj-data-rows .proj-pos-2 { color: #ddd; }
.proj-data-rows .proj-pos-3 { color: #f4a460; }

/* Individual by board body table */
.proj-board-body td {
    padding: 0.65rem 1.5rem;
    border-bottom: 1px solid #c8e6c9;
    overflow: hidden;
}

.proj-board-body td:nth-child(2) { text-overflow: ellipsis; white-space: nowrap; }
.proj-board-body td.td-pos  { text-align: center; width: 5rem; font-weight: 800; font-size: 1.35rem; padding-left: 1.5rem; }
.proj-board-body td.td-pts  { text-align: center; width: 6rem; }
.proj-board-body td.td-games { text-align: center; width: 6rem; }
.proj-board-body td.td-elo  { text-align: center; width: 7rem; }

.proj-board-body tbody tr:nth-child(odd)  td { background: var(--proj-green); color: #fff; }
.proj-board-body tbody tr:nth-child(even) td { background: #fff; color: #111; }

#proiettore-overlay .proj-board-body td { border-bottom: 1px solid #c8e6c9 !important; }

.proj-board-body .proj-pos-1 { color: #FFD700; }
.proj-board-body .proj-pos-2 { color: #ddd; }
.proj-board-body .proj-pos-3 { color: #f4a460; }

/* Gender layout */
.proj-gender-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; flex: 1; min-height: 0; overflow: hidden; width: 100%; }
.proj-gender-col   { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.proj-gender-label { font-size:1.3rem; font-weight:800; flex-shrink:0; margin-bottom:0.4rem; padding: 0.3rem 0; }
