:root {
    --primary-color: #4a3c2e; /* Dark warm brown - Soft Beige theme */
    --primary-dark: #382c21;  /* Deep brown */
    --primary-accent: #2563eb;
    --success-color: #059669;
    --success-dark: #047857;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --bg-light: #e8dcc8;
    --card-bg: #fffdf8;
    --text-main: #271e16;
    --text-muted: #6b5b45;
    --border-color: #d9c9ae;
    --border-light: #ede2cf;
    --input-bg: #f4ebdc;
    --neutral-grey: #ede2cf;
    --winner-bg: #bbf7d0; /* Clear, saturated winner highlight */
    --qualify-bg: #bbf7d0;
    --candidate-bg: #fde68a;
}

* {
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

.app-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* התראות מערכת */
.tournament-alert {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10050; /* מעל חלונות המודאל (10000), כדי שהתראה תיראה גם כשחלון פתוח */
    min-width: 320px;
    max-width: 90vw;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.92rem;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tournament-alert.alert-error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.tournament-alert.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.tournament-alert.alert-warning {
    background-color: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 18px;
    margin-bottom: 20px;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
    color: #271e16;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.role-selector-zone {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fffdf8;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.role-selector-zone label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
}

.role-selector-zone select {
    padding: 6px 12px;
    font-size: 0.92rem;
    font-weight: 700;
    border-radius: 8px;
    border: 1px solid #c4b08f;
    background-color: #f4ebdc;
    color: var(--text-main);
    cursor: pointer;
}

/* שורת טאבים (1A Segmented Pill Switcher) */
.tabs {
    display: inline-flex;
    background: #d9c9ae;
    padding: 4px;
    border-radius: 14px;
    gap: 4px;
    margin-bottom: 20px;
    overflow-x: auto;
    border: 1px solid #c4b08f;
}

.tab-btn {
    padding: 8px 18px;
    font-size: 0.88rem;
    font-weight: 700;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    color: #6b5b45;
    transition: all 0.18s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tab-btn:hover:not(.active) {
    color: #271e16;
    background: rgba(255, 255, 255, 0.4);
}

.tab-btn.active {
    background: #fffdf8;
    color: #271e16;
    border: 1px solid #c4b08f;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

/* סרגל כפתורי פעולה מהירים עליון בראש העמוד (1A Silver Action Bar) */
.top-action-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: #fffdf8;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 12px;
    margin-bottom: 22px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.top-action-toolbar .btn-sm {
    padding: 7px 14px;
    font-size: 0.84rem;
    font-weight: 700;
    border-radius: 10px;
}

.top-action-toolbar .btn-seed-playoffs-action {
    background: #ecfdf5 !important;
    border: 1px solid #a7f3d0 !important;
    color: #065f46 !important;
    box-shadow: none !important;
}

.top-action-toolbar .btn-seed-playoffs-action:hover {
    background: #d1fae5 !important;
    border-color: #6ee7b7 !important;
    color: #047857 !important;
}

@media (max-width: 640px) {
    .tabs {
        width: 100%;
        display: flex;
    }
    .tab-btn {
        flex: 1;
        justify-content: center;
        padding: 8px 6px;
        font-size: 0.8rem;
    }
    .top-action-toolbar {
        padding: 8px 6px;
        gap: 6px;
        justify-content: stretch;
    }
    .top-action-toolbar button {
        flex: 1 1 calc(50% - 6px);
        font-size: 0.78rem;
        padding: 7px 4px;
        text-align: center;
        white-space: nowrap;
    }
}

/* כרטיסים */
.card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-color);
}

.card h2 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 1.35rem;
    color: #271e16;
}

.section-subtitle {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.role-notice {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* רשת הזנת קבוצות */
.teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

/* הגדרות טורניר: הקבוצות מקובצות לפי בתים */
.team-house-section {
    grid-column: 1 / -1;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 14px 14px;
}

.team-house-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 1.02rem;
    font-weight: 800;
    color: var(--text-main);
}

.team-house-count {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--neutral-grey);
    padding: 2px 8px;
    border-radius: 9999px;
}

.teams-grid.team-house-grid {
    margin-bottom: 0;
    gap: 10px;
}

.team-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f4ebdc;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.team-input-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #57493a;
}

.team-input-group input {
    padding: 8px 10px;
    border: 1px solid #c4b08f;
    border-radius: 6px;
    background-color: var(--input-bg);
    font-size: 0.95rem;
    font-weight: 600;
    color: #271e16;
    transition: border-color 0.2s;
}

.team-input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* כפתורים כלליים (1A Silver Minimal Button Tokens) */
.btn-primary, .btn-success, .btn-danger, .btn-secondary, .btn-csv, .btn-profile {
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
}

.btn-primary {
    background: #4a3c2e;
    color: #fffdf8;
    border-color: #382c21;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.btn-primary:hover {
    background: #382c21;
    border-color: #271e16;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.12);
}

.btn-secondary {
    background: #fffdf8;
    color: #4a3c2e;
    border: 1px solid #d9c9ae;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-secondary:hover {
    background: #f4ebdc;
    border-color: #c4b08f;
    color: #271e16;
}

.btn-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.btn-success:hover {
    background: #d1fae5;
    border-color: #6ee7b7;
    color: #047857;
}

.btn-danger {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.btn-csv {
    background: #fffdf8;
    color: #065f46;
    border: 1px solid #c4b08f;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.btn-csv:hover {
    background: #f0fdf4;
    border-color: #86efac;
}

.btn-profile {
    background: #fffdf8;
    color: #4a3c2e;
    border: 1px solid #d9c9ae;
}

.btn-profile:hover {
    background: #f4ebdc;
    border-color: #c4b08f;
    color: #271e16;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.84rem;
}

/* סרגל כפתורי פעולה מהירים */
.actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    align-items: center;
}

/* פריסת שלב הבתים - טבלאות דירוג וסיכום ראשונות, ולאחריהן משחקים בגלילה למטה */
.tournament-layout {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.matches-column h2, .standings-column h2 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 14px;
    color: #271e16;
    letter-spacing: -0.01em;
}

/* סרגל סינון משחקים */
.filter-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-tabs {
    gap: 12px;
}

/* עותק הסינונים שבראש העמוד */
.filter-tabs-top {
    margin-bottom: 20px;
}

/* הקבוצה הנבחרת בלוח המשחקים: מודגשת במיוחד עם קו תחתון (כמו בטבלת הבתים) */
.match-team-row .team-name.is-chosen-team {
    -webkit-text-stroke: 0.7px currentColor;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.filter-select-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #6b5b45;
    white-space: nowrap;
}

.filter-select {
    min-width: 150px;
    max-width: 100%;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    color: #271e16;
    background: #fffdf8;
    border: 1px solid #c4b08f;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filter-select:hover {
    border-color: #a08c6c;
}

.filter-select:focus {
    outline: none;
    border-color: #6b5b45;
    box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.2);
}

/* כרטיסי משחק (1A Silver Minimal Framing) */
.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.match-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 0;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.match-card:hover {
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    border-color: #c4b08f;
}

.match-header {
    background: #f4ebdc;
    color: #4a3c2e;
    text-align: center;
    padding: 8px 12px;
    font-weight: 700;
    font-size: 0.84rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.match-badge {
    background: #d9c9ae;
    color: #57493a;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid #c4b08f;
}

.match-team-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #ede2cf;
    transition: background-color 0.18s;
}

