/* === Team Generator === */
.tg-container {
    max-width: 800px;
    margin: 0 auto;
    font-family: 'Segoe UI', system-ui, sans-serif
}

/* Input area */
.tg-input-section {
    padding: 16px;
    margin: 0 0 12px
}

.tg-textarea {
    width: 100%;
    min-height: 120px;
    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
}

.tg-textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12)
}

.tg-textarea::placeholder {
    color: #9ca3af
}

.tg-input-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    flex-wrap: wrap;
    gap: 8px
}

.tg-member-count {
    font-size: 14px;
    color: #4b5563;
    font-weight: 600
}

.tg-member-count strong {
    color: #2563eb
}

.tg-input-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap
}

.tg-small-btn {
    background: #f0f4ff;
    border: 1.5px solid #2563eb;
    color: #2563eb;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap
}

.tg-small-btn:hover {
    background: #2563eb;
    color: #fff
}

.tg-small-btn.tg-danger {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2
}

.tg-small-btn.tg-danger:hover {
    background: #ef4444;
    color: #fff
}

/* Settings */
.tg-settings {
    padding: 0 16px;
    margin-bottom: 12px
}

.tg-setting-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap
}

.tg-setting-label {
    font-size: 14px;
    color: #1f2937;
    font-weight: 600;
    min-width: 100px
}

.tg-num-ctrl {
    display: flex;
    align-items: center;
    gap: 0
}

.tg-num-btn {
    width: 36px;
    height: 36px;
    border: 2px solid #d1d5db;
    background: #fff;
    color: #1f2937;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s
}

.tg-num-btn:first-child {
    border-radius: 8px 0 0 8px
}

.tg-num-btn:last-child {
    border-radius: 0 8px 8px 0
}

.tg-num-btn:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb
}

.tg-num-val {
    width: 48px;
    height: 36px;
    border: 2px solid #d1d5db;
    border-left: none;
    border-right: none;
    background: #fff;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: #1f2937
}

.tg-num-val:focus {
    outline: none
}

.tg-radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap
}

.tg-radio-group label {
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px
}

.tg-radio-group input[type="radio"] {
    accent-color: #2563eb
}

/* Accordion */
.tg-accordion {
    margin: 0 16px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden
}

.tg-accordion-header {
    padding: 12px 16px;
    background: #f9fafb;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    user-select: none;
    transition: background .2s
}

.tg-accordion-header:hover {
    background: #f0f4ff
}

.tg-accordion-arrow {
    transition: transform .3s;
    font-size: 12px;
    color: #6b7280
}

.tg-accordion.open .tg-accordion-arrow {
    transform: rotate(180deg)
}

.tg-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease
}

.tg-accordion.open .tg-accordion-body {
    max-height: 800px
}

.tg-opt-item {
    padding: 10px 16px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap
}

.tg-opt-item label {
    font-size: 13px;
    color: #1f2937;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600
}

.tg-opt-item input[type="checkbox"] {
    accent-color: #2563eb;
    width: 16px;
    height: 16px
}

.tg-opt-desc {
    font-size: 12px;
    color: #6b7280;
    margin-left: auto
}

/* Skill editor */
.tg-skill-editor {
    padding: 8px 16px;
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid #f0f0f0
}

.tg-skill-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 13px;
    color: #1f2937
}

.tg-skill-row .tg-name {
    flex: 1;
    min-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.tg-skill-stars {
    display: flex;
    gap: 2px
}

.tg-skill-stars span {
    cursor: pointer;
    font-size: 16px;
    color: #d1d5db;
    transition: color .15s
}

.tg-skill-stars span.active {
    color: #f59e0b
}

.tg-skill-stars span:hover {
    color: #f59e0b
}

/* Pair editor */
.tg-pair-editor {
    padding: 8px 16px;
    border-top: 1px solid #f0f0f0
}

.tg-pair-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 13px
}

.tg-pair-select {
    padding: 4px 8px;
    border: 1.5px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #1f2937;
    background: #fff;
    min-width: 80px
}

.tg-pair-select:focus {
    outline: none;
    border-color: #2563eb
}

.tg-pair-remove {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px
}

.tg-pair-add {
    font-size: 12px;
    color: #2563eb;
    cursor: pointer;
    border: none;
    background: none;
    font-weight: 600;
    padding: 4px 0
}

.tg-pair-add:hover {
    text-decoration: underline
}

/* Generate button */
.tg-gen-wrap {
    text-align: center;
    padding: 8px 16px 16px
}

.tg-gen-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    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(37, 99, 235, .3);
    letter-spacing: 0.5px
}

.tg-gen-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, .4)
}

