/* ============================================================
   🚀 HABITEL — Premium Gaming Hub Design System
   Version: 2.0 (2025-2026)
   
   Design principles:
   • Dark-first, deep space background
   • Liquid gradients + glassmorphism 2.0
   • Micro-animations on every interaction
   • Large typography with letter-spacing
   • Bento-grid card layout
   • AI-glow neomorphic accents
   ============================================================ */

/* ==============================
   🎨 DESIGN TOKENS
   ============================== */
:root {
    /* Primitives — Purple Core */
    --primary-50: #f6edff;
    --primary-100: #e6dcff;
    --primary-200: #d7a6ff;
    --primary-300: #b884ff;
    --primary-400: #9b62ff;
    --primary-500: #7e3df0;
    --primary-600: #6406cd;
    --primary-700: #4b00ab;
    --primary-800: #360089;
    --primary-900: #130039;

    /* Warm amber accent */
    --secondary-50: #fff0d2;
    --secondary-200: #ffb841;
    --secondary-300: #ef9800;
    --secondary-500: #ac5a00;
    --secondary-700: #6c1c00;

    /* Neutrals */
    --gray-50: #f0f6fe;
    --gray-200: #bdcfe9;
    --gray-300: #9eafc8;
    --gray-400: #8090a8;
    --gray-500: #63738a;
    --gray-600: #47566c;
    --gray-700: #2d3b50;
    --gray-800: #152235;
    --gray-900: #060b14;
    --gray-950: #000002;

    /* Status */
    --success: #00b341;
    --success-bg: rgba(0, 179, 65, 0.12);
    --destructive: #ff4538;
    --destructive-bg: rgba(255, 69, 56, 0.12);
    --warning: #ff9f0a;
    --warning-bg: rgba(255, 159, 10, 0.12);

    /* ═════ Semantic Surface ═════ */
    --bg-deep: #000002;
    --bg-surface: rgba(6, 11, 20, 0.92);
    --bg-card: rgba(21, 34, 53, 0.45);
    --bg-card-hover: rgba(45, 59, 80, 0.45);
    --bg-elevated: rgba(6, 11, 20, 0.96);
    --bg-input: rgba(21, 34, 53, 0.6);

    --border-default: rgba(45, 59, 80, 0.5);
    --border-soft: rgba(45, 59, 80, 0.25);
    --border-glow: rgba(126, 61, 240, 0.35);
    --border-ai: rgba(155, 98, 255, 0.3);

    /* Text */
    --text-primary: #f0f6fe;
    --text-secondary: #8090a8;
    --text-muted: #47566c;
    --text-on-primary: #ffffff;

    /* ═════ Shadows & Glows ═════ */
    --shadow-card: 0 4px 32px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.3);
    --shadow-elevated: 0 8px 48px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-input: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    --glow-primary: 0 0 24px rgba(126, 61, 240, 0.25);
    --glow-primary-strong: 0 0 40px rgba(126, 61, 240, 0.35);
    --glow-ai: 0 0 24px rgba(155, 98, 255, 0.3);
    --glow-win: 0 0 24px rgba(0, 179, 65, 0.25);

    /* ═════ Animations ═════ */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 150ms;
    --duration-normal: 300ms;
    --duration-slow: 500ms;

    /* ═════ Shapes ═════ */
    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 28px;

    /* ═════ Typography ═════ */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ==============================
   🌌 RESET & BASE
   ============================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Liquid gradient background — animate slowly */