.match-team-row:last-child {
    border-bottom: none;
}

.match-team-row .team-name {
    font-weight: 700;
    font-size: 0.92rem;
    color: #382c21;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.match-team-row.winner {
    background-color: var(--winner-bg) !important;
    box-shadow: inset -4px 0 0 #16a34a;
}

.match-team-row.winner .team-name {
    color: #14532d;
}

.match-team-row.winner .team-name::after {
    content: " 🏆";
    font-size: 0.85rem;
}

.match-team-row input.score-input {
    width: 52px;
    height: 36px;
    text-align: center;
    padding: 4px;
    background-color: #f4ebdc;
    border: 1px solid #c4b08f;
    border-radius: 8px;
    font-weight: 800;
    font-size: 1.05rem;
    color: #271e16;
    transition: all 0.18s ease;
}

.match-team-row input.score-input:focus {
    outline: none;
    border-color: #6b5b45;
    box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.2);
    background-color: #fffdf8;
}

/* טבלאות דירוג (Standings - 1A Silver Styling) */
.standings-group-card {
    background: #fffdf8;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.standings-group-header {
    background: #f4ebdc;
    color: #382c21;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 14px;
    font-size: 0.92rem;
    font-weight: 800;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.standings-header-title-box {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.group-progress-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: #475569;
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 9999px;
}

.btn-toggle-stats-detail {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    background: #fffdf8;
    border: 1px solid #c4b08f;
    border-radius: 6px;
    padding: 4px 10px;
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    color: #4a3c2e;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: all 0.15s ease;
}

.btn-toggle-stats-detail:hover {
    background: #ede2cf;
    border-color: #a08c6c;
    color: #271e16;
}

/* ברירת מחדל: טבלה מקוצרת. עמודות הזכות, החובה וההפרש מוצגות רק בתצוגה מורחבת */
.standings-table-wrap:not(.show-all-stats) .col-stat-detail {
    display: none;
}

.standings-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.standings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: center;
}

.standings-table th {
    background: #ede2cf;
    color: #57493a;
    font-weight: 700;
    padding: 10px 6px;
    font-size: 0.8rem;
    border-bottom: 1px solid #c4b08f;
}

.standings-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #d9c9ae;
    color: #4a3c2e;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.12s ease;
}

.standings-table td.team-cell {
    text-align: right;
    font-weight: 700;
    color: #271e16;
    padding-right: 10px;
}

.standings-table td.team-cell .team-name-text {
    vertical-align: middle;
}

.standings-table tr:last-child td {
    border-bottom: none;
}

/* הדגשת עולות לפלייאוף */
.standings-table tr.row-direct-qualify {
    background-color: var(--qualify-bg);
}

.standings-table tr.row-candidate-qualify {
    background-color: var(--candidate-bg);
}

.rank-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.78rem;
    font-weight: 800;
}

.rank-top {
    background: #22c55e;
    color: white;
}

.rank-third {
    background: #f59e0b;
    color: white;
}

.rank-out {
    background: #c4b08f;
    color: #57493a;
}

.diff-positive {
    color: #16a34a;
    font-weight: 800;
}

.diff-negative {
    color: #dc2626;
    font-weight: 800;
}

.diff-zero {
    color: #6b5b45;
}

.pts-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 24px;
    padding: 0 6px;
    background: #0369a1;
    color: #ffffff;
    font-weight: 800;
    border-radius: 6px;
    font-size: 0.88rem;
}

.standings-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.8rem;
    margin-top: 10px;
    margin-bottom: 16px;
    color: #57493a;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

/* שלב הפלייאוף */
.bracket-view {
    margin-top: 10px;
}

/* עץ פלייאוף: הסיבוב הראשון (העלים) משמאל, הגמר מימין, עם קווי חיבור */
.bracket-tree-scroll {
    direction: ltr;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
}

.bracket-tree {
    --bracket-gap: 18px;
    --bracket-line: #a08c6c;
    --bracket-win-line: #16a34a;
    display: flex;
    align-items: stretch;
    max-width: calc(var(--rounds, 3) * 340px);
    margin: 0 auto;
}

.bracket-round-column {
    display: flex;
    flex-direction: column;
    flex: 1 0 250px;
    min-width: 0;
}

.bracket-round-matches {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.bracket-slot {
    flex: 1;
    display: flex;
    align-items: center;
    position: relative;
    padding: 8px var(--bracket-gap);
}

.bracket-slot .playoff-match-card {
    flex: 1;
    min-width: 0;
    direction: rtl;
}

/* קו יוצא ממשחק ששתי הקבוצות בו ידועות אל המשחק הבא (זוג משחקים מתחבר לנקודה אחת) */
.bracket-round-column:not(:last-child) .bracket-slot.is-set::after {
    content: '';
    position: absolute;
    right: 0;
    width: var(--bracket-gap);
    height: 50%;
    border: 0 solid var(--bracket-line);
    border-right-width: 2px;
    box-sizing: border-box;
}

.bracket-round-column:not(:last-child) .bracket-slot.is-set:nth-child(odd)::after {
    top: 50%;
    border-top-width: 2px;
    border-top-right-radius: 6px;
}

.bracket-round-column:not(:last-child) .bracket-slot.is-set:nth-child(even)::after {
    bottom: 50%;
    border-bottom-width: 2px;
    border-bottom-right-radius: 6px;
}

/* כרטיס משחק מוקטן בעץ (גרסת מובייל) */
.bracket-mini-card {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    direction: rtl;
    font-family: inherit;
    color: var(--text-main);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.bracket-mini-card.is-final {
    border: 2px solid #f59e0b;
}

.mini-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    min-height: 26px;
    padding: 4px 5px;
    font-size: 0.7rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border-light);
}

.mini-row:last-child {
    border-bottom: none;
}

.mini-row.winner {
    background: var(--winner-bg);
    color: #14532d;
}

.mini-row.is-waiting .mini-name {
    color: var(--text-muted);
    font-weight: 600;
}

