/* === Tournament Generator === */
.tn-container {
    max-width: 860px;
    margin: 0 auto;
    font-family: 'Segoe UI', system-ui, sans-serif
}

/* Tabs */
.tn-tabs {
    display: flex;
    gap: 0;
    margin: 0 0 16px;
    border-bottom: 2px solid #e5e7eb
}

.tn-tab {
    flex: 1;
    text-align: center;
    padding: 12px;
    font-size: 14px;
    font-weight: 700;
    color: #6b7280;
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all .2s
}

.tn-tab.active {
    color: #0ea5e9;
    border-bottom-color: #0ea5e9
}

.tn-tab:hover {
    color: #0ea5e9;
    background: #f0f9ff
}

.tn-tab-panel {
    display: none
}

.tn-tab-panel.active {
    display: block
}

/* Input area */
.tn-input-section {
    padding: 16px;
    margin: 0 0 12px
}

.tn-textarea {
    width: 100%;
    min-height: 110px;
    padding: 12px;
    border: 2px solid #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    color: #1f2937;
    background: #fff;
    box-sizing: border-box;
    line-height: 1.6
}

.tn-textarea:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, .12)
}

.tn-textarea::placeholder {
    color: #9ca3af
}

.tn-input-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    flex-wrap: wrap;
    gap: 8px
}

.tn-member-count {
    font-size: 14px;
    color: #4b5563;
    font-weight: 600
}

.tn-member-count strong {
    color: #0ea5e9
}

.tn-input-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap
}

.tn-small-btn {
    background: #f0f9ff;
    border: 1.5px solid #0ea5e9;
    color: #0ea5e9;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap
}

.tn-small-btn:hover {
    background: #0ea5e9;
    color: #fff
}

.tn-small-btn.tn-danger {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2
}

.tn-small-btn.tn-danger:hover {
    background: #ef4444;
    color: #fff
}

/* Settings */
.tn-settings {
    padding: 0 16px;
    margin-bottom: 12px
}

.tn-setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap
}

.tn-setting-label {
    font-size: 14px;
    color: #1f2937;
    font-weight: 600;
    min-width: 90px
}

.tn-text-input {
    padding: 6px 12px;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    color: #1f2937;
    background: #fff;
    flex: 1;
    max-width: 300px
}

.tn-text-input:focus {
    outline: none;
    border-color: #0ea5e9
}

.tn-check {
    display: flex;
    gap: 20px;
    flex-wrap: wrap
}

.tn-check label {
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 600
}

.tn-check input[type="checkbox"] {
    accent-color: #0ea5e9;
    width: 16px;
    height: 16px
}

/* Generate button */
.tn-gen-wrap {
    text-align: center;
    padding: 8px 16px 16px
}

.tn-gen-btn {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #fff;
    border: none;
    padding: 14px 40px;
    font-size: 17px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all .2s;
    box-shadow: 0 4px 15px rgba(14, 165, 233, .3);
    letter-spacing: .5px
}

.tn-gen-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, .4)
}

.tn-gen-btn:active {
    transform: translateY(0)
}

.tn-gen-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none
}

/* Canvas bracket */
.tn-bracket-wrap {
    padding: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch
}

.tn-bracket-canvas {
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    cursor: pointer
}

/* Results bar */
.tn-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    flex-wrap: wrap;
    gap: 8px
}

.tn-results-title {
    font-size: 16px;
    font-weight: 800;
    color: #1f2937
}

.tn-results-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap
}

.tn-act-btn {
    background: #f0f9ff;
    border: 1.5px solid #0ea5e9;
    color: #0ea5e9;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s
}

.tn-act-btn:hover {
    background: #0ea5e9;
    color: #fff
}

.tn-act-btn.copied {
    background: #10b981;
    border-color: #10b981;
    color: #fff
}

/* Winner */
.tn-winner-banner {
    text-align: center;
    padding: 16px;
    margin: 12px 16px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 800;
    color: #92400e
}

/* League table */
.tn-league-wrap {
    overflow-x: auto;
    padding: 0 16px;
    margin-bottom: 16px
}

.tn-league-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 400px
}

.tn-league-table th,
.tn-league-table td {
    border: 1px solid #e5e7eb;
    padding: 6px 8px;
    text-align: center;
    font-size: 13px
}

.tn-league-table th {
    background: #f0f9ff;
    color: #0ea5e9;
    font-weight: 700;
    font-size: 12px
}

.tn-league-table td.tn-diag {
    background: #f3f4f6
}

.tn-league-table td.tn-name {
    font-weight: 700;
    color: #1f2937;
    text-align: left;
    padding-left: 12px;
    background: #fafafa
}

.tn-score-input {
    width: 24px;
    height: 24px;
    border: 1.5px solid #d1d5db;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    padding: 0
}

.tn-score-input:focus {
    outline: none;
    border-color: #0ea5e9
}

.tn-score-sep {
    margin: 0 2px;
    color: #9ca3af;
    font-size: 11px
}

/* Standings */
.tn-standings {
    margin: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden
}

.tn-standings-title {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb
}

.tn-standings-table {
    border-collapse: collapse;
    width: 100%
}

.tn-standings-table th {
    background: #f0f9ff;
    color: #0ea5e9;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 8px;
    border-bottom: 1px solid #e5e7eb
}

.tn-standings-table td {
    padding: 6px 8px;
    font-size: 13px;
    color: #1f2937;
    border-bottom: 1px solid #f0f0f0;
    text-align: center
}

.tn-standings-table td:nth-child(2) {
    text-align: left;
    font-weight: 600
}

.tn-standings-table tr:first-child td {
    background: #fffbeb
}

.tn-standings-table .tn-rank-1 {
    color: #f59e0b;
    font-weight: 800
}

/* Security banner */
.tn-security-banner {
    display: flex;
    gap: 16px;
    padding: 16px;
    margin: 16px;
    background: #f0f9ff;
    border-radius: 12px;
    border: 2px solid #bae6fd;
    flex-wrap: wrap
}

.tn-security-item {
    flex: 1;
    min-width: 140px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #4b5563
}

.tn-security-icon {
    font-size: 22px
}

.tn-security-item strong {
    color: #1f2937;
    display: block;
    font-size: 14px
}

.tn-security-item p {
    margin: 2px 0 0;
    font-size: 12px;
    color: #6b7280
}

/* Responsive */
@media(max-width:600px) {
    .tn-setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px
    }

    .tn-setting-label {
        min-width: auto
    }

    .tn-results-bar {
        flex-direction: column;
        align-items: flex-start
    }

    .tn-security-banner {
        flex-direction: column;
        gap: 10px;
        margin: 12px 8px
    }

    .tn-gen-btn {
        width: 100%;
        padding: 14px
    }
}