:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.3);
    --gold: #fbbf24;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    background-image: 
        radial-gradient(at 0% 0%, rgba(15, 23, 42, 1) 0, transparent 50%), 
        radial-gradient(at 50% 100%, rgba(30, 58, 138, 0.5) 0, transparent 50%), 
        radial-gradient(at 100% 0%, rgba(88, 28, 135, 0.4) 0, transparent 50%);
    background-attachment: fixed;
    line-height: 1.6;
}

.app-container {
    max-width: 95%;
    margin: 0 auto;
    padding: 1rem;
}

.header {
    text-align: center;
    margin-bottom: 1rem;
    animation: fadeInDown 0.8s ease-out;
}


.header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(to right, #38bdf8, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0px;
}

.header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.roster-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 1000px;
    margin: 0 auto;
    animation: fadeInUp 0.8s ease-out;
}


.uma-card-container {
    background: transparent;
    cursor: default;
    min-width: 0;
}

.uma-card {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
}



.card-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 0%, var(--accent-glow), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}



.card-content {
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

.uma-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 1rem;
}

.uma-name {
    font-size: 1.5rem;
    font-weight: 600;
}

.uma-rank {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--gold);
}

.stat-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.uma-sparks h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sparks-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.sparks-list li {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.3rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    transition: background 0.2s;
    text-align: center;
}

.spark-blue {
    background: rgba(56, 189, 248, 0.2) !important;
    border-color: rgba(56, 189, 248, 0.4) !important;
}

.spark-pink {
    background: rgba(244, 114, 182, 0.2) !important;
    border-color: rgba(244, 114, 182, 0.4) !important;
}

.spark-green {
    background: rgba(74, 222, 128, 0.2) !important;
    border-color: rgba(74, 222, 128, 0.4) !important;
}

.sparks-list li:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Loading State */
.loading-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

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

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tree UI Integration */
.tree-ui-container {
    background: #0f1115;
    border-radius: 16px;
    padding: 2rem;
    margin: 20px auto;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    border: 1px solid rgba(255,255,255,0.05);
}

