:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --accent-hover: #0284c7;
    --border-color: rgba(255, 255, 255, 0.1);
    --error-color: #f43f5e;
    --success-color: #10b981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
    user-select: none;
}

body {
    background: #0f172a;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(8px, 3vw, 15px);
    position: relative;
    overflow-x: hidden;
    width: 100%;
}

/* Fullscreen Video Background */
#bg-video {
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -2;
    transform: translate(-50%, -50%);
    object-fit: cover;
    filter: brightness(0.45) contrast(1.1);
    pointer-events: none;
}

/* Dynamic Animated Fallback Background */
body::before {
    content: "";
    position: fixed;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background: url('/static/background.png') no-repeat center center / cover;
    filter: blur(12px) brightness(0.45);
    z-index: -1;
    animation: bgPulse 15s ease-in-out infinite alternate;
}

@keyframes bgPulse {
    0% {
        transform: scale(1) rotate(0deg);
    }

    100% {
        transform: scale(1.08) rotate(1deg);
    }
}

.app-container {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-sizing: border-box;
}

.app-header {
    text-align: center;
    margin-top: 5px;
    padding: 0 10px;
}

.logo-icon {
    font-size: clamp(35px, 8vw, 45px);
    margin-bottom: 6px;
}

.app-header h1 {
    font-size: clamp(18px, 5vw, 22px);
    font-weight: 800;
    color: #ffffff;
    word-break: break-word;
}

.subtitle {
    font-size: clamp(12px, 3.5vw, 14px);
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}

.card-box {
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: clamp(14px, 4vw, 22px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.step-view {
    display: none;
    flex-direction: column;
    animation: fadeIn 0.3s ease-in-out;
    width: 100%;
}

.step-view.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-badge {
    align-self: flex-start;
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent-color);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 10px;
}

.card-box h2 {
    font-size: clamp(16px, 4.5vw, 18px);
    font-weight: 700;
    margin-bottom: 6px;
    word-break: break-word;
}

.description {
    font-size: clamp(12px, 3.5vw, 13px);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 0 12px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.input-group:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.input-icon {
    font-size: 18px;
    margin-left: 8px;
    flex-shrink: 0;
}

.input-group input {
    width: 100%;
    padding: 12px 0;
    background: transparent;
    border: none;
    outline: none;
    color: #ffffff;
    font-size: clamp(14px, 4vw, 16px);
    direction: ltr;
    text-align: right;
}

.btn {
    width: 100%;
    padding: 13px;
    border-radius: 14px;
    border: none;
    font-size: clamp(14px, 4vw, 15px);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-sizing: border-box;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: #ffffff;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.mt-10 {
    margin-top: 10px;
}

.mt-15 {
    margin-top: 15px;
}

.spinner-circle {
    width: 38px;
    height: 38px;
    border: 3.5px solid rgba(56, 189, 248, 0.2);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spinCircle 0.8s linear infinite;
    margin: 0 auto 10px auto;
}

@keyframes spinCircle {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader {
    width: 18px;
    height: 18px;
    border: 2px solid #ffffff;
    border-bottom-color: transparent;
    border-radius: 50%;
    display: none;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.alert {
    padding: 12px;
    border-radius: 12px;
    font-size: 13px;
    margin-top: 15px;
    text-align: center;
}

.alert.hidden {
    display: none;
}

.alert.error {
    background: rgba(244, 63, 94, 0.2);
    color: var(--error-color);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.alert.success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.success-icon {
    font-size: 50px;
    text-align: center;
    margin-bottom: 10px;
}

.user-card {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 14px;
    margin: 12px 0;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-card span {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent-color);
}

.app-footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    padding-bottom: 5px;
}

/* Media Queries for Ultra-narrow Popups (Telegram Desktop Popup) */
@media (max-width: 360px) {
    body {
        padding: 5px;
    }

    .card-box {
        padding: 12px 10px;
        border-radius: 14px;
    }

    .btn {
        padding: 11px;
        font-size: 13px;
    }
}