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

:root {
    --primary: #1e40af;
    --primary-dark: #1e3a8a;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #0f172a;
    --card: white;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 25px 60px rgba(0,0,0,0.3);
    --gradient-start: #fbbf24;
    --gradient-mid: #f59e0b;
    --gradient-end: #1e40af;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    flex: 1;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    background: linear-gradient(125deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));
    background-size: 400% 400%;
    animation: gradientFlow 15s ease infinite;
}

@keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    25% { background-position: 100% 50%; }
    50% { background-position: 0% 50%; }
    75% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes floatBlob {
    0%, 100% { transform: translate(0, 0) scale(1) rotate(0deg); }
    20% { transform: translate(20px, -30px) scale(1.1) rotate(5deg); }
    40% { transform: translate(-20px, 20px) scale(0.9) rotate(-5deg); }
    60% { transform: translate(30px, 10px) scale(1.05) rotate(3deg); }
    80% { transform: translate(-15px, -20px) scale(0.95) rotate(-3deg); }
}

.bg-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: floatBlob 18s ease-in-out infinite;
}

.blob-1 { width: 300px; height: 300px; top: -10%; left: -8%; background: var(--gradient-start); animation-duration: 20s; }
.blob-2 { width: 250px; height: 250px; bottom: -12%; right: -10%; background: var(--gradient-end); animation-duration: 22s; animation-delay: -4s; }
.blob-3 { width: 200px; height: 200px; top: 40%; left: 50%; transform: translateX(-50%); background: var(--gradient-mid); animation-duration: 24s; animation-delay: -8s; }
.blob-4 { width: 180px; height: 180px; top: 10%; right: 15%; background: var(--gradient-start); animation-duration: 20s; animation-delay: -2s; }
.blob-5 { width: 220px; height: 220px; bottom: 20%; left: 8%; background: var(--gradient-end); animation-duration: 26s; animation-delay: -6s; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    flex: 1;
    width: 100%;
    position: relative;
    z-index: 1;
    min-height: calc(100vh - 56px);
}

@media (max-width: 768px) {
    .container { padding: 1rem; }
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.navbar {
    background: white;
    backdrop-filter: blur(30px);
    color: white;
    padding: 0 1rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    width: 100%;
    max-width: 100vw;
}

.nav-brand {
    overflow: hidden;
    white-space: nowrap;
}

.nav-brand a {
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 700;
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: #334155;
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: background 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
    background: #f1f5f9;
    color: #1e293b;
    text-decoration: none;
}

.nav-profile {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.profile-pic {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.profile-name {
    color: #334155;
    font-size: 0.9rem;
    font-weight: 500;
}

.profile-dropdown {
    position: relative;
}

.profile-dropdown a {
    color: #334155;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.profile-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 160px;
    padding: 0.5rem 0;
    z-index: 1000;
}

.profile-content.open {
    display: block;
}

.profile-content a {
    display: block;
    padding: 0.5rem 1rem;
    color: #334155;
    text-decoration: none;
    font-size: 0.85rem;
}

.profile-content a:hover {
    background: #f8fafc;
}

.nav-user-mobile {
    display: none;
}

.menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    margin-left: 0.5rem;
}

.menu-toggle span {
    width: 22px;
    height: 2px;
    background: #334155;
    margin: 3px 0;
    transition: 0.3s;
    border-radius: 2px;
}

.nav-group {
    position: relative;
}

.nav-group-toggle {
    cursor: pointer;
    user-select: none;
}

.nav-group-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 180px;
    padding: 0.5rem 0;
    z-index: 1000;
}

.nav-group-content.open {
    display: block;
}

.nav-group-content a {
    display: block;
    padding: 0.5rem 1rem;
    color: #334155;
    text-decoration: none;
    font-size: 0.85rem;
}

.nav-group-content a:hover {
    background: #f8fafc;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
    
    .nav-links {
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 1rem;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .nav-links.open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-links a {
        color: #334155;
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        border-radius: 6px;
        margin-bottom: 0.25rem;
    }
    
    .nav-links a:hover {
        background: #f8fafc;
    }
    
    .btn-ghost {
        background: white;
        color: #334155;
        border: 1px solid #e2e8f0;
    }
    
    .nav-user-mobile {
        display: flex;
        align-items: center;
    }
    
    .nav-group-content {
        position: static;
        box-shadow: none;
        border: none;
        background: #f8fafc;
        margin-top: 0.25rem;
        border-radius: 6px;
    }
}

.card {
    background: white;
    backdrop-filter: blur(30px);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.2rem;
    margin-bottom: 1.5rem;
    max-width: 700px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 768px) {
    .card {
        padding: 1rem;
        margin: 0 0.5rem 1.5rem;
        max-width: 100%;
    }
}

@media (max-width: 400px) {
    .card {
        margin: 0;
    }
}

.card-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #1e293b;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: white;
}

.btn:hover { text-decoration: none; box-shadow: 0 2px 4px rgba(0,0,0,0.15); }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; }
.btn-secondary { background: var(--secondary); }
.btn-secondary:hover { background: #475569; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

table {
    width: 100%;
    border-collapse: collapse;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
}

.table th, .table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    color: #1e293b;
}