.tree-top-row {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.tree-node {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.avatar-wrapper {
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    border: none;
    box-shadow: none;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-card {
    border: none;
    box-shadow: none;
}

.avatar-placeholder {
    font-size: 2rem;
    color: rgba(255,255,255,0.2);
}

.affinity-pill {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #f43f5e;
    color: white;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    z-index: 10;
    white-space: nowrap;
}

.remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-weight: bold;
    z-index: 10;
}

.tree-middle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.tree-legacies {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
}

.legacy-branch {
    display: flex;
    align-items: center;
    gap: 15px;
}

.tree-connector {
    width: 30px;
    height: 2px;
    background: rgba(255,255,255,0.2);
    position: relative;
}

.conn-a { background: #38bdf8; }
.conn-b { background: #f472b6; }

.sub-legacies {
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
}

.conn-a::after {
    content: '';
    position: absolute;
    right: -15px;
    top: -33px;
    width: 15px;
    height: 72px;
    border-top: 2px solid #38bdf8;
    border-bottom: 2px solid #38bdf8;
    border-left: 2px solid #38bdf8;
}
.conn-b::before {
    content: '';
    position: absolute;
    left: -15px;
    top: -35px;
    width: 15px;
    height: 72px;
    border-top: 2px solid #f472b6;
    border-bottom: 2px solid #f472b6;
    border-right: 2px solid #f472b6;
}

.sub-avatar {
    width: 60px;
    height: 60px;
}

.tree-score-panel {
    text-align: center;
    transition: opacity 0.3s;
}

.score-rank {
    font-size: 3.5rem;
    color: var(--gold);
    display: inline-block;
    vertical-align: middle;
}

.score-total {
    font-size: 4.5rem;
    font-weight: 700;
    color: white;
    display: inline-block;
    vertical-align: middle;
    margin-left: 10px;
}

.score-breakdown {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 10px;
}

.score-breakdown span {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
}

.trainee-select {
    margin-top: 15px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    font-family: inherit;
}

/* Horizontal Card Layout */
.hz-card {
    display: flex;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
    color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}


.hz-left-col {
    padding: 10px;
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.hz-mini-tree {
    display: flex;
    align-items: center;
    position: relative;
    width: auto;
    padding-bottom: 15px;
}

.hz-main-avatar {
    width: 70px;
    height: 70px;
    position: relative;
    z-index: 2;
}

.hz-rank-badge {
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gold);
    color: #000;
    font-weight: 700;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
    white-space: nowrap;
}

.pedigree-lines {
    position: relative;
    width: 25px;
    height: 60px;
    margin-left: 5px;
    margin-right: 5px;
}
.pedigree-lines .line-h {
    position: absolute; height: 2px; width: 12px; top: 50%; left: 0; transform: translateY(-50%);
    background: rgba(255,255,255,0.3);
}
.pedigree-lines .line-v {
    position: absolute; width: 2px; height: 100%; top: 0; left: 12px;
    background: rgba(255,255,255,0.3);
}
.pedigree-lines .line-h-top {
    position: absolute; height: 2px; width: 13px; top: 0; left: 12px;
    background: rgba(255,255,255,0.3);
}
.pedigree-lines .line-h-bot {
    position: absolute; height: 2px; width: 13px; bottom: 0; left: 12px;
    background: rgba(255,255,255,0.3);
}

.light-lines .line-h, .light-lines .line-v, .light-lines .line-h-top, .light-lines .line-h-bot {
    background: rgba(255,255,255,0.15);
}

.sub-legacies-col {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 80px;
}

.hz-sub-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
}

.hz-right-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 15px;
}

.hz-top-bar {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    gap: 15px;
    flex-wrap: nowrap;
    overflow: hidden;
}

.hz-id-section {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 120px;
}

.hz-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
}

.hz-card-id {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
}

.hz-main-sparks {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.hz-main-sparks li { margin: 0; padding: 2px 6px; font-size: 0.75rem; }

.hz-actions {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

.hz-dark-panel {
    background: rgba(0,0,0,0.4);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 5px;
    border: 1px solid rgba(255,255,255,0.05);
}

.hz-legacy-row {
    display: flex;
    align-items: center;
}

.hz-legacy-label {
    min-width: 120px;
    font-size: 0.85rem;
    color: var(--gold);
    font-weight: 600;
}

.hz-legacy-sparks {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}
.hz-legacy-sparks li { padding: 2px 6px; font-size: 0.75rem; margin: 0; }

.hz-bottom-bar {
    display: flex;
    gap: 20px;
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 10px;
}

.hz-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.05);
    padding: 6px 14px;
    border-radius: 20px;
    white-space: nowrap;
    height: 26px;
}

.hz-badge-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.hz-badge-val {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
}

/* Simulator Top - Legacy Boxes */
.simulator-top {
    margin-bottom: 40px;
}

.legacy-selectors-row {
    display: flex;
    gap: 20px;
    align-items: stretch;
    justify-content: center;
}

.legacy-selector-box {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--card-border);
    padding: 20px;
    position: relative;
    width: 250px;
}

.box-a { border-color: rgba(56, 189, 248, 0.4); box-shadow: 0 4px 15px rgba(56, 189, 248, 0.1); }
.box-b { border-color: rgba(244, 114, 182, 0.4); box-shadow: 0 4px 15px rgba(244, 114, 182, 0.1); }
.avatar-a { box-shadow: 0 0 20px 2px rgba(56, 189, 248, 0.4); }
.avatar-b { box-shadow: 0 0 20px 2px rgba(244, 114, 182, 0.4); }
.avatar-trainee { 
    box-shadow: 0 0 20px 2px rgba(74, 222, 128, 0.4); 
    border: 2px dashed #4ade80;
}

.box-badge {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    z-index: 10;
}
.badge-a { background: #38bdf8; }
.badge-b { background: #f472b6; }

.mini-pedigree {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
}

.main-legacy-avatar {
    width: 80px;
    height: 80px;
}

.score-box {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-color: rgba(251, 191, 36, 0.3);
}
/* Grade Potential Box */
.nextgen-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    border-color: rgba(168, 85, 247, 0.3);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.08);
    width: 250px;
    transition: opacity 0.3s;
    overflow: hidden;
}