.mini-name {
    flex: 1;
    min-width: 0;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-score {
    flex-shrink: 0;
    font-weight: 800;
}

.bracket-mobile-hint {
    margin: 0 0 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

/* משחק פתוח מעל העץ במובייל: כרטיס מלא עם שמות מלאים והזנת תוצאה */
.bracket-editor-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(39, 30, 22, 0.6);
}

.bracket-editor {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bracket-editor .playoff-match-card {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.bracket-editor .team-name {
    white-space: normal;
}

/* קו נכנס אל משחק מהסיבוב הקודם */
.bracket-round-column:not(:first-child) .bracket-slot.has-feed::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: var(--bracket-gap);
    border-top: 2px solid var(--bracket-line);
    margin-top: -1px;
}

.round-header {
    background: #f4ebdc;
    color: #382c21;
    border: 1px solid var(--border-color);
    padding: 10px;
    text-align: center;
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.95rem;
    margin: 0 var(--bracket-gap) 8px;
    direction: rtl;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

/* מסלול המנצחת: הקו ממשחק שהוכרע אל המשחק הבא נצבע בירוק */
.bracket-round-column:not(:last-child) .bracket-slot.is-set.is-decided::after {
    border-color: var(--bracket-win-line);
}

.bracket-round-column:not(:first-child) .bracket-slot.has-feed.has-winner-feed::before {
    border-top-color: var(--bracket-win-line);
}

/* כותרת סיבוב לחיצה: מגדילה את משחקי הסיבוב לצפייה נוחה */
.round-header.is-clickable {
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.round-header.is-clickable:hover,
.round-header.is-clickable:focus-visible {
    outline: none;
    border-color: #a08c6c;
    box-shadow: 0 0 0 2px rgba(160, 140, 108, 0.35);
}

.bracket-round-column.is-enlarged {
    flex-grow: 2.2;
    flex-basis: 380px;
}

.bracket-round-column.is-enlarged .round-header {
    border-color: #4a3c2e;
    box-shadow: 0 0 0 2px rgba(74, 60, 46, 0.25);
}

.bracket-round-column.is-enlarged .match-header {
    font-size: 1rem;
    padding: 10px 14px;
}

.bracket-round-column.is-enlarged .match-team-row {
    padding: 16px 16px;
}

.bracket-round-column.is-enlarged .match-team-row .team-name {
    font-size: 1.2rem;
    white-space: normal;
}

.bracket-round-column.is-enlarged .match-team-row input.score-input,
.bracket-round-column.is-enlarged .score-display-viewer {
    width: 68px;
    min-width: 68px;
    height: 46px;
    font-size: 1.35rem;
}

.bracket-round-column.is-enlarged .mini-row {
    min-height: 40px;
    padding: 8px 8px;
    font-size: 0.95rem;
}

.bracket-round-column.is-enlarged .mini-name {
    white-space: normal;
}

.round-matches-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
}

.bracket-step-nav-bar {
    display: none; /* מוסתר בדסקטופ, פעיל במובייל */
}

/* כרטיס משחק פלייאוף מעוצב בסגנון Challonge */
.playoff-match-card {
    background: #ffffff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.playoff-match-card:hover {
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    border-color: #c4b08f;
}

.playoff-match-card.is-final {
    border-color: #f59e0b;
    border-width: 2px;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.18);
}

.playoff-match-card .match-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #475569;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.match-header-title {
    font-weight: 800;
    color: inherit;
}

.match-status-pill {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 700;
}

.status-done {
    background: #dcfce7;
    color: #15803d;
}

.status-live {
    background: #e0f2fe;
    color: #0369a1;
}

.status-tie {
    background: #fee2e2;
    color: #b91c1c;
    animation: pulse 1.5s infinite;
}

.status-ready {
    background: #f1f5f9;
    color: #475569;
}

.status-waiting {
    background: #f8fafc;
    color: #94a3b8;
    border: 1px dashed #cbd5e1;
}

.match-teams-list {
    display: flex;
    flex-direction: column;
}

.playoff-match-card .match-team-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    background: #ffffff;
    transition: background 0.15s ease;
}

.playoff-match-card .match-team-row:last-child {
    border-bottom: none;
}

.playoff-match-card .match-team-row.winner {
    background: #f0fdf4;
    border-right: 4px solid #16a34a;
}

.playoff-match-card.is-final .match-team-row.winner {
    background: #fefce8;
    border-right: 4px solid #eab308;
}

.team-meta-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    overflow: hidden;
    padding-left: 8px;
}

.challonge-seed-badge {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.72rem;
    font-weight: 800;
    flex-shrink: 0;
}

.winner-trophy-icon {
    margin-left: 4px;
    display: inline-block;
}

.score-input-wrap {
    flex-shrink: 0;
}

.score-display-viewer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
    padding: 0 8px;
    background: #f1f5f9;
    color: #334155;
    border-radius: 8px;
    font-weight: 800;
    font-size: 1rem;
    border: 1.5px solid #cbd5e1;
}

.score-display-viewer.score-winner {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.playoff-match-card input.score-input {
    width: 44px;
    height: 36px;
    font-size: 16px;
    text-align: center;
    font-weight: 800;
    border-radius: 8px;
    border: 1.5px solid #cbd5e1;
    background: #f8fafc;
    transition: all 0.15s ease;
}

.playoff-match-card input.score-input:focus {
    background: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.2);
    outline: none;
}

.playoff-match-card input.score-input.score-winner {
    background: #16a34a;
    color: white;
    border-color: #15803d;
}

.champion-banner {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-top: 24px;
    animation: bounceIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.champion-banner h3 {
    margin: 0;
    font-size: 1.5rem;
    color: #92400e;
}

.champion-banner .champ-name {
    font-size: 2rem;
    font-weight: 900;
    color: #78350f;
    margin: 8px 0;
}

@keyframes bounceIn {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* טאב ניהול משתמשים */
.user-management-mock {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 400px;
    margin-top: 16px;
}

/* מערכת ניהול הרשאות מבוססת תפקיד (CSS-driven security layers) */
body.role-viewer #screen-main input,
body.role-viewer .admin-editable,
body.role-viewer button.admin-editable {
    pointer-events: none !important;
    opacity: 0.6;
}

#screen-login,
#screen-login input,
#screen-login button,
#screen-login select {
    pointer-events: auto !important;
    opacity: 1 !important;
}

body:not(.role-owner) .owner-only,
body.role-viewer .tab-btn.owner-only,
body.role-admin .tab-btn.owner-only {
    display: none !important;
}

.btn-danger-delete {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-danger-delete:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

.hidden { display: none !important; }
.placeholder-text { 
    color: var(--text-muted); 
    font-style: italic; 
    text-align: center; 
    padding: 24px;
    background: #f4ebdc;
    border-radius: 8px;
    border: 1px dashed #c4b08f;
}

/* Modal for GitHub Export Guide */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
}

.modal-card {
    background: white;
    border-radius: 14px;
    max-width: 680px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    position: relative;
    border: 1px solid var(--border-color);
}

.modal-close-btn {
    position: absolute;
    top: 18px;
    left: 18px;
    background: #ede2cf;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #57493a;
    transition: all 0.2s;
}

.modal-close-btn:hover {
    background: #d9c9ae;
    color: #271e16;
}

.code-block-wrap {
    position: relative;
    margin: 14px 0;
}

.code-block {
    background: #271e16;
    color: #38bdf8;
    padding: 16px;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.88rem;
    line-height: 1.6;
    overflow-x: auto;
    direction: ltr;
    text-align: left;
    white-space: pre;
    margin: 0;
}

.btn-github {
    background: #24292f;
    color: #fffdf8;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.btn-github:hover {
    background: #271e16;
}

.btn-csv {
    background: #107c41;
    color: #fffdf8;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s, transform 0.1s;
    font-size: 0.9rem;
}

.btn-csv:hover {
    background: #0b5a2f;
}

.btn-csv:active {
    transform: scale(0.98);
}

/* ===================================================
   עמוד נחיתה - כניסה והרשאות (Login Landing Page - Concept 1A)
   =================================================== */
.login-landing-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-light);
}

.login-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 460px;
    padding: 32px 28px;
    border-radius: 18px;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border-color);
    text-align: center;
}

.login-icon-box {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    background: #ede2cf;
    border: 1px solid #d9c9ae;
    color: #382c21;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.login-card h1 {
    font-size: 1.45rem;
    font-weight: 800;
    color: #271e16;
    margin: 0 0 6px;
    letter-spacing: -0.01em;
}

.login-card p.subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 0 0 20px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: right;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.login-field label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #57493a;
}

.login-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #c4b08f;
    border-radius: 10px;
    font-size: 0.95rem;
    background-color: #f4ebdc;
    color: var(--text-main);
    transition: all 0.18s ease;
    direction: rtl;
    text-align: right;
    font-family: inherit;
}