.tg-gen-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(37, 99, 235, .3)
}

.tg-gen-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none
}

/* Results */
.tg-results {
    padding: 0 16px
}

.tg-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px
}

.tg-results-title {
    font-size: 18px;
    font-weight: 800;
    color: #1f2937
}

.tg-results-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap
}

.tg-act-btn {
    background: #f0f4ff;
    border: 1.5px solid #2563eb;
    color: #2563eb;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s
}

.tg-act-btn:hover {
    background: #2563eb;
    color: #fff
}

.tg-act-btn.copied {
    background: #10b981;
    border-color: #10b981;
    color: #fff
}

/* Team cards */
.tg-teams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px
}

.tg-team-card {
    background: #fff;
    border-radius: 12px;
    border: 1.5px solid #e5e7eb;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
    transition: transform .2s
}

.tg-team-card:hover {
    transform: translateY(-2px)
}

.tg-team-card-header {
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between
}

.tg-team-card-header .tg-team-count {
    font-size: 12px;
    font-weight: 500;
    opacity: .85
}

.tg-team-member {
    padding: 6px 14px;
    font-size: 13px;
    color: #1f2937;
    border-top: 1px solid #f5f5f5;
    display: flex;
    align-items: center;
    gap: 6px
}

.tg-team-member.tg-captain {
    font-weight: 700;
    color: #f59e0b
}

.tg-team-member .tg-captain-badge {
    font-size: 14px
}

.tg-team-avg {
    padding: 8px 14px;
    font-size: 12px;
    color: #6b7280;
    border-top: 1px solid #f0f0f0;
    text-align: right;
    font-weight: 600
}

/* Team colors */
.tg-color-0 {
    background: #2563eb
}

.tg-color-1 {
    background: #10b981
}

.tg-color-2 {
    background: #f59e0b
}

.tg-color-3 {
    background: #ef4444
}

.tg-color-4 {
    background: #8b5cf6
}

.tg-color-5 {
    background: #ec4899
}

.tg-color-6 {
    background: #14b8a6
}

.tg-color-7 {
    background: #f97316
}

/* Kanji / leader banner */
.tg-leader-banner {
    text-align: center;
    padding: 16px;
    margin: 12px 0;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    color: #92400e
}

/* History */
.tg-history {
    margin-top: 16px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid #e5e7eb
}

.tg-history-title {
    font-size: 13px;
    font-weight: 700;
    color: #4b5563;
    margin-bottom: 8px
}

.tg-history-item {
    font-size: 12px;
    color: #6b7280;
    padding: 4px 0;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: color .2s
}

.tg-history-item:hover {
    color: #2563eb
}

.tg-history-item:last-child {
    border-bottom: none
}

/* Saved lists */
.tg-saved-lists {
    margin-top: 8px
}

.tg-saved-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all .2s
}

.tg-saved-item:hover {
    border-color: #2563eb;
    background: #f0f4ff
}

.tg-saved-delete {
    color: #ef4444;
    font-size: 14px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 2px 6px
}

/* Security banner */
.tg-security-banner {
    display: flex;
    gap: 16px;
    padding: 16px;
    margin: 16px;
    background: #f0f8ff;
    border-radius: 12px;
    border: 2px solid #dbeafe;
    flex-wrap: wrap
}

.tg-security-item {
    flex: 1;
    min-width: 140px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #4b5563
}

.tg-security-icon {
    font-size: 22px
}

.tg-security-item strong {
    color: #1f2937;
    display: block;
    font-size: 14px
}

.tg-security-item p {
    margin: 2px 0 0;
    font-size: 12px;
    color: #6b7280
}

/* Animation */
.tg-team-card {
    animation: tg-card-in .4s ease both
}

@keyframes tg-card-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(.95)
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1)
    }
}

.tg-member-anim {
    animation: tg-member-in .3s ease both
}

@keyframes tg-member-in {
    from {
        opacity: 0;
        transform: translateX(-10px)
    }

    to {
        opacity: 1;
        transform: translateX(0)
    }
}

/* Responsive */
@media(max-width:600px) {
    .tg-teams-grid {
        grid-template-columns: 1fr 1fr
    }

    .tg-setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px
    }

    .tg-setting-label {
        min-width: auto
    }

    .tg-results-header {
        flex-direction: column;
        align-items: flex-start
    }

    .tg-security-banner {
        flex-direction: column;
        gap: 10px;
        margin: 12px 8px
    }

    .tg-gen-btn {
        width: 100%;
        padding: 14px
    }
}

@media(max-width:400px) {
    .tg-teams-grid {
        grid-template-columns: 1fr
    }
}