:root {
    --bg-color: #0d1117;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --glass-bg: rgba(22, 27, 34, 0.6);
    --glass-border: rgba(48, 54, 61, 0.5);
    
    --rank-1: #ffd700;
    --rank-2: #c0c0c0;
    --rank-3: #cd7f32;
    --hit-green: #2ea043;
    --danger: #f85149;
    
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}

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

body.dark-theme {
    background-color: var(--bg-color);
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    padding-bottom: 4rem;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s infinite ease-in-out alternate;
}
.blob-1 {
    width: 600px; height: 600px;
    background: radial-gradient(circle, #3fb950 0%, transparent 70%);
    top: -200px; left: -200px;
}
.blob-2 {
    width: 500px; height: 500px;
    background: radial-gradient(circle, #2f81f7 0%, transparent 70%);
    bottom: -100px; right: -100px;
    animation-delay: -5s;
}
@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 50px) scale(1.1); }
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
}
@media (max-width: 480px) {
    .container { padding: 0 0.75rem; }
}

header {
    text-align: center;
    padding: 3rem 0;
}
.logo {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.logo span {
    color: var(--accent);
    -webkit-text-fill-color: var(--accent);
}
.tagline {
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-size: 1.1rem;
}

/* Glassmorphism utility */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* Selection Panel */
.selection-panel {
    margin-bottom: 2rem;
}
.selection-panel h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Search Area */
.search-container {
    position: relative;
    margin-bottom: 2rem;
}

.filters-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}
@media (max-width: 768px) {
    .filters-row {
        flex-direction: column;
        gap: 0.5rem;
    }
}
.filters-row select {
    flex: 1;
    padding: 0.75rem 1rem;
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}
.filters-row select:focus {
    outline: none;
    border-color: var(--accent);
}

#team-search {
    width: 100%;
    padding: 1rem 1.5rem;
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-family: 'Outfit', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}
#team-search:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0; right: 0;
    max-width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background: #161b22;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    z-index: 10;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.search-results.hidden { display: none; }

.search-item {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    transition: background 0.2s;
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: rgba(88, 166, 255, 0.1); }
.search-item.empty { cursor: default; color: var(--text-secondary); text-align: center; }

.si-program { font-size: 0.85rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.25rem; }
.si-team { font-size: 1.1rem; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.si-badge { font-size: 0.8rem; background: rgba(255,255,255,0.1); padding: 2px 6px; border-radius: 4px; font-weight: normal; }
.si-div { color: var(--accent); opacity: 0.8; }

/* Locked Teams */
.locked-teams-container {
    margin-bottom: 2rem;
}
.locked-teams-container h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}
.locked-teams-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.empty-roster {
    color: var(--text-secondary);
    font-style: italic;
    width: 100%;
}

.locked-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 1rem;
    position: relative;
    width: calc(50% - 0.5rem);
    animation: fadeIn 0.3s ease;
}
@media (max-width: 768px) {
    .locked-card { width: 100%; }
}
@media (min-width: 900px) {
    .locked-card { width: calc(33.333% - 0.67rem); }
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.lc-program { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; }
.lc-team { font-weight: 600; margin-bottom: 0.2rem; font-size: 1.1rem; }
.lc-div { font-size: 0.8rem; color: var(--accent); opacity: 0.8; margin-bottom: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-stats { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-secondary); border-top: 1px solid rgba(255,255,255,0.05); padding-top: 0.5rem;}
.lc-stats strong { color: var(--accent); }

.remove-btn {
    position: absolute;
    top: 8px; right: 8px;
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 1.2rem; cursor: pointer;
    line-height: 1;
    transition: color 0.1s;
}
.remove-btn:hover { color: var(--danger); }

/* Buttons */
.actions {
    display: flex; gap: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 1.5rem;
}
@media (max-width: 480px) {
    .actions { flex-direction: column; }
}
button {
    font-family: inherit;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    flex: 1;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}
.btn-secondary:hover { background: rgba(255,255,255,0.05); }

/* Results Section */
.results-container.hidden { display: none; }
.results-title {
    margin: 2rem 0 1rem;
    font-size: 1.5rem;
    display: flex; align-items: center; gap: 0.5rem;
}

.prediction-table {
    width: 100%;
    border-collapse: collapse;
}
.prediction-table th {
    text-align: left;
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.9rem;
}
.prediction-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    vertical-align: middle;
}
.prediction-row { cursor: pointer; transition: background 0.2s; }
.prediction-row:last-child td { border-bottom: none; }
.prediction-row:hover { background: rgba(255,255,255,0.05); }