body::before {
    content: '';
    position: fixed;
    inset: -100%;
    background:
        radial-gradient(ellipse 60% 50% at 20% 20%, rgba(126, 61, 240, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 50% 60% at 80% 80%, rgba(239, 152, 0, 0.04) 0%, transparent 60%),
        radial-gradient(ellipse 70% 40% at 50% 50%, rgba(6, 11, 20, 0.6) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
    animation: liquidShift 30s ease-in-out infinite alternate;
}

@keyframes liquidShift {
    0%   { transform: translate(0, 0) rotate(0deg) scale(1); }
    25%  { transform: translate(-3%, 2%) rotate(1deg) scale(1.02); }
    50%  { transform: translate(2%, -1%) rotate(-0.5deg) scale(1.01); }
    75%  { transform: translate(-1%, 3%) rotate(0.5deg) scale(1.03); }
    100% { transform: translate(3%, -2%) rotate(-1deg) scale(1.01); }
}

/* Grain texture overlay (subtle) */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

/* ==============================
   📐 LAYOUT
   ============================== */
.app-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 32px 20px 48px;
    position: relative;
    z-index: 1;
}

@media (max-width: 480px) {
    .app-container { padding: 20px 14px 40px; }
}

/* ==============================
   🔤 TYPOGRAPHY
   ============================== */
.app-title {
    text-align: center;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.75px;
    margin-bottom: 6px;
    line-height: 1.2;
}

.app-title .gradient-text {
    background: linear-gradient(135deg, #d7a6ff 0%, #7e3df0 40%, #9b62ff 60%, #ffb841 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-title .no-fill { -webkit-text-fill-color: var(--text-primary); }

.app-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 400;
    margin-bottom: 32px;
    letter-spacing: 0.2px;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 14px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

/* ==============================
   🃏 CARDS — Glassmorphism 2.0
   ============================== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 24px;
    margin-bottom: 16px;
    transition: all var(--duration-normal) var(--ease-smooth);
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

/* Subtle glass shine on top of cards */
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
    pointer-events: none;
}

.card:hover {
    border-color: rgba(126, 61, 240, 0.25);
    transform: translateY(-1px);
    box-shadow: var(--shadow-card), 0 0 16px rgba(126, 61, 240, 0.08);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.card-header .card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(100, 6, 205, 0.3);
}

.card-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

/* ==============================
   🎴 BENTO GAME CARD
   ============================== */
.game-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-xl);
    padding: 20px 24px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out-expo);
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 18px;
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(126, 61, 240, 0.03) 0%, transparent 60%);
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-smooth);
}

.game-card:hover {
    border-color: var(--border-glow);
    transform: translateX(6px) scale(1.005);
    box-shadow: var(--shadow-card), var(--glow-primary);
}

.game-card:hover::before { opacity: 1; }

.game-card:active {
    transform: translateX(3px) scale(0.995);
}

.game-card-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.game-card-icon::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, transparent 50%);
    pointer-events: none;
}

.game-card-body { flex: 1; min-width: 0; }

.game-card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}

.game-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.game-card-arrow {
    color: var(--text-muted);
    font-size: 22px;
    transition: transform var(--duration-normal) var(--ease-out-expo), color var(--duration-fast) var(--ease-smooth);
    flex-shrink: 0;
}

.game-card:hover .game-card-arrow {
    transform: translateX(6px);
    color: var(--primary-400);
}

.game-card-features {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.game-card-features .feature-tag {
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 100px;
    background: rgba(126, 61, 240, 0.08);
    color: var(--primary-300);
    font-weight: 600;
    border: 1px solid rgba(126, 61, 240, 0.12);
    letter-spacing: 0.3px;
}

.game-card-features .feature-tag.ai-tag {
    background: linear-gradient(135deg, rgba(155, 98, 255, 0.12), rgba(126, 61, 240, 0.08));
    color: #c9a6ff;
    border-color: rgba(155, 98, 255, 0.2);
}

/* ==============================
   🎛️ FORM ELEMENTS
   ============================== */
.form-group { margin-bottom: 14px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

select, input, .input-like {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    font-family: var(--font-sans);
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1.5px solid var(--border-soft);
    border-radius: var(--radius-md);
    outline: none;
    transition: all var(--duration-fast) var(--ease-smooth);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='9' viewBox='0 0 14 9' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L7 7.5L13 1.5' stroke='%238090a8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
}

select:focus, input:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px rgba(126, 61, 240, 0.15), var(--shadow-input);
    background: rgba(21, 34, 53, 0.8);
}

select:hover { border-color: rgba(126, 61, 240, 0.4); }

select option {
    background: var(--gray-900);
    color: var(--text-primary);
    padding: 8px;
}

/* ==============================
   🔘 BUTTONS — Premium
   ============================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 22px;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-smooth);
    text-decoration: none;
    position: relative;
    overflow: hidden;
    letter-spacing: -0.1px;
}

/* Glass shine overlay on buttons */
.btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 100%);
    pointer-events: none;
    border-radius: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: var(--text-on-primary);
    box-shadow: 0 4px 20px rgba(126, 61, 240, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(126, 61, 240, 0.45);
}

.btn-primary:active { transform: translateY(0) scale(0.99); }

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1.5px solid var(--border-soft);
    backdrop-filter: blur(12px);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary-500);
    transform: translateY(-1px);
}