input.login-input[type="email"],
input.login-input[type="password"] {
    direction: ltr;
    text-align: left;
}

.login-input:focus {
    outline: none;
    border-color: #6b5b45;
    background-color: #fffdf8;
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.15);
}

.login-tournament-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #c4b08f;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    background-color: #f4ebdc;
    color: var(--text-main);
    cursor: pointer;
    direction: rtl;
    text-align: right;
    font-family: inherit;
}

.login-tournament-select:focus {
    outline: none;
    border-color: #6b5b45;
    background-color: #fffdf8;
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.15);
}

.login-btn-primary {
    width: 100%;
    padding: 11px;
    font-size: 0.98rem;
    font-weight: 700;
    background: #4a3c2e;
    color: #fffdf8;
    border: 1px solid #382c21;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.18s, transform 0.1s;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.login-btn-primary:hover {
    background: #382c21;
}

/* מסך הפתיחה: בחירה בין כניסת צופה לכניסת מנהל */
.login-choice {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.login-choice-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    padding: 16px 20px;
    font-family: inherit;
    text-align: right;
    color: #271e16;
    background: #f4ebdc;
    border: 1px solid #c4b08f;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.login-choice-btn:hover,
.login-choice-btn:focus-visible {
    outline: none;
    background: #ede2cf;
    border-color: #a08c6c;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}

.login-choice-btn.login-choice-manager {
    color: #fffdf8;
    background: #4a3c2e;
    border-color: #382c21;
}

.login-choice-btn.login-choice-manager:hover,
.login-choice-btn.login-choice-manager:focus-visible {
    background: #382c21;
    border-color: #271e16;
}

.login-choice-icon {
    flex-shrink: 0;
    font-size: 1.7rem;
    line-height: 1;
}

.login-choice-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
    text-align: right;
}

.login-choice-text strong {
    font-size: 1.08rem;
    font-weight: 800;
}

.login-choice-text small {
    font-size: 0.82rem;
    font-weight: 500;
    opacity: 0.85;
}

/* חלון בחירת טורניר לניהול (לאחר התחברות מנהל) */
.admin-chooser-card {
    max-width: 480px;
    background: var(--card-bg);
}

.admin-chooser-title {
    margin: 0 0 4px;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-main);
}

.admin-chooser-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0 12px;
    max-height: 46vh;
    overflow-y: auto;
    padding: 2px;
}

.admin-chooser-list .login-choice-btn.is-archived {
    background: var(--neutral-grey);
    color: var(--text-muted);
}

.admin-chooser-new {
    margin-top: 4px;
}

.login-back-link {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 6px;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    color: #6b5b45;
    background: none;
    border: none;
    cursor: pointer;
}

.login-back-link:hover {
    color: #271e16;
    text-decoration: underline;
}

.login-btn-guest {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    background: #fffdf8;
    color: #57493a;
    border: 1px solid #d9c9ae;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.login-btn-guest:hover {
    background: #f4ebdc;
    color: #271e16;
    border-color: #c4b08f;
}

/* לשוניות מעבר: כניסה / הרשמה (Auth Tabs - 1A Pill Switcher) */
.auth-tabs {
    display: flex;
    background: #ede2cf;
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    gap: 4px;
    border: 1px solid #d9c9ae;
}

.auth-tab {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #6b5b45;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
}

.auth-tab.active {
    background: #fffdf8;
    color: #271e16;
    border-color: #c4b08f;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.auth-tab:hover:not(.active) {
    color: #382c21;
    background: rgba(255, 255, 255, 0.5);
}

/* כפתור כניסה באמצעות Google / Gmail */
.google-auth-wrapper {
    margin-bottom: 16px;
}

.btn-google-auth {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fffdf8;
    color: #3c4043;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 0.96rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(60, 64, 67, 0.08);
    transition: all 0.2s ease;
}

.btn-google-auth:hover {
    background: #f4ebdc;
    border-color: #c2c7d0;
    box-shadow: 0 2px 6px rgba(60, 64, 67, 0.15);
    transform: translateY(-1px);
}

.btn-google-auth:active {
    background: #ede2cf;
    transform: translateY(0);
}

.google-icon {
    flex-shrink: 0;
}

/* מפריד או במייל */
.auth-divider {
    display: flex;
    align-items: center;
    margin: 16px 0 20px;
    text-align: center;
    color: #a08c6c;
    font-size: 0.82rem;
    font-weight: 600;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid #d9c9ae;
}

.auth-divider span {
    padding: 0 12px;
}

.auth-switch-note {
    font-size: 0.86rem;
    color: #6b5b45;
    margin-top: 14px;
    text-align: center;
}

.auth-switch-note a {
    color: var(--primary-color);
    font-weight: 700;
    text-decoration: none;
}

.auth-switch-note a:hover {
    text-decoration: underline;
}

.login-btn-signup {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.25);
}

.login-btn-signup:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

/* מודאל Google Authentication */
.google-modal-card {
    max-width: 440px;
    padding: 32px 28px;
    border-radius: 18px;
    text-align: center;
}

.google-modal-header {
    margin-bottom: 22px;
}

.google-modal-header svg {
    margin-bottom: 10px;
}

.google-modal-header h2 {
    font-size: 1.35rem;
    color: #271e16;
    margin: 0 0 6px;
    font-weight: 800;
}

.google-modal-sub {
    font-size: 0.9rem;
    color: #6b5b45;
    margin: 0;
    line-height: 1.5;
}

.google-accounts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.google-account-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border: 1px solid #d9c9ae;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fffdf8;
    text-align: right;
}

.google-account-item:hover {
    background: #f4ebdc;
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
    transform: translateY(-1px);
}

.google-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
}

.google-avatar-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.google-avatar-other {
    background: #d9c9ae;
    color: #57493a;
}

.google-account-info {
    flex: 1;
    overflow: hidden;
}

.google-account-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #271e16;
    display: flex;
    align-items: center;
    gap: 6px;
}

.google-owner-tag {
    font-size: 0.72rem;
    background: #fef3c7;
    color: #92400e;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 800;
    border: 1px solid #fcd34d;
}

.google-account-email {
    font-size: 0.82rem;
    color: #6b5b45;
    direction: ltr;
    text-align: right;
}

.google-account-arrow {
    color: #a08c6c;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.google-account-item:hover .google-account-arrow {
    color: var(--primary-color);
    transform: translateX(-4px);
}

.custom-google-box {
    margin-top: 10px;
    padding: 12px;
    background: #f4ebdc;
    border: 1px dashed #c4b08f;
    border-radius: 10px;
    text-align: right;
}

.custom-google-box label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #4a3c2e;
}

.google-modal-footer {
    padding-top: 12px;
    border-top: 1px solid #ede2cf;
}

.google-modal-footer p {
    margin: 0;
    font-size: 0.78rem;
    color: #6b5b45;
    line-height: 1.4;
}

.login-role-guide {
    margin-top: 24px;
    padding: 14px;
    border-radius: 10px;
    background: #f4ebdc;
    border: 1px dashed #c4b08f;
    font-size: 0.8rem;
    color: #6b5b45;
    text-align: right;
    line-height: 1.6;
}

.login-role-guide strong {
    color: #382c21;
}

/* ===================================================
   סרגל משתמש וטורניר ב-Header
   =================================================== */
