/* ============================================
   HabitFlow - Main Stylesheet
   ============================================ */

:root {
    --bg-primary: #0B1220;
    --bg-secondary: #111827;
    --bg-card: #1a2332;
    --bg-card-hover: #1e2a3a;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --accent-blue: #3B82F6;
    --accent-purple: #6D28D9;
    --accent-cyan: #22D3EE;
    --accent-green: #10B981;
    --accent-red: #EF4444;
    --accent-yellow: #F59E0B;
    --accent-orange: #F97316;
    --border-color: rgba(59, 130, 246, 0.2);
    --glow-blue: 0 0 20px rgba(59, 130, 246, 0.3);
    --glow-cyan: 0 0 20px rgba(34, 211, 238, 0.3);
    --glow-purple: 0 0 20px rgba(109, 40, 217, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Orbitron', sans-serif;
}

/* Light mode */
[data-theme="light"] {
    --bg-primary: #F1F5F9;
    --bg-secondary: #E2E8F0;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8FAFC;
    --text-primary: #0F172A;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --border-color: rgba(37, 99, 235, 0.2);
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-cyan);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-cyan);
}

/* ============================================
   TOPBAR / NAVBAR
   ============================================ */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(11, 18, 32, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    transition: var(--transition);
}

[data-theme="light"] .topbar {
    background: rgba(241, 245, 249, 0.85);
}

.topbar.scrolled {
    background: rgba(11, 18, 32, 0.95);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.topbar-logo {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-right: 24px;
    letter-spacing: 1px;
}

.topbar-nav {
    display: flex;
    gap: 4px;
}

.topbar-nav a {
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

.topbar-nav a:hover,
.topbar-nav a.active {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.1);
}

.topbar-nav a.active {
    color: var(--accent-blue);
}

.topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 24px;
}

.xp-bar-container {
    width: 100%;
    max-width: 300px;
}

.xp-bar-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.xp-bar-track {
    width: 100%;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    border-radius: 4px;
    transition: width 0.8s ease;
    position: relative;
}

.xp-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: xpShimmer 2s infinite;
}

@keyframes xpShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
}

/* Spacer: hidden on desktop (topbar-center fills), shown on mobile */
.topbar-spacer {
    display: none;
    flex: 1;
}

.coins-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(245, 158, 11, 0.1);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(245, 158, 11, 0.2);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--accent-yellow);
}

.coins-display i {
    color: var(--accent-yellow);
}

.notification-bell {
    position: relative;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.notification-bell:hover {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.1);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--accent-red);
    border-radius: 50%;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
}

.profile-dropdown {
    position: relative;
}

.profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

.profile-btn:hover {
    border-color: var(--accent-blue);
}

.profile-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.profile-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    min-width: 200px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: none;
    overflow: hidden;
    z-index: 1001;
}

.profile-dropdown-menu.show {
    display: block;
}

.profile-dropdown-menu a,
.profile-dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    border: none;
    background: none;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.profile-dropdown-menu a:hover,
.profile-dropdown-menu button:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--text-primary);
}

.theme-toggle-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.theme-toggle-btn:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-top: 64px;
    padding: 24px;
    min-height: calc(100vh - 64px);
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(59, 130, 246, 0.4);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   HABIT CARDS
   ============================================ */
.habit-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.habit-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--accent-blue), var(--accent-cyan));
}

.habit-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
    box-shadow: var(--glow-blue);
}

.habit-card.completed {
    opacity: 0.7;
}

.habit-card.completed::before {
    background: var(--accent-green);
}

.habit-card.missed::before {
    background: var(--accent-red);
}

.habit-check {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    background: transparent;
    color: transparent;
    font-size: 1rem;
}

.habit-check:hover {
    border-color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
}

.habit-check.checked {
    border-color: var(--accent-green);
    background: var(--accent-green);
    color: white;
}

.habit-info {
    flex: 1;
}

.habit-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.habit-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.habit-category {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.habit-rewards {
    display: flex;
    gap: 8px;
    font-size: 0.8rem;
}

.habit-reward-xp {
    color: var(--accent-cyan);
}

.habit-reward-coins {
    color: var(--accent-yellow);
}

.habit-streak {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--accent-orange);
    font-size: 0.85rem;
    font-weight: 600;
}

.habit-actions {
    display: flex;
    gap: 8px;
}

.habit-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.habit-actions button:hover {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.1);
}

/* Card styles for marketplace */
.habit-card.card-neon {
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.habit-card.card-shadow {
    border-color: var(--accent-purple);
    box-shadow: var(--glow-purple);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), #2563EB);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--glow-blue);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

.btn-secondary:hover {
    border-color: var(--accent-blue);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #DC2626);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-glow {
    box-shadow: var(--glow-blue);
}

.btn-glow:hover {
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
}

/* ============================================
   MODALS
   ============================================ */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
}