.btn-ai {
    background: linear-gradient(135deg, #7e3df0 0%, #5222a0 50%, #764ba2 100%);
    color: #fff;
    box-shadow: 0 4px 20px rgba(118, 75, 162, 0.3);
    animation: aiPulse 3s ease-in-out infinite;
}

@keyframes aiPulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(118, 75, 162, 0.3); }
    50% { box-shadow: 0 4px 30px rgba(155, 98, 255, 0.5), 0 0 40px rgba(126, 61, 240, 0.1); }
}

.btn-ai:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 36px rgba(118, 75, 162, 0.5), 0 0 50px rgba(126, 61, 240, 0.15);
}

.btn-ai:active { transform: translateY(0); }

.btn-sm {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    width: auto;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* Link-style button (subtle) */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    padding: 8px 14px;
    width: auto;
    border: none;
}

.btn-ghost::after { display: none; }

.btn-ghost:hover {
    color: var(--primary-300);
    background: rgba(126, 61, 240, 0.06);
}

/* ==============================
   ⚡ DIVIDER
   ============================== */
.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-default), transparent);
}

/* ==============================
   🔙 BACK / NAVIGATION
   ============================== */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--duration-fast) var(--ease-smooth);
    margin-bottom: 16px;
    backdrop-filter: blur(12px);
}

.back-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--primary-500);
    transform: translateX(-2px);
}

.back-btn:active { transform: translateX(0); }

/* ==============================
   ⚠️ TOAST NOTIFICATIONS
   ============================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 14px 22px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    backdrop-filter: blur(24px) saturate(1.3);
    -webkit-backdrop-filter: blur(24px) saturate(1.3);
    box-shadow: var(--shadow-elevated);
    animation: toastSlideIn 0.4s var(--ease-spring);
    max-width: 380px;
    border: 1px solid;
}

.toast.error {
    background: var(--destructive-bg);
    border-color: rgba(255, 69, 56, 0.25);
    color: var(--destructive);
}

.toast.info {
    background: rgba(126, 61, 240, 0.12);
    border-color: rgba(126, 61, 240, 0.2);
    color: var(--primary-300);
}

.toast.success {
    background: var(--success-bg);
    border-color: rgba(0, 179, 65, 0.2);
    color: var(--success);
}

@keyframes toastSlideIn {
    0% { transform: translateX(120%) scale(0.85); opacity: 0; }
    60% { transform: translateX(-8%) scale(1.02); opacity: 1; }
    100% { transform: translateX(0) scale(1); opacity: 1; }
}

.toast.out {
    animation: toastSlideOut 0.3s var(--ease-smooth) forwards;
}

@keyframes toastSlideOut {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(120%); opacity: 0; }
}

/* ==============================
   💫 LOADING SPINNER
   ============================== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    color: var(--text-muted);
    font-size: 14px;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid rgba(126, 61, 240, 0.12);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==============================
   📋 EMPTY STATE
   ============================== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
    display: block;
}

.empty-state p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* ==============================
   📱 ONBOARDING (No Auth)
   ============================== */
.onboarding-icon {
    display: block;
    text-align: center;
    font-size: 64px;
    margin-bottom: 20px;
}

.onboarding-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-soft);
}

.onboarding-step:last-child { border-bottom: none; }

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(126, 61, 240, 0.3);
}

.step-content { flex: 1; }

.step-content strong {
    display: block;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.step-content p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Placement success */
.placement-success {
    display: none;
    background: var(--success-bg);
    border: 1px solid rgba(0, 179, 65, 0.2);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    color: var(--success);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    animation: fadeIn 0.4s var(--ease-smooth);
}

@keyframes fadeIn {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ==============================
   📱 RESPONSIVE
   ============================== */
@media (max-width: 480px) {
    .app-title { font-size: 26px; }
    .card {
        padding: 18px;
        border-radius: var(--radius-lg);
    }
    .game-card {
        padding: 16px 18px;
        border-radius: var(--radius-lg);
    }
    .game-card-icon { width: 48px; height: 48px; font-size: 24px; }
    .toast {
        max-width: calc(100vw - 32px);
        font-size: 13px;
        padding: 12px 18px;
    }
    select, input { padding: 12px 14px; font-size: 14px; }
    .btn { padding: 12px 18px; font-size: 14px; }
}