.user-session-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
}

.user-badge-owner {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.user-badge-admin {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.user-badge-viewer {
    background: #f4ebdc;
    color: #57493a;
    border: 1px solid #c4b08f;
}

.tournament-select-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fffdf8;
    padding: 4px 10px;
    border-radius: 10px;
    border: 1px solid #d9c9ae;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.tournament-select-wrap label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #6b5b45;
}

.tournament-select-wrap select {
    border: none;
    background: transparent;
    font-weight: 700;
    font-size: 0.88rem;
    color: #271e16;
    cursor: pointer;
    outline: none;
}

.guest-tournament-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.guest-tournament-badge .guest-tourney-icon {
    font-size: 0.95rem;
}

.guest-tournament-badge .guest-tourney-label {
    color: #64748b;
    font-weight: 600;
    font-size: 0.8rem;
}

.guest-tournament-badge .guest-tourney-name {
    color: #0369a1;
    font-weight: 800;
}

body:not(.role-viewer) .guest-tournament-badge {
    display: none !important;
}

body.role-viewer .guest-tournament-badge {
    display: inline-flex !important;
}

.btn-logout {
    padding: 6px 12px;
    font-size: 0.84rem;
    font-weight: 600;
    background: #fffdf8;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.btn-logout:hover {
    background: #fef2f2;
    border-color: #f87171;
}

/* באנר ארכיון כשצופים בטורניר ישן */
.archive-banner {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

/* ===================================================
   ניהול מנהלים וטורנירים (Owner Dashboard)
   =================================================== */
.admin-management-box {
    margin-top: 20px;
}

.admin-add-form {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.admin-add-form input {
    flex: 1;
    min-width: 250px;
    padding: 10px 12px;
    border: 1px solid #c4b08f;
    border-radius: 8px;
    font-size: 0.95rem;
    direction: ltr;
    text-align: left;
}

.admins-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.admins-table th {
    background: #f4ebdc;
    padding: 10px;
    text-align: right;
    font-size: 0.85rem;
    color: #57493a;
    border-bottom: 2px solid #d9c9ae;
}

.admins-table td {
    padding: 10px;
    border-bottom: 1px solid #d9c9ae;
    font-size: 0.9rem;
}

.btn-delete-admin {
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #f87171;
    border-radius: 4px;
    cursor: pointer;
}

.btn-delete-admin:hover {
    background: #fca5a5;
}

/* ===================================================
   סגנונות אשף הקמת טורניר ועריכת משתמש
   =================================================== */
.wizard-modal-card {
    max-width: 580px;
    width: 95%;
}

.wizard-format-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.wizard-format-card {
    border: 2px solid #c4b08f;
    border-radius: 12px;
    padding: 14px 10px;
    cursor: pointer;
    background: #fffdf8;
    transition: all 0.2s ease;
    text-align: center;
    position: relative;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.wizard-format-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.wizard-format-card:hover {
    border-color: #3b82f6;
    background: #f4ebdc;
}

.wizard-format-card.active {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

.wizard-card-icon {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.wizard-card-title {
    font-weight: 800;
    font-size: 0.95rem;
    color: #271e16;
    margin-bottom: 4px;
}

.wizard-card-desc {
    font-size: 0.8rem;
    color: #6b5b45;
    line-height: 1.4;
}

.wizard-settings-box {
    background: #f4ebdc;
    border: 1px solid #d9c9ae;
    border-radius: 12px;
    padding: 14px;
    margin-top: 14px;
}

.wizard-summary-pill {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 16px;
    font-size: 0.9rem;
    color: #166534;
    text-align: right;
    font-weight: 700;
    line-height: 1.5;
    direction: rtl;
}

.btn-edit-user {
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-edit-user:hover {
    background: #dbeafe;
}

/* יישור מספרים מימין בעברית: תגיות מספר בראש השורה */
.team-label-rtl {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    direction: rtl !important;
    text-align: right !important;
    font-weight: 700;
    font-size: 0.88rem;
}

.team-num-prefix {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #2563eb;
    color: #fffdf8;
    font-weight: 800;
    font-size: 0.8rem;
    min-width: 28px;
    height: 22px;
    padding: 0 6px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.25);
    flex-shrink: 0;
}

/* תוצאה שווה (אין תיקו בכדורשת): מסומנת כמשחק שטרם הוכרע */
.match-team-row.draw-match {
    background-color: #d9c9ae !important;
    border-right: 4px solid #6b5b45;
}

.match-team-row.draw-match .team-name::after {
    content: " ⚠️";
    font-size: 0.85rem;
}

/* עמודת נקודות בטבלת הדירוג */
.standings-table th.pts-th {
    background: #e0f2fe;
    color: #0369a1;
    font-weight: 800;
}

.standings-table td.pts-td {
    background: #f0f9ff;
    color: #0369a1;
    font-weight: 800;
    font-size: 0.95rem;
}

/* אלופת הבית (טורניר בתים בלבד) */
.rank-champion {
    background: #eab308;
    color: #fffdf8;
    box-shadow: 0 0 6px rgba(234, 179, 8, 0.4);
}

.row-champion {
    background-color: #fde68a !important;
}

/* ==========================================================================
   התאמות צפייה וניקיון עבור אורח / צופה (Viewer Clean UI)
   הסתרת כל כפתורי העריכה, הפרופיל, הסיסמה, והגדרות שאינן רלוונטיות
   ========================================================================== */
body.role-viewer .btn-profile,
body.role-viewer .tab-btn[onclick*="setup"],
body.role-viewer #tab-setup,
body.role-viewer .admin-editable,
body.role-viewer .owner-only,
body.role-viewer .tournament-select-wrap,
body.role-viewer .guest-only-btn,
body.role-viewer .guest-banner-actions,
body.role-viewer .actions-bar {
    display: none !important;
}

body:not(.role-viewer) .guest-only-btn {
    display: none !important;
}

/* תצוגת תוצאות נקייה וקריאה במצב צופה (במקום תיבות קלט אפורות) */
.score-display-viewer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 36px;
    padding: 0 6px;
    background: #ede2cf;
    border: 1px solid #c4b08f;
    border-radius: 6px;
    font-weight: 800;
    font-size: 1.1rem;
    color: #271e16;
}

.match-team-row.winner .score-display-viewer {
    background: #86efac;
    border-color: #16a34a;
    color: #065f46;
}

/* ==========================================================================
   מעקב אישי: באנר עליון, הדגשת קבוצה ובלוק משחקים מועדף (Concept 1A)
   ========================================================================== */
.guest-followed-banner {
    background: #fffdf8;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 12px 18px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.04);
    color: #1e3a8a;
    font-size: 0.92rem;
}

.guest-followed-banner strong {
    color: #1d4ed8;
}

.guest-banner-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* הקבוצה במעקב מודגשת בטקסט בלבד (מודגש במיוחד + קו תחתון), בלי צבע רקע,
   כדי לא להתבלבל עם צבעי העולות והמועמדות. העיבוי נעשה בקו מתאר ולא במשקל גופן
   כבד יותר, כי במשקלים 800-900 העברית מוחלפת בגופן אחר בחלק מהמכשירים */
.row-followed-team td.team-cell .team-name-text {
    font-weight: 700;
    -webkit-text-stroke: 0.7px currentColor;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.followed-matches-container {
    background: #fffdf8;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(34, 197, 94, 0.04);
}

.followed-matches-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: #166534;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.all-matches-divider {
    font-size: 1.05rem;
    font-weight: 800;
    color: #271e16;
    margin: 22px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #d9c9ae;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   מצב שוויון בפלייאוף - תצוגה עדינה שאינה מוחקת נתונים
   ========================================================================== */
.playoff-tie-card {
    border-color: #f59e0b !important;
}

.tie-badge {
    background: #fef3c7;
    color: #92400e;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    border: 1px solid #fcd34d;
}

.score-input.score-tie {
    border-color: #f59e0b;
    background-color: #fde68a;
}

/* ==========================================================================
   התאמות מלאות למסכי סמארטפון / מובייל (Mobile First Responsiveness)
   מניעת גלילה אופקית, מניעת זום אוטומטי ב-iOS וקריאות מיטבית
   ========================================================================== */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

@media (max-width: 640px) {
    .app-container {
        padding: 8px 6px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding-bottom: 12px;
        margin-bottom: 12px;
    }

    header h1 {
        font-size: 1.25rem;
        text-align: center;
        justify-content: center;
    }

    .user-session-bar {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: center;
        align-items: center;
    }

    .tournament-select-wrap {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }

    .tournament-select-wrap select {
        flex: 1;
        max-width: 220px;
        font-size: 0.9rem;
    }

    .tabs {
        gap: 4px;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.84rem;
        white-space: nowrap;
    }

    .card {
        padding: 14px 10px;
        border-radius: 10px;
    }

    /* ========================================================
       טבלאות דירוג קומפקטיות ונוחות במובייל - התאמה מלאה ללא גלילה
       ======================================================== */
    /* כותרות עמודות מלאות במובייל: גופן קטן ושבירת שורה כדי שהטבלה תתאים לרוחב המכשיר */
    .standings-table th {
        font-size: 0.66rem;
        line-height: 1.2;
        padding: 6px 2px;
    }

    .standings-table {
        font-size: 0.8rem;
        width: 100% !important;
    }

    .standings-table th, .standings-table td {
        padding: 8px 3px;
    }

    .standings-table td.team-cell {
        max-width: 130px;
        padding-right: 6px;
        font-size: 0.82rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .standings-table td.team-cell .team-name-text {
        display: inline-block;
        max-width: 110px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        vertical-align: middle;
    }

    /* מקום לקו התחתון שלא ייחתך */
    .standings-table .row-followed-team td.team-cell .team-name-text {
        padding-bottom: 4px;
    }

    .pts-pill {
        min-width: 24px;
        height: 22px;
        font-size: 0.82rem;
        padding: 0 4px;
    }

    .rank-indicator {
        width: 20px;
        height: 20px;
        font-size: 0.72rem;
    }

    /* כרטיסי משחק תופסים 100% רוחב */
    .matches-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .match-card {
        width: 100%;
    }

    .match-team-row {
        padding: 8px 10px;
    }

    .match-team-row .team-name {
        font-size: 0.88rem;
    }

    /* הגדרת font-size 16px על מנת למנוע זום אוטומטי מציק במכשירי iOS / ספארי */
    .match-team-row input.score-input {
        font-size: 16px;
        width: 48px;
        height: 38px;
    }

    /* עץ פלייאוף במובייל: כל העץ נכנס לרוחב המסך בכרטיסים מוקטנים */
    .bracket-tree {
        --bracket-gap: 5px;
        max-width: none;
    }

    .bracket-round-column {
        flex: 1 1 0;
    }

    .bracket-slot {
        padding: 3px var(--bracket-gap);
    }

    .bracket-round-column:not(:last-child) .bracket-slot.is-set:nth-child(odd)::after,
    .bracket-round-column:not(:last-child) .bracket-slot.is-set:nth-child(even)::after {
        border-radius: 0;
    }

    .round-header {
        padding: 4px 2px;
        font-size: 0.66rem;
        line-height: 1.25;
        border-radius: 6px;
        margin-bottom: 6px;
    }

    /* במובייל הסיבוב המוגדל מקבל את רוב רוחב המסך, והשאר מצטמצמים */
    .bracket-round-column.is-enlarged {
        flex: 3 1 0;
    }

    .bracket-round-column.is-enlarged .round-header {
        font-size: 0.8rem;
        padding: 6px 4px;
    }

    /* לוח המשחקים: כל משחק בשורה אחת (קבוצה מול קבוצה) במקום כרטיס גבוה */
    #group-matches-container .matches-grid {
        gap: 8px;
    }

    #group-matches-container .match-card {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    #group-matches-container .match-header {
        grid-column: 1 / -1;
        padding: 3px 10px;
        font-size: 0.7rem;
    }

    #group-matches-container .match-badge {
        font-size: 0.66rem;
        padding: 0 6px;
    }

    #group-matches-container .match-team-row {
        padding: 6px 8px;
        gap: 6px;
        min-width: 0;
        border-bottom: none;
    }

    #group-matches-container .match-team-row:last-child {
        flex-direction: row-reverse;
        border-right: 1px solid var(--border-color);
    }

    #group-matches-container .match-team-row:last-child .team-name {
        text-align: left;
    }

    #group-matches-container .match-team-row.winner:last-child {
        box-shadow: inset 4px 0 0 #16a34a;
    }

    #group-matches-container .match-team-row.draw-match:last-child {
        border-right: 1px solid var(--border-color);
        border-left: 4px solid #6b5b45;
    }

    .filter-tabs {
        flex-wrap: nowrap;
        gap: 8px;
    }

    .filter-select-wrap {
        flex: 1 1 0;
        min-width: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 3px;
    }

    .filter-select-wrap .filter-select {
        width: 100%;
    }

    .filter-select {
        flex: 1;
        min-width: 0;
        font-size: 16px;
    }

    /* מודאלים מותאמים לרוחב המכשיר */
    .modal-card, .wizard-modal-card {
        width: 95vw !important;
        max-width: 95vw !important;
        padding: 16px 12px !important;
        max-height: 92vh;
        overflow-y: auto;
    }

    .guest-followed-banner {
        padding: 10px 12px;
        font-size: 0.88rem;
    }
}