.btn-close {
    filter: invert(1);
}

[data-theme="light"] .btn-close {
    filter: none;
}

/* ============================================
   MARKETPLACE
   ============================================ */
.marketplace-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.marketplace-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: var(--transition);
    position: relative;
}

.marketplace-item:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: var(--glow-blue);
}

.marketplace-item.owned {
    border-color: var(--accent-green);
}

.marketplace-item.equipped {
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}

.item-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    color: var(--accent-blue);
}

.item-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
}

.item-description {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.item-price {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 600;
    color: var(--accent-yellow);
    margin-bottom: 12px;
}

.item-level-req {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.item-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.item-badge.owned-badge {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

.item-badge.equipped-badge {
    background: rgba(34, 211, 238, 0.2);
    color: var(--accent-cyan);
}

/* ============================================
   CALENDAR - Compact Dashboard Widget
   ============================================ */
.calendar-widget {
    max-width: 100%;
    overflow: hidden;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-header-cell {
    text-align: center;
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 4px 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    color: var(--text-primary);
    padding: 6px 2px;
    min-height: 32px;
}

.calendar-cell:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.08);
}

.calendar-cell.today {
    border-color: var(--accent-cyan);
    font-weight: 700;
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.2);
}

.calendar-cell.completed {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

.calendar-cell.missed {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

.calendar-cell.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-yellow);
}

.calendar-cell.freeze {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.calendar-cell.empty {
    cursor: default;
}

.calendar-cell.before-creation {
    opacity: 0.25;
    cursor: default;
    color: var(--text-muted);
}

/* Calendar legend */
.calendar-legend {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.75rem;
    flex-wrap: wrap;
}

.calendar-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.calendar-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    display: inline-block;
}

.calendar-legend-dot.completed { background: rgba(16, 185, 129, 0.4); }
.calendar-legend-dot.missed { background: rgba(239, 68, 68, 0.3); }
.calendar-legend-dot.pending { background: rgba(245, 158, 11, 0.25); }
.calendar-legend-dot.freeze { background: rgba(56, 189, 248, 0.35); border: 1px solid rgba(56, 189, 248, 0.4); }
.calendar-legend-dot.before { background: rgba(100, 116, 139, 0.2); }

/* Calendar navigation */
.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.calendar-nav-title {
    font-family: var(--font-display);
    font-size: 1rem;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

/* Responsive calendar */
@media (max-width: 768px) {
    .calendar-cell {
        font-size: 0.65rem;
        border-radius: 4px;
    }
    .calendar-header-cell {
        font-size: 0.6rem;
    }
}

/* ============================================
   STATISTICS
   ============================================ */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

/* ============================================
   NOTIFICATION PANEL
   ============================================ */
.notification-panel {
    position: fixed;
    top: 64px;
    right: 0;
    width: 360px;
    max-height: calc(100vh - 80px);
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: -4px 0 30px rgba(0,0,0,0.3);
    z-index: 1001;
    overflow-y: auto;
    display: none;
    padding: 16px;
}

.notification-panel.show {
    display: block;
}

.notification-item {
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border-left: 3px solid var(--accent-blue);
    background: rgba(59, 130, 246, 0.05);
    transition: var(--transition);
}

.notification-item.unread {
    border-left-color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.05);
}

.notification-item.success {
    border-left-color: var(--accent-green);
}

.notification-item.warning {
    border-left-color: var(--accent-yellow);
}

.notification-item.error {
    border-left-color: var(--accent-red);
}

.notification-message {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   ONBOARDING
   ============================================ */
.onboarding-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
}

.onboarding-step {
    display: none;
}

.onboarding-step.active {
    display: block;
}

.onboarding-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.purpose-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.purpose-option {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.purpose-option:hover {
    border-color: var(--accent-blue);
}

.purpose-option.selected {
    border-color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.1);
    box-shadow: var(--glow-cyan);
}

.purpose-option i {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--accent-blue);
}

.purpose-option span {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
}

.template-option {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 12px;
}

.template-option:hover {
    border-color: var(--accent-blue);
}

.template-option.selected {
    border-color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.1);
}

/* ============================================
   ADMIN
   ============================================ */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
}

.admin-card h5 {
    color: var(--accent-blue);
    margin-bottom: 12px;
    font-size: 0.95rem;
}

/* ============================================
   LEVEL UP POPUP
   ============================================ */
.level-up-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.level-up-card {
    background: var(--bg-card);
    border: 2px solid var(--accent-cyan);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    box-shadow: 0 0 60px rgba(34, 211, 238, 0.3);
    animation: scaleIn 0.5s ease;
}

.level-up-label {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--accent-cyan);
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.level-up-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.level-up-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.3); }
    50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.6); }
}

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

