: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: 2rem;
}

.header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeInDown 1s 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: 0.5rem;
}

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

.roster-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
}

.uma-card-container {
    background: transparent;
    cursor: pointer;
    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;
}

.uma-card-container:hover .uma-card {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.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;
}

.uma-card:hover .card-glow {
    opacity: 1;
}

.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-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.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);
}

.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);
}

/* 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: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);
}