/* הגדרות טורניר במובייל: שתי קבוצות בשורה בכל בית, כדי שהרשימה לא תהיה ארוכה מדי */
@media (max-width: 640px) {
    .team-house-section {
        padding: 10px;
    }

    .teams-grid.team-house-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .team-house-grid .team-input-group {
        padding: 8px;
        min-width: 0;
    }

    .team-house-grid .team-input-group input {
        width: 100%;
        min-width: 0;
        font-size: 16px;
    }
}

/* טאב שמוסתר לפי מצב לוח המשחקים (לפני/אחרי יצירת הלוח) */
.tab-btn.board-hidden {
    display: none !important;
}

/* רכיבי עריכה של שלב הבתים שמוסתרים לאחר נעילת השלב ושיבוץ הפלייאוף */
.stage-locked-hidden {
    display: none !important;
}

/* ==========================================================================
   משחק במערכות (הטוב משלוש): כל מערכה מוצגת בתא משלה בכרטיס המשחק
   ========================================================================== */
.match-card.multi-set .sets-labels {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 0;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
}

.sets-labels-spacer {
    flex: 1;
}

.sets-cells {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.set-label {
    width: 46px;
    text-align: center;
}

.sets-total,
.sets-total-label {
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.sets-total {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
}

.match-team-row.sets-row {
    gap: 8px;
}

.match-team-row.sets-row input.score-input.set-cell,
.match-team-row.sets-row .score-display-viewer.set-cell {
    width: 46px;
    min-width: 46px;
    height: 34px;
    padding: 2px;
    font-size: 0.98rem;
}

/* המערכה שהקבוצה ניצחה מודגשת בירוק */
.match-team-row.sets-row .set-cell.set-won {
    background: #86efac;
    border-color: #16a34a;
    color: #065f46;
}

/* מערכה שלישית שאינה נדרשת (המשחק הוכרע 2:0) */
.match-team-row.sets-row .set-cell.set-not-needed {
    opacity: 0.4;
}

/* טבלת הבתים: יחס (מספר גדול) ומתחתיו זכות:חובה */
.standings-table td.ratio-cell {
    line-height: 1.15;
}

.ratio-main {
    display: block;
    font-weight: 800;
}

.ratio-sub {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
}

@media (max-width: 640px) {
    /* במובייל כרטיס מערכות נשאר שורה לכל קבוצה (ולא שתי קבוצות זו מול זו) */
    #group-matches-container .match-card.multi-set {
        display: block;
    }

    #group-matches-container .match-card.multi-set .match-team-row,
    #group-matches-container .match-card.multi-set .match-team-row:last-child {
        flex-direction: row;
        border-right: none;
        padding: 6px 8px;
    }

    #group-matches-container .match-card.multi-set .match-team-row:first-of-type {
        border-bottom: 1px solid var(--border-light);
    }

    #group-matches-container .match-card.multi-set .match-team-row:last-child .team-name {
        text-align: right;
    }

    #group-matches-container .match-card.multi-set .match-team-row.winner:last-child {
        box-shadow: inset -4px 0 0 #16a34a;
    }

    .match-card.multi-set .sets-labels {
        padding: 5px 8px 0;
        gap: 6px;
    }

    .match-team-row.sets-row {
        gap: 6px;
    }

    .sets-cells {
        gap: 4px;
    }

    .set-label {
        width: 42px;
        font-size: 0.62rem;
    }

    .match-team-row.sets-row input.score-input.set-cell,
    .match-team-row.sets-row .score-display-viewer.set-cell {
        width: 42px;
        min-width: 42px;
        height: 36px;
        font-size: 16px;
    }

    .sets-total,
    .sets-total-label {
        width: 34px;
        font-size: 0.62rem;
    }

    .sets-total {
        font-size: 1rem;
    }
}