.table th {
    background: white;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.table tr:hover td { background: #f8fafc; }

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: #334155;
}

.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: white;
    transition: border 0.15s;
    color: #1e293b;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.3);
}

textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { padding: 0.5rem 0.75rem; }

.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.color-swatch {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
}

.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: var(--text); }

.color-swatch input[type="radio"] { display: none; }

.alert {
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid;
}

.alert-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

.actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.house-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 0.75rem;
    border: 1px solid #e2e8f0;
}

.house-color-badge {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--primary);
    border: 1px solid #e2e8f0;
}

.rank-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: #64748b;
    width: 36px;
    text-align: center;
}

.flex-1 { flex: 1; }
.flex { display: flex; }
.space-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 1rem; }

.match-bracket {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.match-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
}

.match-card .round-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.match-participants {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.match-house {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border: 1px solid #e2e8f0;
}

.match-house.winner {
    font-weight: 600;
    border-left: 3px solid var(--success);
}

.text-muted { color: #64748b; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

.footer {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 1rem;
    text-align: center;
    color: #64748b;
    font-size: 0.875rem;
    margin-top: auto;
}

.login-container {
    max-width: 320px;
    margin: 1.5rem auto;
    padding: 0.75rem;
    display: flex;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
}

.login-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.28rem;
    margin-bottom: 1.5rem;
    width: 100%;
    box-sizing: border-box;
}

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo h1 {
    color: #1e293b;
    font-size: 1.4rem;
    font-weight: 700;
}

.login-logo p {
    color: #64748b;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e2e8f0;
    transition: background 0.3s, transform 0.3s;
}

.step-dot.active {
    background: var(--primary);
    transform: scale(1.3);
    box-shadow: 0 0 12px rgba(30, 64, 175, 0.5);
}

.step-line {
    width: 40px;
    height: 2px;
    background: #e2e8f0;
}

.user-greeting {
    text-align: center;
    margin-bottom: 1.5rem;
}

.user-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    margin: 0 auto 0.75rem;
}

.flex-row {
    display: flex;
    gap: 0.5rem;
}

.btn-ghost {
    background: #f8fafc;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.btn-ghost:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.form-group label {
    color: #334155;
}

.form-control {
    background: #f8fafc;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .nav-links { gap: 0.25rem; }
    .nav-links a { padding: 0.3rem 0.5rem; font-size: 0.8rem; }
    .match-bracket { grid-template-columns: 1fr; }
    .container { padding: 1rem; max-width: 100%; }
    .card { padding: 1.2rem; }
    .navbar { padding: 0 1rem; }
    .login-container { margin: 1rem; padding: 0.5rem; justify-content: center; max-width: 100%; }
    .login-card { padding: 1.28rem; }
}

@media (max-width: 480px) {
    .navbar { height: 48px; }
    .nav-brand a { font-size: 1rem; }
    .nav-links a { font-size: 0.75rem; padding: 0.2rem 0.4rem; }
    table th, table td { padding: 0.5rem; font-size: 0.85rem; }
    .btn { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
    .login-card { padding: 1.2rem; }
}