.nextgen-tree {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 10px;
}

.nextgen-child {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.nextgen-child-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.nextgen-child-label {
    background: rgba(74, 222, 128, 0.15);
    border: 1px dashed rgba(74, 222, 128, 0.4);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #4ade80;
    font-weight: 600;
}

.nextgen-connector {
    width: 20px;
    height: 2px;
    background: rgba(255, 255, 255, 0.15);
    position: relative;
}

.nextgen-connector::after {
    content: '';
    position: absolute;
    right: 0;
    top: -15px;
    width: 2px;
    height: 32px;
    background: rgba(255, 255, 255, 0.15);
}

.nextgen-gps {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.nextgen-gp {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nextgen-gp::before {
    content: '';
    display: block;
    width: 8px;
    height: 2px;
    background: rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.nextgen-gp-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.nextgen-gp-placeholder {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 600;
}

.nextgen-gp-bonus {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gold);
    min-width: 16px;
}

.nextgen-total {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.nextgen-total-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.nextgen-total-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffffff;
}

.nextgen-schedule {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    width: 100%;
}

.schedule-upload-btn {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid rgba(168, 85, 247, 0.4);
    background: rgba(168, 85, 247, 0.08);
    color: rgba(168, 85, 247, 0.9);
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
}

.schedule-upload-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    color: white;
}

.schedule-upload-btn.loaded {
    border-color: rgba(74, 222, 128, 0.4);
    color: rgba(74, 222, 128, 0.9);
    background: rgba(74, 222, 128, 0.08);
}

.deck-selector {
    width: 100%;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(168, 85, 247, 0.3);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a855f7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 22px;
}

.deck-selector option {
    background: #1e1b2e;
    color: white;
}

.set-legacy-btn {
    padding: 6px 12px; 
    border-radius: 8px; 
    border: 1px solid var(--card-border); 
    background: rgba(0,0,0,0.4); 
    color: white; 
    cursor: pointer; 
    transition: 0.2s;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.set-legacy-btn:hover {
    background: rgba(255,255,255,0.1);
}

.card-selected-a {
    border-color: #38bdf8 !important;
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.3) !important;
}

.card-selected-b {
    border-color: #f472b6 !important;
    box-shadow: 0 4px 20px rgba(244, 114, 182, 0.3) !important;
}

.highlight-btn-a {
    background: rgba(56, 189, 248, 0.3) !important;
    border-color: #38bdf8 !important;
    color: white !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5) !important;
}

.highlight-btn-b {
    background: rgba(244, 114, 182, 0.3) !important;
    border-color: #f472b6 !important;
    color: white !important;
    box-shadow: 0 0 10px rgba(244, 114, 182, 0.5) !important;
}

/* Mode Toggle Buttons */
.mode-btn {
    padding: 6px 16px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: rgba(0,0,0,0.4);
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
}
.mode-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}
.mode-btn.active {
    background: rgba(56, 189, 248, 0.25);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.mode-btn.gold {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(251, 191, 36, 0.05);
}

.mode-btn.gold:hover {
    background: rgba(251, 191, 36, 0.15);
    color: white;
    border-color: var(--gold);
}

.upload-btn-gold {
    padding: 6px 16px;
    border-radius: 8px;
    border: 1px solid var(--gold);
    background: rgba(251, 191, 36, 0.05);
    color: var(--gold);
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
}

.upload-btn-gold:hover {
    background: rgba(251, 191, 36, 0.15);
    color: white;
}

.clear-data-btn {
    padding: 6px 16px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
}

.clear-data-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: white;
}