/* ==========================================================================
   פלייאוף במערכות: כרטיס המשחק בעץ מציג תא לכל מערכה
   ========================================================================== */
.match-team-row.sets-row .team-meta-wrap {
    flex: 1;
    min-width: 0;
}

.bracket-tree.has-sets .bracket-round-column {
    flex-basis: 330px;
}

.playoff-match-card.multi-set .set-label,
.playoff-match-card.multi-set .match-team-row.sets-row input.score-input.set-cell,
.playoff-match-card.multi-set .match-team-row.sets-row .score-display-viewer.set-cell {
    width: 40px;
    min-width: 40px;
}

.playoff-match-card.multi-set .sets-total,
.playoff-match-card.multi-set .sets-total-label {
    width: 34px;
}

.playoff-match-card.multi-set .set-label {
    font-size: 0.62rem;
}

/* סיבוב מוגדל: תאי המערכות גדלים במידה, לא לרוחב של שדה תוצאה יחיד */
.bracket-round-column.is-enlarged .playoff-match-card.multi-set .set-label,
.bracket-round-column.is-enlarged .playoff-match-card.multi-set .match-team-row.sets-row input.score-input.set-cell,
.bracket-round-column.is-enlarged .playoff-match-card.multi-set .match-team-row.sets-row .score-display-viewer.set-cell {
    width: 52px;
    min-width: 52px;
    height: 42px;
    font-size: 1.15rem;
}

.bracket-round-column.is-enlarged .playoff-match-card.multi-set .set-label {
    height: auto;
    font-size: 0.72rem;
}

/* בכרטיס הפלייאוף הצר תוויות המערכות נשארות בשורה אחת, והשם מקבל את מלוא הרוחב שנותר */
.playoff-match-card.multi-set .set-label {
    font-size: 0.56rem;
    white-space: nowrap;
}

.playoff-match-card.multi-set .match-team-row.sets-row {
    gap: 6px;
    padding-left: 10px;
    padding-right: 10px;
}

.playoff-match-card.multi-set .sets-cells {
    gap: 4px;
}

.bracket-tree.has-sets .bracket-round-column {
    flex-basis: 350px;
}

.bracket-tree.has-sets {
    max-width: calc(var(--rounds, 3) * 380px);
}

/* ==========================================================================
   הרשאות מפתח (Developer): כמו מנהל, ובנוסף מחיקת טורנירים וכלי בדיקה
   ========================================================================== */
/* מחיקת טורניר: בעלים ומפתח בלבד */
body:not(.role-owner):not(.role-developer) .can-delete-only {
    display: none !important;
}

/* כלי בדיקה (מילוי/איפוס תוצאות, סימולציית פלייאוף, שמות לדוגמה): בעלים ומפתח בלבד */
body:not(.role-owner):not(.role-developer) .debug-only {
    display: none !important;
}

/* ==========================================================================
   מצב ללא טורניר פעיל
   ========================================================================== */
#noTournamentState {
    display: none;
    text-align: center;
    padding: 44px 20px;
}

body.no-tournament #noTournamentState {
    display: block;
}

.no-tournament-icon {
    font-size: 2.6rem;
    line-height: 1;
    margin-bottom: 10px;
}

.no-tournament-state h2 {
    margin: 0 0 6px;
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-main);
}

.no-tournament-state p {
    margin: 0 auto 18px;
    max-width: 440px;
    color: var(--text-muted);
    line-height: 1.5;
}

.no-tournament-create {
    padding: 12px 24px;
    font-size: 1.05rem;
    font-weight: 800;
}

/* ההודעה לצופים מוצגת רק לצופים; החלק של המנהלים מוסתר מצופים דרך admin-editable */
body:not(.role-viewer) .no-tournament-viewer {
    display: none;
}

/* בלי טורניר מוצג אין טאבים, תוכן טורניר או פעולות על טורניר */
body.no-tournament nav.tabs,
body.no-tournament .tab-section,
body.no-tournament #archiveBanner,
body.no-tournament .btn-csv,
body.no-tournament #headerRenameTeamsBtn,
body.no-tournament #headerArchiveTournamentBtn,
body.no-tournament #headerBtnNewTourney,
body.no-tournament .can-delete-only,
body.no-tournament .guest-tournament-badge,
body.zero-tournaments .tournament-select-wrap {
    display: none !important;
}

/* מסך הכניסה לצופים כשאין טורניר פעיל */
.viewer-waiting {
    display: none;
    text-align: center;
    padding: 8px 4px 4px;
    color: var(--text-main);
}

.viewer-waiting strong {
    display: block;
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 6px;
}

.viewer-waiting p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted);
}

#login-step-viewer.no-active .viewer-waiting {
    display: block;
}

#login-step-viewer.no-active .login-field,
#login-step-viewer.no-active .login-btn-primary {
    display: none !important;
}