/* History Dropdown */
.history-row.hidden { display: none; }
.history-row td { padding: 0; border-bottom: 1px solid rgba(255,255,255,0.1); }
.history-content { padding: 1.5rem 2rem; background: rgba(0,0,0,0.2); box-shadow: inset 0 2px 5px rgba(0,0,0,0.2); }
.history-content h4 { margin-bottom: 1rem; color: var(--accent); font-family: 'Orbitron', sans-serif; letter-spacing: 1px; font-size: 0.9rem;}
.history-inner-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.history-inner-table th { text-align: left; padding: 0.5rem; color: var(--text-secondary); border-bottom: 1px solid rgba(255,255,255,0.05); font-weight: normal; }
.history-inner-table td { padding: 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.02); }
.history-inner-table tr:last-child td { border-bottom: none; }

.rank-badge {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-family: 'Orbitron', sans-serif;
    background: rgba(255,255,255,0.1);
}
.rank-1 { background: rgba(255, 215, 0, 0.2); color: var(--rank-1); border: 1px solid var(--rank-1); box-shadow: 0 0 10px rgba(255, 215, 0, 0.3); }
.rank-2 { background: rgba(192, 192, 192, 0.2); color: var(--rank-2); border: 1px solid var(--rank-2); }
.rank-3 { background: rgba(205, 127, 50, 0.2); color: var(--rank-3); border: 1px solid var(--rank-3); }

.team-program { font-size: 0.75rem; color: var(--text-secondary); text-transform: uppercase; }
.team-name { font-weight: 600; font-size: 1.1rem; }

.score-cell { font-family: 'Orbitron', monospace; font-size: 1.1rem; }
.power-cell { color: var(--accent); font-weight: bold; font-size: 1.25rem; }
.subtext { font-size: 0.75rem; color: var(--text-secondary); font-family: 'Outfit'; }

.badge {
    display: inline-block;
    padding: 2px 6px; border-radius: 4px; font-size: 0.7rem;
    font-family: 'Outfit', sans-serif; margin-left: 0.5rem;
    vertical-align: middle;
}
.rank-change {
    position: absolute;
    top: 50%;
    right: -5px;
    transform: translateY(-50%);
    font-size: 0.7rem;
    font-weight: bold;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    gap: 1px;
}
.rank-change.up { color: var(--hit-green); }
.rank-change.down { color: var(--danger); }

.hit-badge {
    background: rgba(46, 160, 67, 0.2);
    color: #3fb950;
    border: 1px solid var(--hit-green);
}

/* Mobile Responsiveness Improvements */
@media (max-width: 768px) {
    header { padding: 2rem 0; }
    .logo { font-size: 2rem; }
    .tagline { font-size: 0.95rem; padding: 0 1rem; }
    
    .glass-card { padding: 1.25rem; }
    
    .prediction-table { min-width: 650px; }
    .table-wrapper { 
        overflow-x: auto; 
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .logo { font-size: 1.6rem; }
    .glass-card { padding: 0.75rem; }
    .selection-panel h2, .results-title { font-size: 1.1rem; }
    
    .si-team { font-size: 1rem; flex-wrap: wrap; gap: 0.5rem; }
    .team-name { font-size: 0.95rem; }
    .power-cell { font-size: 1.1rem; }
    .score-cell { font-size: 0.95rem; }
}

/* Loading Spinner */
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