.animate-slide-up {
    animation: slideUp 0.5s ease forwards;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 992px) {
    /* ── Mobile topbar: ☰  [          ] coins streak freeze 🔔 🌙 avatar ── */

    /* Hide desktop-only elements */
    .topbar-nav    { display: none; }
    .topbar-center { display: none; }
    .topbar-left   { display: none; }
    .topbar-spacer { display: none; }

    /* Topbar itself: flex row, items vertically centred */
    .topbar {
        padding: 0 12px;
        height: 56px;
        justify-content: flex-start; /* hamburger anchors left */
        gap: 0;
    }

    /* Hamburger: leftmost, fixed width */
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        margin-right: 0;
    }

    /* Right group: push ALL the way to the right edge */
    .topbar-right {
        margin-left: auto;   /* ← this is the key: fills all remaining space */
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }

    /* Compact pill badges */
    .coins-display {
        padding: 5px 9px;
        font-size: 0.8rem;
        gap: 4px;
    }

    .streak-display-topbar,
    .freeze-display-topbar {
        padding: 5px 9px;
        font-size: 0.8rem;
    }

    /* Bell & moon compact */
    .notification-bell {
        padding: 5px 8px;
        font-size: 1rem;
    }
    .theme-toggle-btn {
        padding: 5px 8px;
        font-size: 1rem;
    }

    /* Avatar only — hide name & chevron */
    .profile-btn-name,
    .profile-btn-chevron { display: none; }
    .profile-btn {
        padding: 4px;
        gap: 0;
        background: none;
        border: none;
    }

    /* Mobile slide-down nav */
    .mobile-nav {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 8px 24px rgba(0,0,0,0.3);
        padding: 12px;
        z-index: 999;
    }
    .mobile-nav.show { display: block; }
    .mobile-nav a {
        display: block;
        padding: 10px 16px;
        color: var(--text-secondary);
        border-radius: var(--radius-sm);
        margin-bottom: 4px;
        font-size: 0.9rem;
    }
    .mobile-nav a:hover,
    .mobile-nav a.active {
        background: rgba(59, 130, 246, 0.1);
        color: var(--text-primary);
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 16px;
    }

    .marketplace-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .notification-panel {
        width: 100%;
    }

    .habit-card {
        flex-wrap: wrap;
    }

    .habit-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 576px) {
    .main-content {
        margin-top: 56px;
        min-height: calc(100vh - 56px);
    }

    /* Tighter padding on small phones */
    .topbar-right { gap: 4px; }

    .coins-display {
        padding: 4px 7px;
        font-size: 0.75rem;
    }

    .streak-display-topbar,
    .freeze-display-topbar {
        padding: 4px 7px;
        font-size: 0.75rem;
    }

    .page-title { font-size: 1.2rem; }
    .marketplace-grid { grid-template-columns: 1fr; }
    .purpose-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Extra small — very tight phones */
@media (max-width: 400px) {
    .coins-display i {
        font-size: 0.75rem;
    }

    .streak-display-topbar span,
    .freeze-display-topbar span {
        font-size: 0.72rem;
    }

    .coins-display {
        padding: 3px 5px;
        font-size: 0.72rem;
    }

    /* Hide coins text on very small, keep icon only */
    .coins-display .coins-amount {
        max-width: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px 10px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.mobile-menu-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
}

/* ============================================
   MISC
   ============================================ */
.text-accent-blue { color: var(--accent-blue); }
.text-accent-cyan { color: var(--accent-cyan); }
.text-accent-green { color: var(--accent-green); }
.text-accent-red { color: var(--accent-red); }
.text-accent-yellow { color: var(--accent-yellow); }
.text-accent-purple { color: var(--accent-purple); }
.text-muted { color: var(--text-muted); }

.bg-glow-blue { box-shadow: var(--glow-blue); }
.bg-glow-cyan { box-shadow: var(--glow-cyan); }
.bg-glow-purple { box-shadow: var(--glow-purple); }

.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.cooldown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    z-index: 10;
}

.system-message {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--accent-cyan);
    letter-spacing: 2px;
    text-align: center;
}

/* Toast custom styles */
.toast-container {
    z-index: 9999;
}