/* סרגל הפעולות העליון של שלב הבתים מכיל רק כלים לבעלים ולמפתחים (כולל כפתור הנעילה העליון),
   ולכן מנהל רגיל אינו רואה אותו כלל; כפתור הנעילה התחתון נשאר לכל המנהלים */
body:not(.role-owner):not(.role-developer) #tab-group-stage .top-action-toolbar {
    display: none !important;
}

/* כפתור שם ותאריך הטורניר אינו רלוונטי כשאין טורניר מוצג */
body.no-tournament #headerTournamentDetailsBtn {
    display: none !important;
}

/* פעולות לבעלים ולמפתחים בלבד (למשל העברה לארכיון) */
body:not(.role-owner):not(.role-developer) .senior-only {
    display: none !important;
}

/* באנר טורניר שהסתיים */
.archive-banner.finished-banner {
    background: #dcfce7;
    border-color: #86efac;
    color: #14532d;
}

body.no-tournament #finishedBanner,
body.no-tournament #headerFinalizeTournamentBtn {
    display: none !important;
}

/* אשף טורניר חדש: התאריך שמתווסף לשם מוצג "מודבק" לשדה השם */
.name-with-date {
    display: flex;
    align-items: stretch;
}

.name-with-date .login-input {
    flex: 1;
    min-width: 0;
    /* הממשק מימין לשמאל: השדה מימין והתאריך צמוד אליו משמאל */
    border-radius: 0 10px 10px 0;
    border-left: none;
}

.name-date-suffix {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0 12px;
    /* מימין לשמאל: המקף צמוד לשם (מימין לתאריך), כמו בשם המלא "שם - תאריך" */
    direction: rtl;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-muted);
    background: var(--neutral-grey);
    border: 1px solid #c4b08f;
    border-radius: 10px 0 0 10px;
    white-space: nowrap;
}

.name-date-hint {
    display: block;
    margin-top: 4px;
    margin-bottom: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ==========================================================================
   פלייאוף פנימי: משחקי מיקום בתוך כל בית והדירוג הסופי שנקבע מהם
   ========================================================================== */
.internal-playoff {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    align-items: start;
}

.internal-house {
    background: #fbf5ea;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
}

.internal-house-title {
    margin: 0 0 10px;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-main);
}

.internal-house-matches {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.internal-match-slot {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.internal-match-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
}

.internal-final-ranking {
    margin-top: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
}

.internal-final-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 6px;
}

.internal-final-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.internal-final-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px dashed var(--border-color);
}

.internal-final-list li:last-child {
    border-bottom: none;
}

.internal-final-list li.is-pending .final-team {
    font-weight: 400;
    font-style: italic;
    color: var(--text-muted);
}

.internal-final-list li.is-champion .final-team {
    color: #b45309;
}

.final-place {
    flex-shrink: 0;
    width: 26px;
    text-align: center;
    font-weight: 800;
    color: var(--text-muted);
}

/* ==========================================================================
   אשף הטורניר: הודעת שגיאה בתוך החלון וסימון שדות חסרים
   ========================================================================== */
.wizard-error-box {
    margin-top: 16px;
    padding: 10px 12px;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: 10px;
    color: #b91c1c;
    font-weight: 700;
    font-size: 0.92rem;
    line-height: 1.4;
}

#new-tournament-wizard-modal .login-input.field-missing {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
    background-color: #fef2f2;
}

#new-tournament-wizard-modal .wizard-format-options.field-missing {
    outline: 2px solid #dc2626;
    outline-offset: 6px;
    border-radius: 12px;
}

/* משחק של שתי מערכות שהסתיים 1:1: הסבר ההכרעה לפי סך הנקודות */
.sets-decision-note {
    padding: 5px 12px 7px;
    font-size: 0.76rem;
    font-weight: 700;
    color: #166534;
    background: #f0fdf4;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.sets-decision-note.is-tie {
    color: #b45309;
    background: #fffbeb;
}

/* ==========================================================================
   יומן פעולות וסטטיסטיקת צופים (פאנל הבעלים)
   ========================================================================== */
.audit-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}

.audit-filters .filter-select {
    min-width: 150px;
}

.audit-filters .audit-search {
    flex: 1;
    min-width: 200px;
}

.audit-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.audit-table-wrap {
    overflow: auto;
    max-height: 520px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
}

.audit-table-wrap .admins-table {
    margin: 0;
}

.audit-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.audit-table td {
    vertical-align: top;
    font-size: 0.85rem;
}

.audit-time {
    white-space: nowrap;
    color: var(--text-muted);
}

.audit-email {
    font-size: 0.74rem;
    color: var(--text-muted);
    direction: ltr;
    display: inline-block;
}

.audit-action {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 9999px;
    background: #f4ebdc;
    border: 1px solid var(--border-color);
    font-weight: 700;
    font-size: 0.76rem;
    white-space: nowrap;
}

.audit-details {
    min-width: 240px;
    line-height: 1.4;
}

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

.stat-tile {
    background: #fbf5ea;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.1;
}

.stat-label {
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================================================
   שתי תצוגות לבעלים: ניהול הטורניר / ניהול המערכת
   ========================================================================== */
/* בניהול המערכת כל מה ששייך לטורניר עצמו מוסתר: בורר וכפתורי הטורניר, הטאבים והבאנרים */
body.owner-dashboard .tournament-view-only,
body.owner-dashboard nav.tabs,
body.owner-dashboard #archiveBanner,
body.owner-dashboard #finishedBanner,
body.owner-dashboard #noTournamentState {
    display: none !important;
}

/* ניהול המערכת זמין גם כשאין אף טורניר פעיל */
body.owner-dashboard #tab-users {
    display: block !important;
}

.dash-title {
    margin: 0 0 12px;
}

/* הניווט הפנימי נשאר צמוד לראש המסך בזמן גלילה, כך שתמיד אפשר לעבור בין החלקים */
.dash-tabs {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    gap: 4px;
    padding: 4px;
    margin-bottom: 18px;
    background: #d9c9ae;
    border: 1px solid #c4b08f;
    border-radius: 14px;
    flex-wrap: wrap;
}

.dash-tab-btn {
    flex: 1 1 auto;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    color: #6b5b45;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.18s ease;
}

.dash-tab-btn:hover {
    color: #271e16;
}

.dash-tab-btn.active {
    background: #fffdf8;
    color: #271e16;
    border-color: #c4b08f;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.dash-critical {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   חלון אישור פנימי ומחיקת רשומות מיומן הפעולות
   ========================================================================== */
.confirm-overlay {
    z-index: 10020; /* מעל חלונות אחרים, מתחת להתראות */
}

.confirm-message {
    white-space: pre-line;
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
}

.audit-delete-panel {
    margin-top: 14px;
    border: 1px solid #fca5a5;
    border-radius: 10px;
    background: #fef2f2;
}

.audit-delete-panel > summary {
    padding: 9px 12px;
    font-weight: 700;
    color: #b91c1c;
    cursor: pointer;
}

.audit-delete-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 4px 12px 12px;
}

.audit-delete-modes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    font-weight: 600;
    color: var(--text-main);
}

.audit-delete-modes label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.audit-delete-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-main);
}

.audit-delete-hint {
    flex-basis: 100%;
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* בחירת טורניר בכניסה: כפתור המעבר ליומן הפעולות (בעלים בלבד) */
.admin-chooser-audit {
    margin-top: 10px;
}

/* יומן הפעולות: הסתרת הפעולות של המשתמש עצמו */
.audit-hide-self {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
}