/* Inspiration Toggle Button */
.insp-btn {
    padding: 6px 18px;
    border-radius: 20px;
    border: 1px solid var(--card-border);
    background: rgba(0,0,0,0.4);
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
}
.insp-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.insp-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}
.insp-btn.active {
    background: rgba(251, 191, 36, 0.2);
    border-color: var(--gold);
    color: white;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

/* ========================================
   Trainee Card (top selector area)
   ======================================== */
.trainee-card {
    position: relative;
    display: flex;
    margin: 0 auto 30px;
    width: 680px;
    min-height: 120px;
    padding: 12px 20px;
    align-items: center;
    gap: 20px;
}

.remove-btn-trainee {
    display: none;
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    z-index: 15;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.trainee-avatar-container {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
    position: relative;
}

.trainee-avatar-img {
    display: none;
    border-radius: 50%;
    width: 100%;
    height: 100%;
}

.trainee-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.2);
    border-radius: 50%;
    font-size: 2rem;
    color: rgba(255,255,255,0.3);
}

.trainee-select-prompt {
    flex: 1;
    text-align: left;
}

.trainee-select-prompt h3 {
    color: var(--gold);
    margin-bottom: 4px;
}

.trainee-select-prompt p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.aptitude-content {
    display: none;
    flex-direction: column;
    flex: 1;
    align-items: center;
}

.aptitude-row {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
    margin-bottom: 6px;
    flex-wrap: nowrap;
}

.aptitude-row:last-child {
    margin-bottom: 0;
}

.aptitude-label {
    color: var(--gold);
    font-weight: 700;
    font-size: 0.85rem;
    width: 60px;
    text-align: right;
    flex-shrink: 0;
}

.aptitude-badges-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    flex: 1;
}