/* Category colors */
.cat-exercise { color: #10B981; }
.cat-wellness { color: #06B6D4; }
.cat-journaling { color: #8B5CF6; }
.cat-discipline { color: #3B82F6; }
.cat-learning { color: #F59E0B; }
.cat-productivity { color: #EF4444; }
.cat-creativity { color: #EC4899; }
.cat-mental-health { color: #14B8A6; }
.cat-custom { color: #94A3B8; }

/* ============================================
   PROFILE CARD + PET DISPLAY
   ============================================ */
.dashboard-profile-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    margin-bottom: 24px;
    align-items: start;
}

.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    gap: 20px;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.profile-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: var(--glow-blue);
}

.profile-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    position: relative;
}

.profile-frame-neon {
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.4), inset 0 0 15px rgba(34, 211, 238, 0.1);
    border: 2px solid var(--accent-cyan);
}

.profile-frame-shadow {
    box-shadow: 0 0 15px rgba(109, 40, 217, 0.4), inset 0 0 15px rgba(109, 40, 217, 0.1);
    border: 2px solid var(--accent-purple);
}

.profile-frame-gold {
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.4), inset 0 0 15px rgba(245, 158, 11, 0.1);
    border: 2px solid var(--accent-yellow);
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-username {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-title-badge {
    font-size: 0.7rem;
    color: var(--accent-cyan);
    font-style: italic;
    background: rgba(34, 211, 238, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.profile-stats-row {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.profile-stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.profile-stat-item i {
    font-size: 0.75rem;
}

.profile-stat-item .stat-val {
    font-weight: 600;
    color: var(--text-primary);
}

.profile-xp-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.profile-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    border-radius: 3px;
    transition: width 0.8s ease;
}

.profile-xp-text {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Pet display area */
.pet-area {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    min-height: 100px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    position: relative;
}

.pet-sprite {
    font-size: 3rem;
    animation: petFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.3));
}

@keyframes petFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.pet-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 4px;
}

/* Profile modal */
.profile-modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
}

.profile-modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.profile-modal-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.profile-modal-section h6 {
    color: var(--accent-blue);
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.profile-modal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.85rem;
}

.profile-modal-item .label {
    color: var(--text-secondary);
}

.profile-modal-item .value {
    color: var(--text-primary);
    font-weight: 500;
}

.cosmetic-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cosmetic-chip {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.cosmetic-chip.equipped {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.1);
}

@media (max-width: 768px) {
    /* ============================================
       MOBILE DASHBOARD — Rule of Proximity,
       Whitespace & Visual Hierarchy fixes
       ============================================ */

    /* 1. Profile + Pet: stack vertically, merge into one unified card */
    .dashboard-profile-row {
        grid-template-columns: 1fr;
        gap: 0;
        margin-bottom: 20px;
    }

    /* Profile card gets a full-width unified look */
    .profile-card {
        border-radius: var(--radius) var(--radius) 0 0;
        border-bottom: none;
        padding: 20px 20px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* Avatar + name row side by side */
    .profile-card > .profile-avatar-large {
        position: absolute;
        top: 20px;
        right: 20px;
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
    }

    .profile-info {
        width: 100%;
        padding-right: 64px; /* room for avatar */
    }

    /* Username: larger, primary hierarchy */
    .profile-username {
        font-size: 1.2rem;
        font-weight: 700;
        margin-bottom: 6px;
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Stats row: tighten spacing — related items grouped closely */
    .profile-stats-row {
        gap: 12px;
        margin-top: 6px;
        margin-bottom: 10px;
    }

    .profile-stat-item {
        font-size: 0.82rem;
        gap: 4px;
        background: rgba(255,255,255,0.04);
        padding: 4px 8px;
        border-radius: 6px;
    }

    .profile-stat-item .stat-val {
        font-size: 0.9rem;
    }

    /* XP bar: give it breathing room */
    .profile-xp-bar {
        height: 8px;
        margin-top: 10px;
        border-radius: 4px;
    }

    .profile-xp-text {
        font-size: 0.72rem;
        margin-top: 4px;
        color: var(--text-muted);
        letter-spacing: 0.01em;
    }

    /* Pet area: seamlessly attached below profile card */
    .pet-area {
        min-width: unset;
        min-height: unset;
        width: 100%;
        border-radius: 0 0 var(--radius) var(--radius);
        border-top: 1px solid rgba(255,255,255,0.06);
        padding: 14px 20px;
        flex-direction: row;
        justify-content: flex-start;
        gap: 14px;
        background: rgba(255,255,255,0.02);
    }

    .pet-sprite {
        font-size: 2.2rem;
        animation: petFloat 3s ease-in-out infinite;
    }

    .pet-name {
        font-size: 0.78rem;
        color: var(--text-secondary);
        text-align: left;
        margin-top: 2px;
    }

    /* 2. Stats grid — 2x2 on mobile, not 4x1 */
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* Stat cards: tighten padding, emphasize hierarchy */
    .stat-card {
        padding: 16px 14px;
    }

    .stat-value {
        font-size: 1.6rem;
        line-height: 1.1;
    }

    .stat-label {
        font-size: 0.75rem;
        margin-top: 6px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
    }

    /* 3. Cards: full bleed padding on mobile */
    .card {
        border-radius: 12px;
    }

    /* 4. Page header: tighter on mobile */
    .page-header {
        margin-bottom: 20px;
    }

    .page-title {
        font-size: 1.3rem;
    }

    .page-subtitle {
        font-size: 0.82rem;
        margin-top: 2px;
    }
}