/* Aptitude Badges & Rank Colors (was embedded <style> in index.html) */
.apt-badge {
    position: relative;
    background: rgba(0,0,0,0.4);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    display: flex;
    gap: 8px;
    align-items: center;
    border: 1px solid rgba(255,255,255,0.1);
    flex-wrap: nowrap;
    font-family: 'Outfit', sans-serif;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.apt-badge small { color: var(--text-primary); font-weight: 400; }
.apt-badge b { font-size: 1.1rem; font-family: 'Outfit', sans-serif; font-weight: 700; color: #fff; }
.rank-S b { color: #fbbf24; text-shadow: 0px 0px 6px #ef4444; }
.rank-A b { color: #ea580c; }
.rank-B b { color: #ec4899; }
.rank-C b { color: #4ade80; }
.rank-D b { color: #38bdf8; }
.rank-E b { color: #c084fc; }
.rank-F b { color: #7c3aed; }
.rank-G b { color: #64748b; }

.boost-tag {
    position: absolute;
    top: -7px;
    right: -2px;
    color: #22c55e !important;
    font-size: 0.85rem !important;
    font-weight: 800 !important;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
    z-index: 5;
    font-family: 'Outfit', sans-serif;
    border: none !important;
    background: none !important;
}

.avatar-placeholder, .avatar-wrapper img { cursor: pointer; }

.apt-badge-sm {
    padding: 2px 8px;
    font-size: 0.8rem;
}

/* ========================================
   Character Selection Modal
   ======================================== */
.trainee-grid-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.trainee-grid-modal-inner {
    background: var(--bg-dark);
    border: 1px solid var(--accent);
    border-radius: 16px;
    padding: 20px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.trainee-grid-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.trainee-grid-modal-header h2 {
    color: var(--gold);
    font-size: 1.5rem;
    margin: 0;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.filter-input-wrap {
    position: relative;
    margin-bottom: 15px;
}

.trainee-grid-filter {
    padding: 10px;
    padding-right: 35px;
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 1rem;
    box-sizing: border-box;
}

.clear-filter-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 1.5rem;
    cursor: pointer;
    display: none;
    padding: 0;
    line-height: 1;
}

.trainee-grid-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
    overflow-y: auto;
    padding-right: 10px;
    padding-bottom: 20px;
    align-items: center;
    justify-content: center;
}

/* ========================================
   Legacy Selector Pedigree (top area)
   ======================================== */
.mini-pedigree-layout {
    display: flex;
    justify-content: center;
    gap: 15px;
    align-items: center;
    min-height: 180px;
}

.main-legacy-avatar-wrap {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 50%;
}

.compat-badge {
    display: none;
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: #fbbf24;
    border: 1px solid #fbbf24;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: bold;
    color: #000;
    padding: 2px 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    z-index: 10;
    white-space: nowrap;
    min-width: max-content;
}

.compat-badge-sm {
    display: none;
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: #fbbf24;
    border: 1px solid #fbbf24;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: bold;
    color: #000;
    padding: 2px 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    z-index: 10;
    white-space: nowrap;
    min-width: max-content;
}

.pedigree-bracket-line {
    border-top: 2px solid rgba(255,255,255,0.3);
    border-bottom: 2px solid rgba(255,255,255,0.3);
    border-left: 2px solid rgba(255,255,255,0.3);
    width: 15px;
    height: 90px;
    position: relative;
}

.bracket-h-connector {
    position: absolute;
    top: 50%;
    left: -15px;
    width: 15px;
    height: 2px;
    background: rgba(255,255,255,0.3);
    transform: translateY(-50%);
}

.sub-legacies-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-content: center;
}

.sub-avatar-wrap {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 50%;
}

.sub-placeholder {
    color: rgba(255,255,255,0.2);
    font-size: 1.5rem;
    text-align: center;
}

.main-placeholder {
    color: rgba(255,255,255,0.2);
    font-size: 2rem;
    text-align: center;
}

.sub-remove-btn {
    display: none;
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    border: none;
    cursor: pointer;
    font-size: 12px;
}

.main-remove-btn {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    border: none;
    cursor: pointer;
}

/* Score Panel */
.score-panel-title {
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.score-detail-label {
    color: var(--text-secondary);
}

/* ========================================
   Roster Controls Grid
   ======================================== */
.roster-controls {
    animation: fadeInUp 0.8s ease-out;
    margin: 0 auto 20px;
    max-width: 800px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 4px 10px;
    align-items: stretch;
}

.mode-toggle-bar-layout {
    grid-column: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    box-sizing: border-box;
}

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

.toggle-group-right {
    display: flex;
    gap: 15px;
    align-items: center;
}

.toggle-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
}

.toggle-btns {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Search tooltip */
.search-tooltip-wrap {
    grid-column: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-tooltip-wrap:hover .search-tooltip {
    display: block !important;
}

.search-tooltip-btn {
    background: var(--card-bg);
    border: 1px solid var(--gold);
    color: var(--gold);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-weight: bold;
    cursor: help;
}

.search-tooltip {
    display: none;
    position: absolute;
    top: 110%;
    left: 0;
    background: #0f172a;
    border: 1px solid var(--card-border);
    padding: 15px;
    border-radius: 8px;
    width: 340px;
    text-align: left;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.8);
    font-size: 0.9rem;
    line-height: 1.4;
}

.search-tooltip strong {
    color: var(--gold);
    display: block;
    margin-bottom: 5px;
}

.search-tooltip p { margin: 0 0 8px 0; }
.search-tooltip ul { padding-left: 15px; margin: 0 0 10px 0; color: var(--text-secondary); }

.roster-filter-wrap {
    grid-column: 2;
    position: relative;
}

.roster-filter-input {
    width: 100%;
    padding: 12px;
    padding-right: 40px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    color: var(--text-primary);
    font-size: 1rem;
    box-sizing: border-box;
}

.clear-roster-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 1.5rem;
    cursor: pointer;
    display: none;
    padding: 0;
    line-height: 1;
}

.upload-label {
    grid-column: 3;
    margin: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    padding: 0 20px;
    min-width: 130px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.upload-label::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: rgba(239, 68, 68, 0.4);
    border-radius: inherit;
    transition: none;
    pointer-events: none;
    z-index: 0;
}

.upload-label.hold-progress::after {
    width: 100%;
    transition: width 1s linear;
}

.upload-label.hold-triggered {
    border-color: #ef4444 !important;
    color: #ef4444 !important;
}

/* Trigger Rates Box */
.trigger-rates-box {
    display: none;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 20px;
    max-width: 800px;
    margin: 10px auto 15px;
    text-align: left;
}

.trigger-rates-list {
    justify-content: center;
    display: flex;
    flex-wrap: wrap;
}

/* Loading State */
.loading-state-dim {
    opacity: 0.6;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast-msg {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--accent);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    animation: slideInRight 0.3s ease-out;
    transition: opacity 0.3s ease-out;
    font-weight: 600;
}

/* Owner Badge (Borrow Indicator) */
.badge-owner {
    background: rgba(14, 165, 233, 0.15);
    border: 1px solid rgba(14, 165, 233, 0.4);
}
.badge-owner .hz-badge-label {
    color: #38bdf8;
    font-weight: 700;
}
.owner-name-val {
    color: #fff;
    font-weight: 700;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========================================
   Roster card template inline overrides
   ======================================== */
.hz-left-col-layout {
    position: relative;
    flex-direction: column;
    justify-content: flex-start;
}

.hz-actions-layout {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.hz-top-bar-clean {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 5px;
}

.hz-stat-badges-layout {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
    overflow: hidden;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.hz-left-badges-layout {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    justify-content: flex-start;
    margin-top: 10px;
    width: 100%;
}

.hz-badge-row {
    display: flex;
    flex-direction: row;
    gap: 5px;
    width: 100%;
}
.hz-badge-row .hz-badge {
    flex: 1;
}

/* ========================================
   JS-generated DOM element styles
   (moved from cssText in app.js)
   ======================================== */
.modal-chara-clear {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.2);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    border: 2px solid #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.modal-chara-wrap {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    overflow: visible;
    cursor: pointer;
    border: 2px solid transparent;
    transition: 0.2s;
}

.modal-chara-wrap:hover {
    border-color: #4ade80;
}

.modal-chara-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.modal-affinity-badge {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: #fbbf24;
    color: #000;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 1px 6px;
    border-radius: 10px;
    border: 1px solid #000;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 5;
}

.spark-highlight {
    box-shadow: inset 0 0 0 1px rgba(255, 235, 100, 0.6);
}

.badge-blue {
    background: rgba(56, 189, 248, 0.2);
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.badge-blue-highlight {
    background: rgba(56, 189, 248, 0.2);
    border: 2px solid rgba(250, 204, 21, 0.8);
    box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.4);
}

.badge-pink {
    background: rgba(244, 114, 182, 0.2);
    border: 1px solid rgba(244, 114, 182, 0.4);
}

.badge-pink-highlight {
    background: rgba(244, 114, 182, 0.2);
    border: 2px solid rgba(250, 204, 21, 0.8);
    box-shadow: inset 0 0 0 1px rgba(250, 204, 21, 0.4);
}

.totals-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.totals-list li {
    padding: 2px 6px;
    font-size: 0.75rem;
    margin: 0;
}

/* Spark rate % */
.spark-pct {
    font-weight: bold;
    opacity: 0.9;
}

/* Trigger rate list item text */
.trigger-rate-empty {
    width: 100%;
    text-align: center;
    color: var(--text-secondary);
    background: transparent;
    border: none;
}

/* ========================================
   Calculator page styles
   (moved from embedded <style> in calculator.html)
   ======================================== */
.nav-links {
    text-align: center;
    margin-bottom: 20px;
}
.nav-links a {
    color: var(--accent);
    text-decoration: none;
    margin: 0 15px;
    font-weight: 600;
}
.nav-links a:hover {
    text-decoration: underline;
}

.calc-form {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    max-width: 800px;
    margin: 0 auto;
}

.calc-form select, .calc-form button {
    width: 100%;
    padding: 10px;
    margin: 10px 0 20px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: rgba(0,0,0,0.3);
    color: white;
    font-family: inherit;
}

.calc-form button {
    background: var(--accent);
    color: black;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.calc-form button:hover {
    background: #2dd4bf;
}

.calc-results {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid var(--card-border);
    max-width: 800px;
    margin: 2rem auto 0;
    text-align: center;
}

.rank-circle {
    font-size: 5rem;
    line-height: 1;
    color: var(--gold);
    margin-bottom: 1rem;
}

.breakdown {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 1.5rem;
}

.breakdown div {
    background: rgba(255,255,255,0.05);
    padding: 1rem 2rem;
    border-radius: 12px;
}
